LLVM API Documentation
00001 //===- TableGen'erated file -------------------------------------*- C++ -*-===// 00002 // 00003 // DAG Instruction Selector for the ARM target 00004 // 00005 // Automatically generated file, do not edit! 00006 // 00007 //===----------------------------------------------------------------------===// 00008 00009 // *** NOTE: This file is #included into the middle of the target 00010 // *** instruction selector class. These functions are really methods. 00011 00012 #if defined(__GNUC__) && \ 00013 ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 4))) 00014 #define NOINLINE __attribute__((noinline)) 00015 #else 00016 00017 #define NOINLINE 00018 00019 #endif 00020 00021 // Instance var to keep track of multiply used nodes that have 00022 // already been selected. 00023 std::map<SDOperand, SDOperand> CodeGenMap; 00024 // Instance var to keep track of mapping of chain generating nodes 00025 // and their place handle nodes. 00026 std::map<SDOperand, SDOperand> HandleMap; 00027 // Instance var to keep track of mapping of place handle nodes 00028 // and their replacement nodes. 00029 std::map<SDOperand, SDOperand> ReplaceMap; 00030 // Keep track of nodes that are currently being selecte and therefore 00031 // should not be folded. 00032 std::set<SDNode*> InFlightSet; 00033 00034 static void findNonImmUse(SDNode* Use, SDNode* Def, bool &found, std::set<SDNode *> &Visited) { 00035 if (found || !Visited.insert(Use).second) return; 00036 for (unsigned i = 0, e = Use->getNumOperands(); i != e; ++i) { 00037 SDNode *N = Use->getOperand(i).Val; 00038 if (N != Def) { 00039 findNonImmUse(N, Def, found, Visited); 00040 } else { 00041 found = true; 00042 break; 00043 } 00044 } 00045 } 00046 00047 static bool isNonImmUse(SDNode* Use, SDNode* Def) { 00048 std::set<SDNode *> Visited; 00049 bool found = false; 00050 for (unsigned i = 0, e = Use->getNumOperands(); i != e; ++i) { 00051 SDNode *N = Use->getOperand(i).Val; 00052 if (N != Def) { 00053 findNonImmUse(N, Def, found, Visited); 00054 if (found) break; 00055 } 00056 } 00057 return found; 00058 } 00059 00060 // AddHandleReplacement - Note the pending replacement node for a 00061 // handle node in ReplaceMap. 00062 void AddHandleReplacement(SDNode *H, unsigned HNum, SDNode *R, unsigned RNum) { 00063 SDOperand N(H, HNum); 00064 std::map<SDOperand, SDOperand>::iterator HMI = HandleMap.find(N); 00065 if (HMI != HandleMap.end()) { 00066 ReplaceMap[HMI->second] = SDOperand(R, RNum); 00067 HandleMap.erase(N); 00068 } 00069 } 00070 00071 // SelectDanglingHandles - Select replacements for all `dangling` 00072 // handles.Some handles do not yet have replacements because the 00073 // nodes they replacements have only dead readers. 00074 void SelectDanglingHandles() { 00075 for (std::map<SDOperand, SDOperand>::iterator I = HandleMap.begin(), 00076 E = HandleMap.end(); I != E; ++I) { 00077 SDOperand N = I->first; 00078 SDOperand R; 00079 Select(R, N.getValue(0)); 00080 AddHandleReplacement(N.Val, N.ResNo, R.Val, R.ResNo); 00081 } 00082 } 00083 00084 // ReplaceHandles - Replace all the handles with the real target 00085 // specific nodes. 00086 void ReplaceHandles() { 00087 for (std::map<SDOperand, SDOperand>::iterator I = ReplaceMap.begin(), 00088 E = ReplaceMap.end(); I != E; ++I) { 00089 SDOperand From = I->first; 00090 SDOperand To = I->second; 00091 for (SDNode::use_iterator UI = From.Val->use_begin(), E = From.Val->use_end(); UI != E; ++UI) { 00092 SDNode *Use = *UI; 00093 std::vector<SDOperand> Ops; 00094 for (unsigned i = 0, e = Use->getNumOperands(); i != e; ++i){ 00095 SDOperand O = Use->getOperand(i); 00096 if (O.Val == From.Val) 00097 Ops.push_back(To); 00098 else 00099 Ops.push_back(O); 00100 } 00101 SDOperand U = SDOperand(Use, 0); 00102 CurDAG->UpdateNodeOperands(U, Ops); 00103 } 00104 } 00105 } 00106 00107 // SelectRoot - Top level entry to DAG isel. 00108 SDOperand SelectRoot(SDOperand N) { 00109 SDOperand ResNode; 00110 Select(ResNode, N); 00111 SelectDanglingHandles(); 00112 ReplaceHandles(); 00113 ReplaceMap.clear(); 00114 return ResNode; 00115 } 00116 00117 // Node transformations. 00118 00119 // Predicate functions. 00120 inline bool Predicate_immAllOnes(SDNode *inN) { 00121 ConstantSDNode *N = cast<ConstantSDNode>(inN); 00122 return N->isAllOnesValue(); 00123 } 00124 inline bool Predicate_immAllOnesV(SDNode *N) { 00125 00126 return ISD::isBuildVectorAllOnes(N); 00127 00128 } 00129 inline bool Predicate_immAllOnesV_bc(SDNode *N) { 00130 00131 return ISD::isBuildVectorAllOnes(N); 00132 00133 } 00134 inline bool Predicate_immAllZerosV(SDNode *N) { 00135 00136 return ISD::isBuildVectorAllZeros(N); 00137 00138 } 00139 inline bool Predicate_vtFP(SDNode *inN) { 00140 VTSDNode *N = cast<VTSDNode>(inN); 00141 return MVT::isFloatingPoint(N->getVT()); 00142 } 00143 inline bool Predicate_vtInt(SDNode *inN) { 00144 VTSDNode *N = cast<VTSDNode>(inN); 00145 return MVT::isInteger(N->getVT()); 00146 } 00147 00148 00149 void Emit_0(SDOperand &Result, SDOperand &N, unsigned Opc0, SDOperand &Chain, SDOperand &N1, bool HasInFlag) NOINLINE { 00150 SDOperand InFlag(0, 0); 00151 SDOperand Tmp0(0, 0); 00152 SDNode *ResNode = NULL; 00153 HasInFlag = (N.getOperand(N.getNumOperands()-1).getValueType() == MVT::Flag); 00154 std::vector<SDOperand> Ops; 00155 Tmp0 = N1; 00156 Select(Chain, Chain); 00157 if (HasInFlag) 00158 Select(InFlag, N.getOperand(N.getNumOperands()-1)); 00159 Ops.push_back(Tmp0); 00160 for (unsigned i = 2, e = N.getNumOperands()-(HasInFlag?1:0); i != e; ++i) { 00161 SDOperand VarOp(0, 0); 00162 Select(VarOp, N.getOperand(i)); 00163 Ops.push_back(VarOp); 00164 } 00165 Ops.push_back(Chain); 00166 if (HasInFlag) 00167 Ops.push_back(InFlag); 00168 ResNode = CurDAG->getTargetNode(Opc0, MVT::Other, MVT::Flag, Ops); 00169 Chain = SDOperand(ResNode, 0); 00170 InFlag = SDOperand(ResNode, 1); 00171 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, Chain.Val, Chain.ResNo); 00172 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, InFlag.Val, InFlag.ResNo); 00173 Result = SDOperand(ResNode, N.ResNo); 00174 return; 00175 } 00176 void Select_ARMcall(SDOperand &Result, SDOperand N) { 00177 SDOperand Chain(0, 0); 00178 SDOperand InFlag(0, 0); 00179 SDOperand N1(0, 0); 00180 SDOperand Tmp0(0, 0); 00181 SDNode *ResNode = NULL; 00182 bool HasInFlag = false; 00183 Chain = N.getOperand(0); 00184 N1 = N.getOperand(1); 00185 if (N1.getOpcode() == ISD::TargetGlobalAddress) { 00186 Emit_0(Result, N, ARM::bl, Chain, N1, HasInFlag); 00187 return; 00188 } 00189 std::cerr << "Cannot yet select: "; 00190 N.Val->dump(CurDAG); 00191 std::cerr << '\n'; 00192 abort(); 00193 } 00194 00195 void Emit_1(SDOperand &Result, SDOperand &N, unsigned Opc0, MVT::ValueType VT0, SDOperand &N0, SDOperand &N1) NOINLINE { 00196 SDOperand Tmp0(0, 0); 00197 SDOperand Tmp1(0, 0); 00198 SDNode *ResNode = NULL; 00199 SelectionDAG::InsertInFlightSetEntry(InFlightSet, N0.Val); 00200 Select(Tmp0, N0); 00201 Tmp1 = CurDAG->getTargetConstant(((unsigned) cast<ConstantSDNode>(N1)->getValue()), MVT::i32); 00202 SelectionDAG::RemoveInFlightSetEntry(InFlightSet, N0.Val); 00203 if (N.Val->hasOneUse()) { 00204 Result = CurDAG->SelectNodeTo(N.Val, Opc0, VT0, Tmp0, Tmp1); 00205 } else { 00206 ResNode = CurDAG->getTargetNode(Opc0, VT0, Tmp0, Tmp1); 00207 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0); 00208 Result = SDOperand(ResNode, 0); 00209 } 00210 return; 00211 } 00212 void Select_add(SDOperand &Result, SDOperand N) { 00213 SDOperand N0(0, 0); 00214 SDOperand N1(0, 0); 00215 SDOperand Tmp0(0, 0); 00216 SDOperand Tmp1(0, 0); 00217 SDNode *ResNode = NULL; 00218 N0 = N.getOperand(0); 00219 N1 = N.getOperand(1); 00220 if (N1.getOpcode() == ISD::Constant) { 00221 Emit_1(Result, N, ARM::addri, MVT::i32, N0, N1); 00222 return; 00223 } 00224 std::cerr << "Cannot yet select: "; 00225 N.Val->dump(CurDAG); 00226 std::cerr << '\n'; 00227 abort(); 00228 } 00229 00230 void Emit_2(SDOperand &Result, SDOperand &N, unsigned Opc0, SDOperand &Chain, SDOperand &N1) NOINLINE { 00231 SDOperand Tmp0(0, 0); 00232 SDNode *ResNode = NULL; 00233 SelectionDAG::InsertInFlightSetEntry(InFlightSet, N1.Val); 00234 Select(Tmp0, N1); 00235 Select(Chain, Chain); 00236 SelectionDAG::RemoveInFlightSetEntry(InFlightSet, N1.Val); 00237 ResNode = CurDAG->getTargetNode(Opc0, MVT::Other, Tmp0, Chain); 00238 Chain = SDOperand(ResNode, 0); 00239 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, Chain.Val, Chain.ResNo); 00240 Result = SDOperand(ResNode, N.ResNo); 00241 return; 00242 } 00243 void Select_brind(SDOperand &Result, SDOperand N) { 00244 SDOperand Chain(0, 0); 00245 SDOperand N1(0, 0); 00246 SDOperand Tmp0(0, 0); 00247 SDNode *ResNode = NULL; 00248 Chain = N.getOperand(0); 00249 N1 = N.getOperand(1); 00250 if (N1.Val->getValueType(0) == MVT::i32) { 00251 Emit_2(Result, N, ARM::bx, Chain, N1); 00252 return; 00253 } 00254 std::cerr << "Cannot yet select: "; 00255 N.Val->dump(CurDAG); 00256 std::cerr << '\n'; 00257 abort(); 00258 } 00259 00260 void Emit_3(SDOperand &Result, SDOperand &N, unsigned Opc0, SDOperand &Chain, SDOperand &N1) NOINLINE { 00261 SDOperand Tmp0(0, 0); 00262 SDNode *ResNode = NULL; 00263 Tmp0 = CurDAG->getTargetConstant(((unsigned) cast<ConstantSDNode>(N1)->getValue()), MVT::i32); 00264 Select(Chain, Chain); 00265 ResNode = CurDAG->getTargetNode(Opc0, MVT::Other, Tmp0, Chain); 00266 Chain = SDOperand(ResNode, 0); 00267 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, Chain.Val, Chain.ResNo); 00268 Result = SDOperand(ResNode, N.ResNo); 00269 return; 00270 } 00271 void Select_callseq_end(SDOperand &Result, SDOperand N) { 00272 SDOperand Chain(0, 0); 00273 SDOperand N1(0, 0); 00274 SDOperand Tmp0(0, 0); 00275 SDNode *ResNode = NULL; 00276 Chain = N.getOperand(0); 00277 N1 = N.getOperand(1); 00278 if (N1.getOpcode() == ISD::Constant) { 00279 Emit_3(Result, N, ARM::ADJCALLSTACKUP, Chain, N1); 00280 return; 00281 } 00282 std::cerr << "Cannot yet select: "; 00283 N.Val->dump(CurDAG); 00284 std::cerr << '\n'; 00285 abort(); 00286 } 00287 00288 void Select_callseq_start(SDOperand &Result, SDOperand N) { 00289 SDOperand Chain(0, 0); 00290 SDOperand N1(0, 0); 00291 SDOperand Tmp0(0, 0); 00292 SDNode *ResNode = NULL; 00293 Chain = N.getOperand(0); 00294 N1 = N.getOperand(1); 00295 if (N1.getOpcode() == ISD::Constant) { 00296 Emit_3(Result, N, ARM::ADJCALLSTACKDOWN, Chain, N1); 00297 return; 00298 } 00299 std::cerr << "Cannot yet select: "; 00300 N.Val->dump(CurDAG); 00301 std::cerr << '\n'; 00302 abort(); 00303 } 00304 00305 void Emit_4(SDOperand &Result, SDOperand &N, unsigned Opc0, MVT::ValueType VT0) NOINLINE { 00306 SDOperand Tmp0(0, 0); 00307 SDNode *ResNode = NULL; 00308 Tmp0 = CurDAG->getTargetConstant(((unsigned) cast<ConstantSDNode>(N)->getValue()), MVT::i32); 00309 if (N.Val->hasOneUse()) { 00310 Result = CurDAG->SelectNodeTo(N.Val, Opc0, VT0, Tmp0); 00311 } else { 00312 ResNode = CurDAG->getTargetNode(Opc0, VT0, Tmp0); 00313 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, ResNode, 0); 00314 Result = SDOperand(ResNode, 0); 00315 } 00316 return; 00317 } 00318 void Select_imm(SDOperand &Result, SDOperand N) { 00319 SDOperand Tmp0(0, 0); 00320 SDNode *ResNode = NULL; 00321 Emit_4(Result, N, ARM::movri, MVT::i32); 00322 return; 00323 } 00324 00325 void Emit_5(SDOperand &Result, SDOperand &N, unsigned Opc0, MVT::ValueType VT0, SDOperand &CPTmp0, SDOperand &CPTmp1, SDOperand &Chain, SDOperand &N1) NOINLINE { 00326 SDOperand Tmp0(0, 0); 00327 SDOperand Tmp1(0, 0); 00328 SDNode *ResNode = NULL; 00329 SelectionDAG::InsertInFlightSetEntry(InFlightSet, CPTmp0.Val); 00330 SelectionDAG::InsertInFlightSetEntry(InFlightSet, CPTmp1.Val); 00331 Select(Tmp0, CPTmp0); 00332 Select(Tmp1, CPTmp1); 00333 Select(Chain, Chain); 00334 SelectionDAG::RemoveInFlightSetEntry(InFlightSet, CPTmp0.Val); 00335 SelectionDAG::RemoveInFlightSetEntry(InFlightSet, CPTmp1.Val); 00336 ResNode = CurDAG->getTargetNode(Opc0, VT0, MVT::Other, Tmp0, Tmp1, Chain); 00337 Chain = SDOperand(ResNode, 1); 00338 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, ResNode, 0); 00339 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, Chain.Val, Chain.ResNo); 00340 if (N.ResNo == 0) AddHandleReplacement(N.Val, 1, Chain.Val, Chain.ResNo); 00341 Result = SDOperand(ResNode, N.ResNo); 00342 return; 00343 } 00344 void Select_load(SDOperand &Result, SDOperand N) { 00345 if (N.ResNo == 1 && N.getValue(0).hasOneUse()) { 00346 SDOperand Dummy = CurDAG->getNode(ISD::HANDLENODE, MVT::Other, N); 00347 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, Dummy.Val, 0); 00348 SelectionDAG::InsertISelMapEntry(HandleMap, N.Val, 1, Dummy.Val, 0); 00349 Result = Dummy; 00350 return; 00351 } 00352 SDOperand CPTmp0(0, 0); 00353 SDOperand CPTmp1(0, 0); 00354 SDOperand Chain(0, 0); 00355 SDOperand N1(0, 0); 00356 SDOperand Tmp0(0, 0); 00357 SDOperand Tmp1(0, 0); 00358 SDNode *ResNode = NULL; 00359 Chain = N.getOperand(0); 00360 N1 = N.getOperand(1); 00361 if (N.Val->getValueType(0) == MVT::i32) { 00362 bool Match = SelectAddrRegImm(N1, CPTmp0, CPTmp1); 00363 if (Match) { 00364 Emit_5(Result, N, ARM::ldr, MVT::i32, CPTmp0, CPTmp1, Chain, N1); 00365 return; 00366 } 00367 } 00368 std::cerr << "Cannot yet select: "; 00369 N.Val->dump(CurDAG); 00370 std::cerr << '\n'; 00371 abort(); 00372 } 00373 00374 void Emit_6(SDOperand &Result, SDOperand &N, unsigned Opc0, SDOperand &Chain, SDOperand &N1, SDOperand &N2) NOINLINE { 00375 SDOperand Tmp0(0, 0); 00376 SDOperand Tmp1(0, 0); 00377 SDNode *ResNode = NULL; 00378 SelectionDAG::InsertInFlightSetEntry(InFlightSet, N1.Val); 00379 SelectionDAG::InsertInFlightSetEntry(InFlightSet, N2.Val); 00380 Select(Tmp0, N1); 00381 Select(Tmp1, N2); 00382 Select(Chain, Chain); 00383 SelectionDAG::RemoveInFlightSetEntry(InFlightSet, N1.Val); 00384 SelectionDAG::RemoveInFlightSetEntry(InFlightSet, N2.Val); 00385 ResNode = CurDAG->getTargetNode(Opc0, MVT::Other, Tmp0, Tmp1, Chain); 00386 Chain = SDOperand(ResNode, 0); 00387 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, Chain.Val, Chain.ResNo); 00388 Result = SDOperand(ResNode, N.ResNo); 00389 return; 00390 } 00391 void Select_store(SDOperand &Result, SDOperand N) { 00392 SDOperand Chain(0, 0); 00393 SDOperand N1(0, 0); 00394 SDOperand N2(0, 0); 00395 SDOperand Tmp0(0, 0); 00396 SDOperand Tmp1(0, 0); 00397 SDNode *ResNode = NULL; 00398 Chain = N.getOperand(0); 00399 N1 = N.getOperand(1); 00400 N2 = N.getOperand(2); 00401 if (N1.Val->getValueType(0) == MVT::i32 && 00402 N2.Val->getValueType(0) == MVT::i32) { 00403 Emit_6(Result, N, ARM::str, Chain, N1, N2); 00404 return; 00405 } 00406 std::cerr << "Cannot yet select: "; 00407 N.Val->dump(CurDAG); 00408 std::cerr << '\n'; 00409 abort(); 00410 } 00411 00412 void Select_sub(SDOperand &Result, SDOperand N) { 00413 SDOperand N0(0, 0); 00414 SDOperand N1(0, 0); 00415 SDOperand Tmp0(0, 0); 00416 SDOperand Tmp1(0, 0); 00417 SDNode *ResNode = NULL; 00418 N0 = N.getOperand(0); 00419 N1 = N.getOperand(1); 00420 if (N1.getOpcode() == ISD::Constant) { 00421 Emit_1(Result, N, ARM::subri, MVT::i32, N0, N1); 00422 return; 00423 } 00424 std::cerr << "Cannot yet select: "; 00425 N.Val->dump(CurDAG); 00426 std::cerr << '\n'; 00427 abort(); 00428 } 00429 00430 void Select_INLINEASM(SDOperand& Result, SDOperand N) { 00431 std::vector<SDOperand> Ops(N.Val->op_begin(), N.Val->op_end()); 00432 Select(Ops[0], N.getOperand(0)); // Select the chain. 00433 00434 // Select the flag operand. 00435 if (Ops.back().getValueType() == MVT::Flag) 00436 Select(Ops.back(), Ops.back()); 00437 SelectInlineAsmMemoryOperands(Ops, *CurDAG); 00438 std::vector<MVT::ValueType> VTs; 00439 VTs.push_back(MVT::Other); 00440 VTs.push_back(MVT::Flag); 00441 SDOperand New = CurDAG->getNode(ISD::INLINEASM, VTs, Ops); 00442 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, New.Val, 0); 00443 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, New.Val, 1); 00444 Result = New.getValue(N.ResNo); 00445 return; 00446 } 00447 00448 // The main instruction selector code. 00449 void SelectCode(SDOperand &Result, SDOperand N) { 00450 if (N.getOpcode() >= ISD::BUILTIN_OP_END && 00451 N.getOpcode() < (ISD::BUILTIN_OP_END+ARM::INSTRUCTION_LIST_END)) { 00452 Result = N; 00453 return; // Already selected. 00454 } 00455 00456 std::map<SDOperand, SDOperand>::iterator CGMI = CodeGenMap.find(N); 00457 if (CGMI != CodeGenMap.end()) { 00458 Result = CGMI->second; 00459 return; 00460 } 00461 00462 switch (N.getOpcode()) { 00463 default: break; 00464 case ISD::EntryToken: // These leaves remain the same. 00465 case ISD::BasicBlock: 00466 case ISD::Register: 00467 case ISD::HANDLENODE: 00468 case ISD::TargetConstant: 00469 case ISD::TargetConstantPool: 00470 case ISD::TargetFrameIndex: 00471 case ISD::TargetJumpTable: 00472 case ISD::TargetGlobalAddress: { 00473 Result = N; 00474 return; 00475 } 00476 case ISD::AssertSext: 00477 case ISD::AssertZext: { 00478 SDOperand Tmp0; 00479 Select(Tmp0, N.getOperand(0)); 00480 if (!N.Val->hasOneUse()) 00481 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, Tmp0.Val, Tmp0.ResNo); 00482 Result = Tmp0; 00483 return; 00484 } 00485 case ISD::TokenFactor: 00486 if (N.getNumOperands() == 2) { 00487 SDOperand Op0, Op1; 00488 Select(Op0, N.getOperand(0)); 00489 Select(Op1, N.getOperand(1)); 00490 Result = 00491 CurDAG->getNode(ISD::TokenFactor, MVT::Other, Op0, Op1); 00492 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, Result.Val, Result.ResNo); 00493 } else { 00494 std::vector<SDOperand> Ops; 00495 for (unsigned i = 0, e = N.getNumOperands(); i != e; ++i) { 00496 SDOperand Val; 00497 Select(Val, N.getOperand(i)); 00498 Ops.push_back(Val); 00499 } 00500 Result = 00501 CurDAG->getNode(ISD::TokenFactor, MVT::Other, Ops); 00502 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, N.ResNo, Result.Val, Result.ResNo); 00503 } 00504 return; 00505 case ISD::CopyFromReg: { 00506 SDOperand Chain; 00507 Select(Chain, N.getOperand(0)); 00508 unsigned Reg = cast<RegisterSDNode>(N.getOperand(1))->getReg(); 00509 MVT::ValueType VT = N.Val->getValueType(0); 00510 if (N.Val->getNumValues() == 2) { 00511 if (Chain == N.getOperand(0)) { 00512 Result = N; // No change 00513 return; 00514 } 00515 SDOperand New = CurDAG->getCopyFromReg(Chain, Reg, VT); 00516 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, New.Val, 0); 00517 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, New.Val, 1); 00518 Result = New.getValue(N.ResNo); 00519 return; 00520 } else { 00521 SDOperand Flag; 00522 if (N.getNumOperands() == 3) Select(Flag, N.getOperand(2)); 00523 if (Chain == N.getOperand(0) && 00524 (N.getNumOperands() == 2 || Flag == N.getOperand(2))) { 00525 Result = N; // No change 00526 return; 00527 } 00528 SDOperand New = CurDAG->getCopyFromReg(Chain, Reg, VT, Flag); 00529 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, New.Val, 0); 00530 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, New.Val, 1); 00531 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 2, New.Val, 2); 00532 Result = New.getValue(N.ResNo); 00533 return; 00534 } 00535 } 00536 case ISD::CopyToReg: { 00537 SDOperand Chain; 00538 Select(Chain, N.getOperand(0)); 00539 unsigned Reg = cast<RegisterSDNode>(N.getOperand(1))->getReg(); 00540 SDOperand Val; 00541 Select(Val, N.getOperand(2)); 00542 Result = N; 00543 if (N.Val->getNumValues() == 1) { 00544 if (Chain != N.getOperand(0) || Val != N.getOperand(2)) 00545 Result = CurDAG->getCopyToReg(Chain, Reg, Val); 00546 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, Result.Val, 0); 00547 } else { 00548 SDOperand Flag(0, 0); 00549 if (N.getNumOperands() == 4) Select(Flag, N.getOperand(3)); 00550 if (Chain != N.getOperand(0) || Val != N.getOperand(2) || 00551 (N.getNumOperands() == 4 && Flag != N.getOperand(3))) 00552 Result = CurDAG->getCopyToReg(Chain, Reg, Val, Flag); 00553 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 0, Result.Val, 0); 00554 SelectionDAG::InsertISelMapEntry(CodeGenMap, N.Val, 1, Result.Val, 1); 00555 Result = Result.getValue(N.ResNo); 00556 } 00557 return; 00558 } 00559 case ISD::INLINEASM: Select_INLINEASM(Result, N); return; 00560 case ARMISD::CALL: Select_ARMcall(Result, N); return; 00561 case ISD::ADD: Select_add(Result, N); return; 00562 case ISD::BRIND: Select_brind(Result, N); return; 00563 case ISD::CALLSEQ_END: Select_callseq_end(Result, N); return; 00564 case ISD::CALLSEQ_START: Select_callseq_start(Result, N); return; 00565 case ISD::Constant: Select_imm(Result, N); return; 00566 case ISD::LOAD: Select_load(Result, N); return; 00567 case ISD::STORE: Select_store(Result, N); return; 00568 case ISD::SUB: Select_sub(Result, N); return; 00569 } // end of big switch. 00570 00571 std::cerr << "Cannot yet select: "; 00572 if (N.getOpcode() != ISD::INTRINSIC_W_CHAIN && 00573 N.getOpcode() != ISD::INTRINSIC_WO_CHAIN && 00574 N.getOpcode() != ISD::INTRINSIC_VOID) { 00575 N.Val->dump(CurDAG); 00576 } else { 00577 unsigned iid = cast<ConstantSDNode>(N.getOperand(N.getOperand(0).getValueType() == MVT::Other))->getValue(); 00578 std::cerr << "intrinsic %"<< Intrinsic::getName((Intrinsic::ID)iid); 00579 } 00580 std::cerr << '\n'; 00581 abort(); 00582 }