This is an archive of the discontinued LLVM Phabricator instance.

[TableGen] Fix spurious type error in bit assignment.
ClosedPublic

Authored by simon_tatham on Feb 7 2020, 6:47 AM.

Details

Summary

The following example gives the error message "expected value of type
'bits<32>', got 'bit'" on the assignment.

class Instruction { bits<32> encoding; }
def foo: Instruction { let encoding{10} = !eq(0, 1); }

But there's nothing wrong with this code: 'bit' is a perfectly good
type for the RHS of an assignment to a single bit of an
instruction encoding.

The problem is that ParseBodyItem is accidentally type-checking the
RHS against the full type of the encoding field, without adjusting
it in the case where we're only assigning to a subset of the bits. The
fix is trivial.

Event Timeline

simon_tatham created this revision.Feb 7 2020, 6:47 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2020, 6:47 AM
hfinkel accepted this revision.Feb 7 2020, 6:55 AM

LGTM

This revision is now accepted and ready to land.Feb 7 2020, 6:55 AM
This revision was automatically updated to reflect the committed changes.