LLVM  5.0.0
BPFISelLowering.h
Go to the documentation of this file.
1 //===-- BPFISelLowering.h - BPF DAG Lowering Interface ----------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the interfaces that BPF uses to lower LLVM code into a
11 // selection DAG.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LIB_TARGET_BPF_BPFISELLOWERING_H
16 #define LLVM_LIB_TARGET_BPF_BPFISELLOWERING_H
17 
18 #include "BPF.h"
21 
22 namespace llvm {
23 class BPFSubtarget;
24 namespace BPFISD {
25 enum NodeType : unsigned {
32 };
33 }
34 
36 public:
37  explicit BPFTargetLowering(const TargetMachine &TM, const BPFSubtarget &STI);
38 
39  // Provide custom lowering hooks for some operations.
40  SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
41 
42  // This method returns the name of a target specific DAG node.
43  const char *getTargetNodeName(unsigned Opcode) const override;
44 
45  // This method decides whether folding a constant offset
46  // with the given GlobalAddress is legal.
47  bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
48 
51  MachineBasicBlock *BB) const override;
52 
53 private:
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;
57 
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,
62  const SDLoc &DL, SelectionDAG &DAG,
63  SmallVectorImpl<SDValue> &InVals) const;
64 
65  // Maximum number of arguments to a call
66  static const unsigned MaxArgs;
67 
68  // Lower a call into CALLSEQ_START - BPFISD:CALL - CALLSEQ_END chain
70  SmallVectorImpl<SDValue> &InVals) const override;
71 
72  // Lower incoming arguments, copy physregs into vregs
73  SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
74  bool IsVarArg,
76  const SDLoc &DL, SelectionDAG &DAG,
77  SmallVectorImpl<SDValue> &InVals) const override;
78 
79  SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
81  const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
82  SelectionDAG &DAG) const override;
83 
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;
88  }
89 
90  bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
91  Type *Ty) const override {
92  return true;
93  }
94 };
95 }
96 
97 #endif
BUILTIN_OP_END - This must be the last enum value in this list.
Definition: ISDOpcodes.h:827
DataLayout DL
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override
Return true if folding a constant offset with the given GlobalAddress is legal.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
const char * getTargetNodeName(unsigned Opcode) const override
This method returns the name of a target specific DAG node.
Extended Value Type.
Definition: ValueTypes.h:34
This structure contains all information that is necessary for lowering calls.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:209
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Class for arbitrary precision integers.
Definition: APInt.h:69
constexpr char Size[]
Key for Kernel::Arg::Metadata::mSize.
Representation of each machine instruction.
Definition: MachineInstr.h:59
BPFTargetLowering(const TargetMachine &TM, const BPFSubtarget &STI)
MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr &MI, MachineBasicBlock *BB) const override
This method should be implemented by targets that mark instructions with the 'usesCustomInserter' fla...
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:56
IRTranslator LLVM IR MI
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
This file describes how to lower LLVM code to machine code.
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override
This callback is invoked for operations that are unsupported by the target, which are registered to u...