1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00
llvm-mirror/include/llvm/MC
Oliver Stannard 14e90c0414 [Assembler] Report multiple near misses for invalid instructions
The current table-generated assembly instruction matcher returns a
64-bit error code when matching fails. Since multiple instruction
encodings with the same mnemonic can fail for different reasons, it uses
some heuristics to decide which message is important.

This heuristic does not work well for targets that have many encodings
with the same mnemonic but different operands, or which have different
versions of instructions controlled by subtarget features, as it is hard
to know which encoding the user was intending to use.

Instead of trying to improve the heuristic in the table-generated
matcher, this patch changes it to report a list of near-miss encodings.
This list contains an entry for each encoding with the correct mnemonic,
but with exactly one thing preventing it from being valid. This thing
could be a single invalid operand, a missing target feature or a failed
target-specific validation function.

The target-specific assembly parser can then report an error message
giving multiple options for instruction variants that the user may have
been trying to use. For example, I am working on a patch to use this for
ARM, which can give this error for an invalid instruction for ARMv6-M:

  <stdin>:8:3: error: invalid instruction, multiple near-miss encodings found
    adds r0, r1, #0x8
    ^
  <stdin>:8:3: note: for one encoding: instruction requires: thumb2
    adds r0, r1, #0x8
    ^
  <stdin>:8:16: note: for one encoding: expected an integer in range [0, 7]
    adds r0, r1, #0x8
                 ^
  <stdin>:8:16: note: for one encoding: expected a register in range [r0, r7]
    adds r0, r1, #0x8
                 ^

This also allows the target-specific assembly parser to apply its own
heuristics to suppress some errors. For example, the error "instruction
requires: arm-mode" is never going to be useful when targeting an
M-profile architecture (which does not have ARM mode).

This patch just adds the target-independent mechanism for doing this,
all targets still use the old mechanism. I've added a bit in the
AsmParser tablegen class to allow targets to switch to this new
mechanism. To use this, the target-specific assembly parser will have to
be modified for the change in signature of MatchInstructionImpl, and to
report errors based on the list of near-misses.

Differential revision: https://reviews.llvm.org/D27620

llvm-svn: 314774
2017-10-03 09:33:12 +00:00
..
MCDisassembler Doxygen formatting. NFCI 2017-07-10 22:11:50 +00:00
MCParser [Assembler] Report multiple near misses for invalid instructions 2017-10-03 09:33:12 +00:00
ConstantPools.h [MC] Fix constant pools with DenseMap sentinel values 2017-05-30 09:37:11 +00:00
LaneBitmask.h Implement LaneBitmask::getNumLanes and LaneBitmask::getHighestLane 2017-07-20 19:43:19 +00:00
MachineLocation.h Remove the unused Offset field from MachineLocation (NFC) 2017-08-02 17:07:38 +00:00
MCAsmBackend.h Fully fix the movw/movt addend. 2017-07-11 23:18:25 +00:00
MCAsmInfo.h sink DebugCompressionType into MC for exposing to clang 2017-06-09 00:40:19 +00:00
MCAsmInfoCOFF.h [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-11 00:27:28 +00:00
MCAsmInfoDarwin.h [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-11 00:27:28 +00:00
MCAsmInfoELF.h [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-11 00:27:28 +00:00
MCAsmInfoWasm.h [WebAssembly] Add skeleton MC support for the Wasm container format 2017-02-22 01:23:18 +00:00
MCAsmLayout.h
MCAssembler.h ARM: move some logic from processFixupValue to applyFixup. 2017-06-23 22:52:36 +00:00
MCCodeEmitter.h [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-08 22:23:19 +00:00
MCCodeView.h Re-land "Fix Bug 30978 by emitting cv file checksums." 2017-09-19 18:14:45 +00:00
MCContext.h [WebAssembly] Remove flags from MCSectionWasm 2017-09-12 18:31:24 +00:00
MCDirectives.h
MCDwarf.h MC: add support for cfi_return_column 2017-07-28 03:39:19 +00:00
MCELFObjectWriter.h [mips] Do not pass redundant IsN64 flag to MCELFObjectTargetWriter. NFC 2017-09-21 14:04:47 +00:00
MCELFStreamer.h Reland r298901 with modifications (reverted in r298932) 2017-04-03 21:50:04 +00:00
MCExpr.h [MC] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC). 2017-04-26 22:31:39 +00:00
MCFixedLenDisassembler.h
MCFixup.h Documentation fix. NFC. 2017-07-13 17:00:30 +00:00
MCFixupKindInfo.h
MCFragment.h Mark dump() methods as const. NFC 2017-06-21 22:19:17 +00:00
MCInst.h [MC] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC). 2017-04-26 22:31:39 +00:00
MCInstBuilder.h
MCInstPrinter.h [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-11 00:27:28 +00:00
MCInstrAnalysis.h [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-11 00:27:28 +00:00
MCInstrDesc.h [ARM|CodeGen] Improve the code in FastISel 2017-07-18 10:19:48 +00:00
MCInstrInfo.h
MCInstrItineraries.h [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-11 00:27:28 +00:00
MCLabel.h [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-08 22:23:19 +00:00
MCLinkerOptimizationHint.h [MC] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC). 2017-04-26 22:31:39 +00:00
MCMachObjectWriter.h Simplify interface now that we don't need to pass IsPCRel. NFC. 2017-07-11 23:56:10 +00:00
MCObjectFileInfo.h Don't pass the code model to MC 2017-08-02 20:32:26 +00:00
MCObjectStreamer.h Re-land "Fix Bug 30978 by emitting cv file checksums." 2017-09-19 18:14:45 +00:00
MCObjectWriter.h Simplify interface now that we don't need to pass IsPCRel. NFC. 2017-07-11 23:56:10 +00:00
MCRegisterInfo.h [MC] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC). 2017-04-26 22:31:39 +00:00
MCSchedule.h Cleanup some problems with LLVM_ENABLE_DUMP in release builds, and 2017-09-27 21:19:56 +00:00
MCSection.h Mark dump() methods as const. NFC 2017-06-21 22:19:17 +00:00
MCSectionCOFF.h [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-10 01:33:54 +00:00
MCSectionELF.h Fix asm printing of associated sections. 2017-03-14 19:28:51 +00:00
MCSectionMachO.h Move Object format code to lib/BinaryFormat. 2017-06-07 03:48:56 +00:00
MCSectionWasm.h [WebAssembly] MC: Create wasm data segments based on MCSections 2017-09-15 20:54:59 +00:00
MCStreamer.h Re-land "Fix Bug 30978 by emitting cv file checksums." 2017-09-19 18:14:45 +00:00
MCSubtargetInfo.h Subtarget support for parameterized register class information 2017-09-14 20:44:20 +00:00
MCSymbol.h [MC] Fix some Clang-tidy modernize-use-using warnings; other minor fixes (NFC). 2017-04-26 22:31:39 +00:00
MCSymbolCOFF.h [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-10 01:33:54 +00:00
MCSymbolELF.h
MCSymbolMachO.h
MCSymbolWasm.h [WebAssembly] Fix types for address taken functions 2017-07-05 20:25:08 +00:00
MCTargetOptions.h sink DebugCompressionType into MC for exposing to clang 2017-06-09 00:40:19 +00:00
MCTargetOptionsCommandFlags.h
MCValue.h Fix use of uninitialized value. 2017-06-24 00:18:15 +00:00
MCWasmObjectWriter.h [WebAssembly] Cleanup WebAssemblyWasmObjectWriter 2017-06-13 18:51:50 +00:00
MCWasmStreamer.h MC: De-duplicate the object streamer implementations of EmitFileDirective into MCObjectStreamer. NFCI. 2017-03-03 21:22:06 +00:00
MCWin64EH.h
MCWinCOFFObjectWriter.h Add missing forward declaration. 2017-06-26 21:11:29 +00:00
MCWinCOFFStreamer.h MC: De-duplicate the object streamer implementations of EmitFileDirective into MCObjectStreamer. NFCI. 2017-03-03 21:22:06 +00:00
MCWinEH.h
SectionKind.h
StringTableBuilder.h [MC] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC). 2017-02-11 00:27:28 +00:00
SubtargetFeature.h Subtarget support for parameterized register class information 2017-09-14 20:44:20 +00:00