blob: f0a9645c4ecbac4d9411535b99f480c768571d91 [file] [log] [blame]
Chris Lattner035dfbe2002-08-09 20:08:06 +00001//===-- MachineInstr.cpp --------------------------------------------------===//
Vikram S. Adve70bc4b52001-07-21 12:41:50 +00002//
Chris Lattner035dfbe2002-08-09 20:08:06 +00003//===----------------------------------------------------------------------===//
Vikram S. Adve70bc4b52001-07-21 12:41:50 +00004
Chris Lattner822b4fb2001-09-07 17:18:30 +00005#include "llvm/CodeGen/MachineInstr.h"
Chris Lattnerddd7fcb2002-10-29 23:19:00 +00006#include "llvm/CodeGen/MachineBasicBlock.h"
Chris Lattner3801f6d2002-02-03 07:46:01 +00007#include "llvm/Value.h"
Chris Lattner10491642002-10-30 00:48:05 +00008#include "llvm/Target/TargetMachine.h"
Chris Lattner188732c2002-10-30 02:02:37 +00009#include "llvm/Target/MachineInstrInfo.h"
Chris Lattner2a79a092002-10-30 00:58:19 +000010#include "llvm/Target/MRegisterInfo.h"
Chris Lattner697954c2002-01-20 22:54:45 +000011using std::cerr;
Vikram S. Adve5b795912001-08-28 23:02:39 +000012
Chris Lattnerf1757c42002-10-29 17:40:30 +000013// Global variable holding an array of descriptors for machine instructions.
14// The actual object needs to be created separately for each target machine.
15// This variable is initialized and reset by class MachineInstrInfo.
16//
17// FIXME: This should be a property of the target so that more than one target
18// at a time can be active...
19//
20extern const MachineInstrDescriptor *TargetInstrDescriptors;
Ruchira Sasanka69917e22001-10-18 22:40:02 +000021
Vikram S. Adve1885da42001-07-31 21:49:28 +000022// Constructor for instructions with fixed #operands (nearly all)
Chris Lattner72791222002-10-28 20:59:49 +000023MachineInstr::MachineInstr(MachineOpCode _opCode)
Chris Lattner9a8e4122002-10-28 21:17:20 +000024 : opCode(_opCode),
Vikram S. Advea2bae302002-10-29 19:41:18 +000025 operands(TargetInstrDescriptors[_opCode].numOperands, MachineOperand()),
26 numImplicitRefs(0)
27{
Vikram S. Adve1885da42001-07-31 21:49:28 +000028 assert(TargetInstrDescriptors[_opCode].numOperands >= 0);
29}
30
31// Constructor for instructions with variable #operands
Chris Lattnerb98a53f2002-10-28 21:02:40 +000032MachineInstr::MachineInstr(MachineOpCode OpCode, unsigned numOperands)
Vikram S. Advea2bae302002-10-29 19:41:18 +000033 : opCode(OpCode),
34 operands(numOperands, MachineOperand()),
35 numImplicitRefs(0)
36{
Vikram S. Adve70bc4b52001-07-21 12:41:50 +000037}
38
Chris Lattnerddd7fcb2002-10-29 23:19:00 +000039/// MachineInstr ctor - This constructor only does a _reserve_ of the operands,
40/// not a resize for them. It is expected that if you use this that you call
41/// add* methods below to fill up the operands, instead of the Set methods.
42/// Eventually, the "resizing" ctors will be phased out.
43///
Chris Lattner72791222002-10-28 20:59:49 +000044MachineInstr::MachineInstr(MachineOpCode Opcode, unsigned numOperands,
Vikram S. Advea2bae302002-10-29 19:41:18 +000045 bool XX, bool YY)
46 : opCode(Opcode),
47 numImplicitRefs(0)
48{
Chris Lattner72791222002-10-28 20:59:49 +000049 operands.reserve(numOperands);
50}
51
Chris Lattnerddd7fcb2002-10-29 23:19:00 +000052/// MachineInstr ctor - Work exactly the same as the ctor above, except that the
53/// MachineInstr is created and added to the end of the specified basic block.
54///
55MachineInstr::MachineInstr(MachineBasicBlock *MBB, MachineOpCode Opcode,
56 unsigned numOperands)
57 : opCode(Opcode),
58 numImplicitRefs(0)
59{
60 assert(MBB && "Cannot use inserting ctor with null basic block!");
61 operands.reserve(numOperands);
62 MBB->push_back(this); // Add instruction to end of basic block!
63}
64
65
Chris Lattner413746e2002-10-28 20:48:39 +000066// OperandComplete - Return true if it's illegal to add a new operand
Vikram S. Advea2bae302002-10-29 19:41:18 +000067bool MachineInstr::OperandsComplete() const
68{
Chris Lattner413746e2002-10-28 20:48:39 +000069 int NumOperands = TargetInstrDescriptors[opCode].numOperands;
Vikram S. Advea2bae302002-10-29 19:41:18 +000070 if (NumOperands >= 0 && getNumOperands() >= (unsigned)NumOperands)
Chris Lattner413746e2002-10-28 20:48:39 +000071 return true; // Broken!
72 return false;
73}
74
75
Vikram S. Advee8b57ef2002-09-20 00:47:49 +000076//
77// Support for replacing opcode and operands of a MachineInstr in place.
78// This only resets the size of the operand vector and initializes it.
79// The new operands must be set explicitly later.
80//
Vikram S. Advea2bae302002-10-29 19:41:18 +000081void MachineInstr::replace(MachineOpCode Opcode, unsigned numOperands)
82{
83 assert(getNumImplicitRefs() == 0 &&
84 "This is probably broken because implicit refs are going to be lost.");
Chris Lattner413746e2002-10-28 20:48:39 +000085 opCode = Opcode;
Vikram S. Advee8b57ef2002-09-20 00:47:49 +000086 operands.clear();
Chris Lattner413746e2002-10-28 20:48:39 +000087 operands.resize(numOperands, MachineOperand());
Vikram S. Advee8b57ef2002-09-20 00:47:49 +000088}
89
Vikram S. Adve70bc4b52001-07-21 12:41:50 +000090void
Chris Lattner413746e2002-10-28 20:48:39 +000091MachineInstr::SetMachineOperandVal(unsigned i,
Vikram S. Adve7a4be952002-07-08 22:38:45 +000092 MachineOperand::MachineOperandType opType,
Chris Lattner572f5c82002-10-28 04:24:49 +000093 Value* V,
Chris Lattner0c0edf82002-07-25 06:17:51 +000094 bool isdef,
95 bool isDefAndUse)
Vikram S. Adve70bc4b52001-07-21 12:41:50 +000096{
Vikram S. Advea2bae302002-10-29 19:41:18 +000097 assert(i < operands.size()); // may be explicit or implicit op
Chris Lattner572f5c82002-10-28 04:24:49 +000098 operands[i].opType = opType;
99 operands[i].value = V;
100 operands[i].regNum = -1;
Chris Lattner572f5c82002-10-28 04:24:49 +0000101
Vikram S. Adve3bc9ef92002-07-10 21:45:04 +0000102 if (isDefAndUse)
Chris Lattner570f55d2002-11-17 22:14:08 +0000103 operands[i].flags = MachineOperand::DEFUSEFLAG;
104 else if (isdef || TargetInstrDescriptors[opCode].resultPos == (int) i)
105 operands[i].flags = MachineOperand::DEFFLAG;
106 else
107 operands[i].flags = 0;
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000108}
109
110void
Chris Lattner572f5c82002-10-28 04:24:49 +0000111MachineInstr::SetMachineOperandConst(unsigned i,
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000112 MachineOperand::MachineOperandType operandType,
Vikram S. Advec356e562002-03-18 03:35:24 +0000113 int64_t intValue)
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000114{
Vikram S. Advea2bae302002-10-29 19:41:18 +0000115 assert(i < getNumOperands()); // must be explicit op
Vikram S. Advec356e562002-03-18 03:35:24 +0000116 assert(TargetInstrDescriptors[opCode].resultPos != (int) i &&
117 "immed. constant cannot be defined");
Chris Lattner572f5c82002-10-28 04:24:49 +0000118
119 operands[i].opType = operandType;
120 operands[i].value = NULL;
121 operands[i].immedVal = intValue;
122 operands[i].regNum = -1;
123 operands[i].flags = 0;
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000124}
125
126void
Chris Lattner572f5c82002-10-28 04:24:49 +0000127MachineInstr::SetMachineOperandReg(unsigned i,
Vikram S. Advec356e562002-03-18 03:35:24 +0000128 int regNum,
Chris Lattner2f305982002-10-28 19:46:59 +0000129 bool isdef) {
Vikram S. Advea2bae302002-10-29 19:41:18 +0000130 assert(i < getNumOperands()); // must be explicit op
Chris Lattner572f5c82002-10-28 04:24:49 +0000131
Chris Lattner2f305982002-10-28 19:46:59 +0000132 operands[i].opType = MachineOperand::MO_MachineRegister;
Chris Lattner572f5c82002-10-28 04:24:49 +0000133 operands[i].value = NULL;
134 operands[i].regNum = regNum;
Chris Lattner572f5c82002-10-28 04:24:49 +0000135
Vikram S. Adve3bc9ef92002-07-10 21:45:04 +0000136 if (isdef || TargetInstrDescriptors[opCode].resultPos == (int) i)
Chris Lattner570f55d2002-11-17 22:14:08 +0000137 operands[i].flags = MachineOperand::DEFFLAG;
138 else
139 operands[i].flags = 0;
140
Chris Lattner27a08932002-10-22 23:16:21 +0000141 insertUsedReg(regNum);
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000142}
143
144void
Vikram S. Adve7a4be952002-07-08 22:38:45 +0000145MachineInstr::SetRegForOperand(unsigned i, int regNum)
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000146{
Vikram S. Advea2bae302002-10-29 19:41:18 +0000147 assert(i < getNumOperands()); // must be explicit op
Vikram S. Adve7a4be952002-07-08 22:38:45 +0000148 operands[i].setRegForValue(regNum);
Chris Lattner27a08932002-10-22 23:16:21 +0000149 insertUsedReg(regNum);
Vikram S. Adve7a4be952002-07-08 22:38:45 +0000150}
151
152
Vikram S. Advee2a78e32002-08-14 16:52:58 +0000153// Subsitute all occurrences of Value* oldVal with newVal in all operands
154// and all implicit refs. If defsOnly == true, substitute defs only.
155unsigned
156MachineInstr::substituteValue(const Value* oldVal, Value* newVal, bool defsOnly)
157{
158 unsigned numSubst = 0;
159
160 // Subsitute operands
161 for (MachineInstr::val_op_iterator O = begin(), E = end(); O != E; ++O)
162 if (*O == oldVal)
163 if (!defsOnly || O.isDef())
164 {
165 O.getMachineOperand().value = newVal;
166 ++numSubst;
167 }
168
169 // Subsitute implicit refs
Vikram S. Advea2bae302002-10-29 19:41:18 +0000170 for (unsigned i=0, N=getNumImplicitRefs(); i < N; ++i)
Chris Lattner27a08932002-10-22 23:16:21 +0000171 if (getImplicitRef(i) == oldVal)
Vikram S. Advee2a78e32002-08-14 16:52:58 +0000172 if (!defsOnly || implicitRefIsDefined(i))
173 {
Vikram S. Advea2bae302002-10-29 19:41:18 +0000174 getImplicitOp(i).value = newVal;
Vikram S. Advee2a78e32002-08-14 16:52:58 +0000175 ++numSubst;
176 }
177
178 return numSubst;
179}
180
181
Vikram S. Adve7a4be952002-07-08 22:38:45 +0000182void
183MachineInstr::dump() const
184{
185 cerr << " " << *this;
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000186}
187
Vikram S. Adve8c6936a2002-09-16 15:18:53 +0000188static inline std::ostream&
189OutputValue(std::ostream &os, const Value* val)
Vikram S. Adve93240fe2002-04-25 04:31:18 +0000190{
191 os << "(val ";
192 if (val && val->hasName())
Vikram S. Adve3bc9ef92002-07-10 21:45:04 +0000193 return os << val->getName() << ")";
Vikram S. Adve93240fe2002-04-25 04:31:18 +0000194 else
Vikram S. Adve3bc9ef92002-07-10 21:45:04 +0000195 return os << (void*) val << ")"; // print address only
Vikram S. Adve93240fe2002-04-25 04:31:18 +0000196}
197
Chris Lattner2a79a092002-10-30 00:58:19 +0000198static inline void OutputReg(std::ostream &os, unsigned RegNo,
199 const MRegisterInfo *MRI = 0) {
200 if (MRI) {
201 if (RegNo < MRegisterInfo::FirstVirtualRegister)
202 os << "%" << MRI->get(RegNo).Name;
203 else
204 os << "%reg" << RegNo;
205 } else
206 os << "%mreg(" << RegNo << ")";
Vikram S. Adve8c6936a2002-09-16 15:18:53 +0000207}
208
Chris Lattner10491642002-10-30 00:48:05 +0000209static void print(const MachineOperand &MO, std::ostream &OS,
210 const TargetMachine &TM) {
Chris Lattner2a79a092002-10-30 00:58:19 +0000211 const MRegisterInfo *MRI = TM.getRegisterInfo();
Chris Lattner10491642002-10-30 00:48:05 +0000212 bool CloseParen = true;
213 if (MO.opHiBits32())
214 OS << "%lm(";
215 else if (MO.opLoBits32())
216 OS << "%lo(";
217 else if (MO.opHiBits64())
218 OS << "%hh(";
219 else if (MO.opLoBits64())
220 OS << "%hm(";
221 else
222 CloseParen = false;
223
224 switch (MO.getType()) {
225 case MachineOperand::MO_VirtualRegister:
226 if (MO.getVRegValue()) {
227 OS << "%reg";
228 OutputValue(OS, MO.getVRegValue());
229 if (MO.hasAllocatedReg())
230 OS << "==";
231 }
232 if (MO.hasAllocatedReg())
Chris Lattner2a79a092002-10-30 00:58:19 +0000233 OutputReg(OS, MO.getAllocatedRegNum(), MRI);
Chris Lattner10491642002-10-30 00:48:05 +0000234 break;
235 case MachineOperand::MO_CCRegister:
236 OS << "%ccreg";
237 OutputValue(OS, MO.getVRegValue());
238 if (MO.hasAllocatedReg()) {
239 OS << "==";
Chris Lattner2a79a092002-10-30 00:58:19 +0000240 OutputReg(OS, MO.getAllocatedRegNum(), MRI);
Chris Lattner10491642002-10-30 00:48:05 +0000241 }
242 break;
243 case MachineOperand::MO_MachineRegister:
Chris Lattner2a79a092002-10-30 00:58:19 +0000244 OutputReg(OS, MO.getMachineRegNum(), MRI);
Chris Lattner10491642002-10-30 00:48:05 +0000245 break;
246 case MachineOperand::MO_SignExtendedImmed:
247 OS << (long)MO.getImmedValue();
248 break;
249 case MachineOperand::MO_UnextendedImmed:
250 OS << (long)MO.getImmedValue();
251 break;
252 case MachineOperand::MO_PCRelativeDisp: {
253 const Value* opVal = MO.getVRegValue();
254 bool isLabel = isa<Function>(opVal) || isa<BasicBlock>(opVal);
255 OS << "%disp(" << (isLabel? "label " : "addr-of-val ");
256 if (opVal->hasName())
257 OS << opVal->getName();
258 else
259 OS << (const void*) opVal;
260 OS << ")";
261 break;
262 }
Chris Lattner2109f502002-12-15 20:35:25 +0000263 case MachineOperand::MO_MachineBasicBlock:
264 OS << "bb<"
265 << ((Value*)MO.getMachineBasicBlock()->getBasicBlock())->getName()
266 << "," << (void*)MO.getMachineBasicBlock()->getBasicBlock() << ">";
267 break;
Chris Lattner10cb79b2002-12-28 20:37:37 +0000268 case MachineOperand::MO_FrameIndex:
269 OS << "<fi#" << MO.getFrameIndex() << ">";
270 break;
Chris Lattner10491642002-10-30 00:48:05 +0000271 default:
272 assert(0 && "Unrecognized operand type");
273 }
274
275 if (CloseParen)
276 OS << ")";
277}
278
Chris Lattneraf55be12002-11-17 23:22:13 +0000279void MachineInstr::print(std::ostream &OS, const TargetMachine &TM) const {
Chris Lattner6a592272002-10-30 01:55:38 +0000280 unsigned StartOp = 0;
Chris Lattner10491642002-10-30 00:48:05 +0000281
Chris Lattner6a592272002-10-30 01:55:38 +0000282 // Specialize printing if op#0 is definition
283 if (getNumOperands() && operandIsDefined(0)) {
284 ::print(getOperand(0), OS, TM);
285 OS << " = ";
286 ++StartOp; // Don't print this operand again!
287 }
288 OS << TM.getInstrInfo().getName(getOpcode());
289
290 for (unsigned i = StartOp, e = getNumOperands(); i != e; ++i) {
291 if (i != StartOp)
292 OS << ",";
293 OS << " ";
294 ::print(getOperand(i), OS, TM);
295
Chris Lattner10491642002-10-30 00:48:05 +0000296 if (operandIsDefinedAndUsed(i))
297 OS << "<def&use>";
298 else if (operandIsDefined(i))
299 OS << "<def>";
300 }
Chris Lattner6a592272002-10-30 01:55:38 +0000301
Chris Lattner10491642002-10-30 00:48:05 +0000302 // code for printing implict references
303 if (getNumImplicitRefs()) {
304 OS << "\tImplicitRefs: ";
305 for(unsigned i = 0, e = getNumImplicitRefs(); i != e; ++i) {
306 OS << "\t";
307 OutputValue(OS, getImplicitRef(i));
308 if (implicitRefIsDefinedAndUsed(i))
309 OS << "<def&use>";
310 else if (implicitRefIsDefined(i))
311 OS << "<def>";
312 }
313 }
314
315 OS << "\n";
316}
317
318
Chris Lattner697954c2002-01-20 22:54:45 +0000319std::ostream &operator<<(std::ostream& os, const MachineInstr& minstr)
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000320{
Chris Lattnerd9512ca2002-10-29 17:35:39 +0000321 os << TargetInstrDescriptors[minstr.opCode].Name;
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000322
Ruchira Sasanka8d243372001-11-14 20:05:23 +0000323 for (unsigned i=0, N=minstr.getNumOperands(); i < N; i++) {
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000324 os << "\t" << minstr.getOperand(i);
Vikram S. Adve7a4be952002-07-08 22:38:45 +0000325 if( minstr.operandIsDefined(i) )
326 os << "*";
327 if( minstr.operandIsDefinedAndUsed(i) )
Ruchira Sasanka07c70862001-11-15 20:46:40 +0000328 os << "*";
Ruchira Sasanka8d243372001-11-14 20:05:23 +0000329 }
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000330
Ruchira Sasanka69917e22001-10-18 22:40:02 +0000331 // code for printing implict references
Ruchira Sasanka69917e22001-10-18 22:40:02 +0000332 unsigned NumOfImpRefs = minstr.getNumImplicitRefs();
333 if( NumOfImpRefs > 0 ) {
Vikram S. Adve93240fe2002-04-25 04:31:18 +0000334 os << "\tImplicit: ";
Ruchira Sasanka69917e22001-10-18 22:40:02 +0000335 for(unsigned z=0; z < NumOfImpRefs; z++) {
Vikram S. Adve93240fe2002-04-25 04:31:18 +0000336 OutputValue(os, minstr.getImplicitRef(z));
Ruchira Sasanka8d243372001-11-14 20:05:23 +0000337 if( minstr.implicitRefIsDefined(z)) os << "*";
Vikram S. Adve7a4be952002-07-08 22:38:45 +0000338 if( minstr.implicitRefIsDefinedAndUsed(z)) os << "*";
Ruchira Sasanka07c70862001-11-15 20:46:40 +0000339 os << "\t";
Ruchira Sasanka69917e22001-10-18 22:40:02 +0000340 }
341 }
Vikram S. Adve93240fe2002-04-25 04:31:18 +0000342
Chris Lattner697954c2002-01-20 22:54:45 +0000343 return os << "\n";
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000344}
345
Chris Lattner10cb79b2002-12-28 20:37:37 +0000346std::ostream &operator<<(std::ostream &OS, const MachineOperand &MO)
Vikram S. Adve6e447182001-09-18 12:56:28 +0000347{
Chris Lattner2109f502002-12-15 20:35:25 +0000348 if (MO.opHiBits32())
Chris Lattner10cb79b2002-12-28 20:37:37 +0000349 OS << "%lm(";
Chris Lattner2109f502002-12-15 20:35:25 +0000350 else if (MO.opLoBits32())
Chris Lattner10cb79b2002-12-28 20:37:37 +0000351 OS << "%lo(";
Chris Lattner2109f502002-12-15 20:35:25 +0000352 else if (MO.opHiBits64())
Chris Lattner10cb79b2002-12-28 20:37:37 +0000353 OS << "%hh(";
Chris Lattner2109f502002-12-15 20:35:25 +0000354 else if (MO.opLoBits64())
Chris Lattner10cb79b2002-12-28 20:37:37 +0000355 OS << "%hm(";
Vikram S. Adve3bc9ef92002-07-10 21:45:04 +0000356
Chris Lattner2109f502002-12-15 20:35:25 +0000357 switch (MO.getType())
Vikram S. Adve6e447182001-09-18 12:56:28 +0000358 {
359 case MachineOperand::MO_VirtualRegister:
Chris Lattner10cb79b2002-12-28 20:37:37 +0000360 OS << "%reg";
361 OutputValue(OS, MO.getVRegValue());
Chris Lattner2109f502002-12-15 20:35:25 +0000362 if (MO.hasAllocatedReg()) {
Chris Lattner10cb79b2002-12-28 20:37:37 +0000363 OS << "==";
364 OutputReg(OS, MO.getAllocatedRegNum());
Chris Lattner10491642002-10-30 00:48:05 +0000365 }
Vikram S. Adve3bc9ef92002-07-10 21:45:04 +0000366 break;
Vikram S. Adve6e447182001-09-18 12:56:28 +0000367 case MachineOperand::MO_CCRegister:
Chris Lattner10cb79b2002-12-28 20:37:37 +0000368 OS << "%ccreg";
369 OutputValue(OS, MO.getVRegValue());
Chris Lattner2109f502002-12-15 20:35:25 +0000370 if (MO.hasAllocatedReg()) {
Chris Lattner10cb79b2002-12-28 20:37:37 +0000371 OS << "==";
372 OutputReg(OS, MO.getAllocatedRegNum());
Chris Lattner10491642002-10-30 00:48:05 +0000373 }
Vikram S. Adve3bc9ef92002-07-10 21:45:04 +0000374 break;
375 case MachineOperand::MO_MachineRegister:
Chris Lattner10cb79b2002-12-28 20:37:37 +0000376 OutputReg(OS, MO.getMachineRegNum());
Vikram S. Adve3bc9ef92002-07-10 21:45:04 +0000377 break;
Vikram S. Adve6e447182001-09-18 12:56:28 +0000378 case MachineOperand::MO_SignExtendedImmed:
Chris Lattner10cb79b2002-12-28 20:37:37 +0000379 OS << (long)MO.getImmedValue();
Vikram S. Adve3bc9ef92002-07-10 21:45:04 +0000380 break;
Vikram S. Adve6e447182001-09-18 12:56:28 +0000381 case MachineOperand::MO_UnextendedImmed:
Chris Lattner10cb79b2002-12-28 20:37:37 +0000382 OS << (long)MO.getImmedValue();
Vikram S. Adve3bc9ef92002-07-10 21:45:04 +0000383 break;
Vikram S. Adve6e447182001-09-18 12:56:28 +0000384 case MachineOperand::MO_PCRelativeDisp:
Vikram S. Advee949da52001-09-30 23:44:19 +0000385 {
Chris Lattner2109f502002-12-15 20:35:25 +0000386 const Value* opVal = MO.getVRegValue();
Chris Lattner4d669b52002-04-08 22:01:15 +0000387 bool isLabel = isa<Function>(opVal) || isa<BasicBlock>(opVal);
Chris Lattner10cb79b2002-12-28 20:37:37 +0000388 OS << "%disp(" << (isLabel? "label " : "addr-of-val ");
Vikram S. Adved9beb972001-11-12 14:19:47 +0000389 if (opVal->hasName())
Chris Lattner10cb79b2002-12-28 20:37:37 +0000390 OS << opVal->getName();
Vikram S. Adved9beb972001-11-12 14:19:47 +0000391 else
Chris Lattner10cb79b2002-12-28 20:37:37 +0000392 OS << (const void*) opVal;
393 OS << ")";
Vikram S. Adve3bc9ef92002-07-10 21:45:04 +0000394 break;
Vikram S. Advee949da52001-09-30 23:44:19 +0000395 }
Chris Lattner2109f502002-12-15 20:35:25 +0000396 case MachineOperand::MO_MachineBasicBlock:
Chris Lattner10cb79b2002-12-28 20:37:37 +0000397 OS << "bb<"
Chris Lattner2109f502002-12-15 20:35:25 +0000398 << ((Value*)MO.getMachineBasicBlock()->getBasicBlock())->getName()
399 << "," << (void*)MO.getMachineBasicBlock()->getBasicBlock() << ">";
400 break;
Chris Lattner10cb79b2002-12-28 20:37:37 +0000401 case MachineOperand::MO_FrameIndex:
402 OS << "<fi#" << MO.getFrameIndex() << ">";
403 break;
Vikram S. Adve6e447182001-09-18 12:56:28 +0000404 default:
405 assert(0 && "Unrecognized operand type");
406 break;
407 }
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000408
Chris Lattner2109f502002-12-15 20:35:25 +0000409 if (MO.flags &
Vikram S. Adve3bc9ef92002-07-10 21:45:04 +0000410 (MachineOperand::HIFLAG32 | MachineOperand::LOFLAG32 |
411 MachineOperand::HIFLAG64 | MachineOperand::LOFLAG64))
Chris Lattner10cb79b2002-12-28 20:37:37 +0000412 OS << ")";
Vikram S. Adve3bc9ef92002-07-10 21:45:04 +0000413
Chris Lattner10cb79b2002-12-28 20:37:37 +0000414 return OS;
Vikram S. Adve70bc4b52001-07-21 12:41:50 +0000415}