aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-04-13 20:53:41 +0000
committerChris Lattner <sabre@nondot.org>2002-04-13 20:53:41 +0000
commit2761e9f076bbe6c961629aece62db4b836a41ef8 (patch)
tree61a34604977cc9bcde2da99855f601c670a74d9e /lib/VMCore
parentddcbd34f566e1b3cb1e91cab128703cf9d13136d (diff)
downloadexternal_llvm-2761e9f076bbe6c961629aece62db4b836a41ef8.zip
external_llvm-2761e9f076bbe6c961629aece62db4b836a41ef8.tar.gz
external_llvm-2761e9f076bbe6c961629aece62db4b836a41ef8.tar.bz2
* Remove obselete code for unsized arrays
* Add new function printTypeAtLeastOneLevel used to... * Print the symbol table *WITH SYMBOLIC TYPES*. Now we get: %tree = type { int, %tree*, %tree* } in the type definition section of the disassembled output instead of %tree = type { int, \2*, \2* } the different for the health benchmark and power are simply amazing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2240 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r--lib/VMCore/AsmWriter.cpp87
1 files changed, 67 insertions, 20 deletions
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index aa11d81..7d535e3 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -151,17 +151,17 @@ static string calcTypeName(const Type *Ty, vector<const Type *> &TypeStack,
string Result;
switch (Ty->getPrimitiveID()) {
case Type::FunctionTyID: {
- const FunctionType *MTy = cast<const FunctionType>(Ty);
- Result = calcTypeName(MTy->getReturnType(), TypeStack, TypeNames) + " (";
+ const FunctionType *FTy = cast<const FunctionType>(Ty);
+ Result = calcTypeName(FTy->getReturnType(), TypeStack, TypeNames) + " (";
for (FunctionType::ParamTypes::const_iterator
- I = MTy->getParamTypes().begin(),
- E = MTy->getParamTypes().end(); I != E; ++I) {
- if (I != MTy->getParamTypes().begin())
+ I = FTy->getParamTypes().begin(),
+ E = FTy->getParamTypes().end(); I != E; ++I) {
+ if (I != FTy->getParamTypes().begin())
Result += ", ";
Result += calcTypeName(*I, TypeStack, TypeNames);
}
- if (MTy->isVarArg()) {
- if (!MTy->getParamTypes().empty()) Result += ", ";
+ if (FTy->isVarArg()) {
+ if (!FTy->getParamTypes().empty()) Result += ", ";
Result += "...";
}
Result += ")";
@@ -186,9 +186,7 @@ static string calcTypeName(const Type *Ty, vector<const Type *> &TypeStack,
break;
case Type::ArrayTyID: {
const ArrayType *ATy = cast<const ArrayType>(Ty);
- int NumElements = ATy->getNumElements();
- Result = "[";
- if (NumElements != -1) Result += itostr(NumElements) + " x ";
+ Result = "[" + itostr(ATy->getNumElements()) + " x ";
Result += calcTypeName(ATy->getElementType(), TypeStack, TypeNames) + "]";
break;
}
@@ -294,7 +292,18 @@ private :
void printArgument(const Argument *FA);
void printBasicBlock(const BasicBlock *BB);
void printInstruction(const Instruction *I);
- ostream &printType(const Type *Ty);
+
+ // printType - Go to extreme measures to attempt to print out a short,
+ // symbolic version of a type name.
+ //
+ ostream &printType(const Type *Ty) {
+ return printTypeInt(Out, Ty, TypeNames);
+ }
+
+ // printTypeAtLeastOneLevel - Print out one level of the possibly complex type
+ // without considering any symbolic types that we may have equal to it.
+ //
+ ostream &printTypeAtLeastOneLevel(const Type *Ty);
void writeOperand(const Value *Op, bool PrintType, bool PrintName = true);
@@ -304,6 +313,47 @@ private :
};
+// printTypeAtLeastOneLevel - Print out one level of the possibly complex type
+// without considering any symbolic types that we may have equal to it.
+//
+ostream &AssemblyWriter::printTypeAtLeastOneLevel(const Type *Ty) {
+ if (FunctionType *FTy = dyn_cast<FunctionType>(Ty)) {
+ printType(FTy->getReturnType()) << " (";
+ for (FunctionType::ParamTypes::const_iterator
+ I = FTy->getParamTypes().begin(),
+ E = FTy->getParamTypes().end(); I != E; ++I) {
+ if (I != FTy->getParamTypes().begin())
+ Out << ", ";
+ Out << printType(*I);
+ }
+ if (FTy->isVarArg()) {
+ if (!FTy->getParamTypes().empty()) Out << ", ";
+ Out << "...";
+ }
+ Out << ")";
+ } else if (StructType *STy = dyn_cast<StructType>(Ty)) {
+ Out << "{ ";
+ for (StructType::ElementTypes::const_iterator
+ I = STy->getElementTypes().begin(),
+ E = STy->getElementTypes().end(); I != E; ++I) {
+ if (I != STy->getElementTypes().begin())
+ Out << ", ";
+ printType(*I);
+ }
+ Out << " }";
+ } else if (PointerType *PTy = dyn_cast<PointerType>(Ty)) {
+ printType(PTy->getElementType()) << "*";
+ } else if (ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
+ Out << "[" << ATy->getNumElements() << " x ";
+ printType(ATy->getElementType()) << "]";
+ } else {
+ assert(Ty->isPrimitiveType() && "Unknown derived type!");
+ printType(Ty);
+ }
+ return Out;
+}
+
+
void AssemblyWriter::writeOperand(const Value *Operand, bool PrintType,
bool PrintName) {
if (PrintType) { Out << " "; printType(Operand->getType()); }
@@ -355,7 +405,12 @@ void AssemblyWriter::printSymbolTable(const SymbolTable &ST) {
if (const Constant *CPV = dyn_cast<const Constant>(V)) {
printConstant(CPV);
} else if (const Type *Ty = dyn_cast<const Type>(V)) {
- Out << "\t%" << I->first << " = type " << Ty->getDescription() << "\n";
+ Out << "\t%" << I->first << " = type ";
+
+ // Make sure we print out at least one level of the type structure, so
+ // that we do not get %FILE = type %FILE
+ //
+ printTypeAtLeastOneLevel(Ty) << "\n";
}
}
}
@@ -625,14 +680,6 @@ void AssemblyWriter::printInstruction(const Instruction *I) {
}
-// printType - Go to extreme measures to attempt to print out a short, symbolic
-// version of a type name.
-//
-ostream &AssemblyWriter::printType(const Type *Ty) {
- return printTypeInt(Out, Ty, TypeNames);
-}
-
-
//===----------------------------------------------------------------------===//
// External Interface declarations
//===----------------------------------------------------------------------===//