1 //===-- PowerPCAsmPrinter.cpp - Print machine instrs to PowerPC assembly --===//
3 // The LLVM Compiler Infrastructure
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.
8 //===----------------------------------------------------------------------===//
10 // This file contains a printer that converts from our internal representation
11 // of machine-dependent LLVM code to PowerPC assembly language. This printer is
12 // the output mechanism used by `llc'.
14 // Documentation at http://developer.apple.com/documentation/DeveloperTools/
15 // Reference/Assembler/ASMIntroduction/chapter_1_section_1.html
17 //===----------------------------------------------------------------------===//
19 #define DEBUG_TYPE "asmprinter"
21 #include "PowerPCTargetMachine.h"
22 #include "llvm/Constants.h"
23 #include "llvm/DerivedTypes.h"
24 #include "llvm/Module.h"
25 #include "llvm/Assembly/Writer.h"
26 #include "llvm/CodeGen/AsmPrinter.h"
27 #include "llvm/CodeGen/MachineConstantPool.h"
28 #include "llvm/CodeGen/MachineFunctionPass.h"
29 #include "llvm/CodeGen/MachineInstr.h"
30 #include "llvm/CodeGen/ValueTypes.h"
31 #include "llvm/Support/Mangler.h"
32 #include "llvm/Support/MathExtras.h"
33 #include "llvm/Support/CommandLine.h"
34 #include "llvm/Support/Debug.h"
35 #include "llvm/Target/MRegisterInfo.h"
36 #include "llvm/Target/TargetInstrInfo.h"
37 #include "llvm/ADT/Statistic.h"
38 #include "llvm/ADT/StringExtras.h"
43 Statistic<> EmittedInsts("asm-printer", "Number of machine instrs printed");
45 struct PowerPCAsmPrinter : public AsmPrinter {
46 std::set<std::string> FnStubs, GVStubs, LinkOnceStubs;
48 PowerPCAsmPrinter(std::ostream &O, TargetMachine &TM)
49 : AsmPrinter(O, TM), LabelNumber(0) {}
51 /// Unique incrementer for label values for referencing Global values.
55 virtual const char *getPassName() const {
56 return "PowerPC Assembly Printer";
59 PowerPCTargetMachine &getTM() {
60 return static_cast<PowerPCTargetMachine&>(TM);
63 /// printInstruction - This method is automatically generated by tablegen
64 /// from the instruction set description. This method returns true if the
65 /// machine instruction was sufficiently described to print it, otherwise it
67 bool printInstruction(const MachineInstr *MI);
69 void printMachineInstruction(const MachineInstr *MI);
70 void printOp(const MachineOperand &MO, bool IsCallOp = false);
72 void printOperand(const MachineInstr *MI, unsigned OpNo, MVT::ValueType VT){
73 const MachineOperand &MO = MI->getOperand(OpNo);
74 if (MO.getType() == MachineOperand::MO_MachineRegister) {
75 assert(MRegisterInfo::isPhysicalRegister(MO.getReg())&&"Not physreg??");
76 O << LowercaseString(TM.getRegisterInfo()->get(MO.getReg()).Name);
77 } else if (MO.isImmediate()) {
78 O << MO.getImmedValue();
84 void printU5ImmOperand(const MachineInstr *MI, unsigned OpNo,
86 unsigned char value = MI->getOperand(OpNo).getImmedValue();
87 assert(value <= 31 && "Invalid u5imm argument!");
88 O << (unsigned int)value;
90 void printU6ImmOperand(const MachineInstr *MI, unsigned OpNo,
92 unsigned char value = MI->getOperand(OpNo).getImmedValue();
93 assert(value <= 63 && "Invalid u6imm argument!");
94 O << (unsigned int)value;
96 void printS16ImmOperand(const MachineInstr *MI, unsigned OpNo,
98 O << (short)MI->getOperand(OpNo).getImmedValue();
100 void printU16ImmOperand(const MachineInstr *MI, unsigned OpNo,
102 O << (unsigned short)MI->getOperand(OpNo).getImmedValue();
104 void printBranchOperand(const MachineInstr *MI, unsigned OpNo,
106 // Branches can take an immediate operand. This is used by the branch
107 // selection pass to print $+8, an eight byte displacement from the PC.
108 if (MI->getOperand(OpNo).isImmediate()) {
109 O << "$+" << MI->getOperand(OpNo).getImmedValue();
111 printOp(MI->getOperand(OpNo),
112 TM.getInstrInfo()->isCall(MI->getOpcode()));
115 void printPICLabel(const MachineInstr *MI, unsigned OpNo,
117 // FIXME: should probably be converted to cout.width and cout.fill
118 O << "\"L0000" << LabelNumber << "$pb\"\n";
119 O << "\"L0000" << LabelNumber << "$pb\":";
121 void printSymbolHi(const MachineInstr *MI, unsigned OpNo,
124 printOp(MI->getOperand(OpNo));
125 O << "-\"L0000" << LabelNumber << "$pb\")";
127 void printSymbolLo(const MachineInstr *MI, unsigned OpNo,
129 // FIXME: Because LFS, LFD, and LWZ can be used either with a s16imm or
130 // a lo16 of a global or constant pool operand, we must handle both here.
131 // this isn't a great design, but it works for now.
132 if (MI->getOperand(OpNo).isImmediate()) {
133 O << (short)MI->getOperand(OpNo).getImmedValue();
136 printOp(MI->getOperand(OpNo));
137 O << "-\"L0000" << LabelNumber << "$pb\")";
140 void printcrbit(const MachineInstr *MI, unsigned OpNo,
142 unsigned char value = MI->getOperand(OpNo).getImmedValue();
143 assert(value <= 3 && "Invalid crbit argument!");
144 unsigned RegNo, CCReg = MI->getOperand(OpNo-1).getReg();
146 case PPC::CR0: RegNo = 0; break;
147 case PPC::CR1: RegNo = 1; break;
148 case PPC::CR2: RegNo = 2; break;
149 case PPC::CR3: RegNo = 3; break;
150 case PPC::CR4: RegNo = 4; break;
151 case PPC::CR5: RegNo = 5; break;
152 case PPC::CR6: RegNo = 6; break;
153 case PPC::CR7: RegNo = 7; break;
155 std::cerr << "Unhandled reg in enumRegToRealReg!\n";
158 O << 4 * RegNo + value;
161 virtual void printConstantPool(MachineConstantPool *MCP) = 0;
162 virtual bool runOnMachineFunction(MachineFunction &F) = 0;
163 virtual bool doFinalization(Module &M) = 0;
166 /// DarwinAsmPrinter - PowerPC assembly printer, customized for Darwin/Mac OS
169 struct DarwinAsmPrinter : public PowerPCAsmPrinter {
171 DarwinAsmPrinter(std::ostream &O, TargetMachine &TM)
172 : PowerPCAsmPrinter(O, TM) {
175 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
176 Data64bitsDirective = 0; // we can't emit a 64-bit unit
177 AlignmentIsInBytes = false; // Alignment is by power of 2.
180 virtual const char *getPassName() const {
181 return "Darwin PPC Assembly Printer";
184 void printConstantPool(MachineConstantPool *MCP);
185 bool runOnMachineFunction(MachineFunction &F);
186 bool doFinalization(Module &M);
189 /// AIXAsmPrinter - PowerPC assembly printer, customized for AIX
191 struct AIXAsmPrinter : public PowerPCAsmPrinter {
192 /// Map for labels corresponding to global variables
194 std::map<const GlobalVariable*,std::string> GVToLabelMap;
196 AIXAsmPrinter(std::ostream &O, TargetMachine &TM)
197 : PowerPCAsmPrinter(O, TM) {
200 ZeroDirective = "\t.space\t"; // ".space N" emits N zeros.
201 Data64bitsDirective = 0; // we can't emit a 64-bit unit
202 AlignmentIsInBytes = false; // Alignment is by power of 2.
205 virtual const char *getPassName() const {
206 return "AIX PPC Assembly Printer";
209 void printConstantPool(MachineConstantPool *MCP);
210 bool runOnMachineFunction(MachineFunction &F);
211 bool doInitialization(Module &M);
212 bool doFinalization(Module &M);
214 } // end of anonymous namespace
216 // SwitchSection - Switch to the specified section of the executable if we are
217 // not already in it!
219 static void SwitchSection(std::ostream &OS, std::string &CurSection,
220 const char *NewSection) {
221 if (CurSection != NewSection) {
222 CurSection = NewSection;
223 if (!CurSection.empty())
224 OS << "\t" << NewSection << "\n";
228 /// isStringCompatible - Can we treat the specified array as a string?
229 /// Only if it is an array of ubytes or non-negative sbytes.
231 static bool isStringCompatible(const ConstantArray *CVA) {
232 const Type *ETy = cast<ArrayType>(CVA->getType())->getElementType();
233 if (ETy == Type::UByteTy) return true;
234 if (ETy != Type::SByteTy) return false;
236 for (unsigned i = 0; i < CVA->getNumOperands(); ++i)
237 if (cast<ConstantSInt>(CVA->getOperand(i))->getValue() < 0)
243 /// toOctal - Convert the low order bits of X into an octal digit.
245 static inline char toOctal(int X) {
249 // Possible states while outputting ASCII strings
258 /// SwitchStringSection - manage the changes required to output bytes as
259 /// characters in a string vs. numeric decimal values
261 static inline void SwitchStringSection(std::ostream &O, StringSection NewSect,
262 StringSection &Current) {
263 if (Current == None) {
264 if (NewSect == Alpha)
266 else if (NewSect == Numeric)
268 } else if (Current == Alpha) {
271 else if (NewSect == Numeric)
274 } else if (Current == Numeric) {
275 if (NewSect == Alpha)
278 else if (NewSect == Numeric)
285 /// getAsCString - Return the specified array as a C compatible
286 /// string, only if the predicate isStringCompatible is true.
288 static void printAsCString(std::ostream &O, const ConstantArray *CVA) {
289 assert(isStringCompatible(CVA) && "Array is not string compatible!");
291 if (CVA->getNumOperands() == 0)
294 StringSection Current = None;
295 for (unsigned i = 0, e = CVA->getNumOperands(); i != e; ++i) {
296 unsigned char C = cast<ConstantInt>(CVA->getOperand(i))->getRawValue();
298 SwitchStringSection(O, Alpha, Current);
300 } else if (isprint(C)) {
301 SwitchStringSection(O, Alpha, Current);
304 SwitchStringSection(O, Numeric, Current);
305 O << utostr((unsigned)C);
308 SwitchStringSection(O, None, Current);
312 /// createDarwinAsmPrinterPass - Returns a pass that prints the PPC assembly
313 /// code for a MachineFunction to the given output stream, in a format that the
314 /// Darwin assembler can deal with.
316 FunctionPass *llvm::createDarwinAsmPrinter(std::ostream &o, TargetMachine &tm) {
317 return new DarwinAsmPrinter(o, tm);
320 /// createAIXAsmPrinterPass - Returns a pass that prints the PPC assembly code
321 /// for a MachineFunction to the given output stream, in a format that the
322 /// AIX 5L assembler can deal with.
324 FunctionPass *llvm::createAIXAsmPrinter(std::ostream &o, TargetMachine &tm) {
325 return new AIXAsmPrinter(o, tm);
328 // Include the auto-generated portion of the assembly writer
329 #include "PowerPCGenAsmWriter.inc"
331 void PowerPCAsmPrinter::printOp(const MachineOperand &MO, bool IsCallOp) {
332 const MRegisterInfo &RI = *TM.getRegisterInfo();
335 switch (MO.getType()) {
336 case MachineOperand::MO_VirtualRegister:
337 if (Value *V = MO.getVRegValueOrNull()) {
338 O << "<" << V->getName() << ">";
342 case MachineOperand::MO_MachineRegister:
343 case MachineOperand::MO_CCRegister:
344 O << LowercaseString(RI.get(MO.getReg()).Name);
347 case MachineOperand::MO_SignExtendedImmed:
348 case MachineOperand::MO_UnextendedImmed:
349 std::cerr << "printOp() does not handle immediate values\n";
353 case MachineOperand::MO_PCRelativeDisp:
354 std::cerr << "Shouldn't use addPCDisp() when building PPC MachineInstrs";
358 case MachineOperand::MO_MachineBasicBlock: {
359 MachineBasicBlock *MBBOp = MO.getMachineBasicBlock();
360 O << ".LBB" << Mang->getValueName(MBBOp->getParent()->getFunction())
361 << "_" << MBBOp->getNumber() << "\t; "
362 << MBBOp->getBasicBlock()->getName();
366 case MachineOperand::MO_ConstantPoolIndex:
367 O << ".CPI" << CurrentFnName << "_" << MO.getConstantPoolIndex();
370 case MachineOperand::MO_ExternalSymbol:
372 std::string Name(GlobalPrefix); Name += MO.getSymbolName();
373 FnStubs.insert(Name);
374 O << "L" << Name << "$stub";
377 O << GlobalPrefix << MO.getSymbolName();
380 case MachineOperand::MO_GlobalAddress: {
381 GlobalValue *GV = MO.getGlobal();
382 std::string Name = Mang->getValueName(GV);
384 // Dynamically-resolved functions need a stub for the function. Be
385 // wary however not to output $stub for external functions whose addresses
386 // are taken. Those should be emitted as $non_lazy_ptr below.
387 Function *F = dyn_cast<Function>(GV);
388 if (F && IsCallOp && F->isExternal()) {
389 FnStubs.insert(Name);
390 O << "L" << Name << "$stub";
394 // External or weakly linked global variables need non-lazily-resolved stubs
395 if ((GV->isExternal() || GV->hasWeakLinkage() || GV->hasLinkOnceLinkage())){
396 if (GV->hasLinkOnceLinkage())
397 LinkOnceStubs.insert(Name);
399 GVStubs.insert(Name);
400 O << "L" << Name << "$non_lazy_ptr";
404 O << Mang->getValueName(GV);
409 O << "<unknown operand type: " << MO.getType() << ">";
414 /// printMachineInstruction -- Print out a single PowerPC MI in Darwin syntax to
415 /// the current output stream.
417 void PowerPCAsmPrinter::printMachineInstruction(const MachineInstr *MI) {
419 // Check for slwi/srwi mnemonics.
420 if (MI->getOpcode() == PPC::RLWINM) {
421 bool FoundMnemonic = false;
422 unsigned char SH = MI->getOperand(2).getImmedValue();
423 unsigned char MB = MI->getOperand(3).getImmedValue();
424 unsigned char ME = MI->getOperand(4).getImmedValue();
425 if (SH <= 31 && MB == 0 && ME == (31-SH)) {
426 O << "slwi "; FoundMnemonic = true;
428 if (SH <= 31 && MB == (32-SH) && ME == 31) {
429 O << "srwi "; FoundMnemonic = true;
433 printOperand(MI, 0, MVT::i64);
435 printOperand(MI, 1, MVT::i64);
436 O << ", " << (unsigned int)SH << "\n";
441 if (printInstruction(MI))
442 return; // Printer was automatically generated
444 assert(0 && "Unhandled instruction in asm writer!");
449 /// runOnMachineFunction - This uses the printMachineInstruction()
450 /// method to print assembly for each instruction.
452 bool DarwinAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
453 setupMachineFunction(MF);
456 // Print out constants referenced by the function
457 printConstantPool(MF.getConstantPool());
459 // Print out labels for the function.
462 O << "\t.globl\t" << CurrentFnName << "\n";
463 O << CurrentFnName << ":\n";
465 // Print out code for the function.
466 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
468 // Print a label for the basic block.
469 O << ".LBB" << CurrentFnName << "_" << I->getNumber() << ":\t"
470 << CommentString << " " << I->getBasicBlock()->getName() << "\n";
471 for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
473 // Print the assembly for the instruction.
475 printMachineInstruction(II);
480 // We didn't modify anything.
484 /// printConstantPool - Print to the current output stream assembly
485 /// representations of the constants in the constant pool MCP. This is
486 /// used to print out constants which have been "spilled to memory" by
487 /// the code generator.
489 void DarwinAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
490 const std::vector<Constant*> &CP = MCP->getConstants();
491 const TargetData &TD = TM.getTargetData();
493 if (CP.empty()) return;
495 for (unsigned i = 0, e = CP.size(); i != e; ++i) {
497 emitAlignment(TD.getTypeAlignmentShift(CP[i]->getType()));
498 O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t" << CommentString
500 emitGlobalConstant(CP[i]);
504 bool DarwinAsmPrinter::doFinalization(Module &M) {
505 const TargetData &TD = TM.getTargetData();
506 std::string CurSection;
508 // Print out module-level global variables here.
509 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I)
510 if (I->hasInitializer()) { // External global require no code
512 std::string name = Mang->getValueName(I);
513 Constant *C = I->getInitializer();
514 unsigned Size = TD.getTypeSize(C->getType());
515 unsigned Align = TD.getTypeAlignmentShift(C->getType());
517 if (C->isNullValue() && /* FIXME: Verify correct */
518 (I->hasInternalLinkage() || I->hasWeakLinkage() ||
519 I->hasLinkOnceLinkage())) {
520 SwitchSection(O, CurSection, ".data");
521 if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
522 if (I->hasInternalLinkage())
523 O << ".lcomm " << name << "," << Size << "," << Align;
525 O << ".comm " << name << "," << Size;
527 WriteAsOperand(O, I, true, true, &M);
530 switch (I->getLinkage()) {
531 case GlobalValue::LinkOnceLinkage:
532 O << ".section __TEXT,__textcoal_nt,coalesced,no_toc\n"
533 << ".weak_definition " << name << '\n'
534 << ".private_extern " << name << '\n'
535 << ".section __DATA,__datacoal_nt,coalesced,no_toc\n";
536 LinkOnceStubs.insert(name);
538 case GlobalValue::WeakLinkage: // FIXME: Verify correct for weak.
539 // Nonnull linkonce -> weak
540 O << "\t.weak " << name << "\n";
541 SwitchSection(O, CurSection, "");
542 O << "\t.section\t.llvm.linkonce.d." << name << ",\"aw\",@progbits\n";
544 case GlobalValue::AppendingLinkage:
545 // FIXME: appending linkage variables should go into a section of
546 // their name or something. For now, just emit them as external.
547 case GlobalValue::ExternalLinkage:
548 // If external or appending, declare as a global symbol
549 O << "\t.globl " << name << "\n";
551 case GlobalValue::InternalLinkage:
552 SwitchSection(O, CurSection, ".data");
554 case GlobalValue::GhostLinkage:
555 std::cerr << "Error: unmaterialized (GhostLinkage) function in asm!";
559 emitAlignment(Align);
560 O << name << ":\t\t\t\t; ";
561 WriteAsOperand(O, I, true, true, &M);
563 WriteAsOperand(O, C, false, false, &M);
565 emitGlobalConstant(C);
569 // Output stubs for dynamically-linked functions
570 for (std::set<std::string>::iterator i = FnStubs.begin(), e = FnStubs.end();
574 O << ".section __TEXT,__picsymbolstub1,symbol_stubs,pure_instructions,32\n";
576 O << "L" << *i << "$stub:\n";
577 O << "\t.indirect_symbol " << *i << "\n";
579 O << "\tbcl 20,31,L0$" << *i << "\n";
580 O << "L0$" << *i << ":\n";
582 O << "\taddis r11,r11,ha16(L" << *i << "$lazy_ptr-L0$" << *i << ")\n";
584 O << "\tlwzu r12,lo16(L" << *i << "$lazy_ptr-L0$" << *i << ")(r11)\n";
585 O << "\tmtctr r12\n";
588 O << ".lazy_symbol_pointer\n";
589 O << "L" << *i << "$lazy_ptr:\n";
590 O << "\t.indirect_symbol " << *i << "\n";
591 O << "\t.long dyld_stub_binding_helper\n";
596 // Output stubs for external global variables
597 if (GVStubs.begin() != GVStubs.end())
598 O << ".data\n.non_lazy_symbol_pointer\n";
599 for (std::set<std::string>::iterator i = GVStubs.begin(), e = GVStubs.end();
601 O << "L" << *i << "$non_lazy_ptr:\n";
602 O << "\t.indirect_symbol " << *i << "\n";
606 // Output stubs for link-once variables
607 if (LinkOnceStubs.begin() != LinkOnceStubs.end())
608 O << ".data\n.align 2\n";
609 for (std::set<std::string>::iterator i = LinkOnceStubs.begin(),
610 e = LinkOnceStubs.end(); i != e; ++i) {
611 O << "L" << *i << "$non_lazy_ptr:\n"
612 << "\t.long\t" << *i << '\n';
615 AsmPrinter::doFinalization(M);
616 return false; // success
619 /// runOnMachineFunction - This uses the printMachineInstruction()
620 /// method to print assembly for each instruction.
622 bool AIXAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
623 CurrentFnName = MF.getFunction()->getName();
625 // Print out constants referenced by the function
626 printConstantPool(MF.getConstantPool());
628 // Print out header for the function.
629 O << "\t.csect .text[PR]\n"
631 << "\t.globl " << CurrentFnName << '\n'
632 << "\t.globl ." << CurrentFnName << '\n'
633 << "\t.csect " << CurrentFnName << "[DS],3\n"
634 << CurrentFnName << ":\n"
635 << "\t.llong ." << CurrentFnName << ", TOC[tc0], 0\n"
636 << "\t.csect .text[PR]\n"
637 << '.' << CurrentFnName << ":\n";
639 // Print out code for the function.
640 for (MachineFunction::const_iterator I = MF.begin(), E = MF.end();
642 // Print a label for the basic block.
643 O << "LBB" << CurrentFnName << "_" << I->getNumber() << ":\t# "
644 << I->getBasicBlock()->getName() << "\n";
645 for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end();
647 // Print the assembly for the instruction.
649 printMachineInstruction(II);
654 O << "LT.." << CurrentFnName << ":\n"
656 << "\t.byte 0,0,32,65,128,0,0,0\n"
657 << "\t.long LT.." << CurrentFnName << "-." << CurrentFnName << '\n'
659 << "\t.byte \"" << CurrentFnName << "\"\n"
662 // We didn't modify anything.
666 /// printConstantPool - Print to the current output stream assembly
667 /// representations of the constants in the constant pool MCP. This is
668 /// used to print out constants which have been "spilled to memory" by
669 /// the code generator.
671 void AIXAsmPrinter::printConstantPool(MachineConstantPool *MCP) {
672 const std::vector<Constant*> &CP = MCP->getConstants();
673 const TargetData &TD = TM.getTargetData();
675 if (CP.empty()) return;
677 for (unsigned i = 0, e = CP.size(); i != e; ++i) {
679 O << "\t.align " << (unsigned)TD.getTypeAlignment(CP[i]->getType())
681 O << ".CPI" << CurrentFnName << "_" << i << ":\t\t\t\t\t;"
683 emitGlobalConstant(CP[i]);
687 bool AIXAsmPrinter::doInitialization(Module &M) {
688 const TargetData &TD = TM.getTargetData();
689 std::string CurSection;
691 O << "\t.machine \"ppc64\"\n"
693 << "\t.csect .text[PR]\n";
695 // Print out module-level global variables
696 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) {
697 if (!I->hasInitializer())
700 std::string Name = I->getName();
701 Constant *C = I->getInitializer();
702 // N.B.: We are defaulting to writable strings
703 if (I->hasExternalLinkage()) {
704 O << "\t.globl " << Name << '\n'
705 << "\t.csect .data[RW],3\n";
707 O << "\t.csect _global.rw_c[RW],3\n";
710 emitGlobalConstant(C);
713 // Output labels for globals
714 if (M.global_begin() != M.global_end()) O << "\t.toc\n";
715 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) {
716 const GlobalVariable *GV = I;
717 // Do not output labels for unused variables
718 if (GV->isExternal() && GV->use_begin() == GV->use_end())
721 std::string Name = GV->getName();
722 std::string Label = "LC.." + utostr(LabelNumber++);
723 GVToLabelMap[GV] = Label;
725 << "\t.tc " << Name << "[TC]," << Name;
726 if (GV->isExternal()) O << "[RW]";
730 Mang = new Mangler(M, ".");
731 return false; // success
734 bool AIXAsmPrinter::doFinalization(Module &M) {
735 const TargetData &TD = TM.getTargetData();
736 // Print out module-level global variables
737 for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); I != E; ++I) {
738 if (I->hasInitializer() || I->hasExternalLinkage())
741 std::string Name = I->getName();
742 if (I->hasInternalLinkage()) {
743 O << "\t.lcomm " << Name << ",16,_global.bss_c";
745 O << "\t.comm " << Name << "," << TD.getTypeSize(I->getType())
746 << "," << log2((unsigned)TD.getTypeAlignment(I->getType()));
749 WriteAsOperand(O, I, true, true, &M);
753 O << "_section_.text:\n"
754 << "\t.csect .data[RW],3\n"
755 << "\t.llong _section_.text\n";
758 return false; // success