1 //===-- SPUISelLowering.h - Cell SPU DAG Lowering Interface -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by a team from the Computer Systems Research
6 // Department at The Aerospace Corporation and is distributed under the
7 // University of Illinois Open Source License. See LICENSE.TXT for details.
9 //===----------------------------------------------------------------------===//
11 // This file defines the interfaces that Cell SPU uses to lower LLVM code into
14 //===----------------------------------------------------------------------===//
16 #ifndef SPU_ISELLOWERING_H
17 #define SPU_ISELLOWERING_H
19 #include "llvm/Target/TargetLowering.h"
20 #include "llvm/CodeGen/SelectionDAG.h"
26 // Start the numbering where the builting ops and target ops leave off.
27 FIRST_NUMBER = ISD::BUILTIN_OP_END+SPU::INSTRUCTION_LIST_END,
29 // Pseudo instructions:
30 RET_FLAG, ///< Return with flag, matched by bi instruction
32 Hi, ///< High address component (upper 16)
33 Lo, ///< Low address component (lower 16)
34 PCRelAddr, ///< Program counter relative address
35 DFormAddr, ///< D-Form address "imm($r)"
36 XFormAddr, ///< X-Form address "$r1($r2)"
38 LDRESULT, ///< Load result (value, chain)
39 CALL, ///< CALL instruction
40 SHUFB, ///< Vector shuffle (permute)
41 INSERT_MASK, ///< Insert element shuffle mask
42 CNTB, ///< Count leading ones in bytes
43 PROMOTE_SCALAR, ///< Promote scalar->vector
44 EXTRACT_ELT0, ///< Extract element 0
45 EXTRACT_ELT0_CHAINED, ///< Extract element 0, with chain
46 EXTRACT_I1_ZEXT, ///< Extract element 0 as i1, zero extend
47 EXTRACT_I1_SEXT, ///< Extract element 0 as i1, sign extend
48 EXTRACT_I8_ZEXT, ///< Extract element 0 as i8, zero extend
49 EXTRACT_I8_SEXT, ///< Extract element 0 as i8, sign extend
50 MPY, ///< 16-bit Multiply (low parts of a 32-bit)
51 MPYU, ///< Multiply Unsigned
52 MPYH, ///< Multiply High
53 MPYHH, ///< Multiply High-High
54 VEC_SHL, ///< Vector shift left
55 VEC_SRL, ///< Vector shift right (logical)
56 VEC_SRA, ///< Vector shift right (arithmetic)
57 VEC_ROTL, ///< Vector rotate left
58 VEC_ROTR, ///< Vector rotate right
59 ROTBYTES_RIGHT_Z, ///< Vector rotate right, by bytes, zero fill
60 ROTBYTES_RIGHT_S, ///< Vector rotate right, by bytes, sign fill
61 ROTBYTES_LEFT, ///< Rotate bytes (loads -> ROTQBYI)
62 ROTBYTES_LEFT_CHAINED, ///< Rotate bytes (loads -> ROTQBYI), with chain
63 FSMBI, ///< Form Select Mask for Bytes, Immediate
64 SELB, ///< Select bits -> (b & mask) | (a & ~mask)
65 SFPConstant, ///< Single precision floating point constant
66 FPInterp, ///< Floating point interpolate
67 FPRecipEst, ///< Floating point reciprocal estimate
68 SEXT32TO64, ///< Sign-extended 32-bit const -> 64-bits
69 LAST_SPUISD ///< Last user-defined instruction
73 /// Predicates that are used for node matching:
75 SDOperand get_vec_u18imm(SDNode *N, SelectionDAG &DAG,
76 MVT::ValueType ValueType);
77 SDOperand get_vec_i16imm(SDNode *N, SelectionDAG &DAG,
78 MVT::ValueType ValueType);
79 SDOperand get_vec_i10imm(SDNode *N, SelectionDAG &DAG,
80 MVT::ValueType ValueType);
81 SDOperand get_vec_i8imm(SDNode *N, SelectionDAG &DAG,
82 MVT::ValueType ValueType);
83 SDOperand get_ILHUvec_imm(SDNode *N, SelectionDAG &DAG,
84 MVT::ValueType ValueType);
85 SDOperand get_v4i32_imm(SDNode *N, SelectionDAG &DAG);
86 SDOperand get_v2i64_imm(SDNode *N, SelectionDAG &DAG);
89 class SPUTargetMachine; // forward dec'l.
91 class SPUTargetLowering :
94 int VarArgsFrameIndex; // FrameIndex for start of varargs area.
95 int ReturnAddrIndex; // FrameIndex for return slot.
96 SPUTargetMachine &SPUTM;
99 SPUTargetLowering(SPUTargetMachine &TM);
101 /// getTargetNodeName() - This method returns the name of a target specific
103 virtual const char *getTargetNodeName(unsigned Opcode) const;
105 /// LowerOperation - Provide custom lowering hooks for some operations.
107 virtual SDOperand LowerOperation(SDOperand Op, SelectionDAG &DAG);
109 virtual SDOperand PerformDAGCombine(SDNode *N, DAGCombinerInfo &DCI) const;
111 virtual void computeMaskedBitsForTargetNode(const SDOperand Op,
115 const SelectionDAG &DAG,
116 unsigned Depth = 0) const;
118 virtual MachineBasicBlock *InsertAtEndOfBasicBlock(MachineInstr *MI,
119 MachineBasicBlock *MBB);
121 ConstraintType getConstraintType(const std::string &ConstraintLetter) const;
123 std::pair<unsigned, const TargetRegisterClass*>
124 getRegForInlineAsmConstraint(const std::string &Constraint,
125 MVT::ValueType VT) const;
127 void LowerAsmOperandForConstraint(SDOperand Op, char ConstraintLetter,
128 std::vector<SDOperand> &Ops,
131 /// isLegalAddressImmediate - Return true if the integer value can be used
132 /// as the offset of the target addressing mode.
133 virtual bool isLegalAddressImmediate(int64_t V, const Type *Ty) const;
134 virtual bool isLegalAddressImmediate(GlobalValue *) const;