This is an archive of the discontinued LLVM Phabricator instance.

TableGen: fix typeIsConvertibleTo for record types
ClosedPublic

Authored by nhaehnle on Feb 21 2018, 2:43 AM.

Details

Summary

Only check whether the left-hand side type is a subclass (or equal to)
the right-hand side type.

This requires a further fix in handling !if expressions and in type
resolution.

Furthermore, reverse the order of superclasses so that resolveTypes will
find a least common ancestor at least in simple cases.

Add a test that used to be accepted without flagging the obvious type
error.

Change-Id: Ib366db1a4e6a079f1a0851e469b402cddae76714

Diff Detail

Repository
rL LLVM

Event Timeline

nhaehnle created this revision.Feb 21 2018, 2:43 AM
tra added inline comments.Feb 21 2018, 5:24 PM
test/TableGen/if-type.td
10 ↗(On Diff #135220)

Would A x = !if(cc, b, c); be expected to work? If yes, you may want to add a positive test case for it.

nhaehnle updated this revision to Diff 135425.Feb 22 2018, 7:32 AM
nhaehnle marked an inline comment as done.

Added positive test.

test/TableGen/if-type.td
10 ↗(On Diff #135220)

Yes, it's expected to work, and it does work :) I've added a test for it.

tra added inline comments.Feb 22 2018, 9:37 AM
test/TableGen/if.td
76–85 ↗(On Diff #135425)

I think there should be some defs and CHECKs to demonstrate and verify what we expect to generate.

It's actually not obvious for me whether a particular instance of EX is going to end up with.
I think it will contain only the subset of fields in E from E1/E2. Or, perhaps, I'm wrong and it will contain full set of records from either E1 or E2, depending on cc. Either way it would be good to illustrate expected behavior.

nhaehnle updated this revision to Diff 135529.Feb 22 2018, 3:32 PM
nhaehnle marked an inline comment as done.

Add defs for EX test.

test/TableGen/if.td
76–85 ↗(On Diff #135425)

I don't think the question about fields makes much sense because x will just reference some other record. Of course an expression x.fieldname will only allow access to fields in E.

Anyway, I'm adding some defs to illustrate this, and I suppose it's a good check anyway to make sure things don't break when resolving b and c.

tra accepted this revision.Feb 22 2018, 4:39 PM
tra added inline comments.
test/TableGen/if.td
76–85 ↗(On Diff #135425)

Right. s/contain/make accessible/.

Thank you for adding the defs.

This revision is now accepted and ready to land.Feb 22 2018, 4:39 PM
This revision was automatically updated to reflect the committed changes.