[clang] [llvm] BPF address space insn (PR #84410)

via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 8 08:09:59 PST 2024


================
@@ -638,6 +643,31 @@ SDValue BPFTargetLowering::LowerDYNAMIC_STACKALLOC(SDValue Op,
   return DAG.getMergeValues(Ops, SDLoc());
 }
 
+SDValue BPFTargetLowering::LowerADDRSPACECAST(SDValue Op,
+                                              SelectionDAG &DAG) const {
+  auto *ACast = dyn_cast<AddrSpaceCastSDNode>(Op);
+  const SDValue &Ptr = ACast->getOperand(0);
+  unsigned SrcAS = ACast->getSrcAddressSpace();
+  unsigned DstAS = ACast->getDestAddressSpace();
+  SDLoc DL(Op);
+
+  if (SrcAS > 0 && DstAS > 0) {
+    SmallString<64> Msg;
+    raw_svector_ostream OS(Msg);
+    OS << "Can't cast address space " << SrcAS << " to " << DstAS
+       << ": either source or destination address space has to be zero";
+    fail(DL, DAG, Msg);
----------------
eddyz87 wrote:

Actually, I think this check is no longer necessary. It remains from a previous version, where `cast_kern` and `cast_user` instructions were used, modeled as an address space cast at IR level. There either source or destination address space had to be zero. Sorry for confusion, I should have removed this when switching MR to `addr_space_cast` instruction.

https://github.com/llvm/llvm-project/pull/84410


More information about the llvm-commits mailing list