[PATCH] D43680: TableGen: Generalize record types to fix typeIsConvertibleTo et al.

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 07:56:32 PST 2018


nhaehnle created this revision.
nhaehnle added reviewers: arsenm, craig.topper, tra, MartinO.
Herald added a subscriber: mgrang.
nhaehnle added a dependency: D43679: TableGen: Use DefInit::getDef() instead of the type's getRecord().
nhaehnle added a dependent revision: D43564: TableGen: Introduce an abstract variable resolver interface.

Allow RecordRecTy to represent the type "subtype of N superclasses",
where N may be zero. Furthermore, generate RecordRecTy instances only
with actual classes in the list.

Keeping track of multiple superclasses is required to resolve the type
of a list correctly in some cases. The old code relied on the incorrect
behavior of typeIsConvertibleTo, and an earlier version of this change
relied on a modified ordering of superclasses (it was committed in
r325884 and then reverted because unfortunately some of clang-tblgen's
backends depend on the ordering).

Previously, the DefInit for each Record would have a RecordRecTy of
that Record as its type. Now, all defs with the same superclasses will
share the same type.

This allows us to be more consistent with standard expectations about
type checks involving records:

- typeIsConvertibleTo actually requires the LHS to be a subtype of the RHS

- resolveTypes will return the least supertype of given record types in all cases

- different record types in the two branches of an !if are handled correctly

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

Change-Id: Ib366db1a4e6a079f1a0851e469b402cddae76714


Repository:
  rL LLVM

https://reviews.llvm.org/D43680

Files:
  include/llvm/TableGen/Record.h
  lib/TableGen/Record.cpp
  lib/TableGen/TGParser.cpp
  test/TableGen/if-type.td
  test/TableGen/if.td

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D43680.135643.patch
Type: text/x-patch
Size: 12270 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180223/3ef385ab/attachment.bin>


More information about the llvm-commits mailing list