[clang] [llvm] BPF address space insn (PR #84410)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 8 11:09:16 PST 2024
================
@@ -31,6 +31,9 @@ def SDT_BPFMEMCPY : SDTypeProfile<0, 4, [SDTCisVT<0, i64>,
SDTCisVT<1, i64>,
SDTCisVT<2, i64>,
SDTCisVT<3, i64>]>;
+def SDT_BPFAddrSpaceCast : SDTypeProfile<0, 3, [SDTCisPtrTy<0>,
----------------
eddyz87 wrote:
That works, thanks for the tip. I ended up with the following `td` definitions:
```llvm
def ADDR_SPACE_CAST
: ALU_RR<BPF_ALU64, BPF_MOV, 64,
(outs GPR:$dst),
(ins GPR:$src, i64imm:$dst_as, i64imm:$src_as),
"$dst = addr_space_cast($src, $dst_as, $src_as)",
[]> {
bits<64> dst_as;
bits<64> src_as;
let Inst{47-32} = 1;
let Inst{31-16} = dst_as{15-0};
let Inst{15-0} = src_as{15-0};
}
def SrcAddrSpace : SDNodeXForm<addrspacecast, [{
return CurDAG->getTargetConstant(
cast<AddrSpaceCastSDNode>(N)->getSrcAddressSpace(),
SDLoc(N), MVT::i64);
}]>;
def DstAddrSpace : SDNodeXForm<addrspacecast, [{
return CurDAG->getTargetConstant(
cast<AddrSpaceCastSDNode>(N)->getDestAddressSpace(),
SDLoc(N), MVT::i64);
}]>;
def : Pat<(addrspacecast:$this GPR:$src),
(ADDR_SPACE_CAST $src, (DstAddrSpace $this), (SrcAddrSpace $this))>;
```
https://github.com/llvm/llvm-project/pull/84410
More information about the cfe-commits
mailing list