This is an archive of the discontinued LLVM Phabricator instance.

[TableGen] Fix register class handling in TableGen's DAG ISel Matcher Generator
ClosedPublic

Authored by vhscampos on May 11 2020, 4:01 AM.

Details

Summary

In TableGen's instruction selection table generator, references to
register classes were handled by generating a matcher table entry in the
form of "EmitStringInteger, MVT::i32, 'RegisterClassID'". This ID is in
fact the enum integer value corresponding to the register class.

However, both the table generator and the table consumer
(SelectionDAGISel) assume that this ID is less than or equal to 127,
i.e. at most 7 bits. Values greater than this threshold cause completely
wrong behaviours in the instruction selection process.

This patch adds a check to determine if the enum integer value is
greater than the limit of 127. In finding so, the generator emits an
"EmitInteger" instead, which properly supports values with arbitrary
sizes.

Commit f8d044bbcfdc9e1ddc02247ffb86fe39e1f277f0 fixed the very same bug
for register subindices. The present patch now extends this cover to
register classes.

Diff Detail

Event Timeline

vhscampos created this revision.May 11 2020, 4:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 11 2020, 4:01 AM

LGTM, but needs a test in the llvm/test/TableGen/.

vhscampos updated this revision to Diff 263448.May 12 2020, 8:40 AM

Added a test.

This revision is now accepted and ready to land.May 12 2020, 10:31 AM
This revision was automatically updated to reflect the committed changes.