|
25 | 25 | #include "llvm/CodeGen/ValueTypes.h" |
26 | 26 | #include "llvm/IR/DiagnosticInfo.h" |
27 | 27 | #include "llvm/IR/DiagnosticPrinter.h" |
| 28 | +#include "llvm/IR/IntrinsicsBPF.h" |
28 | 29 | #include "llvm/Support/Debug.h" |
29 | 30 | #include "llvm/Support/ErrorHandling.h" |
30 | 31 | #include "llvm/Support/MathExtras.h" |
@@ -81,6 +82,8 @@ BPFTargetLowering::BPFTargetLowering(const TargetMachine &TM, |
81 | 82 | setOperationAction(ISD::STACKSAVE, MVT::Other, Expand); |
82 | 83 | setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand); |
83 | 84 |
|
| 85 | + setOperationAction(ISD::INTRINSIC_W_CHAIN, MVT::Other, Custom); |
| 86 | + |
84 | 87 | for (auto VT : {MVT::i8, MVT::i16, MVT::i32, MVT::i32, MVT::i64}) { |
85 | 88 | if (Subtarget->isSolana()) { |
86 | 89 | // Implement custom lowering for all atomic operations |
@@ -404,10 +407,28 @@ SDValue BPFTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const { |
404 | 407 | case ISD::ATOMIC_LOAD_UMIN: |
405 | 408 | case ISD::ATOMIC_LOAD_XOR: |
406 | 409 | return LowerATOMICRMW(Op, DAG); |
| 410 | + case ISD::INTRINSIC_W_CHAIN: { |
| 411 | + unsigned IntNo = cast<ConstantSDNode>(Op->getOperand(1))->getZExtValue(); |
| 412 | + switch (IntNo) { |
| 413 | + case Intrinsic::bpf_load_byte: |
| 414 | + case Intrinsic::bpf_load_half: |
| 415 | + case Intrinsic::bpf_load_word: |
| 416 | + if (Subtarget->isSolana()) { |
| 417 | + report_fatal_error( |
| 418 | + "llvm.bpf.load.* intrinsics are not supported in SBF", false); |
| 419 | + } |
| 420 | + break; |
| 421 | + default: |
| 422 | + break; |
| 423 | + } |
| 424 | + |
| 425 | + // continue the expansion as defined with tablegen |
| 426 | + return SDValue(); |
| 427 | + } |
407 | 428 | case ISD::DYNAMIC_STACKALLOC: |
408 | 429 | report_fatal_error("Unsupported dynamic stack allocation"); |
409 | 430 | default: |
410 | | - llvm_unreachable("unimplemented atomic operand"); |
| 431 | + llvm_unreachable("unimplemented operation"); |
411 | 432 | } |
412 | 433 | } |
413 | 434 |
|
|
0 commit comments