Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 1 | //===-- AsmPrinter.cpp - Common AsmPrinter code ---------------------------===// |
| 2 | // |
| 3 | // 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. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the AsmPrinter class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Evan Cheng | 932f022 | 2006-03-03 02:04:29 +0000 | [diff] [blame] | 14 | #include "llvm/CodeGen/AsmPrinter.h" |
Evan Cheng | 246ae0d | 2006-03-01 22:18:09 +0000 | [diff] [blame] | 15 | #include "llvm/Assembly/Writer.h" |
Nate Begeman | 8cfa57b | 2005-12-06 06:18:55 +0000 | [diff] [blame] | 16 | #include "llvm/DerivedTypes.h" |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 17 | #include "llvm/Constants.h" |
Chris Lattner | 450de39 | 2005-11-10 18:36:17 +0000 | [diff] [blame] | 18 | #include "llvm/Module.h" |
Chris Lattner | 3b4fd32 | 2005-11-21 08:25:09 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/MachineConstantPool.h" |
Nate Begeman | 37efe67 | 2006-04-22 18:53:45 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/MachineJumpTableInfo.h" |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 21 | #include "llvm/Support/Mangler.h" |
Jim Laskey | cb6682f | 2005-08-17 19:34:49 +0000 | [diff] [blame] | 22 | #include "llvm/Support/MathExtras.h" |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 23 | #include "llvm/Target/TargetAsmInfo.h" |
Owen Anderson | 07000c6 | 2006-05-12 06:33:49 +0000 | [diff] [blame] | 24 | #include "llvm/Target/TargetData.h" |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 25 | #include "llvm/Target/TargetMachine.h" |
Duraid Madina | 2e096c1 | 2005-12-28 06:29:02 +0000 | [diff] [blame] | 26 | #include <iostream> |
Chris Lattner | 6609913 | 2006-02-01 22:41:11 +0000 | [diff] [blame] | 27 | #include <cerrno> |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 28 | using namespace llvm; |
| 29 | |
Jim Laskey | a0f3d17 | 2006-09-07 22:06:40 +0000 | [diff] [blame^] | 30 | AsmPrinter::AsmPrinter(std::ostream &o, TargetMachine &tm, |
| 31 | const TargetAsmInfo *T) |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 32 | : FunctionNumber(0), O(o), TM(tm), TAI(T) |
| 33 | {} |
Chris Lattner | ed13893 | 2005-12-13 06:32:10 +0000 | [diff] [blame] | 34 | |
| 35 | |
Chris Lattner | 4632d7a | 2006-05-09 04:59:56 +0000 | [diff] [blame] | 36 | /// SwitchToTextSection - Switch to the specified text section of the executable |
| 37 | /// if we are not already in it! |
Chris Lattner | ac28fbd | 2005-11-21 07:06:27 +0000 | [diff] [blame] | 38 | /// |
Chris Lattner | 4632d7a | 2006-05-09 04:59:56 +0000 | [diff] [blame] | 39 | void AsmPrinter::SwitchToTextSection(const char *NewSection, |
| 40 | const GlobalValue *GV) { |
Chris Lattner | ac28fbd | 2005-11-21 07:06:27 +0000 | [diff] [blame] | 41 | std::string NS; |
Chris Lattner | a7090ae | 2006-05-09 05:24:50 +0000 | [diff] [blame] | 42 | if (GV && GV->hasSection()) |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 43 | NS = TAI->getSwitchToSectionDirective() + GV->getSection(); |
Chris Lattner | a7090ae | 2006-05-09 05:24:50 +0000 | [diff] [blame] | 44 | else |
| 45 | NS = NewSection; |
| 46 | |
| 47 | // If we're already in this section, we're done. |
| 48 | if (CurrentSection == NS) return; |
Jeff Cohen | 51b776d | 2006-05-02 03:58:45 +0000 | [diff] [blame] | 49 | |
Chris Lattner | 7faec9b | 2006-05-09 05:33:48 +0000 | [diff] [blame] | 50 | // Close the current section, if applicable. |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 51 | if (TAI->getSectionEndDirectiveSuffix() && !CurrentSection.empty()) |
| 52 | O << CurrentSection << TAI->getSectionEndDirectiveSuffix() << "\n"; |
Jeff Cohen | 51b776d | 2006-05-02 03:58:45 +0000 | [diff] [blame] | 53 | |
Chris Lattner | 7faec9b | 2006-05-09 05:33:48 +0000 | [diff] [blame] | 54 | CurrentSection = NS; |
| 55 | |
| 56 | if (!CurrentSection.empty()) |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 57 | O << CurrentSection << TAI->getTextSectionStartSuffix() << '\n'; |
Chris Lattner | ac28fbd | 2005-11-21 07:06:27 +0000 | [diff] [blame] | 58 | } |
| 59 | |
Nate Begeman | 2f1ae88 | 2006-07-27 01:13:04 +0000 | [diff] [blame] | 60 | /// SwitchToDataSection - Switch to the specified data section of the executable |
Chris Lattner | 4632d7a | 2006-05-09 04:59:56 +0000 | [diff] [blame] | 61 | /// if we are not already in it! |
| 62 | /// |
| 63 | void AsmPrinter::SwitchToDataSection(const char *NewSection, |
| 64 | const GlobalValue *GV) { |
| 65 | std::string NS; |
Chris Lattner | b81cb61 | 2006-05-09 05:23:12 +0000 | [diff] [blame] | 66 | if (GV && GV->hasSection()) |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 67 | NS = TAI->getSwitchToSectionDirective() + GV->getSection(); |
Chris Lattner | b81cb61 | 2006-05-09 05:23:12 +0000 | [diff] [blame] | 68 | else |
| 69 | NS = NewSection; |
Chris Lattner | 4632d7a | 2006-05-09 04:59:56 +0000 | [diff] [blame] | 70 | |
Chris Lattner | b81cb61 | 2006-05-09 05:23:12 +0000 | [diff] [blame] | 71 | // If we're already in this section, we're done. |
| 72 | if (CurrentSection == NS) return; |
| 73 | |
Chris Lattner | 7faec9b | 2006-05-09 05:33:48 +0000 | [diff] [blame] | 74 | // Close the current section, if applicable. |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 75 | if (TAI->getSectionEndDirectiveSuffix() && !CurrentSection.empty()) |
| 76 | O << CurrentSection << TAI->getSectionEndDirectiveSuffix() << "\n"; |
Chris Lattner | 7faec9b | 2006-05-09 05:33:48 +0000 | [diff] [blame] | 77 | |
| 78 | CurrentSection = NS; |
Chris Lattner | 4632d7a | 2006-05-09 04:59:56 +0000 | [diff] [blame] | 79 | |
Chris Lattner | 7faec9b | 2006-05-09 05:33:48 +0000 | [diff] [blame] | 80 | if (!CurrentSection.empty()) |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 81 | O << CurrentSection << TAI->getDataSectionStartSuffix() << '\n'; |
Chris Lattner | 4632d7a | 2006-05-09 04:59:56 +0000 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 85 | bool AsmPrinter::doInitialization(Module &M) { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 86 | Mang = new Mangler(M, TAI->getGlobalPrefix()); |
Chris Lattner | 2c1b159 | 2006-01-23 23:47:53 +0000 | [diff] [blame] | 87 | |
Chris Lattner | 3e2fa7a | 2006-01-24 04:16:34 +0000 | [diff] [blame] | 88 | if (!M.getModuleInlineAsm().empty()) |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 89 | O << TAI->getCommentString() << " Start of file scope inline assembly\n" |
Chris Lattner | 3e2fa7a | 2006-01-24 04:16:34 +0000 | [diff] [blame] | 90 | << M.getModuleInlineAsm() |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 91 | << "\n" << TAI->getCommentString() |
| 92 | << " End of file scope inline assembly\n"; |
Chris Lattner | 2c1b159 | 2006-01-23 23:47:53 +0000 | [diff] [blame] | 93 | |
Chris Lattner | 4632d7a | 2006-05-09 04:59:56 +0000 | [diff] [blame] | 94 | SwitchToDataSection("", 0); // Reset back to no section. |
Jim Laskey | b3e789a | 2006-01-26 20:21:46 +0000 | [diff] [blame] | 95 | |
| 96 | if (MachineDebugInfo *DebugInfo = getAnalysisToUpdate<MachineDebugInfo>()) { |
| 97 | DebugInfo->AnalyzeModule(M); |
| 98 | } |
| 99 | |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 100 | return false; |
| 101 | } |
| 102 | |
| 103 | bool AsmPrinter::doFinalization(Module &M) { |
| 104 | delete Mang; Mang = 0; |
| 105 | return false; |
| 106 | } |
| 107 | |
Chris Lattner | 25045bd | 2005-11-21 07:51:36 +0000 | [diff] [blame] | 108 | void AsmPrinter::SetupMachineFunction(MachineFunction &MF) { |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 109 | // What's my mangled name? |
Chris Lattner | 450de39 | 2005-11-10 18:36:17 +0000 | [diff] [blame] | 110 | CurrentFnName = Mang->getValueName(MF.getFunction()); |
Chris Lattner | 77bc228 | 2005-11-21 08:13:27 +0000 | [diff] [blame] | 111 | IncrementFunctionNumber(); |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 112 | } |
| 113 | |
Chris Lattner | 3b4fd32 | 2005-11-21 08:25:09 +0000 | [diff] [blame] | 114 | /// EmitConstantPool - Print to the current output stream assembly |
| 115 | /// representations of the constants in the constant pool MCP. This is |
| 116 | /// used to print out constants which have been "spilled to memory" by |
| 117 | /// the code generator. |
| 118 | /// |
| 119 | void AsmPrinter::EmitConstantPool(MachineConstantPool *MCP) { |
Chris Lattner | fa77d43 | 2006-02-09 04:22:52 +0000 | [diff] [blame] | 120 | const std::vector<MachineConstantPoolEntry> &CP = MCP->getConstants(); |
Chris Lattner | 3b4fd32 | 2005-11-21 08:25:09 +0000 | [diff] [blame] | 121 | if (CP.empty()) return; |
Evan Cheng | 2d2cec1 | 2006-06-29 00:26:09 +0000 | [diff] [blame] | 122 | |
| 123 | // Some targets require 4-, 8-, and 16- byte constant literals to be placed |
| 124 | // in special sections. |
| 125 | std::vector<std::pair<MachineConstantPoolEntry,unsigned> > FourByteCPs; |
| 126 | std::vector<std::pair<MachineConstantPoolEntry,unsigned> > EightByteCPs; |
| 127 | std::vector<std::pair<MachineConstantPoolEntry,unsigned> > SixteenByteCPs; |
| 128 | std::vector<std::pair<MachineConstantPoolEntry,unsigned> > OtherCPs; |
Chris Lattner | 3b4fd32 | 2005-11-21 08:25:09 +0000 | [diff] [blame] | 129 | for (unsigned i = 0, e = CP.size(); i != e; ++i) { |
Evan Cheng | 2d2cec1 | 2006-06-29 00:26:09 +0000 | [diff] [blame] | 130 | MachineConstantPoolEntry CPE = CP[i]; |
| 131 | const Constant *CV = CPE.Val; |
| 132 | const Type *Ty = CV->getType(); |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 133 | if (TAI->getFourByteConstantSection() && |
Evan Cheng | 2d2cec1 | 2006-06-29 00:26:09 +0000 | [diff] [blame] | 134 | TM.getTargetData()->getTypeSize(Ty) == 4) |
| 135 | FourByteCPs.push_back(std::make_pair(CPE, i)); |
Evan Cheng | 61c958e | 2006-09-07 18:50:20 +0000 | [diff] [blame] | 136 | else if (TAI->getEightByteConstantSection() && |
Evan Cheng | 2d2cec1 | 2006-06-29 00:26:09 +0000 | [diff] [blame] | 137 | TM.getTargetData()->getTypeSize(Ty) == 8) |
| 138 | EightByteCPs.push_back(std::make_pair(CPE, i)); |
Evan Cheng | 61c958e | 2006-09-07 18:50:20 +0000 | [diff] [blame] | 139 | else if (TAI->getSixteenByteConstantSection() && |
Evan Cheng | 2d2cec1 | 2006-06-29 00:26:09 +0000 | [diff] [blame] | 140 | TM.getTargetData()->getTypeSize(Ty) == 16) |
| 141 | SixteenByteCPs.push_back(std::make_pair(CPE, i)); |
| 142 | else |
| 143 | OtherCPs.push_back(std::make_pair(CPE, i)); |
| 144 | } |
| 145 | |
| 146 | unsigned Alignment = MCP->getConstantPoolAlignment(); |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 147 | EmitConstantPool(Alignment, TAI->getFourByteConstantSection(), FourByteCPs); |
| 148 | EmitConstantPool(Alignment, TAI->getEightByteConstantSection(), EightByteCPs); |
| 149 | EmitConstantPool(Alignment, TAI->getSixteenByteConstantSection(), |
| 150 | SixteenByteCPs); |
| 151 | EmitConstantPool(Alignment, TAI->getConstantPoolSection(), OtherCPs); |
Evan Cheng | 2d2cec1 | 2006-06-29 00:26:09 +0000 | [diff] [blame] | 152 | } |
| 153 | |
| 154 | void AsmPrinter::EmitConstantPool(unsigned Alignment, const char *Section, |
| 155 | std::vector<std::pair<MachineConstantPoolEntry,unsigned> > &CP) { |
| 156 | if (CP.empty()) return; |
| 157 | |
| 158 | SwitchToDataSection(Section, 0); |
| 159 | EmitAlignment(Alignment); |
| 160 | for (unsigned i = 0, e = CP.size(); i != e; ++i) { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 161 | O << TAI->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber() << '_' |
| 162 | << CP[i].second << ":\t\t\t\t\t" << TAI->getCommentString() << " "; |
Evan Cheng | 2d2cec1 | 2006-06-29 00:26:09 +0000 | [diff] [blame] | 163 | WriteTypeSymbolic(O, CP[i].first.Val->getType(), 0) << '\n'; |
| 164 | EmitGlobalConstant(CP[i].first.Val); |
Chris Lattner | 3029f92 | 2006-02-09 04:46:04 +0000 | [diff] [blame] | 165 | if (i != e-1) { |
Evan Cheng | 2d2cec1 | 2006-06-29 00:26:09 +0000 | [diff] [blame] | 166 | unsigned EntSize = |
| 167 | TM.getTargetData()->getTypeSize(CP[i].first.Val->getType()); |
| 168 | unsigned ValEnd = CP[i].first.Offset + EntSize; |
Chris Lattner | 3029f92 | 2006-02-09 04:46:04 +0000 | [diff] [blame] | 169 | // Emit inter-object padding for alignment. |
Evan Cheng | 2d2cec1 | 2006-06-29 00:26:09 +0000 | [diff] [blame] | 170 | EmitZeros(CP[i+1].first.Offset-ValEnd); |
Chris Lattner | 3029f92 | 2006-02-09 04:46:04 +0000 | [diff] [blame] | 171 | } |
Chris Lattner | 3b4fd32 | 2005-11-21 08:25:09 +0000 | [diff] [blame] | 172 | } |
| 173 | } |
| 174 | |
Nate Begeman | 37efe67 | 2006-04-22 18:53:45 +0000 | [diff] [blame] | 175 | /// EmitJumpTableInfo - Print assembly representations of the jump tables used |
| 176 | /// by the current function to the current output stream. |
| 177 | /// |
| 178 | void AsmPrinter::EmitJumpTableInfo(MachineJumpTableInfo *MJTI) { |
| 179 | const std::vector<MachineJumpTableEntry> &JT = MJTI->getJumpTables(); |
| 180 | if (JT.empty()) return; |
Owen Anderson | a69571c | 2006-05-03 01:29:57 +0000 | [diff] [blame] | 181 | const TargetData *TD = TM.getTargetData(); |
Nate Begeman | 4d9bbdc | 2006-07-27 16:46:58 +0000 | [diff] [blame] | 182 | |
| 183 | // JTEntryDirective is a string to print sizeof(ptr) for non-PIC jump tables, |
| 184 | // and 32 bits for PIC since PIC jump table entries are differences, not |
| 185 | // pointers to blocks. |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 186 | const char *JTEntryDirective = TAI->getData32bitsDirective(); |
Nate Begeman | 37efe67 | 2006-04-22 18:53:45 +0000 | [diff] [blame] | 187 | |
Nate Begeman | 2f1ae88 | 2006-07-27 01:13:04 +0000 | [diff] [blame] | 188 | // Pick the directive to use to print the jump table entries, and switch to |
| 189 | // the appropriate section. |
| 190 | if (TM.getRelocationModel() == Reloc::PIC_) { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 191 | SwitchToTextSection(TAI->getJumpTableTextSection(), 0); |
Nate Begeman | 2f1ae88 | 2006-07-27 01:13:04 +0000 | [diff] [blame] | 192 | } else { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 193 | SwitchToDataSection(TAI->getJumpTableDataSection(), 0); |
Nate Begeman | 2f1ae88 | 2006-07-27 01:13:04 +0000 | [diff] [blame] | 194 | if (TD->getPointerSize() == 8) |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 195 | JTEntryDirective = TAI->getData64bitsDirective(); |
Nate Begeman | 2f1ae88 | 2006-07-27 01:13:04 +0000 | [diff] [blame] | 196 | } |
Owen Anderson | a69571c | 2006-05-03 01:29:57 +0000 | [diff] [blame] | 197 | EmitAlignment(Log2_32(TD->getPointerAlignment())); |
Chris Lattner | 0c4e678 | 2006-07-15 01:34:12 +0000 | [diff] [blame] | 198 | |
Nate Begeman | 37efe67 | 2006-04-22 18:53:45 +0000 | [diff] [blame] | 199 | for (unsigned i = 0, e = JT.size(); i != e; ++i) { |
Nate Begeman | 52a51e38 | 2006-08-12 21:29:52 +0000 | [diff] [blame] | 200 | const std::vector<MachineBasicBlock*> &JTBBs = JT[i].MBBs; |
| 201 | |
| 202 | // For PIC codegen, if possible we want to use the SetDirective to reduce |
| 203 | // the number of relocations the assembler will generate for the jump table. |
| 204 | // Set directives are all printed before the jump table itself. |
| 205 | std::set<MachineBasicBlock*> EmittedSets; |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 206 | if (TAI->getSetDirective() && TM.getRelocationModel() == Reloc::PIC_) |
Nate Begeman | 52a51e38 | 2006-08-12 21:29:52 +0000 | [diff] [blame] | 207 | for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) |
| 208 | if (EmittedSets.insert(JTBBs[ii]).second) |
| 209 | printSetLabel(i, JTBBs[ii]); |
| 210 | |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 211 | O << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() |
| 212 | << '_' << i << ":\n"; |
Nate Begeman | 52a51e38 | 2006-08-12 21:29:52 +0000 | [diff] [blame] | 213 | |
Nate Begeman | 37efe67 | 2006-04-22 18:53:45 +0000 | [diff] [blame] | 214 | for (unsigned ii = 0, ee = JTBBs.size(); ii != ee; ++ii) { |
Nate Begeman | 4d9bbdc | 2006-07-27 16:46:58 +0000 | [diff] [blame] | 215 | O << JTEntryDirective << ' '; |
Nate Begeman | 52a51e38 | 2006-08-12 21:29:52 +0000 | [diff] [blame] | 216 | // If we have emitted set directives for the jump table entries, print |
| 217 | // them rather than the entries themselves. If we're emitting PIC, then |
| 218 | // emit the table entries as differences between two text section labels. |
| 219 | // If we're emitting non-PIC code, then emit the entries as direct |
| 220 | // references to the target basic blocks. |
| 221 | if (!EmittedSets.empty()) { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 222 | O << TAI->getPrivateGlobalPrefix() << getFunctionNumber() |
| 223 | << '_' << i << "_set_" << JTBBs[ii]->getNumber(); |
Nate Begeman | 52a51e38 | 2006-08-12 21:29:52 +0000 | [diff] [blame] | 224 | } else if (TM.getRelocationModel() == Reloc::PIC_) { |
| 225 | printBasicBlockLabel(JTBBs[ii], false, false); |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 226 | O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" |
| 227 | << getFunctionNumber() << '_' << i; |
Nate Begeman | 52a51e38 | 2006-08-12 21:29:52 +0000 | [diff] [blame] | 228 | } else { |
| 229 | printBasicBlockLabel(JTBBs[ii], false, false); |
Nate Begeman | 2f1ae88 | 2006-07-27 01:13:04 +0000 | [diff] [blame] | 230 | } |
Nate Begeman | 37efe67 | 2006-04-22 18:53:45 +0000 | [diff] [blame] | 231 | O << '\n'; |
| 232 | } |
| 233 | } |
| 234 | } |
| 235 | |
Chris Lattner | ed13893 | 2005-12-13 06:32:10 +0000 | [diff] [blame] | 236 | /// EmitSpecialLLVMGlobal - Check to see if the specified global is a |
| 237 | /// special global used by LLVM. If so, emit it and return true, otherwise |
| 238 | /// do nothing and return false. |
| 239 | bool AsmPrinter::EmitSpecialLLVMGlobal(const GlobalVariable *GV) { |
Jim Laskey | 7809811 | 2006-03-07 22:00:35 +0000 | [diff] [blame] | 240 | // Ignore debug and non-emitted data. |
| 241 | if (GV->getSection() == "llvm.metadata") return true; |
| 242 | |
| 243 | if (!GV->hasAppendingLinkage()) return false; |
| 244 | |
| 245 | assert(GV->hasInitializer() && "Not a special LLVM global!"); |
Chris Lattner | ed13893 | 2005-12-13 06:32:10 +0000 | [diff] [blame] | 246 | |
| 247 | if (GV->getName() == "llvm.used") |
| 248 | return true; // No need to emit this at all. |
| 249 | |
Chris Lattner | 5166b82 | 2006-01-12 19:17:23 +0000 | [diff] [blame] | 250 | if (GV->getName() == "llvm.global_ctors" && GV->use_empty()) { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 251 | SwitchToDataSection(TAI->getStaticCtorsSection(), 0); |
Chris Lattner | ed13893 | 2005-12-13 06:32:10 +0000 | [diff] [blame] | 252 | EmitAlignment(2, 0); |
| 253 | EmitXXStructorList(GV->getInitializer()); |
| 254 | return true; |
| 255 | } |
| 256 | |
Chris Lattner | 5166b82 | 2006-01-12 19:17:23 +0000 | [diff] [blame] | 257 | if (GV->getName() == "llvm.global_dtors" && GV->use_empty()) { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 258 | SwitchToDataSection(TAI->getStaticDtorsSection(), 0); |
Chris Lattner | ed13893 | 2005-12-13 06:32:10 +0000 | [diff] [blame] | 259 | EmitAlignment(2, 0); |
| 260 | EmitXXStructorList(GV->getInitializer()); |
| 261 | return true; |
| 262 | } |
| 263 | |
| 264 | return false; |
| 265 | } |
| 266 | |
| 267 | /// EmitXXStructorList - Emit the ctor or dtor list. This just prints out the |
| 268 | /// function pointers, ignoring the init priority. |
| 269 | void AsmPrinter::EmitXXStructorList(Constant *List) { |
| 270 | // Should be an array of '{ int, void ()* }' structs. The first value is the |
| 271 | // init priority, which we ignore. |
| 272 | if (!isa<ConstantArray>(List)) return; |
| 273 | ConstantArray *InitList = cast<ConstantArray>(List); |
| 274 | for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) |
| 275 | if (ConstantStruct *CS = dyn_cast<ConstantStruct>(InitList->getOperand(i))){ |
| 276 | if (CS->getNumOperands() != 2) return; // Not array of 2-element structs. |
Chris Lattner | 8de324b | 2005-12-21 01:17:37 +0000 | [diff] [blame] | 277 | |
| 278 | if (CS->getOperand(1)->isNullValue()) |
| 279 | return; // Found a null terminator, exit printing. |
| 280 | // Emit the function pointer. |
Chris Lattner | ed13893 | 2005-12-13 06:32:10 +0000 | [diff] [blame] | 281 | EmitGlobalConstant(CS->getOperand(1)); |
| 282 | } |
| 283 | } |
Chris Lattner | 3b4fd32 | 2005-11-21 08:25:09 +0000 | [diff] [blame] | 284 | |
Chris Lattner | 4d57e0c | 2006-02-05 01:29:18 +0000 | [diff] [blame] | 285 | /// getPreferredAlignmentLog - Return the preferred alignment of the |
| 286 | /// specified global, returned in log form. This includes an explicitly |
| 287 | /// requested alignment (if the global has one). |
| 288 | unsigned AsmPrinter::getPreferredAlignmentLog(const GlobalVariable *GV) const { |
Jim Laskey | 35f8c20 | 2006-06-15 13:10:58 +0000 | [diff] [blame] | 289 | const Type *ElemType = GV->getType()->getElementType(); |
| 290 | unsigned Alignment = TM.getTargetData()->getTypeAlignmentShift(ElemType); |
Chris Lattner | 4d57e0c | 2006-02-05 01:29:18 +0000 | [diff] [blame] | 291 | if (GV->getAlignment() > (1U << Alignment)) |
| 292 | Alignment = Log2_32(GV->getAlignment()); |
| 293 | |
Chris Lattner | 519ea2a | 2006-02-05 01:46:49 +0000 | [diff] [blame] | 294 | if (GV->hasInitializer()) { |
Jim Laskey | d5a932b | 2006-06-15 19:37:14 +0000 | [diff] [blame] | 295 | // Always round up alignment of global doubles to 8 bytes. |
| 296 | if (GV->getType()->getElementType() == Type::DoubleTy && Alignment < 3) |
| 297 | Alignment = 3; |
Chris Lattner | 519ea2a | 2006-02-05 01:46:49 +0000 | [diff] [blame] | 298 | if (Alignment < 4) { |
| 299 | // If the global is not external, see if it is large. If so, give it a |
| 300 | // larger alignment. |
Jim Laskey | 35f8c20 | 2006-06-15 13:10:58 +0000 | [diff] [blame] | 301 | if (TM.getTargetData()->getTypeSize(ElemType) > 128) |
Chris Lattner | 519ea2a | 2006-02-05 01:46:49 +0000 | [diff] [blame] | 302 | Alignment = 4; // 16-byte alignment. |
| 303 | } |
Chris Lattner | 4d57e0c | 2006-02-05 01:29:18 +0000 | [diff] [blame] | 304 | } |
| 305 | return Alignment; |
| 306 | } |
Chris Lattner | 3b4fd32 | 2005-11-21 08:25:09 +0000 | [diff] [blame] | 307 | |
Chris Lattner | 25045bd | 2005-11-21 07:51:36 +0000 | [diff] [blame] | 308 | // EmitAlignment - Emit an alignment directive to the specified power of two. |
| 309 | void AsmPrinter::EmitAlignment(unsigned NumBits, const GlobalValue *GV) const { |
Chris Lattner | a1ab72d | 2005-11-14 19:00:06 +0000 | [diff] [blame] | 310 | if (GV && GV->getAlignment()) |
| 311 | NumBits = Log2_32(GV->getAlignment()); |
Chris Lattner | 2a21c6e | 2005-11-10 18:09:27 +0000 | [diff] [blame] | 312 | if (NumBits == 0) return; // No need to emit alignment. |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 313 | if (TAI->getAlignmentIsInBytes()) NumBits = 1 << NumBits; |
| 314 | O << TAI->getAlignDirective() << NumBits << "\n"; |
Chris Lattner | bfddc20 | 2004-08-17 19:14:29 +0000 | [diff] [blame] | 315 | } |
| 316 | |
Chris Lattner | 25045bd | 2005-11-21 07:51:36 +0000 | [diff] [blame] | 317 | /// EmitZeros - Emit a block of zeros. |
Chris Lattner | 7d057a3 | 2004-08-17 21:38:40 +0000 | [diff] [blame] | 318 | /// |
Chris Lattner | 25045bd | 2005-11-21 07:51:36 +0000 | [diff] [blame] | 319 | void AsmPrinter::EmitZeros(uint64_t NumZeros) const { |
Chris Lattner | 7d057a3 | 2004-08-17 21:38:40 +0000 | [diff] [blame] | 320 | if (NumZeros) { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 321 | if (TAI->getZeroDirective()) { |
| 322 | O << TAI->getZeroDirective() << NumZeros; |
| 323 | if (TAI->getZeroDirectiveSuffix()) |
| 324 | O << TAI->getZeroDirectiveSuffix(); |
Jeff Cohen | c6a057b | 2006-05-02 03:46:13 +0000 | [diff] [blame] | 325 | O << "\n"; |
| 326 | } else { |
Chris Lattner | 7d057a3 | 2004-08-17 21:38:40 +0000 | [diff] [blame] | 327 | for (; NumZeros; --NumZeros) |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 328 | O << TAI->getData8bitsDirective() << "0\n"; |
Chris Lattner | 7d057a3 | 2004-08-17 21:38:40 +0000 | [diff] [blame] | 329 | } |
| 330 | } |
| 331 | } |
| 332 | |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 333 | // Print out the specified constant, without a storage class. Only the |
| 334 | // constants valid in constant expressions can occur here. |
Chris Lattner | 25045bd | 2005-11-21 07:51:36 +0000 | [diff] [blame] | 335 | void AsmPrinter::EmitConstantValueOnly(const Constant *CV) { |
Chris Lattner | bd1d382 | 2004-10-16 18:19:26 +0000 | [diff] [blame] | 336 | if (CV->isNullValue() || isa<UndefValue>(CV)) |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 337 | O << "0"; |
| 338 | else if (const ConstantBool *CB = dyn_cast<ConstantBool>(CV)) { |
| 339 | assert(CB == ConstantBool::True); |
| 340 | O << "1"; |
| 341 | } else if (const ConstantSInt *CI = dyn_cast<ConstantSInt>(CV)) |
| 342 | if (((CI->getValue() << 32) >> 32) == CI->getValue()) |
| 343 | O << CI->getValue(); |
| 344 | else |
Duraid Madina | 4560657 | 2005-05-15 13:05:48 +0000 | [diff] [blame] | 345 | O << (uint64_t)CI->getValue(); |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 346 | else if (const ConstantUInt *CI = dyn_cast<ConstantUInt>(CV)) |
| 347 | O << CI->getValue(); |
Chris Lattner | 450de39 | 2005-11-10 18:36:17 +0000 | [diff] [blame] | 348 | else if (const GlobalValue *GV = dyn_cast<GlobalValue>(CV)) { |
Duraid Madina | 855a519 | 2005-04-02 12:21:51 +0000 | [diff] [blame] | 349 | // This is a constant address for a global variable or function. Use the |
| 350 | // name of the variable or function as the address value, possibly |
| 351 | // decorating it with GlobalVarAddrPrefix/Suffix or |
| 352 | // FunctionAddrPrefix/Suffix (these all default to "" ) |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 353 | if (isa<Function>(GV)) { |
| 354 | O << TAI->getFunctionAddrPrefix() |
| 355 | << Mang->getValueName(GV) |
| 356 | << TAI->getFunctionAddrSuffix(); |
| 357 | } else { |
| 358 | O << TAI->getGlobalVarAddrPrefix() |
| 359 | << Mang->getValueName(GV) |
| 360 | << TAI->getGlobalVarAddrSuffix(); |
| 361 | } |
Duraid Madina | 855a519 | 2005-04-02 12:21:51 +0000 | [diff] [blame] | 362 | } else if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) { |
Owen Anderson | a69571c | 2006-05-03 01:29:57 +0000 | [diff] [blame] | 363 | const TargetData *TD = TM.getTargetData(); |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 364 | switch(CE->getOpcode()) { |
| 365 | case Instruction::GetElementPtr: { |
| 366 | // generate a symbolic expression for the byte address |
| 367 | const Constant *ptrVal = CE->getOperand(0); |
| 368 | std::vector<Value*> idxVec(CE->op_begin()+1, CE->op_end()); |
Owen Anderson | a69571c | 2006-05-03 01:29:57 +0000 | [diff] [blame] | 369 | if (int64_t Offset = TD->getIndexedOffset(ptrVal->getType(), idxVec)) { |
Chris Lattner | 27e1921 | 2005-02-14 21:40:26 +0000 | [diff] [blame] | 370 | if (Offset) |
| 371 | O << "("; |
Chris Lattner | 25045bd | 2005-11-21 07:51:36 +0000 | [diff] [blame] | 372 | EmitConstantValueOnly(ptrVal); |
Chris Lattner | 27e1921 | 2005-02-14 21:40:26 +0000 | [diff] [blame] | 373 | if (Offset > 0) |
| 374 | O << ") + " << Offset; |
| 375 | else if (Offset < 0) |
| 376 | O << ") - " << -Offset; |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 377 | } else { |
Chris Lattner | 25045bd | 2005-11-21 07:51:36 +0000 | [diff] [blame] | 378 | EmitConstantValueOnly(ptrVal); |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 379 | } |
| 380 | break; |
| 381 | } |
| 382 | case Instruction::Cast: { |
Chris Lattner | 4a6bd33 | 2006-07-29 01:57:19 +0000 | [diff] [blame] | 383 | // Support only foldable casts to/from pointers that can be eliminated by |
| 384 | // changing the pointer to the appropriately sized integer type. |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 385 | Constant *Op = CE->getOperand(0); |
| 386 | const Type *OpTy = Op->getType(), *Ty = CE->getType(); |
| 387 | |
Chris Lattner | 4a6bd33 | 2006-07-29 01:57:19 +0000 | [diff] [blame] | 388 | // Handle casts to pointers by changing them into casts to the appropriate |
| 389 | // integer type. This promotes constant folding and simplifies this code. |
| 390 | if (isa<PointerType>(Ty)) { |
| 391 | const Type *IntPtrTy = TD->getIntPtrType(); |
| 392 | Op = ConstantExpr::getCast(Op, IntPtrTy); |
| 393 | return EmitConstantValueOnly(Op); |
| 394 | } |
| 395 | |
| 396 | // We know the dest type is not a pointer. Is the src value a pointer or |
| 397 | // integral? |
| 398 | if (isa<PointerType>(OpTy) || OpTy->isIntegral()) { |
| 399 | // We can emit the pointer value into this slot if the slot is an |
| 400 | // integer slot greater or equal to the size of the pointer. |
| 401 | if (Ty->isIntegral() && TD->getTypeSize(Ty) >= TD->getTypeSize(OpTy)) |
| 402 | return EmitConstantValueOnly(Op); |
| 403 | } |
| 404 | |
| 405 | assert(0 && "FIXME: Don't yet support this kind of constant cast expr"); |
Chris Lattner | 25045bd | 2005-11-21 07:51:36 +0000 | [diff] [blame] | 406 | EmitConstantValueOnly(Op); |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 407 | break; |
| 408 | } |
| 409 | case Instruction::Add: |
| 410 | O << "("; |
Chris Lattner | 25045bd | 2005-11-21 07:51:36 +0000 | [diff] [blame] | 411 | EmitConstantValueOnly(CE->getOperand(0)); |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 412 | O << ") + ("; |
Chris Lattner | 25045bd | 2005-11-21 07:51:36 +0000 | [diff] [blame] | 413 | EmitConstantValueOnly(CE->getOperand(1)); |
Chris Lattner | a80ba71 | 2004-08-16 23:15:22 +0000 | [diff] [blame] | 414 | O << ")"; |
| 415 | break; |
| 416 | default: |
| 417 | assert(0 && "Unsupported operator!"); |
| 418 | } |
| 419 | } else { |
| 420 | assert(0 && "Unknown constant value!"); |
| 421 | } |
| 422 | } |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 423 | |
| 424 | /// toOctal - Convert the low order bits of X into an octal digit. |
| 425 | /// |
| 426 | static inline char toOctal(int X) { |
| 427 | return (X&7)+'0'; |
| 428 | } |
| 429 | |
Chris Lattner | 2980cef | 2005-11-10 18:06:33 +0000 | [diff] [blame] | 430 | /// printAsCString - Print the specified array as a C compatible string, only if |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 431 | /// the predicate isString is true. |
| 432 | /// |
Chris Lattner | 2980cef | 2005-11-10 18:06:33 +0000 | [diff] [blame] | 433 | static void printAsCString(std::ostream &O, const ConstantArray *CVA, |
| 434 | unsigned LastElt) { |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 435 | assert(CVA->isString() && "Array is not string compatible!"); |
| 436 | |
| 437 | O << "\""; |
Chris Lattner | 2980cef | 2005-11-10 18:06:33 +0000 | [diff] [blame] | 438 | for (unsigned i = 0; i != LastElt; ++i) { |
Misha Brukman | edf128a | 2005-04-21 22:36:52 +0000 | [diff] [blame] | 439 | unsigned char C = |
Chris Lattner | dea18b6 | 2005-01-08 19:59:10 +0000 | [diff] [blame] | 440 | (unsigned char)cast<ConstantInt>(CVA->getOperand(i))->getRawValue(); |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 441 | |
| 442 | if (C == '"') { |
| 443 | O << "\\\""; |
| 444 | } else if (C == '\\') { |
| 445 | O << "\\\\"; |
| 446 | } else if (isprint(C)) { |
| 447 | O << C; |
| 448 | } else { |
| 449 | switch(C) { |
| 450 | case '\b': O << "\\b"; break; |
| 451 | case '\f': O << "\\f"; break; |
| 452 | case '\n': O << "\\n"; break; |
| 453 | case '\r': O << "\\r"; break; |
| 454 | case '\t': O << "\\t"; break; |
| 455 | default: |
| 456 | O << '\\'; |
| 457 | O << toOctal(C >> 6); |
| 458 | O << toOctal(C >> 3); |
| 459 | O << toOctal(C >> 0); |
| 460 | break; |
| 461 | } |
| 462 | } |
| 463 | } |
| 464 | O << "\""; |
| 465 | } |
| 466 | |
Jeff Cohen | c884db4 | 2006-05-02 01:16:28 +0000 | [diff] [blame] | 467 | /// EmitString - Emit a zero-byte-terminated string constant. |
| 468 | /// |
| 469 | void AsmPrinter::EmitString(const ConstantArray *CVA) const { |
| 470 | unsigned NumElts = CVA->getNumOperands(); |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 471 | if (TAI->getAscizDirective() && NumElts && |
Jeff Cohen | c884db4 | 2006-05-02 01:16:28 +0000 | [diff] [blame] | 472 | cast<ConstantInt>(CVA->getOperand(NumElts-1))->getRawValue() == 0) { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 473 | O << TAI->getAscizDirective(); |
Jeff Cohen | c884db4 | 2006-05-02 01:16:28 +0000 | [diff] [blame] | 474 | printAsCString(O, CVA, NumElts-1); |
| 475 | } else { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 476 | O << TAI->getAsciiDirective(); |
Jeff Cohen | c884db4 | 2006-05-02 01:16:28 +0000 | [diff] [blame] | 477 | printAsCString(O, CVA, NumElts); |
| 478 | } |
| 479 | O << "\n"; |
| 480 | } |
| 481 | |
Chris Lattner | 25045bd | 2005-11-21 07:51:36 +0000 | [diff] [blame] | 482 | /// EmitGlobalConstant - Print a general LLVM constant to the .s file. |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 483 | /// |
Chris Lattner | 25045bd | 2005-11-21 07:51:36 +0000 | [diff] [blame] | 484 | void AsmPrinter::EmitGlobalConstant(const Constant *CV) { |
Owen Anderson | a69571c | 2006-05-03 01:29:57 +0000 | [diff] [blame] | 485 | const TargetData *TD = TM.getTargetData(); |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 486 | |
Chris Lattner | bd1d382 | 2004-10-16 18:19:26 +0000 | [diff] [blame] | 487 | if (CV->isNullValue() || isa<UndefValue>(CV)) { |
Owen Anderson | a69571c | 2006-05-03 01:29:57 +0000 | [diff] [blame] | 488 | EmitZeros(TD->getTypeSize(CV->getType())); |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 489 | return; |
| 490 | } else if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) { |
| 491 | if (CVA->isString()) { |
Jeff Cohen | c884db4 | 2006-05-02 01:16:28 +0000 | [diff] [blame] | 492 | EmitString(CVA); |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 493 | } else { // Not a string. Print the values in successive locations |
| 494 | for (unsigned i = 0, e = CVA->getNumOperands(); i != e; ++i) |
Chris Lattner | 25045bd | 2005-11-21 07:51:36 +0000 | [diff] [blame] | 495 | EmitGlobalConstant(CVA->getOperand(i)); |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 496 | } |
| 497 | return; |
| 498 | } else if (const ConstantStruct *CVS = dyn_cast<ConstantStruct>(CV)) { |
| 499 | // Print the fields in successive locations. Pad to align if needed! |
Owen Anderson | a69571c | 2006-05-03 01:29:57 +0000 | [diff] [blame] | 500 | const StructLayout *cvsLayout = TD->getStructLayout(CVS->getType()); |
Chris Lattner | dea18b6 | 2005-01-08 19:59:10 +0000 | [diff] [blame] | 501 | uint64_t sizeSoFar = 0; |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 502 | for (unsigned i = 0, e = CVS->getNumOperands(); i != e; ++i) { |
| 503 | const Constant* field = CVS->getOperand(i); |
| 504 | |
| 505 | // Check if padding is needed and insert one or more 0s. |
Owen Anderson | a69571c | 2006-05-03 01:29:57 +0000 | [diff] [blame] | 506 | uint64_t fieldSize = TD->getTypeSize(field->getType()); |
Chris Lattner | dea18b6 | 2005-01-08 19:59:10 +0000 | [diff] [blame] | 507 | uint64_t padSize = ((i == e-1? cvsLayout->StructSize |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 508 | : cvsLayout->MemberOffsets[i+1]) |
| 509 | - cvsLayout->MemberOffsets[i]) - fieldSize; |
| 510 | sizeSoFar += fieldSize + padSize; |
| 511 | |
| 512 | // Now print the actual field value |
Chris Lattner | 25045bd | 2005-11-21 07:51:36 +0000 | [diff] [blame] | 513 | EmitGlobalConstant(field); |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 514 | |
| 515 | // Insert the field padding unless it's zero bytes... |
Chris Lattner | 25045bd | 2005-11-21 07:51:36 +0000 | [diff] [blame] | 516 | EmitZeros(padSize); |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 517 | } |
| 518 | assert(sizeSoFar == cvsLayout->StructSize && |
| 519 | "Layout of constant struct may be incorrect!"); |
| 520 | return; |
| 521 | } else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV)) { |
| 522 | // FP Constants are printed as integer constants to avoid losing |
| 523 | // precision... |
| 524 | double Val = CFP->getValue(); |
| 525 | if (CFP->getType() == Type::DoubleTy) { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 526 | if (TAI->getData64bitsDirective()) |
| 527 | O << TAI->getData64bitsDirective() << DoubleToBits(Val) << "\t" |
| 528 | << TAI->getCommentString() << " double value: " << Val << "\n"; |
Owen Anderson | a69571c | 2006-05-03 01:29:57 +0000 | [diff] [blame] | 529 | else if (TD->isBigEndian()) { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 530 | O << TAI->getData32bitsDirective() << unsigned(DoubleToBits(Val) >> 32) |
| 531 | << "\t" << TAI->getCommentString() |
| 532 | << " double most significant word " << Val << "\n"; |
| 533 | O << TAI->getData32bitsDirective() << unsigned(DoubleToBits(Val)) |
| 534 | << "\t" << TAI->getCommentString() |
| 535 | << " double least significant word " << Val << "\n"; |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 536 | } else { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 537 | O << TAI->getData32bitsDirective() << unsigned(DoubleToBits(Val)) |
| 538 | << "\t" << TAI->getCommentString() |
| 539 | << " double least significant word " << Val << "\n"; |
| 540 | O << TAI->getData32bitsDirective() << unsigned(DoubleToBits(Val) >> 32) |
| 541 | << "\t" << TAI->getCommentString() |
| 542 | << " double most significant word " << Val << "\n"; |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 543 | } |
| 544 | return; |
| 545 | } else { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 546 | O << TAI->getData32bitsDirective() << FloatToBits(Val) |
| 547 | << "\t" << TAI->getCommentString() << " float " << Val << "\n"; |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 548 | return; |
| 549 | } |
| 550 | } else if (CV->getType() == Type::ULongTy || CV->getType() == Type::LongTy) { |
| 551 | if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) { |
| 552 | uint64_t Val = CI->getRawValue(); |
Misha Brukman | edf128a | 2005-04-21 22:36:52 +0000 | [diff] [blame] | 553 | |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 554 | if (TAI->getData64bitsDirective()) |
| 555 | O << TAI->getData64bitsDirective() << Val << "\n"; |
Owen Anderson | a69571c | 2006-05-03 01:29:57 +0000 | [diff] [blame] | 556 | else if (TD->isBigEndian()) { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 557 | O << TAI->getData32bitsDirective() << unsigned(Val >> 32) |
| 558 | << "\t" << TAI->getCommentString() |
| 559 | << " Double-word most significant word " << Val << "\n"; |
| 560 | O << TAI->getData32bitsDirective() << unsigned(Val) |
| 561 | << "\t" << TAI->getCommentString() |
| 562 | << " Double-word least significant word " << Val << "\n"; |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 563 | } else { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 564 | O << TAI->getData32bitsDirective() << unsigned(Val) |
| 565 | << "\t" << TAI->getCommentString() |
| 566 | << " Double-word least significant word " << Val << "\n"; |
| 567 | O << TAI->getData32bitsDirective() << unsigned(Val >> 32) |
| 568 | << "\t" << TAI->getCommentString() |
| 569 | << " Double-word most significant word " << Val << "\n"; |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 570 | } |
| 571 | return; |
| 572 | } |
Nate Begeman | 8cfa57b | 2005-12-06 06:18:55 +0000 | [diff] [blame] | 573 | } else if (const ConstantPacked *CP = dyn_cast<ConstantPacked>(CV)) { |
| 574 | const PackedType *PTy = CP->getType(); |
| 575 | |
| 576 | for (unsigned I = 0, E = PTy->getNumElements(); I < E; ++I) |
| 577 | EmitGlobalConstant(CP->getOperand(I)); |
| 578 | |
| 579 | return; |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 580 | } |
| 581 | |
| 582 | const Type *type = CV->getType(); |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 583 | switch (type->getTypeID()) { |
Misha Brukman | edf128a | 2005-04-21 22:36:52 +0000 | [diff] [blame] | 584 | case Type::BoolTyID: |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 585 | case Type::UByteTyID: case Type::SByteTyID: |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 586 | O << TAI->getData8bitsDirective(); |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 587 | break; |
| 588 | case Type::UShortTyID: case Type::ShortTyID: |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 589 | O << TAI->getData16bitsDirective(); |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 590 | break; |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 591 | case Type::PointerTyID: |
Owen Anderson | a69571c | 2006-05-03 01:29:57 +0000 | [diff] [blame] | 592 | if (TD->getPointerSize() == 8) { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 593 | assert(TAI->getData64bitsDirective() && |
Evan Cheng | a9767f6 | 2006-06-15 08:10:56 +0000 | [diff] [blame] | 594 | "Target cannot handle 64-bit pointer exprs!"); |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 595 | O << TAI->getData64bitsDirective(); |
Andrew Lenharth | 571c9c3 | 2005-02-04 13:47:16 +0000 | [diff] [blame] | 596 | break; |
| 597 | } |
| 598 | //Fall through for pointer size == int size |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 599 | case Type::UIntTyID: case Type::IntTyID: |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 600 | O << TAI->getData32bitsDirective(); |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 601 | break; |
Misha Brukman | edf128a | 2005-04-21 22:36:52 +0000 | [diff] [blame] | 602 | case Type::ULongTyID: case Type::LongTyID: |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 603 | assert(TAI->getData64bitsDirective() && |
| 604 | "Target cannot handle 64-bit constant exprs!"); |
| 605 | O << TAI->getData64bitsDirective(); |
Chris Lattner | 660538c | 2005-08-08 04:26:32 +0000 | [diff] [blame] | 606 | break; |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 607 | case Type::FloatTyID: case Type::DoubleTyID: |
| 608 | assert (0 && "Should have already output floating point constant."); |
| 609 | default: |
| 610 | assert (0 && "Can't handle printing this type of thing"); |
| 611 | break; |
| 612 | } |
Chris Lattner | 25045bd | 2005-11-21 07:51:36 +0000 | [diff] [blame] | 613 | EmitConstantValueOnly(CV); |
Chris Lattner | 1b7e235 | 2004-08-17 06:36:49 +0000 | [diff] [blame] | 614 | O << "\n"; |
| 615 | } |
Chris Lattner | 0264d1a | 2006-01-27 02:10:10 +0000 | [diff] [blame] | 616 | |
| 617 | /// printInlineAsm - This method formats and prints the specified machine |
| 618 | /// instruction that is an inline asm. |
| 619 | void AsmPrinter::printInlineAsm(const MachineInstr *MI) const { |
Chris Lattner | f2b67cf | 2006-01-30 23:00:08 +0000 | [diff] [blame] | 620 | unsigned NumOperands = MI->getNumOperands(); |
| 621 | |
| 622 | // Count the number of register definitions. |
| 623 | unsigned NumDefs = 0; |
Chris Lattner | 67942f5 | 2006-09-05 20:02:51 +0000 | [diff] [blame] | 624 | for (; MI->getOperand(NumDefs).isReg() && MI->getOperand(NumDefs).isDef(); |
| 625 | ++NumDefs) |
Chris Lattner | f2b67cf | 2006-01-30 23:00:08 +0000 | [diff] [blame] | 626 | assert(NumDefs != NumOperands-1 && "No asm string?"); |
| 627 | |
| 628 | assert(MI->getOperand(NumDefs).isExternalSymbol() && "No asm string?"); |
Chris Lattner | 6609913 | 2006-02-01 22:41:11 +0000 | [diff] [blame] | 629 | |
| 630 | // Disassemble the AsmStr, printing out the literal pieces, the operands, etc. |
Chris Lattner | f2b67cf | 2006-01-30 23:00:08 +0000 | [diff] [blame] | 631 | const char *AsmStr = MI->getOperand(NumDefs).getSymbolName(); |
Chris Lattner | 6609913 | 2006-02-01 22:41:11 +0000 | [diff] [blame] | 632 | |
Chris Lattner | f26f5dd | 2006-07-28 00:17:20 +0000 | [diff] [blame] | 633 | // If this asmstr is empty, don't bother printing the #APP/#NOAPP markers. |
| 634 | if (AsmStr[0] == 0) { |
| 635 | O << "\n"; // Tab already printed, avoid double indenting next instr. |
| 636 | return; |
| 637 | } |
| 638 | |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 639 | O << TAI->getInlineAsmStart() << "\n\t"; |
Chris Lattner | f26f5dd | 2006-07-28 00:17:20 +0000 | [diff] [blame] | 640 | |
Chris Lattner | 6609913 | 2006-02-01 22:41:11 +0000 | [diff] [blame] | 641 | // The variant of the current asmprinter: FIXME: change. |
| 642 | int AsmPrinterVariant = 0; |
Chris Lattner | f2b67cf | 2006-01-30 23:00:08 +0000 | [diff] [blame] | 643 | |
Chris Lattner | 6609913 | 2006-02-01 22:41:11 +0000 | [diff] [blame] | 644 | int CurVariant = -1; // The number of the {.|.|.} region we are in. |
| 645 | const char *LastEmitted = AsmStr; // One past the last character emitted. |
Chris Lattner | 2cc2f66 | 2006-02-01 01:28:23 +0000 | [diff] [blame] | 646 | |
Chris Lattner | 6609913 | 2006-02-01 22:41:11 +0000 | [diff] [blame] | 647 | while (*LastEmitted) { |
| 648 | switch (*LastEmitted) { |
| 649 | default: { |
| 650 | // Not a special case, emit the string section literally. |
| 651 | const char *LiteralEnd = LastEmitted+1; |
| 652 | while (*LiteralEnd && *LiteralEnd != '{' && *LiteralEnd != '|' && |
Chris Lattner | 1c05997 | 2006-05-05 21:47:05 +0000 | [diff] [blame] | 653 | *LiteralEnd != '}' && *LiteralEnd != '$' && *LiteralEnd != '\n') |
Chris Lattner | 6609913 | 2006-02-01 22:41:11 +0000 | [diff] [blame] | 654 | ++LiteralEnd; |
| 655 | if (CurVariant == -1 || CurVariant == AsmPrinterVariant) |
| 656 | O.write(LastEmitted, LiteralEnd-LastEmitted); |
| 657 | LastEmitted = LiteralEnd; |
| 658 | break; |
| 659 | } |
Chris Lattner | 1c05997 | 2006-05-05 21:47:05 +0000 | [diff] [blame] | 660 | case '\n': |
| 661 | ++LastEmitted; // Consume newline character. |
| 662 | O << "\n\t"; // Indent code with newline. |
| 663 | break; |
Chris Lattner | 6609913 | 2006-02-01 22:41:11 +0000 | [diff] [blame] | 664 | case '$': { |
| 665 | ++LastEmitted; // Consume '$' character. |
| 666 | if (*LastEmitted == '$') { // $$ -> $ |
| 667 | if (CurVariant == -1 || CurVariant == AsmPrinterVariant) |
| 668 | O << '$'; |
| 669 | ++LastEmitted; // Consume second '$' character. |
| 670 | break; |
| 671 | } |
| 672 | |
| 673 | bool HasCurlyBraces = false; |
| 674 | if (*LastEmitted == '{') { // ${variable} |
| 675 | ++LastEmitted; // Consume '{' character. |
| 676 | HasCurlyBraces = true; |
| 677 | } |
| 678 | |
| 679 | const char *IDStart = LastEmitted; |
| 680 | char *IDEnd; |
| 681 | long Val = strtol(IDStart, &IDEnd, 10); // We only accept numbers for IDs. |
| 682 | if (!isdigit(*IDStart) || (Val == 0 && errno == EINVAL)) { |
| 683 | std::cerr << "Bad $ operand number in inline asm string: '" |
| 684 | << AsmStr << "'\n"; |
| 685 | exit(1); |
| 686 | } |
| 687 | LastEmitted = IDEnd; |
| 688 | |
Chris Lattner | a36cb0a | 2006-02-06 22:17:23 +0000 | [diff] [blame] | 689 | char Modifier[2] = { 0, 0 }; |
| 690 | |
Chris Lattner | 6609913 | 2006-02-01 22:41:11 +0000 | [diff] [blame] | 691 | if (HasCurlyBraces) { |
Chris Lattner | a36cb0a | 2006-02-06 22:17:23 +0000 | [diff] [blame] | 692 | // If we have curly braces, check for a modifier character. This |
| 693 | // supports syntax like ${0:u}, which correspond to "%u0" in GCC asm. |
| 694 | if (*LastEmitted == ':') { |
| 695 | ++LastEmitted; // Consume ':' character. |
| 696 | if (*LastEmitted == 0) { |
| 697 | std::cerr << "Bad ${:} expression in inline asm string: '" |
| 698 | << AsmStr << "'\n"; |
| 699 | exit(1); |
| 700 | } |
| 701 | |
| 702 | Modifier[0] = *LastEmitted; |
| 703 | ++LastEmitted; // Consume modifier character. |
| 704 | } |
| 705 | |
Chris Lattner | 6609913 | 2006-02-01 22:41:11 +0000 | [diff] [blame] | 706 | if (*LastEmitted != '}') { |
| 707 | std::cerr << "Bad ${} expression in inline asm string: '" |
| 708 | << AsmStr << "'\n"; |
| 709 | exit(1); |
| 710 | } |
| 711 | ++LastEmitted; // Consume '}' character. |
| 712 | } |
| 713 | |
| 714 | if ((unsigned)Val >= NumOperands-1) { |
| 715 | std::cerr << "Invalid $ operand number in inline asm string: '" |
| 716 | << AsmStr << "'\n"; |
| 717 | exit(1); |
| 718 | } |
| 719 | |
Chris Lattner | c3a9f8d | 2006-02-23 19:21:04 +0000 | [diff] [blame] | 720 | // Okay, we finally have a value number. Ask the target to print this |
Chris Lattner | 6609913 | 2006-02-01 22:41:11 +0000 | [diff] [blame] | 721 | // operand! |
Chris Lattner | c3a9f8d | 2006-02-23 19:21:04 +0000 | [diff] [blame] | 722 | if (CurVariant == -1 || CurVariant == AsmPrinterVariant) { |
| 723 | unsigned OpNo = 1; |
Chris Lattner | fd561cd | 2006-06-08 18:00:47 +0000 | [diff] [blame] | 724 | |
| 725 | bool Error = false; |
| 726 | |
Chris Lattner | c3a9f8d | 2006-02-23 19:21:04 +0000 | [diff] [blame] | 727 | // Scan to find the machine operand number for the operand. |
Chris Lattner | daf6bc6 | 2006-02-24 19:50:58 +0000 | [diff] [blame] | 728 | for (; Val; --Val) { |
Chris Lattner | fd561cd | 2006-06-08 18:00:47 +0000 | [diff] [blame] | 729 | if (OpNo >= MI->getNumOperands()) break; |
Chris Lattner | daf6bc6 | 2006-02-24 19:50:58 +0000 | [diff] [blame] | 730 | unsigned OpFlags = MI->getOperand(OpNo).getImmedValue(); |
| 731 | OpNo += (OpFlags >> 3) + 1; |
| 732 | } |
Chris Lattner | dd26033 | 2006-02-24 20:21:58 +0000 | [diff] [blame] | 733 | |
Chris Lattner | fd561cd | 2006-06-08 18:00:47 +0000 | [diff] [blame] | 734 | if (OpNo >= MI->getNumOperands()) { |
| 735 | Error = true; |
Chris Lattner | dd26033 | 2006-02-24 20:21:58 +0000 | [diff] [blame] | 736 | } else { |
Chris Lattner | fd561cd | 2006-06-08 18:00:47 +0000 | [diff] [blame] | 737 | unsigned OpFlags = MI->getOperand(OpNo).getImmedValue(); |
| 738 | ++OpNo; // Skip over the ID number. |
| 739 | |
| 740 | AsmPrinter *AP = const_cast<AsmPrinter*>(this); |
| 741 | if ((OpFlags & 7) == 4 /*ADDR MODE*/) { |
| 742 | Error = AP->PrintAsmMemoryOperand(MI, OpNo, AsmPrinterVariant, |
| 743 | Modifier[0] ? Modifier : 0); |
| 744 | } else { |
| 745 | Error = AP->PrintAsmOperand(MI, OpNo, AsmPrinterVariant, |
| 746 | Modifier[0] ? Modifier : 0); |
| 747 | } |
Chris Lattner | dd26033 | 2006-02-24 20:21:58 +0000 | [diff] [blame] | 748 | } |
| 749 | if (Error) { |
Chris Lattner | 6609913 | 2006-02-01 22:41:11 +0000 | [diff] [blame] | 750 | std::cerr << "Invalid operand found in inline asm: '" |
| 751 | << AsmStr << "'\n"; |
| 752 | MI->dump(); |
| 753 | exit(1); |
| 754 | } |
Chris Lattner | c3a9f8d | 2006-02-23 19:21:04 +0000 | [diff] [blame] | 755 | } |
Chris Lattner | 6609913 | 2006-02-01 22:41:11 +0000 | [diff] [blame] | 756 | break; |
| 757 | } |
| 758 | case '{': |
| 759 | ++LastEmitted; // Consume '{' character. |
| 760 | if (CurVariant != -1) { |
| 761 | std::cerr << "Nested variants found in inline asm string: '" |
| 762 | << AsmStr << "'\n"; |
| 763 | exit(1); |
| 764 | } |
| 765 | CurVariant = 0; // We're in the first variant now. |
| 766 | break; |
| 767 | case '|': |
| 768 | ++LastEmitted; // consume '|' character. |
| 769 | if (CurVariant == -1) { |
| 770 | std::cerr << "Found '|' character outside of variant in inline asm " |
| 771 | << "string: '" << AsmStr << "'\n"; |
| 772 | exit(1); |
| 773 | } |
| 774 | ++CurVariant; // We're in the next variant. |
| 775 | break; |
| 776 | case '}': |
| 777 | ++LastEmitted; // consume '}' character. |
| 778 | if (CurVariant == -1) { |
| 779 | std::cerr << "Found '}' character outside of variant in inline asm " |
| 780 | << "string: '" << AsmStr << "'\n"; |
| 781 | exit(1); |
| 782 | } |
| 783 | CurVariant = -1; |
| 784 | break; |
| 785 | } |
| 786 | } |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 787 | O << "\n\t" << TAI->getInlineAsmEnd() << "\n"; |
Chris Lattner | 6609913 | 2006-02-01 22:41:11 +0000 | [diff] [blame] | 788 | } |
| 789 | |
| 790 | /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM |
| 791 | /// instruction, using the specified assembler variant. Targets should |
| 792 | /// overried this to format as appropriate. |
| 793 | bool AsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, |
Chris Lattner | a36cb0a | 2006-02-06 22:17:23 +0000 | [diff] [blame] | 794 | unsigned AsmVariant, const char *ExtraCode) { |
Chris Lattner | 6609913 | 2006-02-01 22:41:11 +0000 | [diff] [blame] | 795 | // Target doesn't support this yet! |
| 796 | return true; |
Chris Lattner | 0264d1a | 2006-01-27 02:10:10 +0000 | [diff] [blame] | 797 | } |
Chris Lattner | dd26033 | 2006-02-24 20:21:58 +0000 | [diff] [blame] | 798 | |
| 799 | bool AsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, |
| 800 | unsigned AsmVariant, |
| 801 | const char *ExtraCode) { |
| 802 | // Target doesn't support this yet! |
| 803 | return true; |
| 804 | } |
Nate Begeman | 37efe67 | 2006-04-22 18:53:45 +0000 | [diff] [blame] | 805 | |
| 806 | /// printBasicBlockLabel - This method prints the label for the specified |
| 807 | /// MachineBasicBlock |
Nate Begeman | cdf38c4 | 2006-05-02 05:37:32 +0000 | [diff] [blame] | 808 | void AsmPrinter::printBasicBlockLabel(const MachineBasicBlock *MBB, |
| 809 | bool printColon, |
| 810 | bool printComment) const { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 811 | O << TAI->getPrivateGlobalPrefix() << "BB" << FunctionNumber << "_" |
Nate Begeman | 9d51eeb | 2006-05-02 17:36:46 +0000 | [diff] [blame] | 812 | << MBB->getNumber(); |
Nate Begeman | cdf38c4 | 2006-05-02 05:37:32 +0000 | [diff] [blame] | 813 | if (printColon) |
| 814 | O << ':'; |
| 815 | if (printComment) |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 816 | O << '\t' << TAI->getCommentString() << MBB->getBasicBlock()->getName(); |
Nate Begeman | 37efe67 | 2006-04-22 18:53:45 +0000 | [diff] [blame] | 817 | } |
Nate Begeman | 52a51e38 | 2006-08-12 21:29:52 +0000 | [diff] [blame] | 818 | |
| 819 | /// printSetLabel - This method prints a set label for the specified |
| 820 | /// MachineBasicBlock |
| 821 | void AsmPrinter::printSetLabel(unsigned uid, |
| 822 | const MachineBasicBlock *MBB) const { |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 823 | if (!TAI->getSetDirective()) |
Nate Begeman | 52a51e38 | 2006-08-12 21:29:52 +0000 | [diff] [blame] | 824 | return; |
| 825 | |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 826 | O << TAI->getSetDirective() << ' ' << TAI->getPrivateGlobalPrefix() |
| 827 | << getFunctionNumber() << '_' << uid << "_set_" << MBB->getNumber() << ','; |
Nate Begeman | 52a51e38 | 2006-08-12 21:29:52 +0000 | [diff] [blame] | 828 | printBasicBlockLabel(MBB, false, false); |
Jim Laskey | 563321a | 2006-09-06 18:34:40 +0000 | [diff] [blame] | 829 | O << '-' << TAI->getPrivateGlobalPrefix() << "JTI" << getFunctionNumber() |
Nate Begeman | 52a51e38 | 2006-08-12 21:29:52 +0000 | [diff] [blame] | 830 | << '_' << uid << '\n'; |
| 831 | } |