Zhang via llvm-dev
2021-Apr-01 03:09 UTC
[llvm-dev] Matching BlockAddress DAG Nodes in TableGen
Hi: I've written the following TableGen pattern matching code in my .td: ``` def : Pat<(set GP64:$dst,blockaddress:$tba),(i64 (MOVR8 tblockaddress:$tba))>; ``` Which I assume means it would match the following DAG Node: ```` i64 XX = BlockAddress(@func, at BB) 0 ```` but TableGen asserted out with ``` Assertion failed: (getOperator()->isSubClassOf("SDNodeXForm") && "Unknown node type!"), function ApplyTypeConstraints, file LLVM/llvm/utils/TableGen/CodeGenDAGPatterns.cpp, line 2618. ``` Then I tried to custom lower BlockAddress nodes with custom ISD, yielding the following DAG Node: ``` t162: i64 = LOADBLOCKADDRESS TargetBlockAddress:i64<@main, %odd.i18> 0 ``` then I tried to match this DAG Node in TableGen: ``` def SDT_LOADBLOCKADDRESS : SDTypeProfile<1,1,[SDTCisInt<0>,SDTCisVT<1,i64>]>; def _LOADBLOCKADDRESS : SDNode<"CUSTOMISD::LOADBLOCKADDRESS",SDT_LOADBLOCKADDRESS,[SDNPHasChain]>; ... def : Pat<(i64 (_LOADBLOCKADDRESS tblockaddress:$tba)),(i64 (MOVXI8 tblockaddress:$tba))>; ``` Which failed when matching opcode OPC_RecordChild1 ``` unsigned ChildNo = Opcode-OPC_RecordChild0; if (ChildNo >= N.getNumOperands()) break; // Match fails if out of range child #. ``` due to ChildNo (1) >= N.getNumOperands() Zhang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210401/7e292384/attachment.html>
Zhang via llvm-dev
2021-Apr-01 03:23 UTC
[llvm-dev] Matching BlockAddress DAG Nodes in TableGen
For the custom lowering method, removing the extra SDNPHasChain resolved the issue. However I still don't understand why the first pattern matching method didn't work ------------------ Original ------------------ From: "llvm-dev"<llvm-dev at lists.llvm.org>; Date: Thu, Apr 1, 2021 11:10 AM To: "llvm-dev"<llvm-dev at lists.llvm.org>; Subject: [llvm-dev] Matching BlockAddress DAG Nodes in TableGen Hi: I've written the following TableGen pattern matching code in my .td: ``` def : Pat<(set GP64:$dst,blockaddress:$tba),(i64 (MOVR8 tblockaddress:$tba))>; ``` Which I assume means it would match the following DAG Node: ```` i64 XX = BlockAddress(@func, at BB) 0 ```` but TableGen asserted out with ``` Assertion failed: (getOperator()->isSubClassOf("SDNodeXForm") && "Unknown node type!"), function ApplyTypeConstraints, file LLVM/llvm/utils/TableGen/CodeGenDAGPatterns.cpp, line 2618. ``` Then I tried to custom lower BlockAddress nodes with custom ISD, yielding the following DAG Node: ``` t162: i64 = LOADBLOCKADDRESS TargetBlockAddress:i64<@main, %odd.i18> 0 ``` then I tried to match this DAG Node in TableGen: ``` def SDT_LOADBLOCKADDRESS : SDTypeProfile<1,1,[SDTCisInt<0>,SDTCisVT<1,i64>]>; def _LOADBLOCKADDRESS : SDNode<"CUSTOMISD::LOADBLOCKADDRESS",SDT_LOADBLOCKADDRESS,[SDNPHasChain]>; ... def : Pat<(i64 (_LOADBLOCKADDRESS tblockaddress:$tba)),(i64 (MOVXI8 tblockaddress:$tba))>; ``` Which failed when matching opcode OPC_RecordChild1 ``` unsigned ChildNo = Opcode-OPC_RecordChild0; if (ChildNo >= N.getNumOperands()) break; // Match fails if out of range child #. ``` due to ChildNo (1) >= N.getNumOperands() Zhang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20210401/0d4ecb4e/attachment.html>