blob: cf0d5dacd11763f6c7c0d6d0bb317a2e859a638e [file] [log] [blame]
Nate Begeman6cca84e2005-10-16 05:39:50 +00001//===-- PPCAsmPrinter.cpp - Print machine instrs to PowerPC assembly --------=//
Misha Brukmanb4402432005-04-21 23:30:14 +00002//
Misha Brukmane05203f2004-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 Brukmanb4402432005-04-21 23:30:14 +00007//
Misha Brukmane05203f2004-06-21 16:55:25 +00008//===----------------------------------------------------------------------===//
9//
Misha Brukmanb604b4d2004-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 Lattner07fad1c2004-07-28 20:18:53 +000012// the output mechanism used by `llc'.
Misha Brukmane05203f2004-06-21 16:55:25 +000013//
Misha Brukmanb604b4d2004-07-08 17:58:04 +000014// Documentation at http://developer.apple.com/documentation/DeveloperTools/
15// Reference/Assembler/ASMIntroduction/chapter_1_section_1.html
Misha Brukman811f5c22004-06-29 17:13:26 +000016//
Misha Brukmane05203f2004-06-21 16:55:25 +000017//===----------------------------------------------------------------------===//
18
Misha Brukmanf57c3cd2004-06-24 17:31:42 +000019#define DEBUG_TYPE "asmprinter"
Chris Lattnerbfca1ab2005-10-14 23:51:18 +000020#include "PPC.h"
Chris Lattner6f3b9542005-10-14 23:59:06 +000021#include "PPCTargetMachine.h"
Chris Lattnerbfca1ab2005-10-14 23:51:18 +000022#include "PPCSubtarget.h"
Misha Brukmane05203f2004-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 Lattner0ced9052004-08-16 23:25:21 +000027#include "llvm/CodeGen/AsmPrinter.h"
Misha Brukmane05203f2004-06-21 16:55:25 +000028#include "llvm/CodeGen/MachineConstantPool.h"
Misha Brukmanf57c3cd2004-06-24 17:31:42 +000029#include "llvm/CodeGen/MachineFunctionPass.h"
Misha Brukmane05203f2004-06-21 16:55:25 +000030#include "llvm/CodeGen/MachineInstr.h"
Chris Lattnerec1cc1b2004-08-14 23:27:29 +000031#include "llvm/CodeGen/ValueTypes.h"
Misha Brukmane05203f2004-06-21 16:55:25 +000032#include "llvm/Support/Mangler.h"
Nate Begeman4d847042004-09-04 14:51:26 +000033#include "llvm/Support/MathExtras.h"
Reid Spencer7c16caa2004-09-01 22:55:40 +000034#include "llvm/Support/CommandLine.h"
35#include "llvm/Support/Debug.h"
Nate Begemandd8f1d82004-10-26 06:02:38 +000036#include "llvm/Target/MRegisterInfo.h"
Nate Begeman3f76eb62004-11-25 07:09:01 +000037#include "llvm/Target/TargetInstrInfo.h"
Reid Spencer7c16caa2004-09-01 22:55:40 +000038#include "llvm/ADT/Statistic.h"
39#include "llvm/ADT/StringExtras.h"
Misha Brukmanf57c3cd2004-06-24 17:31:42 +000040#include <set>
Chris Lattner0ced9052004-08-16 23:25:21 +000041using namespace llvm;
Misha Brukmane05203f2004-06-21 16:55:25 +000042
43namespace {
44 Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
45
Chris Lattner0aacd2a2005-11-14 18:52:46 +000046 class PPCAsmPrinter : public AsmPrinter {
Chris Lattner0aacd2a2005-11-14 18:52:46 +000047 public:
Misha Brukman8d75aa42004-07-21 20:11:11 +000048 std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
Chris Lattner0aacd2a2005-11-14 18:52:46 +000049
Chris Lattner0921e3b2005-10-14 23:37:35 +000050 PPCAsmPrinter(std::ostream &O, TargetMachine &TM)
Chris Lattnerfafff9b2005-11-10 21:59:25 +000051 : AsmPrinter(O, TM), FunctionNumber(0) {}
Misha Brukmane05203f2004-06-21 16:55:25 +000052
Misha Brukmaned664f92004-07-26 16:28:33 +000053 /// Unique incrementer for label values for referencing Global values.
Misha Brukman811f5c22004-06-29 17:13:26 +000054 ///
Chris Lattnerfafff9b2005-11-10 21:59:25 +000055 unsigned FunctionNumber;
Misha Brukmanb4402432005-04-21 23:30:14 +000056
Misha Brukmane05203f2004-06-21 16:55:25 +000057 virtual const char *getPassName() const {
Nate Begeman4bfceb12004-09-04 05:00:00 +000058 return "PowerPC Assembly Printer";
Misha Brukmane05203f2004-06-21 16:55:25 +000059 }
60
Nate Begeman6cca84e2005-10-16 05:39:50 +000061 PPCTargetMachine &getTM() {
62 return static_cast<PPCTargetMachine&>(TM);
Chris Lattner0ced9052004-08-16 23:25:21 +000063 }
64
Nate Begeman8465fe82005-07-20 22:42:00 +000065 unsigned enumRegToMachineReg(unsigned enumReg) {
66 switch (enumReg) {
67 default: assert(0 && "Unhandled register!"); break;
68 case PPC::CR0: return 0;
69 case PPC::CR1: return 1;
70 case PPC::CR2: return 2;
71 case PPC::CR3: return 3;
72 case PPC::CR4: return 4;
73 case PPC::CR5: return 5;
74 case PPC::CR6: return 6;
75 case PPC::CR7: return 7;
76 }
77 abort();
78 }
79
Nate Begeman0ad7f812004-08-14 22:09:10 +000080 /// printInstruction - This method is automatically generated by tablegen
81 /// from the instruction set description. This method returns true if the
82 /// machine instruction was sufficiently described to print it, otherwise it
83 /// returns false.
84 bool printInstruction(const MachineInstr *MI);
85
Misha Brukmane05203f2004-06-21 16:55:25 +000086 void printMachineInstruction(const MachineInstr *MI);
Chris Lattner6ab87fa2005-11-17 19:25:59 +000087 void printOp(const MachineOperand &MO);
Chris Lattnerec1cc1b2004-08-14 23:27:29 +000088
89 void printOperand(const MachineInstr *MI, unsigned OpNo, MVT::ValueType VT){
90 const MachineOperand &MO = MI->getOperand(OpNo);
91 if (MO.getType() == MachineOperand::MO_MachineRegister) {
92 assert(MRegisterInfo::isPhysicalRegister(MO.getReg())&&"Not physreg??");
Chris Lattner956820d2005-08-22 22:00:02 +000093 O << TM.getRegisterInfo()->get(MO.getReg()).Name;
Chris Lattnerda2e56f2004-08-15 05:46:14 +000094 } else if (MO.isImmediate()) {
95 O << MO.getImmedValue();
Chris Lattnerec1cc1b2004-08-14 23:27:29 +000096 } else {
97 printOp(MO);
98 }
99 }
100
Nate Begeman3ad3ad42004-08-21 05:56:39 +0000101 void printU5ImmOperand(const MachineInstr *MI, unsigned OpNo,
102 MVT::ValueType VT) {
103 unsigned char value = MI->getOperand(OpNo).getImmedValue();
Chris Lattnerf7833ba2004-08-21 19:11:03 +0000104 assert(value <= 31 && "Invalid u5imm argument!");
Nate Begeman3ad3ad42004-08-21 05:56:39 +0000105 O << (unsigned int)value;
106 }
Nate Begeman143cf942004-08-30 02:28:06 +0000107 void printU6ImmOperand(const MachineInstr *MI, unsigned OpNo,
108 MVT::ValueType VT) {
109 unsigned char value = MI->getOperand(OpNo).getImmedValue();
110 assert(value <= 63 && "Invalid u6imm argument!");
111 O << (unsigned int)value;
112 }
Nate Begeman4bfceb12004-09-04 05:00:00 +0000113 void printS16ImmOperand(const MachineInstr *MI, unsigned OpNo,
114 MVT::ValueType VT) {
115 O << (short)MI->getOperand(OpNo).getImmedValue();
116 }
Chris Lattner8a796852004-08-15 05:20:16 +0000117 void printU16ImmOperand(const MachineInstr *MI, unsigned OpNo,
118 MVT::ValueType VT) {
119 O << (unsigned short)MI->getOperand(OpNo).getImmedValue();
120 }
Chris Lattner5a2fb972005-10-18 16:51:22 +0000121 void printS16X4ImmOperand(const MachineInstr *MI, unsigned OpNo,
122 MVT::ValueType VT) {
123 O << (short)MI->getOperand(OpNo).getImmedValue()*4;
124 }
Nate Begeman61738782004-09-02 08:13:00 +0000125 void printBranchOperand(const MachineInstr *MI, unsigned OpNo,
Misha Brukmancea2e462004-10-23 04:58:32 +0000126 MVT::ValueType VT) {
Nate Begeman4bfceb12004-09-04 05:00:00 +0000127 // Branches can take an immediate operand. This is used by the branch
128 // selection pass to print $+8, an eight byte displacement from the PC.
129 if (MI->getOperand(OpNo).isImmediate()) {
Nate Begeman6566e8a2005-04-10 01:48:29 +0000130 O << "$+" << MI->getOperand(OpNo).getImmedValue();
Nate Begeman4bfceb12004-09-04 05:00:00 +0000131 } else {
Chris Lattnerbd9efdb2005-11-17 19:16:08 +0000132 printOp(MI->getOperand(OpNo));
Nate Begeman4bfceb12004-09-04 05:00:00 +0000133 }
Nate Begeman61738782004-09-02 08:13:00 +0000134 }
Chris Lattnerbd9efdb2005-11-17 19:16:08 +0000135 void printCallOperand(const MachineInstr *MI, unsigned OpNo,
136 MVT::ValueType VT) {
Chris Lattner6ab87fa2005-11-17 19:25:59 +0000137 const MachineOperand &MO = MI->getOperand(OpNo);
Chris Lattnercdde99902005-11-17 19:40:30 +0000138 if (!PPCGenerateStaticCode) {
139 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;
144 } else if (MO.getType() == MachineOperand::MO_GlobalAddress &&
145 isa<Function>(MO.getGlobal()) &&
146 cast<Function>(MO.getGlobal())->isExternal()) {
147 // Dynamically-resolved functions need a stub for the function.
148 std::string Name = Mang->getValueName(MO.getGlobal());
149 FnStubs.insert(Name);
150 O << "L" << Name << "$stub";
151 return;
152 }
Chris Lattner6ab87fa2005-11-17 19:25:59 +0000153 }
Chris Lattnercdde99902005-11-17 19:40:30 +0000154
155 printOp(MI->getOperand(OpNo));
Chris Lattnerbd9efdb2005-11-17 19:16:08 +0000156 }
Nate Begemana171f6b2005-11-16 00:48:01 +0000157 void printAbsAddrOperand(const MachineInstr *MI, unsigned OpNo,
158 MVT::ValueType VT) {
159 O << (int)MI->getOperand(OpNo).getImmedValue()*4;
160 }
Nate Begeman61738782004-09-02 08:13:00 +0000161 void printPICLabel(const MachineInstr *MI, unsigned OpNo,
Misha Brukmancea2e462004-10-23 04:58:32 +0000162 MVT::ValueType VT) {
Nate Begeman61738782004-09-02 08:13:00 +0000163 // FIXME: should probably be converted to cout.width and cout.fill
Chris Lattnerfafff9b2005-11-10 21:59:25 +0000164 O << "\"L0000" << FunctionNumber << "$pb\"\n";
165 O << "\"L0000" << FunctionNumber << "$pb\":";
Nate Begeman61738782004-09-02 08:13:00 +0000166 }
Nate Begeman4bfceb12004-09-04 05:00:00 +0000167 void printSymbolHi(const MachineInstr *MI, unsigned OpNo,
Misha Brukmancea2e462004-10-23 04:58:32 +0000168 MVT::ValueType VT) {
Nate Begemana9443f22005-07-21 20:44:43 +0000169 if (MI->getOperand(OpNo).isImmediate()) {
170 printS16ImmOperand(MI, OpNo, VT);
171 } else {
172 O << "ha16(";
173 printOp(MI->getOperand(OpNo));
174 if (PICEnabled)
Chris Lattnerfafff9b2005-11-10 21:59:25 +0000175 O << "-\"L0000" << FunctionNumber << "$pb\")";
Nate Begemana9443f22005-07-21 20:44:43 +0000176 else
177 O << ')';
178 }
Nate Begeman4bfceb12004-09-04 05:00:00 +0000179 }
180 void printSymbolLo(const MachineInstr *MI, unsigned OpNo,
Misha Brukmancea2e462004-10-23 04:58:32 +0000181 MVT::ValueType VT) {
Nate Begeman4bfceb12004-09-04 05:00:00 +0000182 if (MI->getOperand(OpNo).isImmediate()) {
Nate Begemana9443f22005-07-21 20:44:43 +0000183 printS16ImmOperand(MI, OpNo, VT);
Nate Begeman4bfceb12004-09-04 05:00:00 +0000184 } else {
185 O << "lo16(";
Nate Begeman3f76eb62004-11-25 07:09:01 +0000186 printOp(MI->getOperand(OpNo));
Nate Begemana9443f22005-07-21 20:44:43 +0000187 if (PICEnabled)
Chris Lattnerfafff9b2005-11-10 21:59:25 +0000188 O << "-\"L0000" << FunctionNumber << "$pb\")";
Nate Begemana9443f22005-07-21 20:44:43 +0000189 else
190 O << ')';
Nate Begeman4bfceb12004-09-04 05:00:00 +0000191 }
192 }
Nate Begeman8465fe82005-07-20 22:42:00 +0000193 void printcrbitm(const MachineInstr *MI, unsigned OpNo,
194 MVT::ValueType VT) {
195 unsigned CCReg = MI->getOperand(OpNo).getReg();
196 unsigned RegNo = enumRegToMachineReg(CCReg);
197 O << (0x80 >> RegNo);
198 }
Misha Brukmanb4402432005-04-21 23:30:14 +0000199
Nate Begeman4bfceb12004-09-04 05:00:00 +0000200 virtual void printConstantPool(MachineConstantPool *MCP) = 0;
Misha Brukmanb4402432005-04-21 23:30:14 +0000201 virtual bool runOnMachineFunction(MachineFunction &F) = 0;
Nate Begeman4bfceb12004-09-04 05:00:00 +0000202 virtual bool doFinalization(Module &M) = 0;
203 };
Misha Brukmanb4402432005-04-21 23:30:14 +0000204
Misha Brukman175fdd42004-09-05 02:42:44 +0000205 /// DarwinAsmPrinter - PowerPC assembly printer, customized for Darwin/Mac OS
206 /// X
207 ///
Chris Lattner0921e3b2005-10-14 23:37:35 +0000208 struct DarwinAsmPrinter : public PPCAsmPrinter {
Nate Begeman4bfceb12004-09-04 05:00:00 +0000209
210 DarwinAsmPrinter(std::ostream &O, TargetMachine &TM)
Chris Lattner0921e3b2005-10-14 23:37:35 +0000211 : PPCAsmPrinter(O, TM) {
Nate Begeman4bfceb12004-09-04 05:00:00 +0000212 CommentString = ";";
213 GlobalPrefix = "_";
Chris Lattner41cb1152005-11-21 06:47:58 +0000214 PrivateGlobalPrefix = "L"; // Marker for constant pool idxs
Nate Begeman4bfceb12004-09-04 05:00:00 +0000215 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
216 Data64bitsDirective = 0; // we can't emit a 64-bit unit
217 AlignmentIsInBytes = false; // Alignment is by power of 2.
218 }
219
220 virtual const char *getPassName() const {
221 return "Darwin PPC Assembly Printer";
222 }
Chris Lattner8a796852004-08-15 05:20:16 +0000223
Misha Brukmane05203f2004-06-21 16:55:25 +0000224 void printConstantPool(MachineConstantPool *MCP);
Misha Brukmanb4402432005-04-21 23:30:14 +0000225 bool runOnMachineFunction(MachineFunction &F);
Nate Begeman15527112005-07-21 01:25:49 +0000226 bool doInitialization(Module &M);
Misha Brukmane05203f2004-06-21 16:55:25 +0000227 bool doFinalization(Module &M);
Misha Brukmane05203f2004-06-21 16:55:25 +0000228 };
Misha Brukmanb4402432005-04-21 23:30:14 +0000229
Misha Brukman175fdd42004-09-05 02:42:44 +0000230 /// AIXAsmPrinter - PowerPC assembly printer, customized for AIX
231 ///
Chris Lattner0921e3b2005-10-14 23:37:35 +0000232 struct AIXAsmPrinter : public PPCAsmPrinter {
Nate Begeman4bfceb12004-09-04 05:00:00 +0000233 /// Map for labels corresponding to global variables
234 ///
235 std::map<const GlobalVariable*,std::string> GVToLabelMap;
236
237 AIXAsmPrinter(std::ostream &O, TargetMachine &TM)
Chris Lattner0921e3b2005-10-14 23:37:35 +0000238 : PPCAsmPrinter(O, TM) {
Nate Begeman4bfceb12004-09-04 05:00:00 +0000239 CommentString = "#";
Chris Lattner59e44ff2005-11-10 18:20:29 +0000240 GlobalPrefix = ".";
Nate Begeman4bfceb12004-09-04 05:00:00 +0000241 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
242 Data64bitsDirective = 0; // we can't emit a 64-bit unit
243 AlignmentIsInBytes = false; // Alignment is by power of 2.
244 }
Misha Brukmanb4402432005-04-21 23:30:14 +0000245
Nate Begeman4bfceb12004-09-04 05:00:00 +0000246 virtual const char *getPassName() const {
247 return "AIX PPC Assembly Printer";
248 }
249
250 void printConstantPool(MachineConstantPool *MCP);
Misha Brukmanb4402432005-04-21 23:30:14 +0000251 bool runOnMachineFunction(MachineFunction &F);
Nate Begeman4bfceb12004-09-04 05:00:00 +0000252 bool doInitialization(Module &M);
253 bool doFinalization(Module &M);
254 };
Misha Brukmane05203f2004-06-21 16:55:25 +0000255} // end of anonymous namespace
256
Misha Brukmanb4402432005-04-21 23:30:14 +0000257/// createDarwinAsmPrinterPass - Returns a pass that prints the PPC assembly
258/// code for a MachineFunction to the given output stream, in a format that the
Nate Begeman4bfceb12004-09-04 05:00:00 +0000259/// Darwin assembler can deal with.
260///
261FunctionPass *llvm::createDarwinAsmPrinter(std::ostream &o, TargetMachine &tm) {
262 return new DarwinAsmPrinter(o, tm);
263}
264
265/// createAIXAsmPrinterPass - Returns a pass that prints the PPC assembly code
Misha Brukmanb4402432005-04-21 23:30:14 +0000266/// for a MachineFunction to the given output stream, in a format that the
Nate Begeman4bfceb12004-09-04 05:00:00 +0000267/// AIX 5L assembler can deal with.
268///
269FunctionPass *llvm::createAIXAsmPrinter(std::ostream &o, TargetMachine &tm) {
270 return new AIXAsmPrinter(o, tm);
Misha Brukmane05203f2004-06-21 16:55:25 +0000271}
272
Nate Begeman0ad7f812004-08-14 22:09:10 +0000273// Include the auto-generated portion of the assembly writer
Chris Lattner0921e3b2005-10-14 23:37:35 +0000274#include "PPCGenAsmWriter.inc"
Nate Begeman0ad7f812004-08-14 22:09:10 +0000275
Chris Lattner6ab87fa2005-11-17 19:25:59 +0000276void PPCAsmPrinter::printOp(const MachineOperand &MO) {
Misha Brukmane05203f2004-06-21 16:55:25 +0000277 const MRegisterInfo &RI = *TM.getRegisterInfo();
278 int new_symbol;
Misha Brukmanb4402432005-04-21 23:30:14 +0000279
Misha Brukmane05203f2004-06-21 16:55:25 +0000280 switch (MO.getType()) {
281 case MachineOperand::MO_VirtualRegister:
282 if (Value *V = MO.getVRegValueOrNull()) {
283 O << "<" << V->getName() << ">";
284 return;
285 }
286 // FALLTHROUGH
287 case MachineOperand::MO_MachineRegister:
Misha Brukmanb604b4d2004-07-08 17:58:04 +0000288 case MachineOperand::MO_CCRegister:
Chris Lattner956820d2005-08-22 22:00:02 +0000289 O << RI.get(MO.getReg()).Name;
Misha Brukmana08a2362004-06-24 23:51:00 +0000290 return;
Misha Brukmane05203f2004-06-21 16:55:25 +0000291
292 case MachineOperand::MO_SignExtendedImmed:
Misha Brukman47d5a222004-07-28 00:00:48 +0000293 case MachineOperand::MO_UnextendedImmed:
294 std::cerr << "printOp() does not handle immediate values\n";
295 abort();
Misha Brukman8d75aa42004-07-21 20:11:11 +0000296 return;
297
Misha Brukmanb604b4d2004-07-08 17:58:04 +0000298 case MachineOperand::MO_PCRelativeDisp:
299 std::cerr << "Shouldn't use addPCDisp() when building PPC MachineInstrs";
300 abort();
301 return;
Misha Brukmanb4402432005-04-21 23:30:14 +0000302
Misha Brukmane05203f2004-06-21 16:55:25 +0000303 case MachineOperand::MO_MachineBasicBlock: {
304 MachineBasicBlock *MBBOp = MO.getMachineBasicBlock();
Chris Lattnerfafff9b2005-11-10 21:59:25 +0000305 O << "LBB" << FunctionNumber << "_" << MBBOp->getNumber() << "\t; "
Misha Brukmanc56b66f2004-06-25 15:42:10 +0000306 << MBBOp->getBasicBlock()->getName();
Misha Brukmane05203f2004-06-21 16:55:25 +0000307 return;
308 }
Misha Brukmanb604b4d2004-07-08 17:58:04 +0000309
310 case MachineOperand::MO_ConstantPoolIndex:
Chris Lattner41cb1152005-11-21 06:47:58 +0000311 O << PrivateGlobalPrefix << "CPI" << FunctionNumber
312 << '_' << MO.getConstantPoolIndex();
Misha Brukmane05203f2004-06-21 16:55:25 +0000313 return;
Misha Brukmanb604b4d2004-07-08 17:58:04 +0000314
315 case MachineOperand::MO_ExternalSymbol:
Nate Begeman5851a662005-03-30 01:45:43 +0000316 O << GlobalPrefix << MO.getSymbolName();
Misha Brukmanb604b4d2004-07-08 17:58:04 +0000317 return;
318
Nate Begeman5bf9bfe2004-08-13 09:32:01 +0000319 case MachineOperand::MO_GlobalAddress: {
320 GlobalValue *GV = MO.getGlobal();
321 std::string Name = Mang->getValueName(GV);
Misha Brukman7dba17d2004-07-23 16:08:20 +0000322
Nate Begeman844186b2004-10-17 23:01:34 +0000323 // External or weakly linked global variables need non-lazily-resolved stubs
Chris Lattnercdde99902005-11-17 19:40:30 +0000324 if (!PPCGenerateStaticCode &&
325 ((GV->isExternal() || GV->hasWeakLinkage() ||
326 GV->hasLinkOnceLinkage()))) {
Nate Begeman3f76eb62004-11-25 07:09:01 +0000327 if (GV->hasLinkOnceLinkage())
328 LinkOnceStubs.insert(Name);
329 else
330 GVStubs.insert(Name);
Nate Begeman5bf9bfe2004-08-13 09:32:01 +0000331 O << "L" << Name << "$non_lazy_ptr";
332 return;
333 }
Nate Begeman3f76eb62004-11-25 07:09:01 +0000334
Chris Lattnercdde99902005-11-17 19:40:30 +0000335 O << Name;
Misha Brukmane05203f2004-06-21 16:55:25 +0000336 return;
Nate Begeman5bf9bfe2004-08-13 09:32:01 +0000337 }
Misha Brukmanb4402432005-04-21 23:30:14 +0000338
Misha Brukmane05203f2004-06-21 16:55:25 +0000339 default:
Misha Brukmanb604b4d2004-07-08 17:58:04 +0000340 O << "<unknown operand type: " << MO.getType() << ">";
Misha Brukmana2737582004-06-25 15:11:34 +0000341 return;
Misha Brukmane05203f2004-06-21 16:55:25 +0000342 }
343}
344
Nate Begeman0ad7f812004-08-14 22:09:10 +0000345/// printMachineInstruction -- Print out a single PowerPC MI in Darwin syntax to
346/// the current output stream.
Misha Brukmane05203f2004-06-21 16:55:25 +0000347///
Chris Lattner0921e3b2005-10-14 23:37:35 +0000348void PPCAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
Nate Begeman0ad7f812004-08-14 22:09:10 +0000349 ++EmittedInsts;
Chris Lattner2121f3c2005-10-14 22:44:13 +0000350
Nate Begeman52441732005-04-05 18:19:50 +0000351 // Check for slwi/srwi mnemonics.
352 if (MI->getOpcode() == PPC::RLWINM) {
353 bool FoundMnemonic = false;
354 unsigned char SH = MI->getOperand(2).getImmedValue();
355 unsigned char MB = MI->getOperand(3).getImmedValue();
356 unsigned char ME = MI->getOperand(4).getImmedValue();
357 if (SH <= 31 && MB == 0 && ME == (31-SH)) {
358 O << "slwi "; FoundMnemonic = true;
359 }
360 if (SH <= 31 && MB == (32-SH) && ME == 31) {
361 O << "srwi "; FoundMnemonic = true;
362 SH = 32-SH;
363 }
364 if (FoundMnemonic) {
Misha Brukmanb4402432005-04-21 23:30:14 +0000365 printOperand(MI, 0, MVT::i64);
366 O << ", ";
367 printOperand(MI, 1, MVT::i64);
Nate Begeman52441732005-04-05 18:19:50 +0000368 O << ", " << (unsigned int)SH << "\n";
369 return;
370 }
371 }
Misha Brukmanb4402432005-04-21 23:30:14 +0000372
Nate Begeman0ad7f812004-08-14 22:09:10 +0000373 if (printInstruction(MI))
374 return; // Printer was automatically generated
Misha Brukmanb4402432005-04-21 23:30:14 +0000375
Nate Begeman4bfceb12004-09-04 05:00:00 +0000376 assert(0 && "Unhandled instruction in asm writer!");
377 abort();
Nate Begeman0ad7f812004-08-14 22:09:10 +0000378 return;
Misha Brukmane05203f2004-06-21 16:55:25 +0000379}
380
Nate Begeman4bfceb12004-09-04 05:00:00 +0000381/// runOnMachineFunction - This uses the printMachineInstruction()
382/// method to print assembly for each instruction.
383///
384bool DarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
385 setupMachineFunction(MF);
386 O << "\n\n";
387
388 // Print out constants referenced by the function
389 printConstantPool(MF.getConstantPool());
390
391 // Print out labels for the function.
Chris Lattner0aacd2a2005-11-14 18:52:46 +0000392 const Function *F = MF.getFunction();
393 SwitchSection(".text", F);
Chris Lattner1a4adc72005-11-14 19:00:30 +0000394 emitAlignment(4, F);
Chris Lattner0aacd2a2005-11-14 18:52:46 +0000395 if (!F->hasInternalLinkage())
Chris Lattner97d72c82005-10-28 18:44:07 +0000396 O << "\t.globl\t" << CurrentFnName << "\n";
Nate Begeman4bfceb12004-09-04 05:00:00 +0000397 O << CurrentFnName << ":\n";
398
399 // Print out code for the function.
400 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
401 I != E; ++I) {
402 // Print a label for the basic block.
Chris Lattner968aeb12005-08-21 19:09:33 +0000403 if (I != MF.begin()) {
Chris Lattnerfafff9b2005-11-10 21:59:25 +0000404 O << "LBB" << FunctionNumber << '_' << I->getNumber() << ":\t";
Chris Lattner968aeb12005-08-21 19:09:33 +0000405 if (!I->getBasicBlock()->getName().empty())
406 O << CommentString << " " << I->getBasicBlock()->getName();
407 O << "\n";
408 }
Nate Begeman4bfceb12004-09-04 05:00:00 +0000409 for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
410 II != E; ++II) {
411 // Print the assembly for the instruction.
412 O << "\t";
413 printMachineInstruction(II);
414 }
415 }
Chris Lattnerfafff9b2005-11-10 21:59:25 +0000416 ++FunctionNumber;
Nate Begeman4bfceb12004-09-04 05:00:00 +0000417
418 // We didn't modify anything.
419 return false;
420}
421
422/// printConstantPool - Print to the current output stream assembly
423/// representations of the constants in the constant pool MCP. This is
424/// used to print out constants which have been "spilled to memory" by
425/// the code generator.
426///
427void DarwinAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
428 const std::vector<Constant*> &CP = MCP->getConstants();
429 const TargetData &TD = TM.getTargetData();
Misha Brukmanb4402432005-04-21 23:30:14 +0000430
Nate Begeman4bfceb12004-09-04 05:00:00 +0000431 if (CP.empty()) return;
432
Chris Lattner41cb1152005-11-21 06:47:58 +0000433 SwitchSection(".const", 0);
Nate Begeman4bfceb12004-09-04 05:00:00 +0000434 for (unsigned i = 0, e = CP.size(); i != e; ++i) {
Nate Begemane3cbe102005-08-04 21:04:09 +0000435 // FIXME: force doubles to be naturally aligned. We should handle this
436 // more correctly in the future.
Chris Lattner41cb1152005-11-21 06:47:58 +0000437 if (CP[i]->getType() == Type::DoubleTy)
Nate Begemane3cbe102005-08-04 21:04:09 +0000438 emitAlignment(3);
439 else
440 emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
Chris Lattner41cb1152005-11-21 06:47:58 +0000441 O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i
442 << ":\t\t\t\t\t" << CommentString << *CP[i] << '\n';
Nate Begeman4bfceb12004-09-04 05:00:00 +0000443 emitGlobalConstant(CP[i]);
Misha Brukmane05203f2004-06-21 16:55:25 +0000444 }
445}
446
Nate Begeman15527112005-07-21 01:25:49 +0000447bool DarwinAsmPrinter::doInitialization(Module &M) {
Chris Lattner983a4152005-08-05 22:05:03 +0000448 if (TM.getSubtarget<PPCSubtarget>().isGigaProcessor())
449 O << "\t.machine ppc970\n";
Nate Begeman15527112005-07-21 01:25:49 +0000450 AsmPrinter::doInitialization(M);
Chris Lattner9eb7dfa2005-11-10 19:33:43 +0000451
452 // Darwin wants symbols to be quoted if they have complex names.
453 Mang->setUseQuotes(true);
Nate Begeman15527112005-07-21 01:25:49 +0000454 return false;
455}
456
Nate Begeman4bfceb12004-09-04 05:00:00 +0000457bool DarwinAsmPrinter::doFinalization(Module &M) {
Misha Brukmane05203f2004-06-21 16:55:25 +0000458 const TargetData &TD = TM.getTargetData();
Misha Brukmane05203f2004-06-21 16:55:25 +0000459
460 // Print out module-level global variables here.
Chris Lattner1a4adc72005-11-14 19:00:30 +0000461 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
462 I != E; ++I)
Misha Brukmane05203f2004-06-21 16:55:25 +0000463 if (I->hasInitializer()) { // External global require no code
Nate Begeman033b8162004-09-22 04:40:25 +0000464 O << '\n';
Misha Brukmane05203f2004-06-21 16:55:25 +0000465 std::string name = Mang->getValueName(I);
466 Constant *C = I->getInitializer();
467 unsigned Size = TD.getTypeSize(C->getType());
Chris Lattner2501f5852004-08-17 19:26:03 +0000468 unsigned Align = TD.getTypeAlignmentShift(C->getType());
Misha Brukmane05203f2004-06-21 16:55:25 +0000469
Misha Brukman8d75aa42004-07-21 20:11:11 +0000470 if (C->isNullValue() && /* FIXME: Verify correct */
Misha Brukmanb4402432005-04-21 23:30:14 +0000471 (I->hasInternalLinkage() || I->hasWeakLinkage() ||
Nate Begeman11649552004-11-09 04:01:18 +0000472 I->hasLinkOnceLinkage())) {
Chris Lattner0aacd2a2005-11-14 18:52:46 +0000473 SwitchSection(".data", I);
Chris Lattnercbd47632004-12-12 20:36:19 +0000474 if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
Misha Brukmane05203f2004-06-21 16:55:25 +0000475 if (I->hasInternalLinkage())
Chris Lattner10b637e2004-12-12 20:31:00 +0000476 O << ".lcomm " << name << "," << Size << "," << Align;
Misha Brukmanb4402432005-04-21 23:30:14 +0000477 else
Chris Lattner10b637e2004-12-12 20:31:00 +0000478 O << ".comm " << name << "," << Size;
Chris Lattnerafef68b2005-10-03 07:08:36 +0000479 O << "\t\t; '" << I->getName() << "'\n";
Misha Brukmane05203f2004-06-21 16:55:25 +0000480 } else {
481 switch (I->getLinkage()) {
482 case GlobalValue::LinkOnceLinkage:
Chris Lattner63985e22005-11-15 01:45:01 +0000483 SwitchSection("", 0);
Misha Brukman8d75aa42004-07-21 20:11:11 +0000484 O << ".section __TEXT,__textcoal_nt,coalesced,no_toc\n"
485 << ".weak_definition " << name << '\n'
486 << ".private_extern " << name << '\n'
487 << ".section __DATA,__datacoal_nt,coalesced,no_toc\n";
488 LinkOnceStubs.insert(name);
Misha Brukmanb4402432005-04-21 23:30:14 +0000489 break;
Chris Lattner06721f52005-07-26 19:03:27 +0000490 case GlobalValue::WeakLinkage:
491 O << ".weak_definition " << name << '\n'
492 << ".private_extern " << name << '\n';
Misha Brukmane05203f2004-06-21 16:55:25 +0000493 break;
Misha Brukmane05203f2004-06-21 16:55:25 +0000494 case GlobalValue::AppendingLinkage:
495 // FIXME: appending linkage variables should go into a section of
496 // their name or something. For now, just emit them as external.
497 case GlobalValue::ExternalLinkage:
498 // If external or appending, declare as a global symbol
499 O << "\t.globl " << name << "\n";
500 // FALL THROUGH
501 case GlobalValue::InternalLinkage:
Chris Lattner0aacd2a2005-11-14 18:52:46 +0000502 SwitchSection(".data", I);
Misha Brukmane05203f2004-06-21 16:55:25 +0000503 break;
Chris Lattner0aacd2a2005-11-14 18:52:46 +0000504 default:
505 std::cerr << "Unknown linkage type!";
Misha Brukmane225fa12004-11-14 21:03:30 +0000506 abort();
Misha Brukmane05203f2004-06-21 16:55:25 +0000507 }
508
Chris Lattner1a4adc72005-11-14 19:00:30 +0000509 emitAlignment(Align, I);
Chris Lattnerafef68b2005-10-03 07:08:36 +0000510 O << name << ":\t\t\t\t; '" << I->getName() << "'\n";
Misha Brukmane05203f2004-06-21 16:55:25 +0000511 emitGlobalConstant(C);
512 }
513 }
Misha Brukmand4ac8182004-07-16 20:29:04 +0000514
515 // Output stubs for dynamically-linked functions
Misha Brukmanb4402432005-04-21 23:30:14 +0000516 for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
Misha Brukmand4ac8182004-07-16 20:29:04 +0000517 i != e; ++i)
Misha Brukmanf62ee7a2004-06-24 23:04:11 +0000518 {
Nate Begemana9443f22005-07-21 20:44:43 +0000519 if (PICEnabled) {
Misha Brukman7dba17d2004-07-23 16:08:20 +0000520 O << ".data\n";
521 O << ".section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32\n";
Chris Lattner2501f5852004-08-17 19:26:03 +0000522 emitAlignment(2);
Misha Brukmanf62ee7a2004-06-24 23:04:11 +0000523 O << "L" << *i << "$stub:\n";
524 O << "\t.indirect_symbol " << *i << "\n";
525 O << "\tmflr r0\n";
Misha Brukman7dba17d2004-07-23 16:08:20 +0000526 O << "\tbcl 20,31,L0$" << *i << "\n";
Misha Brukmanf62ee7a2004-06-24 23:04:11 +0000527 O << "L0$" << *i << ":\n";
528 O << "\tmflr r11\n";
529 O << "\taddis r11,r11,ha16(L" << *i << "$lazy_ptr-L0$" << *i << ")\n";
530 O << "\tmtlr r0\n";
Misha Brukman7dba17d2004-07-23 16:08:20 +0000531 O << "\tlwzu r12,lo16(L" << *i << "$lazy_ptr-L0$" << *i << ")(r11)\n";
Misha Brukmanf62ee7a2004-06-24 23:04:11 +0000532 O << "\tmtctr r12\n";
533 O << "\tbctr\n";
534 O << ".data\n";
535 O << ".lazy_symbol_pointer\n";
536 O << "L" << *i << "$lazy_ptr:\n";
Misha Brukman7dba17d2004-07-23 16:08:20 +0000537 O << "\t.indirect_symbol " << *i << "\n";
538 O << "\t.long dyld_stub_binding_helper\n";
Nate Begemana9443f22005-07-21 20:44:43 +0000539 } else {
540 O << "\t.section __TEXT,__symbol_stub1,symbol_stubs,pure_instructions,16\n";
541 emitAlignment(4);
542 O << "L" << *i << "$stub:\n";
543 O << "\t.indirect_symbol " << *i << "\n";
544 O << "\tlis r11,ha16(L" << *i << "$lazy_ptr)\n";
545 O << "\tlwzu r12,lo16(L" << *i << "$lazy_ptr)(r11)\n";
546 O << "\tmtctr r12\n";
547 O << "\tbctr\n";
548 O << "\t.lazy_symbol_pointer\n";
549 O << "L" << *i << "$lazy_ptr:\n";
550 O << "\t.indirect_symbol " << *i << "\n";
551 O << "\t.long dyld_stub_binding_helper\n";
552 }
Misha Brukmanf62ee7a2004-06-24 23:04:11 +0000553 }
Misha Brukmane05203f2004-06-21 16:55:25 +0000554
Misha Brukmand4ac8182004-07-16 20:29:04 +0000555 O << "\n";
556
557 // Output stubs for external global variables
558 if (GVStubs.begin() != GVStubs.end())
Misha Brukman7dba17d2004-07-23 16:08:20 +0000559 O << ".data\n.non_lazy_symbol_pointer\n";
Misha Brukmanb4402432005-04-21 23:30:14 +0000560 for (std::set<std::string>::iterator i = GVStubs.begin(), e = GVStubs.end();
Misha Brukmand4ac8182004-07-16 20:29:04 +0000561 i != e; ++i) {
562 O << "L" << *i << "$non_lazy_ptr:\n";
563 O << "\t.indirect_symbol " << *i << "\n";
564 O << "\t.long\t0\n";
565 }
Misha Brukmanb4402432005-04-21 23:30:14 +0000566
Nate Begeman0ad7f812004-08-14 22:09:10 +0000567 // Output stubs for link-once variables
568 if (LinkOnceStubs.begin() != LinkOnceStubs.end())
569 O << ".data\n.align 2\n";
Misha Brukmanb4402432005-04-21 23:30:14 +0000570 for (std::set<std::string>::iterator i = LinkOnceStubs.begin(),
Nate Begeman0ad7f812004-08-14 22:09:10 +0000571 e = LinkOnceStubs.end(); i != e; ++i) {
572 O << "L" << *i << "$non_lazy_ptr:\n"
573 << "\t.long\t" << *i << '\n';
574 }
Misha Brukmanb4402432005-04-21 23:30:14 +0000575
Chris Lattner7432ceef2005-11-01 00:12:36 +0000576 // Funny Darwin hack: This flag tells the linker that no global symbols
577 // contain code that falls through to other global symbols (e.g. the obvious
578 // implementation of multiple entry points). If this doesn't occur, the
579 // linker can safely perform dead code stripping. Since LLVM never generates
580 // code that does this, it is always safe to set.
581 O << "\t.subsections_via_symbols\n";
582
Chris Lattner0ced9052004-08-16 23:25:21 +0000583 AsmPrinter::doFinalization(M);
Misha Brukmane05203f2004-06-21 16:55:25 +0000584 return false; // success
585}
Nate Begeman4bfceb12004-09-04 05:00:00 +0000586
587/// runOnMachineFunction - This uses the printMachineInstruction()
588/// method to print assembly for each instruction.
589///
590bool AIXAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
591 CurrentFnName = MF.getFunction()->getName();
592
593 // Print out constants referenced by the function
594 printConstantPool(MF.getConstantPool());
595
596 // Print out header for the function.
597 O << "\t.csect .text[PR]\n"
598 << "\t.align 2\n"
599 << "\t.globl " << CurrentFnName << '\n'
600 << "\t.globl ." << CurrentFnName << '\n'
601 << "\t.csect " << CurrentFnName << "[DS],3\n"
602 << CurrentFnName << ":\n"
603 << "\t.llong ." << CurrentFnName << ", TOC[tc0], 0\n"
604 << "\t.csect .text[PR]\n"
605 << '.' << CurrentFnName << ":\n";
606
607 // Print out code for the function.
608 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
609 I != E; ++I) {
610 // Print a label for the basic block.
Chris Lattnerfafff9b2005-11-10 21:59:25 +0000611 O << "LBB" << CurrentFnName << '_' << I->getNumber() << ":\t# "
612 << I->getBasicBlock()->getName() << '\n';
Nate Begeman4bfceb12004-09-04 05:00:00 +0000613 for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
614 II != E; ++II) {
615 // Print the assembly for the instruction.
616 O << "\t";
617 printMachineInstruction(II);
618 }
619 }
Chris Lattnerfafff9b2005-11-10 21:59:25 +0000620 ++FunctionNumber;
Nate Begeman4bfceb12004-09-04 05:00:00 +0000621
622 O << "LT.." << CurrentFnName << ":\n"
623 << "\t.long 0\n"
624 << "\t.byte 0,0,32,65,128,0,0,0\n"
625 << "\t.long LT.." << CurrentFnName << "-." << CurrentFnName << '\n'
626 << "\t.short 3\n"
627 << "\t.byte \"" << CurrentFnName << "\"\n"
628 << "\t.align 2\n";
629
630 // We didn't modify anything.
631 return false;
632}
633
634/// printConstantPool - Print to the current output stream assembly
635/// representations of the constants in the constant pool MCP. This is
636/// used to print out constants which have been "spilled to memory" by
637/// the code generator.
638///
639void AIXAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
640 const std::vector<Constant*> &CP = MCP->getConstants();
641 const TargetData &TD = TM.getTargetData();
Misha Brukmanb4402432005-04-21 23:30:14 +0000642
Nate Begeman4bfceb12004-09-04 05:00:00 +0000643 if (CP.empty()) return;
644
645 for (unsigned i = 0, e = CP.size(); i != e; ++i) {
Chris Lattner63985e22005-11-15 01:45:01 +0000646 SwitchSection(".const", 0);
Nate Begeman4bfceb12004-09-04 05:00:00 +0000647 O << "\t.align " << (unsigned)TD.getTypeAlignment(CP[i]->getType())
648 << "\n";
Chris Lattner41cb1152005-11-21 06:47:58 +0000649 O << PrivateGlobalPrefix << "CPI" << FunctionNumber << '_' << i
650 << ":\t\t\t\t\t;" << *CP[i] << '\n';
Nate Begeman4bfceb12004-09-04 05:00:00 +0000651 emitGlobalConstant(CP[i]);
652 }
653}
654
655bool AIXAsmPrinter::doInitialization(Module &M) {
Chris Lattner0aacd2a2005-11-14 18:52:46 +0000656 SwitchSection("", 0);
Nate Begeman4bfceb12004-09-04 05:00:00 +0000657 const TargetData &TD = TM.getTargetData();
Nate Begeman4bfceb12004-09-04 05:00:00 +0000658
Misha Brukmanb4402432005-04-21 23:30:14 +0000659 O << "\t.machine \"ppc64\"\n"
Nate Begeman4bfceb12004-09-04 05:00:00 +0000660 << "\t.toc\n"
661 << "\t.csect .text[PR]\n";
662
663 // Print out module-level global variables
Chris Lattner06721f52005-07-26 19:03:27 +0000664 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
665 I != E; ++I) {
Nate Begeman4bfceb12004-09-04 05:00:00 +0000666 if (!I->hasInitializer())
667 continue;
Misha Brukmanb4402432005-04-21 23:30:14 +0000668
Nate Begeman4bfceb12004-09-04 05:00:00 +0000669 std::string Name = I->getName();
670 Constant *C = I->getInitializer();
671 // N.B.: We are defaulting to writable strings
Misha Brukmanb4402432005-04-21 23:30:14 +0000672 if (I->hasExternalLinkage()) {
Nate Begeman4bfceb12004-09-04 05:00:00 +0000673 O << "\t.globl " << Name << '\n'
674 << "\t.csect .data[RW],3\n";
675 } else {
676 O << "\t.csect _global.rw_c[RW],3\n";
677 }
678 O << Name << ":\n";
679 emitGlobalConstant(C);
680 }
681
682 // Output labels for globals
Chris Lattner531f9e92005-03-15 04:54:21 +0000683 if (M.global_begin() != M.global_end()) O << "\t.toc\n";
Chris Lattner06721f52005-07-26 19:03:27 +0000684 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
685 I != E; ++I) {
Nate Begeman4bfceb12004-09-04 05:00:00 +0000686 const GlobalVariable *GV = I;
687 // Do not output labels for unused variables
688 if (GV->isExternal() && GV->use_begin() == GV->use_end())
689 continue;
690
691 std::string Name = GV->getName();
Chris Lattnerfafff9b2005-11-10 21:59:25 +0000692 std::string Label = "LC.." + utostr(FunctionNumber++);
Nate Begeman4bfceb12004-09-04 05:00:00 +0000693 GVToLabelMap[GV] = Label;
694 O << Label << ":\n"
695 << "\t.tc " << Name << "[TC]," << Name;
696 if (GV->isExternal()) O << "[RW]";
697 O << '\n';
698 }
699
Chris Lattner59e44ff2005-11-10 18:20:29 +0000700 AsmPrinter::doInitialization(M);
Nate Begeman4bfceb12004-09-04 05:00:00 +0000701 return false; // success
702}
703
704bool AIXAsmPrinter::doFinalization(Module &M) {
705 const TargetData &TD = TM.getTargetData();
706 // Print out module-level global variables
Chris Lattner06721f52005-07-26 19:03:27 +0000707 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end();
708 I != E; ++I) {
Nate Begeman4bfceb12004-09-04 05:00:00 +0000709 if (I->hasInitializer() || I->hasExternalLinkage())
710 continue;
711
712 std::string Name = I->getName();
713 if (I->hasInternalLinkage()) {
714 O << "\t.lcomm " << Name << ",16,_global.bss_c";
715 } else {
716 O << "\t.comm " << Name << "," << TD.getTypeSize(I->getType())
Chris Lattner6667bdb2005-08-02 19:26:06 +0000717 << "," << Log2_32((unsigned)TD.getTypeAlignment(I->getType()));
Nate Begeman4bfceb12004-09-04 05:00:00 +0000718 }
719 O << "\t\t# ";
Chris Lattnerafef68b2005-10-03 07:08:36 +0000720 WriteAsOperand(O, I, false, true, &M);
Nate Begeman4bfceb12004-09-04 05:00:00 +0000721 O << "\n";
722 }
723
724 O << "_section_.text:\n"
725 << "\t.csect .data[RW],3\n"
726 << "\t.llong _section_.text\n";
Chris Lattner59e44ff2005-11-10 18:20:29 +0000727 AsmPrinter::doFinalization(M);
Nate Begeman4bfceb12004-09-04 05:00:00 +0000728 return false; // success
729}