[llvm] [TableGen] Integrate TableGen-based macro fusion (PR #73115)
Wang Pengcheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 17 00:58:18 PST 2024
================
@@ -323,6 +324,12 @@ class TargetSubtargetInfo : public MCSubtargetInfo {
/// helps removing redundant copies generated by register allocator when
/// handling complex eviction chains.
virtual bool enableSpillageCopyElimination() const { return false; }
+
+ /// Enable macro fusion for this subtarget.
+ virtual bool enableMacroFusion() const { return false; }
----------------
wangpc-pp wrote:
Oh, I get it. The typical usage is like:
```
if (ST.enableMacroFusion()) {
ScheduleDAGMI *DAG = createGenericSchedPostRA(C);
DAG->addMutation(createMacroFusionDAGMutation(ST.getMacroFusions()));
return DAG;
}
```
`enableMacroFusion()` is for knowing if we should enable MacroFusion, `getMacroFusions()` returns the predicates.
Yes, I know we can replace `enableMacroFusion()` with `!getMacroFusions().empty()`, but the implementation of `enableMacroFusion()` avoid the creation of `std::vector`.
Let't take RISCV as an example: https://github.com/llvm/llvm-project/pull/72224/commits/1c92927e7d46c2b3c3f173e35afb2eecd4e9ffbf.
`enableMacroFusion()` is a replacement of `RISCVSubtarget::hasMacroFusion()`:
```
bool hasMacroFusion() const {
return hasLUIADDIFusion() || hasAUIPCADDIFusion() || hasZExtHFusion() ||
hasZExtWFusion() || hasShiftedZExtWFusion() || hasLDADDFusion();
}
```
https://github.com/llvm/llvm-project/pull/73115
More information about the llvm-commits
mailing list