Page MenuHomePhabricator

[AsmParser] Add DiagnosticString to register classes in tablegen

Authored by olista01 on Aug 14 2017, 9:24 AM.



This allows a DiagnosticType and/or DiagnosticString to be associated
with a RegisterClass in tablegen, so that we can emit diagnostics in the
assembler when a register operand is incorrect.

DiagnosticType creates a predictable enum value, which gets returned as
the error code when an operand does not match, and can be used by the
assembly parser to map to a user-facing diagnostic. DiagnosticString
creates an anonymous enum value (currently based on the tablegen class
name), and a function to map from enum values to strings will be
generated. Both of these work the same was as they do for AsmOperand.

This isn't used by any targets yet, but has one (positive) side-effect.
It improves the diagnostic codes returned by validateOperandClass - we
always want to emit the diagnostic that relates to the expected operand
class, but this wasn't always being done when the expected and actual
classes were completely different (token/register/custom). This causes a
few AArch64 diagnostics to be improved, as Match_InvalidOperand was
being returned instead of a specific diagnostic type.

Diff Detail


Event Timeline

olista01 created this revision.Aug 14 2017, 9:24 AM

See D36692 and D36693 for how this will be used.

echristo accepted this revision.Oct 9 2017, 1:50 PM

Other than being relatively certain some of your lines are > 80 columns this is fine :)


This revision is now accepted and ready to land.Oct 9 2017, 1:50 PM
This revision was automatically updated to reflect the committed changes.
RKSimon added inline comments.

@olista01 We're seeing "switch statement contains 'default' but no 'case' labels" warnings (and we build with Werror.....).

Please can you update this so that it just returns MCTargetAsmParser::Match_InvalidOperand if there are no regclass entries?

olista01 added inline comments.Oct 12 2017, 2:29 AM