mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-18 13:34:04 +00:00
added check for Function with 0 BB
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2942 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
f4688a8079
commit
e01166591f
@ -17,7 +17,6 @@
|
|||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// MappingInfo - This method collects mapping info
|
// MappingInfo - This method collects mapping info
|
||||||
// for the mapping from LLVM to machine code.
|
// for the mapping from LLVM to machine code.
|
||||||
//
|
//
|
||||||
@ -148,7 +147,8 @@ void getMappingInfoForFunction::createFunctionKey(Module &M){
|
|||||||
int j = 0;
|
int j = 0;
|
||||||
for (Module::iterator FI = M.begin(), FE = M.end();
|
for (Module::iterator FI = M.begin(), FE = M.end();
|
||||||
FI != FE; ++FI){
|
FI != FE; ++FI){
|
||||||
if(FI->size() <=1) continue;
|
//dont count F with 0 BBs
|
||||||
|
if(FI->isExternal()) continue;
|
||||||
Fkey[FI] = i;
|
Fkey[FI] = i;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
@ -156,11 +156,11 @@ void getMappingInfoForFunction::createFunctionKey(Module &M){
|
|||||||
|
|
||||||
//Assign a Number to each BB
|
//Assign a Number to each BB
|
||||||
void getMappingInfoForFunction::createBasicBlockKey(Module &M){
|
void getMappingInfoForFunction::createBasicBlockKey(Module &M){
|
||||||
int i = 0;
|
//int i = 0;
|
||||||
for (Module::iterator FI = M.begin(), FE = M.end();
|
for (Module::iterator FI = M.begin(), FE = M.end();
|
||||||
FI != FE; ++FI){
|
FI != FE; ++FI){
|
||||||
// int i = 0;
|
int i = 0;
|
||||||
//if(FI->size() <= 1) continue;
|
if(FI->isExternal()) continue;
|
||||||
for (Function::iterator BI = FI->begin(), BE = FI->end();
|
for (Function::iterator BI = FI->begin(), BE = FI->end();
|
||||||
BI != BE; ++BI){
|
BI != BE; ++BI){
|
||||||
MachineCodeForBasicBlock &miBB = MachineCodeForBasicBlock::get(BI);
|
MachineCodeForBasicBlock &miBB = MachineCodeForBasicBlock::get(BI);
|
||||||
@ -170,10 +170,11 @@ void getMappingInfoForFunction::createBasicBlockKey(Module &M){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Assign a number to each MI wrt beginning of the BB
|
||||||
void getMappingInfoForFunction::createMachineInstructionKey(Module &M){
|
void getMappingInfoForFunction::createMachineInstructionKey(Module &M){
|
||||||
for (Module::iterator FI = M.begin(), FE = M.end();
|
for (Module::iterator FI = M.begin(), FE = M.end();
|
||||||
FI != FE; ++FI){
|
FI != FE; ++FI){
|
||||||
//if(FI->size() <= 1) continue;
|
if(FI->isExternal()) continue;
|
||||||
for (Function::iterator BI=FI->begin(), BE=FI->end();
|
for (Function::iterator BI=FI->begin(), BE=FI->end();
|
||||||
BI != BE; ++BI){
|
BI != BE; ++BI){
|
||||||
MachineCodeForBasicBlock &miBB = MachineCodeForBasicBlock::get(BI);
|
MachineCodeForBasicBlock &miBB = MachineCodeForBasicBlock::get(BI);
|
||||||
@ -186,29 +187,29 @@ void getMappingInfoForFunction::createMachineInstructionKey(Module &M){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//BBtoMImap: contains F#, BB#,
|
||||||
|
// MI#[wrt beginning of F], #MI in BB
|
||||||
void getMappingInfoForFunction::createBBToMImap(Module &M){
|
void getMappingInfoForFunction::createBBToMImap(Module &M){
|
||||||
//go thro each function in the module
|
|
||||||
for (Module::iterator FI = M.begin(), FE = M.end();
|
for (Module::iterator FI = M.begin(), FE = M.end();
|
||||||
FI != FE; ++FI){
|
FI != FE; ++FI){
|
||||||
//if(FI->size() <= 1)continue;
|
if(FI->isExternal())continue;
|
||||||
//go thro each basic block in that function
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Function::iterator BI = FI->begin(),
|
for (Function::iterator BI = FI->begin(),
|
||||||
BE = FI->end(); BI != BE; ++BI){
|
BE = FI->end(); BI != BE; ++BI){
|
||||||
//create a Map record
|
|
||||||
//get the corresponding machine instruction
|
|
||||||
MachineCodeForBasicBlock &miBB = MachineCodeForBasicBlock::get(BI);
|
MachineCodeForBasicBlock &miBB = MachineCodeForBasicBlock::get(BI);
|
||||||
//add record into the map
|
//add record into the map
|
||||||
BBmap.push_back(vector<int>());
|
BBmap.push_back(vector<int>());
|
||||||
vector<int> &oneBB = BBmap.back();
|
vector<int> &oneBB = BBmap.back();
|
||||||
oneBB.reserve(4);
|
oneBB.reserve(4);
|
||||||
|
|
||||||
//add the function number
|
//add F#
|
||||||
oneBB.push_back(Fkey[FI]);
|
oneBB.push_back(Fkey[FI]);
|
||||||
//add the machine instruction number
|
//add BB#
|
||||||
oneBB.push_back( i );
|
oneBB.push_back( i );
|
||||||
|
//add the MI#[wrt the beginning of F]
|
||||||
oneBB.push_back( BBkey[ miBB[0] ]);
|
oneBB.push_back( BBkey[ miBB[0] ]);
|
||||||
//add the number of instructions
|
//add the # of MI
|
||||||
oneBB.push_back(miBB.size());
|
oneBB.push_back(miBB.size());
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
@ -216,11 +217,13 @@ void getMappingInfoForFunction::createBBToMImap(Module &M){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//LLVMtoMImap: contains F#, BB#, LLVM#,
|
||||||
|
// MIs[wrt to beginning of BB]
|
||||||
void getMappingInfoForFunction::createLLVMToMImap(Module &M){
|
void getMappingInfoForFunction::createLLVMToMImap(Module &M){
|
||||||
|
|
||||||
for (Module::iterator FI = M.begin(), FE = M.end();
|
for (Module::iterator FI = M.begin(), FE = M.end();
|
||||||
FI != FE; ++FI){
|
FI != FE; ++FI){
|
||||||
//if(FI->size() <= 1) continue;
|
if(FI->isExternal()) continue;
|
||||||
int i =0;
|
int i =0;
|
||||||
for (Function::iterator BI = FI->begin(), BE = FI->end();
|
for (Function::iterator BI = FI->begin(), BE = FI->end();
|
||||||
BI != BE; ++BI, ++i){
|
BI != BE; ++BI, ++i){
|
||||||
@ -229,15 +232,22 @@ void getMappingInfoForFunction::createLLVMToMImap(Module &M){
|
|||||||
IE = BI->end(); II != IE; ++II, ++j){
|
IE = BI->end(); II != IE; ++II, ++j){
|
||||||
MachineCodeForInstruction& miI =
|
MachineCodeForInstruction& miI =
|
||||||
MachineCodeForInstruction::get(II);
|
MachineCodeForInstruction::get(II);
|
||||||
|
//do for each corr. MI
|
||||||
for (MachineCodeForInstruction::iterator miII = miI.begin(),
|
for (MachineCodeForInstruction::iterator miII = miI.begin(),
|
||||||
miIE = miI.end(); miII != miIE; ++miII){
|
miIE = miI.end(); miII != miIE; ++miII){
|
||||||
|
|
||||||
|
MImap.push_back(vector<int>());
|
||||||
|
vector<int> &oneMI = MImap.back();
|
||||||
|
oneMI.reserve(4);
|
||||||
|
|
||||||
vector<int> oneMI;
|
//add F#
|
||||||
oneMI.push_back(Fkey[FI]);
|
oneMI.push_back(Fkey[FI]);
|
||||||
|
//add BB#
|
||||||
oneMI.push_back(i);
|
oneMI.push_back(i);
|
||||||
|
//add LLVM Instr#
|
||||||
oneMI.push_back(j);
|
oneMI.push_back(j);
|
||||||
|
//add MI#[wrt to beginning of BB]
|
||||||
oneMI.push_back(MIkey[*miII]);
|
oneMI.push_back(MIkey[*miII]);
|
||||||
MImap.push_back(oneMI);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// MappingInfo - This method collects mapping info
|
// MappingInfo - This method collects mapping info
|
||||||
// for the mapping from LLVM to machine code.
|
// for the mapping from LLVM to machine code.
|
||||||
//
|
//
|
||||||
@ -148,7 +147,8 @@ void getMappingInfoForFunction::createFunctionKey(Module &M){
|
|||||||
int j = 0;
|
int j = 0;
|
||||||
for (Module::iterator FI = M.begin(), FE = M.end();
|
for (Module::iterator FI = M.begin(), FE = M.end();
|
||||||
FI != FE; ++FI){
|
FI != FE; ++FI){
|
||||||
if(FI->size() <=1) continue;
|
//dont count F with 0 BBs
|
||||||
|
if(FI->isExternal()) continue;
|
||||||
Fkey[FI] = i;
|
Fkey[FI] = i;
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
@ -156,11 +156,11 @@ void getMappingInfoForFunction::createFunctionKey(Module &M){
|
|||||||
|
|
||||||
//Assign a Number to each BB
|
//Assign a Number to each BB
|
||||||
void getMappingInfoForFunction::createBasicBlockKey(Module &M){
|
void getMappingInfoForFunction::createBasicBlockKey(Module &M){
|
||||||
int i = 0;
|
//int i = 0;
|
||||||
for (Module::iterator FI = M.begin(), FE = M.end();
|
for (Module::iterator FI = M.begin(), FE = M.end();
|
||||||
FI != FE; ++FI){
|
FI != FE; ++FI){
|
||||||
// int i = 0;
|
int i = 0;
|
||||||
//if(FI->size() <= 1) continue;
|
if(FI->isExternal()) continue;
|
||||||
for (Function::iterator BI = FI->begin(), BE = FI->end();
|
for (Function::iterator BI = FI->begin(), BE = FI->end();
|
||||||
BI != BE; ++BI){
|
BI != BE; ++BI){
|
||||||
MachineCodeForBasicBlock &miBB = MachineCodeForBasicBlock::get(BI);
|
MachineCodeForBasicBlock &miBB = MachineCodeForBasicBlock::get(BI);
|
||||||
@ -170,10 +170,11 @@ void getMappingInfoForFunction::createBasicBlockKey(Module &M){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Assign a number to each MI wrt beginning of the BB
|
||||||
void getMappingInfoForFunction::createMachineInstructionKey(Module &M){
|
void getMappingInfoForFunction::createMachineInstructionKey(Module &M){
|
||||||
for (Module::iterator FI = M.begin(), FE = M.end();
|
for (Module::iterator FI = M.begin(), FE = M.end();
|
||||||
FI != FE; ++FI){
|
FI != FE; ++FI){
|
||||||
//if(FI->size() <= 1) continue;
|
if(FI->isExternal()) continue;
|
||||||
for (Function::iterator BI=FI->begin(), BE=FI->end();
|
for (Function::iterator BI=FI->begin(), BE=FI->end();
|
||||||
BI != BE; ++BI){
|
BI != BE; ++BI){
|
||||||
MachineCodeForBasicBlock &miBB = MachineCodeForBasicBlock::get(BI);
|
MachineCodeForBasicBlock &miBB = MachineCodeForBasicBlock::get(BI);
|
||||||
@ -186,29 +187,29 @@ void getMappingInfoForFunction::createMachineInstructionKey(Module &M){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//BBtoMImap: contains F#, BB#,
|
||||||
|
// MI#[wrt beginning of F], #MI in BB
|
||||||
void getMappingInfoForFunction::createBBToMImap(Module &M){
|
void getMappingInfoForFunction::createBBToMImap(Module &M){
|
||||||
//go thro each function in the module
|
|
||||||
for (Module::iterator FI = M.begin(), FE = M.end();
|
for (Module::iterator FI = M.begin(), FE = M.end();
|
||||||
FI != FE; ++FI){
|
FI != FE; ++FI){
|
||||||
//if(FI->size() <= 1)continue;
|
if(FI->isExternal())continue;
|
||||||
//go thro each basic block in that function
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (Function::iterator BI = FI->begin(),
|
for (Function::iterator BI = FI->begin(),
|
||||||
BE = FI->end(); BI != BE; ++BI){
|
BE = FI->end(); BI != BE; ++BI){
|
||||||
//create a Map record
|
|
||||||
//get the corresponding machine instruction
|
|
||||||
MachineCodeForBasicBlock &miBB = MachineCodeForBasicBlock::get(BI);
|
MachineCodeForBasicBlock &miBB = MachineCodeForBasicBlock::get(BI);
|
||||||
//add record into the map
|
//add record into the map
|
||||||
BBmap.push_back(vector<int>());
|
BBmap.push_back(vector<int>());
|
||||||
vector<int> &oneBB = BBmap.back();
|
vector<int> &oneBB = BBmap.back();
|
||||||
oneBB.reserve(4);
|
oneBB.reserve(4);
|
||||||
|
|
||||||
//add the function number
|
//add F#
|
||||||
oneBB.push_back(Fkey[FI]);
|
oneBB.push_back(Fkey[FI]);
|
||||||
//add the machine instruction number
|
//add BB#
|
||||||
oneBB.push_back( i );
|
oneBB.push_back( i );
|
||||||
|
//add the MI#[wrt the beginning of F]
|
||||||
oneBB.push_back( BBkey[ miBB[0] ]);
|
oneBB.push_back( BBkey[ miBB[0] ]);
|
||||||
//add the number of instructions
|
//add the # of MI
|
||||||
oneBB.push_back(miBB.size());
|
oneBB.push_back(miBB.size());
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
@ -216,11 +217,13 @@ void getMappingInfoForFunction::createBBToMImap(Module &M){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//LLVMtoMImap: contains F#, BB#, LLVM#,
|
||||||
|
// MIs[wrt to beginning of BB]
|
||||||
void getMappingInfoForFunction::createLLVMToMImap(Module &M){
|
void getMappingInfoForFunction::createLLVMToMImap(Module &M){
|
||||||
|
|
||||||
for (Module::iterator FI = M.begin(), FE = M.end();
|
for (Module::iterator FI = M.begin(), FE = M.end();
|
||||||
FI != FE; ++FI){
|
FI != FE; ++FI){
|
||||||
//if(FI->size() <= 1) continue;
|
if(FI->isExternal()) continue;
|
||||||
int i =0;
|
int i =0;
|
||||||
for (Function::iterator BI = FI->begin(), BE = FI->end();
|
for (Function::iterator BI = FI->begin(), BE = FI->end();
|
||||||
BI != BE; ++BI, ++i){
|
BI != BE; ++BI, ++i){
|
||||||
@ -229,15 +232,22 @@ void getMappingInfoForFunction::createLLVMToMImap(Module &M){
|
|||||||
IE = BI->end(); II != IE; ++II, ++j){
|
IE = BI->end(); II != IE; ++II, ++j){
|
||||||
MachineCodeForInstruction& miI =
|
MachineCodeForInstruction& miI =
|
||||||
MachineCodeForInstruction::get(II);
|
MachineCodeForInstruction::get(II);
|
||||||
|
//do for each corr. MI
|
||||||
for (MachineCodeForInstruction::iterator miII = miI.begin(),
|
for (MachineCodeForInstruction::iterator miII = miI.begin(),
|
||||||
miIE = miI.end(); miII != miIE; ++miII){
|
miIE = miI.end(); miII != miIE; ++miII){
|
||||||
|
|
||||||
|
MImap.push_back(vector<int>());
|
||||||
|
vector<int> &oneMI = MImap.back();
|
||||||
|
oneMI.reserve(4);
|
||||||
|
|
||||||
vector<int> oneMI;
|
//add F#
|
||||||
oneMI.push_back(Fkey[FI]);
|
oneMI.push_back(Fkey[FI]);
|
||||||
|
//add BB#
|
||||||
oneMI.push_back(i);
|
oneMI.push_back(i);
|
||||||
|
//add LLVM Instr#
|
||||||
oneMI.push_back(j);
|
oneMI.push_back(j);
|
||||||
|
//add MI#[wrt to beginning of BB]
|
||||||
oneMI.push_back(MIkey[*miII]);
|
oneMI.push_back(MIkey[*miII]);
|
||||||
MImap.push_back(oneMI);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user