@@ -51,21 +51,6 @@ FunctionPass *llvm::createEVMLowerJumpUnless() {
5151 return new EVMLowerJumpUnless ();
5252}
5353
54- // Lower jump_unless into iszero and jumpi instructions. This instruction
55- // can only be present in non-stackified functions.
56- static void lowerJumpUnless (MachineInstr &MI, const EVMInstrInfo *TII,
57- const bool IsStackified, MachineRegisterInfo &MRI) {
58- assert (!IsStackified && " Found jump_unless in stackified function" );
59- assert (MI.getNumExplicitOperands () == 2 &&
60- " Unexpected number of operands in jump_unless" );
61- auto NewReg = MRI.createVirtualRegister (&EVM::GPRRegClass);
62- BuildMI (*MI.getParent (), MI, MI.getDebugLoc (), TII->get (EVM::ISZERO), NewReg)
63- .add (MI.getOperand (1 ));
64- BuildMI (*MI.getParent (), MI, MI.getDebugLoc (), TII->get (EVM::JUMPI))
65- .add (MI.getOperand (0 ))
66- .addReg (NewReg);
67- }
68-
6954// Lower pseudo jump_unless into iszero and jumpi instructions. This pseudo
7055// instruction can only be present in stackified functions.
7156static void lowerPseudoJumpUnless (MachineInstr &MI, const EVMInstrInfo *TII,
@@ -84,21 +69,17 @@ bool EVMLowerJumpUnless::runOnMachineFunction(MachineFunction &MF) {
8469 << " ********** Function: " << MF.getName () << ' \n ' ;
8570 });
8671
87- MachineRegisterInfo &MRI = MF.getRegInfo ();
8872 const auto *TII = MF.getSubtarget <EVMSubtarget>().getInstrInfo ();
8973 const bool IsStackified =
9074 MF.getInfo <EVMMachineFunctionInfo>()->getIsStackified ();
9175
9276 bool Changed = false ;
9377 for (MachineBasicBlock &MBB : MF) {
9478 for (auto &MI : make_early_inc_range (MBB)) {
95- if (MI.getOpcode () == EVM::PseudoJUMP_UNLESS)
96- lowerPseudoJumpUnless (MI, TII, IsStackified);
97- else if (MI.getOpcode () == EVM::JUMP_UNLESS)
98- lowerJumpUnless (MI, TII, IsStackified, MRI);
99- else
79+ if (MI.getOpcode () != EVM::PseudoJUMP_UNLESS)
10080 continue ;
10181
82+ lowerPseudoJumpUnless (MI, TII, IsStackified);
10283 MI.eraseFromParent ();
10384 Changed = true ;
10485 }
0 commit comments