blob: b8f5b94d2992ad74f7b2ebb8d475b9f57798b15f [file] [log] [blame]
Chris Lattnere88f78c2001-09-19 13:47:27 +00001//===-- EmitAssembly.cpp - Emit Sparc Specific .s File ---------------------==//
2//
3// This file implements all of the stuff neccesary to output a .s file from
4// LLVM. The code in this file assumes that the specified module has already
5// been compiled into the internal data structures of the Module.
6//
Chris Lattnerf57b8452002-04-27 06:56:12 +00007// This code largely consists of two LLVM Pass's: a FunctionPass and a Pass.
8// The FunctionPass is pipelined together with all of the rest of the code
9// generation stages, and the Pass runs at the end to emit code for global
10// variables and such.
Chris Lattnere88f78c2001-09-19 13:47:27 +000011//
12//===----------------------------------------------------------------------===//
13
14#include "SparcInternals.h"
Chris Lattnere88f78c2001-09-19 13:47:27 +000015#include "llvm/CodeGen/MachineInstr.h"
Vikram S. Adveb2debdc2002-07-08 23:30:59 +000016#include "llvm/CodeGen/MachineCodeForBasicBlock.h"
Chris Lattnerc019a172002-02-03 07:48:06 +000017#include "llvm/CodeGen/MachineCodeForMethod.h"
Vikram S. Adve953c83e2001-10-28 21:38:52 +000018#include "llvm/GlobalVariable.h"
Chris Lattner31bcdb82002-04-28 19:55:58 +000019#include "llvm/Constants.h"
Vikram S. Adve953c83e2001-10-28 21:38:52 +000020#include "llvm/DerivedTypes.h"
Chris Lattnere88f78c2001-09-19 13:47:27 +000021#include "llvm/BasicBlock.h"
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000022#include "llvm/Function.h"
Chris Lattnere88f78c2001-09-19 13:47:27 +000023#include "llvm/Module.h"
Chris Lattnerb5794002002-04-07 22:49:37 +000024#include "llvm/SlotCalculator.h"
Chris Lattnerd50b6712002-04-28 20:40:59 +000025#include "llvm/Pass.h"
Chris Lattner4b1de8e2002-04-18 18:15:38 +000026#include "llvm/Assembly/Writer.h"
Chris Lattnercee8f9a2001-11-27 00:03:19 +000027#include "Support/StringExtras.h"
Vikram S. Adve9ee9d712002-03-03 20:46:32 +000028#include <iostream>
Chris Lattner697954c2002-01-20 22:54:45 +000029using std::string;
Chris Lattnere88f78c2001-09-19 13:47:27 +000030
31namespace {
32
Vikram S. Adved198c472002-03-18 03:07:26 +000033class GlobalIdTable: public Annotation {
34 static AnnotationID AnnotId;
35 friend class AsmPrinter; // give access to AnnotId
Vikram S. Adve953c83e2001-10-28 21:38:52 +000036
Vikram S. Adved198c472002-03-18 03:07:26 +000037 typedef std::hash_map<const Value*, int> ValIdMap;
38 typedef ValIdMap::const_iterator ValIdMapConstIterator;
39 typedef ValIdMap:: iterator ValIdMapIterator;
40public:
Chris Lattnerfd63f25f2002-04-28 04:50:54 +000041 SlotCalculator Table; // map anonymous values to unique integer IDs
Chris Lattnerc19b8b12002-02-03 23:41:08 +000042 ValIdMap valToIdMap; // used for values not handled by SlotCalculator
Vikram S. Adved198c472002-03-18 03:07:26 +000043
Chris Lattnerfd63f25f2002-04-28 04:50:54 +000044 GlobalIdTable(Module* M) : Annotation(AnnotId), Table(M, true) {}
Vikram S. Adved198c472002-03-18 03:07:26 +000045};
46
47AnnotationID GlobalIdTable::AnnotId =
48 AnnotationManager::getID("ASM PRINTER GLOBAL TABLE ANNOT");
49
50//===---------------------------------------------------------------------===//
51// Code Shared By the two printer passes, as a mixin
52//===---------------------------------------------------------------------===//
53
54class AsmPrinter {
55 GlobalIdTable* idTable;
Chris Lattnerc19b8b12002-02-03 23:41:08 +000056public:
Chris Lattner697954c2002-01-20 22:54:45 +000057 std::ostream &toAsm;
Chris Lattner59ba1092002-02-04 15:53:23 +000058 const TargetMachine &Target;
Vikram S. Adved198c472002-03-18 03:07:26 +000059
Chris Lattnere88f78c2001-09-19 13:47:27 +000060 enum Sections {
61 Unknown,
62 Text,
Vikram S. Adve953c83e2001-10-28 21:38:52 +000063 ReadOnlyData,
64 InitRWData,
65 UninitRWData,
Chris Lattnere88f78c2001-09-19 13:47:27 +000066 } CurSection;
Chris Lattnerc19b8b12002-02-03 23:41:08 +000067
Chris Lattner59ba1092002-02-04 15:53:23 +000068 AsmPrinter(std::ostream &os, const TargetMachine &T)
Vikram S. Adved198c472002-03-18 03:07:26 +000069 : idTable(0), toAsm(os), Target(T), CurSection(Unknown) {}
70
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000071 // (start|end)(Module|Function) - Callback methods to be invoked by subclasses
Chris Lattner0b12b5f2002-06-25 16:13:21 +000072 void startModule(Module &M) {
Vikram S. Adved198c472002-03-18 03:07:26 +000073 // Create the global id table if it does not already exist
Chris Lattner0b12b5f2002-06-25 16:13:21 +000074 idTable = (GlobalIdTable*)M.getAnnotation(GlobalIdTable::AnnotId);
Vikram S. Adved198c472002-03-18 03:07:26 +000075 if (idTable == NULL) {
Chris Lattner0b12b5f2002-06-25 16:13:21 +000076 idTable = new GlobalIdTable(&M);
77 M.addAnnotation(idTable);
Vikram S. Adved198c472002-03-18 03:07:26 +000078 }
Chris Lattnerc19b8b12002-02-03 23:41:08 +000079 }
Chris Lattner0b12b5f2002-06-25 16:13:21 +000080 void startFunction(Function &F) {
Chris Lattnerb5794002002-04-07 22:49:37 +000081 // Make sure the slot table has information about this function...
Chris Lattner0b12b5f2002-06-25 16:13:21 +000082 idTable->Table.incorporateFunction(&F);
Chris Lattnerc19b8b12002-02-03 23:41:08 +000083 }
Chris Lattner0b12b5f2002-06-25 16:13:21 +000084 void endFunction(Function &) {
Chris Lattnerfd63f25f2002-04-28 04:50:54 +000085 idTable->Table.purgeFunction(); // Forget all about F
Chris Lattnerc19b8b12002-02-03 23:41:08 +000086 }
87 void endModule() {
Chris Lattnere88f78c2001-09-19 13:47:27 +000088 }
89
Vikram S. Adved198c472002-03-18 03:07:26 +000090 // Check if a name is external or accessible from external code.
91 // Only functions can currently be external. "main" is the only name
92 // that is visible externally.
93 bool isExternal(const Value* V) {
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000094 const Function *F = dyn_cast<Function>(V);
95 return F && (F->isExternal() || F->getName() == "main");
Vikram S. Adved198c472002-03-18 03:07:26 +000096 }
Vikram S. Adve953c83e2001-10-28 21:38:52 +000097
Chris Lattnere88f78c2001-09-19 13:47:27 +000098 // enterSection - Use this method to enter a different section of the output
99 // executable. This is used to only output neccesary section transitions.
100 //
101 void enterSection(enum Sections S) {
102 if (S == CurSection) return; // Only switch section if neccesary
103 CurSection = S;
104
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000105 toAsm << "\n\t.section ";
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000106 switch (S)
107 {
108 default: assert(0 && "Bad section name!");
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000109 case Text: toAsm << "\".text\""; break;
110 case ReadOnlyData: toAsm << "\".rodata\",#alloc"; break;
111 case InitRWData: toAsm << "\".data\",#alloc,#write"; break;
112 case UninitRWData: toAsm << "\".bss\",#alloc,#write\nBbss.bss:"; break;
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000113 }
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000114 toAsm << "\n";
Chris Lattnere88f78c2001-09-19 13:47:27 +0000115 }
116
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000117 static std::string getValidSymbolName(const string &S) {
Chris Lattnerc56d7792001-09-28 15:07:24 +0000118 string Result;
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000119
120 // Symbol names in Sparc assembly language have these rules:
121 // (a) Must match { letter | _ | . | $ } { letter | _ | . | $ | digit }*
122 // (b) A name beginning in "." is treated as a local name.
123 // (c) Names beginning with "_" are reserved by ANSI C and shd not be used.
124 //
125 if (S[0] == '_' || isdigit(S[0]))
126 Result += "ll";
127
128 for (unsigned i = 0; i < S.size(); ++i)
129 {
130 char C = S[i];
131 if (C == '_' || C == '.' || C == '$' || isalpha(C) || isdigit(C))
132 Result += C;
133 else
134 {
135 Result += '_';
136 Result += char('0' + ((unsigned char)C >> 4));
137 Result += char('0' + (C & 0xF));
138 }
Chris Lattnerc56d7792001-09-28 15:07:24 +0000139 }
Chris Lattnerc56d7792001-09-28 15:07:24 +0000140 return Result;
141 }
142
Chris Lattnere88f78c2001-09-19 13:47:27 +0000143 // getID - Return a valid identifier for the specified value. Base it on
Vikram S. Adved198c472002-03-18 03:07:26 +0000144 // the name of the identifier if possible (qualified by the type), and
145 // use a numbered value based on prefix otherwise.
146 // FPrefix is always prepended to the output identifier.
Chris Lattnere88f78c2001-09-19 13:47:27 +0000147 //
148 string getID(const Value *V, const char *Prefix, const char *FPrefix = 0) {
Vikram S. Adved198c472002-03-18 03:07:26 +0000149 string Result = FPrefix ? FPrefix : ""; // "Forced prefix"
150
151 Result = Result + (V->hasName()? V->getName() : string(Prefix));
152
153 // Qualify all internal names with a unique id.
154 if (!isExternal(V)) {
Chris Lattnerfd63f25f2002-04-28 04:50:54 +0000155 int valId = idTable->Table.getValSlot(V);
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000156 if (valId == -1) {
Vikram S. Adved198c472002-03-18 03:07:26 +0000157 GlobalIdTable::ValIdMapConstIterator I = idTable->valToIdMap.find(V);
158 if (I == idTable->valToIdMap.end())
159 valId = idTable->valToIdMap[V] = idTable->valToIdMap.size();
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000160 else
161 valId = I->second;
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000162 }
Vikram S. Adved198c472002-03-18 03:07:26 +0000163 Result = Result + "_" + itostr(valId);
Chris Lattnere88f78c2001-09-19 13:47:27 +0000164 }
Vikram S. Adved198c472002-03-18 03:07:26 +0000165
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000166 return getValidSymbolName(Result);
Chris Lattnere88f78c2001-09-19 13:47:27 +0000167 }
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000168
Chris Lattnere88f78c2001-09-19 13:47:27 +0000169 // getID Wrappers - Ensure consistent usage...
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000170 string getID(const Function *F) {
171 return getID(F, "LLVMFunction_");
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000172 }
173 string getID(const BasicBlock *BB) {
174 return getID(BB, "LL", (".L_"+getID(BB->getParent())+"_").c_str());
175 }
176 string getID(const GlobalVariable *GV) {
177 return getID(GV, "LLVMGlobal_", ".G_");
178 }
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000179 string getID(const Constant *CV) {
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000180 return getID(CV, "LLVMConst_", ".C_");
181 }
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000182};
183
184
185
186//===----------------------------------------------------------------------===//
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000187// SparcFunctionAsmPrinter Code
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000188//===----------------------------------------------------------------------===//
189
Chris Lattnerf57b8452002-04-27 06:56:12 +0000190struct SparcFunctionAsmPrinter : public FunctionPass, public AsmPrinter {
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000191 inline SparcFunctionAsmPrinter(std::ostream &os, const TargetMachine &t)
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000192 : AsmPrinter(os, t) {}
193
Chris Lattner96c466b2002-04-29 14:57:45 +0000194 const char *getPassName() const {
195 return "Output Sparc Assembly for Functions";
196 }
197
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000198 virtual bool doInitialization(Module &M) {
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000199 startModule(M);
200 return false;
201 }
202
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000203 virtual bool runOnFunction(Function &F) {
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000204 startFunction(F);
205 emitFunction(F);
206 endFunction(F);
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000207 return false;
208 }
209
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000210 virtual bool doFinalization(Module &M) {
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000211 endModule();
212 return false;
213 }
214
Chris Lattner97e52e42002-04-28 21:27:06 +0000215 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
216 AU.setPreservesAll();
217 }
218
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000219 void emitFunction(const Function &F);
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000220private :
221 void emitBasicBlock(const BasicBlock *BB);
222 void emitMachineInst(const MachineInstr *MI);
223
224 unsigned int printOperands(const MachineInstr *MI, unsigned int opNum);
225 void printOneOperand(const MachineOperand &Op);
226
227 bool OpIsBranchTargetLabel(const MachineInstr *MI, unsigned int opNum);
228 bool OpIsMemoryAddressBase(const MachineInstr *MI, unsigned int opNum);
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000229
Chris Lattnere88f78c2001-09-19 13:47:27 +0000230 unsigned getOperandMask(unsigned Opcode) {
231 switch (Opcode) {
232 case SUBcc: return 1 << 3; // Remove CC argument
Vikram S. Adveb2debdc2002-07-08 23:30:59 +0000233 //case BA: return 1 << 0; // Remove Arg #0, which is always null or xcc
Chris Lattnere88f78c2001-09-19 13:47:27 +0000234 default: return 0; // By default, don't hack operands...
235 }
236 }
237};
238
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000239inline bool
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000240SparcFunctionAsmPrinter::OpIsBranchTargetLabel(const MachineInstr *MI,
241 unsigned int opNum) {
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000242 switch (MI->getOpCode()) {
243 case JMPLCALL:
244 case JMPLRET: return (opNum == 0);
245 default: return false;
246 }
247}
248
249
250inline bool
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000251SparcFunctionAsmPrinter::OpIsMemoryAddressBase(const MachineInstr *MI,
252 unsigned int opNum) {
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000253 if (Target.getInstrInfo().isLoad(MI->getOpCode()))
254 return (opNum == 0);
255 else if (Target.getInstrInfo().isStore(MI->getOpCode()))
256 return (opNum == 1);
257 else
258 return false;
259}
260
261
262#define PrintOp1PlusOp2(Op1, Op2) \
263 printOneOperand(Op1); \
264 toAsm << "+"; \
265 printOneOperand(Op2);
266
267unsigned int
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000268SparcFunctionAsmPrinter::printOperands(const MachineInstr *MI,
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000269 unsigned int opNum)
270{
271 const MachineOperand& Op = MI->getOperand(opNum);
272
273 if (OpIsBranchTargetLabel(MI, opNum))
274 {
275 PrintOp1PlusOp2(Op, MI->getOperand(opNum+1));
276 return 2;
277 }
278 else if (OpIsMemoryAddressBase(MI, opNum))
279 {
280 toAsm << "[";
281 PrintOp1PlusOp2(Op, MI->getOperand(opNum+1));
282 toAsm << "]";
283 return 2;
284 }
285 else
286 {
287 printOneOperand(Op);
288 return 1;
289 }
290}
291
292
293void
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000294SparcFunctionAsmPrinter::printOneOperand(const MachineOperand &op)
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000295{
296 switch (op.getOperandType())
297 {
298 case MachineOperand::MO_VirtualRegister:
299 case MachineOperand::MO_CCRegister:
300 case MachineOperand::MO_MachineRegister:
301 {
302 int RegNum = (int)op.getAllocatedRegNum();
303
Vikram S. Advefbd21612002-03-31 19:03:58 +0000304 // better to print code with NULL registers than to die
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000305 if (RegNum == Target.getRegInfo().getInvalidRegNum()) {
306 toAsm << "<NULL VALUE>";
307 } else {
308 toAsm << "%" << Target.getRegInfo().getUnifiedRegName(RegNum);
309 }
310 break;
311 }
312
313 case MachineOperand::MO_PCRelativeDisp:
314 {
315 const Value *Val = op.getVRegValue();
Vikram S. Adve242a8082002-05-19 15:25:51 +0000316 assert(Val && "\tNULL Value in SparcFunctionAsmPrinter");
317
318 if (const BasicBlock *BB = dyn_cast<const BasicBlock>(Val))
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000319 toAsm << getID(BB);
Chris Lattner31bcdb82002-04-28 19:55:58 +0000320 else if (const Function *M = dyn_cast<Function>(Val))
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000321 toAsm << getID(M);
Chris Lattner31bcdb82002-04-28 19:55:58 +0000322 else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(Val))
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000323 toAsm << getID(GV);
Chris Lattner31bcdb82002-04-28 19:55:58 +0000324 else if (const Constant *CV = dyn_cast<Constant>(Val))
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000325 toAsm << getID(CV);
326 else
Vikram S. Adve242a8082002-05-19 15:25:51 +0000327 assert(0 && "Unrecognized value in SparcFunctionAsmPrinter");
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000328 break;
329 }
330
331 case MachineOperand::MO_SignExtendedImmed:
Vikram S. Adve242a8082002-05-19 15:25:51 +0000332 toAsm << op.getImmedValue();
333 break;
334
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000335 case MachineOperand::MO_UnextendedImmed:
Vikram S. Adve242a8082002-05-19 15:25:51 +0000336 toAsm << (uint64_t) op.getImmedValue();
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000337 break;
338
339 default:
340 toAsm << op; // use dump field
341 break;
342 }
343}
344
345
346void
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000347SparcFunctionAsmPrinter::emitMachineInst(const MachineInstr *MI)
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000348{
349 unsigned Opcode = MI->getOpCode();
350
351 if (TargetInstrDescriptors[Opcode].iclass & M_DUMMY_PHI_FLAG)
352 return; // IGNORE PHI NODES
353
354 toAsm << "\t" << TargetInstrDescriptors[Opcode].opCodeString << "\t";
355
356 unsigned Mask = getOperandMask(Opcode);
357
358 bool NeedComma = false;
359 unsigned N = 1;
360 for (unsigned OpNum = 0; OpNum < MI->getNumOperands(); OpNum += N)
361 if (! ((1 << OpNum) & Mask)) { // Ignore this operand?
362 if (NeedComma) toAsm << ", "; // Handle comma outputing
363 NeedComma = true;
364 N = printOperands(MI, OpNum);
365 }
366 else
367 N = 1;
368
369 toAsm << "\n";
370}
371
372void
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000373SparcFunctionAsmPrinter::emitBasicBlock(const BasicBlock *BB)
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000374{
375 // Emit a label for the basic block
376 toAsm << getID(BB) << ":\n";
377
378 // Get the vector of machine instructions corresponding to this bb.
Vikram S. Adveb2debdc2002-07-08 23:30:59 +0000379 const MachineCodeForBasicBlock &MIs = MachineCodeForBasicBlock::get(BB);
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000380 MachineCodeForBasicBlock::const_iterator MII = MIs.begin(), MIE = MIs.end();
381
382 // Loop over all of the instructions in the basic block...
383 for (; MII != MIE; ++MII)
384 emitMachineInst(*MII);
385 toAsm << "\n"; // Seperate BB's with newlines
386}
387
388void
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000389SparcFunctionAsmPrinter::emitFunction(const Function &F)
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000390{
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000391 string methName = getID(&F);
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000392 toAsm << "!****** Outputing Function: " << methName << " ******\n";
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000393 enterSection(AsmPrinter::Text);
394 toAsm << "\t.align\t4\n\t.global\t" << methName << "\n";
395 //toAsm << "\t.type\t" << methName << ",#function\n";
396 toAsm << "\t.type\t" << methName << ", 2\n";
397 toAsm << methName << ":\n";
398
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000399 // Output code for all of the basic blocks in the function...
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000400 for (Function::const_iterator I = F.begin(), E = F.end(); I != E; ++I)
401 emitBasicBlock(I);
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000402
403 // Output a .size directive so the debugger knows the extents of the function
404 toAsm << ".EndOf_" << methName << ":\n\t.size "
405 << methName << ", .EndOf_"
406 << methName << "-" << methName << "\n";
407
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000408 // Put some spaces between the functions
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000409 toAsm << "\n\n";
410}
411
412} // End anonymous namespace
413
Chris Lattnerf57b8452002-04-27 06:56:12 +0000414Pass *UltraSparc::getFunctionAsmPrinterPass(PassManager &PM, std::ostream &Out){
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000415 return new SparcFunctionAsmPrinter(Out, *this);
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000416}
417
418
419
420
421
422//===----------------------------------------------------------------------===//
Chris Lattner2fbfdcf2002-04-07 20:49:59 +0000423// SparcFunctionAsmPrinter Code
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000424//===----------------------------------------------------------------------===//
425
426namespace {
427
428class SparcModuleAsmPrinter : public Pass, public AsmPrinter {
429public:
Chris Lattner49b8a9c2002-02-24 23:02:40 +0000430 SparcModuleAsmPrinter(std::ostream &os, TargetMachine &t)
431 : AsmPrinter(os, t) {}
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000432
Chris Lattner96c466b2002-04-29 14:57:45 +0000433 const char *getPassName() const { return "Output Sparc Assembly for Module"; }
434
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000435 virtual bool run(Module &M) {
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000436 startModule(M);
437 emitGlobalsAndConstants(M);
438 endModule();
439 return false;
440 }
441
Chris Lattner97e52e42002-04-28 21:27:06 +0000442 virtual void getAnalysisUsage(AnalysisUsage &AU) const {
443 AU.setPreservesAll();
444 }
445
446private:
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000447 void emitGlobalsAndConstants(const Module &M);
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000448
449 void printGlobalVariable(const GlobalVariable *GV);
450 void printSingleConstant( const Constant* CV);
451 void printConstantValueOnly(const Constant* CV);
452 void printConstant( const Constant* CV, std::string valID = "");
453
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000454 static void FoldConstants(const Module &M,
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000455 std::hash_set<const Constant*> &moduleConstants);
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000456};
457
Chris Lattnercee8f9a2001-11-27 00:03:19 +0000458
459// Can we treat the specified array as a string? Only if it is an array of
460// ubytes or non-negative sbytes.
461//
Chris Lattner122787b2002-06-05 18:08:26 +0000462static bool isStringCompatible(const ConstantArray *CPA) {
Chris Lattnercee8f9a2001-11-27 00:03:19 +0000463 const Type *ETy = cast<ArrayType>(CPA->getType())->getElementType();
464 if (ETy == Type::UByteTy) return true;
465 if (ETy != Type::SByteTy) return false;
466
467 for (unsigned i = 0; i < CPA->getNumOperands(); ++i)
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000468 if (cast<ConstantSInt>(CPA->getOperand(i))->getValue() < 0)
Chris Lattnercee8f9a2001-11-27 00:03:19 +0000469 return false;
470
471 return true;
472}
473
474// toOctal - Convert the low order bits of X into an octal letter
475static inline char toOctal(int X) {
476 return (X&7)+'0';
477}
478
479// getAsCString - Return the specified array as a C compatible string, only if
480// the predicate isStringCompatible is true.
481//
Chris Lattner122787b2002-06-05 18:08:26 +0000482static string getAsCString(const ConstantArray *CPA) {
Chris Lattner4b1de8e2002-04-18 18:15:38 +0000483 assert(isStringCompatible(CPA) && "Array is not string compatible!");
Chris Lattnercee8f9a2001-11-27 00:03:19 +0000484
Chris Lattner4b1de8e2002-04-18 18:15:38 +0000485 string Result;
486 const Type *ETy = cast<ArrayType>(CPA->getType())->getElementType();
487 Result = "\"";
488 for (unsigned i = 0; i < CPA->getNumOperands(); ++i) {
489 unsigned char C = (ETy == Type::SByteTy) ?
490 (unsigned char)cast<ConstantSInt>(CPA->getOperand(i))->getValue() :
491 (unsigned char)cast<ConstantUInt>(CPA->getOperand(i))->getValue();
492
Vikram S. Adve242a8082002-05-19 15:25:51 +0000493 if (C == '"') {
494 Result += "\\\"";
495 } else if (isprint(C)) {
Chris Lattner4b1de8e2002-04-18 18:15:38 +0000496 Result += C;
497 } else {
498 switch(C) {
499 case '\a': Result += "\\a"; break;
500 case '\b': Result += "\\b"; break;
501 case '\f': Result += "\\f"; break;
502 case '\n': Result += "\\n"; break;
503 case '\r': Result += "\\r"; break;
504 case '\t': Result += "\\t"; break;
505 case '\v': Result += "\\v"; break;
506 default:
507 Result += '\\';
508 Result += toOctal(C >> 6);
509 Result += toOctal(C >> 3);
510 Result += toOctal(C >> 0);
511 break;
Chris Lattnercee8f9a2001-11-27 00:03:19 +0000512 }
513 }
Chris Lattnercee8f9a2001-11-27 00:03:19 +0000514 }
Chris Lattner4b1de8e2002-04-18 18:15:38 +0000515 Result += "\"";
516
517 return Result;
Chris Lattnercee8f9a2001-11-27 00:03:19 +0000518}
519
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000520inline bool
Chris Lattner122787b2002-06-05 18:08:26 +0000521ArrayTypeIsString(const ArrayType* arrayType)
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000522{
523 return (arrayType->getElementType() == Type::UByteTy ||
524 arrayType->getElementType() == Type::SByteTy);
525}
Chris Lattnere88f78c2001-09-19 13:47:27 +0000526
Vikram S. Adve915b58d2001-11-09 02:19:29 +0000527inline const string
528TypeToDataDirective(const Type* type)
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000529{
530 switch(type->getPrimitiveID())
531 {
532 case Type::BoolTyID: case Type::UByteTyID: case Type::SByteTyID:
533 return ".byte";
534 case Type::UShortTyID: case Type::ShortTyID:
535 return ".half";
536 case Type::UIntTyID: case Type::IntTyID:
537 return ".word";
538 case Type::ULongTyID: case Type::LongTyID: case Type::PointerTyID:
539 return ".xword";
540 case Type::FloatTyID:
Chris Lattnerf678dc62002-04-11 21:44:02 +0000541 return ".word";
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000542 case Type::DoubleTyID:
Chris Lattnerf678dc62002-04-11 21:44:02 +0000543 return ".xword";
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000544 case Type::ArrayTyID:
545 if (ArrayTypeIsString((ArrayType*) type))
546 return ".ascii";
547 else
548 return "<InvaliDataTypeForPrinting>";
549 default:
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000550 return "<InvaliDataTypeForPrinting>";
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000551 }
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000552}
553
Vikram S. Adve21447222001-11-10 02:03:06 +0000554// Get the size of the constant for the given target.
555// If this is an unsized array, return 0.
556//
Vikram S. Adve915b58d2001-11-09 02:19:29 +0000557inline unsigned int
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000558ConstantToSize(const Constant* CV, const TargetMachine& target)
Vikram S. Adve915b58d2001-11-09 02:19:29 +0000559{
Chris Lattner122787b2002-06-05 18:08:26 +0000560 if (const ConstantArray* CPA = dyn_cast<ConstantArray>(CV))
Vikram S. Adve21447222001-11-10 02:03:06 +0000561 {
Chris Lattner122787b2002-06-05 18:08:26 +0000562 const ArrayType *aty = cast<ArrayType>(CPA->getType());
Vikram S. Adve21447222001-11-10 02:03:06 +0000563 if (ArrayTypeIsString(aty))
564 return 1 + CPA->getNumOperands();
Vikram S. Adve21447222001-11-10 02:03:06 +0000565 }
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000566
567 return target.findOptimalStorageSize(CV->getType());
568}
569
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000570
571
Vikram S. Adve915b58d2001-11-09 02:19:29 +0000572// Align data larger than one L1 cache line on L1 cache line boundaries.
Vikram S. Adve21447222001-11-10 02:03:06 +0000573// Align all smaller data on the next higher 2^x boundary (4, 8, ...).
574//
575inline unsigned int
576SizeToAlignment(unsigned int size, const TargetMachine& target)
577{
578 unsigned short cacheLineSize = target.getCacheInfo().getCacheLineSize(1);
579 if (size > (unsigned) cacheLineSize / 2)
580 return cacheLineSize;
581 else
582 for (unsigned sz=1; /*no condition*/; sz *= 2)
583 if (sz >= size)
584 return sz;
585}
586
587// Get the size of the type and then use SizeToAlignment.
Vikram S. Adve915b58d2001-11-09 02:19:29 +0000588//
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000589inline unsigned int
590TypeToAlignment(const Type* type, const TargetMachine& target)
591{
Vikram S. Adve21447222001-11-10 02:03:06 +0000592 return SizeToAlignment(target.findOptimalStorageSize(type), target);
593}
594
595// Get the size of the constant and then use SizeToAlignment.
596// Handles strings as a special case;
597inline unsigned int
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000598ConstantToAlignment(const Constant* CV, const TargetMachine& target)
Vikram S. Adve21447222001-11-10 02:03:06 +0000599{
Chris Lattner122787b2002-06-05 18:08:26 +0000600 if (const ConstantArray* CPA = dyn_cast<ConstantArray>(CV))
Vikram S. Adve21447222001-11-10 02:03:06 +0000601 if (ArrayTypeIsString(cast<ArrayType>(CPA->getType())))
602 return SizeToAlignment(1 + CPA->getNumOperands(), target);
603
604 return TypeToAlignment(CV->getType(), target);
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000605}
606
607
Vikram S. Adve21447222001-11-10 02:03:06 +0000608// Print a single constant value.
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000609void
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000610SparcModuleAsmPrinter::printSingleConstant(const Constant* CV)
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000611{
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000612 assert(CV->getType() != Type::VoidTy &&
613 CV->getType() != Type::TypeTy &&
614 CV->getType() != Type::LabelTy &&
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000615 "Unexpected type for Constant");
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000616
Chris Lattnerf678dc62002-04-11 21:44:02 +0000617 assert((!isa<ConstantArray>(CV) && ! isa<ConstantStruct>(CV))
618 && "Aggregate types should be handled outside this function");
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000619
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000620 toAsm << "\t" << TypeToDataDirective(CV->getType()) << "\t";
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000621
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000622 if (CV->getType()->isPrimitiveType())
623 {
Chris Lattnerf678dc62002-04-11 21:44:02 +0000624 if (CV->getType()->isFloatingPoint()) {
625 // FP Constants are printed as integer constants to avoid losing
626 // precision...
627 double Val = cast<ConstantFP>(CV)->getValue();
628 if (CV->getType() == Type::FloatTy) {
629 float FVal = (float)Val;
630 char *ProxyPtr = (char*)&FVal; // Abide by C TBAA rules
631 toAsm << *(unsigned int*)ProxyPtr;
632 } else if (CV->getType() == Type::DoubleTy) {
633 char *ProxyPtr = (char*)&Val; // Abide by C TBAA rules
634 toAsm << *(uint64_t*)ProxyPtr;
635 } else {
636 assert(0 && "Unknown floating point type!");
637 }
638
639 toAsm << "\t! " << CV->getType()->getDescription()
640 << " value: " << Val << "\n";
641 } else {
Chris Lattner4b1de8e2002-04-18 18:15:38 +0000642 WriteAsOperand(toAsm, CV, false, false) << "\n";
Chris Lattnerf678dc62002-04-11 21:44:02 +0000643 }
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000644 }
Chris Lattner122787b2002-06-05 18:08:26 +0000645 else if (const ConstantPointer* CPP = dyn_cast<ConstantPointer>(CV))
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000646 {
Chris Lattner697954c2002-01-20 22:54:45 +0000647 assert(CPP->isNullValue() &&
648 "Cannot yet print non-null pointer constants to assembly");
649 toAsm << "0\n";
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000650 }
Chris Lattner697954c2002-01-20 22:54:45 +0000651 else if (isa<ConstantPointerRef>(CV))
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000652 {
653 assert(0 && "Cannot yet initialize pointer refs in assembly");
654 }
655 else
656 {
Vikram S. Adve915b58d2001-11-09 02:19:29 +0000657 assert(0 && "Unknown elementary type for constant");
Vikram S. Adve29ff8732001-11-08 05:12:37 +0000658 }
Vikram S. Adve915b58d2001-11-09 02:19:29 +0000659}
660
Vikram S. Adve21447222001-11-10 02:03:06 +0000661// Print a constant value or values (it may be an aggregate).
662// Uses printSingleConstant() to print each individual value.
663void
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000664SparcModuleAsmPrinter::printConstantValueOnly(const Constant* CV)
Vikram S. Adve21447222001-11-10 02:03:06 +0000665{
Chris Lattner122787b2002-06-05 18:08:26 +0000666 const ConstantArray *CPA = dyn_cast<ConstantArray>(CV);
Vikram S. Adve21447222001-11-10 02:03:06 +0000667
668 if (CPA && isStringCompatible(CPA))
669 { // print the string alone and return
Chris Lattner697954c2002-01-20 22:54:45 +0000670 toAsm << "\t" << ".ascii" << "\t" << getAsCString(CPA) << "\n";
Vikram S. Adve21447222001-11-10 02:03:06 +0000671 }
672 else if (CPA)
673 { // Not a string. Print the values in successive locations
Chris Lattner697954c2002-01-20 22:54:45 +0000674 const std::vector<Use> &constValues = CPA->getValues();
Vikram S. Adve242a8082002-05-19 15:25:51 +0000675 for (unsigned i=0; i < constValues.size(); i++)
Chris Lattner122787b2002-06-05 18:08:26 +0000676 printConstantValueOnly(cast<Constant>(constValues[i].get()));
Vikram S. Adve21447222001-11-10 02:03:06 +0000677 }
Chris Lattner122787b2002-06-05 18:08:26 +0000678 else if (const ConstantStruct *CPS = dyn_cast<ConstantStruct>(CV))
Vikram S. Adve21447222001-11-10 02:03:06 +0000679 { // Print the fields in successive locations
Chris Lattner697954c2002-01-20 22:54:45 +0000680 const std::vector<Use>& constValues = CPS->getValues();
Vikram S. Adve242a8082002-05-19 15:25:51 +0000681 for (unsigned i=0; i < constValues.size(); i++)
Chris Lattner122787b2002-06-05 18:08:26 +0000682 printConstantValueOnly(cast<Constant>(constValues[i].get()));
Vikram S. Adve21447222001-11-10 02:03:06 +0000683 }
684 else
Chris Lattner122787b2002-06-05 18:08:26 +0000685 printSingleConstant(CV);
Vikram S. Adve21447222001-11-10 02:03:06 +0000686}
687
688// Print a constant (which may be an aggregate) prefixed by all the
689// appropriate directives. Uses printConstantValueOnly() to print the
690// value or values.
Vikram S. Adve915b58d2001-11-09 02:19:29 +0000691void
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000692SparcModuleAsmPrinter::printConstant(const Constant* CV, string valID)
Vikram S. Adve915b58d2001-11-09 02:19:29 +0000693{
694 if (valID.length() == 0)
695 valID = getID(CV);
696
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000697 toAsm << "\t.align\t" << ConstantToAlignment(CV, Target) << "\n";
Vikram S. Adve915b58d2001-11-09 02:19:29 +0000698
699 // Print .size and .type only if it is not a string.
Chris Lattner122787b2002-06-05 18:08:26 +0000700 const ConstantArray *CPA = dyn_cast<ConstantArray>(CV);
Vikram S. Adve915b58d2001-11-09 02:19:29 +0000701 if (CPA && isStringCompatible(CPA))
702 { // print it as a string and return
Chris Lattner697954c2002-01-20 22:54:45 +0000703 toAsm << valID << ":\n";
704 toAsm << "\t" << ".ascii" << "\t" << getAsCString(CPA) << "\n";
Vikram S. Adve915b58d2001-11-09 02:19:29 +0000705 return;
706 }
Vikram S. Adve21447222001-11-10 02:03:06 +0000707
Chris Lattner697954c2002-01-20 22:54:45 +0000708 toAsm << "\t.type" << "\t" << valID << ",#object\n";
Vikram S. Adve21447222001-11-10 02:03:06 +0000709
710 unsigned int constSize = ConstantToSize(CV, Target);
711 if (constSize)
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000712 toAsm << "\t.size" << "\t" << valID << "," << constSize << "\n";
Vikram S. Adve21447222001-11-10 02:03:06 +0000713
Chris Lattner697954c2002-01-20 22:54:45 +0000714 toAsm << valID << ":\n";
Vikram S. Adve915b58d2001-11-09 02:19:29 +0000715
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000716 printConstantValueOnly(CV);
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000717}
718
719
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000720void SparcModuleAsmPrinter::FoldConstants(const Module &M,
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000721 std::hash_set<const Constant*> &MC) {
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000722 for (Module::const_iterator I = M.begin(), E = M.end(); I != E; ++I)
723 if (!I->isExternal()) {
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000724 const std::hash_set<const Constant*> &pool =
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000725 MachineCodeForMethod::get(I).getConstantPoolValues();
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000726 MC.insert(pool.begin(), pool.end());
727 }
728}
729
730void SparcModuleAsmPrinter::printGlobalVariable(const GlobalVariable* GV)
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000731{
Chris Lattner697954c2002-01-20 22:54:45 +0000732 toAsm << "\t.global\t" << getID(GV) << "\n";
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000733
734 if (GV->hasInitializer())
735 printConstant(GV->getInitializer(), getID(GV));
736 else {
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000737 toAsm << "\t.align\t" << TypeToAlignment(GV->getType()->getElementType(),
738 Target) << "\n";
Chris Lattner697954c2002-01-20 22:54:45 +0000739 toAsm << "\t.type\t" << getID(GV) << ",#object\n";
Vikram S. Adveffbba0f2001-11-08 14:29:57 +0000740 toAsm << "\t.reserve\t" << getID(GV) << ","
Chris Lattnerc019a172002-02-03 07:48:06 +0000741 << Target.findOptimalStorageSize(GV->getType()->getElementType())
Chris Lattner697954c2002-01-20 22:54:45 +0000742 << "\n";
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000743 }
744}
745
746
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000747void SparcModuleAsmPrinter::emitGlobalsAndConstants(const Module &M) {
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000748 // First, get the constants there were marked by the code generator for
749 // inclusion in the assembly code data area and fold them all into a
750 // single constant pool since there may be lots of duplicates. Also,
751 // lets force these constants into the slot table so that we can get
752 // unique names for unnamed constants also.
753 //
Chris Lattner697954c2002-01-20 22:54:45 +0000754 std::hash_set<const Constant*> moduleConstants;
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000755 FoldConstants(M, moduleConstants);
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000756
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000757 // Now, emit the three data sections separately; the cost of I/O should
758 // make up for the cost of extra passes over the globals list!
Vikram S. Advefbd21612002-03-31 19:03:58 +0000759
760 // Section 1 : Read-only data section (implies initialized)
761 enterSection(AsmPrinter::ReadOnlyData);
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000762 for (Module::const_giterator GI = M.gbegin(), GE = M.gend(); GI != GE; ++GI)
763 if (GI->hasInitializer() && GI->isConstant())
764 printGlobalVariable(GI);
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000765
Chris Lattner697954c2002-01-20 22:54:45 +0000766 for (std::hash_set<const Constant*>::const_iterator
767 I = moduleConstants.begin(),
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000768 E = moduleConstants.end(); I != E; ++I)
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000769 printConstant(*I);
770
Vikram S. Advefbd21612002-03-31 19:03:58 +0000771 // Section 2 : Initialized read-write data section
772 enterSection(AsmPrinter::InitRWData);
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000773 for (Module::const_giterator GI = M.gbegin(), GE = M.gend(); GI != GE; ++GI)
774 if (GI->hasInitializer() && !GI->isConstant())
775 printGlobalVariable(GI);
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000776
Vikram S. Advefbd21612002-03-31 19:03:58 +0000777 // Section 3 : Uninitialized read-write data section
778 enterSection(AsmPrinter::UninitRWData);
Chris Lattner0b12b5f2002-06-25 16:13:21 +0000779 for (Module::const_giterator GI = M.gbegin(), GE = M.gend(); GI != GE; ++GI)
780 if (!GI->hasInitializer())
781 printGlobalVariable(GI);
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000782
Chris Lattner697954c2002-01-20 22:54:45 +0000783 toAsm << "\n";
Vikram S. Adve953c83e2001-10-28 21:38:52 +0000784}
785
Chris Lattnere88f78c2001-09-19 13:47:27 +0000786} // End anonymous namespace
787
Chris Lattnerc19b8b12002-02-03 23:41:08 +0000788Pass *UltraSparc::getModuleAsmPrinterPass(PassManager &PM, std::ostream &Out) {
789 return new SparcModuleAsmPrinter(Out, *this);
Chris Lattnerc019a172002-02-03 07:48:06 +0000790}