* Add ability to print out type as symbolic

* Add Module accessor to AssemblyWriter


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@13227 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Misha Brukman 2004-04-28 15:31:21 +00:00
parent 3f98def801
commit 5cf1acff3c

View File

@ -26,8 +26,9 @@
#include "llvm/iPHINode.h" #include "llvm/iPHINode.h"
#include "llvm/iOther.h" #include "llvm/iOther.h"
#include "llvm/Module.h" #include "llvm/Module.h"
#include "llvm/Analysis/SlotCalculator.h"
#include "llvm/SymbolTable.h" #include "llvm/SymbolTable.h"
#include "llvm/Analysis/SlotCalculator.h"
#include "llvm/Assembly/Writer.h"
#include "llvm/Support/CFG.h" #include "llvm/Support/CFG.h"
#include "Support/StringExtras.h" #include "Support/StringExtras.h"
#include "Support/STLExtras.h" #include "Support/STLExtras.h"
@ -474,6 +475,8 @@ public:
void writeOperand(const Value *Op, bool PrintType, bool PrintName = true); void writeOperand(const Value *Op, bool PrintType, bool PrintName = true);
const Module* getModule() { return TheModule; }
private : private :
void printModule(const Module *M); void printModule(const Module *M);
void printSymbolTable(const SymbolTable &ST); void printSymbolTable(const SymbolTable &ST);
@ -1019,7 +1022,7 @@ void CachedWriter::setModule(const Module *M) {
delete SC; delete AW; delete SC; delete AW;
if (M) { if (M) {
SC = new SlotCalculator(M, false); SC = new SlotCalculator(M, false);
AW = new AssemblyWriter(Out, *SC, M, 0); AW = new AssemblyWriter(*Out, *SC, M, 0);
} else { } else {
SC = 0; AW = 0; SC = 0; AW = 0;
} }
@ -1040,7 +1043,16 @@ CachedWriter &CachedWriter::operator<<(const Value *V) {
case Value::BasicBlockVal: AW->write(cast<BasicBlock>(V)); break; case Value::BasicBlockVal: AW->write(cast<BasicBlock>(V)); break;
case Value::FunctionVal: AW->write(cast<Function>(V)); break; case Value::FunctionVal: AW->write(cast<Function>(V)); break;
case Value::GlobalVariableVal: AW->write(cast<GlobalVariable>(V)); break; case Value::GlobalVariableVal: AW->write(cast<GlobalVariable>(V)); break;
default: Out << "<unknown value type: " << V->getValueType() << ">"; break; default: *Out << "<unknown value type: " << V->getValueType() << ">"; break;
} }
return *this; return *this;
} }
CachedWriter& CachedWriter::operator<<(const Type *X) {
if (SymbolicTypes) {
const Module *M = AW->getModule();
if (M) WriteTypeSymbolic(*Out, X, M);
return *this;
} else
return *this << (const Value*)X;
}