blob: 8ae7d90d258ec7614b94fdf5ba5017bd15665192 [file] [log] [blame]
Duraid Madina9b9d45f2005-03-17 18:17:03 +00001//===-- IA64AsmPrinter.cpp - Print out IA64 LLVM as assembly --------------===//
Misha Brukman4633f1c2005-04-21 23:13:11 +00002//
Duraid Madina9b9d45f2005-03-17 18:17:03 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukman4633f1c2005-04-21 23:13:11 +00007//
Duraid Madina9b9d45f2005-03-17 18:17:03 +00008//===----------------------------------------------------------------------===//
9//
10// This file contains a printer that converts from our internal representation
11// of machine-dependent LLVM code to assembly accepted by the GNU binutils 'gas'
12// assembler. The Intel 'ias' and HP-UX 'as' assemblers *may* choke on this
13// output, but if so that's a bug I'd like to hear about: please file a bug
Duraid Madinaf2db9b82005-10-28 17:46:35 +000014// report in bugzilla. FYI, the not too bad 'ias' assembler is bundled with
Duraid Madina9b9d45f2005-03-17 18:17:03 +000015// the Intel C/C++ compiler for Itanium Linux.
16//
17//===----------------------------------------------------------------------===//
18
Chris Lattner95b2c7d2006-12-19 22:59:26 +000019#define DEBUG_TYPE "asm-printer"
Duraid Madina9b9d45f2005-03-17 18:17:03 +000020#include "IA64.h"
21#include "IA64TargetMachine.h"
22#include "llvm/Module.h"
Chris Lattner3c61f702005-03-24 05:12:48 +000023#include "llvm/Type.h"
Duraid Madina9b9d45f2005-03-17 18:17:03 +000024#include "llvm/CodeGen/AsmPrinter.h"
Duraid Madina9b9d45f2005-03-17 18:17:03 +000025#include "llvm/CodeGen/MachineFunctionPass.h"
Jim Laskey563321a2006-09-06 18:34:40 +000026#include "llvm/Target/TargetAsmInfo.h"
Jim Laskeya0f3d172006-09-07 22:06:40 +000027#include "llvm/Target/TargetMachine.h"
Duraid Madina9b9d45f2005-03-17 18:17:03 +000028#include "llvm/Support/Mangler.h"
29#include "llvm/ADT/Statistic.h"
Duraid Madina9b9d45f2005-03-17 18:17:03 +000030using namespace llvm;
31
Chris Lattner95b2c7d2006-12-19 22:59:26 +000032STATISTIC(EmittedInsts, "Number of machine instrs printed");
33
Duraid Madina9b9d45f2005-03-17 18:17:03 +000034namespace {
Jim Laskey563321a2006-09-06 18:34:40 +000035 struct IA64AsmPrinter : public AsmPrinter {
36 std::set<std::string> ExternalFunctionNames, ExternalObjectNames;
37
Jim Laskeya0f3d172006-09-07 22:06:40 +000038 IA64AsmPrinter(std::ostream &O, TargetMachine &TM, const TargetAsmInfo *T)
Jim Laskey563321a2006-09-06 18:34:40 +000039 : AsmPrinter(O, TM, T) {
40 }
Duraid Madina9b9d45f2005-03-17 18:17:03 +000041
42 virtual const char *getPassName() const {
43 return "IA64 Assembly Printer";
44 }
45
46 /// printInstruction - This method is automatically generated by tablegen
47 /// from the instruction set description. This method returns true if the
48 /// machine instruction was sufficiently described to print it, otherwise it
49 /// returns false.
50 bool printInstruction(const MachineInstr *MI);
51
52 // This method is used by the tablegen'erated instruction printer.
Nate Begeman391c5d22005-11-30 18:54:35 +000053 void printOperand(const MachineInstr *MI, unsigned OpNo){
Duraid Madina9b9d45f2005-03-17 18:17:03 +000054 const MachineOperand &MO = MI->getOperand(OpNo);
Chris Lattner2d90ac72006-05-04 18:05:43 +000055 if (MO.getType() == MachineOperand::MO_Register) {
Dan Gohman6f0d0242008-02-10 18:45:23 +000056 assert(TargetRegisterInfo::isPhysicalRegister(MO.getReg()) &&
57 "Not physref??");
Duraid Madina9b9d45f2005-03-17 18:17:03 +000058 //XXX Bug Workaround: See note in Printer::doInitialization about %.
Bill Wendling74ab84c2008-02-26 21:11:01 +000059 O << TM.getRegisterInfo()->get(MO.getReg()).AsmName;
Duraid Madina9b9d45f2005-03-17 18:17:03 +000060 } else {
61 printOp(MO);
62 }
63 }
Misha Brukman4633f1c2005-04-21 23:13:11 +000064
Nate Begeman391c5d22005-11-30 18:54:35 +000065 void printS8ImmOperand(const MachineInstr *MI, unsigned OpNo) {
Chris Lattner9a1ceae2007-12-30 20:49:49 +000066 int val=(unsigned int)MI->getOperand(OpNo).getImm();
Duraid Madinae6a0b6c2005-04-07 12:34:36 +000067 if(val>=128) val=val-256; // if negative, flip sign
68 O << val;
69 }
Nate Begeman391c5d22005-11-30 18:54:35 +000070 void printS14ImmOperand(const MachineInstr *MI, unsigned OpNo) {
Chris Lattner9a1ceae2007-12-30 20:49:49 +000071 int val=(unsigned int)MI->getOperand(OpNo).getImm();
Duraid Madinae6a0b6c2005-04-07 12:34:36 +000072 if(val>=8192) val=val-16384; // if negative, flip sign
73 O << val;
74 }
Nate Begeman391c5d22005-11-30 18:54:35 +000075 void printS22ImmOperand(const MachineInstr *MI, unsigned OpNo) {
Chris Lattner9a1ceae2007-12-30 20:49:49 +000076 int val=(unsigned int)MI->getOperand(OpNo).getImm();
Duraid Madina5ef2ec92005-04-11 05:55:56 +000077 if(val>=2097152) val=val-4194304; // if negative, flip sign
78 O << val;
Duraid Madina9b9d45f2005-03-17 18:17:03 +000079 }
Nate Begeman391c5d22005-11-30 18:54:35 +000080 void printU64ImmOperand(const MachineInstr *MI, unsigned OpNo) {
Chris Lattner9a1ceae2007-12-30 20:49:49 +000081 O << (uint64_t)MI->getOperand(OpNo).getImm();
Duraid Madina9b9d45f2005-03-17 18:17:03 +000082 }
Nate Begeman391c5d22005-11-30 18:54:35 +000083 void printS64ImmOperand(const MachineInstr *MI, unsigned OpNo) {
Duraid Madinaf2db9b82005-10-28 17:46:35 +000084// XXX : nasty hack to avoid GPREL22 "relocation truncated to fit" linker
85// errors - instead of add rX = @gprel(CPI<whatever>), r1;; we now
86// emit movl rX = @gprel(CPI<whatever);;
Anton Korobeynikov003bcab2008-08-07 09:52:13 +000087// add rX = rX, r1;
Duraid Madinaf2db9b82005-10-28 17:46:35 +000088// this gives us 64 bits instead of 22 (for the add long imm) to play
89// with, which shuts up the linker. The problem is that the constant
Anton Korobeynikov003bcab2008-08-07 09:52:13 +000090// pool entries aren't immediates at this stage, so we check here.
Duraid Madinaf2db9b82005-10-28 17:46:35 +000091// If it's an immediate, print it the old fashioned way. If it's
Anton Korobeynikov003bcab2008-08-07 09:52:13 +000092// not, we print it as a constant pool index.
Duraid Madinaf2db9b82005-10-28 17:46:35 +000093 if(MI->getOperand(OpNo).isImmediate()) {
Chris Lattner9a1ceae2007-12-30 20:49:49 +000094 O << (int64_t)MI->getOperand(OpNo).getImm();
Duraid Madinaf2db9b82005-10-28 17:46:35 +000095 } else { // this is a constant pool reference: FIXME: assert this
96 printOp(MI->getOperand(OpNo));
97 }
98 }
99
Nate Begeman391c5d22005-11-30 18:54:35 +0000100 void printGlobalOperand(const MachineInstr *MI, unsigned OpNo) {
Duraid Madinaf2db9b82005-10-28 17:46:35 +0000101 printOp(MI->getOperand(OpNo), false); // this is NOT a br.call instruction
Duraid Madina1ce0c012005-04-14 10:08:01 +0000102 }
Misha Brukman4633f1c2005-04-21 23:13:11 +0000103
Nate Begeman391c5d22005-11-30 18:54:35 +0000104 void printCallOperand(const MachineInstr *MI, unsigned OpNo) {
Misha Brukman4633f1c2005-04-21 23:13:11 +0000105 printOp(MI->getOperand(OpNo), true); // this is a br.call instruction
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000106 }
107
Chris Lattneredad2b72006-10-05 02:51:36 +0000108 std::string getSectionForFunction(const Function &F) const;
109
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000110 void printMachineInstruction(const MachineInstr *MI);
111 void printOp(const MachineOperand &MO, bool isBRCALLinsn= false);
Anton Korobeynikovdc3ca2e2008-08-07 09:52:35 +0000112 void printModuleLevelGV(const GlobalVariable* GVar);
Misha Brukman4633f1c2005-04-21 23:13:11 +0000113 bool runOnMachineFunction(MachineFunction &F);
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000114 bool doInitialization(Module &M);
Chris Lattner42a76cd2005-11-21 08:40:17 +0000115 bool doFinalization(Module &M);
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000116 };
117} // end of anonymous namespace
118
119
120// Include the auto-generated portion of the assembly writer.
121#include "IA64GenAsmWriter.inc"
122
123
Anton Korobeynikov003bcab2008-08-07 09:52:13 +0000124// Substitute old hook with new one temporary
Chris Lattneredad2b72006-10-05 02:51:36 +0000125std::string IA64AsmPrinter::getSectionForFunction(const Function &F) const {
Anton Korobeynikov003bcab2008-08-07 09:52:13 +0000126 return TAI->SectionForGlobal(&F);
Chris Lattneredad2b72006-10-05 02:51:36 +0000127}
128
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000129/// runOnMachineFunction - This uses the printMachineInstruction()
130/// method to print assembly for each instruction.
131///
132bool IA64AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
Chris Lattner8b8b9512005-11-21 07:51:23 +0000133 SetupMachineFunction(MF);
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000134 O << "\n\n";
135
136 // Print out constants referenced by the function
Chris Lattner3dfbe2e2005-11-21 08:38:26 +0000137 EmitConstantPool(MF.getConstantPool());
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000138
Chris Lattneredad2b72006-10-05 02:51:36 +0000139 const Function *F = MF.getFunction();
140 SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
141
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000142 // Print out labels for the function.
Chris Lattner8b8b9512005-11-21 07:51:23 +0000143 EmitAlignment(5);
Anton Korobeynikov98a6dd02008-08-07 09:52:54 +0000144 O << "\t.global\t" << CurrentFnName << '\n';
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000145 O << "\t.type\t" << CurrentFnName << ", @function\n";
146 O << CurrentFnName << ":\n";
147
148 // Print out code for the function.
149 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
150 I != E; ++I) {
151 // Print a label for the basic block if there are any predecessors.
Dan Gohmancb406c22007-10-03 19:26:29 +0000152 if (!I->pred_empty()) {
Evan Chengfb8075d2008-02-28 00:43:03 +0000153 printBasicBlockLabel(I, true, true);
Nate Begemancdf38c42006-05-02 05:37:32 +0000154 O << '\n';
155 }
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000156 for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
157 II != E; ++II) {
158 // Print the assembly for the instruction.
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000159 printMachineInstruction(II);
160 }
161 }
162
163 // We didn't modify anything.
164 return false;
165}
166
167void IA64AsmPrinter::printOp(const MachineOperand &MO,
Chris Lattner63b3d712006-05-04 17:21:20 +0000168 bool isBRCALLinsn /* = false */) {
Dan Gohman6f0d0242008-02-10 18:45:23 +0000169 const TargetRegisterInfo &RI = *TM.getRegisterInfo();
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000170 switch (MO.getType()) {
Chris Lattner2d90ac72006-05-04 18:05:43 +0000171 case MachineOperand::MO_Register:
Bill Wendling74ab84c2008-02-26 21:11:01 +0000172 O << RI.get(MO.getReg()).AsmName;
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000173 return;
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000174
Chris Lattner63b3d712006-05-04 17:21:20 +0000175 case MachineOperand::MO_Immediate:
Chris Lattner9a1ceae2007-12-30 20:49:49 +0000176 O << MO.getImm();
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000177 return;
Nate Begeman37efe672006-04-22 18:53:45 +0000178 case MachineOperand::MO_MachineBasicBlock:
Chris Lattner8aa797a2007-12-30 23:10:15 +0000179 printBasicBlockLabel(MO.getMBB());
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000180 return;
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000181 case MachineOperand::MO_ConstantPoolIndex: {
Jim Laskey563321a2006-09-06 18:34:40 +0000182 O << "@gprel(" << TAI->getPrivateGlobalPrefix()
Chris Lattner8aa797a2007-12-30 23:10:15 +0000183 << "CPI" << getFunctionNumber() << "_" << MO.getIndex() << ")";
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000184 return;
185 }
186
187 case MachineOperand::MO_GlobalAddress: {
188
189 // functions need @ltoff(@fptr(fn_name)) form
190 GlobalValue *GV = MO.getGlobal();
191 Function *F = dyn_cast<Function>(GV);
192
193 bool Needfptr=false; // if we're computing an address @ltoff(X), do
194 // we need to decorate it so it becomes
Misha Brukman7847fca2005-04-22 17:54:37 +0000195 // @ltoff(@fptr(X)) ?
Reid Spencer5cbf9852007-01-30 20:08:39 +0000196 if (F && !isBRCALLinsn /*&& F->isDeclaration()*/)
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000197 Needfptr=true;
Misha Brukman4633f1c2005-04-21 23:13:11 +0000198
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000199 // if this is the target of a call instruction, we should define
200 // the function somewhere (GNU gas has no problem without this, but
201 // Intel ias rightly complains of an 'undefined symbol')
Misha Brukman4633f1c2005-04-21 23:13:11 +0000202
Reid Spencer5cbf9852007-01-30 20:08:39 +0000203 if (F /*&& isBRCALLinsn*/ && F->isDeclaration())
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000204 ExternalFunctionNames.insert(Mang->getValueName(MO.getGlobal()));
Duraid Madinaae8bd732005-03-28 15:21:43 +0000205 else
Reid Spencer5cbf9852007-01-30 20:08:39 +0000206 if (GV->isDeclaration()) // e.g. stuff like 'stdin'
Misha Brukman7847fca2005-04-22 17:54:37 +0000207 ExternalObjectNames.insert(Mang->getValueName(MO.getGlobal()));
Duraid Madinaae8bd732005-03-28 15:21:43 +0000208
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000209 if (!isBRCALLinsn)
210 O << "@ltoff(";
211 if (Needfptr)
212 O << "@fptr(";
213 O << Mang->getValueName(MO.getGlobal());
Anton Korobeynikov003bcab2008-08-07 09:52:13 +0000214
Duraid Madina00d3d442006-02-16 13:12:57 +0000215 if (Needfptr && !isBRCALLinsn)
216 O << "#))"; // close both fptr( and ltoff(
217 else {
218 if (Needfptr)
219 O << "#)"; // close only fptr(
220 if (!isBRCALLinsn)
221 O << "#)"; // close only ltoff(
222 }
Anton Korobeynikov003bcab2008-08-07 09:52:13 +0000223
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000224 int Offset = MO.getOffset();
225 if (Offset > 0)
226 O << " + " << Offset;
227 else if (Offset < 0)
228 O << " - " << -Offset;
229 return;
230 }
231 case MachineOperand::MO_ExternalSymbol:
232 O << MO.getSymbolName();
Duraid Madinaae8bd732005-03-28 15:21:43 +0000233 ExternalFunctionNames.insert(MO.getSymbolName());
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000234 return;
235 default:
Misha Brukman4633f1c2005-04-21 23:13:11 +0000236 O << "<AsmPrinter: unknown operand type: " << MO.getType() << " >"; return;
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000237 }
238}
239
240/// printMachineInstruction -- Print out a single IA64 LLVM instruction
241/// MI to the current output stream.
242///
243void IA64AsmPrinter::printMachineInstruction(const MachineInstr *MI) {
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000244 ++EmittedInsts;
Misha Brukman4633f1c2005-04-21 23:13:11 +0000245
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000246 // Call the autogenerated instruction printer routines.
247 printInstruction(MI);
248}
249
250bool IA64AsmPrinter::doInitialization(Module &M) {
Dan Gohmanb8275a32007-07-25 19:33:14 +0000251 bool Result = AsmPrinter::doInitialization(M);
Misha Brukman4633f1c2005-04-21 23:13:11 +0000252
Duraid Madinaae8bd732005-03-28 15:21:43 +0000253 O << "\n.ident \"LLVM-ia64\"\n\n"
Misha Brukman7847fca2005-04-22 17:54:37 +0000254 << "\t.psr lsb\n" // should be "msb" on HP-UX, for starters
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000255 << "\t.radix C\n"
Misha Brukman7847fca2005-04-22 17:54:37 +0000256 << "\t.psr abi64\n"; // we only support 64 bits for now
Dan Gohmanb8275a32007-07-25 19:33:14 +0000257 return Result;
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000258}
259
Anton Korobeynikovdc3ca2e2008-08-07 09:52:35 +0000260void IA64AsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
Owen Andersona69571c2006-05-03 01:29:57 +0000261 const TargetData *TD = TM.getTargetData();
Anton Korobeynikov003bcab2008-08-07 09:52:13 +0000262
Anton Korobeynikovdc3ca2e2008-08-07 09:52:35 +0000263 if (!GVar->hasInitializer())
264 return; // External global require no code
265
266 // Check to see if this is a special global used by LLVM, if so, emit it.
267 if (EmitSpecialLLVMGlobal(GVar))
268 return;
269
270 O << "\n\n";
271 std::string SectionName = TAI->SectionForGlobal(GVar);
272 std::string name = Mang->getValueName(GVar);
273 Constant *C = GVar->getInitializer();
274 unsigned Size = TD->getABITypeSize(C->getType());
275 unsigned Align = TD->getPreferredAlignmentLog(GVar);
276
277 // FIXME: ELF supports visibility
278
279 SwitchToDataSection(SectionName.c_str());
280
281 if (C->isNullValue() && !GVar->hasSection()) {
282 if (!GVar->isThreadLocal() &&
283 (GVar->hasInternalLinkage() || GVar->isWeakForLinker())) {
284 if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
285
286 if (GVar->hasInternalLinkage()) {
287 O << "\t.lcomm " << name << "#," << Size
Anton Korobeynikov98a6dd02008-08-07 09:52:54 +0000288 << ',' << (1 << Align);
289 O << '\n';
Anton Korobeynikovdc3ca2e2008-08-07 09:52:35 +0000290 } else {
291 O << "\t.common " << name << "#," << Size
Anton Korobeynikov98a6dd02008-08-07 09:52:54 +0000292 << ',' << (1 << Align);
293 O << '\n';
Anton Korobeynikovdc3ca2e2008-08-07 09:52:35 +0000294 }
295
296 return;
297 }
298 }
299
300 switch (GVar->getLinkage()) {
301 case GlobalValue::LinkOnceLinkage:
302 case GlobalValue::CommonLinkage:
303 case GlobalValue::WeakLinkage:
304 // Nonnull linkonce -> weak
Anton Korobeynikov98a6dd02008-08-07 09:52:54 +0000305 O << "\t.weak " << name << '\n';
Anton Korobeynikovdc3ca2e2008-08-07 09:52:35 +0000306 break;
307 case GlobalValue::AppendingLinkage:
308 // FIXME: appending linkage variables should go into a section of
309 // their name or something. For now, just emit them as external.
310 case GlobalValue::ExternalLinkage:
311 // If external or appending, declare as a global symbol
Anton Korobeynikov98a6dd02008-08-07 09:52:54 +0000312 O << TAI->getGlobalDirective() << name << '\n';
Anton Korobeynikovdc3ca2e2008-08-07 09:52:35 +0000313 // FALL THROUGH
314 case GlobalValue::InternalLinkage:
315 break;
316 case GlobalValue::GhostLinkage:
317 cerr << "GhostLinkage cannot appear in IA64AsmPrinter!\n";
318 abort();
319 case GlobalValue::DLLImportLinkage:
320 cerr << "DLLImport linkage is not supported by this target!\n";
321 abort();
322 case GlobalValue::DLLExportLinkage:
323 cerr << "DLLExport linkage is not supported by this target!\n";
324 abort();
325 default:
326 assert(0 && "Unknown linkage type!");
327 }
328
Anton Korobeynikovfcd99bb2008-08-07 09:53:38 +0000329 EmitAlignment(Align, GVar);
Anton Korobeynikovdc3ca2e2008-08-07 09:52:35 +0000330
331 if (TAI->hasDotTypeDotSizeDirective()) {
332 O << "\t.type " << name << ",@object\n";
Anton Korobeynikov98a6dd02008-08-07 09:52:54 +0000333 O << "\t.size " << name << ',' << Size << '\n';
Anton Korobeynikovdc3ca2e2008-08-07 09:52:35 +0000334 }
335
Anton Korobeynikov98a6dd02008-08-07 09:52:54 +0000336 O << name << ":\t\t\t\t// " << *C << '\n';
Anton Korobeynikovdc3ca2e2008-08-07 09:52:35 +0000337 EmitGlobalConstant(C);
338}
339
340
341bool IA64AsmPrinter::doFinalization(Module &M) {
Chris Lattner42a76cd2005-11-21 08:40:17 +0000342 // Print out module-level global variables here.
343 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
344 I != E; ++I)
Anton Korobeynikovdc3ca2e2008-08-07 09:52:35 +0000345 printModuleLevelGV(I);
Anton Korobeynikov003bcab2008-08-07 09:52:13 +0000346
347 // we print out ".global X \n .type X, @function" for each external function
348 O << "\n\n// br.call targets referenced (and not defined) above: \n";
Chris Lattner42a76cd2005-11-21 08:40:17 +0000349 for (std::set<std::string>::iterator i = ExternalFunctionNames.begin(),
350 e = ExternalFunctionNames.end(); i!=e; ++i) {
351 O << "\t.global " << *i << "\n\t.type " << *i << ", @function\n";
352 }
353 O << "\n\n";
Anton Korobeynikov003bcab2008-08-07 09:52:13 +0000354
Chris Lattner42a76cd2005-11-21 08:40:17 +0000355 // we print out ".global X \n .type X, @object" for each external object
356 O << "\n\n// (external) symbols referenced (and not defined) above: \n";
357 for (std::set<std::string>::iterator i = ExternalObjectNames.begin(),
358 e = ExternalObjectNames.end(); i!=e; ++i) {
359 O << "\t.global " << *i << "\n\t.type " << *i << ", @object\n";
360 }
361 O << "\n\n";
Anton Korobeynikov003bcab2008-08-07 09:52:13 +0000362
Dan Gohmanb8275a32007-07-25 19:33:14 +0000363 return AsmPrinter::doFinalization(M);
Chris Lattner42a76cd2005-11-21 08:40:17 +0000364}
365
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000366/// createIA64CodePrinterPass - Returns a pass that prints the IA64
367/// assembly code for a MachineFunction to the given output stream, using
368/// the given target machine description.
369///
Evan Chengc4c62572006-03-13 23:20:37 +0000370FunctionPass *llvm::createIA64CodePrinterPass(std::ostream &o,
371 IA64TargetMachine &tm) {
Jim Laskeya0f3d172006-09-07 22:06:40 +0000372 return new IA64AsmPrinter(o, tm, tm.getTargetAsmInfo());
Duraid Madina9b9d45f2005-03-17 18:17:03 +0000373}