blob: 3bc4e63c4f25ab85c836b160fb3d774330e46f4e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
//===-- cpu_model_common.c - Utilities for cpu model detection ----*- C -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file implements common utilities for runtime cpu model detection.
//
//===----------------------------------------------------------------------===//
#ifndef COMPILER_RT_LIB_BUILTINS_CPU_MODEL_COMMON_H
#define COMPILER_RT_LIB_BUILTINS_CPU_MODEL_COMMON_H
#define bool int
#define true 1
#define false 0
#ifndef __has_attribute
#define __has_attribute(attr) 0
#endif
#if __has_attribute(constructor)
#if __GNUC__ >= 9
// Ordinarily init priorities below 101 are disallowed as they are reserved for
// the implementation. However, we are the implementation, so silence the
// diagnostic, since it doesn't apply to us.
#pragma GCC diagnostic ignored "-Wprio-ctor-dtor"
#endif
// We're choosing init priority 90 to force our constructors to run before any
// constructors in the end user application (starting at priority 101). This
// value matches the libgcc choice for the same functions.
#ifdef _WIN32
// Contructor that replaces the ifunc runs currently with prio 10, see
// the LowerIFuncPass. The resolver of FMV depends on the cpu features so set
// the priority to 9.
#define CONSTRUCTOR_PRIORITY 9
#else
#define CONSTRUCTOR_PRIORITY 90
#endif
#define CONSTRUCTOR_ATTRIBUTE __attribute__((constructor(CONSTRUCTOR_PRIORITY)))
#else
// FIXME: For MSVC, we should make a function pointer global in .CRT$X?? so that
// this runs during initialization.
#define CONSTRUCTOR_ATTRIBUTE
#endif
#endif
|