LLVM API Documentation
00001 //===-- SparcISelLowering.h - Sparc DAG Lowering Interface ------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file defines the interfaces that Sparc uses to lower LLVM code into a 00011 // selection DAG. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef LLVM_LIB_TARGET_SPARC_SPARCISELLOWERING_H 00016 #define LLVM_LIB_TARGET_SPARC_SPARCISELLOWERING_H 00017 00018 #include "Sparc.h" 00019 #include "llvm/Target/TargetLowering.h" 00020 00021 namespace llvm { 00022 class SparcSubtarget; 00023 00024 namespace SPISD { 00025 enum { 00026 FIRST_NUMBER = ISD::BUILTIN_OP_END, 00027 CMPICC, // Compare two GPR operands, set icc+xcc. 00028 CMPFCC, // Compare two FP operands, set fcc. 00029 BRICC, // Branch to dest on icc condition 00030 BRXCC, // Branch to dest on xcc condition (64-bit only). 00031 BRFCC, // Branch to dest on fcc condition 00032 SELECT_ICC, // Select between two values using the current ICC flags. 00033 SELECT_XCC, // Select between two values using the current XCC flags. 00034 SELECT_FCC, // Select between two values using the current FCC flags. 00035 00036 Hi, Lo, // Hi/Lo operations, typically on a global address. 00037 00038 FTOI, // FP to Int within a FP register. 00039 ITOF, // Int to FP within a FP register. 00040 FTOX, // FP to Int64 within a FP register. 00041 XTOF, // Int64 to FP within a FP register. 00042 00043 CALL, // A call instruction. 00044 RET_FLAG, // Return with a flag operand. 00045 GLOBAL_BASE_REG, // Global base reg for PIC. 00046 FLUSHW, // FLUSH register windows to stack. 00047 00048 TLS_ADD, // For Thread Local Storage (TLS). 00049 TLS_LD, 00050 TLS_CALL 00051 }; 00052 } 00053 00054 class SparcTargetLowering : public TargetLowering { 00055 const SparcSubtarget *Subtarget; 00056 public: 00057 SparcTargetLowering(TargetMachine &TM); 00058 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override; 00059 00060 /// computeKnownBitsForTargetNode - Determine which of the bits specified 00061 /// in Mask are known to be either zero or one and return them in the 00062 /// KnownZero/KnownOne bitsets. 00063 void computeKnownBitsForTargetNode(const SDValue Op, 00064 APInt &KnownZero, 00065 APInt &KnownOne, 00066 const SelectionDAG &DAG, 00067 unsigned Depth = 0) const override; 00068 00069 MachineBasicBlock * 00070 EmitInstrWithCustomInserter(MachineInstr *MI, 00071 MachineBasicBlock *MBB) const override; 00072 00073 const char *getTargetNodeName(unsigned Opcode) const override; 00074 00075 ConstraintType getConstraintType(const std::string &Constraint) const override; 00076 ConstraintWeight 00077 getSingleConstraintMatchWeight(AsmOperandInfo &info, 00078 const char *constraint) const override; 00079 void LowerAsmOperandForConstraint(SDValue Op, 00080 std::string &Constraint, 00081 std::vector<SDValue> &Ops, 00082 SelectionDAG &DAG) const override; 00083 std::pair<unsigned, const TargetRegisterClass*> 00084 getRegForInlineAsmConstraint(const std::string &Constraint, MVT VT) const override; 00085 00086 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override; 00087 MVT getScalarShiftAmountTy(EVT LHSTy) const override { return MVT::i32; } 00088 00089 /// getSetCCResultType - Return the ISD::SETCC ValueType 00090 EVT getSetCCResultType(LLVMContext &Context, EVT VT) const override; 00091 00092 SDValue 00093 LowerFormalArguments(SDValue Chain, 00094 CallingConv::ID CallConv, 00095 bool isVarArg, 00096 const SmallVectorImpl<ISD::InputArg> &Ins, 00097 SDLoc dl, SelectionDAG &DAG, 00098 SmallVectorImpl<SDValue> &InVals) const override; 00099 SDValue LowerFormalArguments_32(SDValue Chain, 00100 CallingConv::ID CallConv, 00101 bool isVarArg, 00102 const SmallVectorImpl<ISD::InputArg> &Ins, 00103 SDLoc dl, SelectionDAG &DAG, 00104 SmallVectorImpl<SDValue> &InVals) const; 00105 SDValue LowerFormalArguments_64(SDValue Chain, 00106 CallingConv::ID CallConv, 00107 bool isVarArg, 00108 const SmallVectorImpl<ISD::InputArg> &Ins, 00109 SDLoc dl, SelectionDAG &DAG, 00110 SmallVectorImpl<SDValue> &InVals) const; 00111 00112 SDValue 00113 LowerCall(TargetLowering::CallLoweringInfo &CLI, 00114 SmallVectorImpl<SDValue> &InVals) const override; 00115 SDValue LowerCall_32(TargetLowering::CallLoweringInfo &CLI, 00116 SmallVectorImpl<SDValue> &InVals) const; 00117 SDValue LowerCall_64(TargetLowering::CallLoweringInfo &CLI, 00118 SmallVectorImpl<SDValue> &InVals) const; 00119 00120 SDValue 00121 LowerReturn(SDValue Chain, 00122 CallingConv::ID CallConv, bool isVarArg, 00123 const SmallVectorImpl<ISD::OutputArg> &Outs, 00124 const SmallVectorImpl<SDValue> &OutVals, 00125 SDLoc dl, SelectionDAG &DAG) const override; 00126 SDValue LowerReturn_32(SDValue Chain, 00127 CallingConv::ID CallConv, bool IsVarArg, 00128 const SmallVectorImpl<ISD::OutputArg> &Outs, 00129 const SmallVectorImpl<SDValue> &OutVals, 00130 SDLoc DL, SelectionDAG &DAG) const; 00131 SDValue LowerReturn_64(SDValue Chain, 00132 CallingConv::ID CallConv, bool IsVarArg, 00133 const SmallVectorImpl<ISD::OutputArg> &Outs, 00134 const SmallVectorImpl<SDValue> &OutVals, 00135 SDLoc DL, SelectionDAG &DAG) const; 00136 00137 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; 00138 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const; 00139 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const; 00140 SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const; 00141 00142 unsigned getSRetArgSize(SelectionDAG &DAG, SDValue Callee) const; 00143 SDValue withTargetFlags(SDValue Op, unsigned TF, SelectionDAG &DAG) const; 00144 SDValue makeHiLoPair(SDValue Op, unsigned HiTF, unsigned LoTF, 00145 SelectionDAG &DAG) const; 00146 SDValue makeAddress(SDValue Op, SelectionDAG &DAG) const; 00147 00148 SDValue LowerF128_LibCallArg(SDValue Chain, ArgListTy &Args, 00149 SDValue Arg, SDLoc DL, 00150 SelectionDAG &DAG) const; 00151 SDValue LowerF128Op(SDValue Op, SelectionDAG &DAG, 00152 const char *LibFuncName, 00153 unsigned numArgs) const; 00154 SDValue LowerF128Compare(SDValue LHS, SDValue RHS, 00155 unsigned &SPCC, 00156 SDLoc DL, 00157 SelectionDAG &DAG) const; 00158 00159 bool ShouldShrinkFPConstant(EVT VT) const override { 00160 // Do not shrink FP constpool if VT == MVT::f128. 00161 // (ldd, call _Q_fdtoq) is more expensive than two ldds. 00162 return VT != MVT::f128; 00163 } 00164 00165 void ReplaceNodeResults(SDNode *N, 00166 SmallVectorImpl<SDValue>& Results, 00167 SelectionDAG &DAG) const override; 00168 00169 MachineBasicBlock *expandSelectCC(MachineInstr *MI, MachineBasicBlock *BB, 00170 unsigned BROpcode) const; 00171 MachineBasicBlock *expandAtomicRMW(MachineInstr *MI, 00172 MachineBasicBlock *BB, 00173 unsigned Opcode, 00174 unsigned CondCode = 0) const; 00175 }; 00176 } // end namespace llvm 00177 00178 #endif // SPARC_ISELLOWERING_H