[PATCH] D91331: [NFC] Add hook for target to customize different legalization action according to the input type

Nemanja Ivanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Nov 19 06:38:46 PST 2020


nemanjai added a comment.

I know that Simon mentioned that perhaps we should limit this to cast operations but TBH, I think there may be value in making this general and passing in the `SDNode` itself rather than opcode/type(s). Then all of this logic can be greatly simplified into something like this:

  void SelectionDAGLegalize::LegalizeOp(SDNode *Node) {
    LLVM_DEBUG(dbgs() << "\nLegalizing: "; Node->dump(&DAG));
    if (TLI.opRequiresLibCall(Node))
      ConvertNodeToLibcall(Node);

And presumably, there would be another function for the TLI to provide the `RTLIB::Libcall` for the specific `SDNode`.

And of course, this needs some tests.



================
Comment at: llvm/include/llvm/CodeGen/TargetLowering.h:1081
+  /// target. If not, the operation is illegal.
+  virtual bool isSupportedCastOperation(unsigned Op, EVT SrcVT,
+                                        EVT DestVT) const {
----------------
The semantics here are rather subtle and I don't think the name describes the semantics adequately.
"Supported" in this case means that some expansion can be performed - not that the operation is `Legal` for the target. The purpose of this appears to be to determine if the conversion requires a libcall. So why not name it that? Perhaps:
```
virtual bool castRequiresLibCall(unsigned Op, EVT SrcVT, EVT DestVT) const {
  return false;
}
```
And then of course, flip the ternary operator above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91331



More information about the llvm-commits mailing list