LLVM 23.0.0git
WebAssemblyTypeUtilities.h
Go to the documentation of this file.
1//===-- WebAssemblyTypeUtilities - WebAssembly Type Utilities---*- 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 contains the declaration of the WebAssembly-specific type parsing
11/// utility functions.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_UTILS_WEBASSEMBLYTYPEUTILITIES_H
16#define LLVM_LIB_TARGET_WEBASSEMBLY_UTILS_WEBASSEMBLYTYPEUTILITIES_H
17
19#include "WasmAddressSpaces.h"
24
25namespace llvm {
26
27namespace WebAssembly {
28
29/// Return true if this is a WebAssembly Externref Type.
30inline bool isWebAssemblyExternrefType(const Type *Ty) {
31 const TargetExtType *TargetTy = dyn_cast<TargetExtType>(Ty);
32 return TargetTy && TargetTy->getName() == "wasm.externref";
33}
34
35/// Return true if this is a WebAssembly Funcref Type.
36inline bool isWebAssemblyFuncrefType(const Type *Ty) {
37 const TargetExtType *TargetTy = dyn_cast<TargetExtType>(Ty);
38 return TargetTy && TargetTy->getName() == "wasm.funcref";
39}
40
41/// Return true if this is a WebAssembly Reference Type.
45
46/// Return true if the table represents a WebAssembly table type.
47inline bool isWebAssemblyTableType(const Type *Ty) {
48 return Ty->isArrayTy() &&
49 isWebAssemblyReferenceType(Ty->getArrayElementType());
50}
51
52// Convert StringRef to ValType / HealType / BlockType
53
55
56// Convert a MVT into its corresponding wasm ValType.
58
59/// Sets a Wasm Symbol Type.
60void wasmSymbolSetType(MCSymbolWasm *Sym, const Type *GlobalVT,
61 ArrayRef<MVT> VTs, bool Mutable);
62
63} // end namespace WebAssembly
64} // end namespace llvm
65
66#endif
This file contains the declaration of the WebAssembly-specific type parsing utility functions.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
Machine Value Type.
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Class to represent target extensions types, which are generally unintrospectable from target-independ...
StringRef getName() const
Return the name for this target extension type.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
bool isWebAssemblyExternrefType(const Type *Ty)
Return true if this is a WebAssembly Externref Type.
bool isWebAssemblyFuncrefType(const Type *Ty)
Return true if this is a WebAssembly Funcref Type.
wasm::ValType toValType(MVT Type)
bool isWebAssemblyReferenceType(const Type *Ty)
Return true if this is a WebAssembly Reference Type.
bool isWebAssemblyTableType(const Type *Ty)
Return true if the table represents a WebAssembly table type.
void wasmSymbolSetType(MCSymbolWasm *Sym, const Type *GlobalVT, ArrayRef< MVT > VTs, bool Mutable)
Sets a Wasm Symbol Type.
MVT parseMVT(StringRef Type)
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition Casting.h:643