LLVM API Documentation
00001 //===-- XCoreISelLowering.h - XCore 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 XCore uses to lower LLVM code into a 00011 // selection DAG. 00012 // 00013 //===----------------------------------------------------------------------===// 00014 00015 #ifndef XCOREISELLOWERING_H 00016 #define XCOREISELLOWERING_H 00017 00018 #include "llvm/CodeGen/SelectionDAG.h" 00019 #include "llvm/Target/TargetLowering.h" 00020 #include "XCore.h" 00021 00022 namespace llvm { 00023 00024 // Forward delcarations 00025 class XCoreSubtarget; 00026 class XCoreTargetMachine; 00027 00028 namespace XCoreISD { 00029 enum NodeType { 00030 // Start the numbering where the builtin ops and target ops leave off. 00031 FIRST_NUMBER = ISD::BUILTIN_OP_END+XCore::INSTRUCTION_LIST_END, 00032 00033 // Branch and link (call) 00034 BL, 00035 00036 // pc relative address 00037 PCRelativeWrapper, 00038 00039 // dp relative address 00040 DPRelativeWrapper, 00041 00042 // cp relative address 00043 CPRelativeWrapper, 00044 00045 // Store word to stack 00046 STWSP, 00047 00048 // Corresponds to retsp instruction 00049 RETSP, 00050 00051 // Corresponds to LADD instruction 00052 LADD, 00053 00054 // Corresponds to LSUB instruction 00055 LSUB 00056 }; 00057 } 00058 00059 //===--------------------------------------------------------------------===// 00060 // TargetLowering Implementation 00061 //===--------------------------------------------------------------------===// 00062 class XCoreTargetLowering : public TargetLowering 00063 { 00064 public: 00065 00066 explicit XCoreTargetLowering(XCoreTargetMachine &TM); 00067 00068 /// LowerOperation - Provide custom lowering hooks for some operations. 00069 virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG); 00070 00071 /// ReplaceNodeResults - Replace the results of node with an illegal result 00072 /// type with new values built out of custom code. 00073 /// 00074 virtual void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results, 00075 SelectionDAG &DAG); 00076 00077 /// getTargetNodeName - This method returns the name of a target specific 00078 // DAG node. 00079 virtual const char *getTargetNodeName(unsigned Opcode) const; 00080 00081 virtual MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI, 00082 MachineBasicBlock *MBB) const; 00083 00084 virtual bool isLegalAddressingMode(const AddrMode &AM, 00085 const Type *Ty) const; 00086 00087 /// getFunctionAlignment - Return the Log2 alignment of this function. 00088 virtual unsigned getFunctionAlignment(const Function *F) const; 00089 00090 private: 00091 const XCoreTargetMachine &TM; 00092 const XCoreSubtarget &Subtarget; 00093 00094 // Lower Operand helpers 00095 SDValue LowerCCCArguments(SDValue Chain, 00096 unsigned CallConv, 00097 bool isVarArg, 00098 const SmallVectorImpl<ISD::InputArg> &Ins, 00099 DebugLoc dl, SelectionDAG &DAG, 00100 SmallVectorImpl<SDValue> &InVals); 00101 SDValue LowerCCCCallTo(SDValue Chain, SDValue Callee, 00102 unsigned CallConv, bool isVarArg, 00103 bool isTailCall, 00104 const SmallVectorImpl<ISD::OutputArg> &Outs, 00105 const SmallVectorImpl<ISD::InputArg> &Ins, 00106 DebugLoc dl, SelectionDAG &DAG, 00107 SmallVectorImpl<SDValue> &InVals); 00108 SDValue LowerCallResult(SDValue Chain, SDValue InFlag, 00109 unsigned CallConv, bool isVarArg, 00110 const SmallVectorImpl<ISD::InputArg> &Ins, 00111 DebugLoc dl, SelectionDAG &DAG, 00112 SmallVectorImpl<SDValue> &InVals); 00113 SDValue getReturnAddressFrameIndex(SelectionDAG &DAG); 00114 SDValue getGlobalAddressWrapper(SDValue GA, GlobalValue *GV, 00115 SelectionDAG &DAG); 00116 00117 // Lower Operand specifics 00118 SDValue LowerLOAD(SDValue Op, SelectionDAG &DAG); 00119 SDValue LowerSTORE(SDValue Op, SelectionDAG &DAG); 00120 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG); 00121 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG); 00122 SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG); 00123 SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG); 00124 SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG); 00125 SDValue LowerVAARG(SDValue Op, SelectionDAG &DAG); 00126 SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG); 00127 SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG); 00128 00129 // Inline asm support 00130 std::vector<unsigned> 00131 getRegClassForInlineAsmConstraint(const std::string &Constraint, 00132 EVT VT) const; 00133 00134 // Expand specifics 00135 SDValue ExpandADDSUB(SDNode *Op, SelectionDAG &DAG); 00136 00137 virtual SDValue PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const; 00138 00139 virtual SDValue 00140 LowerFormalArguments(SDValue Chain, 00141 unsigned CallConv, 00142 bool isVarArg, 00143 const SmallVectorImpl<ISD::InputArg> &Ins, 00144 DebugLoc dl, SelectionDAG &DAG, 00145 SmallVectorImpl<SDValue> &InVals); 00146 00147 virtual SDValue 00148 LowerCall(SDValue Chain, SDValue Callee, 00149 unsigned CallConv, bool isVarArg, 00150 bool isTailCall, 00151 const SmallVectorImpl<ISD::OutputArg> &Outs, 00152 const SmallVectorImpl<ISD::InputArg> &Ins, 00153 DebugLoc dl, SelectionDAG &DAG, 00154 SmallVectorImpl<SDValue> &InVals); 00155 00156 virtual SDValue 00157 LowerReturn(SDValue Chain, 00158 unsigned CallConv, bool isVarArg, 00159 const SmallVectorImpl<ISD::OutputArg> &Outs, 00160 DebugLoc dl, SelectionDAG &DAG); 00161 }; 00162 } 00163 00164 #endif // XCOREISELLOWERING_H