I know these are supported for Arm. See:
https://reviews.llvm.org/D3797
https://reviews.llvm.org/D68862 (includes test files that'll show you
how to use it from C)
I don't know whether that will "just work" for your backend (I assume
you need some option to mark the reserved register) but it should give
you a starting point.
Thanks,
David Spickett.
> _______________________________________________
> LLVM Developers mailing list
> llvm...@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
If your global is sufficiently special, then you might instead want to
look at how things like the global pointer and thread pointer are
handled in different back ends. These are generally registers that are
reserved but contains a value that is used in CodeGen. There are a few
variants:
- Initialised somewhere else, used throughout CodeGen. The thread
pointer is in this category (e.g. HWR 25 on MIPS, FS/GS base on x86).
These are sometimes not even writeable in userspace and must be set by
the kernel.
- Initialised by rtld stub code on cross-library calls, may or may not
be preserved on cross-library calls. I believe the global pointer works
like this on some PowerPC ABIs with function descriptors and on the o32
MIPS ABI.
- Set up in the function prolog but then guaranteed to be there for
the rest of codegen. $gp on MIPS 'new' ABIs works like this. MIPS
(prior to r6) does not have PC-relative addressing and so the ABI
requires callers to use $t9 ($25) as the register that they jump to,
allowing the callee to guarantee that $t9 contains the PC on function
entry. It then does a fixed relocation of the distance from the
function entry to the __gp variable to load the address of the GOT into
$gp. Functions that are not exported or address taken may be able to
optimise this setup away, if all of their callers will have set up $gp.
David