Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | //===-- IA64AsmPrinter.cpp - Print out IA64 LLVM as assembly --------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 081ce94 | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file contains a printer that converts from our internal representation |
| 11 | // of machine-dependent LLVM code to assembly accepted by the GNU binutils 'gas' |
| 12 | // assembler. The Intel 'ias' and HP-UX 'as' assemblers *may* choke on this |
| 13 | // output, but if so that's a bug I'd like to hear about: please file a bug |
| 14 | // report in bugzilla. FYI, the not too bad 'ias' assembler is bundled with |
| 15 | // the Intel C/C++ compiler for Itanium Linux. |
| 16 | // |
| 17 | //===----------------------------------------------------------------------===// |
| 18 | |
| 19 | #define DEBUG_TYPE "asm-printer" |
| 20 | #include "IA64.h" |
| 21 | #include "IA64TargetMachine.h" |
| 22 | #include "llvm/Module.h" |
| 23 | #include "llvm/Type.h" |
| 24 | #include "llvm/CodeGen/AsmPrinter.h" |
| 25 | #include "llvm/CodeGen/MachineFunctionPass.h" |
| 26 | #include "llvm/Target/TargetAsmInfo.h" |
| 27 | #include "llvm/Target/TargetMachine.h" |
| 28 | #include "llvm/Support/Mangler.h" |
Owen Anderson | 847b99b | 2008-08-21 00:14:44 +0000 | [diff] [blame] | 29 | #include "llvm/Support/raw_ostream.h" |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 30 | #include "llvm/ADT/Statistic.h" |
| 31 | using namespace llvm; |
| 32 | |
| 33 | STATISTIC(EmittedInsts, "Number of machine instrs printed"); |
| 34 | |
| 35 | namespace { |
| 36 | struct IA64AsmPrinter : public AsmPrinter { |
| 37 | std::set<std::string> ExternalFunctionNames, ExternalObjectNames; |
| 38 | |
Owen Anderson | 847b99b | 2008-08-21 00:14:44 +0000 | [diff] [blame] | 39 | IA64AsmPrinter(raw_ostream &O, TargetMachine &TM, const TargetAsmInfo *T) |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 40 | : AsmPrinter(O, TM, T) { |
| 41 | } |
| 42 | |
| 43 | virtual const char *getPassName() const { |
| 44 | return "IA64 Assembly Printer"; |
| 45 | } |
| 46 | |
| 47 | /// printInstruction - This method is automatically generated by tablegen |
| 48 | /// from the instruction set description. This method returns true if the |
| 49 | /// machine instruction was sufficiently described to print it, otherwise it |
| 50 | /// returns false. |
| 51 | bool printInstruction(const MachineInstr *MI); |
| 52 | |
| 53 | // This method is used by the tablegen'erated instruction printer. |
| 54 | void printOperand(const MachineInstr *MI, unsigned OpNo){ |
| 55 | const MachineOperand &MO = MI->getOperand(OpNo); |
| 56 | if (MO.getType() == MachineOperand::MO_Register) { |
Dan Gohman | 1e57df3 | 2008-02-10 18:45:23 +0000 | [diff] [blame] | 57 | assert(TargetRegisterInfo::isPhysicalRegister(MO.getReg()) && |
| 58 | "Not physref??"); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 59 | //XXX Bug Workaround: See note in Printer::doInitialization about %. |
Bill Wendling | 8eeb979 | 2008-02-26 21:11:01 +0000 | [diff] [blame] | 60 | O << TM.getRegisterInfo()->get(MO.getReg()).AsmName; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 61 | } else { |
| 62 | printOp(MO); |
| 63 | } |
| 64 | } |
| 65 | |
| 66 | void printS8ImmOperand(const MachineInstr *MI, unsigned OpNo) { |
Chris Lattner | a96056a | 2007-12-30 20:49:49 +0000 | [diff] [blame] | 67 | int val=(unsigned int)MI->getOperand(OpNo).getImm(); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 68 | if(val>=128) val=val-256; // if negative, flip sign |
| 69 | O << val; |
| 70 | } |
| 71 | void printS14ImmOperand(const MachineInstr *MI, unsigned OpNo) { |
Chris Lattner | a96056a | 2007-12-30 20:49:49 +0000 | [diff] [blame] | 72 | int val=(unsigned int)MI->getOperand(OpNo).getImm(); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 73 | if(val>=8192) val=val-16384; // if negative, flip sign |
| 74 | O << val; |
| 75 | } |
| 76 | void printS22ImmOperand(const MachineInstr *MI, unsigned OpNo) { |
Chris Lattner | a96056a | 2007-12-30 20:49:49 +0000 | [diff] [blame] | 77 | int val=(unsigned int)MI->getOperand(OpNo).getImm(); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 78 | if(val>=2097152) val=val-4194304; // if negative, flip sign |
| 79 | O << val; |
| 80 | } |
| 81 | void printU64ImmOperand(const MachineInstr *MI, unsigned OpNo) { |
Chris Lattner | a96056a | 2007-12-30 20:49:49 +0000 | [diff] [blame] | 82 | O << (uint64_t)MI->getOperand(OpNo).getImm(); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 83 | } |
| 84 | void printS64ImmOperand(const MachineInstr *MI, unsigned OpNo) { |
| 85 | // XXX : nasty hack to avoid GPREL22 "relocation truncated to fit" linker |
| 86 | // errors - instead of add rX = @gprel(CPI<whatever>), r1;; we now |
| 87 | // emit movl rX = @gprel(CPI<whatever);; |
Anton Korobeynikov | c7fcf35 | 2008-08-07 09:52:13 +0000 | [diff] [blame] | 88 | // add rX = rX, r1; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 89 | // this gives us 64 bits instead of 22 (for the add long imm) to play |
| 90 | // with, which shuts up the linker. The problem is that the constant |
Anton Korobeynikov | c7fcf35 | 2008-08-07 09:52:13 +0000 | [diff] [blame] | 91 | // pool entries aren't immediates at this stage, so we check here. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 92 | // If it's an immediate, print it the old fashioned way. If it's |
Anton Korobeynikov | c7fcf35 | 2008-08-07 09:52:13 +0000 | [diff] [blame] | 93 | // not, we print it as a constant pool index. |
Dan Gohman | b9f4fa7 | 2008-10-03 15:45:36 +0000 | [diff] [blame] | 94 | if (MI->getOperand(OpNo).isImm()) { |
Chris Lattner | a96056a | 2007-12-30 20:49:49 +0000 | [diff] [blame] | 95 | O << (int64_t)MI->getOperand(OpNo).getImm(); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 96 | } else { // this is a constant pool reference: FIXME: assert this |
| 97 | printOp(MI->getOperand(OpNo)); |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | void printGlobalOperand(const MachineInstr *MI, unsigned OpNo) { |
| 102 | printOp(MI->getOperand(OpNo), false); // this is NOT a br.call instruction |
| 103 | } |
| 104 | |
| 105 | void printCallOperand(const MachineInstr *MI, unsigned OpNo) { |
| 106 | printOp(MI->getOperand(OpNo), true); // this is a br.call instruction |
| 107 | } |
| 108 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 109 | void printMachineInstruction(const MachineInstr *MI); |
| 110 | void printOp(const MachineOperand &MO, bool isBRCALLinsn= false); |
Anton Korobeynikov | 9c53fec | 2008-08-07 09:52:35 +0000 | [diff] [blame] | 111 | void printModuleLevelGV(const GlobalVariable* GVar); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 112 | bool runOnMachineFunction(MachineFunction &F); |
| 113 | bool doInitialization(Module &M); |
| 114 | bool doFinalization(Module &M); |
| 115 | }; |
| 116 | } // end of anonymous namespace |
| 117 | |
| 118 | |
| 119 | // Include the auto-generated portion of the assembly writer. |
| 120 | #include "IA64GenAsmWriter.inc" |
| 121 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 122 | /// runOnMachineFunction - This uses the printMachineInstruction() |
| 123 | /// method to print assembly for each instruction. |
| 124 | /// |
| 125 | bool IA64AsmPrinter::runOnMachineFunction(MachineFunction &MF) { |
| 126 | SetupMachineFunction(MF); |
| 127 | O << "\n\n"; |
| 128 | |
| 129 | // Print out constants referenced by the function |
| 130 | EmitConstantPool(MF.getConstantPool()); |
| 131 | |
| 132 | const Function *F = MF.getFunction(); |
Anton Korobeynikov | 1a9edae | 2008-09-24 22:14:23 +0000 | [diff] [blame] | 133 | SwitchToSection(TAI->SectionForGlobal(F)); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 134 | |
| 135 | // Print out labels for the function. |
| 136 | EmitAlignment(5); |
Anton Korobeynikov | 19eeb15 | 2008-08-07 09:52:54 +0000 | [diff] [blame] | 137 | O << "\t.global\t" << CurrentFnName << '\n'; |
Anton Korobeynikov | 78d69aa | 2008-08-08 18:25:07 +0000 | [diff] [blame] | 138 | |
| 139 | printVisibility(CurrentFnName, F->getVisibility()); |
| 140 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 141 | O << "\t.type\t" << CurrentFnName << ", @function\n"; |
| 142 | O << CurrentFnName << ":\n"; |
| 143 | |
| 144 | // Print out code for the function. |
| 145 | for (MachineFunction::const_iterator I = MF.begin(), E = MF.end(); |
| 146 | I != E; ++I) { |
| 147 | // Print a label for the basic block if there are any predecessors. |
Dan Gohman | 3f7d94b | 2007-10-03 19:26:29 +0000 | [diff] [blame] | 148 | if (!I->pred_empty()) { |
Evan Cheng | 45c1edb | 2008-02-28 00:43:03 +0000 | [diff] [blame] | 149 | printBasicBlockLabel(I, true, true); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 150 | O << '\n'; |
| 151 | } |
| 152 | for (MachineBasicBlock::const_iterator II = I->begin(), E = I->end(); |
| 153 | II != E; ++II) { |
| 154 | // Print the assembly for the instruction. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 155 | printMachineInstruction(II); |
| 156 | } |
| 157 | } |
| 158 | |
| 159 | // We didn't modify anything. |
| 160 | return false; |
| 161 | } |
| 162 | |
| 163 | void IA64AsmPrinter::printOp(const MachineOperand &MO, |
| 164 | bool isBRCALLinsn /* = false */) { |
Dan Gohman | 1e57df3 | 2008-02-10 18:45:23 +0000 | [diff] [blame] | 165 | const TargetRegisterInfo &RI = *TM.getRegisterInfo(); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 166 | switch (MO.getType()) { |
| 167 | case MachineOperand::MO_Register: |
Bill Wendling | 8eeb979 | 2008-02-26 21:11:01 +0000 | [diff] [blame] | 168 | O << RI.get(MO.getReg()).AsmName; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 169 | return; |
| 170 | |
| 171 | case MachineOperand::MO_Immediate: |
Chris Lattner | a96056a | 2007-12-30 20:49:49 +0000 | [diff] [blame] | 172 | O << MO.getImm(); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 173 | return; |
| 174 | case MachineOperand::MO_MachineBasicBlock: |
Chris Lattner | 6017d48 | 2007-12-30 23:10:15 +0000 | [diff] [blame] | 175 | printBasicBlockLabel(MO.getMBB()); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 176 | return; |
| 177 | case MachineOperand::MO_ConstantPoolIndex: { |
| 178 | O << "@gprel(" << TAI->getPrivateGlobalPrefix() |
Chris Lattner | 6017d48 | 2007-12-30 23:10:15 +0000 | [diff] [blame] | 179 | << "CPI" << getFunctionNumber() << "_" << MO.getIndex() << ")"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 180 | return; |
| 181 | } |
| 182 | |
| 183 | case MachineOperand::MO_GlobalAddress: { |
| 184 | |
| 185 | // functions need @ltoff(@fptr(fn_name)) form |
| 186 | GlobalValue *GV = MO.getGlobal(); |
| 187 | Function *F = dyn_cast<Function>(GV); |
| 188 | |
| 189 | bool Needfptr=false; // if we're computing an address @ltoff(X), do |
| 190 | // we need to decorate it so it becomes |
| 191 | // @ltoff(@fptr(X)) ? |
| 192 | if (F && !isBRCALLinsn /*&& F->isDeclaration()*/) |
| 193 | Needfptr=true; |
| 194 | |
| 195 | // if this is the target of a call instruction, we should define |
| 196 | // the function somewhere (GNU gas has no problem without this, but |
| 197 | // Intel ias rightly complains of an 'undefined symbol') |
| 198 | |
| 199 | if (F /*&& isBRCALLinsn*/ && F->isDeclaration()) |
| 200 | ExternalFunctionNames.insert(Mang->getValueName(MO.getGlobal())); |
| 201 | else |
| 202 | if (GV->isDeclaration()) // e.g. stuff like 'stdin' |
| 203 | ExternalObjectNames.insert(Mang->getValueName(MO.getGlobal())); |
| 204 | |
| 205 | if (!isBRCALLinsn) |
| 206 | O << "@ltoff("; |
| 207 | if (Needfptr) |
| 208 | O << "@fptr("; |
| 209 | O << Mang->getValueName(MO.getGlobal()); |
Anton Korobeynikov | c7fcf35 | 2008-08-07 09:52:13 +0000 | [diff] [blame] | 210 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 211 | if (Needfptr && !isBRCALLinsn) |
| 212 | O << "#))"; // close both fptr( and ltoff( |
| 213 | else { |
| 214 | if (Needfptr) |
| 215 | O << "#)"; // close only fptr( |
| 216 | if (!isBRCALLinsn) |
| 217 | O << "#)"; // close only ltoff( |
| 218 | } |
Anton Korobeynikov | c7fcf35 | 2008-08-07 09:52:13 +0000 | [diff] [blame] | 219 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 220 | int Offset = MO.getOffset(); |
| 221 | if (Offset > 0) |
| 222 | O << " + " << Offset; |
| 223 | else if (Offset < 0) |
| 224 | O << " - " << -Offset; |
| 225 | return; |
| 226 | } |
| 227 | case MachineOperand::MO_ExternalSymbol: |
| 228 | O << MO.getSymbolName(); |
| 229 | ExternalFunctionNames.insert(MO.getSymbolName()); |
| 230 | return; |
| 231 | default: |
| 232 | O << "<AsmPrinter: unknown operand type: " << MO.getType() << " >"; return; |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | /// printMachineInstruction -- Print out a single IA64 LLVM instruction |
| 237 | /// MI to the current output stream. |
| 238 | /// |
| 239 | void IA64AsmPrinter::printMachineInstruction(const MachineInstr *MI) { |
| 240 | ++EmittedInsts; |
| 241 | |
| 242 | // Call the autogenerated instruction printer routines. |
| 243 | printInstruction(MI); |
| 244 | } |
| 245 | |
| 246 | bool IA64AsmPrinter::doInitialization(Module &M) { |
Dan Gohman | 4a558a3 | 2007-07-25 19:33:14 +0000 | [diff] [blame] | 247 | bool Result = AsmPrinter::doInitialization(M); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 248 | |
| 249 | O << "\n.ident \"LLVM-ia64\"\n\n" |
| 250 | << "\t.psr lsb\n" // should be "msb" on HP-UX, for starters |
| 251 | << "\t.radix C\n" |
| 252 | << "\t.psr abi64\n"; // we only support 64 bits for now |
Dan Gohman | 4a558a3 | 2007-07-25 19:33:14 +0000 | [diff] [blame] | 253 | return Result; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 254 | } |
| 255 | |
Anton Korobeynikov | 9c53fec | 2008-08-07 09:52:35 +0000 | [diff] [blame] | 256 | void IA64AsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 257 | const TargetData *TD = TM.getTargetData(); |
Anton Korobeynikov | c7fcf35 | 2008-08-07 09:52:13 +0000 | [diff] [blame] | 258 | |
Anton Korobeynikov | 9c53fec | 2008-08-07 09:52:35 +0000 | [diff] [blame] | 259 | if (!GVar->hasInitializer()) |
| 260 | return; // External global require no code |
| 261 | |
| 262 | // Check to see if this is a special global used by LLVM, if so, emit it. |
| 263 | if (EmitSpecialLLVMGlobal(GVar)) |
| 264 | return; |
| 265 | |
| 266 | O << "\n\n"; |
Anton Korobeynikov | 9c53fec | 2008-08-07 09:52:35 +0000 | [diff] [blame] | 267 | std::string name = Mang->getValueName(GVar); |
| 268 | Constant *C = GVar->getInitializer(); |
| 269 | unsigned Size = TD->getABITypeSize(C->getType()); |
| 270 | unsigned Align = TD->getPreferredAlignmentLog(GVar); |
| 271 | |
Anton Korobeynikov | 78d69aa | 2008-08-08 18:25:07 +0000 | [diff] [blame] | 272 | printVisibility(name, GVar->getVisibility()); |
Anton Korobeynikov | 9c53fec | 2008-08-07 09:52:35 +0000 | [diff] [blame] | 273 | |
Anton Korobeynikov | 1a9edae | 2008-09-24 22:14:23 +0000 | [diff] [blame] | 274 | SwitchToSection(TAI->SectionForGlobal(GVar)); |
Anton Korobeynikov | 9c53fec | 2008-08-07 09:52:35 +0000 | [diff] [blame] | 275 | |
| 276 | if (C->isNullValue() && !GVar->hasSection()) { |
| 277 | if (!GVar->isThreadLocal() && |
Duncan Sands | eb3f45f | 2008-09-29 11:25:42 +0000 | [diff] [blame] | 278 | (GVar->hasInternalLinkage() || GVar->mayBeOverridden())) { |
Anton Korobeynikov | 9c53fec | 2008-08-07 09:52:35 +0000 | [diff] [blame] | 279 | if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it. |
| 280 | |
| 281 | if (GVar->hasInternalLinkage()) { |
| 282 | O << "\t.lcomm " << name << "#," << Size |
Anton Korobeynikov | 19eeb15 | 2008-08-07 09:52:54 +0000 | [diff] [blame] | 283 | << ',' << (1 << Align); |
| 284 | O << '\n'; |
Anton Korobeynikov | 9c53fec | 2008-08-07 09:52:35 +0000 | [diff] [blame] | 285 | } else { |
| 286 | O << "\t.common " << name << "#," << Size |
Anton Korobeynikov | 19eeb15 | 2008-08-07 09:52:54 +0000 | [diff] [blame] | 287 | << ',' << (1 << Align); |
| 288 | O << '\n'; |
Anton Korobeynikov | 9c53fec | 2008-08-07 09:52:35 +0000 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | return; |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | switch (GVar->getLinkage()) { |
| 296 | case GlobalValue::LinkOnceLinkage: |
| 297 | case GlobalValue::CommonLinkage: |
| 298 | case GlobalValue::WeakLinkage: |
| 299 | // Nonnull linkonce -> weak |
Anton Korobeynikov | 19eeb15 | 2008-08-07 09:52:54 +0000 | [diff] [blame] | 300 | O << "\t.weak " << name << '\n'; |
Anton Korobeynikov | 9c53fec | 2008-08-07 09:52:35 +0000 | [diff] [blame] | 301 | break; |
| 302 | case GlobalValue::AppendingLinkage: |
| 303 | // FIXME: appending linkage variables should go into a section of |
| 304 | // their name or something. For now, just emit them as external. |
| 305 | case GlobalValue::ExternalLinkage: |
| 306 | // If external or appending, declare as a global symbol |
Anton Korobeynikov | 19eeb15 | 2008-08-07 09:52:54 +0000 | [diff] [blame] | 307 | O << TAI->getGlobalDirective() << name << '\n'; |
Anton Korobeynikov | 9c53fec | 2008-08-07 09:52:35 +0000 | [diff] [blame] | 308 | // FALL THROUGH |
| 309 | case GlobalValue::InternalLinkage: |
| 310 | break; |
| 311 | case GlobalValue::GhostLinkage: |
| 312 | cerr << "GhostLinkage cannot appear in IA64AsmPrinter!\n"; |
| 313 | abort(); |
| 314 | case GlobalValue::DLLImportLinkage: |
| 315 | cerr << "DLLImport linkage is not supported by this target!\n"; |
| 316 | abort(); |
| 317 | case GlobalValue::DLLExportLinkage: |
| 318 | cerr << "DLLExport linkage is not supported by this target!\n"; |
| 319 | abort(); |
| 320 | default: |
| 321 | assert(0 && "Unknown linkage type!"); |
| 322 | } |
| 323 | |
Anton Korobeynikov | b59b229 | 2008-08-07 09:53:38 +0000 | [diff] [blame] | 324 | EmitAlignment(Align, GVar); |
Anton Korobeynikov | 9c53fec | 2008-08-07 09:52:35 +0000 | [diff] [blame] | 325 | |
| 326 | if (TAI->hasDotTypeDotSizeDirective()) { |
| 327 | O << "\t.type " << name << ",@object\n"; |
Anton Korobeynikov | 19eeb15 | 2008-08-07 09:52:54 +0000 | [diff] [blame] | 328 | O << "\t.size " << name << ',' << Size << '\n'; |
Anton Korobeynikov | 9c53fec | 2008-08-07 09:52:35 +0000 | [diff] [blame] | 329 | } |
| 330 | |
Owen Anderson | 847b99b | 2008-08-21 00:14:44 +0000 | [diff] [blame] | 331 | O << name << ":\n"; |
Anton Korobeynikov | 9c53fec | 2008-08-07 09:52:35 +0000 | [diff] [blame] | 332 | EmitGlobalConstant(C); |
| 333 | } |
| 334 | |
| 335 | |
| 336 | bool IA64AsmPrinter::doFinalization(Module &M) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 337 | // Print out module-level global variables here. |
| 338 | for (Module::const_global_iterator I = M.global_begin(), E = M.global_end(); |
| 339 | I != E; ++I) |
Anton Korobeynikov | 9c53fec | 2008-08-07 09:52:35 +0000 | [diff] [blame] | 340 | printModuleLevelGV(I); |
Anton Korobeynikov | c7fcf35 | 2008-08-07 09:52:13 +0000 | [diff] [blame] | 341 | |
| 342 | // we print out ".global X \n .type X, @function" for each external function |
| 343 | O << "\n\n// br.call targets referenced (and not defined) above: \n"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 344 | for (std::set<std::string>::iterator i = ExternalFunctionNames.begin(), |
| 345 | e = ExternalFunctionNames.end(); i!=e; ++i) { |
| 346 | O << "\t.global " << *i << "\n\t.type " << *i << ", @function\n"; |
| 347 | } |
| 348 | O << "\n\n"; |
Anton Korobeynikov | c7fcf35 | 2008-08-07 09:52:13 +0000 | [diff] [blame] | 349 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 350 | // we print out ".global X \n .type X, @object" for each external object |
| 351 | O << "\n\n// (external) symbols referenced (and not defined) above: \n"; |
| 352 | for (std::set<std::string>::iterator i = ExternalObjectNames.begin(), |
| 353 | e = ExternalObjectNames.end(); i!=e; ++i) { |
| 354 | O << "\t.global " << *i << "\n\t.type " << *i << ", @object\n"; |
| 355 | } |
| 356 | O << "\n\n"; |
Anton Korobeynikov | c7fcf35 | 2008-08-07 09:52:13 +0000 | [diff] [blame] | 357 | |
Dan Gohman | 4a558a3 | 2007-07-25 19:33:14 +0000 | [diff] [blame] | 358 | return AsmPrinter::doFinalization(M); |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 359 | } |
| 360 | |
| 361 | /// createIA64CodePrinterPass - Returns a pass that prints the IA64 |
| 362 | /// assembly code for a MachineFunction to the given output stream, using |
| 363 | /// the given target machine description. |
| 364 | /// |
Owen Anderson | 847b99b | 2008-08-21 00:14:44 +0000 | [diff] [blame] | 365 | FunctionPass *llvm::createIA64CodePrinterPass(raw_ostream &o, |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 366 | IA64TargetMachine &tm) { |
| 367 | return new IA64AsmPrinter(o, tm, tm.getTargetAsmInfo()); |
| 368 | } |