LLVM 17.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
34 wasm::WasmSignature LastSig;
35 bool TypeErrorThisFunction = false;
36 bool Unreachable = false;
37 bool is64;
38
39 void dumpTypeStack(Twine Msg);
40 bool typeError(SMLoc ErrorLoc, const Twine &Msg);
41 bool popType(SMLoc ErrorLoc, std::optional<wasm::ValType> EVT);
42 bool popRefType(SMLoc ErrorLoc);
43 bool getLocal(SMLoc ErrorLoc, const MCInst &Inst, wasm::ValType &Type);
44 bool checkEnd(SMLoc ErrorLoc, bool PopVals = false);
45 bool checkSig(SMLoc ErrorLoc, const wasm::WasmSignature &Sig);
46 bool getSymRef(SMLoc ErrorLoc, const MCInst &Inst,
47 const MCSymbolRefExpr *&SymRef);
48 bool getGlobal(SMLoc ErrorLoc, const MCInst &Inst, wasm::ValType &Type);
49 bool getTable(SMLoc ErrorLoc, const MCInst &Inst, wasm::ValType &Type);
50
51public:
52 WebAssemblyAsmTypeCheck(MCAsmParser &Parser, const MCInstrInfo &MII, bool is64);
53
54 void funcDecl(const wasm::WasmSignature &Sig);
55 void localDecl(const SmallVector<wasm::ValType, 4> &Locals);
56 void setLastSig(const wasm::WasmSignature &Sig) { LastSig = Sig; }
57 bool endOfFunction(SMLoc ErrorLoc);
58 bool typeCheck(SMLoc ErrorLoc, const MCInst &Inst, OperandVector &Operands);
59
60 void Clear() {
61 Stack.clear();
62 LocalTypes.clear();
63 ReturnTypes.clear();
64 TypeErrorThisFunction = false;
65 Unreachable = false;
66 }
67};
68
69} // end namespace llvm
70
71#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:192
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:577
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
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)
bool typeCheck(SMLoc ErrorLoc, const MCInst &Inst, OperandVector &Operands)
void localDecl(const SmallVector< wasm::ValType, 4 > &Locals)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Extended Value Type.
Definition: ValueTypes.h:34