[llvm-dev] Aarch64: Build MachineInstruction for "ADR Xd, ."
Max Muster via llvm-dev
llvm-dev at lists.llvm.org
Wed Sep 16 05:01:58 PDT 2020
Hi,
In AArch64, the PC is not a general purpose register.
However, there are other methods to read the current value of the PC to a
register.
According to [1], you can read the PC value via the ADR instruction:
ADR Xd, .
Here, the dot (".") means "here". So a label at the current location.
The question is now, how to build an LLVM MachineInstruction with that?
Something like this:
Register PcReg = MRI.createVirtualRegister(&AArch64::GPR64RegClass);
BuildMI(bb, bb.instr_begin(),
DebugLoc(), TII.get(AArch64::ADR))
.addReg(PcReg)
.addLabel(".");
However, I am struggling in adding a label for the current location as the
second operand.
Best,
Max
[1]
https://developer.arm.com/architectures/learn-the-architecture/armv8-a-instruction-set-architecture/registers-in-aarch64-other-registers
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200916/1a7ef8af/attachment.html>
More information about the llvm-dev
mailing list