[llvm-dev] Matching BlockAddress DAG Nodes in TableGen

Zhang via llvm-dev llvm-dev at lists.llvm.org
Wed Mar 31 20:09:46 PDT 2021


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>


More information about the llvm-dev mailing list