Page MenuHomePhabricator

TableGen: Add support of Intrinsics with multiple returns
ClosedPublic

Authored by wenbos on May 4 2017, 5:38 PM.

Details

Summary

This patch deals with intrinsics with multiple outputs, for example load instrinsic with address updated.

DAG selection for Instrinsics could be done either through source code or tablegen. Handling all intrinsics in source code would introduce a huge chunk of repetitive code if we have a large number of intrinsic that return multiple values (see NVPTX as an example). While intrinsic class in tablegen supports multiple outputs, tablegen only supports Intrinsics with zero or one output on TreePattern. This appears to be a simple bug in tablegen that is fixed by this patch.

Intrinsics is defined as:

def int_xxx_load_addr_updated: Intrinsic<[llvm_i32_ty, llvm_ptr_ty], [llvm_ptr_ty, llvm_i32_ty], []>;

Instruction will be defined as:

def L32_X: Inst<(outs reg:$d1, reg:$d2), (ins reg:$s1, reg:$s2), "ld32_x $d1, $d2, $s2", [(set i32:$d1, i32:$d2, (int_xxx_load_addr_updated i32:$s1, i32:$s2))]>;

Diff Detail

Repository
rL LLVM

Event Timeline

wenbos created this revision.May 4 2017, 5:38 PM
bjope added a subscriber: bjope.May 4 2017, 11:40 PM
sanjoy added a subscriber: sanjoy.May 7 2017, 2:03 PM
hfinkel added a subscriber: hfinkel.May 9 2017, 7:32 PM
hfinkel added inline comments.
utils/TableGen/CodeGenDAGPatterns.cpp
2208 ↗(On Diff #97897)

Can you please add a comment explaining why GetNumNodeResults need to be called here (and not, say, below, where it is now).

wenbos updated this revision to Diff 98403.May 9 2017, 11:24 PM

new comments were added

wenbos added inline comments.May 9 2017, 11:26 PM
utils/TableGen/CodeGenDAGPatterns.cpp
2208 ↗(On Diff #97897)

Hi Hal, comments are added in latest patch.

Does matching instructions with multiple outputs now work except for this intrinsics problem, or is further work necessary to support this in general?

utils/TableGen/CodeGenDAGPatterns.cpp
2208 ↗(On Diff #98403)

covert -> convert, and some grammar improvements:

// Get the actual number of results before Operator is converted to an intrinsic node (which is hard-coded to have either zero or one result).

wenbos added a comment.Jun 1 2017, 6:38 PM

Does matching instructions with multiple outputs now work except for this intrinsics problem, or is further work necessary to support this in general?

Yes, it works now.

wenbos updated this revision to Diff 101160.Jun 1 2017, 6:47 PM

comments are updated

hfinkel accepted this revision.Jun 1 2017, 9:03 PM

LGTM

This revision is now accepted and ready to land.Jun 1 2017, 9:03 PM

Hi Hal, can you commit it since I have no commit access?

Hi Hal, can you commit it since I have no commit access?

Wenbo, I will commit this.

Hi Hal, can you commit it since I have no commit access?

Wenbo, I will commit this.

Thx a lot, Ehsan.

This revision was automatically updated to reflect the committed changes.