Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 1 | //==-- SystemZISelLowering.h - SystemZ DAG Lowering Interface ----*- C++ -*-==// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the interfaces that SystemZ uses to lower LLVM code into a |
| 11 | // selection DAG. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_TARGET_SystemZ_ISELLOWERING_H |
| 16 | #define LLVM_TARGET_SystemZ_ISELLOWERING_H |
| 17 | |
| 18 | #include "SystemZ.h" |
Anton Korobeynikov | 656ac6f | 2009-07-16 13:51:53 +0000 | [diff] [blame] | 19 | #include "SystemZRegisterInfo.h" |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/SelectionDAG.h" |
| 21 | #include "llvm/Target/TargetLowering.h" |
| 22 | |
| 23 | namespace llvm { |
| 24 | namespace SystemZISD { |
| 25 | enum { |
Anton Korobeynikov | 87a24e3 | 2009-07-16 13:28:59 +0000 | [diff] [blame] | 26 | FIRST_NUMBER = ISD::BUILTIN_OP_END, |
| 27 | |
| 28 | /// Return with a flag operand. Operand 0 is the chain operand. |
Anton Korobeynikov | ba249e4 | 2009-07-16 13:50:21 +0000 | [diff] [blame] | 29 | RET_FLAG, |
| 30 | |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 31 | /// CALL - These operations represent an abstract call |
Anton Korobeynikov | ba249e4 | 2009-07-16 13:50:21 +0000 | [diff] [blame] | 32 | /// instruction, which includes a bunch of information. |
Anton Korobeynikov | 4ec3e5f | 2009-07-16 13:52:31 +0000 | [diff] [blame] | 33 | CALL, |
| 34 | |
Anton Korobeynikov | bad769f | 2009-07-16 13:57:27 +0000 | [diff] [blame] | 35 | /// PCRelativeWrapper - PC relative address |
| 36 | PCRelativeWrapper, |
| 37 | |
Anton Korobeynikov | 7d1e39b | 2009-07-16 13:52:51 +0000 | [diff] [blame] | 38 | /// CMP, UCMP - Compare instruction |
Anton Korobeynikov | 4ec3e5f | 2009-07-16 13:52:31 +0000 | [diff] [blame] | 39 | CMP, |
| 40 | UCMP, |
Anton Korobeynikov | 7d1e39b | 2009-07-16 13:52:51 +0000 | [diff] [blame] | 41 | |
| 42 | /// BRCOND - Conditional branch. Operand 0 is chain operand, operand 1 is |
| 43 | /// the block to branch if condition is true, operand 2 is condition code |
| 44 | /// and operand 3 is the flag operand produced by a CMP instruction. |
| 45 | BRCOND, |
| 46 | |
| 47 | /// SELECT - Operands 0 and 1 are selection variables, operand 2 is |
| 48 | /// condition code and operand 3 is the flag operand. |
| 49 | SELECT |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 50 | }; |
| 51 | } |
| 52 | |
| 53 | class SystemZSubtarget; |
| 54 | class SystemZTargetMachine; |
| 55 | |
| 56 | class SystemZTargetLowering : public TargetLowering { |
| 57 | public: |
| 58 | explicit SystemZTargetLowering(SystemZTargetMachine &TM); |
| 59 | |
Owen Anderson | 95771af | 2011-02-25 21:41:48 +0000 | [diff] [blame] | 60 | virtual MVT getShiftAmountTy(EVT LHSTy) const { return MVT::i64; } |
| 61 | |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 62 | /// LowerOperation - Provide custom lowering hooks for some operations. |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 63 | virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const; |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 64 | |
| 65 | /// getTargetNodeName - This method returns the name of a target specific |
| 66 | /// DAG node. |
| 67 | virtual const char *getTargetNodeName(unsigned Opcode) const; |
| 68 | |
Anton Korobeynikov | 3c2734c | 2009-08-21 18:15:41 +0000 | [diff] [blame] | 69 | std::pair<unsigned, const TargetRegisterClass*> |
| 70 | getRegForInlineAsmConstraint(const std::string &Constraint, EVT VT) const; |
| 71 | TargetLowering::ConstraintType |
| 72 | getConstraintType(const std::string &Constraint) const; |
| 73 | |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 74 | SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const; |
| 75 | SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const; |
| 76 | SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; |
| 77 | SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const; |
| 78 | SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const; |
Anton Korobeynikov | ba249e4 | 2009-07-16 13:50:21 +0000 | [diff] [blame] | 79 | |
Anton Korobeynikov | 4ec3e5f | 2009-07-16 13:52:31 +0000 | [diff] [blame] | 80 | SDValue EmitCmp(SDValue LHS, SDValue RHS, |
| 81 | ISD::CondCode CC, SDValue &SystemZCC, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 82 | SelectionDAG &DAG) const; |
Anton Korobeynikov | 4ec3e5f | 2009-07-16 13:52:31 +0000 | [diff] [blame] | 83 | |
Anton Korobeynikov | 7d1e39b | 2009-07-16 13:52:51 +0000 | [diff] [blame] | 84 | |
| 85 | MachineBasicBlock* EmitInstrWithCustomInserter(MachineInstr *MI, |
Dan Gohman | af1d8ca | 2010-05-01 00:01:06 +0000 | [diff] [blame] | 86 | MachineBasicBlock *BB) const; |
Anton Korobeynikov | 7d1e39b | 2009-07-16 13:52:51 +0000 | [diff] [blame] | 87 | |
Evan Cheng | eb2f969 | 2009-10-27 19:56:55 +0000 | [diff] [blame] | 88 | /// isFPImmLegal - Returns true if the target can instruction select the |
| 89 | /// specified FP immediate natively. If false, the legalizer will |
| 90 | /// materialize the FP immediate as a load from a constant pool. |
Evan Cheng | a1eaa3c | 2009-10-28 01:43:28 +0000 | [diff] [blame] | 91 | virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const; |
Evan Cheng | eb2f969 | 2009-10-27 19:56:55 +0000 | [diff] [blame] | 92 | |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 93 | private: |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 94 | SDValue LowerCCCCallTo(SDValue Chain, SDValue Callee, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 95 | CallingConv::ID CallConv, bool isVarArg, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 96 | bool isTailCall, |
| 97 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
Dan Gohman | c940365 | 2010-07-07 15:54:55 +0000 | [diff] [blame] | 98 | const SmallVectorImpl<SDValue> &OutVals, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 99 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 100 | DebugLoc dl, SelectionDAG &DAG, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 101 | SmallVectorImpl<SDValue> &InVals) const; |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 102 | |
| 103 | SDValue LowerCCCArguments(SDValue Chain, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 104 | CallingConv::ID CallConv, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 105 | bool isVarArg, |
| 106 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 107 | DebugLoc dl, |
| 108 | SelectionDAG &DAG, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 109 | SmallVectorImpl<SDValue> &InVals) const; |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 110 | |
| 111 | SDValue LowerCallResult(SDValue Chain, SDValue InFlag, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 112 | CallingConv::ID CallConv, bool isVarArg, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 113 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 114 | DebugLoc dl, SelectionDAG &DAG, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 115 | SmallVectorImpl<SDValue> &InVals) const; |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 116 | |
| 117 | virtual SDValue |
| 118 | LowerFormalArguments(SDValue Chain, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 119 | CallingConv::ID CallConv, bool isVarArg, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 120 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 121 | DebugLoc dl, SelectionDAG &DAG, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 122 | SmallVectorImpl<SDValue> &InVals) const; |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 123 | virtual SDValue |
Evan Cheng | 022d9e1 | 2010-02-02 23:55:14 +0000 | [diff] [blame] | 124 | LowerCall(SDValue Chain, SDValue Callee, |
Evan Cheng | 0c439eb | 2010-01-27 00:07:07 +0000 | [diff] [blame] | 125 | CallingConv::ID CallConv, bool isVarArg, bool &isTailCall, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 126 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
Dan Gohman | c940365 | 2010-07-07 15:54:55 +0000 | [diff] [blame] | 127 | const SmallVectorImpl<SDValue> &OutVals, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 128 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 129 | DebugLoc dl, SelectionDAG &DAG, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 130 | SmallVectorImpl<SDValue> &InVals) const; |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 131 | |
| 132 | virtual SDValue |
| 133 | LowerReturn(SDValue Chain, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 134 | CallingConv::ID CallConv, bool isVarArg, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 135 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
Dan Gohman | c940365 | 2010-07-07 15:54:55 +0000 | [diff] [blame] | 136 | const SmallVectorImpl<SDValue> &OutVals, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 137 | DebugLoc dl, SelectionDAG &DAG) const; |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 138 | |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 139 | const SystemZSubtarget &Subtarget; |
| 140 | const SystemZTargetMachine &TM; |
Anton Korobeynikov | 656ac6f | 2009-07-16 13:51:53 +0000 | [diff] [blame] | 141 | const SystemZRegisterInfo *RegInfo; |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 142 | }; |
| 143 | } // namespace llvm |
| 144 | |
| 145 | #endif // LLVM_TARGET_SystemZ_ISELLOWERING_H |