Since this really only makes sense for these two, change hte instance variable
to reflect whether we are writing a bytecode file or not. This makes it
reasonable to add bcwriter specific stuff to it as necessary.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10837
91177308-0d34-0410-b5e6-
96231b3b80d8
class SlotCalculator {
const Module *TheModule;
class SlotCalculator {
const Module *TheModule;
- bool IgnoreNamedNodes; // Shall we not count named nodes?
+
+ // BuildBytecodeInfo - If true, this is the creating information for the
+ // bytecode writer, if false, we are building information for the assembly
+ // emitter. The assembly emitter doesn't need named objects numbered, among
+ // other differences.
+ bool BuildBytecodeInfo;
typedef std::vector<const Value*> TypePlane;
std::vector<TypePlane> Table;
typedef std::vector<const Value*> TypePlane;
std::vector<TypePlane> Table;
std::vector<unsigned> ModuleLevel;
public:
std::vector<unsigned> ModuleLevel;
public:
- SlotCalculator(const Module *M, bool IgnoreNamed);
+ SlotCalculator(const Module *M, bool BuildBytecodeInfo);
// Start out in incorp state
// Start out in incorp state
- SlotCalculator(const Function *M, bool IgnoreNamed);
+ SlotCalculator(const Function *M, bool BuildBytecodeInfo);
inline ~SlotCalculator() {}
// getSlot returns < 0 on error!
inline ~SlotCalculator() {}
// getSlot returns < 0 on error!
class SlotCalculator {
const Module *TheModule;
class SlotCalculator {
const Module *TheModule;
- bool IgnoreNamedNodes; // Shall we not count named nodes?
+
+ // BuildBytecodeInfo - If true, this is the creating information for the
+ // bytecode writer, if false, we are building information for the assembly
+ // emitter. The assembly emitter doesn't need named objects numbered, among
+ // other differences.
+ bool BuildBytecodeInfo;
typedef std::vector<const Value*> TypePlane;
std::vector<TypePlane> Table;
typedef std::vector<const Value*> TypePlane;
std::vector<TypePlane> Table;
std::vector<unsigned> ModuleLevel;
public:
std::vector<unsigned> ModuleLevel;
public:
- SlotCalculator(const Module *M, bool IgnoreNamed);
+ SlotCalculator(const Module *M, bool BuildBytecodeInfo);
// Start out in incorp state
// Start out in incorp state
- SlotCalculator(const Function *M, bool IgnoreNamed);
+ SlotCalculator(const Function *M, bool BuildBytecodeInfo);
inline ~SlotCalculator() {}
// getSlot returns < 0 on error!
inline ~SlotCalculator() {}
// getSlot returns < 0 on error!
#define SC_DEBUG(X)
#endif
#define SC_DEBUG(X)
#endif
-SlotCalculator::SlotCalculator(const Module *M, bool IgnoreNamed) {
- IgnoreNamedNodes = IgnoreNamed;
+SlotCalculator::SlotCalculator(const Module *M, bool buildBytecodeInfo) {
+ BuildBytecodeInfo = buildBytecodeInfo;
TheModule = M;
// Preload table... Make sure that all of the primitive types are in the table
TheModule = M;
// Preload table... Make sure that all of the primitive types are in the table
-SlotCalculator::SlotCalculator(const Function *M, bool IgnoreNamed) {
- IgnoreNamedNodes = IgnoreNamed;
+SlotCalculator::SlotCalculator(const Function *M, bool buildBytecodeInfo) {
+ BuildBytecodeInfo = buildBytecodeInfo;
TheModule = M ? M->getParent() : 0;
// Preload table... Make sure that all of the primitive types are in the table
TheModule = M ? M->getParent() : 0;
// Preload table... Make sure that all of the primitive types are in the table
// constants, which allows us to emit more compact modules. This is optional,
// and is just used to compactify the constants used by different functions
// together.
// constants, which allows us to emit more compact modules. This is optional,
// and is just used to compactify the constants used by different functions
// together.
- if (!IgnoreNamedNodes) {
+ if (BuildBytecodeInfo) {
SC_DEBUG("Inserting function constants:\n");
for (Module::const_iterator F = TheModule->begin(), E = TheModule->end();
F != E; ++F)
SC_DEBUG("Inserting function constants:\n");
for (Module::const_iterator F = TheModule->begin(), E = TheModule->end();
F != E; ++F)
// Insert constants that are named at module level into the slot pool so that
// the module symbol table can refer to them...
//
// Insert constants that are named at module level into the slot pool so that
// the module symbol table can refer to them...
//
- if (!IgnoreNamedNodes) {
+ if (BuildBytecodeInfo) {
SC_DEBUG("Inserting SymbolTable values:\n");
processSymbolTable(&TheModule->getSymbolTable());
}
SC_DEBUG("Inserting SymbolTable values:\n");
processSymbolTable(&TheModule->getSymbolTable());
}
// all non-value types are pushed to the end of the type table, giving nice
// low numbers to the types that can be used by instructions, thus reducing
// the amount of explodage we suffer.
// all non-value types are pushed to the end of the type table, giving nice
// low numbers to the types that can be used by instructions, thus reducing
// the amount of explodage we suffer.
- if (!IgnoreNamedNodes && Table[Type::TypeTyID].size() >= 64) {
+ if (BuildBytecodeInfo && Table[Type::TypeTyID].size() >= 64) {
// Scan through the type table moving value types to the start of the table.
TypePlane *Types = &Table[Type::TypeTyID];
unsigned FirstNonValueTypeID = 0;
// Scan through the type table moving value types to the start of the table.
TypePlane *Types = &Table[Type::TypeTyID];
unsigned FirstNonValueTypeID = 0;
// nonconstant values. This will be turned into the constant pool for the
// bytecode writer.
//
// nonconstant values. This will be turned into the constant pool for the
// bytecode writer.
//
- if (!IgnoreNamedNodes) { // Assembly writer does not need this!
+ if (BuildBytecodeInfo) { // Assembly writer does not need this!
SC_DEBUG("Inserting function constants:\n";
for (constant_iterator I = constant_begin(F), E = constant_end(F);
I != E; ++I) {
SC_DEBUG("Inserting function constants:\n";
for (constant_iterator I = constant_begin(F), E = constant_end(F);
I != E; ++I) {
getOrCreateSlot(VAN->getArgType());
}
getOrCreateSlot(VAN->getArgType());
}
- if (!IgnoreNamedNodes) {
+ if (BuildBytecodeInfo) {
SC_DEBUG("Inserting SymbolTable values:\n");
processSymbolTable(&F->getSymbolTable());
}
SC_DEBUG("Inserting SymbolTable values:\n");
processSymbolTable(&F->getSymbolTable());
}
//
if (!dontIgnore) // Don't ignore nonignorables!
if (D->getType() == Type::VoidTy || // Ignore void type nodes
//
if (!dontIgnore) // Don't ignore nonignorables!
if (D->getType() == Type::VoidTy || // Ignore void type nodes
- (IgnoreNamedNodes && // Ignore named and constants
+ (!BuildBytecodeInfo && // Ignore named and constants
(D->hasName() || isa<Constant>(D)) && !isa<Type>(D))) {
SC_DEBUG("ignored value " << *D << "\n");
return -1; // We do need types unconditionally though
(D->hasName() || isa<Constant>(D)) && !isa<Type>(D))) {
SC_DEBUG("ignored value " << *D << "\n");
return -1; // We do need types unconditionally though
// If this is the first value to get inserted into the type plane, make sure
// to insert the implicit null value...
// If this is the first value to get inserted into the type plane, make sure
// to insert the implicit null value...
- if (Table[Ty].empty() && Ty >= Type::FirstDerivedTyID && !IgnoreNamedNodes) {
+ if (Table[Ty].empty() && Ty >= Type::FirstDerivedTyID && BuildBytecodeInfo) {
Value *ZeroInitializer = Constant::getNullValue(Typ);
// If we are pushing zeroinit, it will be handled below.
Value *ZeroInitializer = Constant::getNullValue(Typ);
// If we are pushing zeroinit, it will be handled below.
class SlotCalculator {
const Module *TheModule;
class SlotCalculator {
const Module *TheModule;
- bool IgnoreNamedNodes; // Shall we not count named nodes?
+
+ // BuildBytecodeInfo - If true, this is the creating information for the
+ // bytecode writer, if false, we are building information for the assembly
+ // emitter. The assembly emitter doesn't need named objects numbered, among
+ // other differences.
+ bool BuildBytecodeInfo;
typedef std::vector<const Value*> TypePlane;
std::vector<TypePlane> Table;
typedef std::vector<const Value*> TypePlane;
std::vector<TypePlane> Table;
std::vector<unsigned> ModuleLevel;
public:
std::vector<unsigned> ModuleLevel;
public:
- SlotCalculator(const Module *M, bool IgnoreNamed);
+ SlotCalculator(const Module *M, bool BuildBytecodeInfo);
// Start out in incorp state
// Start out in incorp state
- SlotCalculator(const Function *M, bool IgnoreNamed);
+ SlotCalculator(const Function *M, bool BuildBytecodeInfo);
inline ~SlotCalculator() {}
// getSlot returns < 0 on error!
inline ~SlotCalculator() {}
// getSlot returns < 0 on error!
static SlotCalculator *createSlotCalculator(const Value *V) {
assert(!isa<Type>(V) && "Can't create an SC for a type!");
if (const Argument *FA = dyn_cast<Argument>(V)) {
static SlotCalculator *createSlotCalculator(const Value *V) {
assert(!isa<Type>(V) && "Can't create an SC for a type!");
if (const Argument *FA = dyn_cast<Argument>(V)) {
- return new SlotCalculator(FA->getParent(), true);
+ return new SlotCalculator(FA->getParent(), false);
} else if (const Instruction *I = dyn_cast<Instruction>(V)) {
} else if (const Instruction *I = dyn_cast<Instruction>(V)) {
- return new SlotCalculator(I->getParent()->getParent(), true);
+ return new SlotCalculator(I->getParent()->getParent(), false);
} else if (const BasicBlock *BB = dyn_cast<BasicBlock>(V)) {
} else if (const BasicBlock *BB = dyn_cast<BasicBlock>(V)) {
- return new SlotCalculator(BB->getParent(), true);
+ return new SlotCalculator(BB->getParent(), false);
} else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V)){
} else if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V)){
- return new SlotCalculator(GV->getParent(), true);
+ return new SlotCalculator(GV->getParent(), false);
} else if (const Function *Func = dyn_cast<Function>(V)) {
} else if (const Function *Func = dyn_cast<Function>(V)) {
- return new SlotCalculator(Func, true);
+ return new SlotCalculator(Func, false);
void CachedWriter::setModule(const Module *M) {
delete SC; delete AW;
if (M) {
void CachedWriter::setModule(const Module *M) {
delete SC; delete AW;
if (M) {
- SC = new SlotCalculator(M, true);
+ SC = new SlotCalculator(M, false);
AW = new AssemblyWriter(Out, *SC, M, 0);
} else {
SC = 0; AW = 0;
AW = new AssemblyWriter(Out, *SC, M, 0);
} else {
SC = 0; AW = 0;
#define SC_DEBUG(X)
#endif
#define SC_DEBUG(X)
#endif
-SlotCalculator::SlotCalculator(const Module *M, bool IgnoreNamed) {
- IgnoreNamedNodes = IgnoreNamed;
+SlotCalculator::SlotCalculator(const Module *M, bool buildBytecodeInfo) {
+ BuildBytecodeInfo = buildBytecodeInfo;
TheModule = M;
// Preload table... Make sure that all of the primitive types are in the table
TheModule = M;
// Preload table... Make sure that all of the primitive types are in the table
-SlotCalculator::SlotCalculator(const Function *M, bool IgnoreNamed) {
- IgnoreNamedNodes = IgnoreNamed;
+SlotCalculator::SlotCalculator(const Function *M, bool buildBytecodeInfo) {
+ BuildBytecodeInfo = buildBytecodeInfo;
TheModule = M ? M->getParent() : 0;
// Preload table... Make sure that all of the primitive types are in the table
TheModule = M ? M->getParent() : 0;
// Preload table... Make sure that all of the primitive types are in the table
// constants, which allows us to emit more compact modules. This is optional,
// and is just used to compactify the constants used by different functions
// together.
// constants, which allows us to emit more compact modules. This is optional,
// and is just used to compactify the constants used by different functions
// together.
- if (!IgnoreNamedNodes) {
+ if (BuildBytecodeInfo) {
SC_DEBUG("Inserting function constants:\n");
for (Module::const_iterator F = TheModule->begin(), E = TheModule->end();
F != E; ++F)
SC_DEBUG("Inserting function constants:\n");
for (Module::const_iterator F = TheModule->begin(), E = TheModule->end();
F != E; ++F)
// Insert constants that are named at module level into the slot pool so that
// the module symbol table can refer to them...
//
// Insert constants that are named at module level into the slot pool so that
// the module symbol table can refer to them...
//
- if (!IgnoreNamedNodes) {
+ if (BuildBytecodeInfo) {
SC_DEBUG("Inserting SymbolTable values:\n");
processSymbolTable(&TheModule->getSymbolTable());
}
SC_DEBUG("Inserting SymbolTable values:\n");
processSymbolTable(&TheModule->getSymbolTable());
}
// all non-value types are pushed to the end of the type table, giving nice
// low numbers to the types that can be used by instructions, thus reducing
// the amount of explodage we suffer.
// all non-value types are pushed to the end of the type table, giving nice
// low numbers to the types that can be used by instructions, thus reducing
// the amount of explodage we suffer.
- if (!IgnoreNamedNodes && Table[Type::TypeTyID].size() >= 64) {
+ if (BuildBytecodeInfo && Table[Type::TypeTyID].size() >= 64) {
// Scan through the type table moving value types to the start of the table.
TypePlane *Types = &Table[Type::TypeTyID];
unsigned FirstNonValueTypeID = 0;
// Scan through the type table moving value types to the start of the table.
TypePlane *Types = &Table[Type::TypeTyID];
unsigned FirstNonValueTypeID = 0;
// nonconstant values. This will be turned into the constant pool for the
// bytecode writer.
//
// nonconstant values. This will be turned into the constant pool for the
// bytecode writer.
//
- if (!IgnoreNamedNodes) { // Assembly writer does not need this!
+ if (BuildBytecodeInfo) { // Assembly writer does not need this!
SC_DEBUG("Inserting function constants:\n";
for (constant_iterator I = constant_begin(F), E = constant_end(F);
I != E; ++I) {
SC_DEBUG("Inserting function constants:\n";
for (constant_iterator I = constant_begin(F), E = constant_end(F);
I != E; ++I) {
getOrCreateSlot(VAN->getArgType());
}
getOrCreateSlot(VAN->getArgType());
}
- if (!IgnoreNamedNodes) {
+ if (BuildBytecodeInfo) {
SC_DEBUG("Inserting SymbolTable values:\n");
processSymbolTable(&F->getSymbolTable());
}
SC_DEBUG("Inserting SymbolTable values:\n");
processSymbolTable(&F->getSymbolTable());
}
//
if (!dontIgnore) // Don't ignore nonignorables!
if (D->getType() == Type::VoidTy || // Ignore void type nodes
//
if (!dontIgnore) // Don't ignore nonignorables!
if (D->getType() == Type::VoidTy || // Ignore void type nodes
- (IgnoreNamedNodes && // Ignore named and constants
+ (!BuildBytecodeInfo && // Ignore named and constants
(D->hasName() || isa<Constant>(D)) && !isa<Type>(D))) {
SC_DEBUG("ignored value " << *D << "\n");
return -1; // We do need types unconditionally though
(D->hasName() || isa<Constant>(D)) && !isa<Type>(D))) {
SC_DEBUG("ignored value " << *D << "\n");
return -1; // We do need types unconditionally though
// If this is the first value to get inserted into the type plane, make sure
// to insert the implicit null value...
// If this is the first value to get inserted into the type plane, make sure
// to insert the implicit null value...
- if (Table[Ty].empty() && Ty >= Type::FirstDerivedTyID && !IgnoreNamedNodes) {
+ if (Table[Ty].empty() && Ty >= Type::FirstDerivedTyID && BuildBytecodeInfo) {
Value *ZeroInitializer = Constant::getNullValue(Typ);
// If we are pushing zeroinit, it will be handled below.
Value *ZeroInitializer = Constant::getNullValue(Typ);
// If we are pushing zeroinit, it will be handled below.