Jia Liu | b22310f | 2012-02-18 12:03:15 +0000 | [diff] [blame] | 1 | //===-- HexagonISelDAGToDAG.cpp - A dag to dag inst selector for Hexagon --===// |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 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 an instruction selector for the Hexagon target. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 14 | #include "Hexagon.h" |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 15 | #include "HexagonISelLowering.h" |
| 16 | #include "HexagonTargetMachine.h" |
Jyotsna Verma | d922524 | 2013-02-13 21:38:46 +0000 | [diff] [blame] | 17 | #include "llvm/ADT/DenseMap.h" |
Jyotsna Verma | d922524 | 2013-02-13 21:38:46 +0000 | [diff] [blame] | 18 | #include "llvm/CodeGen/SelectionDAGISel.h" |
Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 19 | #include "llvm/IR/Intrinsics.h" |
Jyotsna Verma | d922524 | 2013-02-13 21:38:46 +0000 | [diff] [blame] | 20 | #include "llvm/Support/CommandLine.h" |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 21 | #include "llvm/Support/Compiler.h" |
| 22 | #include "llvm/Support/Debug.h" |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 23 | using namespace llvm; |
| 24 | |
Chandler Carruth | 84e68b2 | 2014-04-22 02:41:26 +0000 | [diff] [blame] | 25 | #define DEBUG_TYPE "hexagon-isel" |
| 26 | |
Jyotsna Verma | d922524 | 2013-02-13 21:38:46 +0000 | [diff] [blame] | 27 | static |
| 28 | cl::opt<unsigned> |
| 29 | MaxNumOfUsesForConstExtenders("ga-max-num-uses-for-constant-extenders", |
| 30 | cl::Hidden, cl::init(2), |
| 31 | cl::desc("Maximum number of uses of a global address such that we still us a" |
| 32 | "constant extended instruction")); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 33 | |
| 34 | //===----------------------------------------------------------------------===// |
| 35 | // Instruction Selector Implementation |
| 36 | //===----------------------------------------------------------------------===// |
| 37 | |
Jyotsna Verma | d922524 | 2013-02-13 21:38:46 +0000 | [diff] [blame] | 38 | namespace llvm { |
| 39 | void initializeHexagonDAGToDAGISelPass(PassRegistry&); |
| 40 | } |
| 41 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 42 | //===--------------------------------------------------------------------===// |
| 43 | /// HexagonDAGToDAGISel - Hexagon specific code to select Hexagon machine |
| 44 | /// instructions for SelectionDAG operations. |
| 45 | /// |
| 46 | namespace { |
| 47 | class HexagonDAGToDAGISel : public SelectionDAGISel { |
| 48 | /// Subtarget - Keep a pointer to the Hexagon Subtarget around so that we can |
| 49 | /// make the right decision when generating code for different targets. |
| 50 | const HexagonSubtarget &Subtarget; |
| 51 | |
| 52 | // Keep a reference to HexagonTargetMachine. |
Krzysztof Parzyszek | d500747 | 2013-05-06 18:38:37 +0000 | [diff] [blame] | 53 | const HexagonTargetMachine& TM; |
Jyotsna Verma | d922524 | 2013-02-13 21:38:46 +0000 | [diff] [blame] | 54 | DenseMap<const GlobalValue *, unsigned> GlobalAddressUseCountMap; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 55 | public: |
Bill Wendling | a3cd350 | 2013-06-19 21:36:55 +0000 | [diff] [blame] | 56 | explicit HexagonDAGToDAGISel(HexagonTargetMachine &targetmachine, |
Jyotsna Verma | d922524 | 2013-02-13 21:38:46 +0000 | [diff] [blame] | 57 | CodeGenOpt::Level OptLevel) |
| 58 | : SelectionDAGISel(targetmachine, OptLevel), |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 59 | Subtarget(targetmachine.getSubtarget<HexagonSubtarget>()), |
Bill Wendling | 4a7a408 | 2013-06-07 06:19:56 +0000 | [diff] [blame] | 60 | TM(targetmachine) { |
Jyotsna Verma | d922524 | 2013-02-13 21:38:46 +0000 | [diff] [blame] | 61 | initializeHexagonDAGToDAGISelPass(*PassRegistry::getPassRegistry()); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 62 | } |
Jyotsna Verma | d922524 | 2013-02-13 21:38:46 +0000 | [diff] [blame] | 63 | bool hasNumUsesBelowThresGA(SDNode *N) const; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 64 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 65 | SDNode *Select(SDNode *N) override; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 66 | |
| 67 | // Complex Pattern Selectors. |
Jyotsna Verma | d922524 | 2013-02-13 21:38:46 +0000 | [diff] [blame] | 68 | inline bool foldGlobalAddress(SDValue &N, SDValue &R); |
| 69 | inline bool foldGlobalAddressGP(SDValue &N, SDValue &R); |
| 70 | bool foldGlobalAddressImpl(SDValue &N, SDValue &R, bool ShouldLookForGP); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 71 | bool SelectADDRri(SDValue& N, SDValue &R1, SDValue &R2); |
| 72 | bool SelectADDRriS11_0(SDValue& N, SDValue &R1, SDValue &R2); |
| 73 | bool SelectADDRriS11_1(SDValue& N, SDValue &R1, SDValue &R2); |
| 74 | bool SelectADDRriS11_2(SDValue& N, SDValue &R1, SDValue &R2); |
| 75 | bool SelectMEMriS11_2(SDValue& Addr, SDValue &Base, SDValue &Offset); |
| 76 | bool SelectADDRriS11_3(SDValue& N, SDValue &R1, SDValue &R2); |
| 77 | bool SelectADDRrr(SDValue &Addr, SDValue &Base, SDValue &Offset); |
| 78 | bool SelectADDRriU6_0(SDValue& N, SDValue &R1, SDValue &R2); |
| 79 | bool SelectADDRriU6_1(SDValue& N, SDValue &R1, SDValue &R2); |
| 80 | bool SelectADDRriU6_2(SDValue& N, SDValue &R1, SDValue &R2); |
| 81 | |
Colin LeMahieu | c7522f3 | 2015-01-14 23:07:36 +0000 | [diff] [blame^] | 82 | bool SelectAddrFI(SDValue &N, SDValue &R); |
| 83 | |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 84 | const char *getPassName() const override { |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 85 | return "Hexagon DAG->DAG Pattern Instruction Selection"; |
| 86 | } |
| 87 | |
| 88 | /// SelectInlineAsmMemoryOperand - Implement addressing mode selection for |
| 89 | /// inline asm expressions. |
Craig Topper | 906c2cd | 2014-04-29 07:58:16 +0000 | [diff] [blame] | 90 | bool SelectInlineAsmMemoryOperand(const SDValue &Op, |
| 91 | char ConstraintCode, |
| 92 | std::vector<SDValue> &OutOps) override; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 93 | bool SelectAddr(SDNode *Op, SDValue Addr, SDValue &Base, SDValue &Offset); |
| 94 | |
| 95 | SDNode *SelectLoad(SDNode *N); |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 96 | SDNode *SelectBaseOffsetLoad(LoadSDNode *LD, SDLoc dl); |
| 97 | SDNode *SelectIndexedLoad(LoadSDNode *LD, SDLoc dl); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 98 | SDNode *SelectIndexedLoadZeroExtend64(LoadSDNode *LD, unsigned Opcode, |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 99 | SDLoc dl); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 100 | SDNode *SelectIndexedLoadSignExtend64(LoadSDNode *LD, unsigned Opcode, |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 101 | SDLoc dl); |
| 102 | SDNode *SelectBaseOffsetStore(StoreSDNode *ST, SDLoc dl); |
| 103 | SDNode *SelectIndexedStore(StoreSDNode *ST, SDLoc dl); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 104 | SDNode *SelectStore(SDNode *N); |
| 105 | SDNode *SelectSHL(SDNode *N); |
| 106 | SDNode *SelectSelect(SDNode *N); |
| 107 | SDNode *SelectTruncate(SDNode *N); |
| 108 | SDNode *SelectMul(SDNode *N); |
| 109 | SDNode *SelectZeroExtend(SDNode *N); |
| 110 | SDNode *SelectIntrinsicWOChain(SDNode *N); |
Sirish Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 111 | SDNode *SelectIntrinsicWChain(SDNode *N); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 112 | SDNode *SelectConstant(SDNode *N); |
Sirish Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 113 | SDNode *SelectConstantFP(SDNode *N); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 114 | SDNode *SelectAdd(SDNode *N); |
Jyotsna Verma | 519b385 | 2012-11-28 20:58:14 +0000 | [diff] [blame] | 115 | bool isConstExtProfitable(SDNode *N) const; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 116 | |
Jyotsna Verma | fdc660b | 2013-03-22 18:41:34 +0000 | [diff] [blame] | 117 | // XformMskToBitPosU5Imm - Returns the bit position which |
| 118 | // the single bit 32 bit mask represents. |
| 119 | // Used in Clr and Set bit immediate memops. |
| 120 | SDValue XformMskToBitPosU5Imm(uint32_t Imm) { |
| 121 | int32_t bitPos; |
| 122 | bitPos = Log2_32(Imm); |
| 123 | assert(bitPos >= 0 && bitPos < 32 && |
| 124 | "Constant out of range for 32 BitPos Memops"); |
| 125 | return CurDAG->getTargetConstant(bitPos, MVT::i32); |
| 126 | } |
| 127 | |
| 128 | // XformMskToBitPosU4Imm - Returns the bit position which the single bit 16 bit |
| 129 | // mask represents. Used in Clr and Set bit immediate memops. |
| 130 | SDValue XformMskToBitPosU4Imm(uint16_t Imm) { |
| 131 | return XformMskToBitPosU5Imm(Imm); |
| 132 | } |
| 133 | |
| 134 | // XformMskToBitPosU3Imm - Returns the bit position which the single bit 8 bit |
| 135 | // mask represents. Used in Clr and Set bit immediate memops. |
| 136 | SDValue XformMskToBitPosU3Imm(uint8_t Imm) { |
| 137 | return XformMskToBitPosU5Imm(Imm); |
| 138 | } |
| 139 | |
| 140 | // Return true if there is exactly one bit set in V, i.e., if V is one of the |
| 141 | // following integers: 2^0, 2^1, ..., 2^31. |
| 142 | bool ImmIsSingleBit(uint32_t v) const { |
| 143 | uint32_t c = CountPopulation_64(v); |
| 144 | // Only return true if we counted 1 bit. |
| 145 | return c == 1; |
| 146 | } |
| 147 | |
| 148 | // XformM5ToU5Imm - Return a target constant with the specified value, of type |
| 149 | // i32 where the negative literal is transformed into a positive literal for |
| 150 | // use in -= memops. |
| 151 | inline SDValue XformM5ToU5Imm(signed Imm) { |
| 152 | assert( (Imm >= -31 && Imm <= -1) && "Constant out of range for Memops"); |
| 153 | return CurDAG->getTargetConstant( - Imm, MVT::i32); |
| 154 | } |
| 155 | |
| 156 | |
Jyotsna Verma | 6031625 | 2013-02-05 19:20:45 +0000 | [diff] [blame] | 157 | // XformU7ToU7M1Imm - Return a target constant decremented by 1, in range |
| 158 | // [1..128], used in cmpb.gtu instructions. |
| 159 | inline SDValue XformU7ToU7M1Imm(signed Imm) { |
| 160 | assert((Imm >= 1 && Imm <= 128) && "Constant out of range for cmpb op"); |
| 161 | return CurDAG->getTargetConstant(Imm - 1, MVT::i8); |
| 162 | } |
| 163 | |
Jyotsna Verma | 89c8482 | 2013-04-23 19:15:55 +0000 | [diff] [blame] | 164 | // XformS8ToS8M1Imm - Return a target constant decremented by 1. |
| 165 | inline SDValue XformSToSM1Imm(signed Imm) { |
| 166 | return CurDAG->getTargetConstant(Imm - 1, MVT::i32); |
| 167 | } |
| 168 | |
| 169 | // XformU8ToU8M1Imm - Return a target constant decremented by 1. |
| 170 | inline SDValue XformUToUM1Imm(unsigned Imm) { |
| 171 | assert((Imm >= 1) && "Cannot decrement unsigned int less than 1"); |
| 172 | return CurDAG->getTargetConstant(Imm - 1, MVT::i32); |
| 173 | } |
| 174 | |
Jyotsna Verma | 6031625 | 2013-02-05 19:20:45 +0000 | [diff] [blame] | 175 | // Include the pieces autogenerated from the target description. |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 176 | #include "HexagonGenDAGISel.inc" |
| 177 | }; |
| 178 | } // end anonymous namespace |
| 179 | |
| 180 | |
| 181 | /// createHexagonISelDag - This pass converts a legalized DAG into a |
| 182 | /// Hexagon-specific DAG, ready for instruction scheduling. |
| 183 | /// |
Bill Wendling | a3cd350 | 2013-06-19 21:36:55 +0000 | [diff] [blame] | 184 | FunctionPass *llvm::createHexagonISelDag(HexagonTargetMachine &TM, |
Jyotsna Verma | d922524 | 2013-02-13 21:38:46 +0000 | [diff] [blame] | 185 | CodeGenOpt::Level OptLevel) { |
| 186 | return new HexagonDAGToDAGISel(TM, OptLevel); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 187 | } |
| 188 | |
Jyotsna Verma | d922524 | 2013-02-13 21:38:46 +0000 | [diff] [blame] | 189 | static void initializePassOnce(PassRegistry &Registry) { |
| 190 | const char *Name = "Hexagon DAG->DAG Pattern Instruction Selection"; |
| 191 | PassInfo *PI = new PassInfo(Name, "hexagon-isel", |
Craig Topper | 062a2ba | 2014-04-25 05:30:21 +0000 | [diff] [blame] | 192 | &SelectionDAGISel::ID, nullptr, false, false); |
Jyotsna Verma | d922524 | 2013-02-13 21:38:46 +0000 | [diff] [blame] | 193 | Registry.registerPass(*PI, true); |
| 194 | } |
| 195 | |
| 196 | void llvm::initializeHexagonDAGToDAGISelPass(PassRegistry &Registry) { |
| 197 | CALL_ONCE_INITIALIZATION(initializePassOnce) |
| 198 | } |
| 199 | |
| 200 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 201 | static bool IsS11_0_Offset(SDNode * S) { |
| 202 | ConstantSDNode *N = cast<ConstantSDNode>(S); |
| 203 | |
| 204 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 205 | // field. |
| 206 | int64_t v = (int64_t)N->getSExtValue(); |
| 207 | return isInt<11>(v); |
| 208 | } |
| 209 | |
| 210 | |
| 211 | static bool IsS11_1_Offset(SDNode * S) { |
| 212 | ConstantSDNode *N = cast<ConstantSDNode>(S); |
| 213 | |
| 214 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 215 | // field. |
| 216 | int64_t v = (int64_t)N->getSExtValue(); |
| 217 | return isShiftedInt<11,1>(v); |
| 218 | } |
| 219 | |
| 220 | |
| 221 | static bool IsS11_2_Offset(SDNode * S) { |
| 222 | ConstantSDNode *N = cast<ConstantSDNode>(S); |
| 223 | |
| 224 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 225 | // field. |
| 226 | int64_t v = (int64_t)N->getSExtValue(); |
| 227 | return isShiftedInt<11,2>(v); |
| 228 | } |
| 229 | |
| 230 | |
| 231 | static bool IsS11_3_Offset(SDNode * S) { |
| 232 | ConstantSDNode *N = cast<ConstantSDNode>(S); |
| 233 | |
| 234 | // immS16 predicate - True if the immediate fits in a 16-bit sign extended |
| 235 | // field. |
| 236 | int64_t v = (int64_t)N->getSExtValue(); |
| 237 | return isShiftedInt<11,3>(v); |
| 238 | } |
| 239 | |
| 240 | |
| 241 | static bool IsU6_0_Offset(SDNode * S) { |
| 242 | ConstantSDNode *N = cast<ConstantSDNode>(S); |
| 243 | |
| 244 | // u6 predicate - True if the immediate fits in a 6-bit unsigned extended |
| 245 | // field. |
| 246 | int64_t v = (int64_t)N->getSExtValue(); |
| 247 | return isUInt<6>(v); |
| 248 | } |
| 249 | |
| 250 | |
| 251 | static bool IsU6_1_Offset(SDNode * S) { |
| 252 | ConstantSDNode *N = cast<ConstantSDNode>(S); |
| 253 | |
| 254 | // u6 predicate - True if the immediate fits in a 6-bit unsigned extended |
| 255 | // field. |
| 256 | int64_t v = (int64_t)N->getSExtValue(); |
| 257 | return isShiftedUInt<6,1>(v); |
| 258 | } |
| 259 | |
| 260 | |
| 261 | static bool IsU6_2_Offset(SDNode * S) { |
| 262 | ConstantSDNode *N = cast<ConstantSDNode>(S); |
| 263 | |
| 264 | // u6 predicate - True if the immediate fits in a 6-bit unsigned extended |
| 265 | // field. |
| 266 | int64_t v = (int64_t)N->getSExtValue(); |
| 267 | return isShiftedUInt<6,2>(v); |
| 268 | } |
| 269 | |
| 270 | |
| 271 | // Intrinsics that return a a predicate. |
| 272 | static unsigned doesIntrinsicReturnPredicate(unsigned ID) |
| 273 | { |
| 274 | switch (ID) { |
| 275 | default: |
| 276 | return 0; |
| 277 | case Intrinsic::hexagon_C2_cmpeq: |
| 278 | case Intrinsic::hexagon_C2_cmpgt: |
| 279 | case Intrinsic::hexagon_C2_cmpgtu: |
| 280 | case Intrinsic::hexagon_C2_cmpgtup: |
| 281 | case Intrinsic::hexagon_C2_cmpgtp: |
| 282 | case Intrinsic::hexagon_C2_cmpeqp: |
| 283 | case Intrinsic::hexagon_C2_bitsset: |
| 284 | case Intrinsic::hexagon_C2_bitsclr: |
| 285 | case Intrinsic::hexagon_C2_cmpeqi: |
| 286 | case Intrinsic::hexagon_C2_cmpgti: |
| 287 | case Intrinsic::hexagon_C2_cmpgtui: |
| 288 | case Intrinsic::hexagon_C2_cmpgei: |
| 289 | case Intrinsic::hexagon_C2_cmpgeui: |
| 290 | case Intrinsic::hexagon_C2_cmplt: |
| 291 | case Intrinsic::hexagon_C2_cmpltu: |
| 292 | case Intrinsic::hexagon_C2_bitsclri: |
| 293 | case Intrinsic::hexagon_C2_and: |
| 294 | case Intrinsic::hexagon_C2_or: |
| 295 | case Intrinsic::hexagon_C2_xor: |
| 296 | case Intrinsic::hexagon_C2_andn: |
| 297 | case Intrinsic::hexagon_C2_not: |
| 298 | case Intrinsic::hexagon_C2_orn: |
| 299 | case Intrinsic::hexagon_C2_pxfer_map: |
| 300 | case Intrinsic::hexagon_C2_any8: |
| 301 | case Intrinsic::hexagon_C2_all8: |
| 302 | case Intrinsic::hexagon_A2_vcmpbeq: |
| 303 | case Intrinsic::hexagon_A2_vcmpbgtu: |
| 304 | case Intrinsic::hexagon_A2_vcmpheq: |
| 305 | case Intrinsic::hexagon_A2_vcmphgt: |
| 306 | case Intrinsic::hexagon_A2_vcmphgtu: |
| 307 | case Intrinsic::hexagon_A2_vcmpweq: |
| 308 | case Intrinsic::hexagon_A2_vcmpwgt: |
| 309 | case Intrinsic::hexagon_A2_vcmpwgtu: |
| 310 | case Intrinsic::hexagon_C2_tfrrp: |
| 311 | case Intrinsic::hexagon_S2_tstbit_i: |
| 312 | case Intrinsic::hexagon_S2_tstbit_r: |
| 313 | return 1; |
| 314 | } |
| 315 | } |
| 316 | |
| 317 | |
| 318 | // Intrinsics that have predicate operands. |
| 319 | static unsigned doesIntrinsicContainPredicate(unsigned ID) |
| 320 | { |
| 321 | switch (ID) { |
| 322 | default: |
| 323 | return 0; |
| 324 | case Intrinsic::hexagon_C2_tfrpr: |
Colin LeMahieu | 30dcb23 | 2014-12-09 18:16:49 +0000 | [diff] [blame] | 325 | return Hexagon::C2_tfrpr; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 326 | case Intrinsic::hexagon_C2_and: |
Colin LeMahieu | 5cf5632 | 2014-12-08 23:55:43 +0000 | [diff] [blame] | 327 | return Hexagon::C2_and; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 328 | case Intrinsic::hexagon_C2_xor: |
Colin LeMahieu | 5cf5632 | 2014-12-08 23:55:43 +0000 | [diff] [blame] | 329 | return Hexagon::C2_xor; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 330 | case Intrinsic::hexagon_C2_or: |
Colin LeMahieu | 5cf5632 | 2014-12-08 23:55:43 +0000 | [diff] [blame] | 331 | return Hexagon::C2_or; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 332 | case Intrinsic::hexagon_C2_not: |
Colin LeMahieu | 5cf5632 | 2014-12-08 23:55:43 +0000 | [diff] [blame] | 333 | return Hexagon::C2_not; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 334 | case Intrinsic::hexagon_C2_any8: |
Colin LeMahieu | 5cf5632 | 2014-12-08 23:55:43 +0000 | [diff] [blame] | 335 | return Hexagon::C2_any8; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 336 | case Intrinsic::hexagon_C2_all8: |
Colin LeMahieu | 5cf5632 | 2014-12-08 23:55:43 +0000 | [diff] [blame] | 337 | return Hexagon::C2_all8; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 338 | case Intrinsic::hexagon_C2_vitpack: |
Colin LeMahieu | 5cf5632 | 2014-12-08 23:55:43 +0000 | [diff] [blame] | 339 | return Hexagon::C2_vitpack; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 340 | case Intrinsic::hexagon_C2_mask: |
Colin LeMahieu | 5cf5632 | 2014-12-08 23:55:43 +0000 | [diff] [blame] | 341 | return Hexagon::C2_mask; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 342 | case Intrinsic::hexagon_C2_mux: |
Colin LeMahieu | e83bc74 | 2014-11-25 20:20:09 +0000 | [diff] [blame] | 343 | return Hexagon::C2_mux; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 344 | |
| 345 | // Mapping hexagon_C2_muxir to MUX_pri. This is pretty weird - but |
| 346 | // that's how it's mapped in q6protos.h. |
| 347 | case Intrinsic::hexagon_C2_muxir: |
Colin LeMahieu | 9665f98 | 2014-12-05 21:09:27 +0000 | [diff] [blame] | 348 | return Hexagon::C2_muxri; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 349 | |
| 350 | // Mapping hexagon_C2_muxri to MUX_pir. This is pretty weird - but |
| 351 | // that's how it's mapped in q6protos.h. |
| 352 | case Intrinsic::hexagon_C2_muxri: |
Colin LeMahieu | 9665f98 | 2014-12-05 21:09:27 +0000 | [diff] [blame] | 353 | return Hexagon::C2_muxir; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 354 | |
| 355 | case Intrinsic::hexagon_C2_muxii: |
Colin LeMahieu | 9665f98 | 2014-12-05 21:09:27 +0000 | [diff] [blame] | 356 | return Hexagon::C2_muxii; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 357 | case Intrinsic::hexagon_C2_vmux: |
| 358 | return Hexagon::VMUX_prr64; |
| 359 | case Intrinsic::hexagon_S2_valignrb: |
| 360 | return Hexagon::VALIGN_rrp; |
| 361 | case Intrinsic::hexagon_S2_vsplicerb: |
| 362 | return Hexagon::VSPLICE_rrp; |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | |
| 367 | static bool OffsetFitsS11(EVT MemType, int64_t Offset) { |
| 368 | if (MemType == MVT::i64 && isShiftedInt<11,3>(Offset)) { |
| 369 | return true; |
| 370 | } |
| 371 | if (MemType == MVT::i32 && isShiftedInt<11,2>(Offset)) { |
| 372 | return true; |
| 373 | } |
| 374 | if (MemType == MVT::i16 && isShiftedInt<11,1>(Offset)) { |
| 375 | return true; |
| 376 | } |
| 377 | if (MemType == MVT::i8 && isInt<11>(Offset)) { |
| 378 | return true; |
| 379 | } |
| 380 | return false; |
| 381 | } |
| 382 | |
| 383 | |
| 384 | // |
| 385 | // Try to lower loads of GlobalAdresses into base+offset loads. Custom |
| 386 | // lowering for GlobalAddress nodes has already turned it into a |
| 387 | // CONST32. |
| 388 | // |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 389 | SDNode *HexagonDAGToDAGISel::SelectBaseOffsetLoad(LoadSDNode *LD, SDLoc dl) { |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 390 | SDValue Chain = LD->getChain(); |
| 391 | SDNode* Const32 = LD->getBasePtr().getNode(); |
| 392 | unsigned Opcode = 0; |
| 393 | |
| 394 | if (Const32->getOpcode() == HexagonISD::CONST32 && |
| 395 | ISD::isNormalLoad(LD)) { |
| 396 | SDValue Base = Const32->getOperand(0); |
| 397 | EVT LoadedVT = LD->getMemoryVT(); |
| 398 | int64_t Offset = cast<GlobalAddressSDNode>(Base)->getOffset(); |
| 399 | if (Offset != 0 && OffsetFitsS11(LoadedVT, Offset)) { |
Bill Wendling | a3cd350 | 2013-06-19 21:36:55 +0000 | [diff] [blame] | 400 | MVT PointerTy = getTargetLowering()->getPointerTy(); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 401 | const GlobalValue* GV = |
| 402 | cast<GlobalAddressSDNode>(Base)->getGlobal(); |
| 403 | SDValue TargAddr = |
| 404 | CurDAG->getTargetGlobalAddress(GV, dl, PointerTy, 0); |
Brendon Cahoon | f6b687e | 2012-05-14 19:35:42 +0000 | [diff] [blame] | 405 | SDNode* NewBase = CurDAG->getMachineNode(Hexagon::CONST32_set, |
| 406 | dl, PointerTy, |
| 407 | TargAddr); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 408 | // Figure out base + offset opcode |
Colin LeMahieu | 947cd70 | 2014-12-23 20:44:59 +0000 | [diff] [blame] | 409 | if (LoadedVT == MVT::i64) Opcode = Hexagon::L2_loadrd_io; |
Colin LeMahieu | 026e88d | 2014-12-23 20:02:16 +0000 | [diff] [blame] | 410 | else if (LoadedVT == MVT::i32) Opcode = Hexagon::L2_loadri_io; |
Colin LeMahieu | 8e39cad | 2014-12-23 17:25:57 +0000 | [diff] [blame] | 411 | else if (LoadedVT == MVT::i16) Opcode = Hexagon::L2_loadrh_io; |
Colin LeMahieu | 4b1eac4 | 2014-12-22 21:40:43 +0000 | [diff] [blame] | 412 | else if (LoadedVT == MVT::i8) Opcode = Hexagon::L2_loadrb_io; |
Sirish Pande | f8e5e3c | 2012-05-03 21:52:53 +0000 | [diff] [blame] | 413 | else llvm_unreachable("unknown memory type"); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 414 | |
| 415 | // Build indexed load. |
| 416 | SDValue TargetConstOff = CurDAG->getTargetConstant(Offset, PointerTy); |
| 417 | SDNode* Result = CurDAG->getMachineNode(Opcode, dl, |
| 418 | LD->getValueType(0), |
| 419 | MVT::Other, |
| 420 | SDValue(NewBase,0), |
| 421 | TargetConstOff, |
| 422 | Chain); |
| 423 | MachineSDNode::mmo_iterator MemOp = MF->allocateMemRefsArray(1); |
| 424 | MemOp[0] = LD->getMemOperand(); |
| 425 | cast<MachineSDNode>(Result)->setMemRefs(MemOp, MemOp + 1); |
| 426 | ReplaceUses(LD, Result); |
| 427 | return Result; |
| 428 | } |
| 429 | } |
| 430 | |
| 431 | return SelectCode(LD); |
| 432 | } |
| 433 | |
| 434 | |
| 435 | SDNode *HexagonDAGToDAGISel::SelectIndexedLoadSignExtend64(LoadSDNode *LD, |
| 436 | unsigned Opcode, |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 437 | SDLoc dl) |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 438 | { |
| 439 | SDValue Chain = LD->getChain(); |
| 440 | EVT LoadedVT = LD->getMemoryVT(); |
| 441 | SDValue Base = LD->getBasePtr(); |
| 442 | SDValue Offset = LD->getOffset(); |
| 443 | SDNode *OffsetNode = Offset.getNode(); |
| 444 | int32_t Val = cast<ConstantSDNode>(OffsetNode)->getSExtValue(); |
| 445 | SDValue N1 = LD->getOperand(1); |
| 446 | SDValue CPTmpN1_0; |
| 447 | SDValue CPTmpN1_1; |
Bill Wendling | 4a7a408 | 2013-06-07 06:19:56 +0000 | [diff] [blame] | 448 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 449 | if (SelectADDRriS11_2(N1, CPTmpN1_0, CPTmpN1_1) && |
| 450 | N1.getNode()->getValueType(0) == MVT::i32) { |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 451 | const HexagonInstrInfo *TII = static_cast<const HexagonInstrInfo *>( |
| 452 | TM.getSubtargetImpl()->getInstrInfo()); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 453 | if (TII->isValidAutoIncImm(LoadedVT, Val)) { |
| 454 | SDValue TargetConst = CurDAG->getTargetConstant(Val, MVT::i32); |
| 455 | SDNode *Result_1 = CurDAG->getMachineNode(Opcode, dl, MVT::i32, MVT::i32, |
| 456 | MVT::Other, Base, TargetConst, |
| 457 | Chain); |
Colin LeMahieu | eb52f69 | 2014-12-11 16:43:06 +0000 | [diff] [blame] | 458 | SDNode *Result_2 = CurDAG->getMachineNode(Hexagon::A2_sxtw, dl, MVT::i64, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 459 | SDValue(Result_1, 0)); |
| 460 | MachineSDNode::mmo_iterator MemOp = MF->allocateMemRefsArray(1); |
| 461 | MemOp[0] = LD->getMemOperand(); |
| 462 | cast<MachineSDNode>(Result_1)->setMemRefs(MemOp, MemOp + 1); |
| 463 | const SDValue Froms[] = { SDValue(LD, 0), |
| 464 | SDValue(LD, 1), |
| 465 | SDValue(LD, 2) |
| 466 | }; |
| 467 | const SDValue Tos[] = { SDValue(Result_2, 0), |
| 468 | SDValue(Result_1, 1), |
| 469 | SDValue(Result_1, 2) |
| 470 | }; |
| 471 | ReplaceUses(Froms, Tos, 3); |
| 472 | return Result_2; |
Sirish Pande | c92c316 | 2012-05-03 16:18:50 +0000 | [diff] [blame] | 473 | } |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 474 | SDValue TargetConst0 = CurDAG->getTargetConstant(0, MVT::i32); |
| 475 | SDValue TargetConstVal = CurDAG->getTargetConstant(Val, MVT::i32); |
| 476 | SDNode *Result_1 = CurDAG->getMachineNode(Opcode, dl, MVT::i32, |
| 477 | MVT::Other, Base, TargetConst0, |
| 478 | Chain); |
Colin LeMahieu | eb52f69 | 2014-12-11 16:43:06 +0000 | [diff] [blame] | 479 | SDNode *Result_2 = CurDAG->getMachineNode(Hexagon::A2_sxtw, dl, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 480 | MVT::i64, SDValue(Result_1, 0)); |
| 481 | SDNode* Result_3 = CurDAG->getMachineNode(Hexagon::ADD_ri, dl, |
| 482 | MVT::i32, Base, TargetConstVal, |
| 483 | SDValue(Result_1, 1)); |
| 484 | MachineSDNode::mmo_iterator MemOp = MF->allocateMemRefsArray(1); |
| 485 | MemOp[0] = LD->getMemOperand(); |
| 486 | cast<MachineSDNode>(Result_1)->setMemRefs(MemOp, MemOp + 1); |
| 487 | const SDValue Froms[] = { SDValue(LD, 0), |
| 488 | SDValue(LD, 1), |
| 489 | SDValue(LD, 2) |
| 490 | }; |
| 491 | const SDValue Tos[] = { SDValue(Result_2, 0), |
| 492 | SDValue(Result_3, 0), |
| 493 | SDValue(Result_1, 1) |
| 494 | }; |
| 495 | ReplaceUses(Froms, Tos, 3); |
| 496 | return Result_2; |
| 497 | } |
| 498 | return SelectCode(LD); |
| 499 | } |
| 500 | |
| 501 | |
| 502 | SDNode *HexagonDAGToDAGISel::SelectIndexedLoadZeroExtend64(LoadSDNode *LD, |
| 503 | unsigned Opcode, |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 504 | SDLoc dl) |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 505 | { |
| 506 | SDValue Chain = LD->getChain(); |
| 507 | EVT LoadedVT = LD->getMemoryVT(); |
| 508 | SDValue Base = LD->getBasePtr(); |
| 509 | SDValue Offset = LD->getOffset(); |
| 510 | SDNode *OffsetNode = Offset.getNode(); |
| 511 | int32_t Val = cast<ConstantSDNode>(OffsetNode)->getSExtValue(); |
| 512 | SDValue N1 = LD->getOperand(1); |
| 513 | SDValue CPTmpN1_0; |
| 514 | SDValue CPTmpN1_1; |
Bill Wendling | 4a7a408 | 2013-06-07 06:19:56 +0000 | [diff] [blame] | 515 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 516 | if (SelectADDRriS11_2(N1, CPTmpN1_0, CPTmpN1_1) && |
| 517 | N1.getNode()->getValueType(0) == MVT::i32) { |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 518 | const HexagonInstrInfo *TII = static_cast<const HexagonInstrInfo *>( |
| 519 | TM.getSubtargetImpl()->getInstrInfo()); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 520 | if (TII->isValidAutoIncImm(LoadedVT, Val)) { |
| 521 | SDValue TargetConstVal = CurDAG->getTargetConstant(Val, MVT::i32); |
| 522 | SDValue TargetConst0 = CurDAG->getTargetConstant(0, MVT::i32); |
| 523 | SDNode *Result_1 = CurDAG->getMachineNode(Opcode, dl, MVT::i32, |
| 524 | MVT::i32, MVT::Other, Base, |
| 525 | TargetConstVal, Chain); |
Colin LeMahieu | 4af437f | 2014-12-09 20:23:30 +0000 | [diff] [blame] | 526 | SDNode *Result_2 = CurDAG->getMachineNode(Hexagon::A2_tfrsi, dl, MVT::i32, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 527 | TargetConst0); |
Colin LeMahieu | b580d7d | 2014-12-09 19:23:45 +0000 | [diff] [blame] | 528 | SDNode *Result_3 = CurDAG->getMachineNode(Hexagon::A2_combinew, dl, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 529 | MVT::i64, MVT::Other, |
| 530 | SDValue(Result_2,0), |
| 531 | SDValue(Result_1,0)); |
| 532 | MachineSDNode::mmo_iterator MemOp = MF->allocateMemRefsArray(1); |
| 533 | MemOp[0] = LD->getMemOperand(); |
| 534 | cast<MachineSDNode>(Result_1)->setMemRefs(MemOp, MemOp + 1); |
| 535 | const SDValue Froms[] = { SDValue(LD, 0), |
| 536 | SDValue(LD, 1), |
| 537 | SDValue(LD, 2) |
| 538 | }; |
| 539 | const SDValue Tos[] = { SDValue(Result_3, 0), |
| 540 | SDValue(Result_1, 1), |
| 541 | SDValue(Result_1, 2) |
| 542 | }; |
| 543 | ReplaceUses(Froms, Tos, 3); |
| 544 | return Result_3; |
| 545 | } |
| 546 | |
| 547 | // Generate an indirect load. |
| 548 | SDValue TargetConst0 = CurDAG->getTargetConstant(0, MVT::i32); |
| 549 | SDValue TargetConstVal = CurDAG->getTargetConstant(Val, MVT::i32); |
| 550 | SDNode *Result_1 = CurDAG->getMachineNode(Opcode, dl, MVT::i32, |
| 551 | MVT::Other, |
| 552 | Base, TargetConst0, Chain); |
Colin LeMahieu | 4af437f | 2014-12-09 20:23:30 +0000 | [diff] [blame] | 553 | SDNode *Result_2 = CurDAG->getMachineNode(Hexagon::A2_tfrsi, dl, MVT::i32, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 554 | TargetConst0); |
Colin LeMahieu | b580d7d | 2014-12-09 19:23:45 +0000 | [diff] [blame] | 555 | SDNode *Result_3 = CurDAG->getMachineNode(Hexagon::A2_combinew, dl, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 556 | MVT::i64, MVT::Other, |
| 557 | SDValue(Result_2,0), |
| 558 | SDValue(Result_1,0)); |
| 559 | // Add offset to base. |
| 560 | SDNode* Result_4 = CurDAG->getMachineNode(Hexagon::ADD_ri, dl, MVT::i32, |
| 561 | Base, TargetConstVal, |
| 562 | SDValue(Result_1, 1)); |
| 563 | MachineSDNode::mmo_iterator MemOp = MF->allocateMemRefsArray(1); |
| 564 | MemOp[0] = LD->getMemOperand(); |
| 565 | cast<MachineSDNode>(Result_1)->setMemRefs(MemOp, MemOp + 1); |
| 566 | const SDValue Froms[] = { SDValue(LD, 0), |
| 567 | SDValue(LD, 1), |
| 568 | SDValue(LD, 2) |
| 569 | }; |
| 570 | const SDValue Tos[] = { SDValue(Result_3, 0), // Load value. |
| 571 | SDValue(Result_4, 0), // New address. |
| 572 | SDValue(Result_1, 1) |
| 573 | }; |
| 574 | ReplaceUses(Froms, Tos, 3); |
| 575 | return Result_3; |
| 576 | } |
| 577 | |
| 578 | return SelectCode(LD); |
| 579 | } |
| 580 | |
| 581 | |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 582 | SDNode *HexagonDAGToDAGISel::SelectIndexedLoad(LoadSDNode *LD, SDLoc dl) { |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 583 | SDValue Chain = LD->getChain(); |
| 584 | SDValue Base = LD->getBasePtr(); |
| 585 | SDValue Offset = LD->getOffset(); |
| 586 | SDNode *OffsetNode = Offset.getNode(); |
| 587 | // Get the constant value. |
| 588 | int32_t Val = cast<ConstantSDNode>(OffsetNode)->getSExtValue(); |
| 589 | EVT LoadedVT = LD->getMemoryVT(); |
| 590 | unsigned Opcode = 0; |
| 591 | |
| 592 | // Check for zero ext loads. |
| 593 | bool zextval = (LD->getExtensionType() == ISD::ZEXTLOAD); |
| 594 | |
| 595 | // Figure out the opcode. |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 596 | const HexagonInstrInfo *TII = static_cast<const HexagonInstrInfo *>( |
| 597 | TM.getSubtargetImpl()->getInstrInfo()); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 598 | if (LoadedVT == MVT::i64) { |
| 599 | if (TII->isValidAutoIncImm(LoadedVT, Val)) |
Colin LeMahieu | c83cbbf | 2014-12-26 19:31:46 +0000 | [diff] [blame] | 600 | Opcode = Hexagon::L2_loadrd_pi; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 601 | else |
Colin LeMahieu | 947cd70 | 2014-12-23 20:44:59 +0000 | [diff] [blame] | 602 | Opcode = Hexagon::L2_loadrd_io; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 603 | } else if (LoadedVT == MVT::i32) { |
| 604 | if (TII->isValidAutoIncImm(LoadedVT, Val)) |
Colin LeMahieu | c83cbbf | 2014-12-26 19:31:46 +0000 | [diff] [blame] | 605 | Opcode = Hexagon::L2_loadri_pi; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 606 | else |
Colin LeMahieu | 026e88d | 2014-12-23 20:02:16 +0000 | [diff] [blame] | 607 | Opcode = Hexagon::L2_loadri_io; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 608 | } else if (LoadedVT == MVT::i16) { |
| 609 | if (TII->isValidAutoIncImm(LoadedVT, Val)) |
Colin LeMahieu | c83cbbf | 2014-12-26 19:31:46 +0000 | [diff] [blame] | 610 | Opcode = zextval ? Hexagon::L2_loadruh_pi : Hexagon::L2_loadrh_pi; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 611 | else |
Colin LeMahieu | 8e39cad | 2014-12-23 17:25:57 +0000 | [diff] [blame] | 612 | Opcode = zextval ? Hexagon::L2_loadruh_io : Hexagon::L2_loadrh_io; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 613 | } else if (LoadedVT == MVT::i8) { |
| 614 | if (TII->isValidAutoIncImm(LoadedVT, Val)) |
Colin LeMahieu | fe9612e | 2014-12-26 19:12:11 +0000 | [diff] [blame] | 615 | Opcode = zextval ? Hexagon::L2_loadrub_pi : Hexagon::L2_loadrb_pi; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 616 | else |
Colin LeMahieu | 4b1eac4 | 2014-12-22 21:40:43 +0000 | [diff] [blame] | 617 | Opcode = zextval ? Hexagon::L2_loadrub_io : Hexagon::L2_loadrb_io; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 618 | } else |
Sirish Pande | f8e5e3c | 2012-05-03 21:52:53 +0000 | [diff] [blame] | 619 | llvm_unreachable("unknown memory type"); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 620 | |
| 621 | // For zero ext i64 loads, we need to add combine instructions. |
| 622 | if (LD->getValueType(0) == MVT::i64 && |
| 623 | LD->getExtensionType() == ISD::ZEXTLOAD) { |
| 624 | return SelectIndexedLoadZeroExtend64(LD, Opcode, dl); |
| 625 | } |
| 626 | if (LD->getValueType(0) == MVT::i64 && |
| 627 | LD->getExtensionType() == ISD::SEXTLOAD) { |
| 628 | // Handle sign ext i64 loads. |
| 629 | return SelectIndexedLoadSignExtend64(LD, Opcode, dl); |
| 630 | } |
| 631 | if (TII->isValidAutoIncImm(LoadedVT, Val)) { |
| 632 | SDValue TargetConstVal = CurDAG->getTargetConstant(Val, MVT::i32); |
| 633 | SDNode* Result = CurDAG->getMachineNode(Opcode, dl, |
| 634 | LD->getValueType(0), |
| 635 | MVT::i32, MVT::Other, Base, |
| 636 | TargetConstVal, Chain); |
| 637 | MachineSDNode::mmo_iterator MemOp = MF->allocateMemRefsArray(1); |
| 638 | MemOp[0] = LD->getMemOperand(); |
| 639 | cast<MachineSDNode>(Result)->setMemRefs(MemOp, MemOp + 1); |
| 640 | const SDValue Froms[] = { SDValue(LD, 0), |
| 641 | SDValue(LD, 1), |
| 642 | SDValue(LD, 2) |
| 643 | }; |
| 644 | const SDValue Tos[] = { SDValue(Result, 0), |
| 645 | SDValue(Result, 1), |
| 646 | SDValue(Result, 2) |
| 647 | }; |
| 648 | ReplaceUses(Froms, Tos, 3); |
| 649 | return Result; |
| 650 | } else { |
| 651 | SDValue TargetConst0 = CurDAG->getTargetConstant(0, MVT::i32); |
| 652 | SDValue TargetConstVal = CurDAG->getTargetConstant(Val, MVT::i32); |
| 653 | SDNode* Result_1 = CurDAG->getMachineNode(Opcode, dl, |
| 654 | LD->getValueType(0), |
| 655 | MVT::Other, Base, TargetConst0, |
| 656 | Chain); |
| 657 | SDNode* Result_2 = CurDAG->getMachineNode(Hexagon::ADD_ri, dl, MVT::i32, |
| 658 | Base, TargetConstVal, |
| 659 | SDValue(Result_1, 1)); |
| 660 | MachineSDNode::mmo_iterator MemOp = MF->allocateMemRefsArray(1); |
| 661 | MemOp[0] = LD->getMemOperand(); |
| 662 | cast<MachineSDNode>(Result_1)->setMemRefs(MemOp, MemOp + 1); |
| 663 | const SDValue Froms[] = { SDValue(LD, 0), |
| 664 | SDValue(LD, 1), |
| 665 | SDValue(LD, 2) |
| 666 | }; |
| 667 | const SDValue Tos[] = { SDValue(Result_1, 0), |
| 668 | SDValue(Result_2, 0), |
| 669 | SDValue(Result_1, 1) |
| 670 | }; |
| 671 | ReplaceUses(Froms, Tos, 3); |
| 672 | return Result_1; |
| 673 | } |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 674 | } |
| 675 | |
| 676 | |
| 677 | SDNode *HexagonDAGToDAGISel::SelectLoad(SDNode *N) { |
| 678 | SDNode *result; |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 679 | SDLoc dl(N); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 680 | LoadSDNode *LD = cast<LoadSDNode>(N); |
| 681 | ISD::MemIndexedMode AM = LD->getAddressingMode(); |
| 682 | |
| 683 | // Handle indexed loads. |
| 684 | if (AM != ISD::UNINDEXED) { |
| 685 | result = SelectIndexedLoad(LD, dl); |
| 686 | } else { |
| 687 | result = SelectBaseOffsetLoad(LD, dl); |
| 688 | } |
| 689 | |
| 690 | return result; |
| 691 | } |
| 692 | |
| 693 | |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 694 | SDNode *HexagonDAGToDAGISel::SelectIndexedStore(StoreSDNode *ST, SDLoc dl) { |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 695 | SDValue Chain = ST->getChain(); |
| 696 | SDValue Base = ST->getBasePtr(); |
| 697 | SDValue Offset = ST->getOffset(); |
| 698 | SDValue Value = ST->getValue(); |
| 699 | SDNode *OffsetNode = Offset.getNode(); |
| 700 | // Get the constant value. |
| 701 | int32_t Val = cast<ConstantSDNode>(OffsetNode)->getSExtValue(); |
| 702 | EVT StoredVT = ST->getMemoryVT(); |
| 703 | |
| 704 | // Offset value must be within representable range |
| 705 | // and must have correct alignment properties. |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 706 | const HexagonInstrInfo *TII = static_cast<const HexagonInstrInfo *>( |
| 707 | TM.getSubtargetImpl()->getInstrInfo()); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 708 | if (TII->isValidAutoIncImm(StoredVT, Val)) { |
Jyotsna Verma | b16a9cb | 2013-01-29 18:42:41 +0000 | [diff] [blame] | 709 | SDValue Ops[] = {Base, CurDAG->getTargetConstant(Val, MVT::i32), Value, |
| 710 | Chain}; |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 711 | unsigned Opcode = 0; |
| 712 | |
| 713 | // Figure out the post inc version of opcode. |
Colin LeMahieu | 9a3cd3f | 2014-12-29 20:00:43 +0000 | [diff] [blame] | 714 | if (StoredVT == MVT::i64) Opcode = Hexagon::S2_storerd_pi; |
| 715 | else if (StoredVT == MVT::i32) Opcode = Hexagon::S2_storeri_pi; |
| 716 | else if (StoredVT == MVT::i16) Opcode = Hexagon::S2_storerh_pi; |
Colin LeMahieu | 3d34afb | 2014-12-29 19:42:14 +0000 | [diff] [blame] | 717 | else if (StoredVT == MVT::i8) Opcode = Hexagon::S2_storerb_pi; |
Sirish Pande | f8e5e3c | 2012-05-03 21:52:53 +0000 | [diff] [blame] | 718 | else llvm_unreachable("unknown memory type"); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 719 | |
| 720 | // Build post increment store. |
| 721 | SDNode* Result = CurDAG->getMachineNode(Opcode, dl, MVT::i32, |
Michael Liao | b53d896 | 2013-04-19 22:22:57 +0000 | [diff] [blame] | 722 | MVT::Other, Ops); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 723 | MachineSDNode::mmo_iterator MemOp = MF->allocateMemRefsArray(1); |
| 724 | MemOp[0] = ST->getMemOperand(); |
| 725 | cast<MachineSDNode>(Result)->setMemRefs(MemOp, MemOp + 1); |
| 726 | |
| 727 | ReplaceUses(ST, Result); |
| 728 | ReplaceUses(SDValue(ST,1), SDValue(Result,1)); |
| 729 | return Result; |
| 730 | } |
| 731 | |
| 732 | // Note: Order of operands matches the def of instruction: |
| 733 | // def STrid : STInst<(outs), (ins MEMri:$addr, DoubleRegs:$src1), ... |
| 734 | // and it differs for POST_ST* for instance. |
| 735 | SDValue Ops[] = { Base, CurDAG->getTargetConstant(0, MVT::i32), Value, |
| 736 | Chain}; |
| 737 | unsigned Opcode = 0; |
| 738 | |
| 739 | // Figure out the opcode. |
Colin LeMahieu | bda31b4 | 2014-12-29 20:44:51 +0000 | [diff] [blame] | 740 | if (StoredVT == MVT::i64) Opcode = Hexagon::S2_storerd_io; |
| 741 | else if (StoredVT == MVT::i32) Opcode = Hexagon::S2_storeri_io; |
| 742 | else if (StoredVT == MVT::i16) Opcode = Hexagon::S2_storerh_io; |
| 743 | else if (StoredVT == MVT::i8) Opcode = Hexagon::S2_storerb_io; |
Sirish Pande | f8e5e3c | 2012-05-03 21:52:53 +0000 | [diff] [blame] | 744 | else llvm_unreachable("unknown memory type"); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 745 | |
| 746 | // Build regular store. |
| 747 | SDValue TargetConstVal = CurDAG->getTargetConstant(Val, MVT::i32); |
Michael Liao | b53d896 | 2013-04-19 22:22:57 +0000 | [diff] [blame] | 748 | SDNode* Result_1 = CurDAG->getMachineNode(Opcode, dl, MVT::Other, Ops); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 749 | // Build splitted incriment instruction. |
| 750 | SDNode* Result_2 = CurDAG->getMachineNode(Hexagon::ADD_ri, dl, MVT::i32, |
| 751 | Base, |
| 752 | TargetConstVal, |
| 753 | SDValue(Result_1, 0)); |
| 754 | MachineSDNode::mmo_iterator MemOp = MF->allocateMemRefsArray(1); |
| 755 | MemOp[0] = ST->getMemOperand(); |
| 756 | cast<MachineSDNode>(Result_1)->setMemRefs(MemOp, MemOp + 1); |
| 757 | |
| 758 | ReplaceUses(SDValue(ST,0), SDValue(Result_2,0)); |
| 759 | ReplaceUses(SDValue(ST,1), SDValue(Result_1,0)); |
| 760 | return Result_2; |
| 761 | } |
| 762 | |
| 763 | |
| 764 | SDNode *HexagonDAGToDAGISel::SelectBaseOffsetStore(StoreSDNode *ST, |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 765 | SDLoc dl) { |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 766 | SDValue Chain = ST->getChain(); |
| 767 | SDNode* Const32 = ST->getBasePtr().getNode(); |
| 768 | SDValue Value = ST->getValue(); |
| 769 | unsigned Opcode = 0; |
| 770 | |
| 771 | // Try to lower stores of GlobalAdresses into indexed stores. Custom |
| 772 | // lowering for GlobalAddress nodes has already turned it into a |
| 773 | // CONST32. Avoid truncating stores for the moment. Post-inc stores |
| 774 | // do the same. Don't think there's a reason for it, so will file a |
| 775 | // bug to fix. |
| 776 | if ((Const32->getOpcode() == HexagonISD::CONST32) && |
| 777 | !(Value.getValueType() == MVT::i64 && ST->isTruncatingStore())) { |
| 778 | SDValue Base = Const32->getOperand(0); |
| 779 | if (Base.getOpcode() == ISD::TargetGlobalAddress) { |
| 780 | EVT StoredVT = ST->getMemoryVT(); |
| 781 | int64_t Offset = cast<GlobalAddressSDNode>(Base)->getOffset(); |
| 782 | if (Offset != 0 && OffsetFitsS11(StoredVT, Offset)) { |
Bill Wendling | a3cd350 | 2013-06-19 21:36:55 +0000 | [diff] [blame] | 783 | MVT PointerTy = getTargetLowering()->getPointerTy(); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 784 | const GlobalValue* GV = |
| 785 | cast<GlobalAddressSDNode>(Base)->getGlobal(); |
| 786 | SDValue TargAddr = |
| 787 | CurDAG->getTargetGlobalAddress(GV, dl, PointerTy, 0); |
Brendon Cahoon | f6b687e | 2012-05-14 19:35:42 +0000 | [diff] [blame] | 788 | SDNode* NewBase = CurDAG->getMachineNode(Hexagon::CONST32_set, |
| 789 | dl, PointerTy, |
| 790 | TargAddr); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 791 | |
| 792 | // Figure out base + offset opcode |
Colin LeMahieu | bda31b4 | 2014-12-29 20:44:51 +0000 | [diff] [blame] | 793 | if (StoredVT == MVT::i64) Opcode = Hexagon::S2_storerd_io; |
| 794 | else if (StoredVT == MVT::i32) Opcode = Hexagon::S2_storeri_io; |
| 795 | else if (StoredVT == MVT::i16) Opcode = Hexagon::S2_storerh_io; |
| 796 | else if (StoredVT == MVT::i8) Opcode = Hexagon::S2_storerb_io; |
Sirish Pande | f8e5e3c | 2012-05-03 21:52:53 +0000 | [diff] [blame] | 797 | else llvm_unreachable("unknown memory type"); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 798 | |
| 799 | SDValue Ops[] = {SDValue(NewBase,0), |
| 800 | CurDAG->getTargetConstant(Offset,PointerTy), |
| 801 | Value, Chain}; |
| 802 | // build indexed store |
| 803 | SDNode* Result = CurDAG->getMachineNode(Opcode, dl, |
Michael Liao | b53d896 | 2013-04-19 22:22:57 +0000 | [diff] [blame] | 804 | MVT::Other, Ops); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 805 | MachineSDNode::mmo_iterator MemOp = MF->allocateMemRefsArray(1); |
| 806 | MemOp[0] = ST->getMemOperand(); |
| 807 | cast<MachineSDNode>(Result)->setMemRefs(MemOp, MemOp + 1); |
| 808 | ReplaceUses(ST, Result); |
| 809 | return Result; |
| 810 | } |
| 811 | } |
| 812 | } |
| 813 | |
| 814 | return SelectCode(ST); |
| 815 | } |
| 816 | |
| 817 | |
| 818 | SDNode *HexagonDAGToDAGISel::SelectStore(SDNode *N) { |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 819 | SDLoc dl(N); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 820 | StoreSDNode *ST = cast<StoreSDNode>(N); |
| 821 | ISD::MemIndexedMode AM = ST->getAddressingMode(); |
| 822 | |
| 823 | // Handle indexed stores. |
| 824 | if (AM != ISD::UNINDEXED) { |
| 825 | return SelectIndexedStore(ST, dl); |
| 826 | } |
Sirish Pande | c92c316 | 2012-05-03 16:18:50 +0000 | [diff] [blame] | 827 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 828 | return SelectBaseOffsetStore(ST, dl); |
| 829 | } |
| 830 | |
| 831 | SDNode *HexagonDAGToDAGISel::SelectMul(SDNode *N) { |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 832 | SDLoc dl(N); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 833 | |
| 834 | // |
| 835 | // %conv.i = sext i32 %tmp1 to i64 |
| 836 | // %conv2.i = sext i32 %add to i64 |
| 837 | // %mul.i = mul nsw i64 %conv2.i, %conv.i |
| 838 | // |
| 839 | // --- match with the following --- |
| 840 | // |
| 841 | // %mul.i = mpy (%tmp1, %add) |
| 842 | // |
| 843 | |
| 844 | if (N->getValueType(0) == MVT::i64) { |
| 845 | // Shifting a i64 signed multiply. |
| 846 | SDValue MulOp0 = N->getOperand(0); |
| 847 | SDValue MulOp1 = N->getOperand(1); |
| 848 | |
| 849 | SDValue OP0; |
| 850 | SDValue OP1; |
| 851 | |
| 852 | // Handle sign_extend and sextload. |
| 853 | if (MulOp0.getOpcode() == ISD::SIGN_EXTEND) { |
| 854 | SDValue Sext0 = MulOp0.getOperand(0); |
| 855 | if (Sext0.getNode()->getValueType(0) != MVT::i32) { |
Sirish Pande | f8e5e3c | 2012-05-03 21:52:53 +0000 | [diff] [blame] | 856 | return SelectCode(N); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 857 | } |
| 858 | |
| 859 | OP0 = Sext0; |
| 860 | } else if (MulOp0.getOpcode() == ISD::LOAD) { |
| 861 | LoadSDNode *LD = cast<LoadSDNode>(MulOp0.getNode()); |
| 862 | if (LD->getMemoryVT() != MVT::i32 || |
| 863 | LD->getExtensionType() != ISD::SEXTLOAD || |
| 864 | LD->getAddressingMode() != ISD::UNINDEXED) { |
Sirish Pande | f8e5e3c | 2012-05-03 21:52:53 +0000 | [diff] [blame] | 865 | return SelectCode(N); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 866 | } |
| 867 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 868 | SDValue Chain = LD->getChain(); |
| 869 | SDValue TargetConst0 = CurDAG->getTargetConstant(0, MVT::i32); |
Colin LeMahieu | 026e88d | 2014-12-23 20:02:16 +0000 | [diff] [blame] | 870 | OP0 = SDValue(CurDAG->getMachineNode(Hexagon::L2_loadri_io, dl, MVT::i32, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 871 | MVT::Other, |
| 872 | LD->getBasePtr(), TargetConst0, |
| 873 | Chain), 0); |
| 874 | } else { |
| 875 | return SelectCode(N); |
| 876 | } |
| 877 | |
| 878 | // Same goes for the second operand. |
| 879 | if (MulOp1.getOpcode() == ISD::SIGN_EXTEND) { |
| 880 | SDValue Sext1 = MulOp1.getOperand(0); |
| 881 | if (Sext1.getNode()->getValueType(0) != MVT::i32) { |
| 882 | return SelectCode(N); |
| 883 | } |
| 884 | |
| 885 | OP1 = Sext1; |
| 886 | } else if (MulOp1.getOpcode() == ISD::LOAD) { |
| 887 | LoadSDNode *LD = cast<LoadSDNode>(MulOp1.getNode()); |
| 888 | if (LD->getMemoryVT() != MVT::i32 || |
| 889 | LD->getExtensionType() != ISD::SEXTLOAD || |
| 890 | LD->getAddressingMode() != ISD::UNINDEXED) { |
| 891 | return SelectCode(N); |
| 892 | } |
| 893 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 894 | SDValue Chain = LD->getChain(); |
| 895 | SDValue TargetConst0 = CurDAG->getTargetConstant(0, MVT::i32); |
Colin LeMahieu | 026e88d | 2014-12-23 20:02:16 +0000 | [diff] [blame] | 896 | OP1 = SDValue(CurDAG->getMachineNode(Hexagon::L2_loadri_io, dl, MVT::i32, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 897 | MVT::Other, |
| 898 | LD->getBasePtr(), TargetConst0, |
| 899 | Chain), 0); |
| 900 | } else { |
| 901 | return SelectCode(N); |
| 902 | } |
| 903 | |
| 904 | // Generate a mpy instruction. |
Colin LeMahieu | d9b2350 | 2014-12-16 16:10:01 +0000 | [diff] [blame] | 905 | SDNode *Result = CurDAG->getMachineNode(Hexagon::M2_dpmpyss_s0, dl, MVT::i64, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 906 | OP0, OP1); |
| 907 | ReplaceUses(N, Result); |
| 908 | return Result; |
| 909 | } |
| 910 | |
| 911 | return SelectCode(N); |
| 912 | } |
| 913 | |
| 914 | |
| 915 | SDNode *HexagonDAGToDAGISel::SelectSelect(SDNode *N) { |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 916 | SDLoc dl(N); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 917 | SDValue N0 = N->getOperand(0); |
| 918 | if (N0.getOpcode() == ISD::SETCC) { |
| 919 | SDValue N00 = N0.getOperand(0); |
| 920 | if (N00.getOpcode() == ISD::SIGN_EXTEND_INREG) { |
| 921 | SDValue N000 = N00.getOperand(0); |
| 922 | SDValue N001 = N00.getOperand(1); |
| 923 | if (cast<VTSDNode>(N001)->getVT() == MVT::i16) { |
| 924 | SDValue N01 = N0.getOperand(1); |
| 925 | SDValue N02 = N0.getOperand(2); |
| 926 | |
| 927 | // Pattern: (select:i32 (setcc:i1 (sext_inreg:i32 IntRegs:i32:$src2, |
| 928 | // i16:Other),IntRegs:i32:$src1, SETLT:Other),IntRegs:i32:$src1, |
| 929 | // IntRegs:i32:$src2) |
| 930 | // Emits: (MAXh_rr:i32 IntRegs:i32:$src1, IntRegs:i32:$src2) |
| 931 | // Pattern complexity = 9 cost = 1 size = 0. |
| 932 | if (cast<CondCodeSDNode>(N02)->get() == ISD::SETLT) { |
| 933 | SDValue N1 = N->getOperand(1); |
| 934 | if (N01 == N1) { |
| 935 | SDValue N2 = N->getOperand(2); |
| 936 | if (N000 == N2 && |
| 937 | N0.getNode()->getValueType(N0.getResNo()) == MVT::i1 && |
| 938 | N00.getNode()->getValueType(N00.getResNo()) == MVT::i32) { |
Colin LeMahieu | 310991c | 2014-11-21 21:54:59 +0000 | [diff] [blame] | 939 | SDNode *SextNode = CurDAG->getMachineNode(Hexagon::A2_sxth, dl, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 940 | MVT::i32, N000); |
Colin LeMahieu | 5cf5632 | 2014-12-08 23:55:43 +0000 | [diff] [blame] | 941 | SDNode *Result = CurDAG->getMachineNode(Hexagon::A2_max, dl, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 942 | MVT::i32, |
| 943 | SDValue(SextNode, 0), |
| 944 | N1); |
| 945 | ReplaceUses(N, Result); |
| 946 | return Result; |
| 947 | } |
| 948 | } |
| 949 | } |
| 950 | |
| 951 | // Pattern: (select:i32 (setcc:i1 (sext_inreg:i32 IntRegs:i32:$src2, |
| 952 | // i16:Other), IntRegs:i32:$src1, SETGT:Other), IntRegs:i32:$src1, |
| 953 | // IntRegs:i32:$src2) |
| 954 | // Emits: (MINh_rr:i32 IntRegs:i32:$src1, IntRegs:i32:$src2) |
| 955 | // Pattern complexity = 9 cost = 1 size = 0. |
| 956 | if (cast<CondCodeSDNode>(N02)->get() == ISD::SETGT) { |
| 957 | SDValue N1 = N->getOperand(1); |
| 958 | if (N01 == N1) { |
| 959 | SDValue N2 = N->getOperand(2); |
| 960 | if (N000 == N2 && |
| 961 | N0.getNode()->getValueType(N0.getResNo()) == MVT::i1 && |
| 962 | N00.getNode()->getValueType(N00.getResNo()) == MVT::i32) { |
Colin LeMahieu | 310991c | 2014-11-21 21:54:59 +0000 | [diff] [blame] | 963 | SDNode *SextNode = CurDAG->getMachineNode(Hexagon::A2_sxth, dl, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 964 | MVT::i32, N000); |
Colin LeMahieu | 5cf5632 | 2014-12-08 23:55:43 +0000 | [diff] [blame] | 965 | SDNode *Result = CurDAG->getMachineNode(Hexagon::A2_min, dl, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 966 | MVT::i32, |
| 967 | SDValue(SextNode, 0), |
| 968 | N1); |
| 969 | ReplaceUses(N, Result); |
| 970 | return Result; |
| 971 | } |
| 972 | } |
| 973 | } |
| 974 | } |
| 975 | } |
| 976 | } |
| 977 | |
| 978 | return SelectCode(N); |
| 979 | } |
| 980 | |
| 981 | |
| 982 | SDNode *HexagonDAGToDAGISel::SelectTruncate(SDNode *N) { |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 983 | SDLoc dl(N); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 984 | SDValue Shift = N->getOperand(0); |
| 985 | |
| 986 | // |
| 987 | // %conv.i = sext i32 %tmp1 to i64 |
| 988 | // %conv2.i = sext i32 %add to i64 |
| 989 | // %mul.i = mul nsw i64 %conv2.i, %conv.i |
| 990 | // %shr5.i = lshr i64 %mul.i, 32 |
| 991 | // %conv3.i = trunc i64 %shr5.i to i32 |
| 992 | // |
| 993 | // --- match with the following --- |
| 994 | // |
| 995 | // %conv3.i = mpy (%tmp1, %add) |
| 996 | // |
| 997 | // Trunc to i32. |
| 998 | if (N->getValueType(0) == MVT::i32) { |
| 999 | // Trunc from i64. |
| 1000 | if (Shift.getNode()->getValueType(0) == MVT::i64) { |
| 1001 | // Trunc child is logical shift right. |
| 1002 | if (Shift.getOpcode() != ISD::SRL) { |
| 1003 | return SelectCode(N); |
| 1004 | } |
| 1005 | |
| 1006 | SDValue ShiftOp0 = Shift.getOperand(0); |
| 1007 | SDValue ShiftOp1 = Shift.getOperand(1); |
| 1008 | |
| 1009 | // Shift by const 32 |
| 1010 | if (ShiftOp1.getOpcode() != ISD::Constant) { |
| 1011 | return SelectCode(N); |
| 1012 | } |
| 1013 | |
| 1014 | int32_t ShiftConst = |
| 1015 | cast<ConstantSDNode>(ShiftOp1.getNode())->getSExtValue(); |
| 1016 | if (ShiftConst != 32) { |
| 1017 | return SelectCode(N); |
| 1018 | } |
| 1019 | |
| 1020 | // Shifting a i64 signed multiply |
| 1021 | SDValue Mul = ShiftOp0; |
| 1022 | if (Mul.getOpcode() != ISD::MUL) { |
| 1023 | return SelectCode(N); |
| 1024 | } |
| 1025 | |
| 1026 | SDValue MulOp0 = Mul.getOperand(0); |
| 1027 | SDValue MulOp1 = Mul.getOperand(1); |
| 1028 | |
| 1029 | SDValue OP0; |
| 1030 | SDValue OP1; |
| 1031 | |
| 1032 | // Handle sign_extend and sextload |
| 1033 | if (MulOp0.getOpcode() == ISD::SIGN_EXTEND) { |
| 1034 | SDValue Sext0 = MulOp0.getOperand(0); |
| 1035 | if (Sext0.getNode()->getValueType(0) != MVT::i32) { |
| 1036 | return SelectCode(N); |
| 1037 | } |
| 1038 | |
| 1039 | OP0 = Sext0; |
| 1040 | } else if (MulOp0.getOpcode() == ISD::LOAD) { |
| 1041 | LoadSDNode *LD = cast<LoadSDNode>(MulOp0.getNode()); |
| 1042 | if (LD->getMemoryVT() != MVT::i32 || |
| 1043 | LD->getExtensionType() != ISD::SEXTLOAD || |
| 1044 | LD->getAddressingMode() != ISD::UNINDEXED) { |
| 1045 | return SelectCode(N); |
| 1046 | } |
| 1047 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1048 | SDValue Chain = LD->getChain(); |
| 1049 | SDValue TargetConst0 = CurDAG->getTargetConstant(0, MVT::i32); |
Colin LeMahieu | 026e88d | 2014-12-23 20:02:16 +0000 | [diff] [blame] | 1050 | OP0 = SDValue(CurDAG->getMachineNode(Hexagon::L2_loadri_io, dl, MVT::i32, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1051 | MVT::Other, |
| 1052 | LD->getBasePtr(), |
| 1053 | TargetConst0, Chain), 0); |
| 1054 | } else { |
| 1055 | return SelectCode(N); |
| 1056 | } |
| 1057 | |
| 1058 | // Same goes for the second operand. |
| 1059 | if (MulOp1.getOpcode() == ISD::SIGN_EXTEND) { |
| 1060 | SDValue Sext1 = MulOp1.getOperand(0); |
| 1061 | if (Sext1.getNode()->getValueType(0) != MVT::i32) |
| 1062 | return SelectCode(N); |
| 1063 | |
| 1064 | OP1 = Sext1; |
| 1065 | } else if (MulOp1.getOpcode() == ISD::LOAD) { |
| 1066 | LoadSDNode *LD = cast<LoadSDNode>(MulOp1.getNode()); |
| 1067 | if (LD->getMemoryVT() != MVT::i32 || |
| 1068 | LD->getExtensionType() != ISD::SEXTLOAD || |
| 1069 | LD->getAddressingMode() != ISD::UNINDEXED) { |
| 1070 | return SelectCode(N); |
| 1071 | } |
| 1072 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1073 | SDValue Chain = LD->getChain(); |
| 1074 | SDValue TargetConst0 = CurDAG->getTargetConstant(0, MVT::i32); |
Colin LeMahieu | 026e88d | 2014-12-23 20:02:16 +0000 | [diff] [blame] | 1075 | OP1 = SDValue(CurDAG->getMachineNode(Hexagon::L2_loadri_io, dl, MVT::i32, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1076 | MVT::Other, |
| 1077 | LD->getBasePtr(), |
| 1078 | TargetConst0, Chain), 0); |
| 1079 | } else { |
| 1080 | return SelectCode(N); |
| 1081 | } |
| 1082 | |
| 1083 | // Generate a mpy instruction. |
Colin LeMahieu | d9b2350 | 2014-12-16 16:10:01 +0000 | [diff] [blame] | 1084 | SDNode *Result = CurDAG->getMachineNode(Hexagon::M2_mpy_up, dl, MVT::i32, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1085 | OP0, OP1); |
| 1086 | ReplaceUses(N, Result); |
| 1087 | return Result; |
| 1088 | } |
| 1089 | } |
| 1090 | |
| 1091 | return SelectCode(N); |
| 1092 | } |
| 1093 | |
| 1094 | |
| 1095 | SDNode *HexagonDAGToDAGISel::SelectSHL(SDNode *N) { |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 1096 | SDLoc dl(N); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1097 | if (N->getValueType(0) == MVT::i32) { |
| 1098 | SDValue Shl_0 = N->getOperand(0); |
| 1099 | SDValue Shl_1 = N->getOperand(1); |
| 1100 | // RHS is const. |
| 1101 | if (Shl_1.getOpcode() == ISD::Constant) { |
| 1102 | if (Shl_0.getOpcode() == ISD::MUL) { |
| 1103 | SDValue Mul_0 = Shl_0.getOperand(0); // Val |
| 1104 | SDValue Mul_1 = Shl_0.getOperand(1); // Const |
| 1105 | // RHS of mul is const. |
| 1106 | if (Mul_1.getOpcode() == ISD::Constant) { |
| 1107 | int32_t ShlConst = |
| 1108 | cast<ConstantSDNode>(Shl_1.getNode())->getSExtValue(); |
| 1109 | int32_t MulConst = |
| 1110 | cast<ConstantSDNode>(Mul_1.getNode())->getSExtValue(); |
| 1111 | int32_t ValConst = MulConst << ShlConst; |
| 1112 | SDValue Val = CurDAG->getTargetConstant(ValConst, |
| 1113 | MVT::i32); |
| 1114 | if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Val.getNode())) |
| 1115 | if (isInt<9>(CN->getSExtValue())) { |
| 1116 | SDNode* Result = |
Colin LeMahieu | d9b2350 | 2014-12-16 16:10:01 +0000 | [diff] [blame] | 1117 | CurDAG->getMachineNode(Hexagon::M2_mpysmi, dl, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1118 | MVT::i32, Mul_0, Val); |
| 1119 | ReplaceUses(N, Result); |
| 1120 | return Result; |
| 1121 | } |
| 1122 | |
| 1123 | } |
| 1124 | } else if (Shl_0.getOpcode() == ISD::SUB) { |
| 1125 | SDValue Sub_0 = Shl_0.getOperand(0); // Const 0 |
| 1126 | SDValue Sub_1 = Shl_0.getOperand(1); // Val |
| 1127 | if (Sub_0.getOpcode() == ISD::Constant) { |
| 1128 | int32_t SubConst = |
| 1129 | cast<ConstantSDNode>(Sub_0.getNode())->getSExtValue(); |
| 1130 | if (SubConst == 0) { |
| 1131 | if (Sub_1.getOpcode() == ISD::SHL) { |
| 1132 | SDValue Shl2_0 = Sub_1.getOperand(0); // Val |
| 1133 | SDValue Shl2_1 = Sub_1.getOperand(1); // Const |
| 1134 | if (Shl2_1.getOpcode() == ISD::Constant) { |
| 1135 | int32_t ShlConst = |
| 1136 | cast<ConstantSDNode>(Shl_1.getNode())->getSExtValue(); |
| 1137 | int32_t Shl2Const = |
| 1138 | cast<ConstantSDNode>(Shl2_1.getNode())->getSExtValue(); |
| 1139 | int32_t ValConst = 1 << (ShlConst+Shl2Const); |
| 1140 | SDValue Val = CurDAG->getTargetConstant(-ValConst, MVT::i32); |
| 1141 | if (ConstantSDNode *CN = |
| 1142 | dyn_cast<ConstantSDNode>(Val.getNode())) |
| 1143 | if (isInt<9>(CN->getSExtValue())) { |
| 1144 | SDNode* Result = |
Colin LeMahieu | d9b2350 | 2014-12-16 16:10:01 +0000 | [diff] [blame] | 1145 | CurDAG->getMachineNode(Hexagon::M2_mpysmi, dl, MVT::i32, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1146 | Shl2_0, Val); |
| 1147 | ReplaceUses(N, Result); |
| 1148 | return Result; |
| 1149 | } |
| 1150 | } |
| 1151 | } |
| 1152 | } |
| 1153 | } |
| 1154 | } |
| 1155 | } |
| 1156 | } |
| 1157 | return SelectCode(N); |
| 1158 | } |
| 1159 | |
| 1160 | |
| 1161 | // |
| 1162 | // If there is an zero_extend followed an intrinsic in DAG (this means - the |
| 1163 | // result of the intrinsic is predicate); convert the zero_extend to |
| 1164 | // transfer instruction. |
| 1165 | // |
| 1166 | // Zero extend -> transfer is lowered here. Otherwise, zero_extend will be |
| 1167 | // converted into a MUX as predicate registers defined as 1 bit in the |
| 1168 | // compiler. Architecture defines them as 8-bit registers. |
| 1169 | // We want to preserve all the lower 8-bits and, not just 1 LSB bit. |
| 1170 | // |
| 1171 | SDNode *HexagonDAGToDAGISel::SelectZeroExtend(SDNode *N) { |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 1172 | SDLoc dl(N); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1173 | SDNode *IsIntrinsic = N->getOperand(0).getNode(); |
| 1174 | if ((IsIntrinsic->getOpcode() == ISD::INTRINSIC_WO_CHAIN)) { |
| 1175 | unsigned ID = |
| 1176 | cast<ConstantSDNode>(IsIntrinsic->getOperand(0))->getZExtValue(); |
| 1177 | if (doesIntrinsicReturnPredicate(ID)) { |
| 1178 | // Now we need to differentiate target data types. |
| 1179 | if (N->getValueType(0) == MVT::i64) { |
| 1180 | // Convert the zero_extend to Rs = Pd followed by COMBINE_rr(0,Rs). |
| 1181 | SDValue TargetConst0 = CurDAG->getTargetConstant(0, MVT::i32); |
Colin LeMahieu | 30dcb23 | 2014-12-09 18:16:49 +0000 | [diff] [blame] | 1182 | SDNode *Result_1 = CurDAG->getMachineNode(Hexagon::C2_tfrpr, dl, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1183 | MVT::i32, |
| 1184 | SDValue(IsIntrinsic, 0)); |
Colin LeMahieu | 4af437f | 2014-12-09 20:23:30 +0000 | [diff] [blame] | 1185 | SDNode *Result_2 = CurDAG->getMachineNode(Hexagon::A2_tfrsi, dl, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1186 | MVT::i32, |
| 1187 | TargetConst0); |
Colin LeMahieu | b580d7d | 2014-12-09 19:23:45 +0000 | [diff] [blame] | 1188 | SDNode *Result_3 = CurDAG->getMachineNode(Hexagon::A2_combinew, dl, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1189 | MVT::i64, MVT::Other, |
| 1190 | SDValue(Result_2, 0), |
| 1191 | SDValue(Result_1, 0)); |
| 1192 | ReplaceUses(N, Result_3); |
| 1193 | return Result_3; |
| 1194 | } |
| 1195 | if (N->getValueType(0) == MVT::i32) { |
| 1196 | // Convert the zero_extend to Rs = Pd |
Colin LeMahieu | 30dcb23 | 2014-12-09 18:16:49 +0000 | [diff] [blame] | 1197 | SDNode* RsPd = CurDAG->getMachineNode(Hexagon::C2_tfrpr, dl, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1198 | MVT::i32, |
| 1199 | SDValue(IsIntrinsic, 0)); |
| 1200 | ReplaceUses(N, RsPd); |
| 1201 | return RsPd; |
| 1202 | } |
Craig Topper | e55c556 | 2012-02-07 02:50:20 +0000 | [diff] [blame] | 1203 | llvm_unreachable("Unexpected value type"); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1204 | } |
| 1205 | } |
| 1206 | return SelectCode(N); |
| 1207 | } |
| 1208 | |
| 1209 | |
| 1210 | // |
| 1211 | // Checking for intrinsics which have predicate registers as operand(s) |
| 1212 | // and lowering to the actual intrinsic. |
| 1213 | // |
| 1214 | SDNode *HexagonDAGToDAGISel::SelectIntrinsicWOChain(SDNode *N) { |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 1215 | SDLoc dl(N); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1216 | unsigned ID = cast<ConstantSDNode>(N->getOperand(0))->getZExtValue(); |
| 1217 | unsigned IntrinsicWithPred = doesIntrinsicContainPredicate(ID); |
| 1218 | |
| 1219 | // We are concerned with only those intrinsics that have predicate registers |
| 1220 | // as at least one of the operands. |
| 1221 | if (IntrinsicWithPred) { |
| 1222 | SmallVector<SDValue, 8> Ops; |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 1223 | const HexagonInstrInfo *TII = static_cast<const HexagonInstrInfo *>( |
| 1224 | TM.getSubtargetImpl()->getInstrInfo()); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1225 | const MCInstrDesc &MCID = TII->get(IntrinsicWithPred); |
Eric Christopher | d913448 | 2014-08-04 21:25:23 +0000 | [diff] [blame] | 1226 | const TargetRegisterInfo *TRI = TM.getSubtargetImpl()->getRegisterInfo(); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1227 | |
| 1228 | // Iterate over all the operands of the intrinsics. |
| 1229 | // For PredRegs, do the transfer. |
| 1230 | // For Double/Int Regs, just preserve the value |
| 1231 | // For immediates, lower it. |
| 1232 | for (unsigned i = 1; i < N->getNumOperands(); ++i) { |
| 1233 | SDNode *Arg = N->getOperand(i).getNode(); |
Jakob Stoklund Olesen | 3c52f02 | 2012-05-07 22:10:26 +0000 | [diff] [blame] | 1234 | const TargetRegisterClass *RC = TII->getRegClass(MCID, i, TRI, *MF); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1235 | |
Craig Topper | c7242e0 | 2012-04-20 07:30:17 +0000 | [diff] [blame] | 1236 | if (RC == &Hexagon::IntRegsRegClass || |
| 1237 | RC == &Hexagon::DoubleRegsRegClass) { |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1238 | Ops.push_back(SDValue(Arg, 0)); |
Craig Topper | c7242e0 | 2012-04-20 07:30:17 +0000 | [diff] [blame] | 1239 | } else if (RC == &Hexagon::PredRegsRegClass) { |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1240 | // Do the transfer. |
Colin LeMahieu | 30dcb23 | 2014-12-09 18:16:49 +0000 | [diff] [blame] | 1241 | SDNode *PdRs = CurDAG->getMachineNode(Hexagon::C2_tfrrp, dl, MVT::i1, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1242 | SDValue(Arg, 0)); |
| 1243 | Ops.push_back(SDValue(PdRs,0)); |
Craig Topper | 062a2ba | 2014-04-25 05:30:21 +0000 | [diff] [blame] | 1244 | } else if (!RC && (dyn_cast<ConstantSDNode>(Arg) != nullptr)) { |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1245 | // This is immediate operand. Lower it here making sure that we DO have |
| 1246 | // const SDNode for immediate value. |
| 1247 | int32_t Val = cast<ConstantSDNode>(Arg)->getSExtValue(); |
| 1248 | SDValue SDVal = CurDAG->getTargetConstant(Val, MVT::i32); |
| 1249 | Ops.push_back(SDVal); |
| 1250 | } else { |
Craig Topper | e55c556 | 2012-02-07 02:50:20 +0000 | [diff] [blame] | 1251 | llvm_unreachable("Unimplemented"); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1252 | } |
| 1253 | } |
| 1254 | EVT ReturnValueVT = N->getValueType(0); |
| 1255 | SDNode *Result = CurDAG->getMachineNode(IntrinsicWithPred, dl, |
Michael Liao | b53d896 | 2013-04-19 22:22:57 +0000 | [diff] [blame] | 1256 | ReturnValueVT, Ops); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1257 | ReplaceUses(N, Result); |
| 1258 | return Result; |
| 1259 | } |
| 1260 | return SelectCode(N); |
| 1261 | } |
| 1262 | |
Sirish Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 1263 | // |
| 1264 | // Map floating point constant values. |
| 1265 | // |
| 1266 | SDNode *HexagonDAGToDAGISel::SelectConstantFP(SDNode *N) { |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 1267 | SDLoc dl(N); |
Sirish Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 1268 | ConstantFPSDNode *CN = dyn_cast<ConstantFPSDNode>(N); |
| 1269 | APFloat APF = CN->getValueAPF(); |
| 1270 | if (N->getValueType(0) == MVT::f32) { |
| 1271 | return CurDAG->getMachineNode(Hexagon::TFRI_f, dl, MVT::f32, |
| 1272 | CurDAG->getTargetConstantFP(APF.convertToFloat(), MVT::f32)); |
| 1273 | } |
| 1274 | else if (N->getValueType(0) == MVT::f64) { |
| 1275 | return CurDAG->getMachineNode(Hexagon::CONST64_Float_Real, dl, MVT::f64, |
| 1276 | CurDAG->getTargetConstantFP(APF.convertToDouble(), MVT::f64)); |
| 1277 | } |
| 1278 | |
| 1279 | return SelectCode(N); |
| 1280 | } |
| 1281 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1282 | |
| 1283 | // |
| 1284 | // Map predicate true (encoded as -1 in LLVM) to a XOR. |
| 1285 | // |
| 1286 | SDNode *HexagonDAGToDAGISel::SelectConstant(SDNode *N) { |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 1287 | SDLoc dl(N); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1288 | if (N->getValueType(0) == MVT::i1) { |
| 1289 | SDNode* Result; |
| 1290 | int32_t Val = cast<ConstantSDNode>(N)->getSExtValue(); |
| 1291 | if (Val == -1) { |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1292 | // Create the IntReg = 1 node. |
| 1293 | SDNode* IntRegTFR = |
Colin LeMahieu | 4af437f | 2014-12-09 20:23:30 +0000 | [diff] [blame] | 1294 | CurDAG->getMachineNode(Hexagon::A2_tfrsi, dl, MVT::i32, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1295 | CurDAG->getTargetConstant(0, MVT::i32)); |
| 1296 | |
| 1297 | // Pd = IntReg |
Colin LeMahieu | 30dcb23 | 2014-12-09 18:16:49 +0000 | [diff] [blame] | 1298 | SDNode* Pd = CurDAG->getMachineNode(Hexagon::C2_tfrrp, dl, MVT::i1, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1299 | SDValue(IntRegTFR, 0)); |
| 1300 | |
| 1301 | // not(Pd) |
Colin LeMahieu | 5cf5632 | 2014-12-08 23:55:43 +0000 | [diff] [blame] | 1302 | SDNode* NotPd = CurDAG->getMachineNode(Hexagon::C2_not, dl, MVT::i1, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1303 | SDValue(Pd, 0)); |
| 1304 | |
| 1305 | // xor(not(Pd)) |
Colin LeMahieu | 5cf5632 | 2014-12-08 23:55:43 +0000 | [diff] [blame] | 1306 | Result = CurDAG->getMachineNode(Hexagon::C2_xor, dl, MVT::i1, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1307 | SDValue(Pd, 0), SDValue(NotPd, 0)); |
| 1308 | |
| 1309 | // We have just built: |
| 1310 | // Rs = Pd |
| 1311 | // Pd = xor(not(Pd), Pd) |
| 1312 | |
| 1313 | ReplaceUses(N, Result); |
| 1314 | return Result; |
| 1315 | } |
| 1316 | } |
| 1317 | |
| 1318 | return SelectCode(N); |
| 1319 | } |
| 1320 | |
| 1321 | |
| 1322 | // |
| 1323 | // Map add followed by a asr -> asr +=. |
| 1324 | // |
| 1325 | SDNode *HexagonDAGToDAGISel::SelectAdd(SDNode *N) { |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 1326 | SDLoc dl(N); |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1327 | if (N->getValueType(0) != MVT::i32) { |
| 1328 | return SelectCode(N); |
| 1329 | } |
| 1330 | // Identify nodes of the form: add(asr(...)). |
| 1331 | SDNode* Src1 = N->getOperand(0).getNode(); |
| 1332 | if (Src1->getOpcode() != ISD::SRA || !Src1->hasOneUse() |
| 1333 | || Src1->getValueType(0) != MVT::i32) { |
| 1334 | return SelectCode(N); |
| 1335 | } |
| 1336 | |
| 1337 | // Build Rd = Rd' + asr(Rs, Rt). The machine constraints will ensure that |
| 1338 | // Rd and Rd' are assigned to the same register |
Colin LeMahieu | 0f850bd | 2014-12-19 20:29:29 +0000 | [diff] [blame] | 1339 | SDNode* Result = CurDAG->getMachineNode(Hexagon::S2_asr_r_r_acc, dl, MVT::i32, |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1340 | N->getOperand(1), |
| 1341 | Src1->getOperand(0), |
| 1342 | Src1->getOperand(1)); |
| 1343 | ReplaceUses(N, Result); |
| 1344 | |
| 1345 | return Result; |
| 1346 | } |
| 1347 | |
| 1348 | |
| 1349 | SDNode *HexagonDAGToDAGISel::Select(SDNode *N) { |
Tim Northover | 31d093c | 2013-09-22 08:21:56 +0000 | [diff] [blame] | 1350 | if (N->isMachineOpcode()) { |
| 1351 | N->setNodeId(-1); |
Craig Topper | 062a2ba | 2014-04-25 05:30:21 +0000 | [diff] [blame] | 1352 | return nullptr; // Already selected. |
Tim Northover | 31d093c | 2013-09-22 08:21:56 +0000 | [diff] [blame] | 1353 | } |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1354 | |
| 1355 | |
| 1356 | switch (N->getOpcode()) { |
| 1357 | case ISD::Constant: |
| 1358 | return SelectConstant(N); |
| 1359 | |
Sirish Pande | 69295b8 | 2012-05-10 20:20:25 +0000 | [diff] [blame] | 1360 | case ISD::ConstantFP: |
| 1361 | return SelectConstantFP(N); |
| 1362 | |
Tony Linthicum | 1213a7a | 2011-12-12 21:14:40 +0000 | [diff] [blame] | 1363 | case ISD::ADD: |
| 1364 | return SelectAdd(N); |
| 1365 | |
| 1366 | case ISD::SHL: |
| 1367 | return SelectSHL(N); |
| 1368 | |
| 1369 | case ISD::LOAD: |
| 1370 | return SelectLoad(N); |
| 1371 | |
| 1372 | case ISD::STORE: |
| 1373 | return SelectStore(N); |
| 1374 | |
| 1375 | case ISD::SELECT: |
| 1376 | return SelectSelect(N); |
| 1377 | |
| 1378 | case ISD::TRUNCATE: |
| 1379 | return SelectTruncate(N); |
| 1380 | |
| 1381 | case ISD::MUL: |
| 1382 | return SelectMul(N); |
| 1383 | |
| 1384 | case ISD::ZERO_EXTEND: |
| 1385 | return SelectZeroExtend(N); |
| 1386 | |
| 1387 | case ISD::INTRINSIC_WO_CHAIN: |
| 1388 | return SelectIntrinsicWOChain(N); |
| 1389 | } |
| 1390 | |
| 1391 | return SelectCode(N); |
| 1392 | } |
| 1393 | |
| 1394 | |
| 1395 | // |
| 1396 | // Hexagon_TODO: Five functions for ADDRri?! Surely there must be a better way |
| 1397 | // to define these instructions. |
| 1398 | // |
| 1399 | bool HexagonDAGToDAGISel::SelectADDRri(SDValue& Addr, SDValue &Base, |
| 1400 | SDValue &Offset) { |
| 1401 | if (Addr.getOpcode() == ISD::TargetExternalSymbol || |
| 1402 | Addr.getOpcode() == ISD::TargetGlobalAddress) |
| 1403 | return false; // Direct calls. |
| 1404 | |
| 1405 | if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Addr)) { |
| 1406 | Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32); |
| 1407 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1408 | return true; |
| 1409 | } |
| 1410 | Base = Addr; |
| 1411 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1412 | return true; |
| 1413 | } |
| 1414 | |
| 1415 | |
| 1416 | bool HexagonDAGToDAGISel::SelectADDRriS11_0(SDValue& Addr, SDValue &Base, |
| 1417 | SDValue &Offset) { |
| 1418 | if (Addr.getOpcode() == ISD::TargetExternalSymbol || |
| 1419 | Addr.getOpcode() == ISD::TargetGlobalAddress) |
| 1420 | return false; // Direct calls. |
| 1421 | |
| 1422 | if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Addr)) { |
| 1423 | Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32); |
| 1424 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1425 | return (IsS11_0_Offset(Offset.getNode())); |
| 1426 | } |
| 1427 | Base = Addr; |
| 1428 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1429 | return (IsS11_0_Offset(Offset.getNode())); |
| 1430 | } |
| 1431 | |
| 1432 | |
| 1433 | bool HexagonDAGToDAGISel::SelectADDRriS11_1(SDValue& Addr, SDValue &Base, |
| 1434 | SDValue &Offset) { |
| 1435 | if (Addr.getOpcode() == ISD::TargetExternalSymbol || |
| 1436 | Addr.getOpcode() == ISD::TargetGlobalAddress) |
| 1437 | return false; // Direct calls. |
| 1438 | |
| 1439 | if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Addr)) { |
| 1440 | Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32); |
| 1441 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1442 | return (IsS11_1_Offset(Offset.getNode())); |
| 1443 | } |
| 1444 | Base = Addr; |
| 1445 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1446 | return (IsS11_1_Offset(Offset.getNode())); |
| 1447 | } |
| 1448 | |
| 1449 | |
| 1450 | bool HexagonDAGToDAGISel::SelectADDRriS11_2(SDValue& Addr, SDValue &Base, |
| 1451 | SDValue &Offset) { |
| 1452 | if (Addr.getOpcode() == ISD::TargetExternalSymbol || |
| 1453 | Addr.getOpcode() == ISD::TargetGlobalAddress) |
| 1454 | return false; // Direct calls. |
| 1455 | |
| 1456 | if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Addr)) { |
| 1457 | Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32); |
| 1458 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1459 | return (IsS11_2_Offset(Offset.getNode())); |
| 1460 | } |
| 1461 | Base = Addr; |
| 1462 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1463 | return (IsS11_2_Offset(Offset.getNode())); |
| 1464 | } |
| 1465 | |
| 1466 | |
| 1467 | bool HexagonDAGToDAGISel::SelectADDRriU6_0(SDValue& Addr, SDValue &Base, |
| 1468 | SDValue &Offset) { |
| 1469 | if (Addr.getOpcode() == ISD::TargetExternalSymbol || |
| 1470 | Addr.getOpcode() == ISD::TargetGlobalAddress) |
| 1471 | return false; // Direct calls. |
| 1472 | |
| 1473 | if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Addr)) { |
| 1474 | Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32); |
| 1475 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1476 | return (IsU6_0_Offset(Offset.getNode())); |
| 1477 | } |
| 1478 | Base = Addr; |
| 1479 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1480 | return (IsU6_0_Offset(Offset.getNode())); |
| 1481 | } |
| 1482 | |
| 1483 | |
| 1484 | bool HexagonDAGToDAGISel::SelectADDRriU6_1(SDValue& Addr, SDValue &Base, |
| 1485 | SDValue &Offset) { |
| 1486 | if (Addr.getOpcode() == ISD::TargetExternalSymbol || |
| 1487 | Addr.getOpcode() == ISD::TargetGlobalAddress) |
| 1488 | return false; // Direct calls. |
| 1489 | |
| 1490 | if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Addr)) { |
| 1491 | Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32); |
| 1492 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1493 | return (IsU6_1_Offset(Offset.getNode())); |
| 1494 | } |
| 1495 | Base = Addr; |
| 1496 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1497 | return (IsU6_1_Offset(Offset.getNode())); |
| 1498 | } |
| 1499 | |
| 1500 | |
| 1501 | bool HexagonDAGToDAGISel::SelectADDRriU6_2(SDValue& Addr, SDValue &Base, |
| 1502 | SDValue &Offset) { |
| 1503 | if (Addr.getOpcode() == ISD::TargetExternalSymbol || |
| 1504 | Addr.getOpcode() == ISD::TargetGlobalAddress) |
| 1505 | return false; // Direct calls. |
| 1506 | |
| 1507 | if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Addr)) { |
| 1508 | Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32); |
| 1509 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1510 | return (IsU6_2_Offset(Offset.getNode())); |
| 1511 | } |
| 1512 | Base = Addr; |
| 1513 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1514 | return (IsU6_2_Offset(Offset.getNode())); |
| 1515 | } |
| 1516 | |
| 1517 | |
| 1518 | bool HexagonDAGToDAGISel::SelectMEMriS11_2(SDValue& Addr, SDValue &Base, |
| 1519 | SDValue &Offset) { |
| 1520 | |
| 1521 | if (Addr.getOpcode() != ISD::ADD) { |
| 1522 | return(SelectADDRriS11_2(Addr, Base, Offset)); |
| 1523 | } |
| 1524 | |
| 1525 | return SelectADDRriS11_2(Addr, Base, Offset); |
| 1526 | } |
| 1527 | |
| 1528 | |
| 1529 | bool HexagonDAGToDAGISel::SelectADDRriS11_3(SDValue& Addr, SDValue &Base, |
| 1530 | SDValue &Offset) { |
| 1531 | if (Addr.getOpcode() == ISD::TargetExternalSymbol || |
| 1532 | Addr.getOpcode() == ISD::TargetGlobalAddress) |
| 1533 | return false; // Direct calls. |
| 1534 | |
| 1535 | if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Addr)) { |
| 1536 | Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32); |
| 1537 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1538 | return (IsS11_3_Offset(Offset.getNode())); |
| 1539 | } |
| 1540 | Base = Addr; |
| 1541 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1542 | return (IsS11_3_Offset(Offset.getNode())); |
| 1543 | } |
| 1544 | |
| 1545 | bool HexagonDAGToDAGISel::SelectADDRrr(SDValue &Addr, SDValue &R1, |
| 1546 | SDValue &R2) { |
| 1547 | if (Addr.getOpcode() == ISD::FrameIndex) return false; |
| 1548 | if (Addr.getOpcode() == ISD::TargetExternalSymbol || |
| 1549 | Addr.getOpcode() == ISD::TargetGlobalAddress) |
| 1550 | return false; // Direct calls. |
| 1551 | |
| 1552 | if (Addr.getOpcode() == ISD::ADD) { |
| 1553 | if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Addr.getOperand(1))) |
| 1554 | if (isInt<13>(CN->getSExtValue())) |
| 1555 | return false; // Let the reg+imm pattern catch this! |
| 1556 | R1 = Addr.getOperand(0); |
| 1557 | R2 = Addr.getOperand(1); |
| 1558 | return true; |
| 1559 | } |
| 1560 | |
| 1561 | R1 = Addr; |
| 1562 | |
| 1563 | return true; |
| 1564 | } |
| 1565 | |
| 1566 | |
| 1567 | // Handle generic address case. It is accessed from inlined asm =m constraints, |
| 1568 | // which could have any kind of pointer. |
| 1569 | bool HexagonDAGToDAGISel::SelectAddr(SDNode *Op, SDValue Addr, |
| 1570 | SDValue &Base, SDValue &Offset) { |
| 1571 | if (Addr.getOpcode() == ISD::TargetExternalSymbol || |
| 1572 | Addr.getOpcode() == ISD::TargetGlobalAddress) |
| 1573 | return false; // Direct calls. |
| 1574 | |
| 1575 | if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Addr)) { |
| 1576 | Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), MVT::i32); |
| 1577 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1578 | return true; |
| 1579 | } |
| 1580 | |
| 1581 | if (Addr.getOpcode() == ISD::ADD) { |
| 1582 | Base = Addr.getOperand(0); |
| 1583 | Offset = Addr.getOperand(1); |
| 1584 | return true; |
| 1585 | } |
| 1586 | |
| 1587 | Base = Addr; |
| 1588 | Offset = CurDAG->getTargetConstant(0, MVT::i32); |
| 1589 | return true; |
| 1590 | } |
| 1591 | |
| 1592 | |
| 1593 | bool HexagonDAGToDAGISel:: |
| 1594 | SelectInlineAsmMemoryOperand(const SDValue &Op, char ConstraintCode, |
| 1595 | std::vector<SDValue> &OutOps) { |
| 1596 | SDValue Op0, Op1; |
| 1597 | |
| 1598 | switch (ConstraintCode) { |
| 1599 | case 'o': // Offsetable. |
| 1600 | case 'v': // Not offsetable. |
| 1601 | default: return true; |
| 1602 | case 'm': // Memory. |
| 1603 | if (!SelectAddr(Op.getNode(), Op, Op0, Op1)) |
| 1604 | return true; |
| 1605 | break; |
| 1606 | } |
| 1607 | |
| 1608 | OutOps.push_back(Op0); |
| 1609 | OutOps.push_back(Op1); |
| 1610 | return false; |
| 1611 | } |
Jyotsna Verma | 519b385 | 2012-11-28 20:58:14 +0000 | [diff] [blame] | 1612 | |
| 1613 | bool HexagonDAGToDAGISel::isConstExtProfitable(SDNode *N) const { |
| 1614 | unsigned UseCount = 0; |
| 1615 | for (SDNode::use_iterator I = N->use_begin(), E = N->use_end(); I != E; ++I) { |
| 1616 | UseCount++; |
| 1617 | } |
| 1618 | |
| 1619 | return (UseCount <= 1); |
| 1620 | |
| 1621 | } |
Jyotsna Verma | d922524 | 2013-02-13 21:38:46 +0000 | [diff] [blame] | 1622 | |
| 1623 | //===--------------------------------------------------------------------===// |
| 1624 | // Return 'true' if use count of the global address is below threshold. |
| 1625 | //===--------------------------------------------------------------------===// |
| 1626 | bool HexagonDAGToDAGISel::hasNumUsesBelowThresGA(SDNode *N) const { |
| 1627 | assert(N->getOpcode() == ISD::TargetGlobalAddress && |
| 1628 | "Expecting a target global address"); |
| 1629 | |
| 1630 | // Always try to fold the address. |
| 1631 | if (TM.getOptLevel() == CodeGenOpt::Aggressive) |
| 1632 | return true; |
| 1633 | |
| 1634 | GlobalAddressSDNode *GA = cast<GlobalAddressSDNode>(N); |
| 1635 | DenseMap<const GlobalValue *, unsigned>::const_iterator GI = |
| 1636 | GlobalAddressUseCountMap.find(GA->getGlobal()); |
| 1637 | |
| 1638 | if (GI == GlobalAddressUseCountMap.end()) |
| 1639 | return false; |
| 1640 | |
| 1641 | return GI->second <= MaxNumOfUsesForConstExtenders; |
| 1642 | } |
| 1643 | |
| 1644 | //===--------------------------------------------------------------------===// |
Alp Toker | f907b89 | 2013-12-05 05:44:44 +0000 | [diff] [blame] | 1645 | // Return true if the non-GP-relative global address can be folded. |
Jyotsna Verma | d922524 | 2013-02-13 21:38:46 +0000 | [diff] [blame] | 1646 | //===--------------------------------------------------------------------===// |
| 1647 | inline bool HexagonDAGToDAGISel::foldGlobalAddress(SDValue &N, SDValue &R) { |
| 1648 | return foldGlobalAddressImpl(N, R, false); |
| 1649 | } |
| 1650 | |
| 1651 | //===--------------------------------------------------------------------===// |
| 1652 | // Return true if the GP-relative global address can be folded. |
| 1653 | //===--------------------------------------------------------------------===// |
| 1654 | inline bool HexagonDAGToDAGISel::foldGlobalAddressGP(SDValue &N, SDValue &R) { |
| 1655 | return foldGlobalAddressImpl(N, R, true); |
| 1656 | } |
| 1657 | |
| 1658 | //===--------------------------------------------------------------------===// |
| 1659 | // Fold offset of the global address if number of uses are below threshold. |
| 1660 | //===--------------------------------------------------------------------===// |
| 1661 | bool HexagonDAGToDAGISel::foldGlobalAddressImpl(SDValue &N, SDValue &R, |
| 1662 | bool ShouldLookForGP) { |
| 1663 | if (N.getOpcode() == ISD::ADD) { |
| 1664 | SDValue N0 = N.getOperand(0); |
| 1665 | SDValue N1 = N.getOperand(1); |
| 1666 | if ((ShouldLookForGP && (N0.getOpcode() == HexagonISD::CONST32_GP)) || |
| 1667 | (!ShouldLookForGP && (N0.getOpcode() == HexagonISD::CONST32))) { |
| 1668 | ConstantSDNode *Const = dyn_cast<ConstantSDNode>(N1); |
| 1669 | GlobalAddressSDNode *GA = |
| 1670 | dyn_cast<GlobalAddressSDNode>(N0.getOperand(0)); |
| 1671 | |
| 1672 | if (Const && GA && |
| 1673 | (GA->getOpcode() == ISD::TargetGlobalAddress)) { |
| 1674 | if ((N0.getOpcode() == HexagonISD::CONST32) && |
| 1675 | !hasNumUsesBelowThresGA(GA)) |
| 1676 | return false; |
| 1677 | R = CurDAG->getTargetGlobalAddress(GA->getGlobal(), |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 1678 | SDLoc(Const), |
Jyotsna Verma | d922524 | 2013-02-13 21:38:46 +0000 | [diff] [blame] | 1679 | N.getValueType(), |
| 1680 | GA->getOffset() + |
| 1681 | (uint64_t)Const->getSExtValue()); |
| 1682 | return true; |
| 1683 | } |
| 1684 | } |
| 1685 | } |
| 1686 | return false; |
| 1687 | } |
Colin LeMahieu | c7522f3 | 2015-01-14 23:07:36 +0000 | [diff] [blame^] | 1688 | |
| 1689 | bool HexagonDAGToDAGISel::SelectAddrFI(SDValue& N, SDValue &R) { |
| 1690 | if (N.getOpcode() != ISD::FrameIndex) |
| 1691 | return false; |
| 1692 | FrameIndexSDNode *FX = cast<FrameIndexSDNode>(N); |
| 1693 | R = CurDAG->getTargetFrameIndex(FX->getIndex(), MVT::i32); |
| 1694 | return true; |
| 1695 | } |