mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-28 08:59:28 +00:00
Another change that doesn't affect functionality. Since we are only looking
at types in the symbol table, only traverse the type plane, saving a loop nest. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3858 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2c601a7be1
commit
2db41cd5de
@ -566,29 +566,31 @@ void CWriter::printModule(Module *M) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// printSymbolTable - Run through symbol table looking for named constants
|
/// printSymbolTable - Run through symbol table looking for type names. If a
|
||||||
/// if a named constant is found, emit it's declaration...
|
/// type name is found, emit it's declaration...
|
||||||
/// Assuming that symbol table has only types and constants.
|
|
||||||
///
|
///
|
||||||
void CWriter::printSymbolTable(const SymbolTable &ST) {
|
void CWriter::printSymbolTable(const SymbolTable &ST) {
|
||||||
for (SymbolTable::const_iterator TI = ST.begin(); TI != ST.end(); ++TI) {
|
// If there are no type names, exit early.
|
||||||
SymbolTable::type_const_iterator I = ST.type_begin(TI->first);
|
if (ST.find(Type::TypeTy) == ST.end())
|
||||||
SymbolTable::type_const_iterator End = ST.type_end(TI->first);
|
return;
|
||||||
|
|
||||||
for (; I != End; ++I) {
|
// We are only interested in the type plane of the symbol table...
|
||||||
const Value *V = I->second;
|
SymbolTable::type_const_iterator I = ST.type_begin(Type::TypeTy);
|
||||||
if (const Type *Ty = dyn_cast<Type>(V))
|
SymbolTable::type_const_iterator End = ST.type_end(Type::TypeTy);
|
||||||
if (const Type *STy = dyn_cast<StructType>(Ty)) {
|
|
||||||
string Name = "struct l_" + makeNameProper(I->first);
|
for (; I != End; ++I) {
|
||||||
Out << Name << ";\n";
|
const Value *V = I->second;
|
||||||
TypeNames.insert(std::make_pair(STy, Name));
|
if (const Type *Ty = dyn_cast<Type>(V))
|
||||||
} else {
|
if (const Type *STy = dyn_cast<StructType>(Ty)) {
|
||||||
string Name = "l_" + makeNameProper(I->first);
|
string Name = "struct l_" + makeNameProper(I->first);
|
||||||
Out << "typedef ";
|
Out << Name << ";\n";
|
||||||
printType(Ty, Name, true);
|
TypeNames.insert(std::make_pair(STy, Name));
|
||||||
Out << ";\n";
|
} else {
|
||||||
}
|
string Name = "l_" + makeNameProper(I->first);
|
||||||
}
|
Out << "typedef ";
|
||||||
|
printType(Ty, Name, true);
|
||||||
|
Out << ";\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Out << "\n";
|
Out << "\n";
|
||||||
@ -598,14 +600,10 @@ void CWriter::printSymbolTable(const SymbolTable &ST) {
|
|||||||
|
|
||||||
// Loop over all structures then push them into the stack so they are
|
// Loop over all structures then push them into the stack so they are
|
||||||
// printed in the correct order.
|
// printed in the correct order.
|
||||||
for (SymbolTable::const_iterator TI = ST.begin(); TI != ST.end(); ++TI) {
|
//
|
||||||
SymbolTable::type_const_iterator I = ST.type_begin(TI->first);
|
for (I = ST.type_begin(Type::TypeTy); I != End; ++I)
|
||||||
SymbolTable::type_const_iterator End = ST.type_end(TI->first);
|
if (const StructType *STy = dyn_cast<StructType>(I->second))
|
||||||
|
printContainedStructs(STy, StructPrinted);
|
||||||
for (; I != End; ++I)
|
|
||||||
if (const StructType *STy = dyn_cast<StructType>(I->second))
|
|
||||||
printContainedStructs(STy, StructPrinted);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push the struct onto the stack and recursively push all structs
|
// Push the struct onto the stack and recursively push all structs
|
||||||
|
@ -566,29 +566,31 @@ void CWriter::printModule(Module *M) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// printSymbolTable - Run through symbol table looking for named constants
|
/// printSymbolTable - Run through symbol table looking for type names. If a
|
||||||
/// if a named constant is found, emit it's declaration...
|
/// type name is found, emit it's declaration...
|
||||||
/// Assuming that symbol table has only types and constants.
|
|
||||||
///
|
///
|
||||||
void CWriter::printSymbolTable(const SymbolTable &ST) {
|
void CWriter::printSymbolTable(const SymbolTable &ST) {
|
||||||
for (SymbolTable::const_iterator TI = ST.begin(); TI != ST.end(); ++TI) {
|
// If there are no type names, exit early.
|
||||||
SymbolTable::type_const_iterator I = ST.type_begin(TI->first);
|
if (ST.find(Type::TypeTy) == ST.end())
|
||||||
SymbolTable::type_const_iterator End = ST.type_end(TI->first);
|
return;
|
||||||
|
|
||||||
for (; I != End; ++I) {
|
// We are only interested in the type plane of the symbol table...
|
||||||
const Value *V = I->second;
|
SymbolTable::type_const_iterator I = ST.type_begin(Type::TypeTy);
|
||||||
if (const Type *Ty = dyn_cast<Type>(V))
|
SymbolTable::type_const_iterator End = ST.type_end(Type::TypeTy);
|
||||||
if (const Type *STy = dyn_cast<StructType>(Ty)) {
|
|
||||||
string Name = "struct l_" + makeNameProper(I->first);
|
for (; I != End; ++I) {
|
||||||
Out << Name << ";\n";
|
const Value *V = I->second;
|
||||||
TypeNames.insert(std::make_pair(STy, Name));
|
if (const Type *Ty = dyn_cast<Type>(V))
|
||||||
} else {
|
if (const Type *STy = dyn_cast<StructType>(Ty)) {
|
||||||
string Name = "l_" + makeNameProper(I->first);
|
string Name = "struct l_" + makeNameProper(I->first);
|
||||||
Out << "typedef ";
|
Out << Name << ";\n";
|
||||||
printType(Ty, Name, true);
|
TypeNames.insert(std::make_pair(STy, Name));
|
||||||
Out << ";\n";
|
} else {
|
||||||
}
|
string Name = "l_" + makeNameProper(I->first);
|
||||||
}
|
Out << "typedef ";
|
||||||
|
printType(Ty, Name, true);
|
||||||
|
Out << ";\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Out << "\n";
|
Out << "\n";
|
||||||
@ -598,14 +600,10 @@ void CWriter::printSymbolTable(const SymbolTable &ST) {
|
|||||||
|
|
||||||
// Loop over all structures then push them into the stack so they are
|
// Loop over all structures then push them into the stack so they are
|
||||||
// printed in the correct order.
|
// printed in the correct order.
|
||||||
for (SymbolTable::const_iterator TI = ST.begin(); TI != ST.end(); ++TI) {
|
//
|
||||||
SymbolTable::type_const_iterator I = ST.type_begin(TI->first);
|
for (I = ST.type_begin(Type::TypeTy); I != End; ++I)
|
||||||
SymbolTable::type_const_iterator End = ST.type_end(TI->first);
|
if (const StructType *STy = dyn_cast<StructType>(I->second))
|
||||||
|
printContainedStructs(STy, StructPrinted);
|
||||||
for (; I != End; ++I)
|
|
||||||
if (const StructType *STy = dyn_cast<StructType>(I->second))
|
|
||||||
printContainedStructs(STy, StructPrinted);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Push the struct onto the stack and recursively push all structs
|
// Push the struct onto the stack and recursively push all structs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user