LLVM
23.0.0git
lib
Target
WebAssembly
Utils
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
18
#include "
MCTargetDesc/WebAssemblyMCTypeUtilities.h
"
19
#include "
WasmAddressSpaces.h
"
20
#include "
llvm/BinaryFormat/Wasm.h
"
21
#include "
llvm/CodeGenTypes/MachineValueType.h
"
22
#include "
llvm/IR/DerivedTypes.h
"
23
#include "
llvm/MC/MCSymbolWasm.h
"
24
25
namespace
llvm
{
26
27
namespace
WebAssembly
{
28
29
/// Return true if this is a WebAssembly Externref Type.
30
inline
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.
36
inline
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.
42
inline
bool
isWebAssemblyReferenceType
(
const
Type
*Ty) {
43
return
isWebAssemblyExternrefType
(Ty) ||
isWebAssemblyFuncrefType
(Ty);
44
}
45
46
/// Return true if the table represents a WebAssembly table type.
47
inline
bool
isWebAssemblyTableType
(
const
Type
*Ty) {
48
return
Ty->isArrayTy() &&
49
isWebAssemblyReferenceType
(Ty->getArrayElementType());
50
}
51
52
// Convert StringRef to ValType / HealType / BlockType
53
54
MVT
parseMVT
(
StringRef
Type
);
55
56
// Convert a MVT into its corresponding wasm ValType.
57
wasm::ValType
toValType
(
MVT
Type
);
58
59
/// Sets a Wasm Symbol Type.
60
void
wasmSymbolSetType
(
MCSymbolWasm
*Sym,
const
Type
*GlobalVT,
61
ArrayRef<MVT>
VTs,
bool
Mutable);
62
63
}
// end namespace WebAssembly
64
}
// end namespace llvm
65
66
#endif
Wasm.h
DerivedTypes.h
MCSymbolWasm.h
MachineValueType.h
WasmAddressSpaces.h
WebAssemblyMCTypeUtilities.h
This file contains the declaration of the WebAssembly-specific type parsing utility functions.
llvm::ArrayRef
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition
ArrayRef.h:40
llvm::MCSymbolWasm
Definition
MCSymbolWasm.h:17
llvm::MVT
Machine Value Type.
Definition
MachineValueType.h:36
llvm::StringRef
Represent a constant reference to a string, i.e.
Definition
StringRef.h:56
llvm::TargetExtType
Class to represent target extensions types, which are generally unintrospectable from target-independ...
Definition
DerivedTypes.h:849
llvm::TargetExtType::getName
StringRef getName() const
Return the name for this target extension type.
Definition
DerivedTypes.h:882
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition
Type.h:46
llvm::WebAssembly
Definition
WasmEHInfo.h:18
llvm::WebAssembly::isWebAssemblyExternrefType
bool isWebAssemblyExternrefType(const Type *Ty)
Return true if this is a WebAssembly Externref Type.
Definition
WebAssemblyTypeUtilities.h:30
llvm::WebAssembly::isWebAssemblyFuncrefType
bool isWebAssemblyFuncrefType(const Type *Ty)
Return true if this is a WebAssembly Funcref Type.
Definition
WebAssemblyTypeUtilities.h:36
llvm::WebAssembly::toValType
wasm::ValType toValType(MVT Type)
Definition
WebAssemblyTypeUtilities.cpp:40
llvm::WebAssembly::isWebAssemblyReferenceType
bool isWebAssemblyReferenceType(const Type *Ty)
Return true if this is a WebAssembly Reference Type.
Definition
WebAssemblyTypeUtilities.h:42
llvm::WebAssembly::isWebAssemblyTableType
bool isWebAssemblyTableType(const Type *Ty)
Return true if the table represents a WebAssembly table type.
Definition
WebAssemblyTypeUtilities.h:47
llvm::WebAssembly::wasmSymbolSetType
void wasmSymbolSetType(MCSymbolWasm *Sym, const Type *GlobalVT, ArrayRef< MVT > VTs, bool Mutable)
Sets a Wasm Symbol Type.
Definition
WebAssemblyTypeUtilities.cpp:69
llvm::WebAssembly::parseMVT
MVT parseMVT(StringRef Type)
Definition
WebAssemblyTypeUtilities.cpp:23
llvm::wasm::ValType
ValType
Definition
Wasm.h:277
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition
FunctionInfo.h:25
llvm::dyn_cast
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
Definition
Casting.h:643
Generated on
for LLVM by
1.14.0