[yaml2obj][obj2yaml] - Do not create a symbol table by default.
[llvm-complete.git] / lib / Target / BPF / BPFISelLowering.h
blobb81bf4e1320dcd83a4a1d42556486b96217c9722
1 //===-- BPFISelLowering.h - BPF DAG Lowering Interface ----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the interfaces that BPF uses to lower LLVM code into a
10 // selection DAG.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_LIB_TARGET_BPF_BPFISELLOWERING_H
15 #define LLVM_LIB_TARGET_BPF_BPFISELLOWERING_H
17 #include "BPF.h"
18 #include "llvm/CodeGen/SelectionDAG.h"
19 #include "llvm/CodeGen/TargetLowering.h"
21 namespace llvm {
22 class BPFSubtarget;
23 namespace BPFISD {
24 enum NodeType : unsigned {
25 FIRST_NUMBER = ISD::BUILTIN_OP_END,
26 RET_FLAG,
27 CALL,
28 SELECT_CC,
29 BR_CC,
30 Wrapper,
31 MEMCPY
35 class BPFTargetLowering : public TargetLowering {
36 public:
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;
49 std::pair<unsigned, const TargetRegisterClass *>
50 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
51 StringRef Constraint, MVT VT) const override;
53 MachineBasicBlock *
54 EmitInstrWithCustomInserter(MachineInstr &MI,
55 MachineBasicBlock *BB) const override;
57 bool getHasAlu32() const { return HasAlu32; }
58 bool getHasJmp32() const { return HasJmp32; }
59 bool getHasJmpExt() const { return HasJmpExt; }
61 EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
62 EVT VT) const override;
64 MVT getScalarShiftAmountTy(const DataLayout &, EVT) const override;
66 private:
67 // Control Instruction Selection Features
68 bool HasAlu32;
69 bool HasJmp32;
70 bool HasJmpExt;
72 SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
73 SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
74 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
76 // Lower the result values of a call, copying them out of physregs into vregs
77 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
78 CallingConv::ID CallConv, bool IsVarArg,
79 const SmallVectorImpl<ISD::InputArg> &Ins,
80 const SDLoc &DL, SelectionDAG &DAG,
81 SmallVectorImpl<SDValue> &InVals) const;
83 // Maximum number of arguments to a call
84 static const unsigned MaxArgs;
86 // Lower a call into CALLSEQ_START - BPFISD:CALL - CALLSEQ_END chain
87 SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
88 SmallVectorImpl<SDValue> &InVals) const override;
90 // Lower incoming arguments, copy physregs into vregs
91 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
92 bool IsVarArg,
93 const SmallVectorImpl<ISD::InputArg> &Ins,
94 const SDLoc &DL, SelectionDAG &DAG,
95 SmallVectorImpl<SDValue> &InVals) const override;
97 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
98 const SmallVectorImpl<ISD::OutputArg> &Outs,
99 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
100 SelectionDAG &DAG) const override;
102 EVT getOptimalMemOpType(uint64_t Size, unsigned DstAlign, unsigned SrcAlign,
103 bool IsMemset, bool ZeroMemset, bool MemcpyStrSrc,
104 const AttributeList &FuncAttributes) const override {
105 return Size >= 8 ? MVT::i64 : MVT::i32;
108 bool shouldConvertConstantLoadToIntImm(const APInt &Imm,
109 Type *Ty) const override {
110 return true;
113 unsigned EmitSubregExt(MachineInstr &MI, MachineBasicBlock *BB, unsigned Reg,
114 bool isSigned) const;
116 MachineBasicBlock * EmitInstrWithCustomInserterMemcpy(MachineInstr &MI,
117 MachineBasicBlock *BB)
118 const;
123 #endif