[PATCH] D50708: [Tablegen][MCInstPredicate] Removed redundant template argument from class TIIPredicate, and implemented verification rules for TIIPredicates in CodeGenSchedule.cpp.

Andrea Di Biagio via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 14 08:12:33 PDT 2018


andreadb created this revision.
andreadb added reviewers: RKSimon, mattd, courbet, gchatelet, craig.topper, atrick.

This patch removes redundant template argument `TargetName` from TIIPredicate.
Tablegen can always infer the target name from the context. So we don't need to force users of TIIPredicate to always specify it.

This allows us to better modularize the tablegen class hierarchy for so-called "function predicates". class FunctionPredicateBase has been added; it is currently used as a building block for TIIPredicates. However, I plan to reuse that class to define other function predicates classes (i.e. not just TIIPredicates).
For example, this can be a first step towards implementing proper support for dependency breaking instructions in tablegen.

This patch also adds a verification step on TIIPredicates in tablegen.
We cannot have multiple TIIPredicates with the same name. Otherwise, this will cause build errors later on, when tablegen'd .inc files are included by cpp files and then compiled.

For example, if I add the following conflicting TIIPredicate at the end of X86SchedPredicates.td

  def : TIIPredicate<"isThreeOperandsLEA", MCReturnStatement<TruePred>>;

tablegen (-gen-instr-info) now generates the following error:

  Included from /home/andrea/llvm/lib/Target/X86/X86.td:405:
  /home/andrea/llvm/lib/Target/X86/X86SchedPredicates.td:58:1: error: TIIPredicate isThreeOperandsLEA is multiply defined.
  def : TIIPredicate<"isThreeOperandsLEA", MCReturnStatement<TruePred>>;
  ^
  Included from /home/andrea/llvm/lib/Target/X86/X86.td:405:
  /home/andrea/llvm/lib/Target/X86/X86SchedPredicates.td:55:1: note:  Previous definition of isThreeOperandsLEA was here.
  def IsThreeOperandsLEAFn :
  ^
  Included from /home/andrea/llvm/lib/Target/X86/X86.td:405:
  /home/andrea/llvm/lib/Target/X86/X86SchedPredicates.td:58:1: error: Found conflicting definitions of TIIPredicate.
  def : TIIPredicate<"isThreeOperandsLEA", MCReturnStatement<TruePred>>;
  ^

Please let me know if okay to commit.

Thanks,

- Andrea


https://reviews.llvm.org/D50708

Files:
  include/llvm/Target/TargetInstrPredicate.td
  lib/Target/X86/X86SchedPredicates.td
  utils/TableGen/CodeGenSchedule.cpp
  utils/TableGen/CodeGenSchedule.h
  utils/TableGen/InstrInfoEmitter.cpp
  utils/TableGen/PredicateExpander.cpp
  utils/TableGen/PredicateExpander.h
  utils/TableGen/SubtargetEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50708.160586.patch
Type: text/x-patch
Size: 9512 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180814/c6f3da2e/attachment.bin>


More information about the llvm-commits mailing list