Now that numbered types have their number printed, it's no longer

interesting to print the number in a comment. Numbered instructions
don't need their number in a comment either.

Also, tidy up newline printing.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78865 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2009-08-12 23:54:22 +00:00
parent a462920ae0
commit 9bf0b9bd44
8 changed files with 19 additions and 18 deletions

View File

@ -521,7 +521,8 @@ public:
/// MDNode map iterators. /// MDNode map iterators.
ValueMap::iterator mdnBegin() { return mdnMap.begin(); } ValueMap::iterator mdnBegin() { return mdnMap.begin(); }
ValueMap::iterator mdnEnd() { return mdnMap.end(); } ValueMap::iterator mdnEnd() { return mdnMap.end(); }
unsigned mdnSize() { return mdnMap.size(); } unsigned mdnSize() const { return mdnMap.size(); }
bool mdnEmpty() const { return mdnMap.empty(); }
/// This function does the actual initialization. /// This function does the actual initialization.
inline void initialize(); inline void initialize();
@ -1343,6 +1344,7 @@ void AssemblyWriter::printModule(const Module *M) {
std::string Asm = M->getModuleInlineAsm(); std::string Asm = M->getModuleInlineAsm();
size_t CurPos = 0; size_t CurPos = 0;
size_t NewLine = Asm.find_first_of('\n', CurPos); size_t NewLine = Asm.find_first_of('\n', CurPos);
Out << '\n';
while (NewLine != std::string::npos) { while (NewLine != std::string::npos) {
// We found a newline, print the portion of the asm string from the // We found a newline, print the portion of the asm string from the
// last newline up to this newline. // last newline up to this newline.
@ -1362,6 +1364,7 @@ void AssemblyWriter::printModule(const Module *M) {
Module::lib_iterator LI = M->lib_begin(); Module::lib_iterator LI = M->lib_begin();
Module::lib_iterator LE = M->lib_end(); Module::lib_iterator LE = M->lib_end();
if (LI != LE) { if (LI != LE) {
Out << '\n';
Out << "deplibs = [ "; Out << "deplibs = [ ";
while (LI != LE) { while (LI != LE) {
Out << '"' << *LI << '"'; Out << '"' << *LI << '"';
@ -1369,12 +1372,15 @@ void AssemblyWriter::printModule(const Module *M) {
if (LI != LE) if (LI != LE)
Out << ", "; Out << ", ";
} }
Out << " ]\n"; Out << " ]";
} }
// Loop over the symbol table, emitting all id'd types. // Loop over the symbol table, emitting all id'd types.
if (!M->getTypeSymbolTable().empty() || !NumberedTypes.empty()) Out << '\n';
printTypeSymbolTable(M->getTypeSymbolTable()); printTypeSymbolTable(M->getTypeSymbolTable());
// Output all globals.
if (!M->global_empty()) Out << '\n';
for (Module::const_global_iterator I = M->global_begin(), E = M->global_end(); for (Module::const_global_iterator I = M->global_begin(), E = M->global_end();
I != E; ++I) I != E; ++I)
printGlobal(I); printGlobal(I);
@ -1390,6 +1396,7 @@ void AssemblyWriter::printModule(const Module *M) {
printFunction(I); printFunction(I);
// Output named metadata. // Output named metadata.
if (!M->named_metadata_empty()) Out << '\n';
for (Module::const_named_metadata_iterator I = M->named_metadata_begin(), for (Module::const_named_metadata_iterator I = M->named_metadata_begin(),
E = M->named_metadata_end(); I != E; ++I) { E = M->named_metadata_end(); I != E; ++I) {
const NamedMDNode *NMD = I; const NamedMDNode *NMD = I;
@ -1403,6 +1410,7 @@ void AssemblyWriter::printModule(const Module *M) {
} }
// Output metadata. // Output metadata.
if (!Machine.mdnEmpty()) Out << '\n';
WriteMDNodes(Out, TypePrinter, Machine); WriteMDNodes(Out, TypePrinter, Machine);
} }
@ -1521,8 +1529,7 @@ void AssemblyWriter::printTypeSymbolTable(const TypeSymbolTable &ST) {
// Make sure we print out at least one level of the type structure, so // Make sure we print out at least one level of the type structure, so
// that we do not get %2 = type %2 // that we do not get %2 = type %2
TypePrinter.printAtLeastOneLevel(NumberedTypes[i], Out); TypePrinter.printAtLeastOneLevel(NumberedTypes[i], Out);
Out.PadToColumn(50); Out << '\n';
Out << "; type %" << i << '\n';
} }
// Print the named types. // Print the named types.
@ -1713,20 +1720,7 @@ void AssemblyWriter::printInfoComment(const Value &V) {
Out.PadToColumn(50); Out.PadToColumn(50);
Out << "; <"; Out << "; <";
TypePrinter.print(V.getType(), Out); TypePrinter.print(V.getType(), Out);
Out << '>'; Out << "> [#uses=" << V.getNumUses() << ']'; // Output # uses
if (!V.hasName() && !isa<Instruction>(V)) {
int SlotNum;
if (const GlobalValue *GV = dyn_cast<GlobalValue>(&V))
SlotNum = Machine.getGlobalSlot(GV);
else
SlotNum = Machine.getLocalSlot(&V);
if (SlotNum == -1)
Out << ":<badref>";
else
Out << ':' << SlotNum; // Print out the def slot taken.
}
Out << " [#uses=" << V.getNumUses() << ']'; // Output # uses
} }
} }

View File

@ -1,4 +1,5 @@
; ModuleID = '<stdin>' ; ModuleID = '<stdin>'
@b = constant i15 0 ; <i15*> [#uses=0] @b = constant i15 0 ; <i15*> [#uses=0]
@c = constant i15 -2 ; <i15*> [#uses=0] @c = constant i15 -2 ; <i15*> [#uses=0]
@d = constant i15 0 ; <i15*> [#uses=0] @d = constant i15 0 ; <i15*> [#uses=0]

View File

@ -1,4 +1,5 @@
; ModuleID = '<stdin>' ; ModuleID = '<stdin>'
@b = constant i17 0 ; <i17*> [#uses=0] @b = constant i17 0 ; <i17*> [#uses=0]
@c = constant i17 -2 ; <i17*> [#uses=0] @c = constant i17 -2 ; <i17*> [#uses=0]
@d = constant i17 0 ; <i17*> [#uses=0] @d = constant i17 0 ; <i17*> [#uses=0]

View File

@ -1,4 +1,5 @@
; ModuleID = '<stdin>' ; ModuleID = '<stdin>'
@b = constant i31 0 ; <i31*> [#uses=0] @b = constant i31 0 ; <i31*> [#uses=0]
@c = constant i31 -2 ; <i31*> [#uses=0] @c = constant i31 -2 ; <i31*> [#uses=0]
@d = constant i31 0 ; <i31*> [#uses=0] @d = constant i31 0 ; <i31*> [#uses=0]

View File

@ -1,4 +1,5 @@
; ModuleID = '<stdin>' ; ModuleID = '<stdin>'
@b = constant i33 0 ; <i33*> [#uses=0] @b = constant i33 0 ; <i33*> [#uses=0]
@c = constant i33 -2 ; <i33*> [#uses=0] @c = constant i33 -2 ; <i33*> [#uses=0]
@d = constant i33 0 ; <i33*> [#uses=0] @d = constant i33 0 ; <i33*> [#uses=0]

View File

@ -1,4 +1,5 @@
; ModuleID = '<stdin>' ; ModuleID = '<stdin>'
@b = constant i63 0 ; <i63*> [#uses=0] @b = constant i63 0 ; <i63*> [#uses=0]
@c = constant i63 -2 ; <i63*> [#uses=0] @c = constant i63 -2 ; <i63*> [#uses=0]
@d = constant i63 0 ; <i63*> [#uses=0] @d = constant i63 0 ; <i63*> [#uses=0]

View File

@ -1,4 +1,5 @@
; ModuleID = '<stdin>' ; ModuleID = '<stdin>'
@b = constant i7 0 ; <i7*> [#uses=0] @b = constant i7 0 ; <i7*> [#uses=0]
@q = constant i7 63 ; <i7*> [#uses=0] @q = constant i7 63 ; <i7*> [#uses=0]
@c = constant i7 -2 ; <i7*> [#uses=0] @c = constant i7 -2 ; <i7*> [#uses=0]

View File

@ -1,4 +1,5 @@
; ModuleID = '<stdin>' ; ModuleID = '<stdin>'
@b = constant i9 0 ; <i9*> [#uses=0] @b = constant i9 0 ; <i9*> [#uses=0]
@c = constant i9 -2 ; <i9*> [#uses=0] @c = constant i9 -2 ; <i9*> [#uses=0]
@d = constant i9 0 ; <i9*> [#uses=0] @d = constant i9 0 ; <i9*> [#uses=0]