This is an archive of the discontinued LLVM Phabricator instance.

TableGen: Type-check BinOps
ClosedPublic

Authored by nhaehnle on Mar 5 2018, 12:20 PM.

Details

Summary

Additionally, allow more than two operands to !con, !add, !and, !or
in the same way as is already allowed for !listconcat and !strconcat.

Change-Id: I9659411f554201b90cd8ed7c7e004d381a66fa93

Diff Detail

Repository
rL LLVM

Event Timeline

nhaehnle created this revision.Mar 5 2018, 12:20 PM
tra added a comment.Mar 7 2018, 11:54 AM

This change should come with an update to the docs.

One thing jumped at me -- we have three different variants of concatenation -- !con, !listconcat and !strconcat (along with '#'). Do we need all of them? I think we could get by with one, which would glue together items of the same kind.

test/TableGen/Paste.td
15–24 ↗(On Diff #137060)

This does not seem to test anything relevant to this patch.Was this change supposed to be here or in some other patch?

test/TableGen/arithmetic.td
14 ↗(On Diff #137060)

I'm not sure if this file was meant to be in this patch. It does not seem to use 3+operand variants of !con, !add, !and, !or.

In D44112#1030389, @tra wrote:

This change should come with an update to the docs.

True, I'm adding that.

One thing jumped at me -- we have three different variants of concatenation -- !con, !listconcat and !strconcat (along with '#'). Do we need all of them? I think we could get by with one, which would glue together items of the same kind.

I agree. The nicest option would be for # to cover everything, though it is a bit special in that it does automatic casts to string. Then again, it's probably good enough to just not do those conversions if one of the LHS or RHS are dags or lists.

test/TableGen/Paste.td
15–24 ↗(On Diff #137060)

This test fails without the change in TGParser.cpp:1957. Previously, parsing the paste passed string as required type to ParseValue, which would fail in the stricter checks when parsing the !add.

test/TableGen/arithmetic.td
14 ↗(On Diff #137060)

This tests that using different operand types on those operations is still allowed. I've added a comment and the full set of ops.

nhaehnle updated this revision to Diff 137721.Mar 9 2018, 3:38 AM

Update the docs, relax operands to !add, !and, !or in the same
way as shifts and add tests for it.

tra accepted this revision.Mar 9 2018, 9:48 AM
tra added inline comments.
docs/TableGen/LangIntro.rst
270–271 ↗(On Diff #137721)

We may add few details regarding intended behavior (or lack of guarantees).
I think we should mention that we operate on 64-bit integers and that results of negative shift count or shift overflow is undefined.

This revision is now accepted and ready to land.Mar 9 2018, 9:48 AM
This revision was automatically updated to reflect the committed changes.