blob: 71bd0dee206854556599531ed3668daaa91a60f1 [file] [log] [blame]
Chris Lattner7c90f732006-02-05 05:50:24 +00001//===-- SparcAsmPrinter.cpp - Sparc LLVM assembly writer ------------------===//
Misha Brukmanb5f662f2005-04-21 23:30:14 +00002//
Brian Gaeke4acfd032004-03-04 06:00:41 +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 Brukmanb5f662f2005-04-21 23:30:14 +00007//
Brian Gaeke4acfd032004-03-04 06:00:41 +00008//===----------------------------------------------------------------------===//
9//
10// This file contains a printer that converts from our internal representation
Chris Lattner7c90f732006-02-05 05:50:24 +000011// of machine-dependent LLVM code to GAS-format SPARC assembly language.
Brian Gaeke4acfd032004-03-04 06:00:41 +000012//
13//===----------------------------------------------------------------------===//
14
Chris Lattner95b2c7d2006-12-19 22:59:26 +000015#define DEBUG_TYPE "asm-printer"
Chris Lattner7c90f732006-02-05 05:50:24 +000016#include "Sparc.h"
17#include "SparcInstrInfo.h"
Chris Lattner225503a2009-06-19 15:48:10 +000018#include "SparcTargetMachine.h"
Brian Gaeke4acfd032004-03-04 06:00:41 +000019#include "llvm/Constants.h"
20#include "llvm/DerivedTypes.h"
21#include "llvm/Module.h"
Devang Patele4c0c0f2009-06-25 00:47:42 +000022#include "llvm/MDNode.h"
Chris Lattner1dbed162005-12-17 07:04:29 +000023#include "llvm/CodeGen/AsmPrinter.h"
Bill Wendlingcb819f12009-02-18 23:12:06 +000024#include "llvm/CodeGen/DwarfWriter.h"
Brian Gaeke4acfd032004-03-04 06:00:41 +000025#include "llvm/CodeGen/MachineFunctionPass.h"
26#include "llvm/CodeGen/MachineConstantPool.h"
27#include "llvm/CodeGen/MachineInstr.h"
Jim Laskey563321a2006-09-06 18:34:40 +000028#include "llvm/Target/TargetAsmInfo.h"
Brian Gaeke4acfd032004-03-04 06:00:41 +000029#include "llvm/Support/Mangler.h"
Owen Andersoncb371882008-08-21 00:14:44 +000030#include "llvm/Support/raw_ostream.h"
Brian Gaeke74dfcf12004-09-02 02:37:43 +000031#include "llvm/ADT/Statistic.h"
32#include "llvm/ADT/StringExtras.h"
33#include "llvm/Support/CommandLine.h"
Jim Laskeyb8df7c22005-08-17 20:04:34 +000034#include "llvm/Support/MathExtras.h"
Brian Gaekea8b00ca2004-03-06 05:30:21 +000035#include <cctype>
Anton Korobeynikovae9f3a32008-02-20 11:08:44 +000036#include <cstring>
Owen Andersonc0078482008-07-10 01:44:27 +000037#include <map>
Brian Gaeke4acfd032004-03-04 06:00:41 +000038using namespace llvm;
39
Chris Lattner95b2c7d2006-12-19 22:59:26 +000040STATISTIC(EmittedInsts, "Number of machine instrs printed");
Brian Gaeke4acfd032004-03-04 06:00:41 +000041
Chris Lattner95b2c7d2006-12-19 22:59:26 +000042namespace {
Bill Wendling57f0db82009-02-24 08:30:20 +000043 class VISIBILITY_HIDDEN SparcAsmPrinter : public AsmPrinter {
Brian Gaeke4acfd032004-03-04 06:00:41 +000044 /// We name each basic block in a Function with a unique number, so
45 /// that we can consistently refer to them later. This is cleared
46 /// at the beginning of each call to runOnMachineFunction().
47 ///
48 typedef std::map<const Value *, unsigned> ValueMapTy;
49 ValueMapTy NumberForBB;
Owen Anderson2af72d42009-06-26 21:45:04 +000050 unsigned BBNumber;
Bill Wendling57f0db82009-02-24 08:30:20 +000051 public:
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +000052 explicit SparcAsmPrinter(raw_ostream &O, TargetMachine &TM,
Daniel Dunbar5bcc8bd2009-07-01 01:48:54 +000053 const TargetAsmInfo *T, bool V)
54 : AsmPrinter(O, TM, T, V), BBNumber(0) {}
Brian Gaeke4acfd032004-03-04 06:00:41 +000055
Brian Gaeke4acfd032004-03-04 06:00:41 +000056 virtual const char *getPassName() const {
Chris Lattner7c90f732006-02-05 05:50:24 +000057 return "Sparc Assembly Printer";
Brian Gaeke4acfd032004-03-04 06:00:41 +000058 }
59
Anton Korobeynikov5b794b92008-08-07 09:51:25 +000060 void printModuleLevelGV(const GlobalVariable* GVar);
Brian Gaeke446ae112004-06-15 19:52:59 +000061 void printOperand(const MachineInstr *MI, int opNum);
Chris Lattnerad7a3e62006-02-10 07:35:42 +000062 void printMemOperand(const MachineInstr *MI, int opNum,
63 const char *Modifier = 0);
Chris Lattner7c90f732006-02-05 05:50:24 +000064 void printCCOperand(const MachineInstr *MI, int opNum);
Chris Lattner6788faa2006-01-31 06:49:09 +000065
Chris Lattner994b7352005-12-16 06:34:17 +000066 bool printInstruction(const MachineInstr *MI); // autogenerated.
Misha Brukmanb5f662f2005-04-21 23:30:14 +000067 bool runOnMachineFunction(MachineFunction &F);
Brian Gaeke4acfd032004-03-04 06:00:41 +000068 bool doInitialization(Module &M);
69 bool doFinalization(Module &M);
Anton Korobeynikovf3693302008-10-10 10:15:03 +000070 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
71 unsigned AsmVariant, const char *ExtraCode);
72 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
73 unsigned AsmVariant, const char *ExtraCode);
Brian Gaeke4acfd032004-03-04 06:00:41 +000074 };
75} // end of anonymous namespace
76
Chris Lattner7c90f732006-02-05 05:50:24 +000077#include "SparcGenAsmWriter.inc"
Chris Lattner994b7352005-12-16 06:34:17 +000078
Chris Lattner7c90f732006-02-05 05:50:24 +000079/// createSparcCodePrinterPass - Returns a pass that prints the SPARC
Brian Gaeke4acfd032004-03-04 06:00:41 +000080/// assembly code for a MachineFunction to the given output stream,
81/// using the given target machine description. This should work
82/// regardless of whether the function is in SSA form.
83///
Owen Andersoncb371882008-08-21 00:14:44 +000084FunctionPass *llvm::createSparcCodePrinterPass(raw_ostream &o,
Bill Wendling57f0db82009-02-24 08:30:20 +000085 TargetMachine &tm,
Bill Wendlingbe8cc2a2009-04-29 00:15:41 +000086 bool verbose) {
Daniel Dunbar5bcc8bd2009-07-01 01:48:54 +000087 return new SparcAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
Brian Gaeke4acfd032004-03-04 06:00:41 +000088}
89
Chris Lattner225503a2009-06-19 15:48:10 +000090
Evan Cheng4eecdeb2008-02-02 08:39:46 +000091/// runOnMachineFunction - This uses the printInstruction()
Brian Gaeke4acfd032004-03-04 06:00:41 +000092/// method to print assembly for each instruction.
93///
Chris Lattner7c90f732006-02-05 05:50:24 +000094bool SparcAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
Bill Wendling57f0db82009-02-24 08:30:20 +000095 this->MF = &MF;
96
Chris Lattner1dbed162005-12-17 07:04:29 +000097 SetupMachineFunction(MF);
98
Chris Lattnerb5e9eb62005-12-17 07:11:43 +000099 // Print out constants referenced by the function
100 EmitConstantPool(MF.getConstantPool());
101
Brian Gaeke4acfd032004-03-04 06:00:41 +0000102 // BBNumber is used here so that a given Printer will never give two
103 // BBs the same name. (If you have a better way, please let me know!)
Brian Gaeke4acfd032004-03-04 06:00:41 +0000104
105 O << "\n\n";
Brian Gaeke4acfd032004-03-04 06:00:41 +0000106
Chris Lattner29bd9e12006-10-05 02:48:40 +0000107 // Print out the label for the function.
108 const Function *F = MF.getFunction();
Anton Korobeynikovc25e1ea2008-09-24 22:14:23 +0000109 SwitchToSection(TAI->SectionForGlobal(F));
Bill Wendling20c568f2009-06-30 22:38:32 +0000110 EmitAlignment(MF.getAlignment(), F);
Anton Korobeynikov2a166e92008-08-07 09:53:13 +0000111 O << "\t.globl\t" << CurrentFnName << '\n';
Anton Korobeynikovf5b6a472008-08-08 18:25:07 +0000112
113 printVisibility(CurrentFnName, F->getVisibility());
114
Brian Gaeke54cc3c22004-03-16 22:52:04 +0000115 O << "\t.type\t" << CurrentFnName << ", #function\n";
Brian Gaeke4acfd032004-03-04 06:00:41 +0000116 O << CurrentFnName << ":\n";
117
118 // Number each basic block so that we can consistently refer to them
119 // in PC-relative references.
Chris Lattner29bd9e12006-10-05 02:48:40 +0000120 // FIXME: Why not use the MBB numbers?
Brian Gaeke4acfd032004-03-04 06:00:41 +0000121 NumberForBB.clear();
122 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
123 I != E; ++I) {
124 NumberForBB[I->getBasicBlock()] = BBNumber++;
125 }
126
127 // Print out code for the function.
128 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
129 I != E; ++I) {
130 // Print a label for the basic block.
Nate Begemancdf38c42006-05-02 05:37:32 +0000131 if (I != MF.begin()) {
Evan Chengfb8075d2008-02-28 00:43:03 +0000132 printBasicBlockLabel(I, true, true);
Nate Begemancdf38c42006-05-02 05:37:32 +0000133 O << '\n';
134 }
Brian Gaeke4acfd032004-03-04 06:00:41 +0000135 for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
Misha Brukman27177f82005-04-22 18:06:01 +0000136 II != E; ++II) {
Brian Gaeke4acfd032004-03-04 06:00:41 +0000137 // Print the assembly for the instruction.
Chris Lattner0d8fcd32005-12-17 06:54:41 +0000138 printInstruction(II);
Chris Lattner1dbed162005-12-17 07:04:29 +0000139 ++EmittedInsts;
Brian Gaeke4acfd032004-03-04 06:00:41 +0000140 }
141 }
142
143 // We didn't modify anything.
144 return false;
145}
146
Chris Lattner7c90f732006-02-05 05:50:24 +0000147void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum) {
Brian Gaeke446ae112004-06-15 19:52:59 +0000148 const MachineOperand &MO = MI->getOperand (opNum);
Dan Gohman6f0d0242008-02-10 18:45:23 +0000149 const TargetRegisterInfo &RI = *TM.getRegisterInfo();
Brian Gaeke446ae112004-06-15 19:52:59 +0000150 bool CloseParen = false;
Dan Gohmand735b802008-10-03 15:45:36 +0000151 if (MI->getOpcode() == SP::SETHIi && !MO.isReg() && !MO.isImm()) {
Brian Gaeke446ae112004-06-15 19:52:59 +0000152 O << "%hi(";
153 CloseParen = true;
Dan Gohmand735b802008-10-03 15:45:36 +0000154 } else if ((MI->getOpcode() == SP::ORri || MI->getOpcode() == SP::ADDri) &&
155 !MO.isReg() && !MO.isImm()) {
Brian Gaeke446ae112004-06-15 19:52:59 +0000156 O << "%lo(";
157 CloseParen = true;
158 }
Brian Gaeke62aa28a2004-03-05 08:39:09 +0000159 switch (MO.getType()) {
Chris Lattner2d90ac72006-05-04 18:05:43 +0000160 case MachineOperand::MO_Register:
Dan Gohman6f0d0242008-02-10 18:45:23 +0000161 if (TargetRegisterInfo::isPhysicalRegister(MO.getReg()))
Bill Wendling74ab84c2008-02-26 21:11:01 +0000162 O << "%" << LowercaseString (RI.get(MO.getReg()).AsmName);
Brian Gaeke62aa28a2004-03-05 08:39:09 +0000163 else
164 O << "%reg" << MO.getReg();
Brian Gaeke446ae112004-06-15 19:52:59 +0000165 break;
Brian Gaeke62aa28a2004-03-05 08:39:09 +0000166
Chris Lattner63b3d712006-05-04 17:21:20 +0000167 case MachineOperand::MO_Immediate:
Chris Lattner9a1ceae2007-12-30 20:49:49 +0000168 O << (int)MO.getImm();
Brian Gaeke446ae112004-06-15 19:52:59 +0000169 break;
Nate Begeman37efe672006-04-22 18:53:45 +0000170 case MachineOperand::MO_MachineBasicBlock:
Chris Lattner8aa797a2007-12-30 23:10:15 +0000171 printBasicBlockLabel(MO.getMBB());
Brian Gaeke09c13092004-06-17 19:39:23 +0000172 return;
Brian Gaeke62aa28a2004-03-05 08:39:09 +0000173 case MachineOperand::MO_GlobalAddress:
Rafael Espindolabb46f522009-01-15 20:18:42 +0000174 {
175 const GlobalValue *GV = MO.getGlobal();
176 O << Mang->getValueName(GV);
177 }
Brian Gaeke446ae112004-06-15 19:52:59 +0000178 break;
Brian Gaeke62aa28a2004-03-05 08:39:09 +0000179 case MachineOperand::MO_ExternalSymbol:
180 O << MO.getSymbolName();
Brian Gaeke446ae112004-06-15 19:52:59 +0000181 break;
Brian Gaeke8a0ae9e2004-06-27 22:50:44 +0000182 case MachineOperand::MO_ConstantPoolIndex:
Evan Cheng347d39f2007-10-14 05:57:21 +0000183 O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << "_"
Chris Lattner8aa797a2007-12-30 23:10:15 +0000184 << MO.getIndex();
Brian Gaeke8a0ae9e2004-06-27 22:50:44 +0000185 break;
Brian Gaeke62aa28a2004-03-05 08:39:09 +0000186 default:
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000187 O << "<unknown operand type>"; abort (); break;
Brian Gaeke62aa28a2004-03-05 08:39:09 +0000188 }
Brian Gaeke446ae112004-06-15 19:52:59 +0000189 if (CloseParen) O << ")";
Brian Gaeke62aa28a2004-03-05 08:39:09 +0000190}
191
Chris Lattnerad7a3e62006-02-10 07:35:42 +0000192void SparcAsmPrinter::printMemOperand(const MachineInstr *MI, int opNum,
193 const char *Modifier) {
Chris Lattnerbc83fd92005-12-17 20:04:49 +0000194 printOperand(MI, opNum);
Anton Korobeynikov5b794b92008-08-07 09:51:25 +0000195
Chris Lattnerad7a3e62006-02-10 07:35:42 +0000196 // If this is an ADD operand, emit it like normal operands.
197 if (Modifier && !strcmp(Modifier, "arith")) {
198 O << ", ";
199 printOperand(MI, opNum+1);
200 return;
201 }
Anton Korobeynikov5b794b92008-08-07 09:51:25 +0000202
Dan Gohmand735b802008-10-03 15:45:36 +0000203 if (MI->getOperand(opNum+1).isReg() &&
Chris Lattner7c90f732006-02-05 05:50:24 +0000204 MI->getOperand(opNum+1).getReg() == SP::G0)
Chris Lattner76acc872005-12-18 02:37:35 +0000205 return; // don't print "+%g0"
Dan Gohmand735b802008-10-03 15:45:36 +0000206 if (MI->getOperand(opNum+1).isImm() &&
Chris Lattner9a1ceae2007-12-30 20:49:49 +0000207 MI->getOperand(opNum+1).getImm() == 0)
Chris Lattner76acc872005-12-18 02:37:35 +0000208 return; // don't print "+0"
Anton Korobeynikov5b794b92008-08-07 09:51:25 +0000209
Chris Lattnerbc83fd92005-12-17 20:04:49 +0000210 O << "+";
Dan Gohmand735b802008-10-03 15:45:36 +0000211 if (MI->getOperand(opNum+1).isGlobal() ||
212 MI->getOperand(opNum+1).isCPI()) {
Chris Lattnere1389ad2005-12-18 02:27:00 +0000213 O << "%lo(";
214 printOperand(MI, opNum+1);
215 O << ")";
216 } else {
217 printOperand(MI, opNum+1);
218 }
Chris Lattnerbc83fd92005-12-17 20:04:49 +0000219}
220
Chris Lattner7c90f732006-02-05 05:50:24 +0000221void SparcAsmPrinter::printCCOperand(const MachineInstr *MI, int opNum) {
Chris Lattner9a1ceae2007-12-30 20:49:49 +0000222 int CC = (int)MI->getOperand(opNum).getImm();
Chris Lattner7c90f732006-02-05 05:50:24 +0000223 O << SPARCCondCodeToString((SPCC::CondCodes)CC);
Chris Lattner6788faa2006-01-31 06:49:09 +0000224}
225
Chris Lattner7c90f732006-02-05 05:50:24 +0000226bool SparcAsmPrinter::doInitialization(Module &M) {
Rafael Espindolabb46f522009-01-15 20:18:42 +0000227 Mang = new Mangler(M, "", TAI->getPrivateGlobalPrefix());
Brian Gaeke4acfd032004-03-04 06:00:41 +0000228 return false; // success
229}
230
Chris Lattner7c90f732006-02-05 05:50:24 +0000231bool SparcAsmPrinter::doFinalization(Module &M) {
Brian Gaeke4acfd032004-03-04 06:00:41 +0000232 // Print out module-level global variables here.
Chris Lattner04f96742006-03-09 06:14:35 +0000233 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
234 I != E; ++I)
Anton Korobeynikov5b794b92008-08-07 09:51:25 +0000235 printModuleLevelGV(I);
Brian Gaeke4acfd032004-03-04 06:00:41 +0000236
Anton Korobeynikov5b794b92008-08-07 09:51:25 +0000237 O << '\n';
Brian Gaeke4acfd032004-03-04 06:00:41 +0000238
Dan Gohmanb8275a32007-07-25 19:33:14 +0000239 return AsmPrinter::doFinalization(M);
Brian Gaeke4acfd032004-03-04 06:00:41 +0000240}
Anton Korobeynikov5b794b92008-08-07 09:51:25 +0000241
242void SparcAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
243 const TargetData *TD = TM.getTargetData();
244
245 if (!GVar->hasInitializer())
246 return; // External global require no code
247
248 // Check to see if this is a special global used by LLVM, if so, emit it.
249 if (EmitSpecialLLVMGlobal(GVar))
250 return;
251
252 O << "\n\n";
Anton Korobeynikov5b794b92008-08-07 09:51:25 +0000253 std::string name = Mang->getValueName(GVar);
254 Constant *C = GVar->getInitializer();
Devang Patel0f05d222009-06-26 02:26:12 +0000255 if (isa<MDNode>(C) || isa<MDString>(C))
Devang Patele4c0c0f2009-06-25 00:47:42 +0000256 return;
Duncan Sands777d2302009-05-09 07:06:46 +0000257 unsigned Size = TD->getTypeAllocSize(C->getType());
Anton Korobeynikov5b794b92008-08-07 09:51:25 +0000258 unsigned Align = TD->getPreferredAlignment(GVar);
259
Anton Korobeynikovf5b6a472008-08-08 18:25:07 +0000260 printVisibility(name, GVar->getVisibility());
261
Anton Korobeynikovc25e1ea2008-09-24 22:14:23 +0000262 SwitchToSection(TAI->SectionForGlobal(GVar));
Anton Korobeynikov5b794b92008-08-07 09:51:25 +0000263
264 if (C->isNullValue() && !GVar->hasSection()) {
265 if (!GVar->isThreadLocal() &&
Duncan Sands667d4b82009-03-07 15:45:40 +0000266 (GVar->hasLocalLinkage() || GVar->isWeakForLinker())) {
Anton Korobeynikov5b794b92008-08-07 09:51:25 +0000267 if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
268
Rafael Espindolabb46f522009-01-15 20:18:42 +0000269 if (GVar->hasLocalLinkage())
Anton Korobeynikov2a166e92008-08-07 09:53:13 +0000270 O << "\t.local " << name << '\n';
Anton Korobeynikov5b794b92008-08-07 09:51:25 +0000271
272 O << TAI->getCOMMDirective() << name << ',' << Size;
273 if (TAI->getCOMMDirectiveTakesAlignment())
274 O << ',' << (1 << Align);
275
276 O << '\n';
277 return;
278 }
279 }
280
281 switch (GVar->getLinkage()) {
Duncan Sands4dc2b392009-03-11 20:14:15 +0000282 case GlobalValue::CommonLinkage:
Duncan Sands667d4b82009-03-07 15:45:40 +0000283 case GlobalValue::LinkOnceAnyLinkage:
284 case GlobalValue::LinkOnceODRLinkage:
285 case GlobalValue::WeakAnyLinkage: // FIXME: Verify correct for weak.
286 case GlobalValue::WeakODRLinkage: // FIXME: Verify correct for weak.
Anton Korobeynikov5b794b92008-08-07 09:51:25 +0000287 // Nonnull linkonce -> weak
Anton Korobeynikov2a166e92008-08-07 09:53:13 +0000288 O << "\t.weak " << name << '\n';
Anton Korobeynikov5b794b92008-08-07 09:51:25 +0000289 break;
290 case GlobalValue::AppendingLinkage:
291 // FIXME: appending linkage variables should go into a section of
292 // their name or something. For now, just emit them as external.
293 case GlobalValue::ExternalLinkage:
294 // If external or appending, declare as a global symbol
Anton Korobeynikov2a166e92008-08-07 09:53:13 +0000295 O << TAI->getGlobalDirective() << name << '\n';
Anton Korobeynikov5b794b92008-08-07 09:51:25 +0000296 // FALL THROUGH
Rafael Espindolabb46f522009-01-15 20:18:42 +0000297 case GlobalValue::PrivateLinkage:
Anton Korobeynikov5b794b92008-08-07 09:51:25 +0000298 case GlobalValue::InternalLinkage:
299 break;
300 case GlobalValue::GhostLinkage:
301 cerr << "Should not have any unmaterialized functions!\n";
302 abort();
303 case GlobalValue::DLLImportLinkage:
304 cerr << "DLLImport linkage is not supported by this target!\n";
305 abort();
306 case GlobalValue::DLLExportLinkage:
307 cerr << "DLLExport linkage is not supported by this target!\n";
308 abort();
309 default:
310 assert(0 && "Unknown linkage type!");
311 }
312
Anton Korobeynikovfcd99bb2008-08-07 09:53:38 +0000313 EmitAlignment(Align, GVar);
Anton Korobeynikov5b794b92008-08-07 09:51:25 +0000314
315 if (TAI->hasDotTypeDotSizeDirective()) {
316 O << "\t.type " << name << ",#object\n";
Anton Korobeynikov2a166e92008-08-07 09:53:13 +0000317 O << "\t.size " << name << ',' << Size << '\n';
Anton Korobeynikov5b794b92008-08-07 09:51:25 +0000318 }
319
320 O << name << ":\n";
321 EmitGlobalConstant(C);
322}
Anton Korobeynikovf3693302008-10-10 10:15:03 +0000323
324/// PrintAsmOperand - Print out an operand for an inline asm expression.
325///
326bool SparcAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
327 unsigned AsmVariant,
328 const char *ExtraCode) {
Anton Korobeynikov4cf5e2e2008-10-10 20:29:50 +0000329 if (ExtraCode && ExtraCode[0]) {
330 if (ExtraCode[1] != 0) return true; // Unknown modifier.
331
332 switch (ExtraCode[0]) {
333 default: return true; // Unknown modifier.
334 case 'r':
335 break;
336 }
337 }
Anton Korobeynikovf3693302008-10-10 10:15:03 +0000338
339 printOperand(MI, OpNo);
340
341 return false;
342}
343
344bool SparcAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
345 unsigned OpNo,
346 unsigned AsmVariant,
347 const char *ExtraCode) {
348 if (ExtraCode && ExtraCode[0])
349 return true; // Unknown modifier
350
351 O << '[';
352 printMemOperand(MI, OpNo);
353 O << ']';
354
355 return false;
356}
Douglas Gregor1555a232009-06-16 20:12:29 +0000357
Chris Lattner225503a2009-06-19 15:48:10 +0000358namespace {
359 static struct Register {
360 Register() {
361 SparcTargetMachine::registerAsmPrinter(createSparcCodePrinterPass);
362 }
363 } Registrator;
364}
365
Bob Wilsona96751f2009-06-23 23:59:40 +0000366// Force static initialization.
367extern "C" void LLVMInitializeSparcAsmPrinter() { }