llvm.org GIT mirror llvm / 8aa797a
Add new shorter predicates for testing machine operands for various types: e.g. MO.isMBB() instead of MO.isMachineBasicBlock(). I don't plan on switching everything over, so new clients should just start using the shorter names. Remove old long accessors, switching everything over to use the short accessor: getMachineBasicBlock() -> getMBB(), getConstantPoolIndex() -> getIndex(), setMachineBasicBlock -> setMBB(), etc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45464 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
40 changed file(s) with 186 addition(s) and 193 deletion(s). Raw diff Collapse all Expand all
121121 bool isGlobalAddress() const { return OpKind == MO_GlobalAddress; }
122122 bool isExternalSymbol() const { return OpKind == MO_ExternalSymbol; }
123123
124 bool isReg() const { return OpKind == MO_Register; }
125 bool isImm() const { return OpKind == MO_Immediate; }
126 bool isMBB() const { return OpKind == MO_MachineBasicBlock; }
127 bool isFI() const { return OpKind == MO_FrameIndex; }
128 bool isCPI() const { return OpKind == MO_ConstantPoolIndex; }
129 bool isJTI() const { return OpKind == MO_JumpTableIndex; }
130 bool isGlobal() const { return OpKind == MO_GlobalAddress; }
131 bool isSymbol() const { return OpKind == MO_ExternalSymbol; }
132
124133 //===--------------------------------------------------------------------===//
125134 // Accessors for Register Operands
126135 //===--------------------------------------------------------------------===//
214223 assert(isMachineBasicBlock() && "Wrong MachineOperand accessor");
215224 return Contents.MBB;
216225 }
217 MachineBasicBlock *getMachineBasicBlock() const {
218 assert(isMachineBasicBlock() && "Wrong MachineOperand accessor");
219 return Contents.MBB;
220 }
221226
222227 int getIndex() const {
223228 assert((isFrameIndex() || isConstantPoolIndex() || isJumpTableIndex()) &&
225230 return Contents.OffsetedInfo.Val.Index;
226231 }
227232
228 int getFrameIndex() const { return getIndex(); }
229 unsigned getConstantPoolIndex() const { return getIndex(); }
230 unsigned getJumpTableIndex() const { return getIndex(); }
231
232233 GlobalValue *getGlobal() const {
233234 assert(isGlobalAddress() && "Wrong MachineOperand accessor");
234235 return Contents.OffsetedInfo.Val.GV;
235236 }
237
236238 int getOffset() const {
237239 assert((isGlobalAddress() || isExternalSymbol() || isConstantPoolIndex()) &&
238240 "Wrong MachineOperand accessor");
239241 return Contents.OffsetedInfo.Offset;
240242 }
243
241244 const char *getSymbolName() const {
242245 assert(isExternalSymbol() && "Wrong MachineOperand accessor");
243246 return Contents.OffsetedInfo.Val.SymbolName;
264267 Contents.OffsetedInfo.Val.Index = Idx;
265268 }
266269
267 void setConstantPoolIndex(unsigned Idx) { setIndex(Idx); }
268 void setJumpTableIndex(unsigned Idx) { setIndex(Idx); }
269
270 void setMachineBasicBlock(MachineBasicBlock *MBB) {
270 void setMBB(MachineBasicBlock *MBB) {
271271 assert(isMachineBasicBlock() && "Wrong MachineOperand accessor");
272272 Contents.MBB = MBB;
273273 }
326326 }
327327 static MachineOperand CreateMBB(MachineBasicBlock *MBB) {
328328 MachineOperand Op(MachineOperand::MO_MachineBasicBlock);
329 Op.setMachineBasicBlock(MBB);
329 Op.setMBB(MBB);
330330 return Op;
331331 }
332332 static MachineOperand CreateFI(unsigned Idx) {
12251225 ++OpNo; // Skip over the ID number.
12261226
12271227 if (Modifier[0]=='l') // labels are target independent
1228 printBasicBlockLabel(MI->getOperand(OpNo).getMachineBasicBlock(),
1228 printBasicBlockLabel(MI->getOperand(OpNo).getMBB(),
12291229 false, false);
12301230 else {
12311231 AsmPrinter *AP = const_cast(this);
171171 for (unsigned op = 0, e = I->getNumOperands(); op != e; ++op) {
172172 MachineOperand &Op = I->getOperand(op);
173173 if (!Op.isJumpTableIndex()) continue;
174 unsigned NewIdx = JTMapping[Op.getJumpTableIndex()];
175 Op.setJumpTableIndex(NewIdx);
174 unsigned NewIdx = JTMapping[Op.getIndex()];
175 Op.setIndex(NewIdx);
176176
177177 // Remember that this JT is live.
178178 JTIsLive[NewIdx] = true;
209209 case MachineOperand::MO_Register: OperandHash = Op.getReg(); break;
210210 case MachineOperand::MO_Immediate: OperandHash = Op.getImm(); break;
211211 case MachineOperand::MO_MachineBasicBlock:
212 OperandHash = Op.getMachineBasicBlock()->getNumber();
212 OperandHash = Op.getMBB()->getNumber();
213213 break;
214 case MachineOperand::MO_FrameIndex: OperandHash = Op.getFrameIndex(); break;
214 case MachineOperand::MO_FrameIndex:
215215 case MachineOperand::MO_ConstantPoolIndex:
216 OperandHash = Op.getConstantPoolIndex();
217 break;
218216 case MachineOperand::MO_JumpTableIndex:
219 OperandHash = Op.getJumpTableIndex();
217 OperandHash = Op.getIndex();
220218 break;
221219 case MachineOperand::MO_GlobalAddress:
222220 case MachineOperand::MO_ExternalSymbol:
695695 for (MachineBasicBlock::const_iterator BBI = I->begin(), BBE = I->end();
696696 BBI != BBE && BBI->getOpcode() == TargetInstrInfo::PHI; ++BBI)
697697 for (unsigned i = 1, e = BBI->getNumOperands(); i != e; i += 2)
698 PHIVarInfo[BBI->getOperand(i + 1).getMachineBasicBlock()->getNumber()].
698 PHIVarInfo[BBI->getOperand(i + 1).getMBB()->getNumber()].
699699 push_back(BBI->getOperand(i).getReg());
700700 }
213213 // Scan the operands of this machine instruction, replacing any uses of Old
214214 // with New.
215215 for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
216 if (I->getOperand(i).isMachineBasicBlock() &&
217 I->getOperand(i).getMachineBasicBlock() == Old)
218 I->getOperand(i).setMachineBasicBlock(New);
216 if (I->getOperand(i).isMBB() && I->getOperand(i).getMBB() == Old)
217 I->getOperand(i).setMBB(New);
219218 }
220219
221220 // Update the successor information. If New was already a successor, just
3939 case MachineOperand::MO_MachineBasicBlock:
4040 return getMBB() == Other.getMBB();
4141 case MachineOperand::MO_FrameIndex:
42 return getFrameIndex() == Other.getFrameIndex();
42 return getIndex() == Other.getIndex();
4343 case MachineOperand::MO_ConstantPoolIndex:
44 return getConstantPoolIndex() == Other.getConstantPoolIndex() &&
45 getOffset() == Other.getOffset();
44 return getIndex() == Other.getIndex() && getOffset() == Other.getOffset();
4645 case MachineOperand::MO_JumpTableIndex:
47 return getJumpTableIndex() == Other.getJumpTableIndex();
46 return getIndex() == Other.getIndex();
4847 case MachineOperand::MO_GlobalAddress:
4948 return getGlobal() == Other.getGlobal() && getOffset() == Other.getOffset();
5049 case MachineOperand::MO_ExternalSymbol:
9998 break;
10099 case MachineOperand::MO_MachineBasicBlock:
101100 OS << "mbb<"
102 << ((Value*)getMachineBasicBlock()->getBasicBlock())->getName()
103 << "," << (void*)getMachineBasicBlock() << ">";
101 << ((Value*)getMBB()->getBasicBlock())->getName()
102 << "," << (void*)getMBB() << ">";
104103 break;
105104 case MachineOperand::MO_FrameIndex:
106 OS << "FrameIndex() << ">";
105 OS << "Index() << ">";
107106 break;
108107 case MachineOperand::MO_ConstantPoolIndex:
109 OS << "ConstantPoolIndex();
108 OS << "Index();
110109 if (getOffset()) OS << "+" << getOffset();
111110 OS << ">";
112111 break;
113112 case MachineOperand::MO_JumpTableIndex:
114 OS << "JumpTableIndex() << ">";
113 OS << "Index() << ">";
115114 break;
116115 case MachineOperand::MO_GlobalAddress:
117116 OS << "getName();
173173 // Adjust the VRegPHIUseCount map to account for the removal of this PHI
174174 // node.
175175 for (unsigned i = 1; i != MPhi->getNumOperands(); i += 2)
176 --VRegPHIUseCount[BBVRegPair(
177 MPhi->getOperand(i + 1).getMachineBasicBlock(),
178 MPhi->getOperand(i).getReg())];
176 --VRegPHIUseCount[BBVRegPair(MPhi->getOperand(i + 1).getMBB(),
177 MPhi->getOperand(i).getReg())];
179178
180179 // Now loop over all of the incoming arguments, changing them to copy into
181180 // the IncomingReg register in the corresponding predecessor basic block.
188187
189188 // Get the MachineBasicBlock equivalent of the BasicBlock that is the
190189 // source path the PHI.
191 MachineBasicBlock &opBlock = *MPhi->getOperand(i).getMachineBasicBlock();
190 MachineBasicBlock &opBlock = *MPhi->getOperand(i).getMBB();
192191
193192 // Check to make sure we haven't already emitted the copy for this block.
194193 // This can happen because PHI nodes may have multiple entries for the
338337 for (MachineBasicBlock::const_iterator BBI = I->begin(), BBE = I->end();
339338 BBI != BBE && BBI->getOpcode() == TargetInstrInfo::PHI; ++BBI)
340339 for (unsigned i = 1, e = BBI->getNumOperands(); i != e; i += 2)
341 ++VRegPHIUseCount[BBVRegPair(
342 BBI->getOperand(i + 1).getMachineBasicBlock(),
343 BBI->getOperand(i).getReg())];
344 }
340 ++VRegPHIUseCount[BBVRegPair(BBI->getOperand(i + 1).getMBB(),
341 BBI->getOperand(i).getReg())];
342 }
384384 UnionedBlocks.count(SrcInfo.DefInst->getParent())) {
385385
386386 // add a copy from a_i to p in Waiting[From[a_i]]
387 MachineBasicBlock* From = P->getOperand(i).getMachineBasicBlock();
387 MachineBasicBlock* From = P->getOperand(i).getMBB();
388388 Waiting[From].insert(std::make_pair(SrcReg, DestReg));
389389 UsedByAnother.insert(SrcReg);
390390 } else {
274274 break;
275275 }
276276 case MachineOperand::MO_MachineBasicBlock:
277 printBasicBlockLabel(MO.getMachineBasicBlock());
277 printBasicBlockLabel(MO.getMBB());
278278 return;
279279 case MachineOperand::MO_GlobalAddress: {
280280 bool isCallOp = Modifier && !strcmp(Modifier, "call");
318318 }
319319 case MachineOperand::MO_ConstantPoolIndex:
320320 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
321 << '_' << MO.getConstantPoolIndex();
321 << '_' << MO.getIndex();
322322 break;
323323 case MachineOperand::MO_JumpTableIndex:
324324 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
325 << '_' << MO.getJumpTableIndex();
325 << '_' << MO.getIndex();
326326 break;
327327 default:
328328 O << ""; abort (); break;
654654 << '_' << ID << ":\n";
655655 } else {
656656 assert(!strcmp(Modifier, "cpentry") && "Unknown modifier for CPE");
657 unsigned CPI = MI->getOperand(OpNo).getConstantPoolIndex();
657 unsigned CPI = MI->getOperand(OpNo).getIndex();
658658
659659 const MachineConstantPoolEntry &MCPE = // Chasing pointers is fun?
660660 MI->getParent()->getParent()->getConstantPool()->getConstants()[CPI];
674674 void ARMAsmPrinter::printJTBlockOperand(const MachineInstr *MI, int OpNo) {
675675 const MachineOperand &MO1 = MI->getOperand(OpNo);
676676 const MachineOperand &MO2 = MI->getOperand(OpNo+1); // Unique Id
677 unsigned JTI = MO1.getJumpTableIndex();
677 unsigned JTI = MO1.getIndex();
678678 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
679679 << '_' << JTI << '_' << MO2.getImm() << ":\n";
680680
142142 } else if (MO.isExternalSymbol()) {
143143 emitExternalSymbolAddress(MO.getSymbolName(), ARM::reloc_arm_relative);
144144 } else if (MO.isConstantPoolIndex()) {
145 emitConstPoolAddress(MO.getConstantPoolIndex(), ARM::reloc_arm_relative);
145 emitConstPoolAddress(MO.getIndex(), ARM::reloc_arm_relative);
146146 } else if (MO.isJumpTableIndex()) {
147 emitJumpTableAddress(MO.getJumpTableIndex(), ARM::reloc_arm_relative);
147 emitJumpTableAddress(MO.getIndex(), ARM::reloc_arm_relative);
148148 } else if (MO.isMachineBasicBlock()) {
149 emitMachineBasicBlock(MO.getMachineBasicBlock());
149 emitMachineBasicBlock(MO.getMBB());
150150 }
151151
152152 return rv;
466466 }
467467
468468 // Remember that this is a user of a CP entry.
469 unsigned CPI = I->getOperand(op).getConstantPoolIndex();
469 unsigned CPI = I->getOperand(op).getIndex();
470470 MachineInstr *CPEMI = CPEMIs[CPI];
471471 unsigned MaxOffs = ((1 << Bits)-1) * Scale;
472472 CPUsers.push_back(CPUser(I, CPEMI, MaxOffs));
801801 }
802802
803803 // No. Look for previously created clones of the CPE that are in range.
804 unsigned CPI = CPEMI->getOperand(1).getConstantPoolIndex();
804 unsigned CPI = CPEMI->getOperand(1).getIndex();
805805 std::vector &CPEs = CPEntries[CPI];
806806 for (unsigned i = 0, e = CPEs.size(); i != e; ++i) {
807807 // We already tried this one
817817 // Change the CPI in the instruction operand to refer to the clone.
818818 for (unsigned j = 0, e = UserMI->getNumOperands(); j != e; ++j)
819819 if (UserMI->getOperand(j).isConstantPoolIndex()) {
820 UserMI->getOperand(j).setConstantPoolIndex(CPEs[i].CPI);
820 UserMI->getOperand(j).setIndex(CPEs[i].CPI);
821821 break;
822822 }
823823 // Adjust the refcount of the clone...
997997 CPUser &U = CPUsers[CPUserIndex];
998998 MachineInstr *UserMI = U.MI;
999999 MachineInstr *CPEMI = U.CPEMI;
1000 unsigned CPI = CPEMI->getOperand(1).getConstantPoolIndex();
1000 unsigned CPI = CPEMI->getOperand(1).getIndex();
10011001 unsigned Size = CPEMI->getOperand(2).getImm();
10021002 MachineBasicBlock *NewMBB;
10031003 // Compute this only once, it's expensive. The 4 or 8 is the value the
10561056
10571057 // Finally, change the CPI in the instruction operand to be ID.
10581058 for (unsigned i = 0, e = UserMI->getNumOperands(); i != e; ++i)
1059 if (UserMI->getOperand(i).isConstantPoolIndex()) {
1060 UserMI->getOperand(i).setConstantPoolIndex(ID);
1059 if (UserMI->getOperand(i).isCPI()) {
1060 UserMI->getOperand(i).setIndex(ID);
10611061 break;
10621062 }
10631063
11381138 /// away to fit in its displacement field.
11391139 bool ARMConstantIslands::FixUpImmediateBr(MachineFunction &Fn, ImmBranch &Br) {
11401140 MachineInstr *MI = Br.MI;
1141 MachineBasicBlock *DestBB = MI->getOperand(0).getMachineBasicBlock();
1141 MachineBasicBlock *DestBB = MI->getOperand(0).getMBB();
11421142
11431143 // Check to see if the DestBB is already in-range.
11441144 if (BBIsInRange(MI, DestBB, Br.MaxDisp))
11781178 bool
11791179 ARMConstantIslands::FixUpConditionalBr(MachineFunction &Fn, ImmBranch &Br) {
11801180 MachineInstr *MI = Br.MI;
1181 MachineBasicBlock *DestBB = MI->getOperand(0).getMachineBasicBlock();
1181 MachineBasicBlock *DestBB = MI->getOperand(0).getMBB();
11821182
11831183 // Add a unconditional branch to the destination and invert the branch
11841184 // condition to jump over it:
12091209 // =>
12101210 // bne L2
12111211 // b L1
1212 MachineBasicBlock *NewDest = BMI->getOperand(0).getMachineBasicBlock();
1212 MachineBasicBlock *NewDest = BMI->getOperand(0).getMBB();
12131213 if (BBIsInRange(MI, NewDest, Br.MaxDisp)) {
12141214 DOUT << " Invert Bcc condition and swap its destination with " << *BMI;
1215 BMI->getOperand(0).setMachineBasicBlock(DestBB);
1216 MI->getOperand(0).setMachineBasicBlock(NewDest);
1215 BMI->getOperand(0).setMBB(DestBB);
1216 MI->getOperand(0).setMBB(NewDest);
12171217 MI->getOperand(1).setImm(CC);
12181218 return true;
12191219 }
7070 MI->getOperand(3).isImmediate() &&
7171 MI->getOperand(2).getReg() == 0 &&
7272 MI->getOperand(3).getImm() == 0) {
73 FrameIndex = MI->getOperand(1).getFrameIndex();
73 FrameIndex = MI->getOperand(1).getIndex();
7474 return MI->getOperand(0).getReg();
7575 }
7676 break;
7979 if (MI->getOperand(1).isFrameIndex() &&
8080 MI->getOperand(2).isImmediate() &&
8181 MI->getOperand(2).getImm() == 0) {
82 FrameIndex = MI->getOperand(1).getFrameIndex();
82 FrameIndex = MI->getOperand(1).getIndex();
8383 return MI->getOperand(0).getReg();
8484 }
8585 break;
8787 if (MI->getOperand(1).isFrameIndex() &&
8888 MI->getOperand(2).isImmediate() &&
8989 MI->getOperand(2).getImm() == 0) {
90 FrameIndex = MI->getOperand(1).getFrameIndex();
90 FrameIndex = MI->getOperand(1).getIndex();
9191 return MI->getOperand(0).getReg();
9292 }
9393 break;
104104 MI->getOperand(3).isImmediate() &&
105105 MI->getOperand(2).getReg() == 0 &&
106106 MI->getOperand(3).getImm() == 0) {
107 FrameIndex = MI->getOperand(1).getFrameIndex();
107 FrameIndex = MI->getOperand(1).getIndex();
108108 return MI->getOperand(0).getReg();
109109 }
110110 break;
113113 if (MI->getOperand(1).isFrameIndex() &&
114114 MI->getOperand(2).isImmediate() &&
115115 MI->getOperand(2).getImm() == 0) {
116 FrameIndex = MI->getOperand(1).getFrameIndex();
116 FrameIndex = MI->getOperand(1).getIndex();
117117 return MI->getOperand(0).getReg();
118118 }
119119 break;
121121 if (MI->getOperand(1).isFrameIndex() &&
122122 MI->getOperand(2).isImmediate() &&
123123 MI->getOperand(2).getImm() == 0) {
124 FrameIndex = MI->getOperand(1).getFrameIndex();
124 FrameIndex = MI->getOperand(1).getIndex();
125125 return MI->getOperand(0).getReg();
126126 }
127127 break;
318318 unsigned LastOpc = LastInst->getOpcode();
319319 if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) {
320320 if (LastOpc == ARM::B || LastOpc == ARM::tB) {
321 TBB = LastInst->getOperand(0).getMachineBasicBlock();
321 TBB = LastInst->getOperand(0).getMBB();
322322 return false;
323323 }
324324 if (LastOpc == ARM::Bcc || LastOpc == ARM::tBcc) {
325325 // Block ends with fall-through condbranch.
326 TBB = LastInst->getOperand(0).getMachineBasicBlock();
326 TBB = LastInst->getOperand(0).getMBB();
327327 Cond.push_back(LastInst->getOperand(1));
328328 Cond.push_back(LastInst->getOperand(2));
329329 return false;
342342 unsigned SecondLastOpc = SecondLastInst->getOpcode();
343343 if ((SecondLastOpc == ARM::Bcc && LastOpc == ARM::B) ||
344344 (SecondLastOpc == ARM::tBcc && LastOpc == ARM::tB)) {
345 TBB = SecondLastInst->getOperand(0).getMachineBasicBlock();
345 TBB = SecondLastInst->getOperand(0).getMBB();
346346 Cond.push_back(SecondLastInst->getOperand(1));
347347 Cond.push_back(SecondLastInst->getOperand(2));
348 FBB = LastInst->getOperand(0).getMachineBasicBlock();
348 FBB = LastInst->getOperand(0).getMBB();
349349 return false;
350350 }
351351
353353 // one is not executed, so remove it.
354354 if ((SecondLastOpc == ARM::B || SecondLastOpc==ARM::tB) &&
355355 (LastOpc == ARM::B || LastOpc == ARM::tB)) {
356 TBB = SecondLastInst->getOperand(0).getMachineBasicBlock();
356 TBB = SecondLastInst->getOperand(0).getMBB();
357357 I = LastInst;
358358 I->eraseFromParent();
359359 return false;
575575 unsigned NumOps = TID->numOperands;
576576 MachineOperand JTOP =
577577 MI->getOperand(NumOps - ((TID->Flags & M_PREDICABLE) ? 3 : 2));
578 unsigned JTI = JTOP.getJumpTableIndex();
578 unsigned JTI = JTOP.getIndex();
579579 MachineJumpTableInfo *MJTI = MF->getJumpTableInfo();
580580 const std::vector &JT = MJTI->getJumpTables();
581581 assert(JTI < JT.size());
147147 else if (MO.isImmediate())
148148 MIB = MIB.addImm(MO.getImm());
149149 else if (MO.isFrameIndex())
150 MIB = MIB.addFrameIndex(MO.getFrameIndex());
150 MIB = MIB.addFrameIndex(MO.getIndex());
151151 else
152152 assert(0 && "Unknown operand for ARMInstrAddOperand!");
153153
869869 }
870870
871871 unsigned FrameReg = ARM::SP;
872 int FrameIndex = MI.getOperand(i).getFrameIndex();
872 int FrameIndex = MI.getOperand(i).getIndex();
873873 int Offset = MF.getFrameInfo()->getObjectOffset(FrameIndex) +
874874 MF.getFrameInfo()->getStackSize() + SPAdj;
875875
9999 return;
100100
101101 case MachineOperand::MO_MachineBasicBlock:
102 printBasicBlockLabel(MO.getMachineBasicBlock());
102 printBasicBlockLabel(MO.getMBB());
103103 return;
104104
105105 case MachineOperand::MO_ConstantPoolIndex:
106106 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
107 << MO.getConstantPoolIndex();
107 << MO.getIndex();
108108 return;
109109
110110 case MachineOperand::MO_ExternalSymbol:
121121
122122 case MachineOperand::MO_JumpTableIndex:
123123 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
124 << '_' << MO.getJumpTableIndex();
124 << '_' << MO.getIndex();
125125 return;
126126
127127 default:
201201 Reloc, MO.getSymbolName(),
202202 Offset, true));
203203 else
204 MCE.addRelocation(MachineRelocation::getConstPool(MCE.getCurrentPCOffset(),
205 Reloc, MO.getConstantPoolIndex(),
206 Offset));
204 MCE.addRelocation(MachineRelocation::getConstPool(MCE.getCurrentPCOffset(),
205 Reloc, MO.getIndex(), Offset));
207206 } else if (MO.isMachineBasicBlock()) {
208207 MCE.addRelocation(MachineRelocation::getBB(MCE.getCurrentPCOffset(),
209 Alpha::reloc_bsr,
210 MO.getMachineBasicBlock()));
208 Alpha::reloc_bsr, MO.getMBB()));
211209 }else {
212210 cerr << "ERROR: Unknown type of MachineOperand: " << MO << "\n";
213211 abort();
5757 case Alpha::LDS:
5858 case Alpha::LDT:
5959 if (MI->getOperand(1).isFrameIndex()) {
60 FrameIndex = MI->getOperand(1).getFrameIndex();
60 FrameIndex = MI->getOperand(1).getIndex();
6161 return MI->getOperand(0).getReg();
6262 }
6363 break;
7575 case Alpha::STS:
7676 case Alpha::STT:
7777 if (MI->getOperand(1).isFrameIndex()) {
78 FrameIndex = MI->getOperand(1).getFrameIndex();
78 FrameIndex = MI->getOperand(1).getIndex();
7979 return MI->getOperand(0).getReg();
8080 }
8181 break;
167167 // If there is only one terminator instruction, process it.
168168 if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) {
169169 if (LastInst->getOpcode() == Alpha::BR) {
170 TBB = LastInst->getOperand(0).getMachineBasicBlock();
170 TBB = LastInst->getOperand(0).getMBB();
171171 return false;
172172 } else if (LastInst->getOpcode() == Alpha::COND_BRANCH_I ||
173173 LastInst->getOpcode() == Alpha::COND_BRANCH_F) {
174174 // Block ends with fall-through condbranch.
175 TBB = LastInst->getOperand(2).getMachineBasicBlock();
175 TBB = LastInst->getOperand(2).getMBB();
176176 Cond.push_back(LastInst->getOperand(0));
177177 Cond.push_back(LastInst->getOperand(1));
178178 return false;
193193 if ((SecondLastInst->getOpcode() == Alpha::COND_BRANCH_I ||
194194 SecondLastInst->getOpcode() == Alpha::COND_BRANCH_F) &&
195195 LastInst->getOpcode() == Alpha::BR) {
196 TBB = SecondLastInst->getOperand(2).getMachineBasicBlock();
196 TBB = SecondLastInst->getOperand(2).getMBB();
197197 Cond.push_back(SecondLastInst->getOperand(0));
198198 Cond.push_back(SecondLastInst->getOperand(1));
199 FBB = LastInst->getOperand(0).getMachineBasicBlock();
199 FBB = LastInst->getOperand(0).getMBB();
200200 return false;
201201 }
202202
204204 // executed, so remove it.
205205 if (SecondLastInst->getOpcode() == Alpha::BR &&
206206 LastInst->getOpcode() == Alpha::BR) {
207 TBB = SecondLastInst->getOperand(0).getMachineBasicBlock();
207 TBB = SecondLastInst->getOperand(0).getMBB();
208208 I = LastInst;
209209 I->eraseFromParent();
210210 return false;
328328 assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!");
329329 }
330330
331 int FrameIndex = MI.getOperand(i).getFrameIndex();
331 int FrameIndex = MI.getOperand(i).getIndex();
332332
333333 // Add the base register of R30 (SP) or R15 (FP).
334334 MI.getOperand(i + 1).ChangeToRegister(FP ? Alpha::R15 : Alpha::R30, false);
303303 return;
304304
305305 case MachineOperand::MO_MachineBasicBlock:
306 printBasicBlockLabel(MO.getMachineBasicBlock());
306 printBasicBlockLabel(MO.getMBB());
307307 return;
308308 case MachineOperand::MO_JumpTableIndex:
309309 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
310 << '_' << MO.getJumpTableIndex();
310 << '_' << MO.getIndex();
311311 // FIXME: PIC relocation model
312312 return;
313313 case MachineOperand::MO_ConstantPoolIndex:
314314 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
315 << '_' << MO.getConstantPoolIndex();
315 << '_' << MO.getIndex();
316316 return;
317317 case MachineOperand::MO_ExternalSymbol:
318318 // Computing the address of an external symbol, not calling it.
138138 case SPU::LQXr16:
139139 if (MI->getOperand(1).isImmediate() && !MI->getOperand(1).getImm() &&
140140 MI->getOperand(2).isFrameIndex()) {
141 FrameIndex = MI->getOperand(2).getFrameIndex();
141 FrameIndex = MI->getOperand(2).getIndex();
142142 return MI->getOperand(0).getReg();
143143 }
144144 break;
172172 // case SPU::STQXr8:
173173 if (MI->getOperand(1).isImmediate() && !MI->getOperand(1).getImm() &&
174174 MI->getOperand(2).isFrameIndex()) {
175 FrameIndex = MI->getOperand(2).getFrameIndex();
175 FrameIndex = MI->getOperand(2).getIndex();
176176 return MI->getOperand(0).getReg();
177177 }
178178 break;
266266 else if (MO.isImmediate())
267267 MIB.addImm(MO.getImm());
268268 else
269 MIB.addFrameIndex(MO.getFrameIndex());
269 MIB.addFrameIndex(MO.getIndex());
270270 }
271271 NewMIs.push_back(MIB);
272272 }
352352 else if (MO.isImmediate())
353353 MIB.addImm(MO.getImm());
354354 else
355 MIB.addFrameIndex(MO.getFrameIndex());
355 MIB.addFrameIndex(MO.getIndex());
356356 }
357357 NewMIs.push_back(MIB);
358358 }
597597 }
598598
599599 MachineOperand &SPOp = MI.getOperand(i);
600 int FrameIndex = SPOp.getFrameIndex();
600 int FrameIndex = SPOp.getIndex();
601601
602602 // Now add the frame object offset to the offset from r1.
603603 int Offset = MFI->getObjectOffset(FrameIndex);
174174 O << MO.getImm();
175175 return;
176176 case MachineOperand::MO_MachineBasicBlock:
177 printBasicBlockLabel(MO.getMachineBasicBlock());
177 printBasicBlockLabel(MO.getMBB());
178178 return;
179179 case MachineOperand::MO_ConstantPoolIndex: {
180180 O << "@gprel(" << TAI->getPrivateGlobalPrefix()
181 << "CPI" << getFunctionNumber() << "_"
182 << MO.getConstantPoolIndex() << ")";
181 << "CPI" << getFunctionNumber() << "_" << MO.getIndex() << ")";
183182 return;
184183 }
185184
8585 else if (MO.isImmediate())
8686 MIB.addImm(MO.getImm());
8787 else
88 MIB.addFrameIndex(MO.getFrameIndex());
88 MIB.addFrameIndex(MO.getIndex());
8989 }
9090 MIB.addReg(SrcReg, false, false, isKill);
9191 NewMIs.push_back(MIB);
137137 else if (MO.isImmediate())
138138 MIB.addImm(MO.getImm());
139139 else
140 MIB.addFrameIndex(MO.getFrameIndex());
140 MIB.addFrameIndex(MO.getIndex());
141141 }
142142 NewMIs.push_back(MIB);
143143 return;
261261 assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!");
262262 }
263263
264 int FrameIndex = MI.getOperand(i).getFrameIndex();
264 int FrameIndex = MI.getOperand(i).getIndex();
265265
266266 // choose a base register: ( hasFP? framepointer : stack pointer )
267267 unsigned BaseRegister = FP ? IA64::r5 : IA64::r12;
379379 break;
380380
381381 case MachineOperand::MO_MachineBasicBlock:
382 printBasicBlockLabel(MO.getMachineBasicBlock());
382 printBasicBlockLabel(MO.getMBB());
383383 return;
384384
385385 case MachineOperand::MO_GlobalAddress:
392392
393393 case MachineOperand::MO_JumpTableIndex:
394394 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
395 << '_' << MO.getJumpTableIndex();
395 << '_' << MO.getIndex();
396396 break;
397397
398398 // FIXME: Verify correct
399399 case MachineOperand::MO_ConstantPoolIndex:
400400 O << TAI->getPrivateGlobalPrefix() << "CPI"
401 << getFunctionNumber() << "_" << MO.getConstantPoolIndex();
401 << getFunctionNumber() << "_" << MO.getIndex();
402402 break;
403403
404404 default:
7373 (MI->getOperand(1).isImmediate()) && // the imm is zero
7474 (isZeroImm(MI->getOperand(1))))
7575 {
76 FrameIndex = MI->getOperand(2).getFrameIndex();
76 FrameIndex = MI->getOperand(2).getIndex();
7777 return MI->getOperand(0).getReg();
7878 }
7979 }
9494 (MI->getOperand(1).isImmediate()) && // the imm is zero
9595 (isZeroImm(MI->getOperand(1))))
9696 {
97 FrameIndex = MI->getOperand(0).getFrameIndex();
97 FrameIndex = MI->getOperand(0).getIndex();
9898 return MI->getOperand(2).getReg();
9999 }
100100 }
179179
180180 // Unconditional branch
181181 if (LastOpc == Mips::J) {
182 TBB = LastInst->getOperand(0).getMachineBasicBlock();
182 TBB = LastInst->getOperand(0).getMBB();
183183 return false;
184184 }
185185
192192 if (LastOpc != Mips::COND_INVALID) {
193193 int LastNumOp = LastInst->getNumOperands();
194194
195 TBB = LastInst->getOperand(LastNumOp-1).getMachineBasicBlock();
195 TBB = LastInst->getOperand(LastNumOp-1).getMBB();
196196 Cond.push_back(MachineOperand::CreateImm(BranchCode));
197197
198198 for (int i=0; i
217217 if (SecondLastOpc != Mips::COND_INVALID && LastOpc == Mips::J) {
218218 int SecondNumOp = SecondLastInst->getNumOperands();
219219
220 TBB = SecondLastInst->getOperand(SecondNumOp-1).getMachineBasicBlock();
220 TBB = SecondLastInst->getOperand(SecondNumOp-1).getMBB();
221221 Cond.push_back(MachineOperand::CreateImm(BranchCode));
222222
223223 for (int i=0; i
224224 Cond.push_back(SecondLastInst->getOperand(i));
225225 }
226226
227 FBB = LastInst->getOperand(0).getMachineBasicBlock();
227 FBB = LastInst->getOperand(0).getMBB();
228228 return false;
229229 }
230230
231231 // If the block ends with two unconditional branches, handle it. The last
232232 // one is not executed, so remove it.
233233 if ((SecondLastOpc == Mips::J) && (LastOpc == Mips::J)) {
234 TBB = SecondLastInst->getOperand(0).getMachineBasicBlock();
234 TBB = SecondLastInst->getOperand(0).getMBB();
235235 I = LastInst;
236236 I->eraseFromParent();
237237 return false;
110110 else if (MO.isImmediate())
111111 MIB.addImm(MO.getImm());
112112 else
113 MIB.addFrameIndex(MO.getFrameIndex());
113 MIB.addFrameIndex(MO.getIndex());
114114 }
115115 NewMIs.push_back(MIB);
116116 return;
141141 else if (MO.isImmediate())
142142 MIB.addImm(MO.getImm());
143143 else
144 MIB.addFrameIndex(MO.getFrameIndex());
144 MIB.addFrameIndex(MO.getIndex());
145145 }
146146 NewMIs.push_back(MIB);
147147 return;
338338 "Instr doesn't have FrameIndex operand!");
339339 }
340340
341 int FrameIndex = MI.getOperand(i).getFrameIndex();
341 int FrameIndex = MI.getOperand(i).getIndex();
342342 int stackSize = MF.getFrameInfo()->getStackSize();
343343 int spOffset = MF.getFrameInfo()->getObjectOffset(FrameIndex);
344344
359359 return;
360360
361361 case MachineOperand::MO_MachineBasicBlock:
362 printBasicBlockLabel(MO.getMachineBasicBlock());
362 printBasicBlockLabel(MO.getMBB());
363363 return;
364364 case MachineOperand::MO_JumpTableIndex:
365365 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
366 << '_' << MO.getJumpTableIndex();
366 << '_' << MO.getIndex();
367367 // FIXME: PIC relocation model
368368 return;
369369 case MachineOperand::MO_ConstantPoolIndex:
370370 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
371 << '_' << MO.getConstantPoolIndex();
371 << '_' << MO.getIndex();
372372 return;
373373 case MachineOperand::MO_ExternalSymbol:
374374 // Computing the address of an external symbol, not calling it.
135135
136136 // Determine the offset from the current branch to the destination
137137 // block.
138 MachineBasicBlock *Dest = I->getOperand(2).getMachineBasicBlock();
138 MachineBasicBlock *Dest = I->getOperand(2).getMBB();
139139
140140 int BranchSize;
141141 if (Dest->getNumber() <= MBB.getNumber()) {
194194 Reloc, MO.getSymbolName(), 0);
195195 } else if (MO.isConstantPoolIndex()) {
196196 R = MachineRelocation::getConstPool(MCE.getCurrentPCOffset(),
197 Reloc, MO.getConstantPoolIndex(), 0);
197 Reloc, MO.getIndex(), 0);
198198 } else {
199199 assert(MO.isJumpTableIndex());
200200 R = MachineRelocation::getJumpTable(MCE.getCurrentPCOffset(),
201 Reloc, MO.getJumpTableIndex(), 0);
201 Reloc, MO.getIndex(), 0);
202202 }
203203
204204 // If in PIC mode, we need to encode the negated address of the
222222 else // BCC instruction
223223 Reloc = PPC::reloc_pcrel_bcx;
224224 MCE.addRelocation(MachineRelocation::getBB(MCE.getCurrentPCOffset(),
225 Reloc,
226 MO.getMachineBasicBlock()));
225 Reloc, MO.getMBB()));
227226 } else {
228227 cerr << "ERROR: Unknown type of MachineOperand: " << MO << "\n";
229228 abort();
9898 case PPC::LWZ:
9999 case PPC::LFS:
100100 case PPC::LFD:
101 if (MI->getOperand(1).isImmediate() && !MI->getOperand(1).getImm() &&
102 MI->getOperand(2).isFrameIndex()) {
103 FrameIndex = MI->getOperand(2).getFrameIndex();
101 if (MI->getOperand(1).isImm() && !MI->getOperand(1).getImm() &&
102 MI->getOperand(2).isFI()) {
103 FrameIndex = MI->getOperand(2).getIndex();
104104 return MI->getOperand(0).getReg();
105105 }
106106 break;
116116 case PPC::STW:
117117 case PPC::STFS:
118118 case PPC::STFD:
119 if (MI->getOperand(1).isImmediate() && !MI->getOperand(1).getImm() &&
120 MI->getOperand(2).isFrameIndex()) {
121 FrameIndex = MI->getOperand(2).getFrameIndex();
119 if (MI->getOperand(1).isImm() && !MI->getOperand(1).getImm() &&
120 MI->getOperand(2).isFI()) {
121 FrameIndex = MI->getOperand(2).getIndex();
122122 return MI->getOperand(0).getReg();
123123 }
124124 break;
183183 // If there is only one terminator instruction, process it.
184184 if (I == MBB.begin() || !isUnpredicatedTerminator(--I)) {
185185 if (LastInst->getOpcode() == PPC::B) {
186 TBB = LastInst->getOperand(0).getMachineBasicBlock();
186 TBB = LastInst->getOperand(0).getMBB();
187187 return false;
188188 } else if (LastInst->getOpcode() == PPC::BCC) {
189189 // Block ends with fall-through condbranch.
190 TBB = LastInst->getOperand(2).getMachineBasicBlock();
190 TBB = LastInst->getOperand(2).getMBB();
191191 Cond.push_back(LastInst->getOperand(0));
192192 Cond.push_back(LastInst->getOperand(1));
193193 return false;
207207 // If the block ends with PPC::B and PPC:BCC, handle it.
208208 if (SecondLastInst->getOpcode() == PPC::BCC &&
209209 LastInst->getOpcode() == PPC::B) {
210 TBB = SecondLastInst->getOperand(2).getMachineBasicBlock();
210 TBB = SecondLastInst->getOperand(2).getMBB();
211211 Cond.push_back(SecondLastInst->getOperand(0));
212212 Cond.push_back(SecondLastInst->getOperand(1));
213 FBB = LastInst->getOperand(0).getMachineBasicBlock();
213 FBB = LastInst->getOperand(0).getMBB();
214214 return false;
215215 }
216216
218218 // executed, so remove it.
219219 if (SecondLastInst->getOpcode() == PPC::B &&
220220 LastInst->getOpcode() == PPC::B) {
221 TBB = SecondLastInst->getOperand(0).getMachineBasicBlock();
221 TBB = SecondLastInst->getOperand(0).getMBB();
222222 I = LastInst;
223223 I->eraseFromParent();
224224 return false;
186186 const TargetRegisterClass *RC,
187187 SmallVectorImpl &NewMIs) const {
188188 if (Addr[0].isFrameIndex()) {
189 StoreRegToStackSlot(TII, SrcReg, isKill, Addr[0].getFrameIndex(), RC,
190 NewMIs);
189 StoreRegToStackSlot(TII, SrcReg, isKill, Addr[0].getIndex(), RC, NewMIs);
191190 return;
192191 }
193192
215214 else if (MO.isImmediate())
216215 MIB.addImm(MO.getImm());
217216 else
218 MIB.addFrameIndex(MO.getFrameIndex());
217 MIB.addFrameIndex(MO.getIndex());
219218 }
220219 NewMIs.push_back(MIB);
221220 return;
294293 void PPCRegisterInfo::loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
295294 SmallVectorImpl &Addr,
296295 const TargetRegisterClass *RC,
297 SmallVectorImpl &NewMIs) const {
296 SmallVectorImpl &NewMIs) const{
298297 if (Addr[0].isFrameIndex()) {
299 LoadRegFromStackSlot(TII, DestReg, Addr[0].getFrameIndex(), RC, NewMIs);
298 LoadRegFromStackSlot(TII, DestReg, Addr[0].getIndex(), RC, NewMIs);
300299 return;
301300 }
302301
325324 else if (MO.isImmediate())
326325 MIB.addImm(MO.getImm());
327326 else
328 MIB.addFrameIndex(MO.getFrameIndex());
327 MIB.addFrameIndex(MO.getIndex());
329328 }
330329 NewMIs.push_back(MIB);
331330 return;
765764 OffsetOperandNo = FIOperandNo-1;
766765
767766 // Get the frame index.
768 int FrameIndex = MI.getOperand(FIOperandNo).getFrameIndex();
767 int FrameIndex = MI.getOperand(FIOperandNo).getIndex();
769768
770769 // Get the frame pointer save index. Users of this index are primarily
771770 // DYNALLOC instructions.
154154 O << (int)MO.getImm();
155155 break;
156156 case MachineOperand::MO_MachineBasicBlock:
157 printBasicBlockLabel(MO.getMachineBasicBlock());
157 printBasicBlockLabel(MO.getMBB());
158158 return;
159159 case MachineOperand::MO_GlobalAddress:
160160 O << Mang->getValueName(MO.getGlobal());
164164 break;
165165 case MachineOperand::MO_ConstantPoolIndex:
166166 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
167 << MO.getConstantPoolIndex();
167 << MO.getIndex();
168168 break;
169169 default:
170170 O << ""; abort (); break;
7171 MI->getOpcode() == SP::LDDFri) {
7272 if (MI->getOperand(1).isFrameIndex() && MI->getOperand(2).isImmediate() &&
7373 MI->getOperand(2).getImm() == 0) {
74 FrameIndex = MI->getOperand(1).getFrameIndex();
74 FrameIndex = MI->getOperand(1).getIndex();
7575 return MI->getOperand(0).getReg();
7676 }
7777 }
9090 MI->getOpcode() == SP::STDFri) {
9191 if (MI->getOperand(0).isFrameIndex() && MI->getOperand(1).isImmediate() &&
9292 MI->getOperand(1).getImm() == 0) {
93 FrameIndex = MI->getOperand(0).getFrameIndex();
93 FrameIndex = MI->getOperand(0).getIndex();
9494 return MI->getOperand(2).getReg();
9595 }
9696 }
6868 MIB.addReg(MO.getReg());
6969 else if (MO.isImmediate())
7070 MIB.addImm(MO.getImm());
71 else
72 MIB.addFrameIndex(MO.getFrameIndex());
71 else {
72 assert(MO.isFI());
73 MIB.addFrameIndex(MO.getIndex());
74 }
7375 }
7476 MIB.addReg(SrcReg, false, false, isKill);
7577 NewMIs.push_back(MIB);
106108 MachineInstrBuilder MIB = BuildMI(TII.get(Opc), DestReg);
107109 for (unsigned i = 0, e = Addr.size(); i != e; ++i) {
108110 MachineOperand &MO = Addr[i];
109 if (MO.isRegister())
111 if (MO.isReg())
110112 MIB.addReg(MO.getReg());
111 else if (MO.isImmediate())
113 else if (MO.isImm())
112114 MIB.addImm(MO.getImm());
113 else
114 MIB.addFrameIndex(MO.getFrameIndex());
115 else {
116 assert(MO.isFI());
117 MIB.addFrameIndex(MO.getIndex());
118 }
115119 }
116120 NewMIs.push_back(MIB);
117121 return;
240244 assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!");
241245 }
242246
243 int FrameIndex = MI.getOperand(i).getFrameIndex();
247 int FrameIndex = MI.getOperand(i).getIndex();
244248
245249 // Addressable stack objects are accessed using neg. offsets from %fp
246250 MachineFunction &MF = *MI.getParent()->getParent();
6161 for (unsigned j = 0, i = 0, e = MI->getNumOperands(); i != e; ++i) {
6262 if ((TID->OpInfo[i].Flags & M_PREDICATE_OPERAND)) {
6363 MachineOperand &MO = MI->getOperand(i);
64 if (MO.isRegister()) {
64 if (MO.isReg()) {
6565 MO.setReg(Pred[j].getReg());
6666 MadeChange = true;
67 } else if (MO.isImmediate()) {
67 } else if (MO.isImm()) {
6868 MO.setImm(Pred[j].getImm());
6969 MadeChange = true;
70 } else if (MO.isMachineBasicBlock()) {
71 MO.setMachineBasicBlock(Pred[j].getMachineBasicBlock());
70 } else if (MO.isMBB()) {
71 MO.setMBB(Pred[j].getMBB());
7272 MadeChange = true;
7373 }
7474 ++j;
231231 O << MO.getImm();
232232 return;
233233 case MachineOperand::MO_MachineBasicBlock:
234 printBasicBlockLabel(MO.getMachineBasicBlock());
234 printBasicBlockLabel(MO.getMBB());
235235 return;
236236 case MachineOperand::MO_JumpTableIndex: {
237237 bool isMemOp = Modifier && !strcmp(Modifier, "mem");
238238 if (!isMemOp) O << '$';
239239 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << "_"
240 << MO.getJumpTableIndex();
240 << MO.getIndex();
241241
242242 if (TM.getRelocationModel() == Reloc::PIC_) {
243243 if (Subtarget->isPICStyleStub())
255255 bool isMemOp = Modifier && !strcmp(Modifier, "mem");
256256 if (!isMemOp) O << '$';
257257 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
258 << MO.getConstantPoolIndex();
258 << MO.getIndex();
259259
260260 if (TM.getRelocationModel() == Reloc::PIC_) {
261261 if (Subtarget->isPICStyleStub())
246246 PCAdj, false, IsPIC);
247247 } else if (RelocOp->isConstantPoolIndex()) {
248248 // Must be in 64-bit mode.
249 emitConstPoolAddress(RelocOp->getConstantPoolIndex(), X86::reloc_pcrel_word,
249 emitConstPoolAddress(RelocOp->getIndex(), X86::reloc_pcrel_word,
250250 RelocOp->getOffset(), PCAdj, IsPIC);
251251 } else if (RelocOp->isJumpTableIndex()) {
252252 // Must be in 64-bit mode.
253 emitJumpTableAddress(RelocOp->getJumpTableIndex(), X86::reloc_pcrel_word,
253 emitJumpTableAddress(RelocOp->getIndex(), X86::reloc_pcrel_word,
254254 PCAdj, IsPIC);
255255 } else {
256256 assert(0 && "Unknown value to relocate!");
271271 if (Is64BitMode) {
272272 DispForReloc = &Op3;
273273 } else {
274 DispVal += MCE.getConstantPoolEntryAddress(Op3.getConstantPoolIndex());
274 DispVal += MCE.getConstantPoolEntryAddress(Op3.getIndex());
275275 DispVal += Op3.getOffset();
276276 }
277277 } else if (Op3.isJumpTableIndex()) {
278278 if (Is64BitMode) {
279279 DispForReloc = &Op3;
280280 } else {
281 DispVal += MCE.getJumpTableEntryAddress(Op3.getJumpTableIndex());
281 DispVal += MCE.getJumpTableEntryAddress(Op3.getIndex());
282282 }
283283 } else {
284284 DispVal = Op3.getImm();
600600 if (CurOp != NumOps) {
601601 const MachineOperand &MO = MI.getOperand(CurOp++);
602602 if (MO.isMachineBasicBlock()) {
603 emitPCRelativeBlockAddress(MO.getMachineBasicBlock());
603 emitPCRelativeBlockAddress(MO.getMBB());
604604 } else if (MO.isGlobalAddress()) {
605605 bool NeedStub = Is64BitMode ||
606606 Opcode == X86::TAILJMPd ||
641641 else if (MO1.isExternalSymbol())
642642 emitExternalSymbolAddress(MO1.getSymbolName(), rt, IsPIC);
643643 else if (MO1.isConstantPoolIndex())
644 emitConstPoolAddress(MO1.getConstantPoolIndex(), rt, IsPIC);
644 emitConstPoolAddress(MO1.getIndex(), rt, IsPIC);
645645 else if (MO1.isJumpTableIndex())
646 emitJumpTableAddress(MO1.getJumpTableIndex(), rt, IsPIC);
646 emitJumpTableAddress(MO1.getIndex(), rt, IsPIC);
647647 }
648648 }
649649 break;
710710 else if (MO1.isExternalSymbol())
711711 emitExternalSymbolAddress(MO1.getSymbolName(), rt, IsPIC);
712712 else if (MO1.isConstantPoolIndex())
713 emitConstPoolAddress(MO1.getConstantPoolIndex(), rt, IsPIC);
713 emitConstPoolAddress(MO1.getIndex(), rt, IsPIC);
714714 else if (MO1.isJumpTableIndex())
715 emitJumpTableAddress(MO1.getJumpTableIndex(), rt, IsPIC);
715 emitJumpTableAddress(MO1.getIndex(), rt, IsPIC);
716716 }
717717 }
718718 break;
744744 else if (MO.isExternalSymbol())
745745 emitExternalSymbolAddress(MO.getSymbolName(), rt, IsPIC);
746746 else if (MO.isConstantPoolIndex())
747 emitConstPoolAddress(MO.getConstantPoolIndex(), rt, IsPIC);
747 emitConstPoolAddress(MO.getIndex(), rt, IsPIC);
748748 else if (MO.isJumpTableIndex())
749 emitJumpTableAddress(MO.getJumpTableIndex(), rt, IsPIC);
749 emitJumpTableAddress(MO.getIndex(), rt, IsPIC);
750750 }
751751 }
752752 break;
58375837 AM.Base.Reg = Op.getReg();
58385838 } else {
58395839 AM.BaseType = X86AddressMode::FrameIndexBase;
5840 AM.Base.FrameIndex = Op.getFrameIndex();
5840 AM.Base.FrameIndex = Op.getIndex();
58415841 }
58425842 Op = MI->getOperand(1);
58435843 if (Op.isImmediate())
7070 case X86::MOVAPDrm:
7171 case X86::MMX_MOVD64rm:
7272 case X86::MMX_MOVQ64rm:
73 if (MI->getOperand(1).isFrameIndex() && MI->getOperand(2).isImmediate() &&
74 MI->getOperand(3).isRegister() && MI->getOperand(4).isImmediate() &&
73 if (MI->getOperand(1).isFI() && MI->getOperand(2).isImm() &&
74 MI->getOperand(3).isReg() && MI->getOperand(4).isImm() &&
7575 MI->getOperand(2).getImm() == 1 &&
7676 MI->getOperand(3).getReg() == 0 &&
7777 MI->getOperand(4).getImm() == 0) {
78 FrameIndex = MI->getOperand(1).getFrameIndex();
78 FrameIndex = MI->getOperand(1).getIndex();
7979 return MI->getOperand(0).getReg();
8080 }
8181 break;
101101 case X86::MMX_MOVD64mr:
102102 case X86::MMX_MOVQ64mr:
103103 case X86::MMX_MOVNTQmr:
104 if (MI->getOperand(0).isFrameIndex() && MI->getOperand(1).isImmediate() &&
105 MI->getOperand(2).isRegister() && MI->getOperand(3).isImmediate() &&
104 if (MI->getOperand(0).isFI() && MI->getOperand(1).isImm() &&
105 MI->getOperand(2).isReg() && MI->getOperand(3).isImm() &&
106106 MI->getOperand(1).getImm() == 1 &&
107107 MI->getOperand(2).getReg() == 0 &&
108108 MI->getOperand(3).getImm() == 0) {
109 FrameIndex = MI->getOperand(0).getFrameIndex();
109 FrameIndex = MI->getOperand(0).getIndex();
110110 return MI->getOperand(4).getReg();
111111 }
112112 break;
688688 // it's an unconditional, conditional, or indirect branch.
689689
690690 if (LastInst->getOpcode() == X86::JMP) {
691 TBB = LastInst->getOperand(0).getMachineBasicBlock();
691 TBB = LastInst->getOperand(0).getMBB();
692692 return false;
693693 }
694694 X86::CondCode BranchCode = GetCondFromBranchOpc(LastInst->getOpcode());
696696 return true; // Can't handle indirect branch.
697697
698698 // Otherwise, block ends with fall-through condbranch.
699 TBB = LastInst->getOperand(0).getMachineBasicBlock();
699 TBB = LastInst->getOperand(0).getMBB();
700700 Cond.push_back(MachineOperand::CreateImm(BranchCode));
701701 return false;
702702 }
712712 // If the block ends with X86::JMP and a conditional branch, handle it.
713713 X86::CondCode BranchCode = GetCondFromBranchOpc(SecondLastInst->getOpcode());
714714 if (BranchCode != X86::COND_INVALID && LastInst->getOpcode() == X86::JMP) {
715 TBB = SecondLastInst->getOperand(0).getMachineBasicBlock();
715 TBB = SecondLastInst->getOperand(0).getMBB();
716716 Cond.push_back(MachineOperand::CreateImm(BranchCode));
717 FBB = LastInst->getOperand(0).getMachineBasicBlock();
717 FBB = LastInst->getOperand(0).getMBB();
718718 return false;
719719 }
720720
722722 // executed, so remove it.
723723 if (SecondLastInst->getOpcode() == X86::JMP &&
724724 LastInst->getOpcode() == X86::JMP) {
725 TBB = SecondLastInst->getOperand(0).getMachineBasicBlock();
725 TBB = SecondLastInst->getOperand(0).getMBB();
726726 I = LastInst;
727727 I->eraseFromParent();
728728 return false;
134134 O << MO.getImm();
135135 return;
136136 case MachineOperand::MO_MachineBasicBlock:
137 printBasicBlockLabel(MO.getMachineBasicBlock());
137 printBasicBlockLabel(MO.getMBB());
138138 return;
139139 case MachineOperand::MO_JumpTableIndex: {
140140 bool isMemOp = Modifier && !strcmp(Modifier, "mem");
141141 if (!isMemOp) O << "OFFSET ";
142142 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber()
143 << "_" << MO.getJumpTableIndex();
143 << "_" << MO.getIndex();
144144 return;
145145 }
146146 case MachineOperand::MO_ConstantPoolIndex: {
147147 bool isMemOp = Modifier && !strcmp(Modifier, "mem");
148148 if (!isMemOp) O << "OFFSET ";
149149 O << "[" << TAI->getPrivateGlobalPrefix() << "CPI"
150 << getFunctionNumber() << "_" << MO.getConstantPoolIndex();
150 << getFunctionNumber() << "_" << MO.getIndex();
151151 int Offset = MO.getOffset();
152152 if (Offset > 0)
153153 O << " + " << Offset;
780780 else if (MO.isImmediate())
781781 MIB = MIB.addImm(MO.getImm());
782782 else if (MO.isFrameIndex())
783 MIB = MIB.addFrameIndex(MO.getFrameIndex());
783 MIB = MIB.addFrameIndex(MO.getIndex());
784784 else if (MO.isGlobalAddress())
785785 MIB = MIB.addGlobalAddress(MO.getGlobal(), MO.getOffset());
786786 else if (MO.isConstantPoolIndex())
787 MIB = MIB.addConstantPoolIndex(MO.getConstantPoolIndex(), MO.getOffset());
787 MIB = MIB.addConstantPoolIndex(MO.getIndex(), MO.getOffset());
788788 else if (MO.isJumpTableIndex())
789 MIB = MIB.addJumpTableIndex(MO.getJumpTableIndex());
789 MIB = MIB.addJumpTableIndex(MO.getIndex());
790790 else if (MO.isExternalSymbol())
791791 MIB = MIB.addExternalSymbol(MO.getSymbolName());
792792 else
16101610 assert(i < MI.getNumOperands() && "Instr doesn't have FrameIndex operand!");
16111611 }
16121612
1613 int FrameIndex = MI.getOperand(i).getFrameIndex();
1613 int FrameIndex = MI.getOperand(i).getIndex();
16141614 // This must be part of a four operand memory reference. Replace the
16151615 // FrameIndex with base register with EBP. Add an offset to the offset.
16161616 MI.getOperand(i).ChangeToRegister(hasFP(MF) ? FramePtr : StackPtr, false);