Skip to content

Commit 8c419a4

Browse files
committed
[SOL] Remove load builtins (llvm#96)
1 parent ec448eb commit 8c419a4

File tree

4 files changed

+1
-177
lines changed

4 files changed

+1
-177
lines changed

llvm/lib/Target/SBF/SBFISelDAGToDAG.cpp

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "llvm/CodeGen/SelectionDAGISel.h"
2525
#include "llvm/IR/Constants.h"
2626
#include "llvm/IR/IntrinsicInst.h"
27-
#include "llvm/IR/IntrinsicsBPF.h"
2827
#include "llvm/Support/Debug.h"
2928
#include "llvm/Support/Endian.h"
3029
#include "llvm/Support/ErrorHandling.h"
@@ -77,7 +76,6 @@ class SBFDAGToDAGISel : public SelectionDAGISel {
7776

7877
// Node preprocessing cases
7978
void PreprocessLoad(SDNode *Node, SelectionDAG::allnodes_iterator &I);
80-
void PreprocessTrunc(SDNode *Node, SelectionDAG::allnodes_iterator &I);
8179

8280
// Find constants from a constant structure
8381
typedef std::vector<unsigned char> val_vec_type;
@@ -206,26 +204,6 @@ void SBFDAGToDAGISel::Select(SDNode *Node) {
206204
}
207205
break;
208206
}
209-
case ISD::INTRINSIC_W_CHAIN: {
210-
unsigned IntNo = cast<ConstantSDNode>(Node->getOperand(1))->getZExtValue();
211-
switch (IntNo) {
212-
case Intrinsic::bpf_load_byte:
213-
case Intrinsic::bpf_load_half:
214-
case Intrinsic::bpf_load_word: {
215-
SDLoc DL(Node);
216-
SDValue Chain = Node->getOperand(0);
217-
SDValue N1 = Node->getOperand(1);
218-
SDValue Skb = Node->getOperand(2);
219-
SDValue N3 = Node->getOperand(3);
220-
221-
SDValue R6Reg = CurDAG->getRegister(SBF::R6, MVT::i64);
222-
Chain = CurDAG->getCopyToReg(Chain, DL, R6Reg, Skb, SDValue());
223-
Node = CurDAG->UpdateNodeOperands(Node, Chain, N1, R6Reg, N3);
224-
break;
225-
}
226-
}
227-
break;
228-
}
229207

230208
case ISD::FrameIndex: {
231209
int FI = cast<FrameIndexSDNode>(Node)->getIndex();
@@ -377,8 +355,6 @@ void SBFDAGToDAGISel::PreprocessISelDAG() {
377355
unsigned Opcode = Node->getOpcode();
378356
if (Opcode == ISD::LOAD)
379357
PreprocessLoad(Node, I);
380-
else if (Opcode == ISD::AND)
381-
PreprocessTrunc(Node, I);
382358
}
383359
}
384360

@@ -508,39 +484,6 @@ bool SBFDAGToDAGISel::fillConstantStruct(const DataLayout &DL,
508484
return true;
509485
}
510486

511-
void SBFDAGToDAGISel::PreprocessTrunc(SDNode *Node,
512-
SelectionDAG::allnodes_iterator &I) {
513-
ConstantSDNode *MaskN = dyn_cast<ConstantSDNode>(Node->getOperand(1));
514-
if (!MaskN)
515-
return;
516-
517-
// The Reg operand should be a virtual register, which is defined
518-
// outside the current basic block. DAG combiner has done a pretty
519-
// good job in removing truncating inside a single basic block except
520-
// when the Reg operand comes from bpf_load_[byte | half | word] for
521-
// which the generic optimizer doesn't understand their results are
522-
// zero extended.
523-
SDValue BaseV = Node->getOperand(0);
524-
if (BaseV.getOpcode() != ISD::INTRINSIC_W_CHAIN)
525-
return;
526-
527-
unsigned IntNo = cast<ConstantSDNode>(BaseV->getOperand(1))->getZExtValue();
528-
uint64_t MaskV = MaskN->getZExtValue();
529-
530-
if (!((IntNo == Intrinsic::bpf_load_byte && MaskV == 0xFF) ||
531-
(IntNo == Intrinsic::bpf_load_half && MaskV == 0xFFFF) ||
532-
(IntNo == Intrinsic::bpf_load_word && MaskV == 0xFFFFFFFF)))
533-
return;
534-
535-
LLVM_DEBUG(dbgs() << "Remove the redundant AND operation in: ";
536-
Node->dump(); dbgs() << '\n');
537-
538-
I--;
539-
CurDAG->ReplaceAllUsesWith(SDValue(Node, 0), BaseV);
540-
I++;
541-
CurDAG->DeleteNode(Node);
542-
}
543-
544487
FunctionPass *llvm::createSBFISelDag(SBFTargetMachine &TM) {
545488
return new SBFDAGToDAGISel(TM);
546489
}

llvm/lib/Target/SBF/SBFISelLowering.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "llvm/CodeGen/ValueTypes.h"
2424
#include "llvm/IR/DiagnosticInfo.h"
2525
#include "llvm/IR/DiagnosticPrinter.h"
26-
#include "llvm/IR/IntrinsicsBPF.h" // TODO: jle.
2726
#include "llvm/Support/ErrorHandling.h"
2827
#include "llvm/Support/raw_ostream.h"
2928
using namespace llvm;
@@ -367,24 +366,9 @@ SDValue SBFTargetLowering::LowerOperation(SDValue Op, SelectionDAG &DAG) const {
367366
case ISD::ATOMIC_LOAD_UMIN:
368367
case ISD::ATOMIC_LOAD_XOR:
369368
return LowerATOMICRMW(Op, DAG);
370-
case ISD::INTRINSIC_W_CHAIN: {
371-
unsigned IntNo = cast<ConstantSDNode>(Op->getOperand(1))->getZExtValue();
372-
switch (IntNo) {
373-
case Intrinsic::bpf_load_byte:
374-
case Intrinsic::bpf_load_half:
375-
case Intrinsic::bpf_load_word:
376-
if (Subtarget->isSolana()) {
377-
report_fatal_error(
378-
"llvm.bpf.load.* intrinsics are not supported in SBF", false);
379-
}
380-
break;
381-
default:
382-
break;
383-
}
384-
369+
case ISD::INTRINSIC_W_CHAIN:
385370
// continue the expansion as defined with tablegen
386371
return SDValue();
387-
}
388372
case ISD::DYNAMIC_STACKALLOC:
389373
report_fatal_error("Unsupported dynamic stack allocation");
390374
default:

llvm/test/CodeGen/BPF/intrinsics.ll

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
; RUN: llc < %s -march=bpfel -show-mc-encoding | FileCheck --check-prefix=CHECK-EL %s
22
; RUN: llc < %s -march=bpfeb -show-mc-encoding | FileCheck --check-prefix=CHECK-EB %s
3-
; RUN: not llc < %s -march=sbf 2>&1 | FileCheck --check-prefix=CHECK-SBF %s
4-
5-
; CHECK-SBF: LLVM ERROR: llvm.bpf.load.* intrinsics are not supported in SBF
63

74
; Function Attrs: nounwind uwtable
85
define i32 @ld_b(i64 %foo, ptr nocapture %bar, ptr %ctx, ptr %ctx2) #0 {

llvm/test/CodeGen/SBF/intrinsics.ll

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)