LLVM 20.0.0git
WebAssemblyAsmTypeCheck.h
Go to the documentation of this file.
1//==- WebAssemblyAsmTypeCheck.h - Assembler for WebAssembly -*- C++ -*-==//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file is part of the WebAssembly Assembler.
11///
12/// It contains code to translate a parsed .s file into MCInsts.
13///
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_ASMPARSER_TYPECHECK_H
17#define LLVM_LIB_TARGET_WEBASSEMBLY_ASMPARSER_TYPECHECK_H
18
20#include "llvm/MC/MCInstrInfo.h"
23#include "llvm/MC/MCSymbol.h"
24
25namespace llvm {
26
28 MCAsmParser &Parser;
29 const MCInstrInfo &MII;
30
35 wasm::WasmSignature LastSig;
36 bool TypeErrorThisFunction = false;
37 bool Unreachable = false;
38 bool is64;
39
40 void dumpTypeStack(Twine Msg);
41 bool typeError(SMLoc ErrorLoc, const Twine &Msg);
42 bool popType(SMLoc ErrorLoc, std::optional<wasm::ValType> EVT);
43 bool popRefType(SMLoc ErrorLoc);
44 bool getLocal(SMLoc ErrorLoc, const MCInst &Inst, wasm::ValType &Type);
45 bool checkEnd(SMLoc ErrorLoc, bool PopVals = false);
46 bool checkBr(SMLoc ErrorLoc, size_t Level);
47 bool checkSig(SMLoc ErrorLoc, const wasm::WasmSignature &Sig);
48 bool getSymRef(SMLoc ErrorLoc, const MCInst &Inst,
49 const MCSymbolRefExpr *&SymRef);
50 bool getGlobal(SMLoc ErrorLoc, const MCInst &Inst, wasm::ValType &Type);
51 bool getTable(SMLoc ErrorLoc, const MCInst &Inst, wasm::ValType &Type);
52
53public:
55 bool is64);
56
57 void funcDecl(const wasm::WasmSignature &Sig);
58 void localDecl(const SmallVectorImpl<wasm::ValType> &Locals);
59 void setLastSig(const wasm::WasmSignature &Sig) { LastSig = Sig; }
60 bool endOfFunction(SMLoc ErrorLoc);
61 bool typeCheck(SMLoc ErrorLoc, const MCInst &Inst, OperandVector &Operands);
62
63 void Clear() {
64 Stack.clear();
65 BrStack.clear();
66 LocalTypes.clear();
67 ReturnTypes.clear();
68 TypeErrorThisFunction = false;
69 Unreachable = false;
70 }
71};
72
73} // end namespace llvm
74
75#endif // LLVM_LIB_TARGET_WEBASSEMBLY_ASMPARSER_TYPECHECK_H
mir Rename Register Operands
Generic assembler parser interface, for use by target specific assembly parsers.
Definition: MCAsmParser.h:123
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:184
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:26
Represent a reference to a symbol from inside an expression.
Definition: MCExpr.h:188
Represents a location in source code.
Definition: SMLoc.h:23
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:587
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1210
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
void funcDecl(const wasm::WasmSignature &Sig)
void setLastSig(const wasm::WasmSignature &Sig)
void localDecl(const SmallVectorImpl< wasm::ValType > &Locals)
bool typeCheck(SMLoc ErrorLoc, const MCInst &Inst, OperandVector &Operands)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Extended Value Type.
Definition: ValueTypes.h:35