[PATCH] D66514: GlobalISel/TableGen: Handle setcc patterns

Daniel Sanders via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 21 13:31:43 PDT 2019


dsanders added a comment.

I've only skimmed part of the patch so far but I had a couple comments:

> This requires duplicating the Predicate enum to avoid a circular build
>  dependency between TableGen and the IR library. I have a patch which
>  moves it to support, but it's rather disruptive.

It looks like you only need the enum to convert between ISD::CondCode and CmpInst::Predicate. One way of avoiding the duplication is to emit something like `getICmpPredicate(ISD::SETOEQ)` to the table or similar. If the conversion function is a constexpr then it should be as efficient as converting in/before tablegen and not turn the state machine into a static initializer. Another way would be to embed the conversion result in the tablegen defs:

  def SETOEQ: CondCode<"FCMP_OEQ", "ICMP_OEQ">

and have tablegen pick between the two results.



================
Comment at: include/llvm/Target/GlobalISel/SelectionDAGCompat.td:112-113
 def : GINodeEquiv<G_FMAXNUM_IEEE, fmaxnum_ieee>;
+def : GINodeEquiv<G_FCMP, setcc>;
+def : GINodeEquiv<G_ICMP, setcc>;
 
----------------
The way we've handled one to many mappings elsewhere is to include the distinguishing information in GINodeEquiv (e.g. IfSignExtend). It's not strictly necessary but it's nice to be able to read these declarations and see the conditions.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66514/new/

https://reviews.llvm.org/D66514





More information about the llvm-commits mailing list