blob: b17cde18de28a2a8e4ed58c66a6520274bcdab7f [file] [log] [blame]
Chris Lattnerb36cbd02005-07-01 22:44:09 +00001//===-- X86ATTAsmPrinter.cpp - Convert X86 LLVM code to Intel assembly ----===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file contains a printer that converts from our internal representation
11// of machine-dependent LLVM code to AT&T format assembly
12// language. This printer is the output mechanism used by `llc'.
13//
14//===----------------------------------------------------------------------===//
15
16#include "X86ATTAsmPrinter.h"
17#include "X86.h"
18#include "X86TargetMachine.h"
Jim Laskeya0f3d172006-09-07 22:06:40 +000019#include "X86TargetAsmInfo.h"
Chris Lattnerb36cbd02005-07-01 22:44:09 +000020#include "llvm/Module.h"
21#include "llvm/Support/Mangler.h"
Jim Laskeya0f3d172006-09-07 22:06:40 +000022#include "llvm/Target/TargetAsmInfo.h"
Evan Cheng7ccced62006-02-18 00:15:05 +000023#include "llvm/Target/TargetOptions.h"
Chris Lattner2c2c6c62006-01-22 23:41:00 +000024#include <iostream>
Chris Lattnerb36cbd02005-07-01 22:44:09 +000025using namespace llvm;
Chris Lattnerb36cbd02005-07-01 22:44:09 +000026
27/// runOnMachineFunction - This uses the printMachineInstruction()
28/// method to print assembly for each instruction.
29///
30bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
Jim Laskeyea348582006-07-27 02:05:13 +000031 if (Subtarget->isTargetDarwin()) {
Jim Laskeye29c2f52006-07-19 11:54:50 +000032 // Let PassManager know we need debug information and relay
33 // the MachineDebugInfo address on to DwarfWriter.
34 DW.SetDebugInfo(&getAnalysis<MachineDebugInfo>());
35 }
Evan Cheng3c992d22006-03-07 02:02:57 +000036
Chris Lattner8b8b9512005-11-21 07:51:23 +000037 SetupMachineFunction(MF);
Chris Lattnerb36cbd02005-07-01 22:44:09 +000038 O << "\n\n";
39
40 // Print out constants referenced by the function
Chris Lattnerd939f6c2005-11-21 08:32:23 +000041 EmitConstantPool(MF.getConstantPool());
Chris Lattnerb36cbd02005-07-01 22:44:09 +000042
43 // Print out labels for the function.
Evan Cheng2338c5c2006-02-07 08:38:37 +000044 const Function *F = MF.getFunction();
45 switch (F->getLinkage()) {
46 default: assert(0 && "Unknown linkage type!");
47 case Function::InternalLinkage: // Symbols default to internal.
Jim Laskey563321a2006-09-06 18:34:40 +000048 SwitchToTextSection(TAI->getTextSection(), F);
Evan Cheng2338c5c2006-02-07 08:38:37 +000049 EmitAlignment(4, F); // FIXME: This should be parameterized somewhere.
50 break;
51 case Function::ExternalLinkage:
Jim Laskey563321a2006-09-06 18:34:40 +000052 SwitchToTextSection(TAI->getTextSection(), F);
Evan Cheng2338c5c2006-02-07 08:38:37 +000053 EmitAlignment(4, F); // FIXME: This should be parameterized somewhere.
Chris Lattner272f9982005-12-16 00:07:30 +000054 O << "\t.globl\t" << CurrentFnName << "\n";
Evan Cheng2338c5c2006-02-07 08:38:37 +000055 break;
56 case Function::WeakLinkage:
57 case Function::LinkOnceLinkage:
Jim Laskeyea348582006-07-27 02:05:13 +000058 if (Subtarget->isTargetDarwin()) {
Chris Lattner4632d7a2006-05-09 04:59:56 +000059 SwitchToTextSection(
60 ".section __TEXT,__textcoal_nt,coalesced,pure_instructions", F);
Evan Chengf1616da2006-02-22 23:59:57 +000061 O << "\t.globl\t" << CurrentFnName << "\n";
Evan Cheng2338c5c2006-02-07 08:38:37 +000062 O << "\t.weak_definition\t" << CurrentFnName << "\n";
Evan Cheng932ad512006-05-25 21:59:08 +000063 } else if (Subtarget->TargetType == X86Subtarget::isCygwin) {
64 EmitAlignment(4, F); // FIXME: This should be parameterized somewhere.
65 O << "\t.section\t.llvm.linkonce.t." << CurrentFnName
66 << ",\"ax\"\n";
67 SwitchToTextSection("", F);
68 O << "\t.weak " << CurrentFnName << "\n";
Evan Cheng2338c5c2006-02-07 08:38:37 +000069 } else {
70 EmitAlignment(4, F); // FIXME: This should be parameterized somewhere.
71 O << "\t.section\t.llvm.linkonce.t." << CurrentFnName
72 << ",\"ax\",@progbits\n";
Chris Lattner4632d7a2006-05-09 04:59:56 +000073 SwitchToTextSection("", F);
Evan Cheng2338c5c2006-02-07 08:38:37 +000074 O << "\t.weak " << CurrentFnName << "\n";
75 }
76 break;
77 }
Chris Lattnerb36cbd02005-07-01 22:44:09 +000078 O << CurrentFnName << ":\n";
79
Jim Laskeyea348582006-07-27 02:05:13 +000080 if (Subtarget->isTargetDarwin()) {
Jim Laskey6b92b8e2006-04-07 20:44:42 +000081 // Emit pre-function debug information.
Jim Laskey89d67fa2006-06-23 12:51:53 +000082 DW.BeginFunction(&MF);
Jim Laskey6b92b8e2006-04-07 20:44:42 +000083 }
84
Chris Lattnerb36cbd02005-07-01 22:44:09 +000085 // Print out code for the function.
86 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
87 I != E; ++I) {
88 // Print a label for the basic block.
Nate Begemancdf38c42006-05-02 05:37:32 +000089 if (I->pred_begin() != I->pred_end()) {
90 printBasicBlockLabel(I, true);
91 O << '\n';
92 }
Chris Lattnerb36cbd02005-07-01 22:44:09 +000093 for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
94 II != E; ++II) {
95 // Print the assembly for the instruction.
96 O << "\t";
97 printMachineInstruction(II);
98 }
99 }
Evan Cheng67afece2006-08-28 22:14:16 +0000100
101 // Print out jump tables referenced by the function
102 // Mac OS X requires at least one non-local (e.g. L1) labels before local
103 // lables that are used in jump table expressions (e.g. LBB1_1-LJT1_0).
104 EmitJumpTableInfo(MF.getJumpTableInfo());
105
Jim Laskey563321a2006-09-06 18:34:40 +0000106 if (TAI->hasDotTypeDotSizeDirective())
Nate Begeman73213f62005-07-12 01:37:28 +0000107 O << "\t.size " << CurrentFnName << ", .-" << CurrentFnName << "\n";
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000108
Jim Laskeyea348582006-07-27 02:05:13 +0000109 if (Subtarget->isTargetDarwin()) {
Evan Chengd5948812006-03-07 02:23:26 +0000110 // Emit post-function debug information.
Jim Laskey99db0442006-03-23 18:09:44 +0000111 DW.EndFunction();
Evan Chengd5948812006-03-07 02:23:26 +0000112 }
Evan Cheng3c992d22006-03-07 02:02:57 +0000113
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000114 // We didn't modify anything.
115 return false;
116}
117
Chris Lattnera3b8c572006-02-06 23:41:19 +0000118void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
119 const char *Modifier) {
120 const MachineOperand &MO = MI->getOperand(OpNo);
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000121 const MRegisterInfo &RI = *TM.getRegisterInfo();
122 switch (MO.getType()) {
Evan Cheng8f7f7122006-05-05 05:40:20 +0000123 case MachineOperand::MO_Register: {
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000124 assert(MRegisterInfo::isPhysicalRegister(MO.getReg()) &&
125 "Virtual registers should not make it this far!");
126 O << '%';
Evan Cheng8f7f7122006-05-05 05:40:20 +0000127 unsigned Reg = MO.getReg();
Evan Chengcbe70e12006-05-31 22:34:26 +0000128 if (Modifier && strncmp(Modifier, "subreg", strlen("subreg")) == 0) {
Evan Cheng25ab6902006-09-08 06:48:29 +0000129 MVT::ValueType VT = (strcmp(Modifier+6,"64") == 0) ?
130 MVT::i64 : ((strcmp(Modifier+6, "32") == 0) ? MVT::i32 :
131 ((strcmp(Modifier+6,"16") == 0) ? MVT::i16 : MVT::i8));
Evan Cheng8f7f7122006-05-05 05:40:20 +0000132 Reg = getX86SubSuperRegister(Reg, VT);
133 }
134 for (const char *Name = RI.get(Reg).Name; *Name; ++Name)
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000135 O << (char)tolower(*Name);
136 return;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000137 }
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000138
Chris Lattner63b3d712006-05-04 17:21:20 +0000139 case MachineOperand::MO_Immediate:
Evan Cheng3c992d22006-03-07 02:02:57 +0000140 if (!Modifier || strcmp(Modifier, "debug") != 0)
141 O << '$';
Evan Cheng138a24e2006-05-26 08:04:31 +0000142 O << MO.getImmedValue();
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000143 return;
Nate Begeman37efe672006-04-22 18:53:45 +0000144 case MachineOperand::MO_MachineBasicBlock:
145 printBasicBlockLabel(MO.getMachineBasicBlock());
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000146 return;
Nate Begeman37efe672006-04-22 18:53:45 +0000147 case MachineOperand::MO_JumpTableIndex: {
148 bool isMemOp = Modifier && !strcmp(Modifier, "mem");
149 if (!isMemOp) O << '$';
Jim Laskey563321a2006-09-06 18:34:40 +0000150 O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() << "_"
Nate Begeman37efe672006-04-22 18:53:45 +0000151 << MO.getJumpTableIndex();
Evan Cheng25ab6902006-09-08 06:48:29 +0000152 if (X86PICStyle == PICStyle::Stub &&
Nate Begeman2f1ae882006-07-27 01:13:04 +0000153 TM.getRelocationModel() == Reloc::PIC_)
154 O << "-\"L" << getFunctionNumber() << "$pb\"";
Evan Cheng25ab6902006-09-08 06:48:29 +0000155 if (Subtarget->is64Bit())
156 O << "(%rip)";
Nate Begeman37efe672006-04-22 18:53:45 +0000157 return;
158 }
Evan Chenga09bd812006-02-26 08:28:12 +0000159 case MachineOperand::MO_ConstantPoolIndex: {
160 bool isMemOp = Modifier && !strcmp(Modifier, "mem");
161 if (!isMemOp) O << '$';
Jim Laskey563321a2006-09-06 18:34:40 +0000162 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
Evan Chenga09bd812006-02-26 08:28:12 +0000163 << MO.getConstantPoolIndex();
Evan Cheng25ab6902006-09-08 06:48:29 +0000164 if (X86PICStyle == PICStyle::Stub &&
Chris Lattner35d86fe2006-07-26 21:12:04 +0000165 TM.getRelocationModel() == Reloc::PIC_)
Evan Chenga09bd812006-02-26 08:28:12 +0000166 O << "-\"L" << getFunctionNumber() << "$pb\"";
167 int Offset = MO.getOffset();
168 if (Offset > 0)
169 O << "+" << Offset;
170 else if (Offset < 0)
171 O << Offset;
Evan Cheng25ab6902006-09-08 06:48:29 +0000172
173 if (Subtarget->is64Bit())
174 O << "(%rip)";
Evan Chenga09bd812006-02-26 08:28:12 +0000175 return;
176 }
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000177 case MachineOperand::MO_GlobalAddress: {
Chris Lattnera3b8c572006-02-06 23:41:19 +0000178 bool isCallOp = Modifier && !strcmp(Modifier, "call");
Evan Cheng2338c5c2006-02-07 08:38:37 +0000179 bool isMemOp = Modifier && !strcmp(Modifier, "mem");
Evan Cheng7ccced62006-02-18 00:15:05 +0000180 if (!isMemOp && !isCallOp) O << '$';
Evan Cheng25ab6902006-09-08 06:48:29 +0000181
182 GlobalValue *GV = MO.getGlobal();
183 std::string Name = Mang->getValueName(GV);
184 bool isExt = (GV->isExternal() || GV->hasWeakLinkage() ||
185 GV->hasLinkOnceLinkage());
186 if (X86PICStyle == PICStyle::Stub &&
Evan Cheng932ad512006-05-25 21:59:08 +0000187 TM.getRelocationModel() != Reloc::Static) {
Evan Cheng2338c5c2006-02-07 08:38:37 +0000188 // Link-once, External, or Weakly-linked global variables need
189 // non-lazily-resolved stubs
Evan Cheng25ab6902006-09-08 06:48:29 +0000190 if (isExt) {
Evan Cheng2338c5c2006-02-07 08:38:37 +0000191 // Dynamically-resolved functions need a stub for the function.
Evan Cheng25ab6902006-09-08 06:48:29 +0000192 if (isCallOp && isa<Function>(GV)) {
Evan Cheng2338c5c2006-02-07 08:38:37 +0000193 FnStubs.insert(Name);
194 O << "L" << Name << "$stub";
195 } else {
196 GVStubs.insert(Name);
197 O << "L" << Name << "$non_lazy_ptr";
198 }
Evan Cheng25ab6902006-09-08 06:48:29 +0000199 } else
200 O << Name;
Chris Lattner35d86fe2006-07-26 21:12:04 +0000201 if (!isCallOp && TM.getRelocationModel() == Reloc::PIC_)
Evan Chenga0ea0532006-02-23 02:43:52 +0000202 O << "-\"L" << getFunctionNumber() << "$pb\"";
Evan Cheng25ab6902006-09-08 06:48:29 +0000203 } else
204 O << Name;
205
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000206 int Offset = MO.getOffset();
207 if (Offset > 0)
208 O << "+" << Offset;
209 else if (Offset < 0)
210 O << Offset;
Evan Cheng25ab6902006-09-08 06:48:29 +0000211
212 if (!isCallOp &&
213 Subtarget->is64Bit()) {
214 if (isExt && TM.getRelocationModel() != Reloc::Static)
215 O << "@GOTPCREL";
216 O << "(%rip)";
217 }
218
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000219 return;
220 }
Chris Lattnera3b8c572006-02-06 23:41:19 +0000221 case MachineOperand::MO_ExternalSymbol: {
222 bool isCallOp = Modifier && !strcmp(Modifier, "call");
Evan Cheng932ad512006-05-25 21:59:08 +0000223 if (isCallOp &&
Evan Cheng25ab6902006-09-08 06:48:29 +0000224 X86PICStyle == PICStyle::Stub &&
Evan Cheng932ad512006-05-25 21:59:08 +0000225 TM.getRelocationModel() != Reloc::Static) {
Jim Laskey563321a2006-09-06 18:34:40 +0000226 std::string Name(TAI->getGlobalPrefix());
Evan Cheng4c1aa862006-02-22 20:19:42 +0000227 Name += MO.getSymbolName();
Nate Begeman72b286b2005-07-08 00:23:26 +0000228 FnStubs.insert(Name);
229 O << "L" << Name << "$stub";
230 return;
231 }
Evan Cheng4c1aa862006-02-22 20:19:42 +0000232 if (!isCallOp) O << '$';
Jim Laskey563321a2006-09-06 18:34:40 +0000233 O << TAI->getGlobalPrefix() << MO.getSymbolName();
Evan Cheng25ab6902006-09-08 06:48:29 +0000234
235 if (!isCallOp &&
236 Subtarget->is64Bit())
237 O << "(%rip)";
238
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000239 return;
Chris Lattnera3b8c572006-02-06 23:41:19 +0000240 }
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000241 default:
242 O << "<unknown operand type>"; return;
243 }
244}
245
Nate Begeman391c5d22005-11-30 18:54:35 +0000246void X86ATTAsmPrinter::printSSECC(const MachineInstr *MI, unsigned Op) {
Nate Begeman6c7cb292005-07-14 22:52:25 +0000247 unsigned char value = MI->getOperand(Op).getImmedValue();
248 assert(value <= 7 && "Invalid ssecc argument!");
249 switch (value) {
250 case 0: O << "eq"; break;
251 case 1: O << "lt"; break;
252 case 2: O << "le"; break;
253 case 3: O << "unord"; break;
254 case 4: O << "neq"; break;
255 case 5: O << "nlt"; break;
256 case 6: O << "nle"; break;
257 case 7: O << "ord"; break;
258 }
259}
260
Evan Cheng25ab6902006-09-08 06:48:29 +0000261void X86ATTAsmPrinter::printMemReference(const MachineInstr *MI, unsigned Op,
262 const char *Modifier){
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000263 assert(isMem(MI, Op) && "Invalid memory reference!");
264
265 const MachineOperand &BaseReg = MI->getOperand(Op);
266 int ScaleVal = MI->getOperand(Op+1).getImmedValue();
267 const MachineOperand &IndexReg = MI->getOperand(Op+2);
268 const MachineOperand &DispSpec = MI->getOperand(Op+3);
269
270 if (BaseReg.isFrameIndex()) {
271 O << "[frame slot #" << BaseReg.getFrameIndex();
272 if (DispSpec.getImmedValue())
273 O << " + " << DispSpec.getImmedValue();
274 O << "]";
275 return;
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000276 }
277
Evan Chengc9676de2006-08-29 22:14:48 +0000278 if (DispSpec.isGlobalAddress() ||
279 DispSpec.isConstantPoolIndex() ||
280 DispSpec.isJumpTableIndex()) {
Evan Cheng2338c5c2006-02-07 08:38:37 +0000281 printOperand(MI, Op+3, "mem");
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000282 } else {
283 int DispVal = DispSpec.getImmedValue();
284 if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg()))
285 O << DispVal;
286 }
287
288 if (IndexReg.getReg() || BaseReg.getReg()) {
289 O << "(";
Evan Cheng25ab6902006-09-08 06:48:29 +0000290 if (BaseReg.getReg()) {
291 printOperand(MI, Op, Modifier);
292 }
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000293
294 if (IndexReg.getReg()) {
295 O << ",";
Evan Cheng25ab6902006-09-08 06:48:29 +0000296 printOperand(MI, Op+2, Modifier);
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000297 if (ScaleVal != 1)
298 O << "," << ScaleVal;
299 }
300
301 O << ")";
302 }
303}
304
Evan Cheng7ccced62006-02-18 00:15:05 +0000305void X86ATTAsmPrinter::printPICLabel(const MachineInstr *MI, unsigned Op) {
306 O << "\"L" << getFunctionNumber() << "$pb\"\n";
307 O << "\"L" << getFunctionNumber() << "$pb\":";
308}
309
Evan Cheng62f27002006-04-28 23:11:40 +0000310
Evan Cheng55c25f22006-04-28 23:19:39 +0000311bool X86ATTAsmPrinter::printAsmMRegister(const MachineOperand &MO,
Evan Cheng62f27002006-04-28 23:11:40 +0000312 const char Mode) {
313 const MRegisterInfo &RI = *TM.getRegisterInfo();
314 unsigned Reg = MO.getReg();
Evan Cheng62f27002006-04-28 23:11:40 +0000315 switch (Mode) {
316 default: return true; // Unknown mode.
317 case 'b': // Print QImode register
Evan Cheng8f7f7122006-05-05 05:40:20 +0000318 Reg = getX86SubSuperRegister(Reg, MVT::i8);
Evan Cheng62f27002006-04-28 23:11:40 +0000319 break;
320 case 'h': // Print QImode high register
Evan Cheng8f7f7122006-05-05 05:40:20 +0000321 Reg = getX86SubSuperRegister(Reg, MVT::i8, true);
Evan Cheng62f27002006-04-28 23:11:40 +0000322 break;
323 case 'w': // Print HImode register
Evan Cheng8f7f7122006-05-05 05:40:20 +0000324 Reg = getX86SubSuperRegister(Reg, MVT::i16);
Evan Cheng62f27002006-04-28 23:11:40 +0000325 break;
326 case 'k': // Print SImode register
Evan Cheng8f7f7122006-05-05 05:40:20 +0000327 Reg = getX86SubSuperRegister(Reg, MVT::i32);
Evan Cheng62f27002006-04-28 23:11:40 +0000328 break;
329 }
330
Evan Cheng8f7f7122006-05-05 05:40:20 +0000331 O << '%';
332 for (const char *Name = RI.get(Reg).Name; *Name; ++Name)
333 O << (char)tolower(*Name);
Evan Cheng62f27002006-04-28 23:11:40 +0000334 return false;
335}
336
Evan Cheng3d48a902006-04-28 21:19:05 +0000337/// PrintAsmOperand - Print out an operand for an inline asm expression.
338///
339bool X86ATTAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
340 unsigned AsmVariant,
341 const char *ExtraCode) {
342 // Does this asm operand have a single letter operand modifier?
343 if (ExtraCode && ExtraCode[0]) {
344 if (ExtraCode[1] != 0) return true; // Unknown modifier.
345
346 switch (ExtraCode[0]) {
347 default: return true; // Unknown modifier.
Evan Cheng62f27002006-04-28 23:11:40 +0000348 case 'b': // Print QImode register
349 case 'h': // Print QImode high register
350 case 'w': // Print HImode register
351 case 'k': // Print SImode register
Evan Cheng55c25f22006-04-28 23:19:39 +0000352 return printAsmMRegister(MI->getOperand(OpNo), ExtraCode[0]);
Evan Cheng3d48a902006-04-28 21:19:05 +0000353 }
354 }
355
356 printOperand(MI, OpNo);
357 return false;
358}
359
360bool X86ATTAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
361 unsigned OpNo,
362 unsigned AsmVariant,
363 const char *ExtraCode) {
364 if (ExtraCode && ExtraCode[0])
365 return true; // Unknown modifier.
366 printMemReference(MI, OpNo);
367 return false;
368}
369
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000370/// printMachineInstruction -- Print out a single X86 LLVM instruction
371/// MI in Intel syntax to the current output stream.
372///
373void X86ATTAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
374 ++EmittedInsts;
Evan Cheng67caa392006-01-26 02:27:43 +0000375
Evan Cheng8f7f7122006-05-05 05:40:20 +0000376 // See if a truncate instruction can be turned into a nop.
377 switch (MI->getOpcode()) {
378 default: break;
Evan Cheng25ab6902006-09-08 06:48:29 +0000379 case X86::TRUNC_64to32:
380 case X86::TRUNC_64to16:
381 case X86::TRUNC_32to16:
382 case X86::TRUNC_32to8:
383 case X86::TRUNC_16to8:
384 case X86::TRUNC_32_to8:
385 case X86::TRUNC_16_to8: {
Evan Cheng8f7f7122006-05-05 05:40:20 +0000386 const MachineOperand &MO0 = MI->getOperand(0);
387 const MachineOperand &MO1 = MI->getOperand(1);
388 unsigned Reg0 = MO0.getReg();
389 unsigned Reg1 = MO1.getReg();
Evan Cheng25ab6902006-09-08 06:48:29 +0000390 unsigned Opc = MI->getOpcode();
391 if (Opc == X86::TRUNC_64to32)
392 Reg1 = getX86SubSuperRegister(Reg1, MVT::i32);
393 else if (Opc == X86::TRUNC_32to16 || Opc == X86::TRUNC_64to16)
Evan Cheng403be7e2006-05-08 08:01:26 +0000394 Reg1 = getX86SubSuperRegister(Reg1, MVT::i16);
Evan Cheng8f7f7122006-05-05 05:40:20 +0000395 else
Evan Cheng403be7e2006-05-08 08:01:26 +0000396 Reg1 = getX86SubSuperRegister(Reg1, MVT::i8);
Jim Laskey563321a2006-09-06 18:34:40 +0000397 O << TAI->getCommentString() << " TRUNCATE ";
Evan Cheng403be7e2006-05-08 08:01:26 +0000398 if (Reg0 != Reg1)
399 O << "\n\t";
Evan Cheng8f7f7122006-05-05 05:40:20 +0000400 break;
401 }
Evan Cheng25ab6902006-09-08 06:48:29 +0000402 case X86::PsMOVZX64rr32:
403 O << TAI->getCommentString() << " ZERO-EXTEND " << "\n\t";
404 break;
Evan Cheng8f7f7122006-05-05 05:40:20 +0000405 }
406
Chris Lattnerb36cbd02005-07-01 22:44:09 +0000407 // Call the autogenerated instruction printer routines.
408 printInstruction(MI);
409}
410
411// Include the auto-generated portion of the assembly writer.
412#include "X86GenAsmWriter.inc"
413