1 //===-- BPFISelLowering.h - BPF DAG Lowering Interface ----------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the interfaces that BPF uses to lower LLVM code into a
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_LIB_TARGET_BPF_BPFISELLOWERING_H
16 #define LLVM_LIB_TARGET_BPF_BPFISELLOWERING_H
19 #include "llvm/CodeGen/SelectionDAG.h"
20 #include "llvm/Target/TargetLowering.h"
25 enum NodeType : unsigned {
26 FIRST_NUMBER = ISD::BUILTIN_OP_END,
35 class BPFTargetLowering : public TargetLowering {
37 explicit BPFTargetLowering(const TargetMachine &TM, const BPFSubtarget &STI);
39 // Provide custom lowering hooks for some operations.
40 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
42 // This method returns the name of a target specific DAG node.
43 const char *getTargetNodeName(unsigned Opcode) const override;
45 // This method decides whether folding a constant offset
46 // with the given GlobalAddress is legal.
47 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
50 EmitInstrWithCustomInserter(MachineInstr &MI,
51 MachineBasicBlock *BB) const override;
54 SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
55 SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
56 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
58 // Lower the result values of a call, copying them out of physregs into vregs
59 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
60 CallingConv::ID CallConv, bool IsVarArg,
61 const SmallVectorImpl<ISD::InputArg> &Ins,
62 const SDLoc &DL, SelectionDAG &DAG,
63 SmallVectorImpl<SDValue> &InVals) const;
65 // Maximum number of arguments to a call
66 static const unsigned MaxArgs;
68 // Lower a call into CALLSEQ_START - BPFISD:CALL - CALLSEQ_END chain
69 SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
70 SmallVectorImpl<SDValue> &InVals) const override;
72 // Lower incoming arguments, copy physregs into vregs
73 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
75 const SmallVectorImpl<ISD::InputArg> &Ins,
76 const SDLoc &DL, SelectionDAG &DAG,
77 SmallVectorImpl<SDValue> &InVals) const override;
79 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
80 const SmallVectorImpl<ISD::OutputArg> &Outs,
81 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
82 SelectionDAG &DAG) const override;
84 EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign,
85 bool IsMemset, bool ZeroMemset, bool MemcpyStrSrc,
86 MachineFunction &MF) const override {
87 return Size >= 8 ? MVT::i64 : MVT::i32;
90 bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
91 Type *Ty) const override {