llvm-project/llvm/lib/MC
Wouter van Oortmerssen 9647a6f719 [WebAssembly] Added initial type checker to MC Assembler
This to protect against non-sensical instruction sequences being assembled,
which would either cause asserts/crashes further down, or a Wasm module being output that doesn't validate.

Unlike a validator, this type checker is able to give type-errors as part of the parsing process, which makes the assembler much friendlier to be used by humans writing manual input.

Because the MC system is single pass (instructions aren't even stored in MC format, they are directly output) the type checker has to be single pass as well, which means that from now on .globaltype and .functype decls must come before their use. An extra pass is added to Codegen to collect information for this purpose, since AsmPrinter is normally single pass / streaming as well, and would otherwise generate this information on the fly.

A `-no-type-check` flag was added to llvm-mc (and any other tools that take asm input) that surpresses type errors, as a quick escape hatch for tests that were not intended to be type correct.

This is a first version of the type checker that ignores control flow, i.e. it checks that types are correct along the linear path, but not the branch path. This will still catch most errors. Branch checking could be added in the future.

Differential Revision: https://reviews.llvm.org/D104945
2021-07-09 14:07:25 -07:00
..
MCDisassembler [MC] Refactor MCObjectFileInfo initialization and allow targets to create MCObjectFileInfo 2021-05-23 14:15:23 -07:00
MCParser [ms] [llvm-ml] Standardize blocking of lexical substitution 2021-07-02 14:17:37 -04:00
CMakeLists.txt [CSSPGO] Pseudo probe encoding and emission. 2020-12-10 17:29:28 -08:00
ConstantPools.cpp
ELFObjectWriter.cpp [MC][ELF] Change SHT_LLVM_CALL_GRAPH_PROFILE relocations from SHT_RELA to SHT_REL 2021-06-24 21:35:48 -07:00
MCAsmBackend.cpp RISCV: adjust handling of relocation emission for RISCV 2021-06-17 08:20:02 -07:00
MCAsmInfo.cpp [AIX] Use AsmParser to do inline asm parsing 2021-07-02 16:12:21 +00:00
MCAsmInfoCOFF.cpp
MCAsmInfoDarwin.cpp
MCAsmInfoELF.cpp
MCAsmInfoWasm.cpp
MCAsmInfoXCOFF.cpp [AIX] Use AsmParser to do inline asm parsing 2021-07-02 16:12:21 +00:00
MCAsmMacro.cpp
MCAsmStreamer.cpp [MCStreamer] Move emission of attributes section into MCELFStreamer 2021-06-30 16:00:27 -05:00
MCAssembler.cpp RISCV: adjust handling of relocation emission for RISCV 2021-06-17 08:20:02 -07:00
MCCodeEmitter.cpp
MCCodeView.cpp [CodeView] Fix inline sites that are missing code offsets. 2020-12-07 13:01:53 -08:00
MCContext.cpp PR51018: Remove explicit conversions from SmallString to StringRef to future-proof against C++23 2021-07-08 13:37:57 -07:00
MCDwarf.cpp RISCV: adjust handling of relocation emission for RISCV 2021-06-17 08:20:02 -07:00
MCELFObjectTargetWriter.cpp
MCELFStreamer.cpp [MCStreamer] Move emission of attributes section into MCELFStreamer 2021-06-30 16:00:27 -05:00
MCExpr.cpp RISCV: adjust handling of relocation emission for RISCV 2021-06-17 08:20:02 -07:00
MCFragment.cpp [CSSPGO] Pseudo probe encoding and emission. 2020-12-10 17:29:28 -08:00
MCInst.cpp [MC] Add the ability to pass MCRegisterInfo to dump_pretty. 2021-05-14 18:21:57 -07:00
MCInstPrinter.cpp
MCInstrAnalysis.cpp
MCInstrDesc.cpp
MCInstrInfo.cpp
MCLabel.cpp
MCLinkerOptimizationHint.cpp
MCMachOStreamer.cpp [MC] Untangle MCContext and MCObjectFileInfo 2021-05-05 10:03:02 -07:00
MCMachObjectTargetWriter.cpp
MCNullStreamer.cpp
MCObjectFileInfo.cpp [lld][WebAssembly] Enable string tail merging in debug sections 2021-05-18 12:25:39 -07:00
MCObjectStreamer.cpp RISCV: adjust handling of relocation emission for RISCV 2021-06-17 08:20:02 -07:00
MCObjectWriter.cpp
MCPseudoProbe.cpp [CSSPGO] Pseudo probe encoding and emission. 2020-12-10 17:29:28 -08:00
MCRegisterInfo.cpp
MCSchedule.cpp
MCSection.cpp [llvm] Use llvm::lower_bound and llvm::upper_bound (NFC) 2021-01-29 23:23:36 -08:00
MCSectionCOFF.cpp
MCSectionELF.cpp [MC][ELF] Support for zero flag section groups 2021-02-16 14:23:40 -08:00
MCSectionMachO.cpp Support `#pragma clang section` directives on MachO targets 2021-02-25 09:30:10 -08:00
MCSectionWasm.cpp [WebAssembly] Add TLS data segment flag: WASM_SEG_FLAG_TLS 2021-05-12 13:31:02 -07:00
MCSectionXCOFF.cpp [XCOFF][AIX] Add Global Variables Directly to TOC for 32 bit AIX 2021-04-30 14:48:02 +00:00
MCStreamer.cpp Implement DW_CFA_LLVM_* for Heterogeneous Debugging 2021-06-14 08:51:50 +05:30
MCSubtargetInfo.cpp AMDGPU: Add target id and code object v4 support 2021-03-24 11:54:05 -04:00
MCSymbol.cpp
MCSymbolELF.cpp
MCSymbolXCOFF.cpp [XCOFF][DebugInfo] support DWARF for XCOFF for assembly output. 2021-03-04 21:07:52 -05:00
MCTargetOptions.cpp [WebAssembly] Added initial type checker to MC Assembler 2021-07-09 14:07:25 -07:00
MCTargetOptionsCommandFlags.cpp [WebAssembly] Added initial type checker to MC Assembler 2021-07-09 14:07:25 -07:00
MCValue.cpp
MCWasmObjectTargetWriter.cpp
MCWasmStreamer.cpp [WebAssembly][MC] Remove useless overrides in MCWasmStreamer 2020-11-17 07:09:49 -08:00
MCWin64EH.cpp Reapply "[CodeGen] [WinException] Only produce handler data at the end of the function if needed" 2020-11-23 23:17:03 +02:00
MCWinCOFFStreamer.cpp [MC] Untangle MCContext and MCObjectFileInfo 2021-05-05 10:03:02 -07:00
MCWinEH.cpp
MCXCOFFObjectTargetWriter.cpp
MCXCOFFStreamer.cpp
MachObjectWriter.cpp
StringTableBuilder.cpp [ADT] Move DenseMapInfo for ArrayRef/StringRef into respective headers (NFC) 2021-06-03 18:34:36 +02:00
SubtargetFeature.cpp
WasmObjectWriter.cpp [WebAssembly] Make tag attribute's encoding uint8 2021-06-21 21:22:39 -07:00
WinCOFFObjectWriter.cpp [COFF] Fix ARM and ARM64 REL32 relocations to be relative to the end of the relocation 2021-05-12 09:53:43 +03:00
XCOFFObjectWriter.cpp [XCOFF][NFC] add DWARF section support in XCOFF object writer 2021-07-05 03:13:29 +00:00