LLVM 17.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
23
24namespace llvm {
25
26class TargetRegisterClass;
27
28namespace WebAssembly {
29
30enum WasmAddressSpace : unsigned {
31 // Default address space, for pointers to linear memory (stack, heap, data).
33 // A non-integral address space for pointers to named objects outside of
34 // linear memory: WebAssembly globals or WebAssembly locals. Loads and stores
35 // to these pointers are lowered to global.get / global.set or local.get /
36 // local.set, as appropriate.
38 // A non-integral address space for externref values
40 // A non-integral address space for funcref values
42};
43
44inline bool isDefaultAddressSpace(unsigned AS) {
45 return AS == WASM_ADDRESS_SPACE_DEFAULT;
46}
47inline bool isWasmVarAddressSpace(unsigned AS) {
48 return AS == WASM_ADDRESS_SPACE_VAR;
49}
50inline bool isValidAddressSpace(unsigned AS) {
52}
53inline bool isFuncrefType(const Type *Ty) {
54 return isa<PointerType>(Ty) &&
57}
58inline bool isExternrefType(const Type *Ty) {
59 return isa<PointerType>(Ty) &&
62}
63inline bool isRefType(const Type *Ty) {
64 return isFuncrefType(Ty) || isExternrefType(Ty);
65}
66
67// Convert StringRef to ValType / HealType / BlockType
68
70
71// Convert a MVT into its corresponding wasm ValType.
73
74// Convert a register class to a wasm ValType.
76
77/// Sets a Wasm Symbol Type.
78void wasmSymbolSetType(MCSymbolWasm *Sym, const Type *GlobalVT,
79 const ArrayRef<MVT> &VTs);
80
81} // end namespace WebAssembly
82} // end namespace llvm
83
84#endif
Symbol * Sym
Definition: ELF_riscv.cpp:463
This file contains the declaration of the WebAssembly-specific type parsing utility functions.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
Machine Value Type.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
unsigned getPointerAddressSpace() const
Get the address space of this pointer or pointer vector type.
bool isDefaultAddressSpace(unsigned AS)
wasm::ValType regClassToValType(unsigned RC)
wasm::ValType toValType(MVT Type)
bool isRefType(wasm::ValType Type)
bool isExternrefType(const Type *Ty)
bool isFuncrefType(const Type *Ty)
bool isValidAddressSpace(unsigned AS)
void wasmSymbolSetType(MCSymbolWasm *Sym, const Type *GlobalVT, const ArrayRef< MVT > &VTs)
Sets a Wasm Symbol Type.
MVT parseMVT(StringRef Type)
bool isWasmVarAddressSpace(unsigned AS)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18