mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
Simplify handling of constant initializers
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17696 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5c911ab6f1
commit
44c94b9671
@ -55,7 +55,6 @@ namespace {
|
|||||||
// Used for both models.
|
// Used for both models.
|
||||||
Function *WriteFn;
|
Function *WriteFn;
|
||||||
Function *AbortFn;
|
Function *AbortFn;
|
||||||
Constant *AbortMessageInit;
|
|
||||||
Value *AbortMessage;
|
Value *AbortMessage;
|
||||||
unsigned AbortMessageLength;
|
unsigned AbortMessageLength;
|
||||||
|
|
||||||
@ -126,18 +125,12 @@ bool LowerInvoke::doInitialization(Module &M) {
|
|||||||
Constant *Msg =
|
Constant *Msg =
|
||||||
ConstantArray::get("ERROR: Exception thrown, but not caught!\n");
|
ConstantArray::get("ERROR: Exception thrown, but not caught!\n");
|
||||||
AbortMessageLength = Msg->getNumOperands()-1; // don't include \0
|
AbortMessageLength = Msg->getNumOperands()-1; // don't include \0
|
||||||
AbortMessageInit = Msg;
|
|
||||||
|
|
||||||
GlobalVariable *MsgGV = M.getGlobalVariable("abort.msg", Msg->getType());
|
GlobalVariable *MsgGV = new GlobalVariable(Msg->getType(), true,
|
||||||
if (MsgGV && (!MsgGV->hasInitializer() || MsgGV->getInitializer() != Msg))
|
GlobalValue::InternalLinkage,
|
||||||
MsgGV = 0;
|
Msg, "abortmsg", &M);
|
||||||
|
|
||||||
if (MsgGV) {
|
|
||||||
std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::LongTy));
|
std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::LongTy));
|
||||||
AbortMessage =
|
AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, GEPIdx);
|
||||||
ConstantExpr::getGetElementPtr(MsgGV, GEPIdx);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// The abort message for cheap EH support tells the user that EH is not
|
// The abort message for cheap EH support tells the user that EH is not
|
||||||
// enabled.
|
// enabled.
|
||||||
@ -145,17 +138,12 @@ bool LowerInvoke::doInitialization(Module &M) {
|
|||||||
ConstantArray::get("Exception handler needed, but not enabled. Recompile"
|
ConstantArray::get("Exception handler needed, but not enabled. Recompile"
|
||||||
" program with -enable-correct-eh-support.\n");
|
" program with -enable-correct-eh-support.\n");
|
||||||
AbortMessageLength = Msg->getNumOperands()-1; // don't include \0
|
AbortMessageLength = Msg->getNumOperands()-1; // don't include \0
|
||||||
AbortMessageInit = Msg;
|
|
||||||
|
|
||||||
GlobalVariable *MsgGV = M.getGlobalVariable("abort.msg", Msg->getType());
|
GlobalVariable *MsgGV = new GlobalVariable(Msg->getType(), true,
|
||||||
if (MsgGV && (!MsgGV->hasInitializer() || MsgGV->getInitializer() != Msg))
|
GlobalValue::InternalLinkage,
|
||||||
MsgGV = 0;
|
Msg, "abortmsg", &M);
|
||||||
|
|
||||||
if (MsgGV) {
|
|
||||||
std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::LongTy));
|
std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::LongTy));
|
||||||
AbortMessage =
|
AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, GEPIdx);
|
||||||
ConstantExpr::getGetElementPtr(MsgGV, GEPIdx);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// We need the 'write' and 'abort' functions for both models.
|
// We need the 'write' and 'abort' functions for both models.
|
||||||
@ -183,17 +171,6 @@ bool LowerInvoke::doInitialization(Module &M) {
|
|||||||
|
|
||||||
void LowerInvoke::writeAbortMessage(Instruction *IB) {
|
void LowerInvoke::writeAbortMessage(Instruction *IB) {
|
||||||
if (WriteFn) {
|
if (WriteFn) {
|
||||||
if (!AbortMessage) {
|
|
||||||
GlobalVariable *MsgGV = new GlobalVariable(AbortMessageInit->getType(),
|
|
||||||
true,
|
|
||||||
GlobalValue::InternalLinkage,
|
|
||||||
AbortMessageInit, "abort.msg",
|
|
||||||
WriteFn->getParent());
|
|
||||||
std::vector<Constant*> GEPIdx(2, Constant::getNullValue(Type::LongTy));
|
|
||||||
AbortMessage =
|
|
||||||
ConstantExpr::getGetElementPtr(MsgGV, GEPIdx);
|
|
||||||
}
|
|
||||||
|
|
||||||
// These are the arguments we WANT...
|
// These are the arguments we WANT...
|
||||||
std::vector<Value*> Args;
|
std::vector<Value*> Args;
|
||||||
Args.push_back(ConstantInt::get(Type::IntTy, 2));
|
Args.push_back(ConstantInt::get(Type::IntTy, 2));
|
||||||
|
Loading…
Reference in New Issue
Block a user