Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 1 | //===-- MipsSEISelDAGToDAG.cpp - A Dag to Dag Inst Selector for MipsSE ----===// |
| 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 | // Subclass of MipsDAGToDAGISel specialized for mips32/64. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 14 | #include "MipsSEISelDAGToDAG.h" |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 15 | #include "MCTargetDesc/MipsBaseInfo.h" |
Chandler Carruth | 8a8cd2b | 2014-01-07 11:48:04 +0000 | [diff] [blame] | 16 | #include "Mips.h" |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 17 | #include "MipsAnalyzeImmediate.h" |
| 18 | #include "MipsMachineFunction.h" |
| 19 | #include "MipsRegisterInfo.h" |
| 20 | #include "llvm/CodeGen/MachineConstantPool.h" |
| 21 | #include "llvm/CodeGen/MachineFrameInfo.h" |
| 22 | #include "llvm/CodeGen/MachineFunction.h" |
| 23 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
| 24 | #include "llvm/CodeGen/MachineRegisterInfo.h" |
| 25 | #include "llvm/CodeGen/SelectionDAGNodes.h" |
Chandler Carruth | 1305dc3 | 2014-03-04 11:45:46 +0000 | [diff] [blame] | 26 | #include "llvm/IR/CFG.h" |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 27 | #include "llvm/IR/GlobalValue.h" |
| 28 | #include "llvm/IR/Instructions.h" |
| 29 | #include "llvm/IR/Intrinsics.h" |
| 30 | #include "llvm/IR/Type.h" |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 31 | #include "llvm/Support/Debug.h" |
| 32 | #include "llvm/Support/ErrorHandling.h" |
| 33 | #include "llvm/Support/raw_ostream.h" |
| 34 | #include "llvm/Target/TargetMachine.h" |
| 35 | using namespace llvm; |
| 36 | |
Chandler Carruth | 84e68b2 | 2014-04-22 02:41:26 +0000 | [diff] [blame] | 37 | #define DEBUG_TYPE "mips-isel" |
| 38 | |
Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 39 | bool MipsSEDAGToDAGISel::runOnMachineFunction(MachineFunction &MF) { |
Eric Christopher | 96e72c6 | 2015-01-29 23:27:36 +0000 | [diff] [blame] | 40 | Subtarget = &static_cast<const MipsSubtarget &>(MF.getSubtarget()); |
Eric Christopher | 22405e4 | 2014-07-10 17:26:51 +0000 | [diff] [blame] | 41 | if (Subtarget->inMips16Mode()) |
Reed Kotler | 1595f36 | 2013-04-09 19:46:01 +0000 | [diff] [blame] | 42 | return false; |
| 43 | return MipsDAGToDAGISel::runOnMachineFunction(MF); |
| 44 | } |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 45 | |
Akira Hatanaka | e86bd4f | 2013-05-03 18:37:49 +0000 | [diff] [blame] | 46 | void MipsSEDAGToDAGISel::addDSPCtrlRegOperands(bool IsDef, MachineInstr &MI, |
| 47 | MachineFunction &MF) { |
| 48 | MachineInstrBuilder MIB(MF, &MI); |
| 49 | unsigned Mask = MI.getOperand(1).getImm(); |
| 50 | unsigned Flag = IsDef ? RegState::ImplicitDefine : RegState::Implicit; |
| 51 | |
| 52 | if (Mask & 1) |
| 53 | MIB.addReg(Mips::DSPPos, Flag); |
| 54 | |
| 55 | if (Mask & 2) |
| 56 | MIB.addReg(Mips::DSPSCount, Flag); |
| 57 | |
| 58 | if (Mask & 4) |
| 59 | MIB.addReg(Mips::DSPCarry, Flag); |
| 60 | |
| 61 | if (Mask & 8) |
| 62 | MIB.addReg(Mips::DSPOutFlag, Flag); |
| 63 | |
| 64 | if (Mask & 16) |
| 65 | MIB.addReg(Mips::DSPCCond, Flag); |
| 66 | |
| 67 | if (Mask & 32) |
| 68 | MIB.addReg(Mips::DSPEFI, Flag); |
| 69 | } |
| 70 | |
Daniel Sanders | f9aa1d1 | 2013-08-28 10:26:24 +0000 | [diff] [blame] | 71 | unsigned MipsSEDAGToDAGISel::getMSACtrlReg(const SDValue RegIdx) const { |
| 72 | switch (cast<ConstantSDNode>(RegIdx)->getZExtValue()) { |
| 73 | default: |
| 74 | llvm_unreachable("Could not map int to register"); |
| 75 | case 0: return Mips::MSAIR; |
| 76 | case 1: return Mips::MSACSR; |
| 77 | case 2: return Mips::MSAAccess; |
| 78 | case 3: return Mips::MSASave; |
| 79 | case 4: return Mips::MSAModify; |
| 80 | case 5: return Mips::MSARequest; |
| 81 | case 6: return Mips::MSAMap; |
| 82 | case 7: return Mips::MSAUnmap; |
| 83 | } |
| 84 | } |
| 85 | |
Akira Hatanaka | 040d225 | 2013-03-14 18:33:23 +0000 | [diff] [blame] | 86 | bool MipsSEDAGToDAGISel::replaceUsesWithZeroReg(MachineRegisterInfo *MRI, |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 87 | const MachineInstr& MI) { |
| 88 | unsigned DstReg = 0, ZeroReg = 0; |
| 89 | |
| 90 | // Check if MI is "addiu $dst, $zero, 0" or "daddiu $dst, $zero, 0". |
| 91 | if ((MI.getOpcode() == Mips::ADDiu) && |
| 92 | (MI.getOperand(1).getReg() == Mips::ZERO) && |
| 93 | (MI.getOperand(2).getImm() == 0)) { |
| 94 | DstReg = MI.getOperand(0).getReg(); |
| 95 | ZeroReg = Mips::ZERO; |
| 96 | } else if ((MI.getOpcode() == Mips::DADDiu) && |
| 97 | (MI.getOperand(1).getReg() == Mips::ZERO_64) && |
| 98 | (MI.getOperand(2).getImm() == 0)) { |
| 99 | DstReg = MI.getOperand(0).getReg(); |
| 100 | ZeroReg = Mips::ZERO_64; |
| 101 | } |
| 102 | |
| 103 | if (!DstReg) |
| 104 | return false; |
| 105 | |
| 106 | // Replace uses with ZeroReg. |
| 107 | for (MachineRegisterInfo::use_iterator U = MRI->use_begin(DstReg), |
| 108 | E = MRI->use_end(); U != E;) { |
Owen Anderson | 16c6bf4 | 2014-03-13 23:12:04 +0000 | [diff] [blame] | 109 | MachineOperand &MO = *U; |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 110 | unsigned OpNo = U.getOperandNo(); |
| 111 | MachineInstr *MI = MO.getParent(); |
| 112 | ++U; |
| 113 | |
| 114 | // Do not replace if it is a phi's operand or is tied to def operand. |
| 115 | if (MI->isPHI() || MI->isRegTiedToDefOperand(OpNo) || MI->isPseudo()) |
| 116 | continue; |
| 117 | |
| 118 | MO.setReg(ZeroReg); |
| 119 | } |
| 120 | |
| 121 | return true; |
| 122 | } |
| 123 | |
Akira Hatanaka | 040d225 | 2013-03-14 18:33:23 +0000 | [diff] [blame] | 124 | void MipsSEDAGToDAGISel::initGlobalBaseReg(MachineFunction &MF) { |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 125 | MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>(); |
| 126 | |
| 127 | if (!MipsFI->globalBaseRegSet()) |
| 128 | return; |
| 129 | |
| 130 | MachineBasicBlock &MBB = MF.front(); |
| 131 | MachineBasicBlock::iterator I = MBB.begin(); |
| 132 | MachineRegisterInfo &RegInfo = MF.getRegInfo(); |
Eric Christopher | 96e72c6 | 2015-01-29 23:27:36 +0000 | [diff] [blame] | 133 | const TargetInstrInfo &TII = *Subtarget->getInstrInfo(); |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 134 | DebugLoc DL = I != MBB.end() ? I->getDebugLoc() : DebugLoc(); |
| 135 | unsigned V0, V1, GlobalBaseReg = MipsFI->getGlobalBaseReg(); |
| 136 | const TargetRegisterClass *RC; |
Eric Christopher | d86af63 | 2015-01-29 23:27:45 +0000 | [diff] [blame] | 137 | const MipsABIInfo &ABI = static_cast<const MipsTargetMachine &>(TM).getABI(); |
| 138 | RC = (ABI.IsN64()) ? &Mips::GPR64RegClass : &Mips::GPR32RegClass; |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 139 | |
| 140 | V0 = RegInfo.createVirtualRegister(RC); |
| 141 | V1 = RegInfo.createVirtualRegister(RC); |
| 142 | |
Eric Christopher | d86af63 | 2015-01-29 23:27:45 +0000 | [diff] [blame] | 143 | if (ABI.IsN64()) { |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 144 | MF.getRegInfo().addLiveIn(Mips::T9_64); |
| 145 | MBB.addLiveIn(Mips::T9_64); |
| 146 | |
| 147 | // lui $v0, %hi(%neg(%gp_rel(fname))) |
| 148 | // daddu $v1, $v0, $t9 |
| 149 | // daddiu $globalbasereg, $v1, %lo(%neg(%gp_rel(fname))) |
| 150 | const GlobalValue *FName = MF.getFunction(); |
| 151 | BuildMI(MBB, I, DL, TII.get(Mips::LUi64), V0) |
| 152 | .addGlobalAddress(FName, 0, MipsII::MO_GPOFF_HI); |
| 153 | BuildMI(MBB, I, DL, TII.get(Mips::DADDu), V1).addReg(V0) |
| 154 | .addReg(Mips::T9_64); |
| 155 | BuildMI(MBB, I, DL, TII.get(Mips::DADDiu), GlobalBaseReg).addReg(V1) |
| 156 | .addGlobalAddress(FName, 0, MipsII::MO_GPOFF_LO); |
| 157 | return; |
| 158 | } |
| 159 | |
| 160 | if (MF.getTarget().getRelocationModel() == Reloc::Static) { |
| 161 | // Set global register to __gnu_local_gp. |
| 162 | // |
| 163 | // lui $v0, %hi(__gnu_local_gp) |
| 164 | // addiu $globalbasereg, $v0, %lo(__gnu_local_gp) |
| 165 | BuildMI(MBB, I, DL, TII.get(Mips::LUi), V0) |
| 166 | .addExternalSymbol("__gnu_local_gp", MipsII::MO_ABS_HI); |
| 167 | BuildMI(MBB, I, DL, TII.get(Mips::ADDiu), GlobalBaseReg).addReg(V0) |
| 168 | .addExternalSymbol("__gnu_local_gp", MipsII::MO_ABS_LO); |
| 169 | return; |
| 170 | } |
| 171 | |
| 172 | MF.getRegInfo().addLiveIn(Mips::T9); |
| 173 | MBB.addLiveIn(Mips::T9); |
| 174 | |
Eric Christopher | d86af63 | 2015-01-29 23:27:45 +0000 | [diff] [blame] | 175 | if (ABI.IsN32()) { |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 176 | // lui $v0, %hi(%neg(%gp_rel(fname))) |
| 177 | // addu $v1, $v0, $t9 |
| 178 | // addiu $globalbasereg, $v1, %lo(%neg(%gp_rel(fname))) |
| 179 | const GlobalValue *FName = MF.getFunction(); |
| 180 | BuildMI(MBB, I, DL, TII.get(Mips::LUi), V0) |
| 181 | .addGlobalAddress(FName, 0, MipsII::MO_GPOFF_HI); |
| 182 | BuildMI(MBB, I, DL, TII.get(Mips::ADDu), V1).addReg(V0).addReg(Mips::T9); |
| 183 | BuildMI(MBB, I, DL, TII.get(Mips::ADDiu), GlobalBaseReg).addReg(V1) |
| 184 | .addGlobalAddress(FName, 0, MipsII::MO_GPOFF_LO); |
| 185 | return; |
| 186 | } |
| 187 | |
Eric Christopher | d86af63 | 2015-01-29 23:27:45 +0000 | [diff] [blame] | 188 | assert(ABI.IsO32()); |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 189 | |
| 190 | // For O32 ABI, the following instruction sequence is emitted to initialize |
| 191 | // the global base register: |
| 192 | // |
| 193 | // 0. lui $2, %hi(_gp_disp) |
| 194 | // 1. addiu $2, $2, %lo(_gp_disp) |
| 195 | // 2. addu $globalbasereg, $2, $t9 |
| 196 | // |
| 197 | // We emit only the last instruction here. |
| 198 | // |
| 199 | // GNU linker requires that the first two instructions appear at the beginning |
| 200 | // of a function and no instructions be inserted before or between them. |
| 201 | // The two instructions are emitted during lowering to MC layer in order to |
| 202 | // avoid any reordering. |
| 203 | // |
| 204 | // Register $2 (Mips::V0) is added to the list of live-in registers to ensure |
| 205 | // the value instruction 1 (addiu) defines is valid when instruction 2 (addu) |
| 206 | // reads it. |
| 207 | MF.getRegInfo().addLiveIn(Mips::V0); |
| 208 | MBB.addLiveIn(Mips::V0); |
| 209 | BuildMI(MBB, I, DL, TII.get(Mips::ADDu), GlobalBaseReg) |
| 210 | .addReg(Mips::V0).addReg(Mips::T9); |
| 211 | } |
| 212 | |
Akira Hatanaka | 040d225 | 2013-03-14 18:33:23 +0000 | [diff] [blame] | 213 | void MipsSEDAGToDAGISel::processFunctionAfterISel(MachineFunction &MF) { |
| 214 | initGlobalBaseReg(MF); |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 215 | |
| 216 | MachineRegisterInfo *MRI = &MF.getRegInfo(); |
| 217 | |
| 218 | for (MachineFunction::iterator MFI = MF.begin(), MFE = MF.end(); MFI != MFE; |
| 219 | ++MFI) |
Akira Hatanaka | e86bd4f | 2013-05-03 18:37:49 +0000 | [diff] [blame] | 220 | for (MachineBasicBlock::iterator I = MFI->begin(); I != MFI->end(); ++I) { |
| 221 | if (I->getOpcode() == Mips::RDDSP) |
| 222 | addDSPCtrlRegOperands(false, *I, MF); |
| 223 | else if (I->getOpcode() == Mips::WRDSP) |
| 224 | addDSPCtrlRegOperands(true, *I, MF); |
| 225 | else |
| 226 | replaceUsesWithZeroReg(MRI, *I); |
| 227 | } |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 228 | } |
| 229 | |
Akira Hatanaka | b8835b8 | 2013-03-14 18:39:25 +0000 | [diff] [blame] | 230 | SDNode *MipsSEDAGToDAGISel::selectAddESubE(unsigned MOp, SDValue InFlag, |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 231 | SDValue CmpLHS, SDLoc DL, |
Akira Hatanaka | b8835b8 | 2013-03-14 18:39:25 +0000 | [diff] [blame] | 232 | SDNode *Node) const { |
| 233 | unsigned Opc = InFlag.getOpcode(); (void)Opc; |
| 234 | |
| 235 | assert(((Opc == ISD::ADDC || Opc == ISD::ADDE) || |
| 236 | (Opc == ISD::SUBC || Opc == ISD::SUBE)) && |
| 237 | "(ADD|SUB)E flag operand must come from (ADD|SUB)C/E insn"); |
| 238 | |
Vasileios Kalintiris | ef96a8e | 2015-01-26 12:33:22 +0000 | [diff] [blame] | 239 | unsigned SLTuOp = Mips::SLTu, ADDuOp = Mips::ADDu; |
| 240 | if (Subtarget->isGP64bit()) { |
| 241 | SLTuOp = Mips::SLTu64; |
| 242 | ADDuOp = Mips::DADDu; |
| 243 | } |
| 244 | |
Akira Hatanaka | b8835b8 | 2013-03-14 18:39:25 +0000 | [diff] [blame] | 245 | SDValue Ops[] = { CmpLHS, InFlag.getOperand(1) }; |
| 246 | SDValue LHS = Node->getOperand(0), RHS = Node->getOperand(1); |
| 247 | EVT VT = LHS.getValueType(); |
| 248 | |
Vasileios Kalintiris | ef96a8e | 2015-01-26 12:33:22 +0000 | [diff] [blame] | 249 | SDNode *Carry = CurDAG->getMachineNode(SLTuOp, DL, VT, Ops); |
| 250 | |
| 251 | if (Subtarget->isGP64bit()) { |
| 252 | // On 64-bit targets, sltu produces an i64 but our backend currently says |
| 253 | // that SLTu64 produces an i32. We need to fix this in the long run but for |
| 254 | // now, just make the DAG type-correct by asserting the upper bits are zero. |
| 255 | Carry = CurDAG->getMachineNode(Mips::SUBREG_TO_REG, DL, VT, |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 256 | CurDAG->getTargetConstant(0, DL, VT), |
Vasileios Kalintiris | ef96a8e | 2015-01-26 12:33:22 +0000 | [diff] [blame] | 257 | SDValue(Carry, 0), |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 258 | CurDAG->getTargetConstant(Mips::sub_32, DL, |
| 259 | VT)); |
Vasileios Kalintiris | ef96a8e | 2015-01-26 12:33:22 +0000 | [diff] [blame] | 260 | } |
| 261 | |
Vasileios Kalintiris | 18581f1 | 2015-02-27 09:01:39 +0000 | [diff] [blame] | 262 | // Generate a second addition only if we know that RHS is not a |
| 263 | // constant-zero node. |
| 264 | SDNode *AddCarry = Carry; |
| 265 | ConstantSDNode *C = dyn_cast<ConstantSDNode>(RHS); |
| 266 | if (!C || C->getZExtValue()) |
| 267 | AddCarry = CurDAG->getMachineNode(ADDuOp, DL, VT, SDValue(Carry, 0), RHS); |
Vasileios Kalintiris | ef96a8e | 2015-01-26 12:33:22 +0000 | [diff] [blame] | 268 | |
Akira Hatanaka | b8835b8 | 2013-03-14 18:39:25 +0000 | [diff] [blame] | 269 | return CurDAG->SelectNodeTo(Node, MOp, VT, MVT::Glue, LHS, |
| 270 | SDValue(AddCarry, 0)); |
| 271 | } |
| 272 | |
Daniel Sanders | fa961d7 | 2014-03-03 14:31:21 +0000 | [diff] [blame] | 273 | /// Match frameindex |
| 274 | bool MipsSEDAGToDAGISel::selectAddrFrameIndex(SDValue Addr, SDValue &Base, |
| 275 | SDValue &Offset) const { |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 276 | if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode>(Addr)) { |
Daniel Sanders | fa961d7 | 2014-03-03 14:31:21 +0000 | [diff] [blame] | 277 | EVT ValTy = Addr.getValueType(); |
| 278 | |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 279 | Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), ValTy); |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 280 | Offset = CurDAG->getTargetConstant(0, SDLoc(Addr), ValTy); |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 281 | return true; |
| 282 | } |
Daniel Sanders | fa961d7 | 2014-03-03 14:31:21 +0000 | [diff] [blame] | 283 | return false; |
| 284 | } |
| 285 | |
| 286 | /// Match frameindex+offset and frameindex|offset |
| 287 | bool MipsSEDAGToDAGISel::selectAddrFrameIndexOffset(SDValue Addr, SDValue &Base, |
| 288 | SDValue &Offset, |
| 289 | unsigned OffsetBits) const { |
| 290 | if (CurDAG->isBaseWithConstantOffset(Addr)) { |
| 291 | ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Addr.getOperand(1)); |
| 292 | if (isIntN(OffsetBits, CN->getSExtValue())) { |
| 293 | EVT ValTy = Addr.getValueType(); |
| 294 | |
| 295 | // If the first operand is a FI, get the TargetFI Node |
| 296 | if (FrameIndexSDNode *FIN = dyn_cast<FrameIndexSDNode> |
| 297 | (Addr.getOperand(0))) |
| 298 | Base = CurDAG->getTargetFrameIndex(FIN->getIndex(), ValTy); |
| 299 | else |
| 300 | Base = Addr.getOperand(0); |
| 301 | |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 302 | Offset = CurDAG->getTargetConstant(CN->getZExtValue(), SDLoc(Addr), |
| 303 | ValTy); |
Daniel Sanders | fa961d7 | 2014-03-03 14:31:21 +0000 | [diff] [blame] | 304 | return true; |
| 305 | } |
| 306 | } |
| 307 | return false; |
| 308 | } |
| 309 | |
| 310 | /// ComplexPattern used on MipsInstrInfo |
| 311 | /// Used on Mips Load/Store instructions |
| 312 | bool MipsSEDAGToDAGISel::selectAddrRegImm(SDValue Addr, SDValue &Base, |
| 313 | SDValue &Offset) const { |
| 314 | // if Address is FI, get the TargetFrameIndex. |
| 315 | if (selectAddrFrameIndex(Addr, Base, Offset)) |
| 316 | return true; |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 317 | |
| 318 | // on PIC code Load GA |
| 319 | if (Addr.getOpcode() == MipsISD::Wrapper) { |
| 320 | Base = Addr.getOperand(0); |
| 321 | Offset = Addr.getOperand(1); |
| 322 | return true; |
| 323 | } |
| 324 | |
| 325 | if (TM.getRelocationModel() != Reloc::PIC_) { |
| 326 | if ((Addr.getOpcode() == ISD::TargetExternalSymbol || |
| 327 | Addr.getOpcode() == ISD::TargetGlobalAddress)) |
| 328 | return false; |
| 329 | } |
| 330 | |
| 331 | // Addresses of the form FI+const or FI|const |
Daniel Sanders | fa961d7 | 2014-03-03 14:31:21 +0000 | [diff] [blame] | 332 | if (selectAddrFrameIndexOffset(Addr, Base, Offset, 16)) |
| 333 | return true; |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 334 | |
| 335 | // Operand is a result from an ADD. |
| 336 | if (Addr.getOpcode() == ISD::ADD) { |
| 337 | // When loading from constant pools, load the lower address part in |
| 338 | // the instruction itself. Example, instead of: |
| 339 | // lui $2, %hi($CPI1_0) |
| 340 | // addiu $2, $2, %lo($CPI1_0) |
| 341 | // lwc1 $f0, 0($2) |
| 342 | // Generate: |
| 343 | // lui $2, %hi($CPI1_0) |
| 344 | // lwc1 $f0, %lo($CPI1_0)($2) |
| 345 | if (Addr.getOperand(1).getOpcode() == MipsISD::Lo || |
| 346 | Addr.getOperand(1).getOpcode() == MipsISD::GPRel) { |
| 347 | SDValue Opnd0 = Addr.getOperand(1).getOperand(0); |
| 348 | if (isa<ConstantPoolSDNode>(Opnd0) || isa<GlobalAddressSDNode>(Opnd0) || |
| 349 | isa<JumpTableSDNode>(Opnd0)) { |
| 350 | Base = Addr.getOperand(0); |
| 351 | Offset = Opnd0; |
| 352 | return true; |
| 353 | } |
| 354 | } |
| 355 | } |
| 356 | |
| 357 | return false; |
| 358 | } |
| 359 | |
Daniel Sanders | e6ed5b7 | 2013-08-28 12:04:29 +0000 | [diff] [blame] | 360 | /// ComplexPattern used on MipsInstrInfo |
| 361 | /// Used on Mips Load/Store instructions |
| 362 | bool MipsSEDAGToDAGISel::selectAddrRegReg(SDValue Addr, SDValue &Base, |
| 363 | SDValue &Offset) const { |
| 364 | // Operand is a result from an ADD. |
| 365 | if (Addr.getOpcode() == ISD::ADD) { |
| 366 | Base = Addr.getOperand(0); |
| 367 | Offset = Addr.getOperand(1); |
| 368 | return true; |
| 369 | } |
| 370 | |
| 371 | return false; |
| 372 | } |
| 373 | |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 374 | bool MipsSEDAGToDAGISel::selectAddrDefault(SDValue Addr, SDValue &Base, |
| 375 | SDValue &Offset) const { |
| 376 | Base = Addr; |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 377 | Offset = CurDAG->getTargetConstant(0, SDLoc(Addr), Addr.getValueType()); |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 378 | return true; |
| 379 | } |
| 380 | |
| 381 | bool MipsSEDAGToDAGISel::selectIntAddr(SDValue Addr, SDValue &Base, |
| 382 | SDValue &Offset) const { |
| 383 | return selectAddrRegImm(Addr, Base, Offset) || |
| 384 | selectAddrDefault(Addr, Base, Offset); |
| 385 | } |
| 386 | |
Daniel Sanders | a73d8fe | 2015-03-24 11:26:34 +0000 | [diff] [blame] | 387 | bool MipsSEDAGToDAGISel::selectAddrRegImm9(SDValue Addr, SDValue &Base, |
| 388 | SDValue &Offset) const { |
| 389 | if (selectAddrFrameIndex(Addr, Base, Offset)) |
| 390 | return true; |
| 391 | |
| 392 | if (selectAddrFrameIndexOffset(Addr, Base, Offset, 9)) |
| 393 | return true; |
| 394 | |
| 395 | return false; |
| 396 | } |
| 397 | |
Daniel Sanders | fa961d7 | 2014-03-03 14:31:21 +0000 | [diff] [blame] | 398 | bool MipsSEDAGToDAGISel::selectAddrRegImm10(SDValue Addr, SDValue &Base, |
| 399 | SDValue &Offset) const { |
| 400 | if (selectAddrFrameIndex(Addr, Base, Offset)) |
| 401 | return true; |
| 402 | |
| 403 | if (selectAddrFrameIndexOffset(Addr, Base, Offset, 10)) |
| 404 | return true; |
| 405 | |
| 406 | return false; |
| 407 | } |
| 408 | |
Jack Carter | 9770097 | 2013-08-13 20:19:16 +0000 | [diff] [blame] | 409 | /// Used on microMIPS Load/Store unaligned instructions (12-bit offset) |
| 410 | bool MipsSEDAGToDAGISel::selectAddrRegImm12(SDValue Addr, SDValue &Base, |
| 411 | SDValue &Offset) const { |
Daniel Sanders | fa961d7 | 2014-03-03 14:31:21 +0000 | [diff] [blame] | 412 | if (selectAddrFrameIndex(Addr, Base, Offset)) |
| 413 | return true; |
Jack Carter | 9770097 | 2013-08-13 20:19:16 +0000 | [diff] [blame] | 414 | |
Daniel Sanders | fa961d7 | 2014-03-03 14:31:21 +0000 | [diff] [blame] | 415 | if (selectAddrFrameIndexOffset(Addr, Base, Offset, 12)) |
| 416 | return true; |
Jack Carter | 9770097 | 2013-08-13 20:19:16 +0000 | [diff] [blame] | 417 | |
| 418 | return false; |
| 419 | } |
| 420 | |
Daniel Sanders | a73d8fe | 2015-03-24 11:26:34 +0000 | [diff] [blame] | 421 | bool MipsSEDAGToDAGISel::selectAddrRegImm16(SDValue Addr, SDValue &Base, |
| 422 | SDValue &Offset) const { |
| 423 | if (selectAddrFrameIndex(Addr, Base, Offset)) |
| 424 | return true; |
| 425 | |
| 426 | if (selectAddrFrameIndexOffset(Addr, Base, Offset, 16)) |
| 427 | return true; |
| 428 | |
| 429 | return false; |
| 430 | } |
| 431 | |
Jack Carter | 9770097 | 2013-08-13 20:19:16 +0000 | [diff] [blame] | 432 | bool MipsSEDAGToDAGISel::selectIntAddrMM(SDValue Addr, SDValue &Base, |
| 433 | SDValue &Offset) const { |
| 434 | return selectAddrRegImm12(Addr, Base, Offset) || |
| 435 | selectAddrDefault(Addr, Base, Offset); |
| 436 | } |
| 437 | |
Zoran Jovanovic | 5a1a780 | 2015-02-04 15:43:17 +0000 | [diff] [blame] | 438 | bool MipsSEDAGToDAGISel::selectIntAddrLSL2MM(SDValue Addr, SDValue &Base, |
| 439 | SDValue &Offset) const { |
| 440 | if (selectAddrFrameIndexOffset(Addr, Base, Offset, 7)) { |
Vasileios Kalintiris | 99eeb8a | 2015-02-13 19:14:22 +0000 | [diff] [blame] | 441 | if (isa<FrameIndexSDNode>(Base)) |
Zoran Jovanovic | 5a1a780 | 2015-02-04 15:43:17 +0000 | [diff] [blame] | 442 | return false; |
Zoran Jovanovic | 5a1a780 | 2015-02-04 15:43:17 +0000 | [diff] [blame] | 443 | |
Vasileios Kalintiris | 99eeb8a | 2015-02-13 19:14:22 +0000 | [diff] [blame] | 444 | if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Offset)) { |
| 445 | unsigned CnstOff = CN->getZExtValue(); |
| 446 | return (CnstOff == (CnstOff & 0x3c)); |
Zoran Jovanovic | 5a1a780 | 2015-02-04 15:43:17 +0000 | [diff] [blame] | 447 | } |
Vasileios Kalintiris | 99eeb8a | 2015-02-13 19:14:22 +0000 | [diff] [blame] | 448 | |
| 449 | return false; |
Zoran Jovanovic | 5a1a780 | 2015-02-04 15:43:17 +0000 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | // For all other cases where "lw" would be selected, don't select "lw16" |
| 453 | // because it would result in additional instructions to prepare operands. |
| 454 | if (selectAddrRegImm(Addr, Base, Offset)) |
| 455 | return false; |
| 456 | |
| 457 | return selectAddrDefault(Addr, Base, Offset); |
| 458 | } |
| 459 | |
Daniel Sanders | fa961d7 | 2014-03-03 14:31:21 +0000 | [diff] [blame] | 460 | bool MipsSEDAGToDAGISel::selectIntAddrMSA(SDValue Addr, SDValue &Base, |
| 461 | SDValue &Offset) const { |
| 462 | if (selectAddrRegImm10(Addr, Base, Offset)) |
| 463 | return true; |
| 464 | |
| 465 | if (selectAddrDefault(Addr, Base, Offset)) |
| 466 | return true; |
| 467 | |
| 468 | return false; |
| 469 | } |
| 470 | |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 471 | // Select constant vector splats. |
| 472 | // |
| 473 | // Returns true and sets Imm if: |
| 474 | // * MSA is enabled |
| 475 | // * N is a ISD::BUILD_VECTOR representing a constant splat |
Daniel Sanders | c8cd58f | 2015-05-19 12:24:52 +0000 | [diff] [blame] | 476 | bool MipsSEDAGToDAGISel::selectVSplat(SDNode *N, APInt &Imm, |
| 477 | unsigned MinSizeInBits) const { |
Eric Christopher | 22405e4 | 2014-07-10 17:26:51 +0000 | [diff] [blame] | 478 | if (!Subtarget->hasMSA()) |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 479 | return false; |
| 480 | |
| 481 | BuildVectorSDNode *Node = dyn_cast<BuildVectorSDNode>(N); |
| 482 | |
Craig Topper | 062a2ba | 2014-04-25 05:30:21 +0000 | [diff] [blame] | 483 | if (!Node) |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 484 | return false; |
| 485 | |
| 486 | APInt SplatValue, SplatUndef; |
| 487 | unsigned SplatBitSize; |
| 488 | bool HasAnyUndefs; |
| 489 | |
Daniel Sanders | c8cd58f | 2015-05-19 12:24:52 +0000 | [diff] [blame] | 490 | if (!Node->isConstantSplat(SplatValue, SplatUndef, SplatBitSize, HasAnyUndefs, |
| 491 | MinSizeInBits, !Subtarget->isLittle())) |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 492 | return false; |
| 493 | |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 494 | Imm = SplatValue; |
| 495 | |
| 496 | return true; |
| 497 | } |
| 498 | |
| 499 | // Select constant vector splats. |
| 500 | // |
| 501 | // In addition to the requirements of selectVSplat(), this function returns |
| 502 | // true and sets Imm if: |
| 503 | // * The splat value is the same width as the elements of the vector |
| 504 | // * The splat value fits in an integer with the specified signed-ness and |
| 505 | // width. |
| 506 | // |
| 507 | // This function looks through ISD::BITCAST nodes. |
| 508 | // TODO: This might not be appropriate for big-endian MSA since BITCAST is |
| 509 | // sometimes a shuffle in big-endian mode. |
| 510 | // |
| 511 | // It's worth noting that this function is not used as part of the selection |
| 512 | // of ldi.[bhwd] since it does not permit using the wrong-typed ldi.[bhwd] |
| 513 | // instruction to achieve the desired bit pattern. ldi.[bhwd] is selected in |
| 514 | // MipsSEDAGToDAGISel::selectNode. |
| 515 | bool MipsSEDAGToDAGISel:: |
| 516 | selectVSplatCommon(SDValue N, SDValue &Imm, bool Signed, |
| 517 | unsigned ImmBitSize) const { |
| 518 | APInt ImmValue; |
| 519 | EVT EltTy = N->getValueType(0).getVectorElementType(); |
| 520 | |
| 521 | if (N->getOpcode() == ISD::BITCAST) |
| 522 | N = N->getOperand(0); |
| 523 | |
Daniel Sanders | c8cd58f | 2015-05-19 12:24:52 +0000 | [diff] [blame] | 524 | if (selectVSplat(N.getNode(), ImmValue, EltTy.getSizeInBits()) && |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 525 | ImmValue.getBitWidth() == EltTy.getSizeInBits()) { |
Daniel Sanders | c8cd58f | 2015-05-19 12:24:52 +0000 | [diff] [blame] | 526 | |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 527 | if (( Signed && ImmValue.isSignedIntN(ImmBitSize)) || |
| 528 | (!Signed && ImmValue.isIntN(ImmBitSize))) { |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 529 | Imm = CurDAG->getTargetConstant(ImmValue, SDLoc(N), EltTy); |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 530 | return true; |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | return false; |
| 535 | } |
| 536 | |
| 537 | // Select constant vector splats. |
| 538 | bool MipsSEDAGToDAGISel:: |
Daniel Sanders | 7e51fe1 | 2013-09-27 11:48:57 +0000 | [diff] [blame] | 539 | selectVSplatUimm1(SDValue N, SDValue &Imm) const { |
| 540 | return selectVSplatCommon(N, Imm, false, 1); |
| 541 | } |
| 542 | |
| 543 | bool MipsSEDAGToDAGISel:: |
| 544 | selectVSplatUimm2(SDValue N, SDValue &Imm) const { |
| 545 | return selectVSplatCommon(N, Imm, false, 2); |
| 546 | } |
| 547 | |
| 548 | bool MipsSEDAGToDAGISel:: |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 549 | selectVSplatUimm3(SDValue N, SDValue &Imm) const { |
| 550 | return selectVSplatCommon(N, Imm, false, 3); |
| 551 | } |
| 552 | |
| 553 | // Select constant vector splats. |
| 554 | bool MipsSEDAGToDAGISel:: |
| 555 | selectVSplatUimm4(SDValue N, SDValue &Imm) const { |
| 556 | return selectVSplatCommon(N, Imm, false, 4); |
| 557 | } |
| 558 | |
| 559 | // Select constant vector splats. |
| 560 | bool MipsSEDAGToDAGISel:: |
| 561 | selectVSplatUimm5(SDValue N, SDValue &Imm) const { |
| 562 | return selectVSplatCommon(N, Imm, false, 5); |
| 563 | } |
| 564 | |
| 565 | // Select constant vector splats. |
| 566 | bool MipsSEDAGToDAGISel:: |
| 567 | selectVSplatUimm6(SDValue N, SDValue &Imm) const { |
| 568 | return selectVSplatCommon(N, Imm, false, 6); |
| 569 | } |
| 570 | |
| 571 | // Select constant vector splats. |
| 572 | bool MipsSEDAGToDAGISel:: |
| 573 | selectVSplatUimm8(SDValue N, SDValue &Imm) const { |
| 574 | return selectVSplatCommon(N, Imm, false, 8); |
| 575 | } |
| 576 | |
| 577 | // Select constant vector splats. |
| 578 | bool MipsSEDAGToDAGISel:: |
| 579 | selectVSplatSimm5(SDValue N, SDValue &Imm) const { |
| 580 | return selectVSplatCommon(N, Imm, true, 5); |
| 581 | } |
| 582 | |
| 583 | // Select constant vector splats whose value is a power of 2. |
| 584 | // |
| 585 | // In addition to the requirements of selectVSplat(), this function returns |
| 586 | // true and sets Imm if: |
| 587 | // * The splat value is the same width as the elements of the vector |
| 588 | // * The splat value is a power of two. |
| 589 | // |
| 590 | // This function looks through ISD::BITCAST nodes. |
| 591 | // TODO: This might not be appropriate for big-endian MSA since BITCAST is |
| 592 | // sometimes a shuffle in big-endian mode. |
| 593 | bool MipsSEDAGToDAGISel::selectVSplatUimmPow2(SDValue N, SDValue &Imm) const { |
| 594 | APInt ImmValue; |
| 595 | EVT EltTy = N->getValueType(0).getVectorElementType(); |
| 596 | |
| 597 | if (N->getOpcode() == ISD::BITCAST) |
| 598 | N = N->getOperand(0); |
| 599 | |
Daniel Sanders | c8cd58f | 2015-05-19 12:24:52 +0000 | [diff] [blame] | 600 | if (selectVSplat(N.getNode(), ImmValue, EltTy.getSizeInBits()) && |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 601 | ImmValue.getBitWidth() == EltTy.getSizeInBits()) { |
| 602 | int32_t Log2 = ImmValue.exactLogBase2(); |
| 603 | |
| 604 | if (Log2 != -1) { |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 605 | Imm = CurDAG->getTargetConstant(Log2, SDLoc(N), EltTy); |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 606 | return true; |
| 607 | } |
| 608 | } |
| 609 | |
| 610 | return false; |
| 611 | } |
| 612 | |
Daniel Sanders | d74b130 | 2013-10-30 14:45:14 +0000 | [diff] [blame] | 613 | // Select constant vector splats whose value only has a consecutive sequence |
| 614 | // of left-most bits set (e.g. 0b11...1100...00). |
| 615 | // |
| 616 | // In addition to the requirements of selectVSplat(), this function returns |
| 617 | // true and sets Imm if: |
| 618 | // * The splat value is the same width as the elements of the vector |
| 619 | // * The splat value is a consecutive sequence of left-most bits. |
| 620 | // |
| 621 | // This function looks through ISD::BITCAST nodes. |
| 622 | // TODO: This might not be appropriate for big-endian MSA since BITCAST is |
| 623 | // sometimes a shuffle in big-endian mode. |
| 624 | bool MipsSEDAGToDAGISel::selectVSplatMaskL(SDValue N, SDValue &Imm) const { |
| 625 | APInt ImmValue; |
| 626 | EVT EltTy = N->getValueType(0).getVectorElementType(); |
| 627 | |
| 628 | if (N->getOpcode() == ISD::BITCAST) |
| 629 | N = N->getOperand(0); |
| 630 | |
Daniel Sanders | c8cd58f | 2015-05-19 12:24:52 +0000 | [diff] [blame] | 631 | if (selectVSplat(N.getNode(), ImmValue, EltTy.getSizeInBits()) && |
Daniel Sanders | d74b130 | 2013-10-30 14:45:14 +0000 | [diff] [blame] | 632 | ImmValue.getBitWidth() == EltTy.getSizeInBits()) { |
| 633 | // Extract the run of set bits starting with bit zero from the bitwise |
| 634 | // inverse of ImmValue, and test that the inverse of this is the same |
| 635 | // as the original value. |
| 636 | if (ImmValue == ~(~ImmValue & ~(~ImmValue + 1))) { |
| 637 | |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 638 | Imm = CurDAG->getTargetConstant(ImmValue.countPopulation(), SDLoc(N), |
| 639 | EltTy); |
Daniel Sanders | d74b130 | 2013-10-30 14:45:14 +0000 | [diff] [blame] | 640 | return true; |
| 641 | } |
| 642 | } |
| 643 | |
| 644 | return false; |
| 645 | } |
| 646 | |
| 647 | // Select constant vector splats whose value only has a consecutive sequence |
| 648 | // of right-most bits set (e.g. 0b00...0011...11). |
| 649 | // |
| 650 | // In addition to the requirements of selectVSplat(), this function returns |
| 651 | // true and sets Imm if: |
| 652 | // * The splat value is the same width as the elements of the vector |
| 653 | // * The splat value is a consecutive sequence of right-most bits. |
| 654 | // |
| 655 | // This function looks through ISD::BITCAST nodes. |
| 656 | // TODO: This might not be appropriate for big-endian MSA since BITCAST is |
| 657 | // sometimes a shuffle in big-endian mode. |
| 658 | bool MipsSEDAGToDAGISel::selectVSplatMaskR(SDValue N, SDValue &Imm) const { |
| 659 | APInt ImmValue; |
| 660 | EVT EltTy = N->getValueType(0).getVectorElementType(); |
| 661 | |
| 662 | if (N->getOpcode() == ISD::BITCAST) |
| 663 | N = N->getOperand(0); |
| 664 | |
Daniel Sanders | c8cd58f | 2015-05-19 12:24:52 +0000 | [diff] [blame] | 665 | if (selectVSplat(N.getNode(), ImmValue, EltTy.getSizeInBits()) && |
Daniel Sanders | d74b130 | 2013-10-30 14:45:14 +0000 | [diff] [blame] | 666 | ImmValue.getBitWidth() == EltTy.getSizeInBits()) { |
| 667 | // Extract the run of set bits starting with bit zero, and test that the |
| 668 | // result is the same as the original value |
| 669 | if (ImmValue == (ImmValue & ~(ImmValue + 1))) { |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 670 | Imm = CurDAG->getTargetConstant(ImmValue.countPopulation(), SDLoc(N), |
| 671 | EltTy); |
Daniel Sanders | d74b130 | 2013-10-30 14:45:14 +0000 | [diff] [blame] | 672 | return true; |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | return false; |
| 677 | } |
| 678 | |
Daniel Sanders | 3f6eb54 | 2013-11-12 10:45:18 +0000 | [diff] [blame] | 679 | bool MipsSEDAGToDAGISel::selectVSplatUimmInvPow2(SDValue N, |
| 680 | SDValue &Imm) const { |
| 681 | APInt ImmValue; |
| 682 | EVT EltTy = N->getValueType(0).getVectorElementType(); |
| 683 | |
| 684 | if (N->getOpcode() == ISD::BITCAST) |
| 685 | N = N->getOperand(0); |
| 686 | |
Daniel Sanders | c8cd58f | 2015-05-19 12:24:52 +0000 | [diff] [blame] | 687 | if (selectVSplat(N.getNode(), ImmValue, EltTy.getSizeInBits()) && |
Daniel Sanders | 3f6eb54 | 2013-11-12 10:45:18 +0000 | [diff] [blame] | 688 | ImmValue.getBitWidth() == EltTy.getSizeInBits()) { |
| 689 | int32_t Log2 = (~ImmValue).exactLogBase2(); |
| 690 | |
| 691 | if (Log2 != -1) { |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 692 | Imm = CurDAG->getTargetConstant(Log2, SDLoc(N), EltTy); |
Daniel Sanders | 3f6eb54 | 2013-11-12 10:45:18 +0000 | [diff] [blame] | 693 | return true; |
| 694 | } |
| 695 | } |
| 696 | |
| 697 | return false; |
| 698 | } |
| 699 | |
Akira Hatanaka | 040d225 | 2013-03-14 18:33:23 +0000 | [diff] [blame] | 700 | std::pair<bool, SDNode*> MipsSEDAGToDAGISel::selectNode(SDNode *Node) { |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 701 | unsigned Opcode = Node->getOpcode(); |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 702 | SDLoc DL(Node); |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 703 | |
| 704 | /// |
| 705 | // Instruction Selection not handled by the auto-generated |
| 706 | // tablegen selection should be handled here. |
| 707 | /// |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 708 | SDNode *Result; |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 709 | |
| 710 | switch(Opcode) { |
| 711 | default: break; |
| 712 | |
Akira Hatanaka | b8835b8 | 2013-03-14 18:39:25 +0000 | [diff] [blame] | 713 | case ISD::SUBE: { |
| 714 | SDValue InFlag = Node->getOperand(2); |
Vasileios Kalintiris | ef96a8e | 2015-01-26 12:33:22 +0000 | [diff] [blame] | 715 | unsigned Opc = Subtarget->isGP64bit() ? Mips::DSUBu : Mips::SUBu; |
| 716 | Result = selectAddESubE(Opc, InFlag, InFlag.getOperand(0), DL, Node); |
Akira Hatanaka | b8835b8 | 2013-03-14 18:39:25 +0000 | [diff] [blame] | 717 | return std::make_pair(true, Result); |
| 718 | } |
| 719 | |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 720 | case ISD::ADDE: { |
Eric Christopher | 22405e4 | 2014-07-10 17:26:51 +0000 | [diff] [blame] | 721 | if (Subtarget->hasDSP()) // Select DSP instructions, ADDSC and ADDWC. |
Akira Hatanaka | 2f08822 | 2013-04-13 00:55:41 +0000 | [diff] [blame] | 722 | break; |
Akira Hatanaka | b8835b8 | 2013-03-14 18:39:25 +0000 | [diff] [blame] | 723 | SDValue InFlag = Node->getOperand(2); |
Vasileios Kalintiris | ef96a8e | 2015-01-26 12:33:22 +0000 | [diff] [blame] | 724 | unsigned Opc = Subtarget->isGP64bit() ? Mips::DADDu : Mips::ADDu; |
| 725 | Result = selectAddESubE(Opc, InFlag, InFlag.getValue(0), DL, Node); |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 726 | return std::make_pair(true, Result); |
| 727 | } |
| 728 | |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 729 | case ISD::ConstantFP: { |
| 730 | ConstantFPSDNode *CN = dyn_cast<ConstantFPSDNode>(Node); |
| 731 | if (Node->getValueType(0) == MVT::f64 && CN->isExactlyValue(+0.0)) { |
Eric Christopher | 22405e4 | 2014-07-10 17:26:51 +0000 | [diff] [blame] | 732 | if (Subtarget->isGP64bit()) { |
Akira Hatanaka | 040d225 | 2013-03-14 18:33:23 +0000 | [diff] [blame] | 733 | SDValue Zero = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), DL, |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 734 | Mips::ZERO_64, MVT::i64); |
Akira Hatanaka | 040d225 | 2013-03-14 18:33:23 +0000 | [diff] [blame] | 735 | Result = CurDAG->getMachineNode(Mips::DMTC1, DL, MVT::f64, Zero); |
Eric Christopher | 22405e4 | 2014-07-10 17:26:51 +0000 | [diff] [blame] | 736 | } else if (Subtarget->isFP64bit()) { |
Daniel Sanders | 08d3cd1 | 2013-11-18 13:12:43 +0000 | [diff] [blame] | 737 | SDValue Zero = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), DL, |
| 738 | Mips::ZERO, MVT::i32); |
| 739 | Result = CurDAG->getMachineNode(Mips::BuildPairF64_64, DL, MVT::f64, |
| 740 | Zero, Zero); |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 741 | } else { |
Akira Hatanaka | 040d225 | 2013-03-14 18:33:23 +0000 | [diff] [blame] | 742 | SDValue Zero = CurDAG->getCopyFromReg(CurDAG->getEntryNode(), DL, |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 743 | Mips::ZERO, MVT::i32); |
Akira Hatanaka | 040d225 | 2013-03-14 18:33:23 +0000 | [diff] [blame] | 744 | Result = CurDAG->getMachineNode(Mips::BuildPairF64, DL, MVT::f64, Zero, |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 745 | Zero); |
| 746 | } |
| 747 | |
| 748 | return std::make_pair(true, Result); |
| 749 | } |
| 750 | break; |
| 751 | } |
| 752 | |
| 753 | case ISD::Constant: { |
| 754 | const ConstantSDNode *CN = dyn_cast<ConstantSDNode>(Node); |
| 755 | unsigned Size = CN->getValueSizeInBits(0); |
| 756 | |
| 757 | if (Size == 32) |
| 758 | break; |
| 759 | |
| 760 | MipsAnalyzeImmediate AnalyzeImm; |
| 761 | int64_t Imm = CN->getSExtValue(); |
| 762 | |
| 763 | const MipsAnalyzeImmediate::InstSeq &Seq = |
| 764 | AnalyzeImm.Analyze(Imm, Size, false); |
| 765 | |
| 766 | MipsAnalyzeImmediate::InstSeq::const_iterator Inst = Seq.begin(); |
Andrew Trick | ef9de2a | 2013-05-25 02:42:55 +0000 | [diff] [blame] | 767 | SDLoc DL(CN); |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 768 | SDNode *RegOpnd; |
| 769 | SDValue ImmOpnd = CurDAG->getTargetConstant(SignExtend64<16>(Inst->ImmOpnd), |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 770 | DL, MVT::i64); |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 771 | |
| 772 | // The first instruction can be a LUi which is different from other |
| 773 | // instructions (ADDiu, ORI and SLL) in that it does not have a register |
| 774 | // operand. |
| 775 | if (Inst->Opc == Mips::LUi64) |
| 776 | RegOpnd = CurDAG->getMachineNode(Inst->Opc, DL, MVT::i64, ImmOpnd); |
| 777 | else |
| 778 | RegOpnd = |
| 779 | CurDAG->getMachineNode(Inst->Opc, DL, MVT::i64, |
| 780 | CurDAG->getRegister(Mips::ZERO_64, MVT::i64), |
| 781 | ImmOpnd); |
| 782 | |
| 783 | // The remaining instructions in the sequence are handled here. |
| 784 | for (++Inst; Inst != Seq.end(); ++Inst) { |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 785 | ImmOpnd = CurDAG->getTargetConstant(SignExtend64<16>(Inst->ImmOpnd), DL, |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 786 | MVT::i64); |
| 787 | RegOpnd = CurDAG->getMachineNode(Inst->Opc, DL, MVT::i64, |
| 788 | SDValue(RegOpnd, 0), ImmOpnd); |
| 789 | } |
| 790 | |
| 791 | return std::make_pair(true, RegOpnd); |
| 792 | } |
| 793 | |
Daniel Sanders | f9aa1d1 | 2013-08-28 10:26:24 +0000 | [diff] [blame] | 794 | case ISD::INTRINSIC_W_CHAIN: { |
| 795 | switch (cast<ConstantSDNode>(Node->getOperand(1))->getZExtValue()) { |
| 796 | default: |
| 797 | break; |
| 798 | |
| 799 | case Intrinsic::mips_cfcmsa: { |
| 800 | SDValue ChainIn = Node->getOperand(0); |
| 801 | SDValue RegIdx = Node->getOperand(2); |
| 802 | SDValue Reg = CurDAG->getCopyFromReg(ChainIn, DL, |
| 803 | getMSACtrlReg(RegIdx), MVT::i32); |
| 804 | return std::make_pair(true, Reg.getNode()); |
| 805 | } |
| 806 | } |
| 807 | break; |
| 808 | } |
| 809 | |
Daniel Sanders | ba9c850 | 2013-08-28 10:44:47 +0000 | [diff] [blame] | 810 | case ISD::INTRINSIC_WO_CHAIN: { |
| 811 | switch (cast<ConstantSDNode>(Node->getOperand(0))->getZExtValue()) { |
| 812 | default: |
| 813 | break; |
| 814 | |
| 815 | case Intrinsic::mips_move_v: |
| 816 | // Like an assignment but will always produce a move.v even if |
| 817 | // unnecessary. |
| 818 | return std::make_pair(true, |
| 819 | CurDAG->getMachineNode(Mips::MOVE_V, DL, |
| 820 | Node->getValueType(0), |
| 821 | Node->getOperand(1))); |
| 822 | } |
| 823 | break; |
| 824 | } |
| 825 | |
Daniel Sanders | f9aa1d1 | 2013-08-28 10:26:24 +0000 | [diff] [blame] | 826 | case ISD::INTRINSIC_VOID: { |
| 827 | switch (cast<ConstantSDNode>(Node->getOperand(1))->getZExtValue()) { |
| 828 | default: |
| 829 | break; |
| 830 | |
| 831 | case Intrinsic::mips_ctcmsa: { |
| 832 | SDValue ChainIn = Node->getOperand(0); |
| 833 | SDValue RegIdx = Node->getOperand(2); |
| 834 | SDValue Value = Node->getOperand(3); |
| 835 | SDValue ChainOut = CurDAG->getCopyToReg(ChainIn, DL, |
| 836 | getMSACtrlReg(RegIdx), Value); |
| 837 | return std::make_pair(true, ChainOut.getNode()); |
| 838 | } |
| 839 | } |
| 840 | break; |
| 841 | } |
| 842 | |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 843 | case MipsISD::ThreadPointer: { |
Mehdi Amini | 44ede33 | 2015-07-09 02:09:04 +0000 | [diff] [blame^] | 844 | EVT PtrVT = getTargetLowering()->getPointerTy(CurDAG->getDataLayout()); |
Akira Hatanaka | 85ccf23 | 2013-08-08 21:37:32 +0000 | [diff] [blame] | 845 | unsigned RdhwrOpc, DestReg; |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 846 | |
| 847 | if (PtrVT == MVT::i32) { |
| 848 | RdhwrOpc = Mips::RDHWR; |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 849 | DestReg = Mips::V1; |
| 850 | } else { |
| 851 | RdhwrOpc = Mips::RDHWR64; |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 852 | DestReg = Mips::V1_64; |
| 853 | } |
| 854 | |
| 855 | SDNode *Rdhwr = |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 856 | CurDAG->getMachineNode(RdhwrOpc, DL, |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 857 | Node->getValueType(0), |
Akira Hatanaka | 85ccf23 | 2013-08-08 21:37:32 +0000 | [diff] [blame] | 858 | CurDAG->getRegister(Mips::HWR29, MVT::i32)); |
Akira Hatanaka | 040d225 | 2013-03-14 18:33:23 +0000 | [diff] [blame] | 859 | SDValue Chain = CurDAG->getCopyToReg(CurDAG->getEntryNode(), DL, DestReg, |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 860 | SDValue(Rdhwr, 0)); |
Akira Hatanaka | 040d225 | 2013-03-14 18:33:23 +0000 | [diff] [blame] | 861 | SDValue ResNode = CurDAG->getCopyFromReg(Chain, DL, DestReg, PtrVT); |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 862 | ReplaceUses(SDValue(Node, 0), ResNode); |
| 863 | return std::make_pair(true, ResNode.getNode()); |
| 864 | } |
Akira Hatanaka | be8612f | 2013-03-30 01:36:35 +0000 | [diff] [blame] | 865 | |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 866 | case ISD::BUILD_VECTOR: { |
| 867 | // Select appropriate ldi.[bhwd] instructions for constant splats of |
| 868 | // 128-bit when MSA is enabled. Fixup any register class mismatches that |
| 869 | // occur as a result. |
| 870 | // |
| 871 | // This allows the compiler to use a wider range of immediates than would |
| 872 | // otherwise be allowed. If, for example, v4i32 could only use ldi.h then |
| 873 | // it would not be possible to load { 0x01010101, 0x01010101, 0x01010101, |
| 874 | // 0x01010101 } without using a constant pool. This would be sub-optimal |
| 875 | // when // 'ldi.b wd, 1' is capable of producing that bit-pattern in the |
| 876 | // same set/ of registers. Similarly, ldi.h isn't capable of producing { |
| 877 | // 0x00000000, 0x00000001, 0x00000000, 0x00000001 } but 'ldi.d wd, 1' can. |
| 878 | |
| 879 | BuildVectorSDNode *BVN = cast<BuildVectorSDNode>(Node); |
| 880 | APInt SplatValue, SplatUndef; |
| 881 | unsigned SplatBitSize; |
| 882 | bool HasAnyUndefs; |
| 883 | unsigned LdiOp; |
| 884 | EVT ResVecTy = BVN->getValueType(0); |
| 885 | EVT ViaVecTy; |
| 886 | |
Eric Christopher | 22405e4 | 2014-07-10 17:26:51 +0000 | [diff] [blame] | 887 | if (!Subtarget->hasMSA() || !BVN->getValueType(0).is128BitVector()) |
Craig Topper | 062a2ba | 2014-04-25 05:30:21 +0000 | [diff] [blame] | 888 | return std::make_pair(false, nullptr); |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 889 | |
| 890 | if (!BVN->isConstantSplat(SplatValue, SplatUndef, SplatBitSize, |
| 891 | HasAnyUndefs, 8, |
Eric Christopher | 22405e4 | 2014-07-10 17:26:51 +0000 | [diff] [blame] | 892 | !Subtarget->isLittle())) |
Craig Topper | 062a2ba | 2014-04-25 05:30:21 +0000 | [diff] [blame] | 893 | return std::make_pair(false, nullptr); |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 894 | |
| 895 | switch (SplatBitSize) { |
| 896 | default: |
Craig Topper | 062a2ba | 2014-04-25 05:30:21 +0000 | [diff] [blame] | 897 | return std::make_pair(false, nullptr); |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 898 | case 8: |
| 899 | LdiOp = Mips::LDI_B; |
| 900 | ViaVecTy = MVT::v16i8; |
| 901 | break; |
| 902 | case 16: |
| 903 | LdiOp = Mips::LDI_H; |
| 904 | ViaVecTy = MVT::v8i16; |
| 905 | break; |
| 906 | case 32: |
| 907 | LdiOp = Mips::LDI_W; |
| 908 | ViaVecTy = MVT::v4i32; |
| 909 | break; |
| 910 | case 64: |
| 911 | LdiOp = Mips::LDI_D; |
| 912 | ViaVecTy = MVT::v2i64; |
| 913 | break; |
| 914 | } |
| 915 | |
| 916 | if (!SplatValue.isSignedIntN(10)) |
Craig Topper | 062a2ba | 2014-04-25 05:30:21 +0000 | [diff] [blame] | 917 | return std::make_pair(false, nullptr); |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 918 | |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 919 | SDValue Imm = CurDAG->getTargetConstant(SplatValue, DL, |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 920 | ViaVecTy.getVectorElementType()); |
| 921 | |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 922 | SDNode *Res = CurDAG->getMachineNode(LdiOp, DL, ViaVecTy, Imm); |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 923 | |
| 924 | if (ResVecTy != ViaVecTy) { |
| 925 | // If LdiOp is writing to a different register class to ResVecTy, then |
| 926 | // fix it up here. This COPY_TO_REGCLASS should never cause a move.v |
| 927 | // since the source and destination register sets contain the same |
| 928 | // registers. |
| 929 | const TargetLowering *TLI = getTargetLowering(); |
| 930 | MVT ResVecTySimple = ResVecTy.getSimpleVT(); |
| 931 | const TargetRegisterClass *RC = TLI->getRegClassFor(ResVecTySimple); |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 932 | Res = CurDAG->getMachineNode(Mips::COPY_TO_REGCLASS, DL, |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 933 | ResVecTy, SDValue(Res, 0), |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 934 | CurDAG->getTargetConstant(RC->getID(), DL, |
Daniel Sanders | f49dd82 | 2013-09-24 13:33:07 +0000 | [diff] [blame] | 935 | MVT::i32)); |
| 936 | } |
| 937 | |
| 938 | return std::make_pair(true, Res); |
| 939 | } |
| 940 | |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 941 | } |
| 942 | |
Craig Topper | 062a2ba | 2014-04-25 05:30:21 +0000 | [diff] [blame] | 943 | return std::make_pair(false, nullptr); |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 944 | } |
| 945 | |
Daniel Sanders | a73d8fe | 2015-03-24 11:26:34 +0000 | [diff] [blame] | 946 | bool MipsSEDAGToDAGISel:: |
| 947 | SelectInlineAsmMemoryOperand(const SDValue &Op, unsigned ConstraintID, |
| 948 | std::vector<SDValue> &OutOps) { |
| 949 | SDValue Base, Offset; |
| 950 | |
| 951 | switch(ConstraintID) { |
| 952 | default: |
| 953 | llvm_unreachable("Unexpected asm memory constraint"); |
| 954 | // All memory constraints can at least accept raw pointers. |
| 955 | case InlineAsm::Constraint_i: |
Daniel Sanders | a73d8fe | 2015-03-24 11:26:34 +0000 | [diff] [blame] | 956 | OutOps.push_back(Op); |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 957 | OutOps.push_back(CurDAG->getTargetConstant(0, SDLoc(Op), MVT::i32)); |
Daniel Sanders | a73d8fe | 2015-03-24 11:26:34 +0000 | [diff] [blame] | 958 | return false; |
Daniel Sanders | c676f2a | 2015-03-24 15:19:14 +0000 | [diff] [blame] | 959 | case InlineAsm::Constraint_m: |
| 960 | if (selectAddrRegImm16(Op, Base, Offset)) { |
| 961 | OutOps.push_back(Base); |
| 962 | OutOps.push_back(Offset); |
| 963 | return false; |
| 964 | } |
| 965 | OutOps.push_back(Op); |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 966 | OutOps.push_back(CurDAG->getTargetConstant(0, SDLoc(Op), MVT::i32)); |
Daniel Sanders | c676f2a | 2015-03-24 15:19:14 +0000 | [diff] [blame] | 967 | return false; |
Daniel Sanders | 82df616 | 2015-03-30 13:27:25 +0000 | [diff] [blame] | 968 | case InlineAsm::Constraint_R: |
| 969 | // The 'R' constraint is supposed to be much more complicated than this. |
| 970 | // However, it's becoming less useful due to architectural changes and |
| 971 | // ought to be replaced by other constraints such as 'ZC'. |
| 972 | // For now, support 9-bit signed offsets which is supportable by all |
| 973 | // subtargets for all instructions. |
| 974 | if (selectAddrRegImm9(Op, Base, Offset)) { |
| 975 | OutOps.push_back(Base); |
| 976 | OutOps.push_back(Offset); |
| 977 | return false; |
| 978 | } |
| 979 | OutOps.push_back(Op); |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 980 | OutOps.push_back(CurDAG->getTargetConstant(0, SDLoc(Op), MVT::i32)); |
Daniel Sanders | 82df616 | 2015-03-30 13:27:25 +0000 | [diff] [blame] | 981 | return false; |
Daniel Sanders | a73d8fe | 2015-03-24 11:26:34 +0000 | [diff] [blame] | 982 | case InlineAsm::Constraint_ZC: |
| 983 | // ZC matches whatever the pref, ll, and sc instructions can handle for the |
| 984 | // given subtarget. |
| 985 | if (Subtarget->inMicroMipsMode()) { |
| 986 | // On microMIPS, they can handle 12-bit offsets. |
| 987 | if (selectAddrRegImm12(Op, Base, Offset)) { |
| 988 | OutOps.push_back(Base); |
| 989 | OutOps.push_back(Offset); |
| 990 | return false; |
| 991 | } |
| 992 | } else if (Subtarget->hasMips32r6()) { |
| 993 | // On MIPS32r6/MIPS64r6, they can only handle 9-bit offsets. |
| 994 | if (selectAddrRegImm9(Op, Base, Offset)) { |
| 995 | OutOps.push_back(Base); |
| 996 | OutOps.push_back(Offset); |
| 997 | return false; |
| 998 | } |
| 999 | } else if (selectAddrRegImm16(Op, Base, Offset)) { |
| 1000 | // Prior to MIPS32r6/MIPS64r6, they can handle 16-bit offsets. |
| 1001 | OutOps.push_back(Base); |
| 1002 | OutOps.push_back(Offset); |
| 1003 | return false; |
| 1004 | } |
| 1005 | // In all cases, 0-bit offsets are acceptable. |
| 1006 | OutOps.push_back(Op); |
Sergey Dmitrouk | 842a51b | 2015-04-28 14:05:47 +0000 | [diff] [blame] | 1007 | OutOps.push_back(CurDAG->getTargetConstant(0, SDLoc(Op), MVT::i32)); |
Daniel Sanders | a73d8fe | 2015-03-24 11:26:34 +0000 | [diff] [blame] | 1008 | return false; |
| 1009 | } |
| 1010 | return true; |
| 1011 | } |
| 1012 | |
Akira Hatanaka | 30a8478 | 2013-03-14 18:27:31 +0000 | [diff] [blame] | 1013 | FunctionPass *llvm::createMipsSEISelDag(MipsTargetMachine &TM) { |
| 1014 | return new MipsSEDAGToDAGISel(TM); |
| 1015 | } |