diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2025-12-06 19:56:45 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2025-12-06 20:08:43 +0000 |
| commit | 3f709e42e3be0f28a88ca3e77663a02b52c914f4 (patch) | |
| tree | 948796bf3bf7e164373caf6c31f9f128ca85fd8c /llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp | |
| parent | 32a711e1c447004eb1fd015925f305ed1d8426de (diff) | |
Diffstat (limited to 'llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp')
| -rw-r--r-- | llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp b/llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp index 39390e8c38f8..666a5b6abfa4 100644 --- a/llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp +++ b/llvm/lib/Target/BPF/BPFMISimplifyPatchable.cpp @@ -50,9 +50,7 @@ struct BPFMISimplifyPatchable : public MachineFunctionPass { const BPFInstrInfo *TII; MachineFunction *MF; - BPFMISimplifyPatchable() : MachineFunctionPass(ID) { - initializeBPFMISimplifyPatchablePass(*PassRegistry::getPassRegistry()); - } + BPFMISimplifyPatchable() : MachineFunctionPass(ID) {} private: std::set<MachineInstr *> SkipInsts; @@ -94,35 +92,39 @@ void BPFMISimplifyPatchable::initialize(MachineFunction &MFParm) { LLVM_DEBUG(dbgs() << "*** BPF simplify patchable insts pass ***\n\n"); } -static bool isST(unsigned Opcode) { +static bool isStoreImm(unsigned Opcode) { return Opcode == BPF::STB_imm || Opcode == BPF::STH_imm || Opcode == BPF::STW_imm || Opcode == BPF::STD_imm; } -static bool isSTX32(unsigned Opcode) { - return Opcode == BPF::STB32 || Opcode == BPF::STH32 || Opcode == BPF::STW32; +static bool isStore32(unsigned Opcode) { + return Opcode == BPF::STB32 || Opcode == BPF::STH32 || Opcode == BPF::STW32 || + Opcode == BPF::STBREL32 || Opcode == BPF::STHREL32 || + Opcode == BPF::STWREL32; } -static bool isSTX64(unsigned Opcode) { +static bool isStore64(unsigned Opcode) { return Opcode == BPF::STB || Opcode == BPF::STH || Opcode == BPF::STW || - Opcode == BPF::STD; + Opcode == BPF::STD || Opcode == BPF::STDREL; } -static bool isLDX32(unsigned Opcode) { - return Opcode == BPF::LDB32 || Opcode == BPF::LDH32 || Opcode == BPF::LDW32; +static bool isLoad32(unsigned Opcode) { + return Opcode == BPF::LDB32 || Opcode == BPF::LDH32 || Opcode == BPF::LDW32 || + Opcode == BPF::LDBACQ32 || Opcode == BPF::LDHACQ32 || + Opcode == BPF::LDWACQ32; } -static bool isLDX64(unsigned Opcode) { +static bool isLoad64(unsigned Opcode) { return Opcode == BPF::LDB || Opcode == BPF::LDH || Opcode == BPF::LDW || - Opcode == BPF::LDD; + Opcode == BPF::LDD || Opcode == BPF::LDDACQ; } -static bool isLDSX(unsigned Opcode) { +static bool isLoadSext(unsigned Opcode) { return Opcode == BPF::LDBSX || Opcode == BPF::LDHSX || Opcode == BPF::LDWSX; } bool BPFMISimplifyPatchable::isLoadInst(unsigned Opcode) { - return isLDX32(Opcode) || isLDX64(Opcode) || isLDSX(Opcode); + return isLoad32(Opcode) || isLoad64(Opcode) || isLoadSext(Opcode); } void BPFMISimplifyPatchable::checkADDrr(MachineRegisterInfo *MRI, @@ -143,11 +145,11 @@ void BPFMISimplifyPatchable::checkADDrr(MachineRegisterInfo *MRI, MachineInstr *DefInst = MO.getParent(); unsigned Opcode = DefInst->getOpcode(); unsigned COREOp; - if (isLDX64(Opcode) || isLDSX(Opcode)) + if (isLoad64(Opcode) || isLoadSext(Opcode)) COREOp = BPF::CORE_LD64; - else if (isLDX32(Opcode)) + else if (isLoad32(Opcode)) COREOp = BPF::CORE_LD32; - else if (isSTX64(Opcode) || isSTX32(Opcode) || isST(Opcode)) + else if (isStore64(Opcode) || isStore32(Opcode) || isStoreImm(Opcode)) COREOp = BPF::CORE_ST; else continue; @@ -160,7 +162,7 @@ void BPFMISimplifyPatchable::checkADDrr(MachineRegisterInfo *MRI, // Reject the form: // %1 = ADD_rr %2, %3 // *(type *)(%2 + 0) = %1 - if (isSTX64(Opcode) || isSTX32(Opcode)) { + if (isStore64(Opcode) || isStore32(Opcode)) { const MachineOperand &Opnd = DefInst->getOperand(0); if (Opnd.isReg() && Opnd.getReg() == MO.getReg()) continue; |
