This is a follow up to D48580 and D48581 which allows reserving
arbitrary general purpose registers with the exception of registers
with special purpose (X8, X16-X18, X29, X30) and registers used by LLVM
(X0, X19). This change also generalizes some of the existing logic to
rely entirely on values generated from tablegen.
Details
Diff Detail
- Repository
- rC Clang
Event Timeline
clang/include/clang/Driver/Options.td | ||
---|---|---|
2121 ↗ | (On Diff #180251) | With this patch x9-15 can be specified as both reserved and callee-saved. Could you extend test/CodeGen/AArch64/arm64-reserve-call-saved-reg.ll as well? |
clang/lib/Driver/ToolChains/Arch/AArch64.cpp | ||
318 ↗ | (On Diff #180251) | What happens (should happen) if we reserve x0 and compile a function with a return value? |
Hi, we're currently working on similar functionality for the ARM backend, so I got pointed to take a look at this patch.
Looks good to me, I quite like the tablegen improvements, but agree with trong's comments.
I assume you've omitted X19, as LLVM uses it as the base pointer?
Done.
I assume you've omitted X19, as LLVM uses it as the base pointer?
Yes.
clang/lib/Driver/ToolChains/Arch/AArch64.cpp | ||
---|---|---|
318 ↗ | (On Diff #180251) | Clang throws error: AArch64 doesn't support function calls if any of the argument registers is reserved. as for any other argument register. |
clang/lib/Driver/ToolChains/Arch/AArch64.cpp | ||
---|---|---|
318 ↗ | (On Diff #180251) | Yes, if x0 is reserved, it can't be used to pass arguments. But what happens if x0 is used to return a value? For example: int foo() { return 1; } It would be helpful if compiling foo() with x0 reserved threw an error. |
clang/lib/Driver/ToolChains/Arch/AArch64.cpp | ||
---|---|---|
318 ↗ | (On Diff #180251) | IIRC gcc never reports any errors for its version of these flags; that doesn't mean we should accept constructs which don't have defined behavior. I'd prefer to print an error in any situation where we would implicitly use a reserved register. |
clang/lib/Driver/ToolChains/Arch/AArch64.cpp | ||
---|---|---|
318 ↗ | (On Diff #180251) | I've looked into it, but there are several places where LLVM assumes and uses x0, so I think it's safer for now to disallow reserving x0 just like we do with x19. |