diff options
author | Chris Lattner <sabre@nondot.org> | 2002-08-07 21:39:48 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2002-08-07 21:39:48 +0000 |
commit | c93df6bf2204072d316012a1b595241a6d9a4ef7 (patch) | |
tree | 29a07a61d7c58e2f7576cb1563f65a56497de35d /llvm/lib/Target/Sparc/EmitAssembly.cpp | |
parent | e64e62eff95c25ec063eafa869c86f5eb5058dff (diff) | |
download | bcm5719-llvm-c93df6bf2204072d316012a1b595241a6d9a4ef7.tar.gz bcm5719-llvm-c93df6bf2204072d316012a1b595241a6d9a4ef7.zip |
Merge three loops into one.
llvm-svn: 3259
Diffstat (limited to 'llvm/lib/Target/Sparc/EmitAssembly.cpp')
-rw-r--r-- | llvm/lib/Target/Sparc/EmitAssembly.cpp | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/llvm/lib/Target/Sparc/EmitAssembly.cpp b/llvm/lib/Target/Sparc/EmitAssembly.cpp index e58a0c2324f..c5adac29fac 100644 --- a/llvm/lib/Target/Sparc/EmitAssembly.cpp +++ b/llvm/lib/Target/Sparc/EmitAssembly.cpp @@ -777,32 +777,27 @@ void SparcModuleAsmPrinter::emitGlobalsAndConstants(const Module &M) { hash_set<const Constant*> moduleConstants; FoldConstants(M, moduleConstants); - // Now, emit the three data sections separately; the cost of I/O should - // make up for the cost of extra passes over the globals list! - - // Section 1 : Read-only data section (implies initialized) + // Output constants spilled to memory enterSection(AsmPrinter::ReadOnlyData); - for (Module::const_giterator GI = M.gbegin(), GE = M.gend(); GI != GE; ++GI) - if (GI->hasInitializer() && GI->isConstant()) - printGlobalVariable(GI); - - for (hash_set<const Constant*>::const_iterator - I = moduleConstants.begin(), + for (hash_set<const Constant*>::const_iterator I = moduleConstants.begin(), E = moduleConstants.end(); I != E; ++I) printConstant(*I); - - // Section 2 : Initialized read-write data section - enterSection(AsmPrinter::InitRWData); - for (Module::const_giterator GI = M.gbegin(), GE = M.gend(); GI != GE; ++GI) - if (GI->hasInitializer() && !GI->isConstant()) - printGlobalVariable(GI); - - // Section 3 : Uninitialized read-write data section - enterSection(AsmPrinter::UninitRWData); - for (Module::const_giterator GI = M.gbegin(), GE = M.gend(); GI != GE; ++GI) - if (!GI->hasInitializer()) - printGlobalVariable(GI); - + + // Output global variables... + for (Module::const_giterator GI = M.gbegin(), GE = M.gend(); GI != GE; ++GI) { + if (GI->hasInitializer() && GI->isConstant()) { + enterSection(AsmPrinter::ReadOnlyData); // read-only, initialized data + } else if (GI->hasInitializer() && !GI->isConstant()) { // read-write data + enterSection(AsmPrinter::ReadOnlyData); // read-only, initialized data + } else if (GI->hasInitializer() && !GI->isConstant()) { // read-write data + enterSection(AsmPrinter::InitRWData); + } else { + assert (!GI->hasInitializer() && "Unexpected global variable type found"); + enterSection(AsmPrinter::UninitRWData); // Uninitialized data + } + printGlobalVariable(GI); + } + toAsm << "\n"; } |