mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-12 03:32:10 +00:00
small corrections
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2816 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d4d79067c0
commit
82f40e8210
@ -19,7 +19,7 @@
|
|||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/SymbolTable.h"
|
#include "llvm/SymbolTable.h"
|
||||||
#include "llvm/GlobalVariable.h"
|
#include "llvm/GlobalVariable.h"
|
||||||
#include "llvm/Constants.h"//llvm/ConstantVals.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/BasicBlock.h"
|
#include "llvm/BasicBlock.h"
|
||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -34,8 +34,6 @@ using std::vector;
|
|||||||
|
|
||||||
void getTriggerCode(Module *M, BasicBlock *BB, int MethNo, Value *pathNo,
|
void getTriggerCode(Module *M, BasicBlock *BB, int MethNo, Value *pathNo,
|
||||||
Value *cnt){
|
Value *cnt){
|
||||||
// return;
|
|
||||||
//cerr<<"In trigger code"<<endl;
|
|
||||||
static int i=-1;
|
static int i=-1;
|
||||||
i++;
|
i++;
|
||||||
char gstr[100];
|
char gstr[100];
|
||||||
@ -43,7 +41,7 @@ void getTriggerCode(Module *M, BasicBlock *BB, int MethNo, Value *pathNo,
|
|||||||
std::string globalVarName=gstr;
|
std::string globalVarName=gstr;
|
||||||
SymbolTable *ST = M->getSymbolTable();
|
SymbolTable *ST = M->getSymbolTable();
|
||||||
vector<const Type*> args;
|
vector<const Type*> args;
|
||||||
args.push_back(PointerType::get(Type::SByteTy));
|
//args.push_back(PointerType::get(Type::SByteTy));
|
||||||
args.push_back(Type::IntTy);
|
args.push_back(Type::IntTy);
|
||||||
args.push_back(Type::IntTy);
|
args.push_back(Type::IntTy);
|
||||||
args.push_back(Type::IntTy);
|
args.push_back(Type::IntTy);
|
||||||
@ -58,21 +56,26 @@ void getTriggerCode(Module *M, BasicBlock *BB, int MethNo, Value *pathNo,
|
|||||||
vector<Value *> trargs;
|
vector<Value *> trargs;
|
||||||
|
|
||||||
//pred_iterator piter=BB->pred_begin();
|
//pred_iterator piter=BB->pred_begin();
|
||||||
std::string predName=BB->getName();
|
//std::string predName = "uu";//BB->getName();
|
||||||
Constant *bbName=ConstantArray::get(predName);//BB->getName());
|
//Constant *bbName=ConstantArray::get(predName);//BB->getName());
|
||||||
GlobalVariable *gbl=new GlobalVariable(ArrayType::get(Type::SByteTy,
|
//GlobalVariable *gbl=new GlobalVariable(ArrayType::get(Type::SByteTy,
|
||||||
predName.size()+1),
|
// predName.size()+1),
|
||||||
true, true, bbName, gstr);
|
// true, true, bbName, gstr);
|
||||||
M->getGlobalList().push_back(gbl);
|
|
||||||
|
//M->getGlobalList().push_back(gbl);
|
||||||
|
|
||||||
vector<Value *> elargs;
|
vector<Value *> elargs;
|
||||||
elargs.push_back(ConstantUInt::get(Type::UIntTy, 0));
|
elargs.push_back(ConstantUInt::get(Type::UIntTy, 0));
|
||||||
elargs.push_back(ConstantUInt::get(Type::UIntTy, 0));
|
elargs.push_back(ConstantUInt::get(Type::UIntTy, 0));
|
||||||
|
|
||||||
Instruction *getElmntInst=new GetElementPtrInst(gbl,elargs,"elmntInst");
|
// commented out bb name frm which its called
|
||||||
|
//Instruction *getElmntInst=new GetElementPtrInst(gbl,elargs,"elmntInst");
|
||||||
|
|
||||||
//trargs.push_back(ConstantArray::get(BB->getName()));
|
//trargs.push_back(ConstantArray::get(BB->getName()));
|
||||||
trargs.push_back(getElmntInst);
|
|
||||||
|
//trargs.push_back(getElmntInst);
|
||||||
|
//trargs.push_back(bbName);
|
||||||
|
|
||||||
trargs.push_back(ConstantSInt::get(Type::IntTy,MethNo));
|
trargs.push_back(ConstantSInt::get(Type::IntTy,MethNo));
|
||||||
|
|
||||||
//trargs.push_back(ConstantSInt::get(Type::IntTy,-1));//erase this
|
//trargs.push_back(ConstantSInt::get(Type::IntTy,-1));//erase this
|
||||||
@ -82,14 +85,8 @@ void getTriggerCode(Module *M, BasicBlock *BB, int MethNo, Value *pathNo,
|
|||||||
|
|
||||||
BasicBlock::InstListType& instList=BB->getInstList();
|
BasicBlock::InstListType& instList=BB->getInstList();
|
||||||
BasicBlock::iterator here=instList.begin();
|
BasicBlock::iterator here=instList.begin();
|
||||||
here = ++instList.insert(here, getElmntInst);
|
//here = ++instList.insert(here, getElmntInst);
|
||||||
instList.insert(here,callInst);
|
instList.insert(here,callInst);
|
||||||
//}
|
|
||||||
//else{
|
|
||||||
//insert trigger method
|
|
||||||
|
|
||||||
//assert(0&&"No method trigger");
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -340,7 +337,8 @@ void insertBB(Edge ed,
|
|||||||
//Is terminator a branch instruction?
|
//Is terminator a branch instruction?
|
||||||
//then we need to change branch destinations to include new BB
|
//then we need to change branch destinations to include new BB
|
||||||
|
|
||||||
BranchInst *BI=cast<BranchInst>(TI);
|
//std::cerr<<"before cast!\n";
|
||||||
|
BranchInst *BI = cast<BranchInst>(TI);
|
||||||
|
|
||||||
if(BI->isUnconditional()){
|
if(BI->isUnconditional()){
|
||||||
BI->setUnconditionalDest(newBB);
|
BI->setUnconditionalDest(newBB);
|
||||||
@ -358,6 +356,7 @@ void insertBB(Edge ed,
|
|||||||
newBB->getInstList().push_back(newBI2);
|
newBB->getInstList().push_back(newBI2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//std::cerr<<"After casting\n";
|
||||||
//get code for the new BB
|
//get code for the new BB
|
||||||
//now iterate over BB2, and set its Phi nodes right
|
//now iterate over BB2, and set its Phi nodes right
|
||||||
for(BasicBlock::iterator BB2Inst = BB2->begin(), BBend = BB2->end();
|
for(BasicBlock::iterator BB2Inst = BB2->begin(), BBend = BB2->end();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user