| Chris Lattner | 0a1762e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 1 | //===-- SparcISelLowering.h - Sparc 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 Sparc uses to lower LLVM code into a |
| 11 | // selection DAG. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef SPARC_ISELLOWERING_H |
| 16 | #define SPARC_ISELLOWERING_H |
| 17 | |
| Chris Lattner | 0a1762e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 18 | #include "Sparc.h" |
| Craig Topper | b25fda9 | 2012-03-17 18:46:09 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetLowering.h" |
| Chris Lattner | 0a1762e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 20 | |
| 21 | namespace llvm { |
| Jakob Stoklund Olesen | 5ad3b35 | 2013-04-02 04:08:54 +0000 | [diff] [blame] | 22 | class SparcSubtarget; |
| 23 | |
| Chris Lattner | 0a1762e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 24 | namespace SPISD { |
| 25 | enum { |
| Dan Gohman | ed1cf1a | 2008-09-23 18:42:32 +0000 | [diff] [blame] | 26 | FIRST_NUMBER = ISD::BUILTIN_OP_END, |
| Jakob Stoklund Olesen | d9bbdfd | 2013-04-03 04:41:44 +0000 | [diff] [blame] | 27 | CMPICC, // Compare two GPR operands, set icc+xcc. |
| Chris Lattner | 0a1762e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 28 | CMPFCC, // Compare two FP operands, set fcc. |
| 29 | BRICC, // Branch to dest on icc condition |
| Jakob Stoklund Olesen | d9bbdfd | 2013-04-03 04:41:44 +0000 | [diff] [blame] | 30 | BRXCC, // Branch to dest on xcc condition (64-bit only). |
| Chris Lattner | 0a1762e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 31 | BRFCC, // Branch to dest on fcc condition |
| 32 | SELECT_ICC, // Select between two values using the current ICC flags. |
| Jakob Stoklund Olesen | 8cfaffa | 2013-04-04 03:08:00 +0000 | [diff] [blame] | 33 | SELECT_XCC, // Select between two values using the current XCC flags. |
| Chris Lattner | 0a1762e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 34 | SELECT_FCC, // Select between two values using the current FCC flags. |
| Anton Korobeynikov | 281cf24 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 35 | |
| Chris Lattner | 0a1762e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 36 | Hi, Lo, // Hi/Lo operations, typically on a global address. |
| Anton Korobeynikov | 281cf24 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 37 | |
| Chris Lattner | 0a1762e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 38 | FTOI, // FP to Int within a FP register. |
| 39 | ITOF, // Int to FP within a FP register. |
| Anton Korobeynikov | 281cf24 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 40 | |
| Chris Lattner | 0a1762e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 41 | CALL, // A call instruction. |
| Chris Lattner | 840c700 | 2009-09-15 17:46:24 +0000 | [diff] [blame] | 42 | RET_FLAG, // Return with a flag operand. |
| Venkatraman Govindaraju | cb1dca6 | 2013-09-22 06:48:52 +0000 | [diff] [blame] | 43 | GLOBAL_BASE_REG, // Global base reg for PIC. |
| 44 | FLUSHW, // FLUSH register windows to stack. |
| 45 | |
| 46 | TLS_ADD, // For Thread Local Storage (TLS). |
| 47 | TLS_LD, |
| 48 | TLS_CALL |
| Chris Lattner | 0a1762e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 49 | }; |
| 50 | } |
| Anton Korobeynikov | 281cf24 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 51 | |
| Chris Lattner | 0a1762e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 52 | class SparcTargetLowering : public TargetLowering { |
| Jakob Stoklund Olesen | 5ad3b35 | 2013-04-02 04:08:54 +0000 | [diff] [blame] | 53 | const SparcSubtarget *Subtarget; |
| Chris Lattner | 0a1762e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 54 | public: |
| 55 | SparcTargetLowering(TargetMachine &TM); |
| Dan Gohman | 21cea8a | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 56 | virtual SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const; |
| Anton Korobeynikov | 281cf24 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 57 | |
| Anton Korobeynikov | 281cf24 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 58 | /// computeMaskedBitsForTargetNode - Determine which of the bits specified |
| 59 | /// in Mask are known to be either zero or one and return them in the |
| Chris Lattner | 0a1762e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 60 | /// KnownZero/KnownOne bitsets. |
| Dan Gohman | 2ce6f2a | 2008-07-27 21:46:04 +0000 | [diff] [blame] | 61 | virtual void computeMaskedBitsForTargetNode(const SDValue Op, |
| Anton Korobeynikov | 281cf24 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 62 | APInt &KnownZero, |
| Chris Lattner | 0a1762e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 63 | APInt &KnownOne, |
| 64 | const SelectionDAG &DAG, |
| 65 | unsigned Depth = 0) const; |
| Anton Korobeynikov | 281cf24 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 66 | |
| Dan Gohman | 25c1653 | 2010-05-01 00:01:06 +0000 | [diff] [blame] | 67 | virtual MachineBasicBlock * |
| 68 | EmitInstrWithCustomInserter(MachineInstr *MI, |
| 69 | MachineBasicBlock *MBB) const; |
| Anton Korobeynikov | 281cf24 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 70 | |
| Chris Lattner | 0a1762e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 71 | virtual const char *getTargetNodeName(unsigned Opcode) const; |
| Anton Korobeynikov | 281cf24 | 2008-10-10 20:28:10 +0000 | [diff] [blame] | 72 | |
| 73 | ConstraintType getConstraintType(const std::string &Constraint) const; |
| 74 | std::pair<unsigned, const TargetRegisterClass*> |
| Chad Rosier | 295bd43 | 2013-06-22 18:37:38 +0000 | [diff] [blame] | 75 | getRegForInlineAsmConstraint(const std::string &Constraint, MVT VT) const; |
| Dan Gohman | 2fe6bee | 2008-10-18 02:06:02 +0000 | [diff] [blame] | 76 | |
| 77 | virtual bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const; |
| Jakob Stoklund Olesen | eed1072 | 2013-04-14 05:48:50 +0000 | [diff] [blame] | 78 | virtual MVT getScalarShiftAmountTy(EVT LHSTy) const { return MVT::i32; } |
| Bill Wendling | 31ceb1b | 2009-06-30 22:38:32 +0000 | [diff] [blame] | 79 | |
| Dan Gohman | f9bbcd1 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 80 | virtual SDValue |
| 81 | LowerFormalArguments(SDValue Chain, |
| Sandeep Patel | 68c5f47 | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 82 | CallingConv::ID CallConv, |
| Dan Gohman | f9bbcd1 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 83 | bool isVarArg, |
| 84 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 85 | SDLoc dl, SelectionDAG &DAG, |
| Dan Gohman | 21cea8a | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 86 | SmallVectorImpl<SDValue> &InVals) const; |
| Jakob Stoklund Olesen | 0b21f35 | 2013-04-02 04:09:02 +0000 | [diff] [blame] | 87 | SDValue LowerFormalArguments_32(SDValue Chain, |
| 88 | CallingConv::ID CallConv, |
| 89 | bool isVarArg, |
| 90 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 91 | SDLoc dl, SelectionDAG &DAG, |
| Jakob Stoklund Olesen | 0b21f35 | 2013-04-02 04:09:02 +0000 | [diff] [blame] | 92 | SmallVectorImpl<SDValue> &InVals) const; |
| 93 | SDValue LowerFormalArguments_64(SDValue Chain, |
| 94 | CallingConv::ID CallConv, |
| 95 | bool isVarArg, |
| 96 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 97 | SDLoc dl, SelectionDAG &DAG, |
| Jakob Stoklund Olesen | 0b21f35 | 2013-04-02 04:09:02 +0000 | [diff] [blame] | 98 | SmallVectorImpl<SDValue> &InVals) const; |
| Dan Gohman | f9bbcd1 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 99 | |
| 100 | virtual SDValue |
| Justin Holewinski | aa58397 | 2012-05-25 16:35:28 +0000 | [diff] [blame] | 101 | LowerCall(TargetLowering::CallLoweringInfo &CLI, |
| Dan Gohman | 21cea8a | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 102 | SmallVectorImpl<SDValue> &InVals) const; |
| Jakob Stoklund Olesen | a30f483 | 2013-04-07 19:10:57 +0000 | [diff] [blame] | 103 | SDValue LowerCall_32(TargetLowering::CallLoweringInfo &CLI, |
| 104 | SmallVectorImpl<SDValue> &InVals) const; |
| 105 | SDValue LowerCall_64(TargetLowering::CallLoweringInfo &CLI, |
| 106 | SmallVectorImpl<SDValue> &InVals) const; |
| Dan Gohman | f9bbcd1 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 107 | |
| 108 | virtual SDValue |
| 109 | LowerReturn(SDValue Chain, |
| Sandeep Patel | 68c5f47 | 2009-09-02 08:44:58 +0000 | [diff] [blame] | 110 | CallingConv::ID CallConv, bool isVarArg, |
| Dan Gohman | f9bbcd1 | 2009-08-05 01:29:28 +0000 | [diff] [blame] | 111 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| Dan Gohman | fe7532a | 2010-07-07 15:54:55 +0000 | [diff] [blame] | 112 | const SmallVectorImpl<SDValue> &OutVals, |
| Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 113 | SDLoc dl, SelectionDAG &DAG) const; |
| Jakob Stoklund Olesen | edaf66b | 2013-04-06 23:57:33 +0000 | [diff] [blame] | 114 | SDValue LowerReturn_32(SDValue Chain, |
| 115 | CallingConv::ID CallConv, bool IsVarArg, |
| 116 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 117 | const SmallVectorImpl<SDValue> &OutVals, |
| Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 118 | SDLoc DL, SelectionDAG &DAG) const; |
| Jakob Stoklund Olesen | edaf66b | 2013-04-06 23:57:33 +0000 | [diff] [blame] | 119 | SDValue LowerReturn_64(SDValue Chain, |
| 120 | CallingConv::ID CallConv, bool IsVarArg, |
| 121 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 122 | const SmallVectorImpl<SDValue> &OutVals, |
| Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 123 | SDLoc DL, SelectionDAG &DAG) const; |
| Chris Lattner | 840c700 | 2009-09-15 17:46:24 +0000 | [diff] [blame] | 124 | |
| Dan Gohman | 21cea8a | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 125 | SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; |
| Venkatraman Govindaraju | cb1dca6 | 2013-09-22 06:48:52 +0000 | [diff] [blame] | 126 | SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const; |
| Dan Gohman | 21cea8a | 2010-04-17 15:26:15 +0000 | [diff] [blame] | 127 | SDValue LowerConstantPool(SDValue Op, SelectionDAG &DAG) const; |
| Venkatraman Govindaraju | f80d72f | 2013-06-03 05:58:33 +0000 | [diff] [blame] | 128 | SDValue LowerBlockAddress(SDValue Op, SelectionDAG &DAG) const; |
| Venkatraman Govindaraju | a82203f | 2011-02-21 03:42:44 +0000 | [diff] [blame] | 129 | |
| 130 | unsigned getSRetArgSize(SelectionDAG &DAG, SDValue Callee) const; |
| Jakob Stoklund Olesen | 1fb08a8 | 2013-04-14 01:33:32 +0000 | [diff] [blame] | 131 | SDValue withTargetFlags(SDValue Op, unsigned TF, SelectionDAG &DAG) const; |
| 132 | SDValue makeHiLoPair(SDValue Op, unsigned HiTF, unsigned LoTF, |
| 133 | SelectionDAG &DAG) const; |
| Jakob Stoklund Olesen | e0fc832 | 2013-04-14 04:35:16 +0000 | [diff] [blame] | 134 | SDValue makeAddress(SDValue Op, SelectionDAG &DAG) const; |
| Venkatraman Govindaraju | 59039dc | 2013-09-03 04:11:59 +0000 | [diff] [blame] | 135 | |
| 136 | SDValue LowerF128_LibCallArg(SDValue Chain, ArgListTy &Args, |
| 137 | SDValue Arg, SDLoc DL, |
| 138 | SelectionDAG &DAG) const; |
| 139 | SDValue LowerF128Op(SDValue Op, SelectionDAG &DAG, |
| 140 | const char *LibFuncName, |
| 141 | unsigned numArgs) const; |
| 142 | SDValue LowerF128Compare(SDValue LHS, SDValue RHS, |
| 143 | unsigned &SPCC, |
| 144 | SDLoc DL, |
| 145 | SelectionDAG &DAG) const; |
| 146 | |
| 147 | bool ShouldShrinkFPConstant(EVT VT) const { |
| 148 | // Do not shrink FP constpool if VT == MVT::f128. |
| 149 | // (ldd, call _Q_fdtoq) is more expensive than two ldds. |
| 150 | return VT != MVT::f128; |
| 151 | } |
| Chris Lattner | 0a1762e | 2008-03-17 03:21:36 +0000 | [diff] [blame] | 152 | }; |
| 153 | } // end namespace llvm |
| 154 | |
| 155 | #endif // SPARC_ISELLOWERING_H |