Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 1 | //===-- SPUISelLowering.h - Cell SPU 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. |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the interfaces that Cell SPU uses to lower LLVM code into |
| 11 | // a selection DAG. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef SPU_ISELLOWERING_H |
| 16 | #define SPU_ISELLOWERING_H |
| 17 | |
| 18 | #include "llvm/Target/TargetLowering.h" |
| 19 | #include "llvm/CodeGen/SelectionDAG.h" |
| 20 | #include "SPU.h" |
| 21 | |
| 22 | namespace llvm { |
| 23 | namespace SPUISD { |
| 24 | enum NodeType { |
| 25 | // Start the numbering where the builting ops and target ops leave off. |
| 26 | FIRST_NUMBER = ISD::BUILTIN_OP_END+SPU::INSTRUCTION_LIST_END, |
| 27 | |
| 28 | // Pseudo instructions: |
| 29 | RET_FLAG, ///< Return with flag, matched by bi instruction |
| 30 | |
| 31 | Hi, ///< High address component (upper 16) |
| 32 | Lo, ///< Low address component (lower 16) |
| 33 | PCRelAddr, ///< Program counter relative address |
Scott Michel | 9de5d0d | 2008-01-11 02:53:15 +0000 | [diff] [blame] | 34 | AFormAddr, ///< A-form address (local store) |
Scott Michel | 053c1da | 2008-01-29 02:16:57 +0000 | [diff] [blame] | 35 | IndirectAddr, ///< D-Form "imm($r)" and X-form "$r($r)" |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 36 | |
| 37 | LDRESULT, ///< Load result (value, chain) |
| 38 | CALL, ///< CALL instruction |
| 39 | SHUFB, ///< Vector shuffle (permute) |
| 40 | INSERT_MASK, ///< Insert element shuffle mask |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame] | 41 | CNTB, ///< Count leading ones in bytes |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 42 | PROMOTE_SCALAR, ///< Promote scalar->vector |
| 43 | EXTRACT_ELT0, ///< Extract element 0 |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame] | 44 | EXTRACT_ELT0_CHAINED, ///< Extract element 0, with chain |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 45 | EXTRACT_I1_ZEXT, ///< Extract element 0 as i1, zero extend |
| 46 | EXTRACT_I1_SEXT, ///< Extract element 0 as i1, sign extend |
| 47 | EXTRACT_I8_ZEXT, ///< Extract element 0 as i8, zero extend |
| 48 | EXTRACT_I8_SEXT, ///< Extract element 0 as i8, sign extend |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame] | 49 | MPY, ///< 16-bit Multiply (low parts of a 32-bit) |
| 50 | MPYU, ///< Multiply Unsigned |
| 51 | MPYH, ///< Multiply High |
| 52 | MPYHH, ///< Multiply High-High |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 53 | SHLQUAD_L_BITS, ///< Rotate quad left, by bits |
| 54 | SHLQUAD_L_BYTES, ///< Rotate quad left, by bytes |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame] | 55 | VEC_SHL, ///< Vector shift left |
| 56 | VEC_SRL, ///< Vector shift right (logical) |
| 57 | VEC_SRA, ///< Vector shift right (arithmetic) |
| 58 | VEC_ROTL, ///< Vector rotate left |
| 59 | VEC_ROTR, ///< Vector rotate right |
Scott Michel | a59d469 | 2008-02-23 18:41:37 +0000 | [diff] [blame] | 60 | ROTQUAD_RZ_BYTES, ///< Rotate quad right, by bytes, zero fill |
| 61 | ROTQUAD_RZ_BITS, ///< Rotate quad right, by bits, zero fill |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 62 | ROTBYTES_RIGHT_S, ///< Vector rotate right, by bytes, sign fill |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame] | 63 | ROTBYTES_LEFT, ///< Rotate bytes (loads -> ROTQBYI) |
| 64 | ROTBYTES_LEFT_CHAINED, ///< Rotate bytes (loads -> ROTQBYI), with chain |
| 65 | FSMBI, ///< Form Select Mask for Bytes, Immediate |
| 66 | SELB, ///< Select bits -> (b & mask) | (a & ~mask) |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 67 | FPInterp, ///< Floating point interpolate |
Scott Michel | 7f9ba9b | 2008-01-30 02:55:46 +0000 | [diff] [blame] | 68 | FPRecipEst, ///< Floating point reciprocal estimate |
| 69 | SEXT32TO64, ///< Sign-extended 32-bit const -> 64-bits |
| 70 | LAST_SPUISD ///< Last user-defined instruction |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 71 | }; |
| 72 | } |
| 73 | |
| 74 | /// Predicates that are used for node matching: |
| 75 | namespace SPU { |
| 76 | SDOperand get_vec_u18imm(SDNode *N, SelectionDAG &DAG, |
| 77 | MVT::ValueType ValueType); |
| 78 | SDOperand get_vec_i16imm(SDNode *N, SelectionDAG &DAG, |
| 79 | MVT::ValueType ValueType); |
| 80 | SDOperand get_vec_i10imm(SDNode *N, SelectionDAG &DAG, |
| 81 | MVT::ValueType ValueType); |
| 82 | SDOperand get_vec_i8imm(SDNode *N, SelectionDAG &DAG, |
| 83 | MVT::ValueType ValueType); |
| 84 | SDOperand get_ILHUvec_imm(SDNode *N, SelectionDAG &DAG, |
| 85 | MVT::ValueType ValueType); |
| 86 | SDOperand get_v4i32_imm(SDNode *N, SelectionDAG &DAG); |
| 87 | SDOperand get_v2i64_imm(SDNode *N, SelectionDAG &DAG); |
| 88 | } |
| 89 | |
| 90 | class SPUTargetMachine; // forward dec'l. |
| 91 | |
| 92 | class SPUTargetLowering : |
| 93 | public TargetLowering |
| 94 | { |
| 95 | int VarArgsFrameIndex; // FrameIndex for start of varargs area. |
| 96 | int ReturnAddrIndex; // FrameIndex for return slot. |
| 97 | SPUTargetMachine &SPUTM; |
| 98 | |
| 99 | public: |
| 100 | SPUTargetLowering(SPUTargetMachine &TM); |
| 101 | |
| 102 | /// getTargetNodeName() - This method returns the name of a target specific |
| 103 | /// DAG node. |
| 104 | virtual const char *getTargetNodeName(unsigned Opcode) const; |
Scott Michel | 5b8f82e | 2008-03-10 15:42:14 +0000 | [diff] [blame] | 105 | |
| 106 | /// getSetCCResultType - Return the ValueType for ISD::SETCC |
Scott Michel | 78c47fa | 2008-03-10 16:58:52 +0000 | [diff] [blame] | 107 | virtual MVT::ValueType getSetCCResultType(const SDOperand &) const; |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 108 | |
| 109 | /// LowerOperation - Provide custom lowering hooks for some operations. |
| 110 | /// |
| 111 | virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG); |
| 112 | |
| 113 | virtual SDOperand PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const; |
| 114 | |
| 115 | virtual void computeMaskedBitsForTargetNode(const SDOperand Op, |
Dan Gohman | 977a76f | 2008-02-13 22:28:48 +0000 | [diff] [blame] | 116 | const APInt &Mask, |
Dan Gohman | fd29e0e | 2008-02-13 00:35:47 +0000 | [diff] [blame] | 117 | APInt &KnownZero, |
| 118 | APInt &KnownOne, |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 119 | const SelectionDAG &DAG, |
| 120 | unsigned Depth = 0) const; |
| 121 | |
Scott Michel | 266bc8f | 2007-12-04 22:23:35 +0000 | [diff] [blame] | 122 | ConstraintType getConstraintType(const std::string &ConstraintLetter) const; |
| 123 | |
| 124 | std::pair<unsigned, const TargetRegisterClass*> |
| 125 | getRegForInlineAsmConstraint(const std::string &Constraint, |
| 126 | MVT::ValueType VT) const; |
| 127 | |
| 128 | void LowerAsmOperandForConstraint(SDOperand Op, char ConstraintLetter, |
| 129 | std::vector<SDOperand> &Ops, |
| 130 | SelectionDAG &DAG); |
| 131 | |
| 132 | /// isLegalAddressImmediate - Return true if the integer value can be used |
| 133 | /// as the offset of the target addressing mode. |
| 134 | virtual bool isLegalAddressImmediate(int64_t V, const Type *Ty) const; |
| 135 | virtual bool isLegalAddressImmediate(GlobalValue *) const; |
| 136 | }; |
| 137 | } |
| 138 | |
| 139 | #endif |