Skip to content

Commit b60ee39

Browse files
authored
Revert "[clang][ARM][AArch64] Define intrinsics guarded by __has_builtin on all platforms" (#137374)
This reverts commit de0153d. It breaks MSVC. --------- Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
1 parent 881f6de commit b60ee39

14 files changed

+145
-269
lines changed

clang/include/clang/Basic/BuiltinHeaders.def

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
//===----------------------------------------------------------------------===//
1313

1414
HEADER(NO_HEADER, nullptr)
15-
HEADER(ARMACLE_H, "arm_acle.h")
1615
HEADER(BLOCKS_H, "Blocks.h")
1716
HEADER(COMPLEX_H, "complex.h")
1817
HEADER(CTYPE_H, "ctype.h")

clang/include/clang/Basic/BuiltinsAArch64.def

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ BUILTIN(__builtin_arm_wfi, "v", "")
5050
BUILTIN(__builtin_arm_sev, "v", "")
5151
BUILTIN(__builtin_arm_sevl, "v", "")
5252
BUILTIN(__builtin_arm_chkfeat, "WUiWUi", "")
53-
TARGET_HEADER_BUILTIN(__yield, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
54-
TARGET_HEADER_BUILTIN(__wfe, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
55-
TARGET_HEADER_BUILTIN(__wfi, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
56-
TARGET_HEADER_BUILTIN(__sev, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
57-
TARGET_HEADER_BUILTIN(__sevl, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
5853

5954
// Like __builtin_trap but provide an 16-bit immediate reason code (which goes into `brk #N`).
6055
BUILTIN(__builtin_arm_trap, "vUIs", "nr")
@@ -87,9 +82,6 @@ TARGET_BUILTIN(__builtin_arm_mops_memset_tag, "v*v*iz", "", "mte,mops")
8782
BUILTIN(__builtin_arm_dmb, "vUi", "nc")
8883
BUILTIN(__builtin_arm_dsb, "vUi", "nc")
8984
BUILTIN(__builtin_arm_isb, "vUi", "nc")
90-
TARGET_HEADER_BUILTIN(__dmb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
91-
TARGET_HEADER_BUILTIN(__dsb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
92-
TARGET_HEADER_BUILTIN(__isb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
9385

9486
TARGET_BUILTIN(__builtin_arm_jcvt, "Zid", "nc", "v8.3a")
9587

@@ -106,6 +98,16 @@ BUILTIN(__builtin_arm_wsr64, "vcC*WUi", "nc")
10698
TARGET_BUILTIN(__builtin_arm_wsr128, "vcC*LLLUi", "nc", "d128")
10799
BUILTIN(__builtin_arm_wsrp, "vcC*vC*", "nc")
108100

101+
// MSVC
102+
LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
103+
LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
104+
LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
105+
LANGBUILTIN(__yield, "v", "", ALL_MS_LANGUAGES)
106+
LANGBUILTIN(__wfe, "v", "", ALL_MS_LANGUAGES)
107+
LANGBUILTIN(__wfi, "v", "", ALL_MS_LANGUAGES)
108+
LANGBUILTIN(__sev, "v", "", ALL_MS_LANGUAGES)
109+
LANGBUILTIN(__sevl, "v", "", ALL_MS_LANGUAGES)
110+
109111
// Misc
110112
BUILTIN(__builtin_sponentry, "v*", "c")
111113

clang/include/clang/Basic/BuiltinsARM.def

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,19 +186,11 @@ BUILTIN(__builtin_arm_wfi, "v", "")
186186
BUILTIN(__builtin_arm_sev, "v", "")
187187
BUILTIN(__builtin_arm_sevl, "v", "")
188188
BUILTIN(__builtin_arm_dbg, "vUi", "")
189-
TARGET_HEADER_BUILTIN(__yield, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
190-
TARGET_HEADER_BUILTIN(__wfe, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
191-
TARGET_HEADER_BUILTIN(__wfi, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
192-
TARGET_HEADER_BUILTIN(__sev, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
193-
TARGET_HEADER_BUILTIN(__sevl, "v", "h", ARMACLE_H, ALL_LANGUAGES, "")
194189

195190
// Data barrier
196191
BUILTIN(__builtin_arm_dmb, "vUi", "nc")
197192
BUILTIN(__builtin_arm_dsb, "vUi", "nc")
198193
BUILTIN(__builtin_arm_isb, "vUi", "nc")
199-
TARGET_HEADER_BUILTIN(__dmb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
200-
TARGET_HEADER_BUILTIN(__dsb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
201-
TARGET_HEADER_BUILTIN(__isb, "vUi", "nch", ARMACLE_H, ALL_LANGUAGES, "")
202194

203195
// Prefetch
204196
BUILTIN(__builtin_arm_prefetch, "vvC*UiUi", "nc")
@@ -217,6 +209,15 @@ BUILTIN(__builtin_sponentry, "v*", "c")
217209
// MSVC
218210
LANGBUILTIN(__emit, "vIUiC", "", ALL_MS_LANGUAGES)
219211

212+
LANGBUILTIN(__yield, "v", "", ALL_MS_LANGUAGES)
213+
LANGBUILTIN(__wfe, "v", "", ALL_MS_LANGUAGES)
214+
LANGBUILTIN(__wfi, "v", "", ALL_MS_LANGUAGES)
215+
LANGBUILTIN(__sev, "v", "", ALL_MS_LANGUAGES)
216+
LANGBUILTIN(__sevl, "v", "", ALL_MS_LANGUAGES)
217+
218+
LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES)
219+
LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES)
220+
LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES)
220221
LANGBUILTIN(__ldrexd, "WiWiCD*", "", ALL_MS_LANGUAGES)
221222
LANGBUILTIN(_MoveFromCoprocessor, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES)
222223
LANGBUILTIN(_MoveFromCoprocessor2, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES)

clang/lib/Headers/arm_acle.h

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,52 @@ extern "C" {
2929

3030
/* 7 SYNCHRONIZATION, BARRIER AND HINT INTRINSICS */
3131
/* 7.3 Memory barriers */
32-
void __dmb(unsigned int);
33-
void __dsb(unsigned int);
34-
void __isb(unsigned int);
32+
#if !__has_builtin(__dmb)
33+
#define __dmb(i) __builtin_arm_dmb(i)
34+
#endif
35+
#if !__has_builtin(__dsb)
36+
#define __dsb(i) __builtin_arm_dsb(i)
37+
#endif
38+
#if !__has_builtin(__isb)
39+
#define __isb(i) __builtin_arm_isb(i)
40+
#endif
3541

3642
/* 7.4 Hints */
37-
void __wfi(void);
38-
void __wfe(void);
39-
void __sev(void);
40-
void __sevl(void);
41-
void __yield(void);
43+
44+
#if !__has_builtin(__wfi)
45+
static __inline__ void __attribute__((__always_inline__, __nodebug__))
46+
__wfi(void) {
47+
__builtin_arm_wfi();
48+
}
49+
#endif
50+
51+
#if !__has_builtin(__wfe)
52+
static __inline__ void __attribute__((__always_inline__, __nodebug__))
53+
__wfe(void) {
54+
__builtin_arm_wfe();
55+
}
56+
#endif
57+
58+
#if !__has_builtin(__sev)
59+
static __inline__ void __attribute__((__always_inline__, __nodebug__))
60+
__sev(void) {
61+
__builtin_arm_sev();
62+
}
63+
#endif
64+
65+
#if !__has_builtin(__sevl)
66+
static __inline__ void __attribute__((__always_inline__, __nodebug__))
67+
__sevl(void) {
68+
__builtin_arm_sevl();
69+
}
70+
#endif
71+
72+
#if !__has_builtin(__yield)
73+
static __inline__ void __attribute__((__always_inline__, __nodebug__))
74+
__yield(void) {
75+
__builtin_arm_yield();
76+
}
77+
#endif
4278

4379
#if defined(__ARM_32BIT_STATE) && __ARM_32BIT_STATE
4480
#define __dbg(t) __builtin_arm_dbg(t)

clang/lib/Sema/SemaARM.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,11 +1010,8 @@ bool SemaARM::CheckARMBuiltinFunctionCall(const TargetInfo &TI,
10101010
case ARM::BI__builtin_arm_vcvtr_d:
10111011
return SemaRef.BuiltinConstantArgRange(TheCall, 1, 0, 1);
10121012
case ARM::BI__builtin_arm_dmb:
1013-
case ARM::BI__dmb:
10141013
case ARM::BI__builtin_arm_dsb:
1015-
case ARM::BI__dsb:
10161014
case ARM::BI__builtin_arm_isb:
1017-
case ARM::BI__isb:
10181015
case ARM::BI__builtin_arm_dbg:
10191016
return SemaRef.BuiltinConstantArgRange(TheCall, 0, 0, 15);
10201017
case ARM::BI__builtin_arm_cdp:
@@ -1111,11 +1108,8 @@ bool SemaARM::CheckAArch64BuiltinFunctionCall(const TargetInfo &TI,
11111108
switch (BuiltinID) {
11121109
default: return false;
11131110
case AArch64::BI__builtin_arm_dmb:
1114-
case AArch64::BI__dmb:
11151111
case AArch64::BI__builtin_arm_dsb:
1116-
case AArch64::BI__dsb:
11171112
case AArch64::BI__builtin_arm_isb:
1118-
case AArch64::BI__isb:
11191113
l = 0;
11201114
u = 15;
11211115
break;

clang/test/CodeGen/arm-former-microsoft-intrinsics-header-warning.c

Lines changed: 0 additions & 50 deletions
This file was deleted.

clang/test/CodeGen/arm-former-microsoft-intrinsics.c

Lines changed: 0 additions & 53 deletions
This file was deleted.

clang/test/CodeGen/arm-microsoft-intrinsics.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,27 @@
44
// RUN: not %clang_cc1 -triple armv7-eabi -Werror -S -o /dev/null %s 2>&1 \
55
// RUN: | FileCheck %s -check-prefix CHECK-EABI
66

7+
void check__dmb(void) {
8+
__dmb(0);
9+
}
10+
11+
// CHECK-MSVC: @llvm.arm.dmb(i32 0)
12+
// CHECK-EABI: error: call to undeclared function '__dmb'
13+
14+
void check__dsb(void) {
15+
__dsb(0);
16+
}
17+
18+
// CHECK-MSVC: @llvm.arm.dsb(i32 0)
19+
// CHECK-EABI: error: call to undeclared function '__dsb'
20+
21+
void check__isb(void) {
22+
__isb(0);
23+
}
24+
25+
// CHECK-MSVC: @llvm.arm.isb(i32 0)
26+
// CHECK-EABI: error: call to undeclared function '__isb'
27+
728
__INT64_TYPE__ check__ldrexd(void) {
829
__INT64_TYPE__ i64;
930
return __ldrexd(&i64);

clang/test/CodeGen/arm64-former-microsoft-intrinsics-header-warning.c

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)