Andrew Lenharth | aa38ce4 | 2005-09-02 18:46:02 +0000 | [diff] [blame] | 1 | //===-- AlphaISelLowering.h - Alpha DAG Lowering Interface ------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 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. |
Andrew Lenharth | aa38ce4 | 2005-09-02 18:46:02 +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 | |
Andrew Lenharth | 1725599 | 2006-06-21 13:37:27 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/VectorExtras.h" |
Andrew Lenharth | aa38ce4 | 2005-09-02 18:46:02 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetLowering.h" |
| 20 | #include "llvm/CodeGen/SelectionDAG.h" |
| 21 | #include "Alpha.h" |
| 22 | |
| 23 | namespace llvm { |
| 24 | |
Andrew Lenharth | 4907d22 | 2005-10-20 00:28:31 +0000 | [diff] [blame] | 25 | namespace AlphaISD { |
| 26 | enum NodeType { |
| 27 | // Start the numbering where the builting ops and target ops leave off. |
Dan Gohman | 0ba2bcf | 2008-09-23 18:42:32 +0000 | [diff] [blame] | 28 | FIRST_NUMBER = ISD::BUILTIN_OP_END, |
Andrew Lenharth | 7f0db91 | 2005-11-30 07:19:56 +0000 | [diff] [blame] | 29 | //These corrospond to the identical Instruction |
Andrew Lenharth | 3553d86 | 2007-01-24 21:09:16 +0000 | [diff] [blame] | 30 | CVTQT_, CVTQS_, CVTTQ_, |
Andrew Lenharth | 4e62951 | 2005-12-24 05:36:33 +0000 | [diff] [blame] | 31 | |
| 32 | /// GPRelHi/GPRelLo - These represent the high and low 16-bit |
Andrew Lenharth | c687b48 | 2005-12-24 08:29:32 +0000 | [diff] [blame] | 33 | /// parts of a global address respectively. |
| 34 | GPRelHi, GPRelLo, |
| 35 | |
| 36 | /// RetLit - Literal Relocation of a Global |
| 37 | RelLit, |
Andrew Lenharth | 4e62951 | 2005-12-24 05:36:33 +0000 | [diff] [blame] | 38 | |
Andrew Lenharth | 0e4dd01 | 2006-06-13 18:27:39 +0000 | [diff] [blame] | 39 | /// GlobalRetAddr - used to restore the return address |
| 40 | GlobalRetAddr, |
Chris Lattner | 2d90bd5 | 2006-01-27 23:39:00 +0000 | [diff] [blame] | 41 | |
| 42 | /// CALL - Normal call. |
| 43 | CALL, |
Andrew Lenharth | 4e62951 | 2005-12-24 05:36:33 +0000 | [diff] [blame] | 44 | |
Andrew Lenharth | 53d8970 | 2005-12-25 01:34:27 +0000 | [diff] [blame] | 45 | /// DIVCALL - used for special library calls for div and rem |
Andrew Lenharth | f2b806a | 2006-06-12 18:09:24 +0000 | [diff] [blame] | 46 | DivCall, |
| 47 | |
| 48 | /// return flag operand |
Andrew Lenharth | f81173f | 2006-10-31 16:49:55 +0000 | [diff] [blame] | 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 |
Andrew Lenharth | 53d8970 | 2005-12-25 01:34:27 +0000 | [diff] [blame] | 58 | |
Andrew Lenharth | 4907d22 | 2005-10-20 00:28:31 +0000 | [diff] [blame] | 59 | }; |
| 60 | } |
| 61 | |
Andrew Lenharth | aa38ce4 | 2005-09-02 18:46:02 +0000 | [diff] [blame] | 62 | class AlphaTargetLowering : public TargetLowering { |
| 63 | int VarArgsOffset; // What is the offset to the first vaarg |
| 64 | int VarArgsBase; // What is the base FrameIndex |
Andrew Lenharth | aa38ce4 | 2005-09-02 18:46:02 +0000 | [diff] [blame] | 65 | public: |
Dan Gohman | 61e729e | 2007-08-02 21:21:54 +0000 | [diff] [blame] | 66 | explicit AlphaTargetLowering(TargetMachine &TM); |
Andrew Lenharth | 7f0db91 | 2005-11-30 07:19:56 +0000 | [diff] [blame] | 67 | |
Scott Michel | 5b8f82e | 2008-03-10 15:42:14 +0000 | [diff] [blame] | 68 | /// getSetCCResultType - Get the SETCC result ValueType |
Owen Anderson | 825b72b | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 69 | virtual MVT::SimpleValueType getSetCCResultType(EVT VT) const; |
Scott Michel | 5b8f82e | 2008-03-10 15:42:14 +0000 | [diff] [blame] | 70 | |
Andrew Lenharth | 7f0db91 | 2005-11-30 07:19:56 +0000 | [diff] [blame] | 71 | /// LowerOperation - Provide custom lowering hooks for some operations. |
| 72 | /// |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 73 | virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG); |
Duncan Sands | 1607f05 | 2008-12-01 11:39:25 +0000 | [diff] [blame] | 74 | |
| 75 | /// ReplaceNodeResults - Replace the results of node with an illegal result |
| 76 | /// type with new values built out of custom code. |
| 77 | /// |
| 78 | virtual void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue>&Results, |
| 79 | SelectionDAG &DAG); |
Andrew Lenharth | 84a0605 | 2006-01-16 19:53:25 +0000 | [diff] [blame] | 80 | |
Duncan Sands | 126d907 | 2008-07-04 11:47:58 +0000 | [diff] [blame] | 81 | // Friendly names for dumps |
Andrew Lenharth | 84a0605 | 2006-01-16 19:53:25 +0000 | [diff] [blame] | 82 | const char *getTargetNodeName(unsigned Opcode) const; |
| 83 | |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 84 | SDValue LowerCallResult(SDValue Chain, SDValue InFlag, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 85 | CallingConv::ID CallConv, bool isVarArg, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 86 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 87 | DebugLoc dl, SelectionDAG &DAG, |
| 88 | SmallVectorImpl<SDValue> &InVals); |
Andrew Lenharth | aa38ce4 | 2005-09-02 18:46:02 +0000 | [diff] [blame] | 89 | |
Chris Lattner | 4234f57 | 2007-03-25 02:14:49 +0000 | [diff] [blame] | 90 | ConstraintType getConstraintType(const std::string &Constraint) const; |
Andrew Lenharth | 1725599 | 2006-06-21 13:37:27 +0000 | [diff] [blame] | 91 | |
| 92 | std::vector<unsigned> |
| 93 | getRegClassForInlineAsmConstraint(const std::string &Constraint, |
Owen Anderson | e50ed30 | 2009-08-10 22:56:29 +0000 | [diff] [blame] | 94 | EVT VT) const; |
Andrew Lenharth | 1725599 | 2006-06-21 13:37:27 +0000 | [diff] [blame] | 95 | |
Andrew Lenharth | ab0b949 | 2008-02-21 06:45:13 +0000 | [diff] [blame] | 96 | MachineBasicBlock *EmitInstrWithCustomInserter(MachineInstr *MI, |
Evan Cheng | fb2e752 | 2009-09-18 21:02:19 +0000 | [diff] [blame] | 97 | MachineBasicBlock *BB, |
| 98 | DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) const; |
Duncan Sands | 126d907 | 2008-07-04 11:47:58 +0000 | [diff] [blame] | 99 | |
Dan Gohman | 6520e20 | 2008-10-18 02:06:02 +0000 | [diff] [blame] | 100 | virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const; |
| 101 | |
Bill Wendling | b4202b8 | 2009-07-01 18:50:55 +0000 | [diff] [blame] | 102 | /// getFunctionAlignment - Return the Log2 alignment of this function. |
Bill Wendling | 20c568f | 2009-06-30 22:38:32 +0000 | [diff] [blame] | 103 | virtual unsigned getFunctionAlignment(const Function *F) const; |
| 104 | |
Evan Cheng | eb2f969 | 2009-10-27 19:56:55 +0000 | [diff] [blame] | 105 | /// isFPImmLegal - Returns true if the target can instruction select the |
| 106 | /// specified FP immediate natively. If false, the legalizer will |
| 107 | /// materialize the FP immediate as a load from a constant pool. |
Evan Cheng | a1eaa3c | 2009-10-28 01:43:28 +0000 | [diff] [blame] | 108 | virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const; |
Evan Cheng | eb2f969 | 2009-10-27 19:56:55 +0000 | [diff] [blame] | 109 | |
Duncan Sands | 126d907 | 2008-07-04 11:47:58 +0000 | [diff] [blame] | 110 | private: |
| 111 | // Helpers for custom lowering. |
Dan Gohman | 475871a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 112 | void LowerVAARG(SDNode *N, SDValue &Chain, SDValue &DataPtr, |
Duncan Sands | 126d907 | 2008-07-04 11:47:58 +0000 | [diff] [blame] | 113 | SelectionDAG &DAG); |
| 114 | |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 115 | virtual SDValue |
| 116 | LowerFormalArguments(SDValue Chain, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 117 | CallingConv::ID CallConv, bool isVarArg, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 118 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 119 | DebugLoc dl, SelectionDAG &DAG, |
| 120 | SmallVectorImpl<SDValue> &InVals); |
| 121 | |
| 122 | virtual SDValue |
| 123 | LowerCall(SDValue Chain, SDValue Callee, |
Evan Cheng | 0c439eb | 2010-01-27 00:07:07 +0000 | [diff] [blame] | 124 | CallingConv::ID CallConv, bool isVarArg, bool &isTailCall, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 125 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 126 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 127 | DebugLoc dl, SelectionDAG &DAG, |
| 128 | SmallVectorImpl<SDValue> &InVals); |
| 129 | |
| 130 | virtual SDValue |
| 131 | LowerReturn(SDValue Chain, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 132 | CallingConv::ID CallConv, bool isVarArg, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 133 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 134 | DebugLoc dl, SelectionDAG &DAG); |
Andrew Lenharth | aa38ce4 | 2005-09-02 18:46:02 +0000 | [diff] [blame] | 135 | }; |
| 136 | } |
| 137 | |
| 138 | #endif // LLVM_TARGET_ALPHA_ALPHAISELLOWERING_H |