Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | //===-- AlphaISelLowering.h - Alpha DAG Lowering Interface ------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 081ce94 | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the interfaces that Alpha uses to lower LLVM code into a |
| 11 | // selection DAG. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_TARGET_ALPHA_ALPHAISELLOWERING_H |
| 16 | #define LLVM_TARGET_ALPHA_ALPHAISELLOWERING_H |
| 17 | |
| 18 | #include "llvm/ADT/VectorExtras.h" |
| 19 | #include "llvm/Target/TargetLowering.h" |
| 20 | #include "llvm/CodeGen/SelectionDAG.h" |
| 21 | #include "Alpha.h" |
| 22 | |
| 23 | namespace llvm { |
| 24 | |
| 25 | namespace AlphaISD { |
| 26 | enum NodeType { |
| 27 | // Start the numbering where the builting ops and target ops leave off. |
Dan Gohman | 868636e | 2008-09-23 18:42:32 +0000 | [diff] [blame] | 28 | FIRST_NUMBER = ISD::BUILTIN_OP_END, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 29 | //These corrospond to the identical Instruction |
| 30 | CVTQT_, CVTQS_, CVTTQ_, |
| 31 | |
| 32 | /// GPRelHi/GPRelLo - These represent the high and low 16-bit |
| 33 | /// parts of a global address respectively. |
| 34 | GPRelHi, GPRelLo, |
| 35 | |
| 36 | /// RetLit - Literal Relocation of a Global |
| 37 | RelLit, |
| 38 | |
| 39 | /// GlobalRetAddr - used to restore the return address |
| 40 | GlobalRetAddr, |
| 41 | |
| 42 | /// CALL - Normal call. |
| 43 | CALL, |
| 44 | |
| 45 | /// DIVCALL - used for special library calls for div and rem |
| 46 | DivCall, |
| 47 | |
| 48 | /// return flag operand |
| 49 | RET_FLAG, |
| 50 | |
| 51 | /// CHAIN = COND_BRANCH CHAIN, OPC, (G|F)PRC, DESTBB [, INFLAG] - This |
| 52 | /// corresponds to the COND_BRANCH pseudo instruction. |
| 53 | /// *PRC is the input register to compare to zero, |
| 54 | /// OPC is the branch opcode to use (e.g. Alpha::BEQ), |
| 55 | /// DESTBB is the destination block to branch to, and INFLAG is |
| 56 | /// an optional input flag argument. |
| 57 | COND_BRANCH_I, COND_BRANCH_F |
| 58 | |
| 59 | }; |
| 60 | } |
| 61 | |
| 62 | class AlphaTargetLowering : public TargetLowering { |
| 63 | int VarArgsOffset; // What is the offset to the first vaarg |
| 64 | int VarArgsBase; // What is the base FrameIndex |
| 65 | bool useITOF; |
| 66 | public: |
Dan Gohman | 3a78bbf | 2007-08-02 21:21:54 +0000 | [diff] [blame] | 67 | explicit AlphaTargetLowering(TargetMachine &TM); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 68 | |
Scott Michel | 502151f | 2008-03-10 15:42:14 +0000 | [diff] [blame] | 69 | /// getSetCCResultType - Get the SETCC result ValueType |
Owen Anderson | 27bfb67 | 2009-08-10 18:56:59 +0000 | [diff] [blame] | 70 | virtual MVT::SimpleValueType getSetCCResultType(MVT VT) const; |
Scott Michel | 502151f | 2008-03-10 15:42:14 +0000 | [diff] [blame] | 71 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 72 | /// LowerOperation - Provide custom lowering hooks for some operations. |
| 73 | /// |
Dan Gohman | 8181bd1 | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 74 | virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG); |
Duncan Sands | 7d9834b | 2008-12-01 11:39:25 +0000 | [diff] [blame] | 75 | |
| 76 | /// ReplaceNodeResults - Replace the results of node with an illegal result |
| 77 | /// type with new values built out of custom code. |
| 78 | /// |
| 79 | virtual void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results, |
| 80 | SelectionDAG &DAG); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 81 | |
Duncan Sands | ac496a1 | 2008-07-04 11:47:58 +0000 | [diff] [blame] | 82 | // Friendly names for dumps |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 83 | const char *getTargetNodeName(unsigned Opcode) const; |
| 84 | |
Dan Gohman | 9178de1 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 85 | SDValue LowerCallResult(SDValue Chain, SDValue InFlag, |
| 86 | unsigned CallConv, bool isVarArg, |
| 87 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 88 | DebugLoc dl, SelectionDAG &DAG, |
| 89 | SmallVectorImpl<SDValue> &InVals); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 90 | |
| 91 | ConstraintType getConstraintType(const std::string &Constraint) const; |
| 92 | |
| 93 | std::vector<unsigned> |
| 94 | getRegClassForInlineAsmConstraint(const std::string &Constraint, |
Duncan Sands | 92c4391 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 95 | MVT VT) const; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 96 | |
| 97 | bool hasITOF() { return useITOF; } |
Andrew Lenharth | e44f390 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 98 | |
| 99 | MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI, |
Dan Gohman | 96d6092 | 2009-02-07 16:15:20 +0000 | [diff] [blame] | 100 | MachineBasicBlock *BB) const; |
Duncan Sands | ac496a1 | 2008-07-04 11:47:58 +0000 | [diff] [blame] | 101 | |
Dan Gohman | 36322c7 | 2008-10-18 02:06:02 +0000 | [diff] [blame] | 102 | virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const; |
| 103 | |
Bill Wendling | 045f263 | 2009-07-01 18:50:55 +0000 | [diff] [blame] | 104 | /// getFunctionAlignment - Return the Log2 alignment of this function. |
Bill Wendling | 25a8ae3 | 2009-06-30 22:38:32 +0000 | [diff] [blame] | 105 | virtual unsigned getFunctionAlignment(const Function *F) const; |
| 106 | |
Duncan Sands | ac496a1 | 2008-07-04 11:47:58 +0000 | [diff] [blame] | 107 | private: |
| 108 | // Helpers for custom lowering. |
Dan Gohman | 8181bd1 | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 109 | void LowerVAARG(SDNode *N, SDValue &Chain, SDValue &DataPtr, |
Duncan Sands | ac496a1 | 2008-07-04 11:47:58 +0000 | [diff] [blame] | 110 | SelectionDAG &DAG); |
| 111 | |
Dan Gohman | 9178de1 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 112 | virtual SDValue |
| 113 | LowerFormalArguments(SDValue Chain, |
| 114 | unsigned CallConv, bool isVarArg, |
| 115 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 116 | DebugLoc dl, SelectionDAG &DAG, |
| 117 | SmallVectorImpl<SDValue> &InVals); |
| 118 | |
| 119 | virtual SDValue |
| 120 | LowerCall(SDValue Chain, SDValue Callee, |
| 121 | unsigned CallConv, bool isVarArg, bool isTailCall, |
| 122 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 123 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 124 | DebugLoc dl, SelectionDAG &DAG, |
| 125 | SmallVectorImpl<SDValue> &InVals); |
| 126 | |
| 127 | virtual SDValue |
| 128 | LowerReturn(SDValue Chain, |
| 129 | unsigned CallConv, bool isVarArg, |
| 130 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 131 | DebugLoc dl, SelectionDAG &DAG); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 132 | }; |
| 133 | } |
| 134 | |
| 135 | #endif // LLVM_TARGET_ALPHA_ALPHAISELLOWERING_H |