[all-commits] [llvm/llvm-project] a0e6b7: [TableGen] Add a backend to generate MacroFusion p...

Wang Pengcheng via All-commits all-commits at lists.llvm.org
Fri Jan 5 06:44:19 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: a0e6b7c0429204ac42095be09bd1d5dcad4a052a
      https://github.com/llvm/llvm-project/commit/a0e6b7c0429204ac42095be09bd1d5dcad4a052a
  Author: Wang Pengcheng <wangpengcheng.pp at bytedance.com>
  Date:   2024-01-05 (Fri, 05 Jan 2024)

  Changed paths:
    M llvm/include/llvm/Target/TargetInstrPredicate.td
    M llvm/include/llvm/Target/TargetSchedule.td
    A llvm/test/TableGen/MacroFusion.td
    M llvm/utils/TableGen/CMakeLists.txt
    A llvm/utils/TableGen/MacroFusionPredicatorEmitter.cpp
    M llvm/utils/TableGen/PredicateExpander.cpp
    M llvm/utils/TableGen/PredicateExpander.h

  Log Message:
  -----------
  [TableGen] Add a backend to generate MacroFusion predicators (#72222)

`FusionPredicate` is used to predicate if target instruction matches
 the requirement. The targets can be firstMI, secondMI or both.

The `Fusion` contains a list of `FusionPredicate`. The generated code
will be like:
```
bool isNAME(const TargetInstrInfo &TII,
            const TargetSubtargetInfo &STI,
            const MachineInstr *FirstMI,
            const MachineInstr &SecondMI) {
  auto &MRI = SecondMI.getMF()->getRegInfo();
  /* Predicates */
  return true;
}
```

A boilerplate class called `SimpleFusion` is added. `SimpleFusion` has
a predefined structure of predicates and accepts predicate for
`firstMI`, predicate for `secondMI` and epilog/prolog as arguments.
The generated code for `SimpleFusion` will be like:
```
bool isNAME(const TargetInstrInfo &TII,
            const TargetSubtargetInfo &STI,
            const MachineInstr *FirstMI,
            const MachineInstr &SecondMI) {
  auto &MRI = SecondMI.getMF()->getRegInfo();
  /* Prolog */
  /* Predicate for `SecondMI` */
  /* Wildcard */
  /* Predicate for `FirstMI` */
  /* Check One Use */
  /* Tie registers */
  /* Epilog */
  return true;
}
```




More information about the All-commits mailing list