64 lines · cpp
1//===- ArmSMEStub.cpp - ArmSME ABI routine stubs --------------------------===//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#include "llvm/Support/Compiler.h"10#include <cstdint>11#include <iostream>12 13#if (defined(_WIN32) || defined(__CYGWIN__))14#ifndef MLIR_ARMSMEABISTUBS_EXPORTED15#ifdef mlir_arm_sme_abi_stubs_EXPORTS16// We are building this library17#define MLIR_ARMSMEABISTUBS_EXPORTED __declspec(dllexport)18#else19// We are using this library20#define MLIR_ARMSMEABISTUBS_EXPORTED __declspec(dllimport)21#endif // mlir_arm_sme_abi_stubs_EXPORTS22#endif // MLIR_ARMSMEABISTUBS_EXPORTED23#else24#define MLIR_ARMSMEABISTUBS_EXPORTED \25 __attribute__((visibility("default"))) LLVM_ATTRIBUTE_WEAK26#endif // (defined(_WIN32) || defined(__CYGWIN__))27 28// The actual implementation of these routines is in:29// compiler-rt/lib/builtins/aarch64/sme-abi.S. These stubs allow the current30// ArmSME tests to run without depending on compiler-rt. This works as we don't31// rely on nested ZA-enabled calls at the moment. The use of these stubs can be32// overridden by setting the ARM_SME_ABI_ROUTINES_SHLIB CMake cache variable to33// a path to an alternate implementation.34 35extern "C" {36 37bool MLIR_ARMSMEABISTUBS_EXPORTED __aarch64_sme_accessible() {38 // The ArmSME tests are run within an emulator so we assume SME is available.39 return true;40}41 42struct sme_state {43 int64_t x0;44 int64_t x1;45};46 47sme_state MLIR_ARMSMEABISTUBS_EXPORTED __arm_sme_state() {48 std::cerr << "[warning] __arm_sme_state() stubbed!\n";49 return sme_state{};50}51 52void MLIR_ARMSMEABISTUBS_EXPORTED __arm_tpidr2_restore() {53 std::cerr << "[warning] __arm_tpidr2_restore() stubbed!\n";54}55 56void MLIR_ARMSMEABISTUBS_EXPORTED __arm_tpidr2_save() {57 std::cerr << "[warning] __arm_tpidr2_save() stubbed!\n";58}59 60void MLIR_ARMSMEABISTUBS_EXPORTED __arm_za_disable() {61 std::cerr << "[warning] __arm_za_disable() stubbed!\n";62}63}64