llvm.org GIT mirror llvm / 548f61d
Implement the constantexpr CAST instruction correctly git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5875 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 17 years ago
2 changed file(s) with 112 addition(s) and 90 deletion(s). Raw diff Collapse all Expand all
191191 Value *Src, User::op_iterator IdxBegin,
192192 User::op_iterator IdxEnd, unsigned TargetReg);
193193
194 /// emitCastOperation - Common code shared between visitCastInst and
195 /// constant expression cast support.
196 void emitCastOperation(MachineBasicBlock *BB,MachineBasicBlock::iterator&IP,
197 Value *Src, const Type *DestTy, unsigned TargetReg);
198
194199 /// copyConstantToRegister - Output the instructions required to put the
195200 /// specified constant into the specified register.
196201 ///
306311 emitGEPOperation(MBB, IP, CE->getOperand(0),
307312 CE->op_begin()+1, CE->op_end(), R);
308313 return;
309 } else if (CE->getOpcode() == Instruction::Cast &&
310 isa(CE->getType()) &&
311 isa(CE->getOperand(0)->getType())) {
312 copyConstantToRegister(MBB, IP, cast(CE->getOperand(0)), R);
314 } else if (CE->getOpcode() == Instruction::Cast) {
315 emitCastOperation(MBB, IP, CE->getOperand(0), CE->getType(), R);
313316 return;
314317 }
315318
445448 // Loop over all of the PHI nodes in the LLVM basic block...
446449 unsigned NumPHIs = 0;
447450 for (BasicBlock::const_iterator I = BB->begin();
448 PHINode *PN = (PHINode*)dyn_cast(&*I); ++I) {
451 PHINode *PN = (PHINode*)dyn_cast(I); ++I) {
449452
450453 // Create a new machine instr PHI node, and insert it.
451454 unsigned PHIReg = getReg(*PN);
13861389 /// visitCastInst - Here we have various kinds of copying with or without
13871390 /// sign extension going on.
13881391 void ISel::visitCastInst(CastInst &CI) {
1389 const Type *DestTy = CI.getType();
1390 Value *Src = CI.getOperand(0);
1392 unsigned DestReg = getReg(CI);
1393 MachineBasicBlock::iterator MI = BB->end();
1394 emitCastOperation(BB, MI, CI.getOperand(0), CI.getType(), DestReg);
1395 }
1396
1397 /// emitCastOperation - Common code shared between visitCastInst and
1398 /// constant expression cast support.
1399 void ISel::emitCastOperation(MachineBasicBlock *BB,
1400 MachineBasicBlock::iterator &IP,
1401 Value *Src, const Type *DestTy,
1402 unsigned DestReg) {
13911403 unsigned SrcReg = getReg(Src);
13921404 const Type *SrcTy = Src->getType();
13931405 unsigned SrcClass = getClassB(SrcTy);
1394 unsigned DestReg = getReg(CI);
13951406 unsigned DestClass = getClassB(DestTy);
13961407
13971408 // Implement casts to bool by using compare on the operand followed by set if
13981409 // not zero on the result.
13991410 if (DestTy == Type::BoolTy) {
14001411 if (SrcClass == cFP || SrcClass == cLong)
1401 visitInstruction(CI);
1412 abort(); // FIXME: implement cast (long & FP) to bool
14021413
1403 BuildMI(BB, X86::CMPri8, 2).addReg(SrcReg).addZImm(0);
1404 BuildMI(BB, X86::SETNEr, 1, DestReg);
1414 BMI(BB, IP, X86::CMPri8, 2).addReg(SrcReg).addZImm(0);
1415 BMI(BB, IP, X86::SETNEr, 1, DestReg);
14051416 return;
14061417 }
14071418
14131424 // getClass) by using a register-to-register move.
14141425 if (SrcClass == DestClass) {
14151426 if (SrcClass <= cInt || (SrcClass == cFP && SrcTy == DestTy)) {
1416 BuildMI(BB, RegRegMove[SrcClass], 1, DestReg).addReg(SrcReg);
1427 BMI(BB, IP, RegRegMove[SrcClass], 1, DestReg).addReg(SrcReg);
14171428 } else if (SrcClass == cFP) {
14181429 if (SrcTy == Type::FloatTy) { // double -> float
14191430 assert(DestTy == Type::DoubleTy && "Unknown cFP member!");
1420 BuildMI(BB, X86::FpMOV, 1, DestReg).addReg(SrcReg);
1431 BMI(BB, IP, X86::FpMOV, 1, DestReg).addReg(SrcReg);
14211432 } else { // float -> double
14221433 assert(SrcTy == Type::DoubleTy && DestTy == Type::FloatTy &&
14231434 "Unknown cFP member!");
14251436 // reading it back.
14261437 unsigned FltAlign = TM.getTargetData().getFloatAlignment();
14271438 int FrameIdx = F->getFrameInfo()->CreateStackObject(4, FltAlign);
1428 addFrameReference(BuildMI(BB, X86::FSTr32, 5), FrameIdx).addReg(SrcReg);
1429 addFrameReference(BuildMI(BB, X86::FLDr32, 5, DestReg), FrameIdx);
1439 addFrameReference(BMI(BB, IP, X86::FSTr32, 5), FrameIdx).addReg(SrcReg);
1440 addFrameReference(BMI(BB, IP, X86::FLDr32, 5, DestReg), FrameIdx);
14301441 }
14311442 } else if (SrcClass == cLong) {
1432 BuildMI(BB, X86::MOVrr32, 1, DestReg).addReg(SrcReg);
1433 BuildMI(BB, X86::MOVrr32, 1, DestReg+1).addReg(SrcReg+1);
1443 BMI(BB, IP, X86::MOVrr32, 1, DestReg).addReg(SrcReg);
1444 BMI(BB, IP, X86::MOVrr32, 1, DestReg+1).addReg(SrcReg+1);
14341445 } else {
1435 visitInstruction(CI);
1446 abort();
14361447 }
14371448 return;
14381449 }
14501461 };
14511462
14521463 bool isUnsigned = SrcTy->isUnsigned();
1453 BuildMI(BB, Opc[isUnsigned][SrcClass + DestClass - 1], 1,
1454 DestReg).addReg(SrcReg);
1464 BMI(BB, IP, Opc[isUnsigned][SrcClass + DestClass - 1], 1,
1465 DestReg).addReg(SrcReg);
14551466
14561467 if (isLong) { // Handle upper 32 bits as appropriate...
14571468 if (isUnsigned) // Zero out top bits...
1458 BuildMI(BB, X86::MOVir32, 1, DestReg+1).addZImm(0);
1469 BMI(BB, IP, X86::MOVir32, 1, DestReg+1).addZImm(0);
14591470 else // Sign extend bottom half...
1460 BuildMI(BB, X86::SARir32, 2, DestReg+1).addReg(DestReg).addZImm(31);
1471 BMI(BB, IP, X86::SARir32, 2, DestReg+1).addReg(DestReg).addZImm(31);
14611472 }
14621473 return;
14631474 }
14641475
14651476 // Special case long -> int ...
14661477 if (SrcClass == cLong && DestClass == cInt) {
1467 BuildMI(BB, X86::MOVrr32, 1, DestReg).addReg(SrcReg);
1478 BMI(BB, IP, X86::MOVrr32, 1, DestReg).addReg(SrcReg);
14681479 return;
14691480 }
14701481
14731484 if ((SrcClass <= cInt || SrcClass == cLong) && DestClass <= cInt
14741485 && SrcClass > DestClass) {
14751486 static const unsigned AReg[] = { X86::AL, X86::AX, X86::EAX, 0, X86::EAX };
1476 BuildMI(BB, RegRegMove[SrcClass], 1, AReg[SrcClass]).addReg(SrcReg);
1477 BuildMI(BB, RegRegMove[DestClass], 1, DestReg).addReg(AReg[DestClass]);
1487 BMI(BB, IP, RegRegMove[SrcClass], 1, AReg[SrcClass]).addReg(SrcReg);
1488 BMI(BB, IP, RegRegMove[DestClass], 1, DestReg).addReg(AReg[DestClass]);
14781489 return;
14791490 }
14801491
14831494 // unsigned int -> load as 64 bit int.
14841495 // unsigned long long -> more complex
14851496 if (SrcTy->isUnsigned() && SrcTy != Type::UByteTy)
1486 visitInstruction(CI); // don't handle unsigned src yet!
1497 abort(); // don't handle unsigned src yet!
14871498
14881499 // We don't have the facilities for directly loading byte sized data from
14891500 // memory. Promote it to 16 bits.
14901501 if (SrcClass == cByte) {
14911502 unsigned TmpReg = makeAnotherReg(Type::ShortTy);
1492 BuildMI(BB, SrcTy->isSigned() ? X86::MOVSXr16r8 : X86::MOVZXr16r8,
1493 1, TmpReg).addReg(SrcReg);
1503 BMI(BB, IP, SrcTy->isSigned() ? X86::MOVSXr16r8 : X86::MOVZXr16r8,
1504 1, TmpReg).addReg(SrcReg);
14941505 SrcTy = Type::ShortTy; // Pretend the short is our input now!
14951506 SrcClass = cShort;
14961507 SrcReg = TmpReg;
15011512 F->getFrameInfo()->CreateStackObject(SrcTy, TM.getTargetData());
15021513
15031514 if (SrcClass == cLong) {
1504 if (SrcTy == Type::ULongTy) visitInstruction(CI);
1505 addFrameReference(BuildMI(BB, X86::MOVrm32, 5), FrameIdx).addReg(SrcReg);
1506 addFrameReference(BuildMI(BB, X86::MOVrm32, 5),
1515 if (SrcTy == Type::ULongTy) abort(); // FIXME: Handle ulong -> FP
1516 addFrameReference(BMI(BB, IP, X86::MOVrm32, 5), FrameIdx).addReg(SrcReg);
1517 addFrameReference(BMI(BB, IP, X86::MOVrm32, 5),
15071518 FrameIdx, 4).addReg(SrcReg+1);
15081519 } else {
15091520 static const unsigned Op1[] = { X86::MOVrm8, X86::MOVrm16, X86::MOVrm32 };
1510 addFrameReference(BuildMI(BB, Op1[SrcClass], 5), FrameIdx).addReg(SrcReg);
1521 addFrameReference(BMI(BB, IP, Op1[SrcClass], 5), FrameIdx).addReg(SrcReg);
15111522 }
15121523
15131524 static const unsigned Op2[] =
15141525 { 0, X86::FILDr16, X86::FILDr32, 0, X86::FILDr64 };
1515 addFrameReference(BuildMI(BB, Op2[SrcClass], 5, DestReg), FrameIdx);
1526 addFrameReference(BMI(BB, IP, Op2[SrcClass], 5, DestReg), FrameIdx);
15161527 return;
15171528 }
15181529
15221533 // mode when truncating to an integer value.
15231534 //
15241535 int CWFrameIdx = F->getFrameInfo()->CreateStackObject(2, 2);
1525 addFrameReference(BuildMI(BB, X86::FNSTCWm16, 4), CWFrameIdx);
1536 addFrameReference(BMI(BB, IP, X86::FNSTCWm16, 4), CWFrameIdx);
15261537
15271538 // Load the old value of the high byte of the control word...
15281539 unsigned HighPartOfCW = makeAnotherReg(Type::UByteTy);
1529 addFrameReference(BuildMI(BB, X86::MOVmr8, 4, HighPartOfCW), CWFrameIdx, 1);
1540 addFrameReference(BMI(BB, IP, X86::MOVmr8, 4, HighPartOfCW), CWFrameIdx, 1);
15301541
15311542 // Set the high part to be round to zero...
1532 addFrameReference(BuildMI(BB, X86::MOVim8, 5), CWFrameIdx, 1).addZImm(12);
1543 addFrameReference(BMI(BB, IP, X86::MOVim8, 5), CWFrameIdx, 1).addZImm(12);
15331544
15341545 // Reload the modified control word now...
1535 addFrameReference(BuildMI(BB, X86::FLDCWm16, 4), CWFrameIdx);
1546 addFrameReference(BMI(BB, IP, X86::FLDCWm16, 4), CWFrameIdx);
15361547
15371548 // Restore the memory image of control word to original value
1538 addFrameReference(BuildMI(BB, X86::MOVrm8, 5),
1549 addFrameReference(BMI(BB, IP, X86::MOVrm8, 5),
15391550 CWFrameIdx, 1).addReg(HighPartOfCW);
15401551
15411552 // We don't have the facilities for directly storing byte sized data to
15481559 case cByte: StoreTy = Type::ShortTy; StoreClass = cShort; break;
15491560 case cShort: StoreTy = Type::IntTy; StoreClass = cInt; break;
15501561 case cInt: StoreTy = Type::LongTy; StoreClass = cLong; break;
1551 case cLong: visitInstruction(CI); // unsigned long long -> more complex
1562 case cLong: abort(); // FIXME: unsigned long long -> more complex
15521563 default: assert(0 && "Unknown store class!");
15531564 }
15541565
15581569
15591570 static const unsigned Op1[] =
15601571 { 0, X86::FISTr16, X86::FISTr32, 0, X86::FISTPr64 };
1561 addFrameReference(BuildMI(BB, Op1[StoreClass], 5), FrameIdx).addReg(SrcReg);
1572 addFrameReference(BMI(BB, IP, Op1[StoreClass], 5), FrameIdx).addReg(SrcReg);
15621573
15631574 if (DestClass == cLong) {
1564 addFrameReference(BuildMI(BB, X86::MOVmr32, 4, DestReg), FrameIdx);
1565 addFrameReference(BuildMI(BB, X86::MOVmr32, 4, DestReg+1), FrameIdx, 4);
1575 addFrameReference(BMI(BB, IP, X86::MOVmr32, 4, DestReg), FrameIdx);
1576 addFrameReference(BMI(BB, IP, X86::MOVmr32, 4, DestReg+1), FrameIdx, 4);
15661577 } else {
15671578 static const unsigned Op2[] = { X86::MOVmr8, X86::MOVmr16, X86::MOVmr32 };
1568 addFrameReference(BuildMI(BB, Op2[DestClass], 4, DestReg), FrameIdx);
1579 addFrameReference(BMI(BB, IP, Op2[DestClass], 4, DestReg), FrameIdx);
15691580 }
15701581
15711582 // Reload the original control word now...
1572 addFrameReference(BuildMI(BB, X86::FLDCWm16, 4), CWFrameIdx);
1583 addFrameReference(BMI(BB, IP, X86::FLDCWm16, 4), CWFrameIdx);
15731584 return;
15741585 }
15751586
15761587 // Anything we haven't handled already, we can't (yet) handle at all.
1577 visitInstruction (CI);
1588 abort();
15781589 }
15791590
15801591 // ExactLog2 - This function solves for (Val == 1 << (N-1)) and returns N. It
191191 Value *Src, User::op_iterator IdxBegin,
192192 User::op_iterator IdxEnd, unsigned TargetReg);
193193
194 /// emitCastOperation - Common code shared between visitCastInst and
195 /// constant expression cast support.
196 void emitCastOperation(MachineBasicBlock *BB,MachineBasicBlock::iterator&IP,
197 Value *Src, const Type *DestTy, unsigned TargetReg);
198
194199 /// copyConstantToRegister - Output the instructions required to put the
195200 /// specified constant into the specified register.
196201 ///
306311 emitGEPOperation(MBB, IP, CE->getOperand(0),
307312 CE->op_begin()+1, CE->op_end(), R);
308313 return;
309 } else if (CE->getOpcode() == Instruction::Cast &&
310 isa(CE->getType()) &&
311 isa(CE->getOperand(0)->getType())) {
312 copyConstantToRegister(MBB, IP, cast(CE->getOperand(0)), R);
314 } else if (CE->getOpcode() == Instruction::Cast) {
315 emitCastOperation(MBB, IP, CE->getOperand(0), CE->getType(), R);
313316 return;
314317 }
315318
445448 // Loop over all of the PHI nodes in the LLVM basic block...
446449 unsigned NumPHIs = 0;
447450 for (BasicBlock::const_iterator I = BB->begin();
448 PHINode *PN = (PHINode*)dyn_cast(&*I); ++I) {
451 PHINode *PN = (PHINode*)dyn_cast(I); ++I) {
449452
450453 // Create a new machine instr PHI node, and insert it.
451454 unsigned PHIReg = getReg(*PN);
13861389 /// visitCastInst - Here we have various kinds of copying with or without
13871390 /// sign extension going on.
13881391 void ISel::visitCastInst(CastInst &CI) {
1389 const Type *DestTy = CI.getType();
1390 Value *Src = CI.getOperand(0);
1392 unsigned DestReg = getReg(CI);
1393 MachineBasicBlock::iterator MI = BB->end();
1394 emitCastOperation(BB, MI, CI.getOperand(0), CI.getType(), DestReg);
1395 }
1396
1397 /// emitCastOperation - Common code shared between visitCastInst and
1398 /// constant expression cast support.
1399 void ISel::emitCastOperation(MachineBasicBlock *BB,
1400 MachineBasicBlock::iterator &IP,
1401 Value *Src, const Type *DestTy,
1402 unsigned DestReg) {
13911403 unsigned SrcReg = getReg(Src);
13921404 const Type *SrcTy = Src->getType();
13931405 unsigned SrcClass = getClassB(SrcTy);
1394 unsigned DestReg = getReg(CI);
13951406 unsigned DestClass = getClassB(DestTy);
13961407
13971408 // Implement casts to bool by using compare on the operand followed by set if
13981409 // not zero on the result.
13991410 if (DestTy == Type::BoolTy) {
14001411 if (SrcClass == cFP || SrcClass == cLong)
1401 visitInstruction(CI);
1412 abort(); // FIXME: implement cast (long & FP) to bool
14021413
1403 BuildMI(BB, X86::CMPri8, 2).addReg(SrcReg).addZImm(0);
1404 BuildMI(BB, X86::SETNEr, 1, DestReg);
1414 BMI(BB, IP, X86::CMPri8, 2).addReg(SrcReg).addZImm(0);
1415 BMI(BB, IP, X86::SETNEr, 1, DestReg);
14051416 return;
14061417 }
14071418
14131424 // getClass) by using a register-to-register move.
14141425 if (SrcClass == DestClass) {
14151426 if (SrcClass <= cInt || (SrcClass == cFP && SrcTy == DestTy)) {
1416 BuildMI(BB, RegRegMove[SrcClass], 1, DestReg).addReg(SrcReg);
1427 BMI(BB, IP, RegRegMove[SrcClass], 1, DestReg).addReg(SrcReg);
14171428 } else if (SrcClass == cFP) {
14181429 if (SrcTy == Type::FloatTy) { // double -> float
14191430 assert(DestTy == Type::DoubleTy && "Unknown cFP member!");
1420 BuildMI(BB, X86::FpMOV, 1, DestReg).addReg(SrcReg);
1431 BMI(BB, IP, X86::FpMOV, 1, DestReg).addReg(SrcReg);
14211432 } else { // float -> double
14221433 assert(SrcTy == Type::DoubleTy && DestTy == Type::FloatTy &&
14231434 "Unknown cFP member!");
14251436 // reading it back.
14261437 unsigned FltAlign = TM.getTargetData().getFloatAlignment();
14271438 int FrameIdx = F->getFrameInfo()->CreateStackObject(4, FltAlign);
1428 addFrameReference(BuildMI(BB, X86::FSTr32, 5), FrameIdx).addReg(SrcReg);
1429 addFrameReference(BuildMI(BB, X86::FLDr32, 5, DestReg), FrameIdx);
1439 addFrameReference(BMI(BB, IP, X86::FSTr32, 5), FrameIdx).addReg(SrcReg);
1440 addFrameReference(BMI(BB, IP, X86::FLDr32, 5, DestReg), FrameIdx);
14301441 }
14311442 } else if (SrcClass == cLong) {
1432 BuildMI(BB, X86::MOVrr32, 1, DestReg).addReg(SrcReg);
1433 BuildMI(BB, X86::MOVrr32, 1, DestReg+1).addReg(SrcReg+1);
1443 BMI(BB, IP, X86::MOVrr32, 1, DestReg).addReg(SrcReg);
1444 BMI(BB, IP, X86::MOVrr32, 1, DestReg+1).addReg(SrcReg+1);
14341445 } else {
1435 visitInstruction(CI);
1446 abort();
14361447 }
14371448 return;
14381449 }
14501461 };
14511462
14521463 bool isUnsigned = SrcTy->isUnsigned();
1453 BuildMI(BB, Opc[isUnsigned][SrcClass + DestClass - 1], 1,
1454 DestReg).addReg(SrcReg);
1464 BMI(BB, IP, Opc[isUnsigned][SrcClass + DestClass - 1], 1,
1465 DestReg).addReg(SrcReg);
14551466
14561467 if (isLong) { // Handle upper 32 bits as appropriate...
14571468 if (isUnsigned) // Zero out top bits...
1458 BuildMI(BB, X86::MOVir32, 1, DestReg+1).addZImm(0);
1469 BMI(BB, IP, X86::MOVir32, 1, DestReg+1).addZImm(0);
14591470 else // Sign extend bottom half...
1460 BuildMI(BB, X86::SARir32, 2, DestReg+1).addReg(DestReg).addZImm(31);
1471 BMI(BB, IP, X86::SARir32, 2, DestReg+1).addReg(DestReg).addZImm(31);
14611472 }
14621473 return;
14631474 }
14641475
14651476 // Special case long -> int ...
14661477 if (SrcClass == cLong && DestClass == cInt) {
1467 BuildMI(BB, X86::MOVrr32, 1, DestReg).addReg(SrcReg);
1478 BMI(BB, IP, X86::MOVrr32, 1, DestReg).addReg(SrcReg);
14681479 return;
14691480 }
14701481
14731484 if ((SrcClass <= cInt || SrcClass == cLong) && DestClass <= cInt
14741485 && SrcClass > DestClass) {
14751486 static const unsigned AReg[] = { X86::AL, X86::AX, X86::EAX, 0, X86::EAX };
1476 BuildMI(BB, RegRegMove[SrcClass], 1, AReg[SrcClass]).addReg(SrcReg);
1477 BuildMI(BB, RegRegMove[DestClass], 1, DestReg).addReg(AReg[DestClass]);
1487 BMI(BB, IP, RegRegMove[SrcClass], 1, AReg[SrcClass]).addReg(SrcReg);
1488 BMI(BB, IP, RegRegMove[DestClass], 1, DestReg).addReg(AReg[DestClass]);
14781489 return;
14791490 }
14801491
14831494 // unsigned int -> load as 64 bit int.
14841495 // unsigned long long -> more complex
14851496 if (SrcTy->isUnsigned() && SrcTy != Type::UByteTy)
1486 visitInstruction(CI); // don't handle unsigned src yet!
1497 abort(); // don't handle unsigned src yet!
14871498
14881499 // We don't have the facilities for directly loading byte sized data from
14891500 // memory. Promote it to 16 bits.
14901501 if (SrcClass == cByte) {
14911502 unsigned TmpReg = makeAnotherReg(Type::ShortTy);
1492 BuildMI(BB, SrcTy->isSigned() ? X86::MOVSXr16r8 : X86::MOVZXr16r8,
1493 1, TmpReg).addReg(SrcReg);
1503 BMI(BB, IP, SrcTy->isSigned() ? X86::MOVSXr16r8 : X86::MOVZXr16r8,
1504 1, TmpReg).addReg(SrcReg);
14941505 SrcTy = Type::ShortTy; // Pretend the short is our input now!
14951506 SrcClass = cShort;
14961507 SrcReg = TmpReg;
15011512 F->getFrameInfo()->CreateStackObject(SrcTy, TM.getTargetData());
15021513
15031514 if (SrcClass == cLong) {
1504 if (SrcTy == Type::ULongTy) visitInstruction(CI);
1505 addFrameReference(BuildMI(BB, X86::MOVrm32, 5), FrameIdx).addReg(SrcReg);
1506 addFrameReference(BuildMI(BB, X86::MOVrm32, 5),
1515 if (SrcTy == Type::ULongTy) abort(); // FIXME: Handle ulong -> FP
1516 addFrameReference(BMI(BB, IP, X86::MOVrm32, 5), FrameIdx).addReg(SrcReg);
1517 addFrameReference(BMI(BB, IP, X86::MOVrm32, 5),
15071518 FrameIdx, 4).addReg(SrcReg+1);
15081519 } else {
15091520 static const unsigned Op1[] = { X86::MOVrm8, X86::MOVrm16, X86::MOVrm32 };
1510 addFrameReference(BuildMI(BB, Op1[SrcClass], 5), FrameIdx).addReg(SrcReg);
1521 addFrameReference(BMI(BB, IP, Op1[SrcClass], 5), FrameIdx).addReg(SrcReg);
15111522 }
15121523
15131524 static const unsigned Op2[] =
15141525 { 0, X86::FILDr16, X86::FILDr32, 0, X86::FILDr64 };
1515 addFrameReference(BuildMI(BB, Op2[SrcClass], 5, DestReg), FrameIdx);
1526 addFrameReference(BMI(BB, IP, Op2[SrcClass], 5, DestReg), FrameIdx);
15161527 return;
15171528 }
15181529
15221533 // mode when truncating to an integer value.
15231534 //
15241535 int CWFrameIdx = F->getFrameInfo()->CreateStackObject(2, 2);
1525 addFrameReference(BuildMI(BB, X86::FNSTCWm16, 4), CWFrameIdx);
1536 addFrameReference(BMI(BB, IP, X86::FNSTCWm16, 4), CWFrameIdx);
15261537
15271538 // Load the old value of the high byte of the control word...
15281539 unsigned HighPartOfCW = makeAnotherReg(Type::UByteTy);
1529 addFrameReference(BuildMI(BB, X86::MOVmr8, 4, HighPartOfCW), CWFrameIdx, 1);
1540 addFrameReference(BMI(BB, IP, X86::MOVmr8, 4, HighPartOfCW), CWFrameIdx, 1);
15301541
15311542 // Set the high part to be round to zero...
1532 addFrameReference(BuildMI(BB, X86::MOVim8, 5), CWFrameIdx, 1).addZImm(12);
1543 addFrameReference(BMI(BB, IP, X86::MOVim8, 5), CWFrameIdx, 1).addZImm(12);
15331544
15341545 // Reload the modified control word now...
1535 addFrameReference(BuildMI(BB, X86::FLDCWm16, 4), CWFrameIdx);
1546 addFrameReference(BMI(BB, IP, X86::FLDCWm16, 4), CWFrameIdx);
15361547
15371548 // Restore the memory image of control word to original value
1538 addFrameReference(BuildMI(BB, X86::MOVrm8, 5),
1549 addFrameReference(BMI(BB, IP, X86::MOVrm8, 5),
15391550 CWFrameIdx, 1).addReg(HighPartOfCW);
15401551
15411552 // We don't have the facilities for directly storing byte sized data to
15481559 case cByte: StoreTy = Type::ShortTy; StoreClass = cShort; break;
15491560 case cShort: StoreTy = Type::IntTy; StoreClass = cInt; break;
15501561 case cInt: StoreTy = Type::LongTy; StoreClass = cLong; break;
1551 case cLong: visitInstruction(CI); // unsigned long long -> more complex
1562 case cLong: abort(); // FIXME: unsigned long long -> more complex
15521563 default: assert(0 && "Unknown store class!");
15531564 }
15541565
15581569
15591570 static const unsigned Op1[] =
15601571 { 0, X86::FISTr16, X86::FISTr32, 0, X86::FISTPr64 };
1561 addFrameReference(BuildMI(BB, Op1[StoreClass], 5), FrameIdx).addReg(SrcReg);
1572 addFrameReference(BMI(BB, IP, Op1[StoreClass], 5), FrameIdx).addReg(SrcReg);
15621573
15631574 if (DestClass == cLong) {
1564 addFrameReference(BuildMI(BB, X86::MOVmr32, 4, DestReg), FrameIdx);
1565 addFrameReference(BuildMI(BB, X86::MOVmr32, 4, DestReg+1), FrameIdx, 4);
1575 addFrameReference(BMI(BB, IP, X86::MOVmr32, 4, DestReg), FrameIdx);
1576 addFrameReference(BMI(BB, IP, X86::MOVmr32, 4, DestReg+1), FrameIdx, 4);
15661577 } else {
15671578 static const unsigned Op2[] = { X86::MOVmr8, X86::MOVmr16, X86::MOVmr32 };
1568 addFrameReference(BuildMI(BB, Op2[DestClass], 4, DestReg), FrameIdx);
1579 addFrameReference(BMI(BB, IP, Op2[DestClass], 4, DestReg), FrameIdx);
15691580 }
15701581
15711582 // Reload the original control word now...
1572 addFrameReference(BuildMI(BB, X86::FLDCWm16, 4), CWFrameIdx);
1583 addFrameReference(BMI(BB, IP, X86::FLDCWm16, 4), CWFrameIdx);
15731584 return;
15741585 }
15751586
15761587 // Anything we haven't handled already, we can't (yet) handle at all.
1577 visitInstruction (CI);
1588 abort();
15781589 }
15791590
15801591 // ExactLog2 - This function solves for (Val == 1 << (N-1)) and returns N. It