Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 1 | //===-- MipsISelLowering.cpp - Mips DAG Lowering Implementation -----------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines the interfaces that Mips uses to lower LLVM code into a |
| 11 | // selection DAG. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #define DEBUG_TYPE "mips-lower" |
| 16 | |
| 17 | #include "MipsISelLowering.h" |
Bruno Cardoso Lopes | a2b1bb5 | 2007-08-28 05:08:16 +0000 | [diff] [blame] | 18 | #include "MipsMachineFunction.h" |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 19 | #include "MipsTargetMachine.h" |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 20 | #include "MipsSubtarget.h" |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 21 | #include "llvm/DerivedTypes.h" |
| 22 | #include "llvm/Function.h" |
| 23 | #include "llvm/Intrinsics.h" |
| 24 | #include "llvm/CallingConv.h" |
| 25 | #include "llvm/CodeGen/CallingConvLower.h" |
| 26 | #include "llvm/CodeGen/MachineFrameInfo.h" |
| 27 | #include "llvm/CodeGen/MachineFunction.h" |
| 28 | #include "llvm/CodeGen/MachineInstrBuilder.h" |
Chris Lattner | 84bc542 | 2007-12-31 04:13:23 +0000 | [diff] [blame] | 29 | #include "llvm/CodeGen/MachineRegisterInfo.h" |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 30 | #include "llvm/CodeGen/SelectionDAGISel.h" |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 31 | #include "llvm/CodeGen/ValueTypes.h" |
| 32 | #include "llvm/Support/Debug.h" |
| 33 | #include <queue> |
| 34 | #include <set> |
| 35 | |
| 36 | using namespace llvm; |
| 37 | |
| 38 | const char *MipsTargetLowering:: |
| 39 | getTargetNodeName(unsigned Opcode) const |
| 40 | { |
| 41 | switch (Opcode) |
| 42 | { |
Bruno Cardoso Lopes | 07cec75 | 2008-06-06 00:58:26 +0000 | [diff] [blame] | 43 | case MipsISD::JmpLink : return "MipsISD::JmpLink"; |
| 44 | case MipsISD::Hi : return "MipsISD::Hi"; |
| 45 | case MipsISD::Lo : return "MipsISD::Lo"; |
| 46 | case MipsISD::Ret : return "MipsISD::Ret"; |
| 47 | case MipsISD::SelectCC : return "MipsISD::SelectCC"; |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 48 | case MipsISD::FPBrcond : return "MipsISD::FPBrcond"; |
| 49 | case MipsISD::FPCmp : return "MipsISD::FPCmp"; |
Bruno Cardoso Lopes | 07cec75 | 2008-06-06 00:58:26 +0000 | [diff] [blame] | 50 | default : return NULL; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 51 | } |
| 52 | } |
| 53 | |
| 54 | MipsTargetLowering:: |
| 55 | MipsTargetLowering(MipsTargetMachine &TM): TargetLowering(TM) |
| 56 | { |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 57 | Subtarget = &TM.getSubtarget<MipsSubtarget>(); |
| 58 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 59 | // Mips does not have i1 type, so use i32 for |
| 60 | // setcc operations results (slt, sgt, ...). |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 61 | setSetCCResultContents(ZeroOrOneSetCCResult); |
| 62 | |
Bruno Cardoso Lopes | 753a987 | 2007-11-12 19:49:57 +0000 | [diff] [blame] | 63 | // JumpTable targets must use GOT when using PIC_ |
| 64 | setUsesGlobalOffsetTable(true); |
| 65 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 66 | // Set up the register classes |
| 67 | addRegisterClass(MVT::i32, Mips::CPURegsRegisterClass); |
| 68 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 69 | // When dealing with single precision only, use libcalls |
| 70 | if (!Subtarget->isSingleFloat()) { |
| 71 | addRegisterClass(MVT::f32, Mips::AFGR32RegisterClass); |
| 72 | if (!Subtarget->isFP64bit()) |
| 73 | addRegisterClass(MVT::f64, Mips::AFGR64RegisterClass); |
| 74 | } else |
| 75 | addRegisterClass(MVT::f32, Mips::FGR32RegisterClass); |
| 76 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 77 | // Custom |
| 78 | setOperationAction(ISD::GlobalAddress, MVT::i32, Custom); |
Lauro Ramos Venancio | 75ce010 | 2007-07-11 17:19:51 +0000 | [diff] [blame] | 79 | setOperationAction(ISD::GlobalTLSAddress, MVT::i32, Custom); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 80 | setOperationAction(ISD::RET, MVT::Other, Custom); |
Bruno Cardoso Lopes | 753a987 | 2007-11-12 19:49:57 +0000 | [diff] [blame] | 81 | setOperationAction(ISD::JumpTable, MVT::i32, Custom); |
Bruno Cardoso Lopes | 07cec75 | 2008-06-06 00:58:26 +0000 | [diff] [blame] | 82 | setOperationAction(ISD::SELECT_CC, MVT::i32, Custom); |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 83 | setOperationAction(ISD::SELECT_CC, MVT::f32, Custom); |
| 84 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 85 | // Load extented operations for i1 types must be promoted |
| 86 | setLoadXAction(ISD::EXTLOAD, MVT::i1, Promote); |
| 87 | setLoadXAction(ISD::ZEXTLOAD, MVT::i1, Promote); |
| 88 | setLoadXAction(ISD::SEXTLOAD, MVT::i1, Promote); |
| 89 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 90 | // Mips does not have these NodeTypes below. |
Bruno Cardoso Lopes | 85e9212 | 2008-07-07 19:11:24 +0000 | [diff] [blame] | 91 | setConvertAction(MVT::f64, MVT::f32, Expand); |
| 92 | |
| 93 | setOperationAction(ISD::BR_JT, MVT::Other, Expand); |
| 94 | setOperationAction(ISD::BR_CC, MVT::Other, Expand); |
| 95 | setOperationAction(ISD::SELECT_CC, MVT::Other, Expand); |
| 96 | setOperationAction(ISD::SELECT, MVT::i32, Expand); |
| 97 | setOperationAction(ISD::UINT_TO_FP, MVT::i32, Expand); |
| 98 | setOperationAction(ISD::FP_TO_UINT, MVT::i32, Expand); |
| 99 | setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i1, Expand); |
| 100 | |
| 101 | if (Subtarget->isSingleFloat()) |
| 102 | setOperationAction(ISD::SELECT_CC, MVT::f64, Expand); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 103 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 104 | if (!Subtarget->isAllegrex()) { |
| 105 | setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i8, Expand); |
| 106 | setOperationAction(ISD::SIGN_EXTEND_INREG, MVT::i16, Expand); |
| 107 | } |
| 108 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 109 | // Mips not supported intrinsics. |
Andrew Lenharth | d497d9f | 2008-02-16 14:46:26 +0000 | [diff] [blame] | 110 | setOperationAction(ISD::MEMBARRIER, MVT::Other, Expand); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 111 | |
| 112 | setOperationAction(ISD::CTPOP, MVT::i32, Expand); |
| 113 | setOperationAction(ISD::CTTZ , MVT::i32, Expand); |
| 114 | setOperationAction(ISD::CTLZ , MVT::i32, Expand); |
| 115 | setOperationAction(ISD::ROTL , MVT::i32, Expand); |
| 116 | setOperationAction(ISD::ROTR , MVT::i32, Expand); |
| 117 | setOperationAction(ISD::BSWAP, MVT::i32, Expand); |
| 118 | |
| 119 | setOperationAction(ISD::SHL_PARTS, MVT::i32, Expand); |
| 120 | setOperationAction(ISD::SRA_PARTS, MVT::i32, Expand); |
| 121 | setOperationAction(ISD::SRL_PARTS, MVT::i32, Expand); |
| 122 | |
| 123 | // We don't have line number support yet. |
Dan Gohman | 7f46020 | 2008-06-30 20:59:49 +0000 | [diff] [blame] | 124 | setOperationAction(ISD::DBG_STOPPOINT, MVT::Other, Expand); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 125 | setOperationAction(ISD::DEBUG_LOC, MVT::Other, Expand); |
Dan Gohman | 4406604 | 2008-07-01 00:05:16 +0000 | [diff] [blame] | 126 | setOperationAction(ISD::DBG_LABEL, MVT::Other, Expand); |
| 127 | setOperationAction(ISD::EH_LABEL, MVT::Other, Expand); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 128 | |
| 129 | // Use the default for now |
| 130 | setOperationAction(ISD::STACKSAVE, MVT::Other, Expand); |
| 131 | setOperationAction(ISD::STACKRESTORE, MVT::Other, Expand); |
| 132 | |
| 133 | setStackPointerRegisterToSaveRestore(Mips::SP); |
| 134 | computeRegisterProperties(); |
| 135 | } |
| 136 | |
| 137 | |
Duncan Sands | 83ec4b6 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 138 | MVT MipsTargetLowering::getSetCCResultType(const SDOperand &) const { |
Scott Michel | 5b8f82e | 2008-03-10 15:42:14 +0000 | [diff] [blame] | 139 | return MVT::i32; |
| 140 | } |
| 141 | |
| 142 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 143 | SDOperand MipsTargetLowering:: |
| 144 | LowerOperation(SDOperand Op, SelectionDAG &DAG) |
| 145 | { |
| 146 | switch (Op.getOpcode()) |
| 147 | { |
| 148 | case ISD::CALL: return LowerCALL(Op, DAG); |
| 149 | case ISD::FORMAL_ARGUMENTS: return LowerFORMAL_ARGUMENTS(Op, DAG); |
| 150 | case ISD::RET: return LowerRET(Op, DAG); |
| 151 | case ISD::GlobalAddress: return LowerGlobalAddress(Op, DAG); |
Lauro Ramos Venancio | 75ce010 | 2007-07-11 17:19:51 +0000 | [diff] [blame] | 152 | case ISD::GlobalTLSAddress: return LowerGlobalTLSAddress(Op, DAG); |
Bruno Cardoso Lopes | 753a987 | 2007-11-12 19:49:57 +0000 | [diff] [blame] | 153 | case ISD::JumpTable: return LowerJumpTable(Op, DAG); |
Bruno Cardoso Lopes | 07cec75 | 2008-06-06 00:58:26 +0000 | [diff] [blame] | 154 | case ISD::SELECT_CC: return LowerSELECT_CC(Op, DAG); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 155 | } |
| 156 | return SDOperand(); |
| 157 | } |
| 158 | |
Bruno Cardoso Lopes | 07cec75 | 2008-06-06 00:58:26 +0000 | [diff] [blame] | 159 | MachineBasicBlock * |
| 160 | MipsTargetLowering::EmitInstrWithCustomInserter(MachineInstr *MI, |
| 161 | MachineBasicBlock *BB) |
| 162 | { |
| 163 | const TargetInstrInfo *TII = getTargetMachine().getInstrInfo(); |
| 164 | switch (MI->getOpcode()) { |
| 165 | default: assert(false && "Unexpected instr type to insert"); |
| 166 | case Mips::Select_CC: { |
| 167 | // To "insert" a SELECT_CC instruction, we actually have to insert the |
| 168 | // diamond control-flow pattern. The incoming instruction knows the |
| 169 | // destination vreg to set, the condition code register to branch on, the |
| 170 | // true/false values to select between, and a branch opcode to use. |
| 171 | const BasicBlock *LLVM_BB = BB->getBasicBlock(); |
Dan Gohman | 8e5f2c6 | 2008-07-07 23:14:23 +0000 | [diff] [blame^] | 172 | MachineFunction::iterator It = BB; |
Bruno Cardoso Lopes | 07cec75 | 2008-06-06 00:58:26 +0000 | [diff] [blame] | 173 | ++It; |
| 174 | |
| 175 | // thisMBB: |
| 176 | // ... |
| 177 | // TrueVal = ... |
| 178 | // setcc r1, r2, r3 |
| 179 | // bNE r1, r0, copy1MBB |
| 180 | // fallthrough --> copy0MBB |
| 181 | MachineBasicBlock *thisMBB = BB; |
Dan Gohman | 8e5f2c6 | 2008-07-07 23:14:23 +0000 | [diff] [blame^] | 182 | MachineFunction *F = BB->getParent(); |
| 183 | MachineBasicBlock *copy0MBB = F->CreateMachineBasicBlock(LLVM_BB); |
| 184 | MachineBasicBlock *sinkMBB = F->CreateMachineBasicBlock(LLVM_BB); |
Bruno Cardoso Lopes | 07cec75 | 2008-06-06 00:58:26 +0000 | [diff] [blame] | 185 | BuildMI(BB, TII->get(Mips::BNE)).addReg(MI->getOperand(1).getReg()) |
| 186 | .addReg(Mips::ZERO).addMBB(sinkMBB); |
Dan Gohman | 8e5f2c6 | 2008-07-07 23:14:23 +0000 | [diff] [blame^] | 187 | F->insert(It, copy0MBB); |
| 188 | F->insert(It, sinkMBB); |
Bruno Cardoso Lopes | 07cec75 | 2008-06-06 00:58:26 +0000 | [diff] [blame] | 189 | // Update machine-CFG edges by first adding all successors of the current |
| 190 | // block to the new block which will contain the Phi node for the select. |
| 191 | for(MachineBasicBlock::succ_iterator i = BB->succ_begin(), |
| 192 | e = BB->succ_end(); i != e; ++i) |
| 193 | sinkMBB->addSuccessor(*i); |
| 194 | // Next, remove all successors of the current block, and add the true |
| 195 | // and fallthrough blocks as its successors. |
| 196 | while(!BB->succ_empty()) |
| 197 | BB->removeSuccessor(BB->succ_begin()); |
| 198 | BB->addSuccessor(copy0MBB); |
| 199 | BB->addSuccessor(sinkMBB); |
| 200 | |
| 201 | // copy0MBB: |
| 202 | // %FalseValue = ... |
| 203 | // # fallthrough to sinkMBB |
| 204 | BB = copy0MBB; |
| 205 | |
| 206 | // Update machine-CFG edges |
| 207 | BB->addSuccessor(sinkMBB); |
| 208 | |
| 209 | // sinkMBB: |
| 210 | // %Result = phi [ %FalseValue, copy0MBB ], [ %TrueValue, thisMBB ] |
| 211 | // ... |
| 212 | BB = sinkMBB; |
| 213 | BuildMI(BB, TII->get(Mips::PHI), MI->getOperand(0).getReg()) |
| 214 | .addReg(MI->getOperand(2).getReg()).addMBB(copy0MBB) |
| 215 | .addReg(MI->getOperand(3).getReg()).addMBB(thisMBB); |
| 216 | |
Dan Gohman | 8e5f2c6 | 2008-07-07 23:14:23 +0000 | [diff] [blame^] | 217 | F->DeleteMachineInstr(MI); // The pseudo instruction is gone now. |
Bruno Cardoso Lopes | 07cec75 | 2008-06-06 00:58:26 +0000 | [diff] [blame] | 218 | return BB; |
| 219 | } |
| 220 | } |
| 221 | } |
| 222 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 223 | //===----------------------------------------------------------------------===// |
| 224 | // Lower helper functions |
| 225 | //===----------------------------------------------------------------------===// |
| 226 | |
| 227 | // AddLiveIn - This helper function adds the specified physical register to the |
| 228 | // MachineFunction as a live in value. It also creates a corresponding |
| 229 | // virtual register for it. |
| 230 | static unsigned |
| 231 | AddLiveIn(MachineFunction &MF, unsigned PReg, TargetRegisterClass *RC) |
| 232 | { |
| 233 | assert(RC->contains(PReg) && "Not the correct regclass!"); |
Chris Lattner | 84bc542 | 2007-12-31 04:13:23 +0000 | [diff] [blame] | 234 | unsigned VReg = MF.getRegInfo().createVirtualRegister(RC); |
| 235 | MF.getRegInfo().addLiveIn(PReg, VReg); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 236 | return VReg; |
| 237 | } |
| 238 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 239 | //===----------------------------------------------------------------------===// |
| 240 | // Misc Lower Operation implementation |
| 241 | //===----------------------------------------------------------------------===// |
| 242 | SDOperand MipsTargetLowering:: |
| 243 | LowerGlobalAddress(SDOperand Op, SelectionDAG &DAG) |
| 244 | { |
Bruno Cardoso Lopes | 8262df3 | 2007-10-09 03:15:11 +0000 | [diff] [blame] | 245 | SDOperand ResNode; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 246 | GlobalValue *GV = cast<GlobalAddressSDNode>(Op)->getGlobal(); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 247 | SDOperand GA = DAG.getTargetGlobalAddress(GV, MVT::i32); |
Bruno Cardoso Lopes | c7db561 | 2007-11-05 03:02:32 +0000 | [diff] [blame] | 248 | bool isPIC = (getTargetMachine().getRelocationModel() == Reloc::PIC_); |
Bruno Cardoso Lopes | 7ff6fa2 | 2007-08-18 02:16:30 +0000 | [diff] [blame] | 249 | |
Bruno Cardoso Lopes | c7db561 | 2007-11-05 03:02:32 +0000 | [diff] [blame] | 250 | SDOperand HiPart; |
| 251 | if (!isPIC) { |
Duncan Sands | 83ec4b6 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 252 | const MVT *VTs = DAG.getNodeValueTypes(MVT::i32); |
Bruno Cardoso Lopes | 8262df3 | 2007-10-09 03:15:11 +0000 | [diff] [blame] | 253 | SDOperand Ops[] = { GA }; |
Bruno Cardoso Lopes | c7db561 | 2007-11-05 03:02:32 +0000 | [diff] [blame] | 254 | HiPart = DAG.getNode(MipsISD::Hi, VTs, 1, Ops, 1); |
| 255 | } else // Emit Load from Global Pointer |
| 256 | HiPart = DAG.getLoad(MVT::i32, DAG.getEntryNode(), GA, NULL, 0); |
Bruno Cardoso Lopes | 7ff6fa2 | 2007-08-18 02:16:30 +0000 | [diff] [blame] | 257 | |
Bruno Cardoso Lopes | c7db561 | 2007-11-05 03:02:32 +0000 | [diff] [blame] | 258 | // On functions and global targets not internal linked only |
| 259 | // a load from got/GP is necessary for PIC to work. |
| 260 | if ((isPIC) && ((!GV->hasInternalLinkage()) || (isa<Function>(GV)))) |
| 261 | return HiPart; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 262 | |
Bruno Cardoso Lopes | c7db561 | 2007-11-05 03:02:32 +0000 | [diff] [blame] | 263 | SDOperand Lo = DAG.getNode(MipsISD::Lo, MVT::i32, GA); |
| 264 | ResNode = DAG.getNode(ISD::ADD, MVT::i32, HiPart, Lo); |
Bruno Cardoso Lopes | 8262df3 | 2007-10-09 03:15:11 +0000 | [diff] [blame] | 265 | |
| 266 | return ResNode; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 267 | } |
| 268 | |
| 269 | SDOperand MipsTargetLowering:: |
Lauro Ramos Venancio | 75ce010 | 2007-07-11 17:19:51 +0000 | [diff] [blame] | 270 | LowerGlobalTLSAddress(SDOperand Op, SelectionDAG &DAG) |
| 271 | { |
| 272 | assert(0 && "TLS not implemented for MIPS."); |
Chris Lattner | d27c991 | 2008-03-30 18:22:13 +0000 | [diff] [blame] | 273 | return SDOperand(); // Not reached |
Lauro Ramos Venancio | 75ce010 | 2007-07-11 17:19:51 +0000 | [diff] [blame] | 274 | } |
| 275 | |
Bruno Cardoso Lopes | 753a987 | 2007-11-12 19:49:57 +0000 | [diff] [blame] | 276 | SDOperand MipsTargetLowering:: |
Bruno Cardoso Lopes | 07cec75 | 2008-06-06 00:58:26 +0000 | [diff] [blame] | 277 | LowerSELECT_CC(SDOperand Op, SelectionDAG &DAG) |
| 278 | { |
| 279 | SDOperand LHS = Op.getOperand(0); |
| 280 | SDOperand RHS = Op.getOperand(1); |
| 281 | SDOperand True = Op.getOperand(2); |
| 282 | SDOperand False = Op.getOperand(3); |
| 283 | SDOperand CC = Op.getOperand(4); |
| 284 | |
Duncan Sands | 83ec4b6 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 285 | const MVT *VTs = DAG.getNodeValueTypes(MVT::i32); |
Bruno Cardoso Lopes | 07cec75 | 2008-06-06 00:58:26 +0000 | [diff] [blame] | 286 | SDOperand Ops[] = { LHS, RHS, CC }; |
| 287 | SDOperand SetCCRes = DAG.getNode(ISD::SETCC, VTs, 1, Ops, 3); |
| 288 | |
| 289 | return DAG.getNode(MipsISD::SelectCC, True.getValueType(), |
| 290 | SetCCRes, True, False); |
| 291 | } |
| 292 | |
| 293 | SDOperand MipsTargetLowering:: |
Bruno Cardoso Lopes | 753a987 | 2007-11-12 19:49:57 +0000 | [diff] [blame] | 294 | LowerJumpTable(SDOperand Op, SelectionDAG &DAG) |
| 295 | { |
| 296 | SDOperand ResNode; |
| 297 | SDOperand HiPart; |
| 298 | |
Duncan Sands | 83ec4b6 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 299 | MVT PtrVT = Op.getValueType(); |
Bruno Cardoso Lopes | 753a987 | 2007-11-12 19:49:57 +0000 | [diff] [blame] | 300 | JumpTableSDNode *JT = cast<JumpTableSDNode>(Op); |
| 301 | SDOperand JTI = DAG.getTargetJumpTable(JT->getIndex(), PtrVT); |
| 302 | |
| 303 | if (getTargetMachine().getRelocationModel() != Reloc::PIC_) { |
Duncan Sands | 83ec4b6 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 304 | const MVT *VTs = DAG.getNodeValueTypes(MVT::i32); |
Bruno Cardoso Lopes | 753a987 | 2007-11-12 19:49:57 +0000 | [diff] [blame] | 305 | SDOperand Ops[] = { JTI }; |
| 306 | HiPart = DAG.getNode(MipsISD::Hi, VTs, 1, Ops, 1); |
| 307 | } else // Emit Load from Global Pointer |
| 308 | HiPart = DAG.getLoad(MVT::i32, DAG.getEntryNode(), JTI, NULL, 0); |
| 309 | |
| 310 | SDOperand Lo = DAG.getNode(MipsISD::Lo, MVT::i32, JTI); |
| 311 | ResNode = DAG.getNode(ISD::ADD, MVT::i32, HiPart, Lo); |
| 312 | |
| 313 | return ResNode; |
| 314 | } |
| 315 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 316 | //===----------------------------------------------------------------------===// |
| 317 | // Calling Convention Implementation |
| 318 | // |
| 319 | // The lower operations present on calling convention works on this order: |
| 320 | // LowerCALL (virt regs --> phys regs, virt regs --> stack) |
| 321 | // LowerFORMAL_ARGUMENTS (phys --> virt regs, stack --> virt regs) |
| 322 | // LowerRET (virt regs --> phys regs) |
| 323 | // LowerCALL (phys regs --> virt regs) |
| 324 | // |
| 325 | //===----------------------------------------------------------------------===// |
| 326 | |
| 327 | #include "MipsGenCallingConv.inc" |
| 328 | |
| 329 | //===----------------------------------------------------------------------===// |
| 330 | // CALL Calling Convention Implementation |
| 331 | //===----------------------------------------------------------------------===// |
| 332 | |
| 333 | /// Mips custom CALL implementation |
| 334 | SDOperand MipsTargetLowering:: |
| 335 | LowerCALL(SDOperand Op, SelectionDAG &DAG) |
| 336 | { |
Chris Lattner | e0b1215 | 2008-03-17 06:57:02 +0000 | [diff] [blame] | 337 | unsigned CallingConv = cast<ConstantSDNode>(Op.getOperand(1))->getValue(); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 338 | |
| 339 | // By now, only CallingConv::C implemented |
Chris Lattner | e0b1215 | 2008-03-17 06:57:02 +0000 | [diff] [blame] | 340 | switch (CallingConv) { |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 341 | default: |
| 342 | assert(0 && "Unsupported calling convention"); |
| 343 | case CallingConv::Fast: |
| 344 | case CallingConv::C: |
| 345 | return LowerCCCCallTo(Op, DAG, CallingConv); |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | /// LowerCCCCallTo - functions arguments are copied from virtual |
| 350 | /// regs to (physical regs)/(stack frame), CALLSEQ_START and |
| 351 | /// CALLSEQ_END are emitted. |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 352 | /// TODO: isVarArg, isTailCall. |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 353 | SDOperand MipsTargetLowering:: |
| 354 | LowerCCCCallTo(SDOperand Op, SelectionDAG &DAG, unsigned CC) |
| 355 | { |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 356 | MachineFunction &MF = DAG.getMachineFunction(); |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 357 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 358 | SDOperand Chain = Op.getOperand(0); |
| 359 | SDOperand Callee = Op.getOperand(4); |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 360 | bool isVarArg = cast<ConstantSDNode>(Op.getOperand(2))->getValue() != 0; |
| 361 | |
| 362 | MachineFrameInfo *MFI = MF.getFrameInfo(); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 363 | |
| 364 | // Analyze operands of the call, assigning locations to each operand. |
| 365 | SmallVector<CCValAssign, 16> ArgLocs; |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 366 | CCState CCInfo(CC, isVarArg, getTargetMachine(), ArgLocs); |
| 367 | |
| 368 | // To meet ABI, Mips must always allocate 16 bytes on |
| 369 | // the stack (even if less than 4 are used as arguments) |
Duncan Sands | 83ec4b6 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 370 | int VTsize = MVT(MVT::i32).getSizeInBits()/8; |
Bruno Cardoso Lopes | a2b1bb5 | 2007-08-28 05:08:16 +0000 | [diff] [blame] | 371 | MFI->CreateFixedObject(VTsize, (VTsize*3)); |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 372 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 373 | CCInfo.AnalyzeCallOperands(Op.Val, CC_Mips); |
| 374 | |
| 375 | // Get a count of how many bytes are to be pushed on the stack. |
| 376 | unsigned NumBytes = CCInfo.getNextStackOffset(); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 377 | Chain = DAG.getCALLSEQ_START(Chain,DAG.getConstant(NumBytes, |
| 378 | getPointerTy())); |
| 379 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 380 | // With EABI is it possible to have 16 args on registers. |
| 381 | SmallVector<std::pair<unsigned, SDOperand>, 16> RegsToPass; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 382 | SmallVector<SDOperand, 8> MemOpChains; |
| 383 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 384 | // First/LastArgStackLoc contains the first/last |
| 385 | // "at stack" argument location. |
| 386 | int LastArgStackLoc = 0; |
| 387 | unsigned FirstStackArgLoc = (Subtarget->isABI_EABI() ? 0 : 16); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 388 | |
| 389 | // Walk the register/memloc assignments, inserting copies/loads. |
| 390 | for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) { |
| 391 | CCValAssign &VA = ArgLocs[i]; |
| 392 | |
| 393 | // Arguments start after the 5 first operands of ISD::CALL |
| 394 | SDOperand Arg = Op.getOperand(5+2*VA.getValNo()); |
| 395 | |
| 396 | // Promote the value if needed. |
| 397 | switch (VA.getLocInfo()) { |
Chris Lattner | e0b1215 | 2008-03-17 06:57:02 +0000 | [diff] [blame] | 398 | default: assert(0 && "Unknown loc info!"); |
| 399 | case CCValAssign::Full: break; |
| 400 | case CCValAssign::SExt: |
| 401 | Arg = DAG.getNode(ISD::SIGN_EXTEND, VA.getLocVT(), Arg); |
| 402 | break; |
| 403 | case CCValAssign::ZExt: |
| 404 | Arg = DAG.getNode(ISD::ZERO_EXTEND, VA.getLocVT(), Arg); |
| 405 | break; |
| 406 | case CCValAssign::AExt: |
| 407 | Arg = DAG.getNode(ISD::ANY_EXTEND, VA.getLocVT(), Arg); |
| 408 | break; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 409 | } |
| 410 | |
Bruno Cardoso Lopes | c7db561 | 2007-11-05 03:02:32 +0000 | [diff] [blame] | 411 | // Arguments that can be passed on register must be kept at |
| 412 | // RegsToPass vector |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 413 | if (VA.isRegLoc()) { |
| 414 | RegsToPass.push_back(std::make_pair(VA.getLocReg(), Arg)); |
Chris Lattner | e0b1215 | 2008-03-17 06:57:02 +0000 | [diff] [blame] | 415 | continue; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 416 | } |
Chris Lattner | e0b1215 | 2008-03-17 06:57:02 +0000 | [diff] [blame] | 417 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 418 | // Register cant get to this point... |
Chris Lattner | e0b1215 | 2008-03-17 06:57:02 +0000 | [diff] [blame] | 419 | assert(VA.isMemLoc()); |
| 420 | |
| 421 | // Create the frame index object for this incoming parameter |
| 422 | // This guarantees that when allocating Local Area the firsts |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 423 | // 16 bytes which are alwayes reserved won't be overwritten |
| 424 | // if O32 ABI is used. For EABI the first address is zero. |
| 425 | LastArgStackLoc = (FirstStackArgLoc + VA.getLocMemOffset()); |
Duncan Sands | 83ec4b6 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 426 | int FI = MFI->CreateFixedObject(VA.getValVT().getSizeInBits()/8, |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 427 | LastArgStackLoc); |
Chris Lattner | e0b1215 | 2008-03-17 06:57:02 +0000 | [diff] [blame] | 428 | |
| 429 | SDOperand PtrOff = DAG.getFrameIndex(FI,getPointerTy()); |
| 430 | |
| 431 | // emit ISD::STORE whichs stores the |
| 432 | // parameter value to a stack Location |
| 433 | MemOpChains.push_back(DAG.getStore(Chain, Arg, PtrOff, NULL, 0)); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 434 | } |
| 435 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 436 | // Transform all store nodes into one single node because all store |
| 437 | // nodes are independent of each other. |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 438 | if (!MemOpChains.empty()) |
| 439 | Chain = DAG.getNode(ISD::TokenFactor, MVT::Other, |
| 440 | &MemOpChains[0], MemOpChains.size()); |
| 441 | |
| 442 | // Build a sequence of copy-to-reg nodes chained together with token |
| 443 | // chain and flag operands which copy the outgoing args into registers. |
| 444 | // The InFlag in necessary since all emited instructions must be |
| 445 | // stuck together. |
| 446 | SDOperand InFlag; |
| 447 | for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) { |
| 448 | Chain = DAG.getCopyToReg(Chain, RegsToPass[i].first, |
| 449 | RegsToPass[i].second, InFlag); |
| 450 | InFlag = Chain.getValue(1); |
| 451 | } |
| 452 | |
Bruno Cardoso Lopes | 8262df3 | 2007-10-09 03:15:11 +0000 | [diff] [blame] | 453 | // If the callee is a GlobalAddress/ExternalSymbol node (quite common, every |
| 454 | // direct call is) turn it into a TargetGlobalAddress/TargetExternalSymbol |
Bruno Cardoso Lopes | c7db561 | 2007-11-05 03:02:32 +0000 | [diff] [blame] | 455 | // node so that legalize doesn't hack it. |
| 456 | if (GlobalAddressSDNode *G = dyn_cast<GlobalAddressSDNode>(Callee)) |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 457 | Callee = DAG.getTargetGlobalAddress(G->getGlobal(), getPointerTy()); |
Bruno Cardoso Lopes | 8262df3 | 2007-10-09 03:15:11 +0000 | [diff] [blame] | 458 | else if (ExternalSymbolSDNode *S = dyn_cast<ExternalSymbolSDNode>(Callee)) |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 459 | Callee = DAG.getTargetExternalSymbol(S->getSymbol(), getPointerTy()); |
| 460 | |
Bruno Cardoso Lopes | c7db561 | 2007-11-05 03:02:32 +0000 | [diff] [blame] | 461 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 462 | // MipsJmpLink = #chain, #target_address, #opt_in_flags... |
| 463 | // = Chain, Callee, Reg#1, Reg#2, ... |
| 464 | // |
| 465 | // Returns a chain & a flag for retval copy to use. |
| 466 | SDVTList NodeTys = DAG.getVTList(MVT::Other, MVT::Flag); |
| 467 | SmallVector<SDOperand, 8> Ops; |
| 468 | Ops.push_back(Chain); |
| 469 | Ops.push_back(Callee); |
| 470 | |
| 471 | // Add argument registers to the end of the list so that they are |
| 472 | // known live into the call. |
| 473 | for (unsigned i = 0, e = RegsToPass.size(); i != e; ++i) |
| 474 | Ops.push_back(DAG.getRegister(RegsToPass[i].first, |
| 475 | RegsToPass[i].second.getValueType())); |
| 476 | |
| 477 | if (InFlag.Val) |
| 478 | Ops.push_back(InFlag); |
| 479 | |
| 480 | Chain = DAG.getNode(MipsISD::JmpLink, NodeTys, &Ops[0], Ops.size()); |
| 481 | InFlag = Chain.getValue(1); |
| 482 | |
Bruno Cardoso Lopes | d2947ee | 2008-06-04 01:45:25 +0000 | [diff] [blame] | 483 | // Create the CALLSEQ_END node. |
Bruno Cardoso Lopes | bdbb750 | 2008-06-01 03:49:39 +0000 | [diff] [blame] | 484 | Chain = DAG.getCALLSEQ_END(Chain, |
| 485 | DAG.getConstant(NumBytes, getPointerTy()), |
| 486 | DAG.getConstant(0, getPointerTy()), |
| 487 | InFlag); |
| 488 | InFlag = Chain.getValue(1); |
| 489 | |
Bruno Cardoso Lopes | c7db561 | 2007-11-05 03:02:32 +0000 | [diff] [blame] | 490 | // Create a stack location to hold GP when PIC is used. This stack |
| 491 | // location is used on function prologue to save GP and also after all |
| 492 | // emited CALL's to restore GP. |
| 493 | if (getTargetMachine().getRelocationModel() == Reloc::PIC_) { |
Bruno Cardoso Lopes | c7db561 | 2007-11-05 03:02:32 +0000 | [diff] [blame] | 494 | // Function can have an arbitrary number of calls, so |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 495 | // hold the LastArgStackLoc with the biggest offset. |
Bruno Cardoso Lopes | c7db561 | 2007-11-05 03:02:32 +0000 | [diff] [blame] | 496 | int FI; |
| 497 | MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>(); |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 498 | if (LastArgStackLoc >= MipsFI->getGPStackOffset()) { |
| 499 | LastArgStackLoc = (!LastArgStackLoc) ? (16) : (LastArgStackLoc+4); |
Bruno Cardoso Lopes | c7db561 | 2007-11-05 03:02:32 +0000 | [diff] [blame] | 500 | // Create the frame index only once. SPOffset here can be anything |
| 501 | // (this will be fixed on processFunctionBeforeFrameFinalized) |
| 502 | if (MipsFI->getGPStackOffset() == -1) { |
| 503 | FI = MFI->CreateFixedObject(4, 0); |
| 504 | MipsFI->setGPFI(FI); |
| 505 | } |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 506 | MipsFI->setGPStackOffset(LastArgStackLoc); |
Bruno Cardoso Lopes | c7db561 | 2007-11-05 03:02:32 +0000 | [diff] [blame] | 507 | } |
| 508 | |
Bruno Cardoso Lopes | c7db561 | 2007-11-05 03:02:32 +0000 | [diff] [blame] | 509 | // Reload GP value. |
| 510 | FI = MipsFI->getGPFI(); |
| 511 | SDOperand FIN = DAG.getFrameIndex(FI,getPointerTy()); |
| 512 | SDOperand GPLoad = DAG.getLoad(MVT::i32, Chain, FIN, NULL, 0); |
| 513 | Chain = GPLoad.getValue(1); |
| 514 | Chain = DAG.getCopyToReg(Chain, DAG.getRegister(Mips::GP, MVT::i32), |
| 515 | GPLoad, SDOperand(0,0)); |
Bruno Cardoso Lopes | bdbb750 | 2008-06-01 03:49:39 +0000 | [diff] [blame] | 516 | InFlag = Chain.getValue(1); |
Bruno Cardoso Lopes | c7db561 | 2007-11-05 03:02:32 +0000 | [diff] [blame] | 517 | } |
| 518 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 519 | // Handle result values, copying them out of physregs into vregs that we |
| 520 | // return. |
| 521 | return SDOperand(LowerCallResult(Chain, InFlag, Op.Val, CC, DAG), Op.ResNo); |
| 522 | } |
| 523 | |
| 524 | /// LowerCallResult - Lower the result values of an ISD::CALL into the |
| 525 | /// appropriate copies out of appropriate physical registers. This assumes that |
| 526 | /// Chain/InFlag are the input chain/flag to use, and that TheCall is the call |
| 527 | /// being lowered. Returns a SDNode with the same number of values as the |
| 528 | /// ISD::CALL. |
| 529 | SDNode *MipsTargetLowering:: |
| 530 | LowerCallResult(SDOperand Chain, SDOperand InFlag, SDNode *TheCall, |
| 531 | unsigned CallingConv, SelectionDAG &DAG) { |
| 532 | |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 533 | bool isVarArg = cast<ConstantSDNode>(TheCall->getOperand(2))->getValue() != 0; |
| 534 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 535 | // Assign locations to each value returned by this call. |
| 536 | SmallVector<CCValAssign, 16> RVLocs; |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 537 | CCState CCInfo(CallingConv, isVarArg, getTargetMachine(), RVLocs); |
| 538 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 539 | CCInfo.AnalyzeCallResult(TheCall, RetCC_Mips); |
| 540 | SmallVector<SDOperand, 8> ResultVals; |
| 541 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 542 | // Copy all of the result registers out of their specified physreg. |
| 543 | for (unsigned i = 0; i != RVLocs.size(); ++i) { |
| 544 | Chain = DAG.getCopyFromReg(Chain, RVLocs[i].getLocReg(), |
| 545 | RVLocs[i].getValVT(), InFlag).getValue(1); |
| 546 | InFlag = Chain.getValue(2); |
| 547 | ResultVals.push_back(Chain.getValue(0)); |
| 548 | } |
| 549 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 550 | ResultVals.push_back(Chain); |
Bruno Cardoso Lopes | c7db561 | 2007-11-05 03:02:32 +0000 | [diff] [blame] | 551 | |
| 552 | // Merge everything together with a MERGE_VALUES node. |
Duncan Sands | f951620 | 2008-06-30 10:19:09 +0000 | [diff] [blame] | 553 | return DAG.getMergeValues(TheCall->getVTList(), &ResultVals[0], |
| 554 | ResultVals.size()).Val; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 555 | } |
| 556 | |
| 557 | //===----------------------------------------------------------------------===// |
| 558 | // FORMAL_ARGUMENTS Calling Convention Implementation |
| 559 | //===----------------------------------------------------------------------===// |
| 560 | |
| 561 | /// Mips custom FORMAL_ARGUMENTS implementation |
| 562 | SDOperand MipsTargetLowering:: |
| 563 | LowerFORMAL_ARGUMENTS(SDOperand Op, SelectionDAG &DAG) |
| 564 | { |
| 565 | unsigned CC = cast<ConstantSDNode>(Op.getOperand(1))->getValue(); |
| 566 | switch(CC) |
| 567 | { |
| 568 | default: |
| 569 | assert(0 && "Unsupported calling convention"); |
| 570 | case CallingConv::C: |
| 571 | return LowerCCCArguments(Op, DAG); |
| 572 | } |
| 573 | } |
| 574 | |
| 575 | /// LowerCCCArguments - transform physical registers into |
| 576 | /// virtual registers and generate load operations for |
| 577 | /// arguments places on the stack. |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 578 | /// TODO: isVarArg |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 579 | SDOperand MipsTargetLowering:: |
| 580 | LowerCCCArguments(SDOperand Op, SelectionDAG &DAG) |
| 581 | { |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 582 | SDOperand Root = Op.getOperand(0); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 583 | MachineFunction &MF = DAG.getMachineFunction(); |
| 584 | MachineFrameInfo *MFI = MF.getFrameInfo(); |
Bruno Cardoso Lopes | a2b1bb5 | 2007-08-28 05:08:16 +0000 | [diff] [blame] | 585 | MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>(); |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 586 | |
| 587 | bool isVarArg = cast<ConstantSDNode>(Op.getOperand(2))->getValue() != 0; |
| 588 | unsigned CC = DAG.getMachineFunction().getFunction()->getCallingConv(); |
| 589 | |
| 590 | unsigned StackReg = MF.getTarget().getRegisterInfo()->getFrameRegister(MF); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 591 | |
Bruno Cardoso Lopes | 753a987 | 2007-11-12 19:49:57 +0000 | [diff] [blame] | 592 | // GP holds the GOT address on PIC calls. |
| 593 | if (getTargetMachine().getRelocationModel() == Reloc::PIC_) |
| 594 | AddLiveIn(MF, Mips::GP, Mips::CPURegsRegisterClass); |
| 595 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 596 | // Assign locations to all of the incoming arguments. |
| 597 | SmallVector<CCValAssign, 16> ArgLocs; |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 598 | CCState CCInfo(CC, isVarArg, getTargetMachine(), ArgLocs); |
| 599 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 600 | CCInfo.AnalyzeFormalArguments(Op.Val, CC_Mips); |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 601 | SmallVector<SDOperand, 16> ArgValues; |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 602 | SDOperand StackPtr; |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 603 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 604 | unsigned FirstStackArgLoc = (Subtarget->isABI_EABI() ? 0 : 16); |
| 605 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 606 | for (unsigned i = 0, e = ArgLocs.size(); i != e; ++i) { |
| 607 | |
| 608 | CCValAssign &VA = ArgLocs[i]; |
| 609 | |
| 610 | // Arguments stored on registers |
| 611 | if (VA.isRegLoc()) { |
Duncan Sands | 83ec4b6 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 612 | MVT RegVT = VA.getLocVT(); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 613 | TargetRegisterClass *RC; |
| 614 | |
| 615 | if (RegVT == MVT::i32) |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 616 | RC = Mips::CPURegsRegisterClass; |
| 617 | else if (RegVT == MVT::f32) { |
| 618 | if (Subtarget->isSingleFloat()) |
| 619 | RC = Mips::FGR32RegisterClass; |
| 620 | else |
| 621 | RC = Mips::AFGR32RegisterClass; |
| 622 | } else if (RegVT == MVT::f64) { |
| 623 | if (!Subtarget->isSingleFloat()) |
| 624 | RC = Mips::AFGR64RegisterClass; |
| 625 | } else |
| 626 | assert(0 && "RegVT not supported by FORMAL_ARGUMENTS Lowering"); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 627 | |
| 628 | // Transform the arguments stored on |
| 629 | // physical registers into virtual ones |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 630 | unsigned Reg = AddLiveIn(DAG.getMachineFunction(), VA.getLocReg(), RC); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 631 | SDOperand ArgValue = DAG.getCopyFromReg(Root, Reg, RegVT); |
| 632 | |
| 633 | // If this is an 8 or 16-bit value, it is really passed promoted |
| 634 | // to 32 bits. Insert an assert[sz]ext to capture this, then |
| 635 | // truncate to the right size. |
| 636 | if (VA.getLocInfo() == CCValAssign::SExt) |
| 637 | ArgValue = DAG.getNode(ISD::AssertSext, RegVT, ArgValue, |
| 638 | DAG.getValueType(VA.getValVT())); |
| 639 | else if (VA.getLocInfo() == CCValAssign::ZExt) |
| 640 | ArgValue = DAG.getNode(ISD::AssertZext, RegVT, ArgValue, |
| 641 | DAG.getValueType(VA.getValVT())); |
| 642 | |
| 643 | if (VA.getLocInfo() != CCValAssign::Full) |
| 644 | ArgValue = DAG.getNode(ISD::TRUNCATE, VA.getValVT(), ArgValue); |
| 645 | |
| 646 | ArgValues.push_back(ArgValue); |
| 647 | |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 648 | // To meet ABI, when VARARGS are passed on registers, the registers |
Bruno Cardoso Lopes | a2b1bb5 | 2007-08-28 05:08:16 +0000 | [diff] [blame] | 649 | // must have their values written to the caller stack frame. |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 650 | if ((isVarArg) && (Subtarget->isABI_O32())) { |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 651 | if (StackPtr.Val == 0) |
| 652 | StackPtr = DAG.getRegister(StackReg, getPointerTy()); |
| 653 | |
Bruno Cardoso Lopes | a2b1bb5 | 2007-08-28 05:08:16 +0000 | [diff] [blame] | 654 | // The stack pointer offset is relative to the caller stack frame. |
| 655 | // Since the real stack size is unknown here, a negative SPOffset |
| 656 | // is used so there's a way to adjust these offsets when the stack |
| 657 | // size get known (on EliminateFrameIndex). A dummy SPOffset is |
| 658 | // used instead of a direct negative address (which is recorded to |
| 659 | // be used on emitPrologue) to avoid mis-calc of the first stack |
| 660 | // offset on PEI::calculateFrameObjectOffsets. |
| 661 | // Arguments are always 32-bit. |
| 662 | int FI = MFI->CreateFixedObject(4, 0); |
| 663 | MipsFI->recordStoreVarArgsFI(FI, -(4+(i*4))); |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 664 | SDOperand PtrOff = DAG.getFrameIndex(FI, getPointerTy()); |
| 665 | |
| 666 | // emit ISD::STORE whichs stores the |
| 667 | // parameter value to a stack Location |
| 668 | ArgValues.push_back(DAG.getStore(Root, ArgValue, PtrOff, NULL, 0)); |
| 669 | } |
| 670 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 671 | } else { // VA.isRegLoc() |
| 672 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 673 | // sanity check |
| 674 | assert(VA.isMemLoc()); |
| 675 | |
Bruno Cardoso Lopes | a2b1bb5 | 2007-08-28 05:08:16 +0000 | [diff] [blame] | 676 | // The stack pointer offset is relative to the caller stack frame. |
| 677 | // Since the real stack size is unknown here, a negative SPOffset |
| 678 | // is used so there's a way to adjust these offsets when the stack |
| 679 | // size get known (on EliminateFrameIndex). A dummy SPOffset is |
| 680 | // used instead of a direct negative address (which is recorded to |
| 681 | // be used on emitPrologue) to avoid mis-calc of the first stack |
| 682 | // offset on PEI::calculateFrameObjectOffsets. |
| 683 | // Arguments are always 32-bit. |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 684 | unsigned ArgSize = VA.getLocVT().getSizeInBits()/8; |
| 685 | int FI = MFI->CreateFixedObject(ArgSize, 0); |
| 686 | MipsFI->recordLoadArgsFI(FI, -(ArgSize+ |
| 687 | (FirstStackArgLoc + VA.getLocMemOffset()))); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 688 | |
| 689 | // Create load nodes to retrieve arguments from the stack |
| 690 | SDOperand FIN = DAG.getFrameIndex(FI, getPointerTy()); |
| 691 | ArgValues.push_back(DAG.getLoad(VA.getValVT(), Root, FIN, NULL, 0)); |
| 692 | } |
| 693 | } |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 694 | |
| 695 | // The mips ABIs for returning structs by value requires that we copy |
| 696 | // the sret argument into $v0 for the return. Save the argument into |
| 697 | // a virtual register so that we can access it from the return points. |
| 698 | if (DAG.getMachineFunction().getFunction()->hasStructRetAttr()) { |
| 699 | unsigned Reg = MipsFI->getSRetReturnReg(); |
| 700 | if (!Reg) { |
| 701 | Reg = MF.getRegInfo().createVirtualRegister(getRegClassFor(MVT::i32)); |
| 702 | MipsFI->setSRetReturnReg(Reg); |
| 703 | } |
| 704 | SDOperand Copy = DAG.getCopyToReg(DAG.getEntryNode(), Reg, ArgValues[0]); |
| 705 | Root = DAG.getNode(ISD::TokenFactor, MVT::Other, Copy, Root); |
| 706 | } |
| 707 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 708 | ArgValues.push_back(Root); |
| 709 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 710 | // Return the new list of results. |
Duncan Sands | f951620 | 2008-06-30 10:19:09 +0000 | [diff] [blame] | 711 | return DAG.getMergeValues(Op.Val->getVTList(), &ArgValues[0], |
| 712 | ArgValues.size()).getValue(Op.ResNo); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 713 | } |
| 714 | |
| 715 | //===----------------------------------------------------------------------===// |
| 716 | // Return Value Calling Convention Implementation |
| 717 | //===----------------------------------------------------------------------===// |
| 718 | |
| 719 | SDOperand MipsTargetLowering:: |
| 720 | LowerRET(SDOperand Op, SelectionDAG &DAG) |
| 721 | { |
| 722 | // CCValAssign - represent the assignment of |
| 723 | // the return value to a location |
| 724 | SmallVector<CCValAssign, 16> RVLocs; |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 725 | unsigned CC = DAG.getMachineFunction().getFunction()->getCallingConv(); |
| 726 | bool isVarArg = DAG.getMachineFunction().getFunction()->isVarArg(); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 727 | |
| 728 | // CCState - Info about the registers and stack slot. |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 729 | CCState CCInfo(CC, isVarArg, getTargetMachine(), RVLocs); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 730 | |
| 731 | // Analize return values of ISD::RET |
| 732 | CCInfo.AnalyzeReturn(Op.Val, RetCC_Mips); |
| 733 | |
| 734 | // If this is the first return lowered for this function, add |
| 735 | // the regs to the liveout set for the function. |
Chris Lattner | 84bc542 | 2007-12-31 04:13:23 +0000 | [diff] [blame] | 736 | if (DAG.getMachineFunction().getRegInfo().liveout_empty()) { |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 737 | for (unsigned i = 0; i != RVLocs.size(); ++i) |
Bruno Cardoso Lopes | 2ab22d1 | 2007-07-11 23:16:16 +0000 | [diff] [blame] | 738 | if (RVLocs[i].isRegLoc()) |
Chris Lattner | 84bc542 | 2007-12-31 04:13:23 +0000 | [diff] [blame] | 739 | DAG.getMachineFunction().getRegInfo().addLiveOut(RVLocs[i].getLocReg()); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 740 | } |
| 741 | |
| 742 | // The chain is always operand #0 |
| 743 | SDOperand Chain = Op.getOperand(0); |
| 744 | SDOperand Flag; |
| 745 | |
| 746 | // Copy the result values into the output registers. |
| 747 | for (unsigned i = 0; i != RVLocs.size(); ++i) { |
| 748 | CCValAssign &VA = RVLocs[i]; |
| 749 | assert(VA.isRegLoc() && "Can only return in registers!"); |
| 750 | |
| 751 | // ISD::RET => ret chain, (regnum1,val1), ... |
| 752 | // So i*2+1 index only the regnums |
Bruno Cardoso Lopes | 8262df3 | 2007-10-09 03:15:11 +0000 | [diff] [blame] | 753 | Chain = DAG.getCopyToReg(Chain, VA.getLocReg(), Op.getOperand(i*2+1), Flag); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 754 | |
| 755 | // guarantee that all emitted copies are |
| 756 | // stuck together, avoiding something bad |
| 757 | Flag = Chain.getValue(1); |
| 758 | } |
| 759 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 760 | // The mips ABIs for returning structs by value requires that we copy |
| 761 | // the sret argument into $v0 for the return. We saved the argument into |
| 762 | // a virtual register in the entry block, so now we copy the value out |
| 763 | // and into $v0. |
| 764 | if (DAG.getMachineFunction().getFunction()->hasStructRetAttr()) { |
| 765 | MachineFunction &MF = DAG.getMachineFunction(); |
| 766 | MipsFunctionInfo *MipsFI = MF.getInfo<MipsFunctionInfo>(); |
| 767 | unsigned Reg = MipsFI->getSRetReturnReg(); |
| 768 | |
| 769 | if (!Reg) |
| 770 | assert(0 && "sret virtual register not created in the entry block"); |
| 771 | SDOperand Val = DAG.getCopyFromReg(Chain, Reg, getPointerTy()); |
| 772 | |
| 773 | Chain = DAG.getCopyToReg(Chain, Mips::V0, Val, Flag); |
| 774 | Flag = Chain.getValue(1); |
| 775 | } |
| 776 | |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 777 | // Return on Mips is always a "jr $ra" |
| 778 | if (Flag.Val) |
| 779 | return DAG.getNode(MipsISD::Ret, MVT::Other, |
Bruno Cardoso Lopes | 8262df3 | 2007-10-09 03:15:11 +0000 | [diff] [blame] | 780 | Chain, DAG.getRegister(Mips::RA, MVT::i32), Flag); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 781 | else // Return Void |
| 782 | return DAG.getNode(MipsISD::Ret, MVT::Other, |
Bruno Cardoso Lopes | 8262df3 | 2007-10-09 03:15:11 +0000 | [diff] [blame] | 783 | Chain, DAG.getRegister(Mips::RA, MVT::i32)); |
Bruno Cardoso Lopes | 972f589 | 2007-06-06 07:42:06 +0000 | [diff] [blame] | 784 | } |
Bruno Cardoso Lopes | 84f47c5 | 2007-08-21 16:09:25 +0000 | [diff] [blame] | 785 | |
| 786 | //===----------------------------------------------------------------------===// |
| 787 | // Mips Inline Assembly Support |
| 788 | //===----------------------------------------------------------------------===// |
| 789 | |
| 790 | /// getConstraintType - Given a constraint letter, return the type of |
| 791 | /// constraint it is for this target. |
| 792 | MipsTargetLowering::ConstraintType MipsTargetLowering:: |
| 793 | getConstraintType(const std::string &Constraint) const |
| 794 | { |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 795 | // Mips specific constrainy |
| 796 | // GCC config/mips/constraints.md |
| 797 | // |
| 798 | // 'd' : An address register. Equivalent to r |
| 799 | // unless generating MIPS16 code. |
| 800 | // 'y' : Equivalent to r; retained for |
| 801 | // backwards compatibility. |
| 802 | // 'f' : Float Point registers. |
Bruno Cardoso Lopes | 84f47c5 | 2007-08-21 16:09:25 +0000 | [diff] [blame] | 803 | if (Constraint.size() == 1) { |
Bruno Cardoso Lopes | 84f47c5 | 2007-08-21 16:09:25 +0000 | [diff] [blame] | 804 | switch (Constraint[0]) { |
| 805 | default : break; |
| 806 | case 'd': |
| 807 | case 'y': |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 808 | case 'f': |
Bruno Cardoso Lopes | 84f47c5 | 2007-08-21 16:09:25 +0000 | [diff] [blame] | 809 | return C_RegisterClass; |
| 810 | break; |
| 811 | } |
| 812 | } |
| 813 | return TargetLowering::getConstraintType(Constraint); |
| 814 | } |
| 815 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 816 | /// getRegClassForInlineAsmConstraint - Given a constraint letter (e.g. "r"), |
| 817 | /// return a list of registers that can be used to satisfy the constraint. |
| 818 | /// This should only be used for C_RegisterClass constraints. |
Bruno Cardoso Lopes | 84f47c5 | 2007-08-21 16:09:25 +0000 | [diff] [blame] | 819 | std::pair<unsigned, const TargetRegisterClass*> MipsTargetLowering:: |
Duncan Sands | 83ec4b6 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 820 | getRegForInlineAsmConstraint(const std::string &Constraint, MVT VT) const |
Bruno Cardoso Lopes | 84f47c5 | 2007-08-21 16:09:25 +0000 | [diff] [blame] | 821 | { |
| 822 | if (Constraint.size() == 1) { |
| 823 | switch (Constraint[0]) { |
| 824 | case 'r': |
| 825 | return std::make_pair(0U, Mips::CPURegsRegisterClass); |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 826 | case 'f': |
| 827 | if (VT == MVT::f32) |
| 828 | if (Subtarget->isSingleFloat()) |
| 829 | return std::make_pair(0U, Mips::FGR32RegisterClass); |
| 830 | else |
| 831 | return std::make_pair(0U, Mips::AFGR32RegisterClass); |
| 832 | if (VT == MVT::f64) |
| 833 | if ((!Subtarget->isSingleFloat()) && (!Subtarget->isFP64bit())) |
| 834 | return std::make_pair(0U, Mips::AFGR64RegisterClass); |
Bruno Cardoso Lopes | 84f47c5 | 2007-08-21 16:09:25 +0000 | [diff] [blame] | 835 | } |
| 836 | } |
| 837 | return TargetLowering::getRegForInlineAsmConstraint(Constraint, VT); |
| 838 | } |
| 839 | |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 840 | /// Given a register class constraint, like 'r', if this corresponds directly |
| 841 | /// to an LLVM register class, return a register of 0 and the register class |
| 842 | /// pointer. |
Bruno Cardoso Lopes | 84f47c5 | 2007-08-21 16:09:25 +0000 | [diff] [blame] | 843 | std::vector<unsigned> MipsTargetLowering:: |
| 844 | getRegClassForInlineAsmConstraint(const std::string &Constraint, |
Duncan Sands | 83ec4b6 | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 845 | MVT VT) const |
Bruno Cardoso Lopes | 84f47c5 | 2007-08-21 16:09:25 +0000 | [diff] [blame] | 846 | { |
| 847 | if (Constraint.size() != 1) |
| 848 | return std::vector<unsigned>(); |
| 849 | |
| 850 | switch (Constraint[0]) { |
| 851 | default : break; |
| 852 | case 'r': |
| 853 | // GCC Mips Constraint Letters |
| 854 | case 'd': |
| 855 | case 'y': |
Bruno Cardoso Lopes | 225ca9c | 2008-07-05 19:05:21 +0000 | [diff] [blame] | 856 | return make_vector<unsigned>(Mips::T0, Mips::T1, Mips::T2, Mips::T3, |
| 857 | Mips::T4, Mips::T5, Mips::T6, Mips::T7, Mips::S0, Mips::S1, |
| 858 | Mips::S2, Mips::S3, Mips::S4, Mips::S5, Mips::S6, Mips::S7, |
| 859 | Mips::T8, 0); |
| 860 | |
| 861 | case 'f': |
| 862 | if (VT == MVT::f32) |
| 863 | if (Subtarget->isSingleFloat()) |
| 864 | return make_vector<unsigned>(Mips::F2, Mips::F3, Mips::F4, Mips::F5, |
| 865 | Mips::F6, Mips::F7, Mips::F8, Mips::F9, Mips::F10, Mips::F11, |
| 866 | Mips::F20, Mips::F21, Mips::F22, Mips::F23, Mips::F24, |
| 867 | Mips::F25, Mips::F26, Mips::F27, Mips::F28, Mips::F29, |
| 868 | Mips::F30, Mips::F31, 0); |
| 869 | else |
| 870 | return make_vector<unsigned>(Mips::F2, Mips::F4, Mips::F6, Mips::F8, |
| 871 | Mips::F10, Mips::F20, Mips::F22, Mips::F24, Mips::F26, |
| 872 | Mips::F28, Mips::F30, 0); |
| 873 | |
| 874 | if (VT == MVT::f64) |
| 875 | if ((!Subtarget->isSingleFloat()) && (!Subtarget->isFP64bit())) |
| 876 | return make_vector<unsigned>(Mips::D1, Mips::D2, Mips::D3, Mips::D4, |
| 877 | Mips::D5, Mips::D10, Mips::D11, Mips::D12, Mips::D13, |
| 878 | Mips::D14, Mips::D15, 0); |
Bruno Cardoso Lopes | 84f47c5 | 2007-08-21 16:09:25 +0000 | [diff] [blame] | 879 | } |
| 880 | return std::vector<unsigned>(); |
| 881 | } |