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 | |
| 60 | /// LowerOperation - Provide custom lowering hooks for some operations. |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame^] | 61 | virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const; |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 62 | |
| 63 | /// getTargetNodeName - This method returns the name of a target specific |
| 64 | /// DAG node. |
| 65 | virtual const char *getTargetNodeName(unsigned Opcode) const; |
| 66 | |
Anton Korobeynikov | 7df8462 | 2009-07-16 14:36:52 +0000 | [diff] [blame] | 67 | /// getFunctionAlignment - Return the Log2 alignment of this function. |
| 68 | virtual unsigned getFunctionAlignment(const Function *F) const { |
| 69 | return 1; |
| 70 | } |
| 71 | |
Anton Korobeynikov | 3c2734c | 2009-08-21 18:15:41 +0000 | [diff] [blame] | 72 | std::pair<unsigned, const TargetRegisterClass*> |
| 73 | getRegForInlineAsmConstraint(const std::string &Constraint, EVT VT) const; |
| 74 | TargetLowering::ConstraintType |
| 75 | getConstraintType(const std::string &Constraint) const; |
| 76 | |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame^] | 77 | SDValue LowerBR_CC(SDValue Op, SelectionDAG &DAG) const; |
| 78 | SDValue LowerSELECT_CC(SDValue Op, SelectionDAG &DAG) const; |
| 79 | SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; |
| 80 | SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const; |
| 81 | SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const; |
Anton Korobeynikov | ba249e4 | 2009-07-16 13:50:21 +0000 | [diff] [blame] | 82 | |
Anton Korobeynikov | 4ec3e5f | 2009-07-16 13:52:31 +0000 | [diff] [blame] | 83 | SDValue EmitCmp(SDValue LHS, SDValue RHS, |
| 84 | ISD::CondCode CC, SDValue &SystemZCC, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame^] | 85 | SelectionDAG &DAG) const; |
Anton Korobeynikov | 4ec3e5f | 2009-07-16 13:52:31 +0000 | [diff] [blame] | 86 | |
Anton Korobeynikov | 7d1e39b | 2009-07-16 13:52:51 +0000 | [diff] [blame] | 87 | |
| 88 | MachineBasicBlock* EmitInstrWithCustomInserter(MachineInstr *MI, |
Evan Cheng | fb2e752 | 2009-09-18 21:02:19 +0000 | [diff] [blame] | 89 | MachineBasicBlock *BB, |
| 90 | DenseMap<MachineBasicBlock*, MachineBasicBlock*> *EM) const; |
Anton Korobeynikov | 7d1e39b | 2009-07-16 13:52:51 +0000 | [diff] [blame] | 91 | |
Evan Cheng | eb2f969 | 2009-10-27 19:56:55 +0000 | [diff] [blame] | 92 | /// isFPImmLegal - Returns true if the target can instruction select the |
| 93 | /// specified FP immediate natively. If false, the legalizer will |
| 94 | /// materialize the FP immediate as a load from a constant pool. |
Evan Cheng | a1eaa3c | 2009-10-28 01:43:28 +0000 | [diff] [blame] | 95 | virtual bool isFPImmLegal(const APFloat &Imm, EVT VT) const; |
Evan Cheng | eb2f969 | 2009-10-27 19:56:55 +0000 | [diff] [blame] | 96 | |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 97 | private: |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 98 | SDValue LowerCCCCallTo(SDValue Chain, SDValue Callee, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 99 | CallingConv::ID CallConv, bool isVarArg, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 100 | bool isTailCall, |
| 101 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 102 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 103 | DebugLoc dl, SelectionDAG &DAG, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame^] | 104 | SmallVectorImpl<SDValue> &InVals) const; |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 105 | |
| 106 | SDValue LowerCCCArguments(SDValue Chain, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 107 | CallingConv::ID CallConv, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 108 | bool isVarArg, |
| 109 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 110 | DebugLoc dl, |
| 111 | SelectionDAG &DAG, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame^] | 112 | SmallVectorImpl<SDValue> &InVals) const; |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 113 | |
| 114 | SDValue LowerCallResult(SDValue Chain, SDValue InFlag, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 115 | CallingConv::ID CallConv, bool isVarArg, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 116 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 117 | DebugLoc dl, SelectionDAG &DAG, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame^] | 118 | SmallVectorImpl<SDValue> &InVals) const; |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 119 | |
| 120 | virtual SDValue |
| 121 | LowerFormalArguments(SDValue Chain, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 122 | CallingConv::ID CallConv, bool isVarArg, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 123 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 124 | DebugLoc dl, SelectionDAG &DAG, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame^] | 125 | SmallVectorImpl<SDValue> &InVals) const; |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 126 | virtual SDValue |
Evan Cheng | 022d9e1 | 2010-02-02 23:55:14 +0000 | [diff] [blame] | 127 | LowerCall(SDValue Chain, SDValue Callee, |
Evan Cheng | 0c439eb | 2010-01-27 00:07:07 +0000 | [diff] [blame] | 128 | CallingConv::ID CallConv, bool isVarArg, bool &isTailCall, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 129 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 130 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 131 | DebugLoc dl, SelectionDAG &DAG, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame^] | 132 | SmallVectorImpl<SDValue> &InVals) const; |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 133 | |
| 134 | virtual SDValue |
| 135 | LowerReturn(SDValue Chain, |
Sandeep Patel | 65c3c8f | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 136 | CallingConv::ID CallConv, bool isVarArg, |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 137 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
Dan Gohman | d858e90 | 2010-04-17 15:26:15 +0000 | [diff] [blame^] | 138 | DebugLoc dl, SelectionDAG &DAG) const; |
Dan Gohman | 98ca4f2 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 139 | |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 140 | const SystemZSubtarget &Subtarget; |
| 141 | const SystemZTargetMachine &TM; |
Anton Korobeynikov | 656ac6f | 2009-07-16 13:51:53 +0000 | [diff] [blame] | 142 | const SystemZRegisterInfo *RegInfo; |
Anton Korobeynikov | 4403b93 | 2009-07-16 13:27:25 +0000 | [diff] [blame] | 143 | }; |
| 144 | } // namespace llvm |
| 145 | |
| 146 | #endif // LLVM_TARGET_SystemZ_ISELLOWERING_H |