blob: 61ac823ee684331855a2ba0968329593678e92e4 [file] [log] [blame]
Chris Lattner72614082002-10-25 22:55:53 +00001//===-- X86/Printer.cpp - Convert X86 code to human readable rep. ---------===//
2//
3// This file contains a printer that converts from our internal representation
4// of LLVM code to a nice human readable form that is suitable for debuggging.
5//
6//===----------------------------------------------------------------------===//
7
8#include "X86.h"
Brian Gaeke6559bb92002-11-14 22:32:30 +00009#include "X86InstrInfo.h"
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000010#include "llvm/Pass.h"
Brian Gaeke6559bb92002-11-14 22:32:30 +000011#include "llvm/Function.h"
12#include "llvm/Target/TargetMachine.h"
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000013#include "llvm/CodeGen/MachineFunction.h"
Chris Lattnerdbb61c62002-11-17 22:53:13 +000014#include "llvm/CodeGen/MachineInstr.h"
Chris Lattner233ad712002-11-21 01:33:44 +000015#include "Support/Statistic.h"
Chris Lattner72614082002-10-25 22:55:53 +000016
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000017namespace {
18 struct Printer : public FunctionPass {
19 TargetMachine &TM;
20 std::ostream &O;
Chris Lattner72614082002-10-25 22:55:53 +000021
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000022 Printer(TargetMachine &tm, std::ostream &o) : TM(tm), O(o) {}
23
24 bool runOnFunction(Function &F);
25 };
26}
27
Chris Lattnerdbb61c62002-11-17 22:53:13 +000028/// createX86CodePrinterPass - Print out the specified machine code function to
29/// the specified stream. This function should work regardless of whether or
30/// not the function is in SSA form or not.
31///
32Pass *createX86CodePrinterPass(TargetMachine &TM, std::ostream &O) {
33 return new Printer(TM, O);
34}
35
36
Brian Gaeke6559bb92002-11-14 22:32:30 +000037/// runOnFunction - This uses the X86InstructionInfo::print method
38/// to print assembly for each instruction.
39bool Printer::runOnFunction (Function & F)
40{
41 static unsigned bbnumber = 0;
42 MachineFunction & MF = MachineFunction::get (&F);
43 const MachineInstrInfo & MII = TM.getInstrInfo ();
Brian Gaeke6559bb92002-11-14 22:32:30 +000044
Chris Lattner927dd092002-11-17 23:20:37 +000045 O << "; x86 printing only sorta implemented so far!\n";
Brian Gaeke6559bb92002-11-14 22:32:30 +000046
47 // Print out labels for the function.
48 O << "\t.globl\t" << F.getName () << "\n";
49 O << "\t.type\t" << F.getName () << ", @function\n";
50 O << F.getName () << ":\n";
51
52 // Print out code for the function.
53 for (MachineFunction::const_iterator bb_i = MF.begin (), bb_e = MF.end ();
54 bb_i != bb_e; ++bb_i)
55 {
56 // Print a label for the basic block.
57 O << ".BB" << bbnumber++ << ":\n";
58 for (MachineBasicBlock::const_iterator i_i = bb_i->begin (), i_e =
59 bb_i->end (); i_i != i_e; ++i_i)
60 {
61 // Print the assembly for the instruction.
62 O << "\t";
Chris Lattner927dd092002-11-17 23:20:37 +000063 MII.print(*i_i, O, TM);
Brian Gaeke6559bb92002-11-14 22:32:30 +000064 }
65 }
66
67 // We didn't modify anything.
Chris Lattnerb4f68ed2002-10-29 22:37:54 +000068 return false;
69}
70
Chris Lattner3d3067b2002-11-21 20:44:15 +000071static bool isReg(const MachineOperand &MO) {
72 return MO.getType() == MachineOperand::MO_VirtualRegister ||
73 MO.getType() == MachineOperand::MO_MachineRegister;
74}
75
76static bool isImmediate(const MachineOperand &MO) {
77 return MO.getType() == MachineOperand::MO_SignExtendedImmed ||
78 MO.getType() == MachineOperand::MO_UnextendedImmed;
79}
80
81static bool isScale(const MachineOperand &MO) {
82 return isImmediate(MO) &&
83 (MO.getImmedValue() == 1 || MO.getImmedValue() == 2 ||
84 MO.getImmedValue() == 4 || MO.getImmedValue() == 8);
85}
86
87static bool isMem(const MachineInstr *MI, unsigned Op) {
88 return Op+4 <= MI->getNumOperands() &&
89 isReg(MI->getOperand(Op )) && isScale(MI->getOperand(Op+1)) &&
90 isReg(MI->getOperand(Op+2)) && isImmediate(MI->getOperand(Op+3));
91}
92
Chris Lattnerf9f60882002-11-18 06:56:51 +000093static void printOp(std::ostream &O, const MachineOperand &MO,
94 const MRegisterInfo &RI) {
95 switch (MO.getType()) {
96 case MachineOperand::MO_VirtualRegister:
Misha Brukmane1f0d812002-11-20 18:56:41 +000097 case MachineOperand::MO_MachineRegister:
Chris Lattnerf9f60882002-11-18 06:56:51 +000098 if (MO.getReg() < MRegisterInfo::FirstVirtualRegister)
99 O << RI.get(MO.getReg()).Name;
100 else
101 O << "%reg" << MO.getReg();
102 return;
Chris Lattner77875d82002-11-21 02:00:20 +0000103
104 case MachineOperand::MO_SignExtendedImmed:
105 case MachineOperand::MO_UnextendedImmed:
106 O << (int)MO.getImmedValue();
107 return;
Chris Lattnerf9f60882002-11-18 06:56:51 +0000108 default:
109 O << "<unknown op ty>"; return;
110 }
111}
112
Chris Lattner3d3067b2002-11-21 20:44:15 +0000113static void printMemReference(std::ostream &O, const MachineInstr *MI,
114 unsigned Op, const MRegisterInfo &RI) {
115 assert(isMem(MI, Op) && "Invalid memory reference!");
116 const MachineOperand &BaseReg = MI->getOperand(Op);
117 const MachineOperand &Scale = MI->getOperand(Op+1);
118 const MachineOperand &IndexReg = MI->getOperand(Op+2);
119 const MachineOperand &Disp = MI->getOperand(Op+3);
120
121 O << "[";
122 bool NeedPlus = false;
123 if (BaseReg.getReg()) {
124 printOp(O, BaseReg, RI);
125 NeedPlus = true;
126 }
127
128 if (IndexReg.getReg()) {
129 if (NeedPlus) O << " + ";
130 if (IndexReg.getImmedValue() != 1)
131 O << IndexReg.getImmedValue() << "*";
132 printOp(O, IndexReg, RI);
133 NeedPlus = true;
134 }
135
136 if (Disp.getImmedValue()) {
137 if (NeedPlus) O << " + ";
138 printOp(O, Disp, RI);
139 }
140 O << "]";
141}
142
Chris Lattnerf9f60882002-11-18 06:56:51 +0000143static inline void toHexDigit(std::ostream &O, unsigned char V) {
144 if (V >= 10)
145 O << (char)('A'+V-10);
146 else
147 O << (char)('0'+V);
148}
149
150static std::ostream &toHex(std::ostream &O, unsigned char V) {
151 toHexDigit(O, V >> 4);
152 toHexDigit(O, V & 0xF);
153 return O;
154}
155
Chris Lattner77875d82002-11-21 02:00:20 +0000156static std::ostream &emitConstant(std::ostream &O, unsigned Val, unsigned Size){
157 // Output the constant in little endian byte order...
158 for (unsigned i = 0; i != Size; ++i) {
159 toHex(O, Val) << " ";
160 Val >>= 8;
161 }
162 return O;
163}
164
Chris Lattner3d3067b2002-11-21 20:44:15 +0000165namespace N86 { // Native X86 Register numbers...
166 enum {
167 EAX = 0, ECX = 1, EDX = 2, EBX = 3, ESP = 4, EBP = 5, ESI = 6, EDI = 7
168 };
Chris Lattner644e1ab2002-11-21 00:30:01 +0000169}
170
171
Chris Lattner233ad712002-11-21 01:33:44 +0000172// getX86RegNum - This function maps LLVM register identifiers to their X86
173// specific numbering, which is used in various places encoding instructions.
174//
175static unsigned getX86RegNum(unsigned RegNo) {
176 switch(RegNo) {
Chris Lattner3d3067b2002-11-21 20:44:15 +0000177 case X86::EAX: case X86::AX: case X86::AL: return N86::EAX;
178 case X86::ECX: case X86::CX: case X86::CL: return N86::ECX;
179 case X86::EDX: case X86::DX: case X86::DL: return N86::EDX;
180 case X86::EBX: case X86::BX: case X86::BL: return N86::EBX;
181 case X86::ESP: case X86::SP: case X86::AH: return N86::ESP;
182 case X86::EBP: case X86::BP: case X86::CH: return N86::EBP;
183 case X86::ESI: case X86::SI: case X86::DH: return N86::ESI;
184 case X86::EDI: case X86::DI: case X86::BH: return N86::EDI;
Chris Lattner233ad712002-11-21 01:33:44 +0000185 default:
186 assert(RegNo >= MRegisterInfo::FirstVirtualRegister &&
187 "Unknown physical register!");
188 DEBUG(std::cerr << "Register allocator hasn't allocated " << RegNo
189 << " correctly yet!\n");
190 return 0;
191 }
192}
193
194inline static unsigned char ModRMByte(unsigned Mod, unsigned RegOpcode,
195 unsigned RM) {
196 assert(Mod < 4 && RegOpcode < 8 && RM < 8 && "ModRM Fields out of range!");
197 return RM | (RegOpcode << 3) | (Mod << 6);
198}
199
Chris Lattner3d3067b2002-11-21 20:44:15 +0000200static void emitRegModRMByte(std::ostream &O, unsigned ModRMReg,
201 unsigned RegOpcodeField) {
202 toHex(O, ModRMByte(3, RegOpcodeField, getX86RegNum(ModRMReg)));
203}
204
205inline static void emitSIBByte(std::ostream &O, unsigned SS, unsigned Index,
206 unsigned Base) {
207 // SIB byte is in the same format as the ModRMByte...
208 toHex(O, ModRMByte(SS, Index, Base));
209}
210
211static bool isDisp8(int Value) {
212 return Value == (signed char)Value;
213}
214
215static void emitMemModRMByte(std::ostream &O, const MachineInstr *MI,
216 unsigned Op, unsigned RegOpcodeField) {
217 assert(isMem(MI, Op) && "Invalid memory reference!");
218 const MachineOperand &BaseReg = MI->getOperand(Op);
219 const MachineOperand &Scale = MI->getOperand(Op+1);
220 const MachineOperand &IndexReg = MI->getOperand(Op+2);
221 const MachineOperand &Disp = MI->getOperand(Op+3);
222
223 // Is a SIB byte needed?
224 if (IndexReg.getReg() == 0 && BaseReg.getReg() != X86::ESP) {
225 if (BaseReg.getReg() == 0) { // Just a displacement?
226 // Emit special case [disp32] encoding
227 toHex(O, ModRMByte(0, RegOpcodeField, 5));
228 emitConstant(O, Disp.getImmedValue(), 4);
229 } else {
230 unsigned BaseRegNo = getX86RegNum(BaseReg.getReg());
231 if (Disp.getImmedValue() == 0 && BaseRegNo != N86::EBP) {
232 // Emit simple indirect register encoding... [EAX] f.e.
233 toHex(O, ModRMByte(0, RegOpcodeField, BaseRegNo));
234 } else if (isDisp8(Disp.getImmedValue())) {
235 // Emit the disp8 encoding... [REG+disp8]
236 toHex(O, ModRMByte(1, RegOpcodeField, BaseRegNo));
237 emitConstant(O, Disp.getImmedValue(), 1);
238 } else {
239 // Emit the most general non-SIB encoding: [REG+disp32]
240 toHex(O, ModRMByte(1, RegOpcodeField, BaseRegNo));
241 emitConstant(O, Disp.getImmedValue(), 4);
242 }
243 }
244
245 } else { // We need a SIB byte, so start by outputting the ModR/M byte first
246 assert(IndexReg.getReg() != X86::ESP && "Cannot use ESP as index reg!");
247
248 bool ForceDisp32 = false;
249 if (BaseReg.getReg() == 0) {
250 // If there is no base register, we emit the special case SIB byte with
251 // MOD=0, BASE=5, to JUST get the index, scale, and displacement.
252 toHex(O, ModRMByte(0, RegOpcodeField, 4));
253 ForceDisp32 = true;
254 } else if (Disp.getImmedValue() == 0) {
255 // Emit no displacement ModR/M byte
256 toHex(O, ModRMByte(0, RegOpcodeField, 4));
257 } else if (isDisp8(Disp.getImmedValue())) {
258 // Emit the disp8 encoding...
259 toHex(O, ModRMByte(1, RegOpcodeField, 4));
260 } else {
261 // Emit the normal disp32 encoding...
262 toHex(O, ModRMByte(2, RegOpcodeField, 4));
263 }
264
265 // Calculate what the SS field value should be...
266 static const unsigned SSTable[] = { ~0, 0, 1, ~0, 2, ~0, ~0, ~0, 3 };
267 unsigned SS = SSTable[Scale.getImmedValue()];
268
269 if (BaseReg.getReg() == 0) {
270 // Handle the SIB byte for the case where there is no base. The
271 // displacement has already been output.
272 assert(IndexReg.getReg() && "Index register must be specified!");
273 emitSIBByte(O, SS, getX86RegNum(IndexReg.getReg()), 5);
274 } else {
275 unsigned BaseRegNo = getX86RegNum(BaseReg.getReg());
276 unsigned IndexRegNo = getX86RegNum(IndexReg.getReg());
277 emitSIBByte(O, SS, IndexRegNo, BaseRegNo);
278 }
279
280 // Do we need to output a displacement?
281 if (Disp.getImmedValue() != 0 || ForceDisp32) {
282 if (!ForceDisp32 && isDisp8(Disp.getImmedValue()))
283 emitConstant(O, Disp.getImmedValue(), 1);
284 else
285 emitConstant(O, Disp.getImmedValue(), 4);
286 }
287 }
Chris Lattner233ad712002-11-21 01:33:44 +0000288}
289
290
Chris Lattnerdbb61c62002-11-17 22:53:13 +0000291// print - Print out an x86 instruction in intel syntax
Chris Lattner927dd092002-11-17 23:20:37 +0000292void X86InstrInfo::print(const MachineInstr *MI, std::ostream &O,
293 const TargetMachine &TM) const {
Chris Lattnerf9f60882002-11-18 06:56:51 +0000294 unsigned Opcode = MI->getOpcode();
295 const MachineInstrDescriptor &Desc = get(Opcode);
296
Chris Lattner233ad712002-11-21 01:33:44 +0000297 // Print instruction prefixes if neccesary
298
299 if (Desc.TSFlags & X86II::OpSize) O << "66 "; // Operand size...
300 if (Desc.TSFlags & X86II::TB) O << "0F "; // Two-byte opcode prefix
Chris Lattnerf9f60882002-11-18 06:56:51 +0000301
302 switch (Desc.TSFlags & X86II::FormMask) {
303 case X86II::OtherFrm:
Chris Lattner77875d82002-11-21 02:00:20 +0000304 O << "\t\t\t";
Chris Lattnerf9f60882002-11-18 06:56:51 +0000305 O << "-"; MI->print(O, TM);
306 break;
307 case X86II::RawFrm:
Chris Lattner77875d82002-11-21 02:00:20 +0000308 toHex(O, getBaseOpcodeFor(Opcode));
309 O << "\n\t\t\t\t";
Chris Lattnerf9f60882002-11-18 06:56:51 +0000310 O << getName(MI->getOpCode()) << " ";
311
312 for (unsigned i = 0, e = MI->getNumOperands(); i != e; ++i) {
313 if (i) O << ", ";
314 printOp(O, MI->getOperand(i), RI);
315 }
316 O << "\n";
317 return;
318
319
Chris Lattner77875d82002-11-21 02:00:20 +0000320 case X86II::AddRegFrm: {
321 // There are currently two forms of acceptable AddRegFrm instructions.
322 // Either the instruction JUST takes a single register (like inc, dec, etc),
323 // or it takes a register and an immediate of the same size as the register
324 // (move immediate f.e.).
325 //
326 assert(isReg(MI->getOperand(0)) &&
327 (MI->getNumOperands() == 1 ||
328 (MI->getNumOperands() == 2 && isImmediate(MI->getOperand(1)))) &&
329 "Illegal form for AddRegFrm instruction!");
Chris Lattnerf9f60882002-11-18 06:56:51 +0000330
Chris Lattner77875d82002-11-21 02:00:20 +0000331 unsigned Reg = MI->getOperand(0).getReg();
332 toHex(O, getBaseOpcodeFor(Opcode) + getX86RegNum(Reg)) << " ";
333
334 if (MI->getNumOperands() == 2) {
335 unsigned Size = 4;
336 emitConstant(O, MI->getOperand(1).getImmedValue(), Size);
337 }
338
339 O << "\n\t\t\t\t";
340 O << getName(MI->getOpCode()) << " ";
341 printOp(O, MI->getOperand(0), RI);
342 if (MI->getNumOperands() == 2) {
343 O << ", ";
Chris Lattner675dd2c2002-11-21 17:09:01 +0000344 printOp(O, MI->getOperand(1), RI);
Chris Lattner77875d82002-11-21 02:00:20 +0000345 }
346 O << "\n";
347 return;
348 }
Chris Lattner233ad712002-11-21 01:33:44 +0000349 case X86II::MRMDestReg: {
Chris Lattnerf9f60882002-11-18 06:56:51 +0000350 // There are two acceptable forms of MRMDestReg instructions, those with 3
351 // and 2 operands:
352 //
353 // 3 Operands: in this form, the first two registers (the destination, and
354 // the first operand) should be the same, post register allocation. The 3rd
355 // operand is an additional input. This should be for things like add
356 // instructions.
357 //
358 // 2 Operands: this is for things like mov that do not read a second input
359 //
Chris Lattner644e1ab2002-11-21 00:30:01 +0000360 assert(isReg(MI->getOperand(0)) &&
361 (MI->getNumOperands() == 2 ||
362 (MI->getNumOperands() == 3 && isReg(MI->getOperand(1)))) &&
363 isReg(MI->getOperand(MI->getNumOperands()-1))
Misha Brukmane1f0d812002-11-20 18:56:41 +0000364 && "Bad format for MRMDestReg!");
Chris Lattnerf9f60882002-11-18 06:56:51 +0000365 if (MI->getNumOperands() == 3 &&
366 MI->getOperand(0).getReg() != MI->getOperand(1).getReg())
367 O << "**";
368
Chris Lattner233ad712002-11-21 01:33:44 +0000369 toHex(O, getBaseOpcodeFor(Opcode)) << " ";
370 unsigned ModRMReg = MI->getOperand(0).getReg();
371 unsigned ExtraReg = MI->getOperand(MI->getNumOperands()-1).getReg();
Chris Lattner3d3067b2002-11-21 20:44:15 +0000372 emitRegModRMByte(O, ModRMReg, getX86RegNum(ExtraReg));
Chris Lattner233ad712002-11-21 01:33:44 +0000373
Chris Lattner77875d82002-11-21 02:00:20 +0000374 O << "\n\t\t\t\t";
Chris Lattnerf9f60882002-11-18 06:56:51 +0000375 O << getName(MI->getOpCode()) << " ";
376 printOp(O, MI->getOperand(0), RI);
377 O << ", ";
378 printOp(O, MI->getOperand(MI->getNumOperands()-1), RI);
379 O << "\n";
380 return;
Chris Lattner233ad712002-11-21 01:33:44 +0000381 }
382 case X86II::MRMSrcReg: {
Chris Lattner644e1ab2002-11-21 00:30:01 +0000383 // There is a two forms that are acceptable for MRMSrcReg instructions,
384 // those with 3 and 2 operands:
385 //
386 // 3 Operands: in this form, the last register (the second input) is the
387 // ModR/M input. The first two operands should be the same, post register
388 // allocation. This is for things like: add r32, r/m32
389 //
390 // 2 Operands: this is for things like mov that do not read a second input
391 //
392 assert(isReg(MI->getOperand(0)) &&
393 isReg(MI->getOperand(1)) &&
394 (MI->getNumOperands() == 2 ||
395 (MI->getNumOperands() == 3 && isReg(MI->getOperand(2))))
396 && "Bad format for MRMDestReg!");
397 if (MI->getNumOperands() == 3 &&
398 MI->getOperand(0).getReg() != MI->getOperand(1).getReg())
399 O << "**";
400
Chris Lattner233ad712002-11-21 01:33:44 +0000401 toHex(O, getBaseOpcodeFor(Opcode)) << " ";
402 unsigned ModRMReg = MI->getOperand(MI->getNumOperands()-1).getReg();
403 unsigned ExtraReg = MI->getOperand(0).getReg();
Chris Lattner3d3067b2002-11-21 20:44:15 +0000404 emitRegModRMByte(O, ModRMReg, getX86RegNum(ExtraReg));
Chris Lattner233ad712002-11-21 01:33:44 +0000405
Chris Lattner77875d82002-11-21 02:00:20 +0000406 O << "\n\t\t\t\t";
Chris Lattner644e1ab2002-11-21 00:30:01 +0000407 O << getName(MI->getOpCode()) << " ";
408 printOp(O, MI->getOperand(0), RI);
409 O << ", ";
410 printOp(O, MI->getOperand(MI->getNumOperands()-1), RI);
411 O << "\n";
412 return;
Chris Lattner233ad712002-11-21 01:33:44 +0000413 }
Chris Lattner675dd2c2002-11-21 17:09:01 +0000414
Chris Lattner3d3067b2002-11-21 20:44:15 +0000415 case X86II::MRMSrcMem: {
416 // These instructions are the same as MRMSrcReg, but instead of having a
417 // register reference for the mod/rm field, it's a memory reference.
418
419 //I(MOVmr8 , "movb", 0x8A, 0, X86II::MRMSrcMem)
420 // R8 = [mem] 8A/r
421
422 assert(isReg(MI->getOperand(0)) &&
423 (MI->getNumOperands() == 1+4 && isMem(MI, 1)) ||
424 (MI->getNumOperands() == 2+4 && isReg(MI->getOperand(1)) &&
425 isMem(MI, 2))
426 && "Bad format for MRMDestReg!");
427 if (MI->getNumOperands() == 2+4 &&
428 MI->getOperand(0).getReg() != MI->getOperand(1).getReg())
429 O << "**";
430
431 toHex(O, getBaseOpcodeFor(Opcode)) << " ";
432 unsigned ExtraReg = MI->getOperand(0).getReg();
433 emitMemModRMByte(O, MI, MI->getNumOperands()-4, getX86RegNum(ExtraReg));
434
435 O << "\n\t\t\t\t";
436 O << getName(MI->getOpCode()) << " ";
437 printOp(O, MI->getOperand(0), RI);
438 O << ", <SIZE> PTR ";
439 printMemReference(O, MI, MI->getNumOperands()-4, RI);
440 O << "\n";
441 return;
442 }
443
Chris Lattner675dd2c2002-11-21 17:09:01 +0000444 case X86II::MRMS0r: case X86II::MRMS1r:
445 case X86II::MRMS2r: case X86II::MRMS3r:
446 case X86II::MRMS4r: case X86II::MRMS5r:
447 case X86II::MRMS6r: case X86II::MRMS7r: {
448 unsigned ExtraField = (Desc.TSFlags & X86II::FormMask)-X86II::MRMS0r;
449
450 // In this form, the following are valid formats:
451 // 1. sete r
452 // 2. shl rdest, rinput <implicit CL or 1>
453 // 3. sbb rdest, rinput, immediate [rdest = rinput]
454 //
455 assert(MI->getNumOperands() > 0 && MI->getNumOperands() < 4 &&
456 isReg(MI->getOperand(0)) && "Bad MRMSxR format!");
457 assert((MI->getNumOperands() < 2 || isReg(MI->getOperand(1))) &&
458 "Bad MRMSxR format!");
459 assert((MI->getNumOperands() < 3 || isImmediate(MI->getOperand(2))) &&
460 "Bad MRMSxR format!");
461
462 if (MI->getNumOperands() > 1 &&
463 MI->getOperand(0).getReg() != MI->getOperand(1).getReg())
464 O << "**";
465
466 toHex(O, getBaseOpcodeFor(Opcode)) << " ";
Chris Lattner3d3067b2002-11-21 20:44:15 +0000467 emitRegModRMByte(O, MI->getOperand(0).getReg(), ExtraField);
Chris Lattner675dd2c2002-11-21 17:09:01 +0000468
469 if (MI->getNumOperands() == 3) {
470 unsigned Size = 4;
471 emitConstant(O, MI->getOperand(1).getImmedValue(), Size);
472 }
473
474 O << "\n\t\t\t\t";
475 O << getName(MI->getOpCode()) << " ";
476 printOp(O, MI->getOperand(0), RI);
477 if (MI->getNumOperands() == 3) {
478 O << ", ";
479 printOp(O, MI->getOperand(2), RI);
480 }
481 O << "\n";
482
483 return;
484 }
485
Chris Lattner644e1ab2002-11-21 00:30:01 +0000486 case X86II::MRMDestMem:
Chris Lattnerf9f60882002-11-18 06:56:51 +0000487 default:
Chris Lattner77875d82002-11-21 02:00:20 +0000488 O << "\t\t\t-"; MI->print(O, TM); break;
Chris Lattnerf9f60882002-11-18 06:56:51 +0000489 }
Chris Lattner72614082002-10-25 22:55:53 +0000490}