Skip to content

Commit 83ff9d4

Browse files
committed
Revert "[Win/X86] Make _m_prefetch[w] builtins to avoid winnt.h conflicts (#115099)"
This broke the build, see buildbot comments on the PR. This reverts commit ee92122 and follow-up 5dccfd9.
1 parent 4313345 commit 83ff9d4

File tree

4 files changed

+21
-36
lines changed

4 files changed

+21
-36
lines changed

clang/include/clang/Basic/BuiltinsX86.td

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,6 @@ let Attributes = [Const, NoThrow, RequiredVectorWidth<128>] in {
130130
}
131131
}
132132

133-
let Features = "sse", Header = "xmmintrin.h", Attributes = [NoThrow, Const] in {
134-
def _mm_prefetch : X86LibBuiltin<"void(void const *, int)">;
135-
}
136-
137133
// AVX
138134
let Attributes = [Const, NoThrow, RequiredVectorWidth<256>], Features = "avx" in {
139135
foreach Op = ["addsub", "hadd", "hsub", "max", "min"] in {
@@ -142,12 +138,6 @@ let Attributes = [Const, NoThrow, RequiredVectorWidth<256>], Features = "avx" in
142138
}
143139
}
144140

145-
// PRFCHW
146-
let Features = "prfchw", Header = "intrin.h", Attributes = [NoThrow, Const] in {
147-
def _m_prefetch : X86LibBuiltin<"void(void *)">;
148-
def _m_prefetchw : X86LibBuiltin<"void(void volatile const *)">;
149-
}
150-
151141

152142
// Mechanically ported builtins from the original `.def` file.
153143
//
@@ -156,6 +146,10 @@ let Features = "prfchw", Header = "intrin.h", Attributes = [NoThrow, Const] in {
156146
// current formulation is based on what was easiest to recognize from the
157147
// pre-TableGen version.
158148

149+
let Features = "mmx", Attributes = [NoThrow, Const] in {
150+
def _mm_prefetch : X86NoPrefixBuiltin<"void(char const *, int)">;
151+
}
152+
159153
let Features = "sse", Attributes = [NoThrow] in {
160154
def ldmxcsr : X86Builtin<"void(unsigned int)">;
161155
}

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15374,17 +15374,6 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
1537415374
Function *F = CGM.getIntrinsic(Intrinsic::prefetch, Address->getType());
1537515375
return Builder.CreateCall(F, {Address, RW, Locality, Data});
1537615376
}
15377-
case X86::BI_m_prefetch:
15378-
case X86::BI_m_prefetchw: {
15379-
Value *Address = Ops[0];
15380-
// The 'w' suffix implies write.
15381-
Value *RW =
15382-
ConstantInt::get(Int32Ty, BuiltinID == X86::BI_m_prefetchw ? 1 : 0);
15383-
Value *Locality = ConstantInt::get(Int32Ty, 0x3);
15384-
Value *Data = ConstantInt::get(Int32Ty, 1);
15385-
Function *F = CGM.getIntrinsic(Intrinsic::prefetch, Address->getType());
15386-
return Builder.CreateCall(F, {Address, RW, Locality, Data});
15387-
}
1538815377
case X86::BI_mm_clflush: {
1538915378
return Builder.CreateCall(CGM.getIntrinsic(Intrinsic::x86_sse2_clflush),
1539015379
Ops[0]);

clang/lib/Headers/prfchwintrin.h

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
#ifndef __PRFCHWINTRIN_H
1515
#define __PRFCHWINTRIN_H
1616

17-
#if defined(__cplusplus)
18-
extern "C" {
19-
#endif
20-
2117
/// Loads a memory sequence containing the specified memory address into
2218
/// all data cache levels.
2319
///
@@ -30,7 +26,11 @@ extern "C" {
3026
///
3127
/// \param __P
3228
/// A pointer specifying the memory address to be prefetched.
33-
void _m_prefetch(void *__P);
29+
static __inline__ void __attribute__((__always_inline__, __nodebug__))
30+
_m_prefetch(void *__P)
31+
{
32+
__builtin_prefetch (__P, 0, 3 /* _MM_HINT_T0 */);
33+
}
3434

3535
/// Loads a memory sequence containing the specified memory address into
3636
/// the L1 data cache and sets the cache-coherency state to modified.
@@ -48,10 +48,13 @@ void _m_prefetch(void *__P);
4848
///
4949
/// \param __P
5050
/// A pointer specifying the memory address to be prefetched.
51-
void _m_prefetchw(volatile const void *__P);
52-
53-
#if defined(__cplusplus)
54-
} // extern "C"
55-
#endif
51+
static __inline__ void __attribute__((__always_inline__, __nodebug__))
52+
_m_prefetchw(volatile const void *__P)
53+
{
54+
#pragma clang diagnostic push
55+
#pragma clang diagnostic ignored "-Wcast-qual"
56+
__builtin_prefetch ((const void*)__P, 1, 3 /* _MM_HINT_T0 */);
57+
#pragma clang diagnostic pop
58+
}
5659

5760
#endif /* __PRFCHWINTRIN_H */

clang/lib/Headers/xmmintrin.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,7 +2197,10 @@ _mm_storer_ps(float *__p, __m128 __a)
21972197
#define _MM_HINT_T2 1
21982198
#define _MM_HINT_NTA 0
21992199

2200-
#if 0
2200+
#ifndef _MSC_VER
2201+
/* FIXME: We have to #define this because "sel" must be a constant integer, and
2202+
Sema doesn't do any form of constant propagation yet. */
2203+
22012204
/// Loads one cache line of data from the specified address to a location
22022205
/// closer to the processor.
22032206
///
@@ -2222,10 +2225,6 @@ _mm_storer_ps(float *__p, __m128 __a)
22222225
/// be generated. \n
22232226
/// _MM_HINT_T2: Move data using the T2 hint. The PREFETCHT2 instruction will
22242227
/// be generated.
2225-
///
2226-
/// _mm_prefetch is implemented as a "library builtin" directly in Clang,
2227-
/// similar to how it is done in MSVC. Clang will warn if the user doesn't
2228-
/// include xmmintrin.h or immintrin.h.
22292228
#define _mm_prefetch(a, sel) (__builtin_prefetch((const void *)(a), \
22302229
((sel) >> 2) & 1, (sel) & 0x3))
22312230
#endif

0 commit comments

Comments
 (0)