xref: /aosp_15_r20/external/llvm/lib/Target/Lanai/LanaiISelLowering.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===-- LanaiISelLowering.h - Lanai DAG Lowering Interface -....-*- C++ -*-===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker // This file defines the interfaces that Lanai uses to lower LLVM code into a
11*9880d681SAndroid Build Coastguard Worker // selection DAG.
12*9880d681SAndroid Build Coastguard Worker //
13*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
14*9880d681SAndroid Build Coastguard Worker 
15*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_LANAI_LANAIISELLOWERING_H
16*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_LANAI_LANAIISELLOWERING_H
17*9880d681SAndroid Build Coastguard Worker 
18*9880d681SAndroid Build Coastguard Worker #include "Lanai.h"
19*9880d681SAndroid Build Coastguard Worker #include "LanaiRegisterInfo.h"
20*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/SelectionDAG.h"
21*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetLowering.h"
22*9880d681SAndroid Build Coastguard Worker 
23*9880d681SAndroid Build Coastguard Worker namespace llvm {
24*9880d681SAndroid Build Coastguard Worker namespace LanaiISD {
25*9880d681SAndroid Build Coastguard Worker enum {
26*9880d681SAndroid Build Coastguard Worker   FIRST_NUMBER = ISD::BUILTIN_OP_END,
27*9880d681SAndroid Build Coastguard Worker 
28*9880d681SAndroid Build Coastguard Worker   ADJDYNALLOC,
29*9880d681SAndroid Build Coastguard Worker 
30*9880d681SAndroid Build Coastguard Worker   // Return with a flag operand. Operand 0 is the chain operand.
31*9880d681SAndroid Build Coastguard Worker   RET_FLAG,
32*9880d681SAndroid Build Coastguard Worker 
33*9880d681SAndroid Build Coastguard Worker   // CALL - These operations represent an abstract call instruction, which
34*9880d681SAndroid Build Coastguard Worker   // includes a bunch of information.
35*9880d681SAndroid Build Coastguard Worker   CALL,
36*9880d681SAndroid Build Coastguard Worker 
37*9880d681SAndroid Build Coastguard Worker   // SELECT_CC - Operand 0 and operand 1 are selection variable, operand 3
38*9880d681SAndroid Build Coastguard Worker   // is condition code and operand 4 is flag operand.
39*9880d681SAndroid Build Coastguard Worker   SELECT_CC,
40*9880d681SAndroid Build Coastguard Worker 
41*9880d681SAndroid Build Coastguard Worker   // SETCC - Store the conditional code to a register.
42*9880d681SAndroid Build Coastguard Worker   SETCC,
43*9880d681SAndroid Build Coastguard Worker 
44*9880d681SAndroid Build Coastguard Worker   // SET_FLAG - Set flag compare.
45*9880d681SAndroid Build Coastguard Worker   SET_FLAG,
46*9880d681SAndroid Build Coastguard Worker 
47*9880d681SAndroid Build Coastguard Worker   // SUBBF - Subtract with borrow that sets flags.
48*9880d681SAndroid Build Coastguard Worker   SUBBF,
49*9880d681SAndroid Build Coastguard Worker 
50*9880d681SAndroid Build Coastguard Worker   // BR_CC - Used to glue together a conditional branch and comparison
51*9880d681SAndroid Build Coastguard Worker   BR_CC,
52*9880d681SAndroid Build Coastguard Worker 
53*9880d681SAndroid Build Coastguard Worker   // Wrapper - A wrapper node for TargetConstantPool, TargetExternalSymbol,
54*9880d681SAndroid Build Coastguard Worker   // and TargetGlobalAddress.
55*9880d681SAndroid Build Coastguard Worker   Wrapper,
56*9880d681SAndroid Build Coastguard Worker 
57*9880d681SAndroid Build Coastguard Worker   // Get the Higher/Lower 16 bits from a 32-bit immediate.
58*9880d681SAndroid Build Coastguard Worker   HI,
59*9880d681SAndroid Build Coastguard Worker   LO,
60*9880d681SAndroid Build Coastguard Worker 
61*9880d681SAndroid Build Coastguard Worker   // Small 21-bit immediate in global memory.
62*9880d681SAndroid Build Coastguard Worker   SMALL
63*9880d681SAndroid Build Coastguard Worker };
64*9880d681SAndroid Build Coastguard Worker } // namespace LanaiISD
65*9880d681SAndroid Build Coastguard Worker 
66*9880d681SAndroid Build Coastguard Worker class LanaiSubtarget;
67*9880d681SAndroid Build Coastguard Worker 
68*9880d681SAndroid Build Coastguard Worker class LanaiTargetLowering : public TargetLowering {
69*9880d681SAndroid Build Coastguard Worker public:
70*9880d681SAndroid Build Coastguard Worker   LanaiTargetLowering(const TargetMachine &TM, const LanaiSubtarget &STI);
71*9880d681SAndroid Build Coastguard Worker 
72*9880d681SAndroid Build Coastguard Worker   // LowerOperation - Provide custom lowering hooks for some operations.
73*9880d681SAndroid Build Coastguard Worker   SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
74*9880d681SAndroid Build Coastguard Worker 
75*9880d681SAndroid Build Coastguard Worker   // getTargetNodeName - This method returns the name of a target specific
76*9880d681SAndroid Build Coastguard Worker   // DAG node.
77*9880d681SAndroid Build Coastguard Worker   const char *getTargetNodeName(unsigned Opcode) const override;
78*9880d681SAndroid Build Coastguard Worker 
79*9880d681SAndroid Build Coastguard Worker   SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const;
80*9880d681SAndroid Build Coastguard Worker   SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const;
81*9880d681SAndroid Build Coastguard Worker   SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
82*9880d681SAndroid Build Coastguard Worker   SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
83*9880d681SAndroid Build Coastguard Worker   SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
84*9880d681SAndroid Build Coastguard Worker   SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
85*9880d681SAndroid Build Coastguard Worker   SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
86*9880d681SAndroid Build Coastguard Worker   SDValue LowerMUL(SDValue Op, SelectionDAG &DAG) const;
87*9880d681SAndroid Build Coastguard Worker   SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
88*9880d681SAndroid Build Coastguard Worker   SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
89*9880d681SAndroid Build Coastguard Worker   SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
90*9880d681SAndroid Build Coastguard Worker   SDValue LowerSETCCE(SDValue Op, SelectionDAG &DAG) const;
91*9880d681SAndroid Build Coastguard Worker   SDValue LowerSRL_PARTS(SDValue Op, SelectionDAG &DAG) const;
92*9880d681SAndroid Build Coastguard Worker   SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
93*9880d681SAndroid Build Coastguard Worker 
94*9880d681SAndroid Build Coastguard Worker   unsigned getRegisterByName(const char *RegName, EVT VT,
95*9880d681SAndroid Build Coastguard Worker                              SelectionDAG &DAG) const override;
96*9880d681SAndroid Build Coastguard Worker   std::pair<unsigned, const TargetRegisterClass *>
97*9880d681SAndroid Build Coastguard Worker   getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
98*9880d681SAndroid Build Coastguard Worker                                StringRef Constraint, MVT VT) const override;
99*9880d681SAndroid Build Coastguard Worker   ConstraintWeight
100*9880d681SAndroid Build Coastguard Worker   getSingleConstraintMatchWeight(AsmOperandInfo &Info,
101*9880d681SAndroid Build Coastguard Worker                                  const char *Constraint) const override;
102*9880d681SAndroid Build Coastguard Worker   void LowerAsmOperandForConstraint(SDValue Op, std::string &Constraint,
103*9880d681SAndroid Build Coastguard Worker                                     std::vector<SDValue> &Ops,
104*9880d681SAndroid Build Coastguard Worker                                     SelectionDAG &DAG) const override;
105*9880d681SAndroid Build Coastguard Worker 
106*9880d681SAndroid Build Coastguard Worker   SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const override;
107*9880d681SAndroid Build Coastguard Worker 
108*9880d681SAndroid Build Coastguard Worker private:
109*9880d681SAndroid Build Coastguard Worker   SDValue LowerCCCCallTo(SDValue Chain, SDValue Callee,
110*9880d681SAndroid Build Coastguard Worker                          CallingConv::ID CallConv, bool IsVarArg,
111*9880d681SAndroid Build Coastguard Worker                          bool IsTailCall,
112*9880d681SAndroid Build Coastguard Worker                          const SmallVectorImpl<ISD::OutputArg> &Outs,
113*9880d681SAndroid Build Coastguard Worker                          const SmallVectorImpl<SDValue> &OutVals,
114*9880d681SAndroid Build Coastguard Worker                          const SmallVectorImpl<ISD::InputArg> &Ins,
115*9880d681SAndroid Build Coastguard Worker                          const SDLoc &dl, SelectionDAG &DAG,
116*9880d681SAndroid Build Coastguard Worker                          SmallVectorImpl<SDValue> &InVals) const;
117*9880d681SAndroid Build Coastguard Worker 
118*9880d681SAndroid Build Coastguard Worker   SDValue LowerCCCArguments(SDValue Chain, CallingConv::ID CallConv,
119*9880d681SAndroid Build Coastguard Worker                             bool IsVarArg,
120*9880d681SAndroid Build Coastguard Worker                             const SmallVectorImpl<ISD::InputArg> &Ins,
121*9880d681SAndroid Build Coastguard Worker                             const SDLoc &DL, SelectionDAG &DAG,
122*9880d681SAndroid Build Coastguard Worker                             SmallVectorImpl<SDValue> &InVals) const;
123*9880d681SAndroid Build Coastguard Worker 
124*9880d681SAndroid Build Coastguard Worker   SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
125*9880d681SAndroid Build Coastguard Worker                           CallingConv::ID CallConv, bool IsVarArg,
126*9880d681SAndroid Build Coastguard Worker                           const SmallVectorImpl<ISD::InputArg> &Ins,
127*9880d681SAndroid Build Coastguard Worker                           const SDLoc &DL, SelectionDAG &DAG,
128*9880d681SAndroid Build Coastguard Worker                           SmallVectorImpl<SDValue> &InVals) const;
129*9880d681SAndroid Build Coastguard Worker 
130*9880d681SAndroid Build Coastguard Worker   SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
131*9880d681SAndroid Build Coastguard Worker                     SmallVectorImpl<SDValue> &InVals) const override;
132*9880d681SAndroid Build Coastguard Worker 
133*9880d681SAndroid Build Coastguard Worker   SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
134*9880d681SAndroid Build Coastguard Worker                                bool IsVarArg,
135*9880d681SAndroid Build Coastguard Worker                                const SmallVectorImpl<ISD::InputArg> &Ins,
136*9880d681SAndroid Build Coastguard Worker                                const SDLoc &DL, SelectionDAG &DAG,
137*9880d681SAndroid Build Coastguard Worker                                SmallVectorImpl<SDValue> &InVals) const override;
138*9880d681SAndroid Build Coastguard Worker 
139*9880d681SAndroid Build Coastguard Worker   SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool IsVarArg,
140*9880d681SAndroid Build Coastguard Worker                       const SmallVectorImpl<ISD::OutputArg> &Outs,
141*9880d681SAndroid Build Coastguard Worker                       const SmallVectorImpl<SDValue> &OutVals, const SDLoc &DL,
142*9880d681SAndroid Build Coastguard Worker                       SelectionDAG &DAG) const override;
143*9880d681SAndroid Build Coastguard Worker 
144*9880d681SAndroid Build Coastguard Worker   const LanaiRegisterInfo *TRI;
145*9880d681SAndroid Build Coastguard Worker };
146*9880d681SAndroid Build Coastguard Worker } // namespace llvm
147*9880d681SAndroid Build Coastguard Worker 
148*9880d681SAndroid Build Coastguard Worker #endif // LLVM_LIB_TARGET_LANAI_LANAIISELLOWERING_H
149