1 //===-- HexagonISelLowering.h - Hexagon 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 Hexagon uses to lower LLVM code into a
13 //===----------------------------------------------------------------------===//
15 #ifndef Hexagon_ISELLOWERING_H
16 #define Hexagon_ISELLOWERING_H
19 #include "llvm/CodeGen/CallingConvLower.h"
20 #include "llvm/IR/CallingConv.h"
21 #include "llvm/Target/TargetLowering.h"
24 namespace HexagonISD {
26 FIRST_NUMBER = ISD::BUILTIN_OP_END,
29 CONST32_GP, // For marking data present in GP.
35 CMPICC, // Compare two GPR operands, set icc.
36 CMPFCC, // Compare two FP operands, set fcc.
37 BRICC, // Branch to dest on icc condition
38 BRFCC, // Branch to dest on fcc condition
39 SELECT_ICC, // Select between two values using the current ICC flags.
40 SELECT_FCC, // Select between two values using the current FCC flags.
42 Hi, Lo, // Hi/Lo operations, typically on a global address.
44 FTOI, // FP to Int within a FP register.
45 ITOF, // Int to FP within a FP register.
47 CALL, // A call instruction.
48 RET_FLAG, // Return with a flag operand.
50 BARRIER, // Memory barrier.
68 class HexagonTargetLowering : public TargetLowering {
69 int VarArgsFrameOffset; // Frame offset to start of varargs area.
71 bool CanReturnSmallStruct(const Function* CalleeFn,
72 unsigned& RetSize) const;
75 HexagonTargetMachine &TM;
76 explicit HexagonTargetLowering(HexagonTargetMachine &targetmachine);
78 /// IsEligibleForTailCallOptimization - Check whether the call is eligible
79 /// for tail call optimization. Targets which want to do tail call
80 /// optimization should implement this function.
82 IsEligibleForTailCallOptimization(SDValue Callee,
83 CallingConv::ID CalleeCC,
85 bool isCalleeStructRet,
86 bool isCallerStructRet,
88 SmallVectorImpl<ISD::OutputArg> &Outs,
89 const SmallVectorImpl<SDValue> &OutVals,
90 const SmallVectorImpl<ISD::InputArg> &Ins,
91 SelectionDAG& DAG) const;
93 virtual bool isTruncateFree(Type *Ty1, Type *Ty2) const;
94 virtual bool isTruncateFree(EVT VT1, EVT VT2) const;
96 virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const;
98 virtual const char *getTargetNodeName(unsigned Opcode) const;
99 SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
100 SDValue LowerDYNAMIC_STACKALLOC(SDValue Op, SelectionDAG &DAG) const;
101 SDValue LowerINLINEASM(SDValue Op, SelectionDAG &DAG) const;
102 SDValue LowerEH_LABEL(SDValue Op, SelectionDAG &DAG) const;
103 SDValue LowerFormalArguments(SDValue Chain,
104 CallingConv::ID CallConv, bool isVarArg,
105 const SmallVectorImpl<ISD::InputArg> &Ins,
106 DebugLoc dl, SelectionDAG &DAG,
107 SmallVectorImpl<SDValue> &InVals) const;
108 SDValue LowerGLOBALADDRESS(SDValue Op, SelectionDAG &DAG) const;
110 SDValue LowerCall(TargetLowering::CallLoweringInfo &CLI,
111 SmallVectorImpl<SDValue> &InVals) const;
113 SDValue LowerCallResult(SDValue Chain, SDValue InFlag,
114 CallingConv::ID CallConv, bool isVarArg,
115 const SmallVectorImpl<ISD::InputArg> &Ins,
116 DebugLoc dl, SelectionDAG &DAG,
117 SmallVectorImpl<SDValue> &InVals,
118 const SmallVectorImpl<SDValue> &OutVals,
119 SDValue Callee) const;
121 SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const;
122 SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
123 SDValue LowerMEMBARRIER(SDValue Op, SelectionDAG& DAG) const;
124 SDValue LowerATOMIC_FENCE(SDValue Op, SelectionDAG& DAG) const;
125 SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;
127 SDValue LowerReturn(SDValue Chain,
128 CallingConv::ID CallConv, bool isVarArg,
129 const SmallVectorImpl<ISD::OutputArg> &Outs,
130 const SmallVectorImpl<SDValue> &OutVals,
131 DebugLoc dl, SelectionDAG &DAG) const;
133 virtual MachineBasicBlock
134 *EmitInstrWithCustomInserter(MachineInstr *MI,
135 MachineBasicBlock *BB) const;
137 SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
138 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const;
139 virtual EVT getSetCCResultType(EVT VT) const {
143 virtual bool getPostIndexedAddressParts(SDNode *N, SDNode *Op,
144 SDValue &Base, SDValue &Offset,
145 ISD::MemIndexedMode &AM,
146 SelectionDAG &DAG) const;
148 std::pair<unsigned, const TargetRegisterClass*>
149 getRegForInlineAsmConstraint(const std::string &Constraint,
153 virtual SDValue LowerINTRINSIC_WO_CHAIN(SDValue Op,
154 SelectionDAG &DAG) const;
155 /// isLegalAddressingMode - Return true if the addressing mode represented
156 /// by AM is legal for this target, for a load/store of the specified type.
157 /// The type may be VoidTy, in which case only return true if the addressing
158 /// mode is legal for a load/store of any legal type.
159 /// TODO: Handle pre/postinc as well.
160 virtual bool isLegalAddressingMode(const AddrMode &AM, Type *Ty) const;
161 virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const;
163 /// isLegalICmpImmediate - Return true if the specified immediate is legal
164 /// icmp immediate, that is the target has icmp instructions which can
165 /// compare a register against the immediate without having to materialize
166 /// the immediate into a register.
167 virtual bool isLegalICmpImmediate(int64_t Imm) const;
169 } // end namespace llvm
171 #endif // Hexagon_ISELLOWERING_H