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-exception
6//
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_EXPORTED
15#ifdef mlir_arm_sme_abi_stubs_EXPORTS
16// We are building this library
17#define MLIR_ARMSMEABISTUBS_EXPORTED __declspec(dllexport)
18#else
19// We are using this library
20#define MLIR_ARMSMEABISTUBS_EXPORTED __declspec(dllimport)
21#endif // mlir_arm_sme_abi_stubs_EXPORTS
22#endif // MLIR_ARMSMEABISTUBS_EXPORTED
23#else
24#define MLIR_ARMSMEABISTUBS_EXPORTED \
25 __attribute__((visibility("default"))) LLVM_ATTRIBUTE_WEAK
26#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 current
30// ArmSME tests to run without depending on compiler-rt. This works as we don't
31// rely on nested ZA-enabled calls at the moment. The use of these stubs can be
32// overridden by setting the ARM_SME_ABI_ROUTINES_SHLIB CMake cache variable to
33// 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

source code of mlir/lib/ExecutionEngine/ArmSMEStubs.cpp