brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 2239bad Raw
49 lines · c
1//===--- llvm/CodeGen/WasmAddressSpaces.h -----------------------*- 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-exception6//7//===----------------------------------------------------------------------===//8//9// Address Spaces for WebAssembly Type Handling10//11//===----------------------------------------------------------------------===//12 13#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_UTILS_WASMADDRESSSPACES_H14#define LLVM_LIB_TARGET_WEBASSEMBLY_UTILS_WASMADDRESSSPACES_H15 16namespace llvm {17 18namespace WebAssembly {19 20enum WasmAddressSpace : unsigned {21  // Default address space, for pointers to linear memory (stack, heap, data).22  WASM_ADDRESS_SPACE_DEFAULT = 0,23  // A non-integral address space for pointers to named objects outside of24  // linear memory: WebAssembly globals or WebAssembly locals.  Loads and stores25  // to these pointers are lowered to global.get / global.set or local.get /26  // local.set, as appropriate.27  WASM_ADDRESS_SPACE_VAR = 1,28  // A non-integral address space for externref values29  WASM_ADDRESS_SPACE_EXTERNREF = 10,30  // A non-integral address space for funcref values31  WASM_ADDRESS_SPACE_FUNCREF = 20,32};33 34inline bool isDefaultAddressSpace(unsigned AS) {35  return AS == WASM_ADDRESS_SPACE_DEFAULT;36}37inline bool isWasmVarAddressSpace(unsigned AS) {38  return AS == WASM_ADDRESS_SPACE_VAR;39}40inline bool isValidAddressSpace(unsigned AS) {41  return isDefaultAddressSpace(AS) || isWasmVarAddressSpace(AS);42}43 44} // namespace WebAssembly45 46} // namespace llvm47 48#endif // LLVM_LIB_TARGET_WEBASSEMBLY_UTILS_WASMADDRESSSPACES_H49