blob: ca586f68ea4e669f6ac18de57ba5099f2fd8c565 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- SparcAsmPrinter.cpp - Sparc LLVM assembly writer ------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file contains a printer that converts from our internal representation
11// of machine-dependent LLVM code to GAS-format SPARC assembly language.
12//
13//===----------------------------------------------------------------------===//
14
15#define DEBUG_TYPE "asm-printer"
16#include "Sparc.h"
17#include "SparcInstrInfo.h"
Chris Lattnere880ec92009-06-19 15:48:10 +000018#include "SparcTargetMachine.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000019#include "llvm/Constants.h"
20#include "llvm/DerivedTypes.h"
21#include "llvm/Module.h"
22#include "llvm/CodeGen/AsmPrinter.h"
Bill Wendling4ff1cdf2009-02-18 23:12:06 +000023#include "llvm/CodeGen/DwarfWriter.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000024#include "llvm/CodeGen/MachineFunctionPass.h"
25#include "llvm/CodeGen/MachineConstantPool.h"
26#include "llvm/CodeGen/MachineInstr.h"
Chris Lattner621c44d2009-08-22 20:48:53 +000027#include "llvm/MC/MCAsmInfo.h"
Chris Lattnerc6f802d2009-09-13 17:14:04 +000028#include "llvm/MC/MCStreamer.h"
29#include "llvm/MC/MCSymbol.h"
Chris Lattnerc4c40a92009-07-28 03:13:23 +000030#include "llvm/Target/TargetLoweringObjectFile.h"
Daniel Dunbarfe5939f2009-07-15 20:24:03 +000031#include "llvm/Target/TargetRegistry.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000032#include "llvm/ADT/Statistic.h"
33#include "llvm/ADT/StringExtras.h"
34#include "llvm/Support/CommandLine.h"
Chris Lattner73266f92009-08-19 05:49:37 +000035#include "llvm/Support/ErrorHandling.h"
36#include "llvm/Support/FormattedStream.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000037#include "llvm/Support/MathExtras.h"
38#include <cctype>
Anton Korobeynikov357a27d2008-02-20 11:08:44 +000039#include <cstring>
Owen Anderson80045bf2008-07-10 01:44:27 +000040#include <map>
Dan Gohmanf17a25c2007-07-18 16:29:46 +000041using namespace llvm;
42
43STATISTIC(EmittedInsts, "Number of machine instrs printed");
44
45namespace {
Nick Lewycky492d06e2009-10-25 06:33:48 +000046 class SparcAsmPrinter : public AsmPrinter {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000047 /// We name each basic block in a Function with a unique number, so
48 /// that we can consistently refer to them later. This is cleared
49 /// at the beginning of each call to runOnMachineFunction().
50 ///
51 typedef std::map<const Value *, unsigned> ValueMapTy;
52 ValueMapTy NumberForBB;
Owen Andersond2d689e2009-06-26 21:45:04 +000053 unsigned BBNumber;
Bill Wendling4f405312009-02-24 08:30:20 +000054 public:
David Greene302008d2009-07-14 20:18:05 +000055 explicit SparcAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
Chris Lattner621c44d2009-08-22 20:48:53 +000056 const MCAsmInfo *T, bool V)
Daniel Dunbarb10d2222009-07-01 01:48:54 +000057 : AsmPrinter(O, TM, T, V), BBNumber(0) {}
Dan Gohmanf17a25c2007-07-18 16:29:46 +000058
59 virtual const char *getPassName() const {
60 return "Sparc Assembly Printer";
61 }
62
Chris Lattnerae982212009-07-21 18:38:57 +000063 void PrintGlobalVariable(const GlobalVariable *GVar);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000064 void printOperand(const MachineInstr *MI, int opNum);
65 void printMemOperand(const MachineInstr *MI, int opNum,
66 const char *Modifier = 0);
67 void printCCOperand(const MachineInstr *MI, int opNum);
68
Chris Lattnerddb259a2009-08-08 01:32:19 +000069 void printInstruction(const MachineInstr *MI); // autogenerated.
Chris Lattner213703c2009-09-13 20:19:22 +000070 static const char *getRegisterName(unsigned RegNo);
Chris Lattner92221692009-09-13 20:08:00 +000071
Dan Gohmanf17a25c2007-07-18 16:29:46 +000072 bool runOnMachineFunction(MachineFunction &F);
Anton Korobeynikov2ffb4732008-10-10 10:15:03 +000073 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
74 unsigned AsmVariant, const char *ExtraCode);
75 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
76 unsigned AsmVariant, const char *ExtraCode);
Chris Lattner49102de2009-09-15 17:46:24 +000077
78 void emitFunctionHeader(const MachineFunction &MF);
79 bool printGetPCX(const MachineInstr *MI, unsigned OpNo);
Dan Gohmanf17a25c2007-07-18 16:29:46 +000080 };
81} // end of anonymous namespace
82
83#include "SparcGenAsmWriter.inc"
84
Evan Cheng8b988692008-02-02 08:39:46 +000085/// runOnMachineFunction - This uses the printInstruction()
Dan Gohmanf17a25c2007-07-18 16:29:46 +000086/// method to print assembly for each instruction.
87///
88bool SparcAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
Bill Wendling4f405312009-02-24 08:30:20 +000089 this->MF = &MF;
90
Dan Gohmanf17a25c2007-07-18 16:29:46 +000091 SetupMachineFunction(MF);
92
93 // Print out constants referenced by the function
94 EmitConstantPool(MF.getConstantPool());
95
96 // BBNumber is used here so that a given Printer will never give two
97 // BBs the same name. (If you have a better way, please let me know!)
Dan Gohmanf17a25c2007-07-18 16:29:46 +000098
99 O << "\n\n";
Chris Lattner49102de2009-09-15 17:46:24 +0000100 emitFunctionHeader(MF);
101
102
Richard Penningtonb246f532009-09-08 12:47:30 +0000103 // Emit pre-function debug information.
104 DW->BeginFunction(&MF);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000105
106 // Number each basic block so that we can consistently refer to them
107 // in PC-relative references.
108 // FIXME: Why not use the MBB numbers?
109 NumberForBB.clear();
110 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
111 I != E; ++I) {
112 NumberForBB[I->getBasicBlock()] = BBNumber++;
113 }
114
115 // Print out code for the function.
116 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
117 I != E; ++I) {
118 // Print a label for the basic block.
119 if (I != MF.begin()) {
Chris Lattner2faa4ef2009-09-13 18:25:37 +0000120 EmitBasicBlockStart(I);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000121 }
122 for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
123 II != E; ++II) {
124 // Print the assembly for the instruction.
Devang Patel5450fc12009-10-06 02:19:11 +0000125 processDebugLoc(II, true);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000126 printInstruction(II);
Chris Lattner32d4cc72009-09-09 23:14:36 +0000127
David Greeneca9b04b2009-11-13 21:34:57 +0000128 if (VerboseAsm)
Chris Lattner32d4cc72009-09-09 23:14:36 +0000129 EmitComments(*II);
130 O << '\n';
Devang Patel5450fc12009-10-06 02:19:11 +0000131 processDebugLoc(II, false);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000132 ++EmittedInsts;
133 }
134 }
135
Richard Penningtonb246f532009-09-08 12:47:30 +0000136 // Emit post-function debug information.
137 DW->EndFunction(&MF);
138
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000139 // We didn't modify anything.
Chris Lattnerce409842010-01-17 21:43:43 +0000140 O << "\t.size\t" << *CurrentFnSym << ", .-" << *CurrentFnSym << '\n';
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000141 return false;
142}
143
Chris Lattner49102de2009-09-15 17:46:24 +0000144void SparcAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
145 const Function *F = MF.getFunction();
146 OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(F, Mang, TM));
147 EmitAlignment(MF.getAlignment(), F);
148
149 switch (F->getLinkage()) {
150 default: llvm_unreachable("Unknown linkage type");
151 case Function::PrivateLinkage:
152 case Function::InternalLinkage:
153 // Function is internal.
154 break;
155 case Function::DLLExportLinkage:
156 case Function::ExternalLinkage:
157 // Function is externally visible
Chris Lattnerce409842010-01-17 21:43:43 +0000158 O << "\t.global\t" << *CurrentFnSym << '\n';
Chris Lattner49102de2009-09-15 17:46:24 +0000159 break;
160 case Function::LinkerPrivateLinkage:
161 case Function::LinkOnceAnyLinkage:
162 case Function::LinkOnceODRLinkage:
163 case Function::WeakAnyLinkage:
164 case Function::WeakODRLinkage:
165 // Function is weak
Chris Lattnerce409842010-01-17 21:43:43 +0000166 O << "\t.weak\t" << *CurrentFnSym << '\n';
Chris Lattner49102de2009-09-15 17:46:24 +0000167 break;
168 }
169
Chris Lattner651adf32010-01-16 00:21:18 +0000170 printVisibility(CurrentFnSym, F->getVisibility());
Chris Lattner49102de2009-09-15 17:46:24 +0000171
Chris Lattnerce409842010-01-17 21:43:43 +0000172 O << "\t.type\t" << *CurrentFnSym << ", #function\n";
173 O << *CurrentFnSym << ":\n";
Chris Lattner49102de2009-09-15 17:46:24 +0000174}
175
176
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000177void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
178 const MachineOperand &MO = MI->getOperand (opNum);
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000179 bool CloseParen = false;
Dan Gohmanb9f4fa72008-10-03 15:45:36 +0000180 if (MI->getOpcode() == SP::SETHIi && !MO.isReg() && !MO.isImm()) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000181 O << "%hi(";
182 CloseParen = true;
Dan Gohmanb9f4fa72008-10-03 15:45:36 +0000183 } else if ((MI->getOpcode() == SP::ORri || MI->getOpcode() == SP::ADDri) &&
184 !MO.isReg() && !MO.isImm()) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000185 O << "%lo(";
186 CloseParen = true;
187 }
188 switch (MO.getType()) {
189 case MachineOperand::MO_Register:
Chris Lattnerf0a25de2009-09-13 20:31:40 +0000190 O << "%" << LowercaseString(getRegisterName(MO.getReg()));
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000191 break;
192
193 case MachineOperand::MO_Immediate:
Chris Lattnera96056a2007-12-30 20:49:49 +0000194 O << (int)MO.getImm();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000195 break;
196 case MachineOperand::MO_MachineBasicBlock:
Chris Lattnerce409842010-01-17 21:43:43 +0000197 O << *GetMBBSymbol(MO.getMBB()->getNumber());
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000198 return;
199 case MachineOperand::MO_GlobalAddress:
Chris Lattnerce409842010-01-17 21:43:43 +0000200 O << *GetGlobalValueSymbol(MO.getGlobal());
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000201 break;
202 case MachineOperand::MO_ExternalSymbol:
203 O << MO.getSymbolName();
204 break;
205 case MachineOperand::MO_ConstantPoolIndex:
Chris Lattnera5ef4d32009-08-22 21:43:10 +0000206 O << MAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
Chris Lattner6017d482007-12-30 23:10:15 +0000207 << MO.getIndex();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000208 break;
209 default:
Edwin Törökbd448e32009-07-14 16:55:14 +0000210 llvm_unreachable("<unknown operand type>");
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000211 }
212 if (CloseParen) O << ")";
213}
214
215void SparcAsmPrinter::printMemOperand(const MachineInstr *MI, int opNum,
216 const char *Modifier) {
217 printOperand(MI, opNum);
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000218
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000219 // If this is an ADD operand, emit it like normal operands.
220 if (Modifier && !strcmp(Modifier, "arith")) {
221 O << ", ";
222 printOperand(MI, opNum+1);
223 return;
224 }
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000225
Dan Gohmanb9f4fa72008-10-03 15:45:36 +0000226 if (MI->getOperand(opNum+1).isReg() &&
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000227 MI->getOperand(opNum+1).getReg() == SP::G0)
228 return; // don't print "+%g0"
Dan Gohmanb9f4fa72008-10-03 15:45:36 +0000229 if (MI->getOperand(opNum+1).isImm() &&
Chris Lattnera96056a2007-12-30 20:49:49 +0000230 MI->getOperand(opNum+1).getImm() == 0)
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000231 return; // don't print "+0"
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000232
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000233 O << "+";
Dan Gohmanb9f4fa72008-10-03 15:45:36 +0000234 if (MI->getOperand(opNum+1).isGlobal() ||
235 MI->getOperand(opNum+1).isCPI()) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000236 O << "%lo(";
237 printOperand(MI, opNum+1);
238 O << ")";
239 } else {
240 printOperand(MI, opNum+1);
241 }
242}
243
Chris Lattner49102de2009-09-15 17:46:24 +0000244bool SparcAsmPrinter::printGetPCX(const MachineInstr *MI, unsigned opNum) {
245 std::string operand = "";
246 const MachineOperand &MO = MI->getOperand(opNum);
247 switch (MO.getType()) {
248 default: assert(0 && "Operand is not a register ");
249 case MachineOperand::MO_Register:
250 assert(TargetRegisterInfo::isPhysicalRegister(MO.getReg()) &&
251 "Operand is not a physical register ");
252 operand = "%" + LowercaseString(getRegisterName(MO.getReg()));
253 break;
254 }
255
256 unsigned bbNum = NumberForBB[MI->getParent()->getBasicBlock()];
257
258 O << '\n' << ".LLGETPCH" << bbNum << ":\n";
259 O << "\tcall\t.LLGETPC" << bbNum << '\n' ;
260
261 O << "\t sethi\t"
262 << "%hi(_GLOBAL_OFFSET_TABLE_+(.-.LLGETPCH" << bbNum << ")), "
263 << operand << '\n' ;
264
265 O << ".LLGETPC" << bbNum << ":\n" ;
266 O << "\tor\t" << operand
267 << ", %lo(_GLOBAL_OFFSET_TABLE_+(.-.LLGETPCH" << bbNum << ")), "
268 << operand << '\n';
269 O << "\tadd\t" << operand << ", %o7, " << operand << '\n';
270
271 return true;
272}
273
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000274void SparcAsmPrinter::printCCOperand(const MachineInstr *MI, int opNum) {
Chris Lattnera96056a2007-12-30 20:49:49 +0000275 int CC = (int)MI->getOperand(opNum).getImm();
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000276 O << SPARCCondCodeToString((SPCC::CondCodes)CC);
277}
278
Chris Lattnerae982212009-07-21 18:38:57 +0000279void SparcAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) {
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000280 const TargetData *TD = TM.getTargetData();
281
282 if (!GVar->hasInitializer())
283 return; // External global require no code
284
285 // Check to see if this is a special global used by LLVM, if so, emit it.
286 if (EmitSpecialLLVMGlobal(GVar))
287 return;
288
289 O << "\n\n";
Chris Lattner22b24952010-01-16 01:12:01 +0000290 MCSymbol *GVarSym = GetGlobalValueSymbol(GVar);
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000291 Constant *C = GVar->getInitializer();
Duncan Sandsec4f97d2009-05-09 07:06:46 +0000292 unsigned Size = TD->getTypeAllocSize(C->getType());
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000293 unsigned Align = TD->getPreferredAlignment(GVar);
294
Chris Lattner22b24952010-01-16 01:12:01 +0000295 printVisibility(GVarSym, GVar->getVisibility());
Anton Korobeynikov78d69aa2008-08-08 18:25:07 +0000296
Chris Lattner73266f92009-08-19 05:49:37 +0000297 OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GVar, Mang,
298 TM));
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000299
300 if (C->isNullValue() && !GVar->hasSection()) {
301 if (!GVar->isThreadLocal() &&
Duncan Sands19d161f2009-03-07 15:45:40 +0000302 (GVar->hasLocalLinkage() || GVar->isWeakForLinker())) {
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000303 if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
304
Chris Lattner22b24952010-01-16 01:12:01 +0000305 if (GVar->hasLocalLinkage()) {
Chris Lattnerce409842010-01-17 21:43:43 +0000306 O << "\t.local " << *GVarSym << '\n';
Chris Lattner22b24952010-01-16 01:12:01 +0000307 }
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000308
Chris Lattnerce409842010-01-17 21:43:43 +0000309 O << MAI->getCOMMDirective() << *GVarSym << ',' << Size;
Chris Lattnera5ef4d32009-08-22 21:43:10 +0000310 if (MAI->getCOMMDirectiveTakesAlignment())
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000311 O << ',' << (1 << Align);
312
313 O << '\n';
314 return;
315 }
316 }
317
318 switch (GVar->getLinkage()) {
Duncan Sandsb95df792009-03-11 20:14:15 +0000319 case GlobalValue::CommonLinkage:
Duncan Sands19d161f2009-03-07 15:45:40 +0000320 case GlobalValue::LinkOnceAnyLinkage:
321 case GlobalValue::LinkOnceODRLinkage:
322 case GlobalValue::WeakAnyLinkage: // FIXME: Verify correct for weak.
323 case GlobalValue::WeakODRLinkage: // FIXME: Verify correct for weak.
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000324 // Nonnull linkonce -> weak
Chris Lattnerce409842010-01-17 21:43:43 +0000325 O << "\t.weak " << *GVarSym << '\n';
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000326 break;
327 case GlobalValue::AppendingLinkage:
328 // FIXME: appending linkage variables should go into a section of
329 // their name or something. For now, just emit them as external.
330 case GlobalValue::ExternalLinkage:
331 // If external or appending, declare as a global symbol
Chris Lattnerce409842010-01-17 21:43:43 +0000332 O << MAI->getGlobalDirective() << *GVarSym << '\n';
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000333 // FALL THROUGH
Rafael Espindolaa168fc92009-01-15 20:18:42 +0000334 case GlobalValue::PrivateLinkage:
Bill Wendling41a07852009-07-20 01:03:30 +0000335 case GlobalValue::LinkerPrivateLinkage:
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000336 case GlobalValue::InternalLinkage:
337 break;
338 case GlobalValue::GhostLinkage:
Edwin Törökbd448e32009-07-14 16:55:14 +0000339 llvm_unreachable("Should not have any unmaterialized functions!");
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000340 case GlobalValue::DLLImportLinkage:
Edwin Törökbd448e32009-07-14 16:55:14 +0000341 llvm_unreachable("DLLImport linkage is not supported by this target!");
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000342 case GlobalValue::DLLExportLinkage:
Edwin Törökbd448e32009-07-14 16:55:14 +0000343 llvm_unreachable("DLLExport linkage is not supported by this target!");
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000344 default:
Edwin Törökbd448e32009-07-14 16:55:14 +0000345 llvm_unreachable("Unknown linkage type!");
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000346 }
347
Anton Korobeynikovb59b2292008-08-07 09:53:38 +0000348 EmitAlignment(Align, GVar);
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000349
Chris Lattnera5ef4d32009-08-22 21:43:10 +0000350 if (MAI->hasDotTypeDotSizeDirective()) {
Chris Lattnerce409842010-01-17 21:43:43 +0000351 O << "\t.type " << *GVarSym << ",#object\n";
352 O << "\t.size " << *GVarSym << ',' << Size << '\n';
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000353 }
354
Chris Lattnerce409842010-01-17 21:43:43 +0000355 O << *GVarSym << ":\n";
Anton Korobeynikovdb9a895b2008-08-07 09:51:25 +0000356 EmitGlobalConstant(C);
357}
Anton Korobeynikov2ffb4732008-10-10 10:15:03 +0000358
359/// PrintAsmOperand - Print out an operand for an inline asm expression.
360///
361bool SparcAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
362 unsigned AsmVariant,
363 const char *ExtraCode) {
Anton Korobeynikov678468b2008-10-10 20:29:50 +0000364 if (ExtraCode && ExtraCode[0]) {
365 if (ExtraCode[1] != 0) return true; // Unknown modifier.
366
367 switch (ExtraCode[0]) {
368 default: return true; // Unknown modifier.
369 case 'r':
370 break;
371 }
372 }
Anton Korobeynikov2ffb4732008-10-10 10:15:03 +0000373
374 printOperand(MI, OpNo);
375
376 return false;
377}
378
379bool SparcAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
380 unsigned OpNo,
381 unsigned AsmVariant,
382 const char *ExtraCode) {
383 if (ExtraCode && ExtraCode[0])
384 return true; // Unknown modifier
385
386 O << '[';
387 printMemOperand(MI, OpNo);
388 O << ']';
389
390 return false;
391}
Douglas Gregor1dc5ff42009-06-16 20:12:29 +0000392
Bob Wilsonebbc1c42009-06-23 23:59:40 +0000393// Force static initialization.
Daniel Dunbarfe5939f2009-07-15 20:24:03 +0000394extern "C" void LLVMInitializeSparcAsmPrinter() {
Daniel Dunbarc680b012009-07-25 06:49:55 +0000395 RegisterAsmPrinter<SparcAsmPrinter> X(TheSparcTarget);
Daniel Dunbarfe5939f2009-07-15 20:24:03 +0000396}