blob: 12b5f4477599e89cae33e3be591cbff5813e7154 [file] [log] [blame]
Nate Begeman21e463b2005-10-16 05:39:50 +00001//===-- PPCAsmPrinter.cpp - Print machine instrs to PowerPC assembly --------=//
Misha Brukmanb5f662f2005-04-21 23:30:14 +00002//
Misha Brukman5dfe3a92004-06-21 16:55:25 +00003// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
Misha Brukmanb5f662f2005-04-21 23:30:14 +00007//
Misha Brukman5dfe3a92004-06-21 16:55:25 +00008//===----------------------------------------------------------------------===//
9//
Misha Brukman05fcd0c2004-07-08 17:58:04 +000010// This file contains a printer that converts from our internal representation
11// of machine-dependent LLVM code to PowerPC assembly language. This printer is
Chris Lattner83660c52004-07-28 20:18:53 +000012// the output mechanism used by `llc'.
Misha Brukman5dfe3a92004-06-21 16:55:25 +000013//
Misha Brukman05fcd0c2004-07-08 17:58:04 +000014// Documentation at http://developer.apple.com/documentation/DeveloperTools/
15// Reference/Assembler/ASMIntroduction/chapter_1_section_1.html
Misha Brukman218bec72004-06-29 17:13:26 +000016//
Misha Brukman5dfe3a92004-06-21 16:55:25 +000017//===----------------------------------------------------------------------===//
18
Misha Brukman05794492004-06-24 17:31:42 +000019#define DEBUG_TYPE "asmprinter"
Chris Lattner26689592005-10-14 23:51:18 +000020#include "PPC.h"
Chris Lattner16e71f22005-10-14 23:59:06 +000021#include "PPCTargetMachine.h"
Chris Lattner26689592005-10-14 23:51:18 +000022#include "PPCSubtarget.h"
Misha Brukman5dfe3a92004-06-21 16:55:25 +000023#include "llvm/Constants.h"
24#include "llvm/DerivedTypes.h"
25#include "llvm/Module.h"
26#include "llvm/Assembly/Writer.h"
Chris Lattnera3840792004-08-16 23:25:21 +000027#include "llvm/CodeGen/AsmPrinter.h"
Jim Laskeya7cea6f2006-01-04 13:52:30 +000028#include "llvm/CodeGen/DwarfWriter.h"
Jim Laskeyf5395ce2005-12-16 22:45:29 +000029#include "llvm/CodeGen/MachineDebugInfo.h"
Misha Brukman05794492004-06-24 17:31:42 +000030#include "llvm/CodeGen/MachineFunctionPass.h"
Misha Brukman5dfe3a92004-06-21 16:55:25 +000031#include "llvm/CodeGen/MachineInstr.h"
Misha Brukman5dfe3a92004-06-21 16:55:25 +000032#include "llvm/Support/Mangler.h"
Nate Begemana11c2e82004-09-04 14:51:26 +000033#include "llvm/Support/MathExtras.h"
Reid Spencer551ccae2004-09-01 22:55:40 +000034#include "llvm/Support/CommandLine.h"
35#include "llvm/Support/Debug.h"
Nate Begeman17304c32004-10-26 06:02:38 +000036#include "llvm/Target/MRegisterInfo.h"
Nate Begemand4c8bea2004-11-25 07:09:01 +000037#include "llvm/Target/TargetInstrInfo.h"
Reid Spencer551ccae2004-09-01 22:55:40 +000038#include "llvm/ADT/Statistic.h"
39#include "llvm/ADT/StringExtras.h"
Misha Brukman05794492004-06-24 17:31:42 +000040#include <set>
Chris Lattnera3840792004-08-16 23:25:21 +000041using namespace llvm;
Misha Brukman5dfe3a92004-06-21 16:55:25 +000042
43namespace {
44 Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
45
Chris Lattnerac7fd7f2005-11-14 18:52:46 +000046 class PPCAsmPrinter : public AsmPrinter {
Chris Lattnerd717b192005-12-11 07:45:47 +000047 public:
Chris Lattnera637c322005-12-16 00:22:14 +000048 std::set<std::string> FnStubs, GVStubs;
Chris Lattnerac7fd7f2005-11-14 18:52:46 +000049
Chris Lattner4c7b43b2005-10-14 23:37:35 +000050 PPCAsmPrinter(std::ostream &O, TargetMachine &TM)
Chris Lattner07455362005-11-21 08:14:07 +000051 : AsmPrinter(O, TM) {}
Misha Brukmanb5f662f2005-04-21 23:30:14 +000052
Misha Brukman5dfe3a92004-06-21 16:55:25 +000053 virtual const char *getPassName() const {
Nate Begemaned428532004-09-04 05:00:00 +000054 return "PowerPC Assembly Printer";
Misha Brukman5dfe3a92004-06-21 16:55:25 +000055 }
56
Nate Begeman21e463b2005-10-16 05:39:50 +000057 PPCTargetMachine &getTM() {
58 return static_cast<PPCTargetMachine&>(TM);
Chris Lattnera3840792004-08-16 23:25:21 +000059 }
60
Nate Begemanadeb43d2005-07-20 22:42:00 +000061 unsigned enumRegToMachineReg(unsigned enumReg) {
62 switch (enumReg) {
63 default: assert(0 && "Unhandled register!"); break;
64 case PPC::CR0: return 0;
65 case PPC::CR1: return 1;
66 case PPC::CR2: return 2;
67 case PPC::CR3: return 3;
68 case PPC::CR4: return 4;
69 case PPC::CR5: return 5;
70 case PPC::CR6: return 6;
71 case PPC::CR7: return 7;
72 }
73 abort();
74 }
75
Nate Begemane59bf592004-08-14 22:09:10 +000076 /// printInstruction - This method is automatically generated by tablegen
77 /// from the instruction set description. This method returns true if the
78 /// machine instruction was sufficiently described to print it, otherwise it
79 /// returns false.
80 bool printInstruction(const MachineInstr *MI);
81
Misha Brukman5dfe3a92004-06-21 16:55:25 +000082 void printMachineInstruction(const MachineInstr *MI);
Chris Lattner9ba13e42005-11-17 19:25:59 +000083 void printOp(const MachineOperand &MO);
Chris Lattner7bb424f2004-08-14 23:27:29 +000084
Nate Begeman391c5d22005-11-30 18:54:35 +000085 void printOperand(const MachineInstr *MI, unsigned OpNo){
Chris Lattner7bb424f2004-08-14 23:27:29 +000086 const MachineOperand &MO = MI->getOperand(OpNo);
87 if (MO.getType() == MachineOperand::MO_MachineRegister) {
88 assert(MRegisterInfo::isPhysicalRegister(MO.getReg())&&"Not physreg??");
Chris Lattner9dc4d3c2005-08-22 22:00:02 +000089 O << TM.getRegisterInfo()->get(MO.getReg()).Name;
Chris Lattner0ea31712004-08-15 05:46:14 +000090 } else if (MO.isImmediate()) {
91 O << MO.getImmedValue();
Chris Lattner7bb424f2004-08-14 23:27:29 +000092 } else {
93 printOp(MO);
94 }
95 }
96
Nate Begeman391c5d22005-11-30 18:54:35 +000097 void printU5ImmOperand(const MachineInstr *MI, unsigned OpNo) {
Nate Begemanc3306122004-08-21 05:56:39 +000098 unsigned char value = MI->getOperand(OpNo).getImmedValue();
Chris Lattner12585ba2004-08-21 19:11:03 +000099 assert(value <= 31 && "Invalid u5imm argument!");
Nate Begemanc3306122004-08-21 05:56:39 +0000100 O << (unsigned int)value;
101 }
Nate Begeman391c5d22005-11-30 18:54:35 +0000102 void printU6ImmOperand(const MachineInstr *MI, unsigned OpNo) {
Nate Begeman07aada82004-08-30 02:28:06 +0000103 unsigned char value = MI->getOperand(OpNo).getImmedValue();
104 assert(value <= 63 && "Invalid u6imm argument!");
105 O << (unsigned int)value;
106 }
Nate Begeman391c5d22005-11-30 18:54:35 +0000107 void printS16ImmOperand(const MachineInstr *MI, unsigned OpNo) {
Nate Begemaned428532004-09-04 05:00:00 +0000108 O << (short)MI->getOperand(OpNo).getImmedValue();
109 }
Nate Begeman391c5d22005-11-30 18:54:35 +0000110 void printU16ImmOperand(const MachineInstr *MI, unsigned OpNo) {
Chris Lattner97b2a2e2004-08-15 05:20:16 +0000111 O << (unsigned short)MI->getOperand(OpNo).getImmedValue();
112 }
Nate Begeman391c5d22005-11-30 18:54:35 +0000113 void printS16X4ImmOperand(const MachineInstr *MI, unsigned OpNo) {
Chris Lattner841d12d2005-10-18 16:51:22 +0000114 O << (short)MI->getOperand(OpNo).getImmedValue()*4;
115 }
Nate Begeman391c5d22005-11-30 18:54:35 +0000116 void printBranchOperand(const MachineInstr *MI, unsigned OpNo) {
Nate Begemaned428532004-09-04 05:00:00 +0000117 // Branches can take an immediate operand. This is used by the branch
118 // selection pass to print $+8, an eight byte displacement from the PC.
119 if (MI->getOperand(OpNo).isImmediate()) {
Nate Begeman27499e32005-04-10 01:48:29 +0000120 O << "$+" << MI->getOperand(OpNo).getImmedValue();
Nate Begemaned428532004-09-04 05:00:00 +0000121 } else {
Chris Lattner3e7f86a2005-11-17 19:16:08 +0000122 printOp(MI->getOperand(OpNo));
Nate Begemaned428532004-09-04 05:00:00 +0000123 }
Nate Begemanb7a8f2c2004-09-02 08:13:00 +0000124 }
Nate Begeman391c5d22005-11-30 18:54:35 +0000125 void printCallOperand(const MachineInstr *MI, unsigned OpNo) {
Chris Lattner9ba13e42005-11-17 19:25:59 +0000126 const MachineOperand &MO = MI->getOperand(OpNo);
Chris Lattner9542f9712005-11-17 19:40:30 +0000127 if (!PPCGenerateStaticCode) {
Chris Lattnera637c322005-12-16 00:22:14 +0000128 if (MO.getType() == MachineOperand::MO_GlobalAddress) {
129 GlobalValue *GV = MO.getGlobal();
130 if (((GV->isExternal() || GV->hasWeakLinkage() ||
131 GV->hasLinkOnceLinkage()))) {
132 // Dynamically-resolved functions need a stub for the function.
133 std::string Name = Mang->getValueName(GV);
134 FnStubs.insert(Name);
135 O << "L" << Name << "$stub";
136 return;
137 }
138 }
Chris Lattner9542f9712005-11-17 19:40:30 +0000139 if (MO.getType() == MachineOperand::MO_ExternalSymbol) {
140 std::string Name(GlobalPrefix); Name += MO.getSymbolName();
141 FnStubs.insert(Name);
142 O << "L" << Name << "$stub";
143 return;
Chris Lattner9542f9712005-11-17 19:40:30 +0000144 }
Chris Lattner9ba13e42005-11-17 19:25:59 +0000145 }
Chris Lattner9542f9712005-11-17 19:40:30 +0000146
147 printOp(MI->getOperand(OpNo));
Chris Lattner3e7f86a2005-11-17 19:16:08 +0000148 }
Nate Begeman391c5d22005-11-30 18:54:35 +0000149 void printAbsAddrOperand(const MachineInstr *MI, unsigned OpNo) {
Nate Begeman422b0ce2005-11-16 00:48:01 +0000150 O << (int)MI->getOperand(OpNo).getImmedValue()*4;
151 }
Nate Begeman391c5d22005-11-30 18:54:35 +0000152 void printPICLabel(const MachineInstr *MI, unsigned OpNo) {
Chris Lattnera637c322005-12-16 00:22:14 +0000153 O << "\"L" << getFunctionNumber() << "$pb\"\n";
154 O << "\"L" << getFunctionNumber() << "$pb\":";
Nate Begemanb7a8f2c2004-09-02 08:13:00 +0000155 }
Nate Begeman391c5d22005-11-30 18:54:35 +0000156 void printSymbolHi(const MachineInstr *MI, unsigned OpNo) {
Nate Begeman2497e632005-07-21 20:44:43 +0000157 if (MI->getOperand(OpNo).isImmediate()) {
Nate Begeman391c5d22005-11-30 18:54:35 +0000158 printS16ImmOperand(MI, OpNo);
Nate Begeman2497e632005-07-21 20:44:43 +0000159 } else {
160 O << "ha16(";
161 printOp(MI->getOperand(OpNo));
162 if (PICEnabled)
Chris Lattnera637c322005-12-16 00:22:14 +0000163 O << "-\"L" << getFunctionNumber() << "$pb\")";
Nate Begeman2497e632005-07-21 20:44:43 +0000164 else
165 O << ')';
166 }
Nate Begemaned428532004-09-04 05:00:00 +0000167 }
Nate Begeman391c5d22005-11-30 18:54:35 +0000168 void printSymbolLo(const MachineInstr *MI, unsigned OpNo) {
Nate Begemaned428532004-09-04 05:00:00 +0000169 if (MI->getOperand(OpNo).isImmediate()) {
Nate Begeman391c5d22005-11-30 18:54:35 +0000170 printS16ImmOperand(MI, OpNo);
Nate Begemaned428532004-09-04 05:00:00 +0000171 } else {
172 O << "lo16(";
Nate Begemand4c8bea2004-11-25 07:09:01 +0000173 printOp(MI->getOperand(OpNo));
Nate Begeman2497e632005-07-21 20:44:43 +0000174 if (PICEnabled)
Chris Lattnera637c322005-12-16 00:22:14 +0000175 O << "-\"L" << getFunctionNumber() << "$pb\")";
Nate Begeman2497e632005-07-21 20:44:43 +0000176 else
177 O << ')';
Nate Begemaned428532004-09-04 05:00:00 +0000178 }
179 }
Nate Begeman391c5d22005-11-30 18:54:35 +0000180 void printcrbitm(const MachineInstr *MI, unsigned OpNo) {
Nate Begemanadeb43d2005-07-20 22:42:00 +0000181 unsigned CCReg = MI->getOperand(OpNo).getReg();
182 unsigned RegNo = enumRegToMachineReg(CCReg);
183 O << (0x80 >> RegNo);
184 }
Nate Begeman7fd1edd2005-12-19 23:25:09 +0000185 // The new addressing mode printers, currently empty
186 void printMemRegImm(const MachineInstr *MI, unsigned OpNo) {
187 printSymbolLo(MI, OpNo);
188 O << '(';
189 printOperand(MI, OpNo+1);
190 O << ')';
191 }
192 void printMemRegReg(const MachineInstr *MI, unsigned OpNo) {
Nate Begeman88276b82005-12-19 23:40:42 +0000193 // When used as the base register, r0 reads constant zero rather than
194 // the value contained in the register. For this reason, the darwin
195 // assembler requires that we print r0 as 0 (no r) when used as the base.
196 const MachineOperand &MO = MI->getOperand(OpNo);
197 if (MO.getReg() == PPC::R0)
198 O << '0';
199 else
200 O << TM.getRegisterInfo()->get(MO.getReg()).Name;
Nate Begeman7fd1edd2005-12-19 23:25:09 +0000201 O << ", ";
202 printOperand(MI, OpNo+1);
203 }
204
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000205 virtual bool runOnMachineFunction(MachineFunction &F) = 0;
Nate Begemaned428532004-09-04 05:00:00 +0000206 virtual bool doFinalization(Module &M) = 0;
207 };
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000208
Jim Laskeya7cea6f2006-01-04 13:52:30 +0000209 /// DarwinDwarfWriter - Dwarf debug info writer customized for Darwin/Mac OS X
210 ///
211 struct DarwinDwarfWriter : public DwarfWriter {
212 // Ctor.
213 DarwinDwarfWriter(std::ostream &o, AsmPrinter *ap, MachineDebugInfo &di)
214 : DwarfWriter(o, ap, di)
215 {
216 hasLEB128 = false;
217 needsSet = true;
218 DwarfAbbrevSection = ".section __DWARFA,__debug_abbrev,regular,debug";
219 DwarfInfoSection = ".section __DWARFA,__debug_info,regular,debug";
220 DwarfLineSection = ".section __DWARFA,__debug_line,regular,debug";
221 }
222 };
223
Misha Brukman3e0b51a2004-09-05 02:42:44 +0000224 /// DarwinAsmPrinter - PowerPC assembly printer, customized for Darwin/Mac OS
225 /// X
226 ///
Chris Lattner4c7b43b2005-10-14 23:37:35 +0000227 struct DarwinAsmPrinter : public PPCAsmPrinter {
Jim Laskeya7cea6f2006-01-04 13:52:30 +0000228
229 DarwinDwarfWriter DW;
Nate Begemaned428532004-09-04 05:00:00 +0000230
231 DarwinAsmPrinter(std::ostream &O, TargetMachine &TM)
Jim Laskeya7cea6f2006-01-04 13:52:30 +0000232 : PPCAsmPrinter(O, TM),
233 // FIXME - MachineDebugInfo needs a proper location
234 DW(O, this, getMachineDebugInfo())
235 {
Nate Begemaned428532004-09-04 05:00:00 +0000236 CommentString = ";";
237 GlobalPrefix = "_";
Chris Lattnerf55366e2005-11-21 06:47:58 +0000238 PrivateGlobalPrefix = "L"; // Marker for constant pool idxs
Nate Begemaned428532004-09-04 05:00:00 +0000239 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
240 Data64bitsDirective = 0; // we can't emit a 64-bit unit
241 AlignmentIsInBytes = false; // Alignment is by power of 2.
Chris Lattnerc569e612005-11-21 08:26:15 +0000242 ConstantPoolSection = "\t.const\t";
Chris Lattnerd717b192005-12-11 07:45:47 +0000243 LCOMMDirective = "\t.lcomm\t";
Chris Lattnerd1239b72005-12-13 06:32:50 +0000244 StaticCtorsSection = ".mod_init_func";
245 StaticDtorsSection = ".mod_term_func";
Nate Begemaned428532004-09-04 05:00:00 +0000246 }
247
248 virtual const char *getPassName() const {
249 return "Darwin PPC Assembly Printer";
250 }
Chris Lattner646f7af2005-12-09 18:24:29 +0000251
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000252 bool runOnMachineFunction(MachineFunction &F);
Nate Begeman18ed0292005-07-21 01:25:49 +0000253 bool doInitialization(Module &M);
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000254 bool doFinalization(Module &M);
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000255 };
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000256
Misha Brukman3e0b51a2004-09-05 02:42:44 +0000257 /// AIXAsmPrinter - PowerPC assembly printer, customized for AIX
258 ///
Chris Lattner4c7b43b2005-10-14 23:37:35 +0000259 struct AIXAsmPrinter : public PPCAsmPrinter {
Nate Begemaned428532004-09-04 05:00:00 +0000260 /// Map for labels corresponding to global variables
261 ///
262 std::map<const GlobalVariable*,std::string> GVToLabelMap;
263
264 AIXAsmPrinter(std::ostream &O, TargetMachine &TM)
Chris Lattner4c7b43b2005-10-14 23:37:35 +0000265 : PPCAsmPrinter(O, TM) {
Nate Begemaned428532004-09-04 05:00:00 +0000266 CommentString = "#";
Chris Lattner3459bfb2005-11-10 18:20:29 +0000267 GlobalPrefix = ".";
Nate Begemaned428532004-09-04 05:00:00 +0000268 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
269 Data64bitsDirective = 0; // we can't emit a 64-bit unit
270 AlignmentIsInBytes = false; // Alignment is by power of 2.
Chris Lattnerc569e612005-11-21 08:26:15 +0000271 ConstantPoolSection = "\t.const\t";
Nate Begemaned428532004-09-04 05:00:00 +0000272 }
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000273
Nate Begemaned428532004-09-04 05:00:00 +0000274 virtual const char *getPassName() const {
275 return "AIX PPC Assembly Printer";
276 }
277
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000278 bool runOnMachineFunction(MachineFunction &F);
Nate Begemaned428532004-09-04 05:00:00 +0000279 bool doInitialization(Module &M);
280 bool doFinalization(Module &M);
281 };
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000282} // end of anonymous namespace
283
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000284/// createDarwinAsmPrinterPass - Returns a pass that prints the PPC assembly
285/// code for a MachineFunction to the given output stream, in a format that the
Nate Begemaned428532004-09-04 05:00:00 +0000286/// Darwin assembler can deal with.
287///
288FunctionPass *llvm::createDarwinAsmPrinter(std::ostream &o, TargetMachine &tm) {
289 return new DarwinAsmPrinter(o, tm);
290}
291
292/// createAIXAsmPrinterPass - Returns a pass that prints the PPC assembly code
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000293/// for a MachineFunction to the given output stream, in a format that the
Nate Begemaned428532004-09-04 05:00:00 +0000294/// AIX 5L assembler can deal with.
295///
296FunctionPass *llvm::createAIXAsmPrinter(std::ostream &o, TargetMachine &tm) {
297 return new AIXAsmPrinter(o, tm);
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000298}
299
Nate Begemane59bf592004-08-14 22:09:10 +0000300// Include the auto-generated portion of the assembly writer
Chris Lattner4c7b43b2005-10-14 23:37:35 +0000301#include "PPCGenAsmWriter.inc"
Nate Begemane59bf592004-08-14 22:09:10 +0000302
Chris Lattner9ba13e42005-11-17 19:25:59 +0000303void PPCAsmPrinter::printOp(const MachineOperand &MO) {
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000304 const MRegisterInfo &RI = *TM.getRegisterInfo();
305 int new_symbol;
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000306
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000307 switch (MO.getType()) {
308 case MachineOperand::MO_VirtualRegister:
309 if (Value *V = MO.getVRegValueOrNull()) {
310 O << "<" << V->getName() << ">";
311 return;
312 }
313 // FALLTHROUGH
314 case MachineOperand::MO_MachineRegister:
Misha Brukman05fcd0c2004-07-08 17:58:04 +0000315 case MachineOperand::MO_CCRegister:
Chris Lattner9dc4d3c2005-08-22 22:00:02 +0000316 O << RI.get(MO.getReg()).Name;
Misha Brukman7f484a52004-06-24 23:51:00 +0000317 return;
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000318
319 case MachineOperand::MO_SignExtendedImmed:
Misha Brukmanaf313fb2004-07-28 00:00:48 +0000320 case MachineOperand::MO_UnextendedImmed:
321 std::cerr << "printOp() does not handle immediate values\n";
322 abort();
Misha Brukman97a296f2004-07-21 20:11:11 +0000323 return;
324
Misha Brukman05fcd0c2004-07-08 17:58:04 +0000325 case MachineOperand::MO_PCRelativeDisp:
326 std::cerr << "Shouldn't use addPCDisp() when building PPC MachineInstrs";
327 abort();
328 return;
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000329
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000330 case MachineOperand::MO_MachineBasicBlock: {
331 MachineBasicBlock *MBBOp = MO.getMachineBasicBlock();
Chris Lattner07455362005-11-21 08:14:07 +0000332 O << PrivateGlobalPrefix << "BB" << getFunctionNumber() << "_"
Chris Lattner7f9ccde2005-11-21 07:41:05 +0000333 << MBBOp->getNumber() << "\t; " << MBBOp->getBasicBlock()->getName();
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000334 return;
335 }
Misha Brukman05fcd0c2004-07-08 17:58:04 +0000336
337 case MachineOperand::MO_ConstantPoolIndex:
Chris Lattner07455362005-11-21 08:14:07 +0000338 O << PrivateGlobalPrefix << "CPI" << getFunctionNumber()
Chris Lattnerf55366e2005-11-21 06:47:58 +0000339 << '_' << MO.getConstantPoolIndex();
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000340 return;
Misha Brukman05fcd0c2004-07-08 17:58:04 +0000341 case MachineOperand::MO_ExternalSymbol:
Chris Lattnera637c322005-12-16 00:22:14 +0000342 // Computing the address of an external symbol, not calling it.
343 if (!PPCGenerateStaticCode) {
344 std::string Name(GlobalPrefix); Name += MO.getSymbolName();
345 GVStubs.insert(Name);
346 O << "L" << Name << "$non_lazy_ptr";
347 return;
348 }
Nate Begeman01d05262005-03-30 01:45:43 +0000349 O << GlobalPrefix << MO.getSymbolName();
Misha Brukman05fcd0c2004-07-08 17:58:04 +0000350 return;
Nate Begemanb73a7112004-08-13 09:32:01 +0000351 case MachineOperand::MO_GlobalAddress: {
Chris Lattnera637c322005-12-16 00:22:14 +0000352 // Computing the address of a global symbol, not calling it.
Nate Begemanb73a7112004-08-13 09:32:01 +0000353 GlobalValue *GV = MO.getGlobal();
354 std::string Name = Mang->getValueName(GV);
Nate Begeman50fb3c42005-12-24 01:00:15 +0000355 int offset = MO.getOffset();
Misha Brukmane2eceb52004-07-23 16:08:20 +0000356
Nate Begemanfcf4a422004-10-17 23:01:34 +0000357 // External or weakly linked global variables need non-lazily-resolved stubs
Chris Lattnera637c322005-12-16 00:22:14 +0000358 if (!PPCGenerateStaticCode) {
359 if (((GV->isExternal() || GV->hasWeakLinkage() ||
360 GV->hasLinkOnceLinkage()))) {
Nate Begemand4c8bea2004-11-25 07:09:01 +0000361 GVStubs.insert(Name);
Chris Lattnera637c322005-12-16 00:22:14 +0000362 O << "L" << Name << "$non_lazy_ptr";
363 return;
364 }
Nate Begemanb73a7112004-08-13 09:32:01 +0000365 }
Nate Begemand4c8bea2004-11-25 07:09:01 +0000366
Chris Lattner9542f9712005-11-17 19:40:30 +0000367 O << Name;
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000368 return;
Nate Begemanb73a7112004-08-13 09:32:01 +0000369 }
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000370
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000371 default:
Misha Brukman05fcd0c2004-07-08 17:58:04 +0000372 O << "<unknown operand type: " << MO.getType() << ">";
Misha Brukman22e12072004-06-25 15:11:34 +0000373 return;
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000374 }
375}
376
Nate Begemane59bf592004-08-14 22:09:10 +0000377/// printMachineInstruction -- Print out a single PowerPC MI in Darwin syntax to
378/// the current output stream.
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000379///
Chris Lattner4c7b43b2005-10-14 23:37:35 +0000380void PPCAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
Nate Begemane59bf592004-08-14 22:09:10 +0000381 ++EmittedInsts;
Chris Lattner617742b2005-10-14 22:44:13 +0000382
Nate Begemanad5f65c2005-04-05 18:19:50 +0000383 // Check for slwi/srwi mnemonics.
384 if (MI->getOpcode() == PPC::RLWINM) {
385 bool FoundMnemonic = false;
386 unsigned char SH = MI->getOperand(2).getImmedValue();
387 unsigned char MB = MI->getOperand(3).getImmedValue();
388 unsigned char ME = MI->getOperand(4).getImmedValue();
389 if (SH <= 31 && MB == 0 && ME == (31-SH)) {
390 O << "slwi "; FoundMnemonic = true;
391 }
392 if (SH <= 31 && MB == (32-SH) && ME == 31) {
393 O << "srwi "; FoundMnemonic = true;
394 SH = 32-SH;
395 }
396 if (FoundMnemonic) {
Nate Begeman391c5d22005-11-30 18:54:35 +0000397 printOperand(MI, 0);
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000398 O << ", ";
Nate Begeman391c5d22005-11-30 18:54:35 +0000399 printOperand(MI, 1);
Nate Begemanad5f65c2005-04-05 18:19:50 +0000400 O << ", " << (unsigned int)SH << "\n";
401 return;
402 }
403 }
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000404
Nate Begemane59bf592004-08-14 22:09:10 +0000405 if (printInstruction(MI))
406 return; // Printer was automatically generated
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000407
Nate Begemaned428532004-09-04 05:00:00 +0000408 assert(0 && "Unhandled instruction in asm writer!");
409 abort();
Nate Begemane59bf592004-08-14 22:09:10 +0000410 return;
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000411}
412
Chris Lattneref658742005-11-21 07:57:37 +0000413
Nate Begemaned428532004-09-04 05:00:00 +0000414/// runOnMachineFunction - This uses the printMachineInstruction()
415/// method to print assembly for each instruction.
416///
417bool DarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
Chris Lattner8b8b9512005-11-21 07:51:23 +0000418 SetupMachineFunction(MF);
Nate Begemaned428532004-09-04 05:00:00 +0000419 O << "\n\n";
Jim Laskeyf5395ce2005-12-16 22:45:29 +0000420
Jim Laskeya7cea6f2006-01-04 13:52:30 +0000421 // Emit pre-function debug information.
422 DW.BeginFunction();
Nate Begemaned428532004-09-04 05:00:00 +0000423
424 // Print out constants referenced by the function
Chris Lattnerc569e612005-11-21 08:26:15 +0000425 EmitConstantPool(MF.getConstantPool());
Nate Begemaned428532004-09-04 05:00:00 +0000426
427 // Print out labels for the function.
Chris Lattnerac7fd7f2005-11-14 18:52:46 +0000428 const Function *F = MF.getFunction();
Chris Lattnera637c322005-12-16 00:22:14 +0000429 switch (F->getLinkage()) {
430 default: assert(0 && "Unknown linkage type!");
431 case Function::InternalLinkage: // Symbols default to internal.
432 SwitchSection(".text", F);
433 EmitAlignment(4, F);
434 break;
435 case Function::ExternalLinkage:
436 SwitchSection(".text", F);
437 EmitAlignment(4, F);
Chris Lattnerf02a9162005-10-28 18:44:07 +0000438 O << "\t.globl\t" << CurrentFnName << "\n";
Chris Lattnera637c322005-12-16 00:22:14 +0000439 break;
440 case Function::WeakLinkage:
441 case Function::LinkOnceLinkage:
442 SwitchSection(".section __TEXT,__textcoal_nt,coalesced,pure_instructions",
443 F);
444 O << "\t.globl\t" << CurrentFnName << "\n";
445 O << "\t.weak_definition\t" << CurrentFnName << "\n";
446 break;
447 }
Nate Begemaned428532004-09-04 05:00:00 +0000448 O << CurrentFnName << ":\n";
449
450 // Print out code for the function.
451 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
452 I != E; ++I) {
453 // Print a label for the basic block.
Chris Lattner1db1adb2005-08-21 19:09:33 +0000454 if (I != MF.begin()) {
Chris Lattner07455362005-11-21 08:14:07 +0000455 O << PrivateGlobalPrefix << "BB" << getFunctionNumber() << '_'
Chris Lattner7f9ccde2005-11-21 07:41:05 +0000456 << I->getNumber() << ":\t";
Chris Lattner1db1adb2005-08-21 19:09:33 +0000457 if (!I->getBasicBlock()->getName().empty())
458 O << CommentString << " " << I->getBasicBlock()->getName();
459 O << "\n";
460 }
Nate Begemaned428532004-09-04 05:00:00 +0000461 for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
462 II != E; ++II) {
463 // Print the assembly for the instruction.
464 O << "\t";
465 printMachineInstruction(II);
466 }
467 }
Nate Begemaned428532004-09-04 05:00:00 +0000468
Jim Laskeya7cea6f2006-01-04 13:52:30 +0000469 // Emit post-function debug information.
470 DW.EndFunction();
471
Nate Begemaned428532004-09-04 05:00:00 +0000472 // We didn't modify anything.
473 return false;
474}
475
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000476
Nate Begeman18ed0292005-07-21 01:25:49 +0000477bool DarwinAsmPrinter::doInitialization(Module &M) {
Chris Lattner3c304a32005-08-05 22:05:03 +0000478 if (TM.getSubtarget<PPCSubtarget>().isGigaProcessor())
479 O << "\t.machine ppc970\n";
Nate Begeman18ed0292005-07-21 01:25:49 +0000480 AsmPrinter::doInitialization(M);
Chris Lattner85eac0d2005-11-10 19:33:43 +0000481
482 // Darwin wants symbols to be quoted if they have complex names.
483 Mang->setUseQuotes(true);
Jim Laskeya7cea6f2006-01-04 13:52:30 +0000484
485 // Emit initial debug information.
486 DW.BeginModule();
Nate Begeman18ed0292005-07-21 01:25:49 +0000487 return false;
488}
489
Nate Begemaned428532004-09-04 05:00:00 +0000490bool DarwinAsmPrinter::doFinalization(Module &M) {
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000491 const TargetData &TD = TM.getTargetData();
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000492
493 // Print out module-level global variables here.
Chris Lattnerced704b2005-11-14 19:00:30 +0000494 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
Chris Lattnerdeea4162005-12-13 04:33:58 +0000495 I != E; ++I) {
496 if (!I->hasInitializer()) continue; // External global require no code
497
Chris Lattnerd1239b72005-12-13 06:32:50 +0000498 // Check to see if this is a special global used by LLVM, if so, emit it.
499 if (I->hasAppendingLinkage() && EmitSpecialLLVMGlobal(I))
500 continue;
Chris Lattnerdeea4162005-12-13 04:33:58 +0000501
502 O << '\n';
503 std::string name = Mang->getValueName(I);
504 Constant *C = I->getInitializer();
505 unsigned Size = TD.getTypeSize(C->getType());
506 unsigned Align = TD.getTypeAlignmentShift(C->getType());
507
508 if (C->isNullValue() && /* FIXME: Verify correct */
509 (I->hasInternalLinkage() || I->hasWeakLinkage() ||
510 I->hasLinkOnceLinkage())) {
511 SwitchSection(".data", I);
512 if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
513 if (I->hasInternalLinkage())
514 O << LCOMMDirective << name << "," << Size << "," << Align;
515 else
516 O << ".comm " << name << "," << Size;
517 O << "\t\t; '" << I->getName() << "'\n";
518 } else {
519 switch (I->getLinkage()) {
520 case GlobalValue::LinkOnceLinkage:
Chris Lattnerdeea4162005-12-13 04:33:58 +0000521 case GlobalValue::WeakLinkage:
Chris Lattnercec26fc2005-12-22 21:15:17 +0000522 O << "\t.globl " << name << '\n'
523 << "\t.weak_definition " << name << '\n';
Chris Lattnera637c322005-12-16 00:22:14 +0000524 SwitchSection(".section __DATA,__datacoal_nt,coalesced", I);
Chris Lattnerdeea4162005-12-13 04:33:58 +0000525 break;
526 case GlobalValue::AppendingLinkage:
527 // FIXME: appending linkage variables should go into a section of
528 // their name or something. For now, just emit them as external.
529 case GlobalValue::ExternalLinkage:
530 // If external or appending, declare as a global symbol
531 O << "\t.globl " << name << "\n";
532 // FALL THROUGH
533 case GlobalValue::InternalLinkage:
534 SwitchSection(".data", I);
535 break;
536 default:
537 std::cerr << "Unknown linkage type!";
538 abort();
539 }
540
541 EmitAlignment(Align, I);
542 O << name << ":\t\t\t\t; '" << I->getName() << "'\n";
543 EmitGlobalConstant(C);
544 }
545 }
Misha Brukmanda2b13f2004-07-16 20:29:04 +0000546
547 // Output stubs for dynamically-linked functions
Chris Lattnerdeea4162005-12-13 04:33:58 +0000548 if (PICEnabled) {
549 for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
550 i != e; ++i) {
Chris Lattnera637c322005-12-16 00:22:14 +0000551 SwitchSection(".section __TEXT,__picsymbolstub1,symbol_stubs,"
552 "pure_instructions,32", 0);
Chris Lattnerdeea4162005-12-13 04:33:58 +0000553 EmitAlignment(2);
554 O << "L" << *i << "$stub:\n";
555 O << "\t.indirect_symbol " << *i << "\n";
556 O << "\tmflr r0\n";
557 O << "\tbcl 20,31,L0$" << *i << "\n";
558 O << "L0$" << *i << ":\n";
559 O << "\tmflr r11\n";
560 O << "\taddis r11,r11,ha16(L" << *i << "$lazy_ptr-L0$" << *i << ")\n";
561 O << "\tmtlr r0\n";
562 O << "\tlwzu r12,lo16(L" << *i << "$lazy_ptr-L0$" << *i << ")(r11)\n";
563 O << "\tmtctr r12\n";
564 O << "\tbctr\n";
Chris Lattnera637c322005-12-16 00:22:14 +0000565 SwitchSection(".lazy_symbol_pointer", 0);
Chris Lattnerdeea4162005-12-13 04:33:58 +0000566 O << "L" << *i << "$lazy_ptr:\n";
567 O << "\t.indirect_symbol " << *i << "\n";
568 O << "\t.long dyld_stub_binding_helper\n";
569 }
570 } else {
571 for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
572 i != e; ++i) {
Chris Lattnera637c322005-12-16 00:22:14 +0000573 SwitchSection(".section __TEXT,__symbol_stub1,symbol_stubs,"
574 "pure_instructions,16", 0);
Chris Lattnerdeea4162005-12-13 04:33:58 +0000575 EmitAlignment(4);
576 O << "L" << *i << "$stub:\n";
577 O << "\t.indirect_symbol " << *i << "\n";
578 O << "\tlis r11,ha16(L" << *i << "$lazy_ptr)\n";
579 O << "\tlwzu r12,lo16(L" << *i << "$lazy_ptr)(r11)\n";
580 O << "\tmtctr r12\n";
581 O << "\tbctr\n";
Chris Lattnera637c322005-12-16 00:22:14 +0000582 SwitchSection(".lazy_symbol_pointer", 0);
Chris Lattnerdeea4162005-12-13 04:33:58 +0000583 O << "L" << *i << "$lazy_ptr:\n";
584 O << "\t.indirect_symbol " << *i << "\n";
585 O << "\t.long dyld_stub_binding_helper\n";
Nate Begeman2497e632005-07-21 20:44:43 +0000586 }
Misha Brukman46fd00a2004-06-24 23:04:11 +0000587 }
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000588
Misha Brukmanda2b13f2004-07-16 20:29:04 +0000589 O << "\n";
590
Chris Lattnera637c322005-12-16 00:22:14 +0000591 // Output stubs for external and common global variables.
592 if (GVStubs.begin() != GVStubs.end()) {
593 SwitchSection(".non_lazy_symbol_pointer", 0);
594 for (std::set<std::string>::iterator I = GVStubs.begin(),
595 E = GVStubs.end(); I != E; ++I) {
596 O << "L" << *I << "$non_lazy_ptr:\n";
597 O << "\t.indirect_symbol " << *I << "\n";
598 O << "\t.long\t0\n";
Chris Lattnerdeea4162005-12-13 04:33:58 +0000599 }
Nate Begemane59bf592004-08-14 22:09:10 +0000600 }
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000601
Chris Lattner5b0ac992005-11-01 00:12:36 +0000602 // Funny Darwin hack: This flag tells the linker that no global symbols
603 // contain code that falls through to other global symbols (e.g. the obvious
604 // implementation of multiple entry points). If this doesn't occur, the
605 // linker can safely perform dead code stripping. Since LLVM never generates
606 // code that does this, it is always safe to set.
607 O << "\t.subsections_via_symbols\n";
608
Jim Laskeya7cea6f2006-01-04 13:52:30 +0000609 // Emit initial debug information.
610 DW.EndModule();
611
Chris Lattnera3840792004-08-16 23:25:21 +0000612 AsmPrinter::doFinalization(M);
Misha Brukman5dfe3a92004-06-21 16:55:25 +0000613 return false; // success
614}
Nate Begemaned428532004-09-04 05:00:00 +0000615
616/// runOnMachineFunction - This uses the printMachineInstruction()
617/// method to print assembly for each instruction.
618///
619bool AIXAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
Chris Lattner6d5a4f62005-11-21 08:02:41 +0000620 SetupMachineFunction(MF);
Jim Laskeya7cea6f2006-01-04 13:52:30 +0000621
Nate Begemaned428532004-09-04 05:00:00 +0000622 // Print out constants referenced by the function
Chris Lattnerc569e612005-11-21 08:26:15 +0000623 EmitConstantPool(MF.getConstantPool());
Nate Begemaned428532004-09-04 05:00:00 +0000624
625 // Print out header for the function.
626 O << "\t.csect .text[PR]\n"
627 << "\t.align 2\n"
628 << "\t.globl " << CurrentFnName << '\n'
629 << "\t.globl ." << CurrentFnName << '\n'
630 << "\t.csect " << CurrentFnName << "[DS],3\n"
631 << CurrentFnName << ":\n"
632 << "\t.llong ." << CurrentFnName << ", TOC[tc0], 0\n"
633 << "\t.csect .text[PR]\n"
634 << '.' << CurrentFnName << ":\n";
635
636 // Print out code for the function.
637 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
638 I != E; ++I) {
639 // Print a label for the basic block.
Chris Lattner07455362005-11-21 08:14:07 +0000640 O << PrivateGlobalPrefix << "BB" << getFunctionNumber() << '_'
641 << I->getNumber()
Chris Lattner6d5a4f62005-11-21 08:02:41 +0000642 << ":\t" << CommentString << I->getBasicBlock()->getName() << '\n';
Nate Begemaned428532004-09-04 05:00:00 +0000643 for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
644 II != E; ++II) {
645 // Print the assembly for the instruction.
646 O << "\t";
647 printMachineInstruction(II);
648 }
649 }
Nate Begemaned428532004-09-04 05:00:00 +0000650
651 O << "LT.." << CurrentFnName << ":\n"
652 << "\t.long 0\n"
653 << "\t.byte 0,0,32,65,128,0,0,0\n"
654 << "\t.long LT.." << CurrentFnName << "-." << CurrentFnName << '\n'
655 << "\t.short 3\n"
656 << "\t.byte \"" << CurrentFnName << "\"\n"
657 << "\t.align 2\n";
658
659 // We didn't modify anything.
660 return false;
661}
662
Nate Begemaned428532004-09-04 05:00:00 +0000663bool AIXAsmPrinter::doInitialization(Module &M) {
Chris Lattnerac7fd7f2005-11-14 18:52:46 +0000664 SwitchSection("", 0);
Nate Begemaned428532004-09-04 05:00:00 +0000665 const TargetData &TD = TM.getTargetData();
Nate Begemaned428532004-09-04 05:00:00 +0000666
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000667 O << "\t.machine \"ppc64\"\n"
Nate Begemaned428532004-09-04 05:00:00 +0000668 << "\t.toc\n"
669 << "\t.csect .text[PR]\n";
670
671 // Print out module-level global variables
Chris Lattner2e00d7d2005-07-26 19:03:27 +0000672 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
673 I != E; ++I) {
Nate Begemaned428532004-09-04 05:00:00 +0000674 if (!I->hasInitializer())
675 continue;
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000676
Nate Begemaned428532004-09-04 05:00:00 +0000677 std::string Name = I->getName();
678 Constant *C = I->getInitializer();
679 // N.B.: We are defaulting to writable strings
Misha Brukmanb5f662f2005-04-21 23:30:14 +0000680 if (I->hasExternalLinkage()) {
Nate Begemaned428532004-09-04 05:00:00 +0000681 O << "\t.globl " << Name << '\n'
682 << "\t.csect .data[RW],3\n";
683 } else {
684 O << "\t.csect _global.rw_c[RW],3\n";
685 }
686 O << Name << ":\n";
Chris Lattner8b8b9512005-11-21 07:51:23 +0000687 EmitGlobalConstant(C);
Nate Begemaned428532004-09-04 05:00:00 +0000688 }
689
690 // Output labels for globals
Chris Lattnere4d5c442005-03-15 04:54:21 +0000691 if (M.global_begin() != M.global_end()) O << "\t.toc\n";
Chris Lattner2e00d7d2005-07-26 19:03:27 +0000692 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
693 I != E; ++I) {
Nate Begemaned428532004-09-04 05:00:00 +0000694 const GlobalVariable *GV = I;
695 // Do not output labels for unused variables
696 if (GV->isExternal() && GV->use_begin() == GV->use_end())
697 continue;
698
Chris Lattner07455362005-11-21 08:14:07 +0000699 IncrementFunctionNumber();
Nate Begemaned428532004-09-04 05:00:00 +0000700 std::string Name = GV->getName();
Chris Lattner07455362005-11-21 08:14:07 +0000701 std::string Label = "LC.." + utostr(getFunctionNumber());
Nate Begemaned428532004-09-04 05:00:00 +0000702 GVToLabelMap[GV] = Label;
703 O << Label << ":\n"
704 << "\t.tc " << Name << "[TC]," << Name;
705 if (GV->isExternal()) O << "[RW]";
706 O << '\n';
Chris Lattner07455362005-11-21 08:14:07 +0000707 }
Nate Begemaned428532004-09-04 05:00:00 +0000708
Chris Lattner3459bfb2005-11-10 18:20:29 +0000709 AsmPrinter::doInitialization(M);
Nate Begemaned428532004-09-04 05:00:00 +0000710 return false; // success
711}
712
713bool AIXAsmPrinter::doFinalization(Module &M) {
714 const TargetData &TD = TM.getTargetData();
715 // Print out module-level global variables
Chris Lattner2e00d7d2005-07-26 19:03:27 +0000716 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
717 I != E; ++I) {
Nate Begemaned428532004-09-04 05:00:00 +0000718 if (I->hasInitializer() || I->hasExternalLinkage())
719 continue;
720
721 std::string Name = I->getName();
722 if (I->hasInternalLinkage()) {
723 O << "\t.lcomm " << Name << ",16,_global.bss_c";
724 } else {
725 O << "\t.comm " << Name << "," << TD.getTypeSize(I->getType())
Chris Lattner0561b3f2005-08-02 19:26:06 +0000726 << "," << Log2_32((unsigned)TD.getTypeAlignment(I->getType()));
Nate Begemaned428532004-09-04 05:00:00 +0000727 }
Chris Lattner6d5a4f62005-11-21 08:02:41 +0000728 O << "\t\t" << CommentString << " ";
Chris Lattner8ca02912005-10-03 07:08:36 +0000729 WriteAsOperand(O, I, false, true, &M);
Nate Begemaned428532004-09-04 05:00:00 +0000730 O << "\n";
731 }
732
733 O << "_section_.text:\n"
734 << "\t.csect .data[RW],3\n"
735 << "\t.llong _section_.text\n";
Chris Lattner3459bfb2005-11-10 18:20:29 +0000736 AsmPrinter::doFinalization(M);
Nate Begemaned428532004-09-04 05:00:00 +0000737 return false; // success
738}