[llvm] r260551 - [GlobalISel][IRTranslator] Change the ownership of the MIRBuilder field.
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 11 09:53:24 PST 2016
Author: qcolombet
Date: Thu Feb 11 11:53:23 2016
New Revision: 260551
URL: http://llvm.org/viewvc/llvm-project?rev=260551&view=rev
Log:
[GlobalISel][IRTranslator] Change the ownership of the MIRBuilder field.
Modified:
llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h
llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h?rev=260551&r1=260550&r2=260551&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/IRTranslator.h Thu Feb 11 11:53:23 2016
@@ -22,6 +22,7 @@
#include "Types.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SetVector.h"
+#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
namespace llvm {
@@ -32,7 +33,6 @@ class Instruction;
class MachineBasicBlock;
class MachineFunction;
class MachineInstr;
-class MachineIRBuilder;
class MachineRegisterInfo;
// Technically the pass should run on an hypothetical MachineModule,
@@ -96,7 +96,7 @@ private:
// I.e., compared to regular MIBuilder, this one also inserts the instruction
// in the current block, it can creates block, etc., basically a kind of
// IRBuilder, but for Machine IR.
- MachineIRBuilder *MIRBuilder;
+ MachineIRBuilder MIRBuilder;
/// MachineRegisterInfo used to create virtual registers.
MachineRegisterInfo *MRI;
Modified: llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp?rev=260551&r1=260550&r2=260551&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/IRTranslator.cpp Thu Feb 11 11:53:23 2016
@@ -12,7 +12,6 @@
#include "llvm/CodeGen/GlobalISel/IRTranslator.h"
-#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/IR/Constant.h"
@@ -26,6 +25,9 @@ using namespace llvm;
char IRTranslator::ID = 0;
+IRTranslator::IRTranslator() : MachineFunctionPass(ID), MRI(nullptr) {
+}
+
const VRegsSequence &IRTranslator::getOrCreateVRegs(const Value *Val) {
VRegsSequence &ValRegSequence = ValToVRegs[Val];
// Check if this is the first time we see Val.
@@ -48,7 +50,7 @@ const VRegsSequence &IRTranslator::getOr
MachineBasicBlock &IRTranslator::getOrCreateBB(const BasicBlock *BB) {
MachineBasicBlock *&MBB = BBToMBB[BB];
if (!MBB) {
- MachineFunction &MF = MIRBuilder->getMF();
+ MachineFunction &MF = MIRBuilder.getMF();
MBB = MF.CreateMachineBasicBlock();
MF.push_back(MBB);
}
@@ -63,12 +65,12 @@ bool IRTranslator::translateADD(const In
unsigned Op0 = *getOrCreateVRegs(Inst.getOperand(0)).begin();
unsigned Op1 = *getOrCreateVRegs(Inst.getOperand(1)).begin();
unsigned Res = *getOrCreateVRegs(&Inst).begin();
- MIRBuilder->buildInstr(TargetOpcode::G_ADD, Res, Op0, Op1);
+ MIRBuilder.buildInstr(TargetOpcode::G_ADD, Res, Op0, Op1);
return true;
}
bool IRTranslator::translate(const Instruction &Inst) {
- MIRBuilder->setDebugLoc(Inst.getDebugLoc());
+ MIRBuilder.setDebugLoc(Inst.getDebugLoc());
switch(Inst.getOpcode()) {
case Instruction::Add: {
return translateADD(Inst);
@@ -86,17 +88,13 @@ void IRTranslator::finalize() {
Constants.clear();
}
-IRTranslator::IRTranslator()
- : MachineFunctionPass(ID) {
-}
-
bool IRTranslator::runOnMachineFunction(MachineFunction &MF) {
const Function &F = *MF.getFunction();
- MIRBuilder->setFunction(MF);
+ MIRBuilder.setFunction(MF);
MRI = &MF.getRegInfo();
for (const BasicBlock &BB: F) {
MachineBasicBlock &MBB = getOrCreateBB(&BB);
- MIRBuilder->setBasicBlock(MBB);
+ MIRBuilder.setBasicBlock(MBB);
for (const Instruction &Inst: BB) {
bool Succeeded = translate(Inst);
if (!Succeeded) {
More information about the llvm-commits
mailing list