mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-03 13:31:05 +00:00
Replaced uses of deprecated `MachineFunction::get(BasicBlock *BB)'.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4351 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
d5806ffb40
commit
b7551ef115
@ -72,21 +72,6 @@ Pass *createMachineCodeDestructionPass() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// get - This deprecated static method returns the MachineBasicBlock object
|
|
||||||
// for the specified BasicBlock.
|
|
||||||
//
|
|
||||||
MachineBasicBlock& MachineBasicBlock::get(const BasicBlock *BB) {
|
|
||||||
const Function *F = BB->getParent();
|
|
||||||
MachineFunction &MF = MachineFunction::get(F);
|
|
||||||
|
|
||||||
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I)
|
|
||||||
if (I->getBasicBlock() == BB)
|
|
||||||
return *I;
|
|
||||||
assert(0 && "MachineBasicBlock object not found for specified block!");
|
|
||||||
return get(BB);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//===---------------------------------------------------------------------===//
|
//===---------------------------------------------------------------------===//
|
||||||
// MachineFunction implementation
|
// MachineFunction implementation
|
||||||
//===---------------------------------------------------------------------===//
|
//===---------------------------------------------------------------------===//
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
#include "llvm/CodeGen/MachineBasicBlock.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/MachineCodeForInstruction.h"
|
#include "llvm/CodeGen/MachineCodeForInstruction.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
using std::vector;
|
using std::vector;
|
||||||
@ -109,7 +109,7 @@ unsigned getMappingInfoForFunction::writeNumber(unsigned X) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Assign a number to each Function
|
//Assign a number to each Function
|
||||||
bool getMappingInfoForFunction::doInitialization(Module &M){
|
bool getMappingInfoForFunction::doInitialization(Module &M) {
|
||||||
unsigned i = 0;
|
unsigned 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){
|
||||||
@ -122,24 +122,25 @@ bool getMappingInfoForFunction::doInitialization(Module &M){
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Assign a Number to each BB
|
//Assign a Number to each BB
|
||||||
void getMappingInfoForFunction::create_BB_to_MInumber_Key(Function &FI){
|
void getMappingInfoForFunction::create_BB_to_MInumber_Key(Function &FI) {
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
for (Function::iterator BI = FI.begin(), BE = FI.end();
|
MachineFunction &MF = MachineFunction::get(&FI);
|
||||||
BI != BE; ++BI){
|
for (MachineFunction::iterator BI = MF.begin(), BE = MF.end();
|
||||||
MachineBasicBlock &miBB = MachineBasicBlock::get(BI);
|
BI != BE; ++BI) {
|
||||||
|
MachineBasicBlock &miBB = *BI;
|
||||||
BBkey[miBB[0]] = i;
|
BBkey[miBB[0]] = i;
|
||||||
i = i+(miBB.size());
|
i = i+(miBB.size());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Assign a number to each MI wrt beginning of the BB
|
//Assign a number to each MI wrt beginning of the BB
|
||||||
void getMappingInfoForFunction::create_MI_to_number_Key(Function &FI){
|
void getMappingInfoForFunction::create_MI_to_number_Key(Function &FI) {
|
||||||
for (Function::iterator BI=FI.begin(), BE=FI.end();
|
MachineFunction &MF = MachineFunction::get(&FI);
|
||||||
BI != BE; ++BI){
|
for (MachineFunction::iterator BI=MF.begin(), BE=MF.end(); BI != BE; ++BI) {
|
||||||
MachineBasicBlock &miBB = MachineBasicBlock::get(BI);
|
MachineBasicBlock &miBB = *BI;
|
||||||
unsigned j = 0;
|
unsigned j = 0;
|
||||||
for(MachineBasicBlock::iterator miI=miBB.begin(), miE=miBB.end();
|
for(MachineBasicBlock::iterator miI=miBB.begin(), miE=miBB.end();
|
||||||
miI!=miE; ++miI, ++j){
|
miI!=miE; ++miI, ++j) {
|
||||||
MIkey[*miI]=j;
|
MIkey[*miI]=j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -148,10 +149,11 @@ void getMappingInfoForFunction::create_MI_to_number_Key(Function &FI){
|
|||||||
//BBtoMImap: contains F#, BB#,
|
//BBtoMImap: contains F#, BB#,
|
||||||
// MI#[wrt beginning of F], #MI in BB
|
// MI#[wrt beginning of F], #MI in BB
|
||||||
void getMappingInfoForFunction::writeBBToMImap(Function &FI){
|
void getMappingInfoForFunction::writeBBToMImap(Function &FI){
|
||||||
unsigned bb=0;
|
unsigned bb = 0;
|
||||||
for (Function::iterator BI = FI.begin(),
|
MachineFunction &MF = MachineFunction::get(&FI);
|
||||||
BE = FI.end(); BI != BE; ++BI, ++bb){
|
for (MachineFunction::iterator BI = MF.begin(), BE = MF.end();
|
||||||
MachineBasicBlock &miBB = MachineBasicBlock::get(BI);
|
BI != BE; ++BI, ++bb) {
|
||||||
|
MachineBasicBlock &miBB = *BI;
|
||||||
writeNumber(bb);
|
writeNumber(bb);
|
||||||
//Out << " BB: "<<(void *)BI<<"\n";
|
//Out << " BB: "<<(void *)BI<<"\n";
|
||||||
//for(int i=0; i<miBB.size(); ++i)
|
//for(int i=0; i<miBB.size(); ++i)
|
||||||
@ -163,11 +165,11 @@ void getMappingInfoForFunction::writeBBToMImap(Function &FI){
|
|||||||
|
|
||||||
//LLVMtoMImap: contains F#, BB#, LLVM#,
|
//LLVMtoMImap: contains F#, BB#, LLVM#,
|
||||||
// MIs[wrt to beginning of BB]
|
// MIs[wrt to beginning of BB]
|
||||||
void getMappingInfoForFunction::writeLLVMToMImap(Function &FI){
|
void getMappingInfoForFunction::writeLLVMToMImap(Function &FI) {
|
||||||
|
|
||||||
unsigned bb =0;
|
unsigned bb =0;
|
||||||
for (Function::iterator BI = FI.begin(), BE = FI.end();
|
for (Function::iterator BI = FI.begin(), BE = FI.end();
|
||||||
BI != BE; ++BI, ++bb){
|
BI != BE; ++BI, ++bb) {
|
||||||
unsigned li = 0;
|
unsigned li = 0;
|
||||||
writeNumber(bb);
|
writeNumber(bb);
|
||||||
//std::cerr<<"BasicBlockNumber= "<<bb<<"\n";
|
//std::cerr<<"BasicBlockNumber= "<<bb<<"\n";
|
||||||
@ -177,7 +179,7 @@ void getMappingInfoForFunction::writeLLVMToMImap(Function &FI){
|
|||||||
//std::cerr<<"BasicBlockSize = "<<BI->size()<<"\n";
|
//std::cerr<<"BasicBlockSize = "<<BI->size()<<"\n";
|
||||||
|
|
||||||
for (BasicBlock::iterator II = BI->begin(),
|
for (BasicBlock::iterator II = BI->begin(),
|
||||||
IE = BI->end(); II != IE; ++II, ++li){
|
IE = BI->end(); II != IE; ++II, ++li) {
|
||||||
//Out << "I: "<<*II<<"\n";
|
//Out << "I: "<<*II<<"\n";
|
||||||
MachineCodeForInstruction& miI =
|
MachineCodeForInstruction& miI =
|
||||||
MachineCodeForInstruction::get(II);
|
MachineCodeForInstruction::get(II);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/CodeGen/PeepholeOpts.h"
|
#include "llvm/CodeGen/PeepholeOpts.h"
|
||||||
#include "llvm/CodeGen/MachineBasicBlock.h"
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
#include "llvm/Target/TargetMachine.h"
|
#include "llvm/Target/TargetMachine.h"
|
||||||
#include "llvm/Target/MachineInstrInfo.h"
|
#include "llvm/Target/MachineInstrInfo.h"
|
||||||
@ -100,7 +100,16 @@ bool
|
|||||||
PeepholeOpts::runOnBasicBlock(BasicBlock &BB)
|
PeepholeOpts::runOnBasicBlock(BasicBlock &BB)
|
||||||
{
|
{
|
||||||
// Get the machine instructions for this BB
|
// Get the machine instructions for this BB
|
||||||
MachineBasicBlock& mvec = MachineBasicBlock::get(&BB);
|
// FIXME: MachineBasicBlock::get() is deprecated, hence inlining the function
|
||||||
|
const Function *F = BB.getParent();
|
||||||
|
MachineFunction &MF = MachineFunction::get(F);
|
||||||
|
MachineBasicBlock *MBB = NULL;
|
||||||
|
for (MachineFunction::iterator I = MF.begin(), E = MF.end(); I != E; ++I) {
|
||||||
|
if (I->getBasicBlock() == &BB)
|
||||||
|
MBB = I;
|
||||||
|
}
|
||||||
|
assert(MBB && "MachineBasicBlock object not found for specified block!");
|
||||||
|
MachineBasicBlock &mvec = *MBB;
|
||||||
|
|
||||||
// Iterate over all machine instructions in the BB
|
// Iterate over all machine instructions in the BB
|
||||||
// Use a reverse iterator to allow deletion of MI or any instruction after it.
|
// Use a reverse iterator to allow deletion of MI or any instruction after it.
|
||||||
|
Loading…
Reference in New Issue
Block a user