<div dir="ltr"><div>Hi,</div><div><br></div><div>In AArch64, the PC is not a general purpose register.<br>However, there are other methods to read the current value of the PC to a register.</div><div><br></div><div>According to [1], you can read the PC value via the ADR instruction:</div><div>ADR Xd, .</div><div><br></div><div>Here, the dot (".") means "here". So a label at the current location.<br><br></div><div>The question is now, how to build an LLVM MachineInstruction with that?</div><div>Something like this:</div><div><br></div><div>Register PcReg = MRI.createVirtualRegister(&AArch64::GPR64RegClass);<br></div><div>BuildMI(bb, bb.instr_begin(),<br>  DebugLoc(), TII.get(AArch64::ADR))<br>   .addReg(PcReg)<br></div><div>   .addLabel(".");</div><div><br></div><div>However, I am struggling in adding a label  for the current location as the second operand. </div><div><br></div>Best,<br>Max<div><br></div><div>[1] <a href="https://developer.arm.com/architectures/learn-the-architecture/armv8-a-instruction-set-architecture/registers-in-aarch64-other-registers">https://developer.arm.com/architectures/learn-the-architecture/armv8-a-instruction-set-architecture/registers-in-aarch64-other-registers</a></div></div>