[PATCH] D127055: [ARM] Merge duplicated Thumb2SizeReduce code (NFC)
ksyx via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 4 14:35:39 PDT 2022
ksyx updated this revision to Diff 434288.
ksyx added a comment.
Apply suggestions from clangfmt
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D127055/new/
https://reviews.llvm.org/D127055
Files:
llvm/lib/Target/ARM/Thumb2SizeReduction.cpp
Index: llvm/lib/Target/ARM/Thumb2SizeReduction.cpp
===================================================================
--- llvm/lib/Target/ARM/Thumb2SizeReduction.cpp
+++ llvm/lib/Target/ARM/Thumb2SizeReduction.cpp
@@ -187,6 +187,9 @@
bool is2Addr, ARMCC::CondCodes Pred,
bool LiveCPSR, bool &HasCC, bool &CCDead);
+ void PerformReduce(MachineBasicBlock &MBB, MachineInstr *MI,
+ MachineInstrBuilder &MIB, llvm::Statistic &Counter);
+
bool ReduceLoadStore(MachineBasicBlock &MBB, MachineInstr *MI,
const ReduceEntry &Entry);
@@ -401,6 +404,19 @@
return true;
}
+void Thumb2SizeReduce::PerformReduce(MachineBasicBlock &MBB, MachineInstr *MI,
+ MachineInstrBuilder &MIB,
+ llvm::Statistic &Counter) {
+ // Transfer MI flags.
+ MIB.setMIFlags(MI->getFlags());
+
+ LLVM_DEBUG(llvm::dbgs() << "Converted 32-bit: " << *MI
+ << " to 16-bit: " << *MIB);
+
+ MBB.erase_instr(MI);
+ ++Counter;
+}
+
bool
Thumb2SizeReduce::ReduceLoadStore(MachineBasicBlock &MBB, MachineInstr *MI,
const ReduceEntry &Entry) {
@@ -618,14 +634,7 @@
// Transfer memoperands.
MIB.setMemRefs(MI->memoperands());
- // Transfer MI flags.
- MIB.setMIFlags(MI->getFlags());
-
- LLVM_DEBUG(errs() << "Converted 32-bit: " << *MI
- << " to 16-bit: " << *MIB);
-
- MBB.erase_instr(MI);
- ++NumLdSts;
+ PerformReduce(MBB, MI, MIB, NumLdSts);
return true;
}
@@ -666,14 +675,7 @@
.addImm(Imm / 4) // The tADDrSPi has an implied scale by four.
.add(predOps(ARMCC::AL));
- // Transfer MI flags.
- MIB.setMIFlags(MI->getFlags());
-
- LLVM_DEBUG(errs() << "Converted 32-bit: " << *MI
- << " to 16-bit: " << *MIB);
-
- MBB.erase_instr(MI);
- ++NumNarrows;
+ PerformReduce(MBB, MI, MIB, NumNarrows);
return true;
}
@@ -846,14 +848,7 @@
MIB.add(MI->getOperand(i));
}
- // Transfer MI flags.
- MIB.setMIFlags(MI->getFlags());
-
- LLVM_DEBUG(errs() << "Converted 32-bit: " << *MI
- << " to 16-bit: " << *MIB);
-
- MBB.erase_instr(MI);
- ++Num2Addrs;
+ PerformReduce(MBB, MI, MIB, Num2Addrs);
return true;
}
@@ -969,14 +964,7 @@
if (!MCID.isPredicable() && NewMCID.isPredicable())
MIB.add(predOps(ARMCC::AL));
- // Transfer MI flags.
- MIB.setMIFlags(MI->getFlags());
-
- LLVM_DEBUG(errs() << "Converted 32-bit: " << *MI
- << " to 16-bit: " << *MIB);
-
- MBB.erase_instr(MI);
- ++NumNarrows;
+ PerformReduce(MBB, MI, MIB, NumNarrows);
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127055.434288.patch
Type: text/x-patch
Size: 2781 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220604/57b453e6/attachment.bin>
More information about the llvm-commits
mailing list