Skip to content

Commit

Permalink
Issue #59: prepare to refactor.
Browse files Browse the repository at this point in the history
  • Loading branch information
lialan committed Apr 28, 2020
1 parent 294918e commit f4966e6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
20 changes: 10 additions & 10 deletions lib/Target/EVM/EVMArgumentMove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ class EVMArgumentMove final : public MachineFunctionPass {
void arrangeStackArgs(MachineFunction &MF) const;
std::vector<unsigned> unusedArgs;
const EVMInstrInfo *TII;
EVMMachineFunctionInfo *MFI;
const Function *F;
MachineRegisterInfo *MRI;
};
} // end anonymous namespace

Expand All @@ -62,14 +65,10 @@ FunctionPass *llvm::createEVMArgumentMove() {
}

bool EVMArgumentMove::isStackArg(const MachineInstr &MI) {
unsigned opc = MI.getOpcode();

return (opc == EVM::pSTACKARG_r);
return (MI.getOpcode() == EVM::pSTACKARG_r);
}

void EVMArgumentMove::arrangeStackArgs(MachineFunction& MF) const {
EVMMachineFunctionInfo *MFI = MF.getInfo<EVMMachineFunctionInfo>();
MachineRegisterInfo &MRI = MF.getRegInfo();

bool hasSubroutine = MF.getSubtarget<EVMSubtarget>().hasSubroutine();

Expand Down Expand Up @@ -106,7 +105,7 @@ void EVMArgumentMove::arrangeStackArgs(MachineFunction& MF) const {
if (!stackargs[i]) {
MachineBasicBlock::iterator insertPt = EntryMBB.begin();

unsigned destReg = MRI.createVirtualRegister(&EVM::GPRRegClass);
unsigned destReg = MRI->createVirtualRegister(&EVM::GPRRegClass);
BuildMI(EntryMBB, insertPt, insertPt->getDebugLoc(),
TII->get(EVM::pSTACKARG_r), destReg)
.addImm(i);
Expand All @@ -126,7 +125,7 @@ void EVMArgumentMove::arrangeStackArgs(MachineFunction& MF) const {
if (!EVMSubtarget::isMainFunction(F)) {
// return address is the last stackarg:
unsigned retAddrStackArgNum = MFI->getNumStackArgs();
unsigned destReg = MRI.createVirtualRegister(&EVM::GPRRegClass);
unsigned destReg = MRI->createVirtualRegister(&EVM::GPRRegClass);
auto bmi =
BuildMI(EntryMBB, EntryMBB.front(), EntryMBB.front().getDebugLoc(),
TII->get(EVM::pSTACKARG_r), destReg)
Expand Down Expand Up @@ -179,8 +178,9 @@ bool EVMArgumentMove::runOnMachineFunction(MachineFunction &MF) {
unusedArgs.clear();

TII = MF.getSubtarget<EVMSubtarget>().getInstrInfo();

MachineRegisterInfo &MRI = MF.getRegInfo();
MFI = MF.getInfo<EVMMachineFunctionInfo>();
F = &MF.getFunction();
MRI = &MF.getRegInfo();

bool Changed = false;
MachineBasicBlock &EntryMBB = MF.front();
Expand All @@ -206,7 +206,7 @@ bool EVMArgumentMove::runOnMachineFunction(MachineFunction &MF) {
unsigned reg = MI.getOperand(0).getReg();

// record unused stack arguments so we can pop it later.
bool IsDead = MRI.use_empty(reg);
bool IsDead = MRI->use_empty(reg);
if (IsDead) {
LLVM_DEBUG({
dbgs() << "Stack argument: " << Register::virtReg2Index(reg)
Expand Down
5 changes: 0 additions & 5 deletions lib/Target/EVM/EVMCallTransformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ class EVMCallTransformation : public ModulePass {

} // end anonymous namespace

static bool
isEVMSpecificIntrinsics(Function *F) {
return F->isIntrinsic() && F->getName().startswith("llvm.evm");
}

FunctionType*
EVMCallTransformation::rebuildFunctionType(FunctionType *OrigType) const {
Type* RetType = OrigType->getReturnType();
Expand Down

0 comments on commit f4966e6

Please sign in to comment.