45 return Reg == AArch64SysReg::TPIDR_EL1 ||
Reg == AArch64SysReg::TPIDR_EL2 ||
46 Reg == AArch64SysReg::TPIDR_EL3;
50 return Inst.
getOpcode() == AArch64::MRS &&
55 return Inst.
getOpcode() == AArch64::MSR &&
67bool AArch64MCLFIRewriter::mayModifyReserved(
const MCInst &Inst)
const {
89 emitInst(Inst, Out, STI);
98 emitInst(Branch, Out, STI);
111 emitInst(Inst, Out, STI);
127 Load.setOpcode(AArch64::LDURXi);
131 emitInst(Load, Out, STI);
134 emitBranch(AArch64::BLR, AArch64::LR, Out, STI);
143void AArch64MCLFIRewriter::rewriteTPRead(
const MCInst &Inst,
MCStreamer &Out,
148 Load.setOpcode(AArch64::LDRXui);
152 emitInst(Load, Out, STI);
158void AArch64MCLFIRewriter::rewriteTPWrite(
const MCInst &Inst,
MCStreamer &Out,
163 Store.setOpcode(AArch64::STRXui);
167 emitInst(Store, Out, STI);
172void AArch64MCLFIRewriter::doRewriteInst(
const MCInst &Inst,
MCStreamer &Out,
175 if (mayModifyReserved(Inst)) {
176 error(Inst,
"illegal modification of reserved LFI register");
182 return rewriteSyscall(Inst, Out, STI);
185 return rewriteTPRead(Inst, Out, STI);
188 return rewriteTPWrite(Inst, Out, STI);
191 error(Inst,
"illegal access to privileged thread pointer register");
195 emitInst(Inst, Out, STI);
206 doRewriteInst(Inst, Out, STI);
static constexpr unsigned LFITPOffset
static constexpr MCRegister LFIScratchReg
static bool isPrivilegedTPAccess(const MCInst &Inst)
static constexpr MCRegister LFICtxReg
static bool isPrivilegedTP(int64_t Reg)
static bool isTPRead(const MCInst &Inst)
static bool isSyscall(const MCInst &Inst)
static constexpr MCRegister LFIAddrReg
static constexpr MCRegister LFIBaseReg
static constexpr int LFISyscallOffset
static bool isTPWrite(const MCInst &Inst)
bool rewriteInst(const MCInst &Inst, MCStreamer &Out, const MCSubtargetInfo &STI) override
Instances of this class represent a single low-level machine instruction.
unsigned getOpcode() const
void addOperand(const MCOperand Op)
void setOpcode(unsigned Op)
const MCOperand & getOperand(unsigned i) const
LLVM_ABI bool mayModifyRegister(const MCInst &Inst, MCRegister Reg) const
static MCOperand createReg(MCRegister Reg)
static MCOperand createImm(int64_t Val)
MCRegister getReg() const
Returns the register number.
Wrapper class representing physical registers. Should be passed by value.
Streaming machine code generation interface.
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
Generic base class for all target subtargets.
Target - Wrapper for Target specific information.
static unsigned getArithExtendImm(AArch64_AM::ShiftExtendType ET, unsigned Imm)
getArithExtendImm - Encode the extend type and shift amount for an arithmetic instruction: imm: 3-bit...
This is an optimization pass for GlobalISel generic memory operations.
static MCRegister getWRegFromXReg(MCRegister Reg)