[PATCH] D36691: [AsmParser] Add DiagnosticString to register classes in tablegen

Oliver Stannard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 14 09:26:09 PDT 2017


olista01 created this revision.
Herald added subscribers: kristof.beyls, javed.absar, aemerson.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D36691

Files:
  include/llvm/Target/Target.td
  test/MC/AArch64/arm64-diags.s
  test/MC/AArch64/basic-a64-diagnostics.s
  utils/TableGen/AsmMatcherEmitter.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36691.111001.patch
Type: text/x-patch
Size: 13780 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170814/ad39afa6/attachment.bin>


More information about the llvm-commits mailing list