diff --git a/llvm/lib/Target/BPF/BPFAsmPrinter.cpp b/llvm/lib/Target/BPF/BPFAsmPrinter.cpp --- a/llvm/lib/Target/BPF/BPFAsmPrinter.cpp +++ b/llvm/lib/Target/BPF/BPFAsmPrinter.cpp @@ -140,7 +140,12 @@ void BPFAsmPrinter::emitInstruction(const MachineInstr *MI) { MCInst TmpInst; - if (!BTF || !BTF->InstLower(MI, TmpInst)) { + if (MI->getOpcode() == BPF::LOAD_U32_TO_PTR) { + TmpInst.setOpcode(BPF::LDW); + TmpInst.addOperand(MCOperand::createReg(MI->getOperand(0).getReg())); + TmpInst.addOperand(MCOperand::createReg(MI->getOperand(1).getReg())); + TmpInst.addOperand(MCOperand::createImm(MI->getOperand(2).getImm())); + } else if (!BTF || !BTF->InstLower(MI, TmpInst)) { BPFMCInstLower MCInstLowering(OutContext, *this); MCInstLowering.Lower(MI, TmpInst); } diff --git a/llvm/lib/Target/BPF/BPFInstrInfo.td b/llvm/lib/Target/BPF/BPFInstrInfo.td --- a/llvm/lib/Target/BPF/BPFInstrInfo.td +++ b/llvm/lib/Target/BPF/BPFInstrInfo.td @@ -392,6 +392,14 @@ let BPFClass = BPF_LD; } +let isCodeGenOnly = 1 in { + def LOAD_U32_TO_PTR : TYPE_LD_ST; +} + // STORE instructions class STORE Pattern> : TYPE_LD_ST