Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/contrib/llvm-project/compiler-rt/lib/builtins/cpu_model/aarch64.c
35291 views
1
//===-- cpu_model/aarch64.c - Support for __cpu_model builtin ----*- 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
// This file is based on LLVM's lib/Support/Host.cpp.
10
// It implements __aarch64_have_lse_atomics, __aarch64_cpu_features for
11
// AArch64.
12
//
13
//===----------------------------------------------------------------------===//
14
15
#include "aarch64.h"
16
17
#if !defined(__aarch64__)
18
#error This file is intended only for aarch64-based targets
19
#endif
20
21
#if __has_include(<sys/ifunc.h>)
22
#include <sys/ifunc.h>
23
#else
24
typedef struct __ifunc_arg_t {
25
unsigned long _size;
26
unsigned long _hwcap;
27
unsigned long _hwcap2;
28
} __ifunc_arg_t;
29
#endif // __has_include(<sys/ifunc.h>)
30
31
// LSE support detection for out-of-line atomics
32
// using HWCAP and Auxiliary vector
33
_Bool __aarch64_have_lse_atomics
34
__attribute__((visibility("hidden"), nocommon)) = false;
35
36
#if defined(__FreeBSD__)
37
// clang-format off: should not reorder sys/auxv.h alphabetically
38
#include <sys/auxv.h>
39
// clang-format on
40
#include "aarch64/hwcap.inc"
41
#include "aarch64/lse_atomics/freebsd.inc"
42
#elif defined(__Fuchsia__)
43
#include "aarch64/hwcap.inc"
44
#include "aarch64/lse_atomics/fuchsia.inc"
45
#elif defined(__ANDROID__)
46
#include "aarch64/hwcap.inc"
47
#include "aarch64/lse_atomics/android.inc"
48
#elif __has_include(<sys/auxv.h>)
49
#include "aarch64/hwcap.inc"
50
#include "aarch64/lse_atomics/sysauxv.inc"
51
#else
52
// When unimplemented, we leave __aarch64_have_lse_atomics initialized to false.
53
#endif
54
55
#if !defined(DISABLE_AARCH64_FMV)
56
57
// Architecture features used
58
// in Function Multi Versioning
59
struct {
60
unsigned long long features;
61
// As features grows new fields could be added
62
} __aarch64_cpu_features __attribute__((visibility("hidden"), nocommon));
63
64
// The formatter wants to re-order these includes, but doing so is incorrect:
65
// clang-format off
66
#if defined(__APPLE__)
67
#include "aarch64/fmv/apple.inc"
68
#elif defined(__FreeBSD__)
69
#include "aarch64/fmv/mrs.inc"
70
#include "aarch64/fmv/freebsd.inc"
71
#elif defined(__Fuchsia__)
72
#include "aarch64/fmv/fuchsia.inc"
73
#elif defined(__ANDROID__)
74
#include "aarch64/fmv/mrs.inc"
75
#include "aarch64/fmv/android.inc"
76
#elif __has_include(<sys/auxv.h>)
77
#include "aarch64/fmv/mrs.inc"
78
#include "aarch64/fmv/sysauxv.inc"
79
#else
80
#include "aarch64/fmv/unimplemented.inc"
81
#endif
82
// clang-format on
83
84
#endif // !defined(DISABLE_AARCH64_FMV)
85
86