mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
When emitting a single function with cppgen=function, you don't want to emit
initializers of global variables used in the function. Also make sure to emit the operands of a constant. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@120253 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ea4afa91eb
commit
7509ccda93
@ -1564,11 +1564,25 @@ void CppWriter::printFunctionUses(const Function* F) {
|
|||||||
// If the operand references a GVal or Constant, make a note of it
|
// If the operand references a GVal or Constant, make a note of it
|
||||||
if (GlobalValue* GV = dyn_cast<GlobalValue>(operand)) {
|
if (GlobalValue* GV = dyn_cast<GlobalValue>(operand)) {
|
||||||
gvs.insert(GV);
|
gvs.insert(GV);
|
||||||
|
if (GenerationType != GenFunction)
|
||||||
if (GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV))
|
if (GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV))
|
||||||
if (GVar->hasInitializer())
|
if (GVar->hasInitializer())
|
||||||
consts.insert(GVar->getInitializer());
|
consts.insert(GVar->getInitializer());
|
||||||
} else if (Constant* C = dyn_cast<Constant>(operand))
|
} else if (Constant* C = dyn_cast<Constant>(operand)) {
|
||||||
consts.insert(C);
|
consts.insert(C);
|
||||||
|
for (unsigned j = 0; j < C->getNumOperands(); ++j) {
|
||||||
|
// If the operand references a GVal or Constant, make a note of it
|
||||||
|
Value* operand = C->getOperand(j);
|
||||||
|
printType(operand->getType());
|
||||||
|
if (GlobalValue* GV = dyn_cast<GlobalValue>(operand)) {
|
||||||
|
gvs.insert(GV);
|
||||||
|
if (GenerationType != GenFunction)
|
||||||
|
if (GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV))
|
||||||
|
if (GVar->hasInitializer())
|
||||||
|
consts.insert(GVar->getInitializer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1601,6 +1615,7 @@ void CppWriter::printFunctionUses(const Function* F) {
|
|||||||
// Process the global variables definitions now that all the constants have
|
// Process the global variables definitions now that all the constants have
|
||||||
// been emitted. These definitions just couple the gvars with their constant
|
// been emitted. These definitions just couple the gvars with their constant
|
||||||
// initializers.
|
// initializers.
|
||||||
|
if (GenerationType != GenFunction) {
|
||||||
nl(Out) << "// Global Variable Definitions"; nl(Out);
|
nl(Out) << "// Global Variable Definitions"; nl(Out);
|
||||||
for (SmallPtrSet<GlobalValue*,64>::iterator I = gvs.begin(), E = gvs.end();
|
for (SmallPtrSet<GlobalValue*,64>::iterator I = gvs.begin(), E = gvs.end();
|
||||||
I != E; ++I) {
|
I != E; ++I) {
|
||||||
@ -1608,6 +1623,7 @@ void CppWriter::printFunctionUses(const Function* F) {
|
|||||||
printVariableBody(GV);
|
printVariableBody(GV);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void CppWriter::printFunctionHead(const Function* F) {
|
void CppWriter::printFunctionHead(const Function* F) {
|
||||||
nl(Out) << "Function* " << getCppName(F);
|
nl(Out) << "Function* " << getCppName(F);
|
||||||
|
Loading…
Reference in New Issue
Block a user