Path: blob/main/contrib/llvm-project/llvm/lib/Target/WebAssembly/Utils/WasmAddressSpaces.h
35294 views
//===--- llvm/CodeGen/WasmAddressSpaces.h -----------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8// Address Spaces for WebAssembly Type Handling9//10//===----------------------------------------------------------------------===//1112#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_UTILS_WASMADDRESSSPACES_H13#define LLVM_LIB_TARGET_WEBASSEMBLY_UTILS_WASMADDRESSSPACES_H1415namespace llvm {1617namespace WebAssembly {1819enum WasmAddressSpace : unsigned {20// Default address space, for pointers to linear memory (stack, heap, data).21WASM_ADDRESS_SPACE_DEFAULT = 0,22// A non-integral address space for pointers to named objects outside of23// linear memory: WebAssembly globals or WebAssembly locals. Loads and stores24// to these pointers are lowered to global.get / global.set or local.get /25// local.set, as appropriate.26WASM_ADDRESS_SPACE_VAR = 1,27// A non-integral address space for externref values28WASM_ADDRESS_SPACE_EXTERNREF = 10,29// A non-integral address space for funcref values30WASM_ADDRESS_SPACE_FUNCREF = 20,31};3233inline bool isDefaultAddressSpace(unsigned AS) {34return AS == WASM_ADDRESS_SPACE_DEFAULT;35}36inline bool isWasmVarAddressSpace(unsigned AS) {37return AS == WASM_ADDRESS_SPACE_VAR;38}39inline bool isValidAddressSpace(unsigned AS) {40return isDefaultAddressSpace(AS) || isWasmVarAddressSpace(AS);41}4243} // namespace WebAssembly4445} // namespace llvm4647#endif // LLVM_LIB_TARGET_WEBASSEMBLY_UTILS_WASMADDRESSSPACES_H484950