-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Towards the compiler #135
Comments
Naked functions are not allowed to have C code? That isn't good. What about the bootloader? |
Yes, see here for the definition in RISC-V and here for how microsoft treats them. This not an issue, as you can call another function that is implemented in C after you do any needed setup. The std |
The Microsoft statement does not explicitly disallow C code. But I see the point. I guess this is not a C standard, but compiler-specific. On bootloader: don't you need to start with a |
Yes, you are right about microsoft, but GCC seems to me to treat C code in naked functions as undefined behavior. I presume clang by extension does the same, but did not find any documentation for this after a quick search. Our bootloader does start with a naked function that sets up the stack using inline asm. |
But it calls C functions with C code (the call is C, not inline assembly): Line 67 in f237b5c
Is this considered OK, then? |
No, not in my opinion. That is what I was refering to earlier that I need to fix. Just like I fixed the newlib start function. |
But there you the call itself in assembler, but the bootloader does not. Could this be the issue with the bootloader? |
It definitely needs fixing. I don't think it's the current issue, as I seem to remember the bootloader failing only when downloading a program and not before. But perhaps the issue only manifests at that point but is indeed caused by |
I would propose to wrap those three functions into one, so you only need to call one function from assembler. |
Add to the list of differences between new and old compiler: The |
Not really an issue, but notes (from @Emoun) what needs to be done in the Patmos C source files and in the handbook:
Changes:
"-fpatmos-nolibsyms", "-fpatmos-noruntimelibs", "-fpatmos_link_object"
Instead, use "-c" to create object files and then call the linker directly.
Instead, call the equivalent "patmos-ld" flags using "-mllvm" prefix:
"-mpatmos-disable-stack-cache" -> "-mllvm --mpatmos-disable-stack-cache"
"-mpatmos-disable-function-splitter" -> "-mllvm --mpatmos-disable-function-splitter"
"-mpatmos-disable-vliw" -> "-mllvm --mpatmos-disable-vliw"
Note how the flags need 2 "-" instead of the previous 1.
I.e. instead of "$r1" use "r1" as clobber register.
In the inline assembly proper, registers need/allow 1 "$" only.
No other code is allowed per the C standard.
If you want to use C code in a naked function, you can manually call a non-naked function from
the inline assembly.
Notes:
Handbook says by default clang compiles to bitcode (section 8.2.1). This is wrong.
The text was updated successfully, but these errors were encountered: