[PATCH] D12278: [X86] Add MSVC-compatible intrinsics for clac, stac, lgdt and sgdt
Michael Kuperstein via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 24 04:56:19 PDT 2015
mkuper created this revision.
mkuper added reviewers: rnk, majnemer.
mkuper added a subscriber: cfe-commits.
LLVM part was posted as D12277
http://reviews.llvm.org/D12278
Files:
include/clang/Basic/BuiltinsX86.def
lib/Headers/Intrin.h
test/CodeGen/builtins-x86.c
Index: lib/Headers/Intrin.h
===================================================================
--- lib/Headers/Intrin.h
+++ lib/Headers/Intrin.h
@@ -59,6 +59,7 @@
void __addfsbyte(unsigned long, unsigned char);
void __addfsdword(unsigned long, unsigned long);
void __addfsword(unsigned long, unsigned short);
+static __inline__ void _clac(void);
void __code_seg(const char *);
static __inline__
void __cpuid(int[4], int);
@@ -82,6 +83,7 @@
void __invlpg(void *);
unsigned short __inword(unsigned short);
void __inwordstring(unsigned short, unsigned short *, unsigned long);
+static __inline__ void _lgdt(void *);
void __lidt(void *);
unsigned __int64 __ll_lshift(unsigned __int64, int);
__int64 __ll_rshift(__int64, int);
@@ -130,9 +132,11 @@
unsigned __int64 __readmsr(unsigned long);
unsigned __int64 __readpmc(unsigned long);
unsigned long __segmentlimit(unsigned long);
+static __inline__ void _sgdt(void *);
void __sidt(void *);
void *__slwpcb(void);
static __inline__
+static __inline__ void _stac(void);
void __stosb(unsigned char *, unsigned char, size_t);
static __inline__
void __stosd(unsigned long *, unsigned long, size_t);
@@ -944,6 +948,24 @@
__writecr3(unsigned int __cr3_val) {
__asm__ ("mov %0, %%cr3" : : "q"(__cr3_val) : "memory");
}
+
+static __inline__ void __DEFAULT_FN_ATTRS _clac(void) {
+ __builtin_ia32_clac();
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS _stac(void) {
+ __builtin_ia32_stac();
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS _lgdt(void *__ptr) {
+ __builtin_ia32_lgdt(__ptr);
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS _sgdt(void *__ptr) {
+ __builtin_ia32_sgdt(__ptr);
+}
+
+
#endif
#ifdef __cplusplus
Index: include/clang/Basic/BuiltinsX86.def
===================================================================
--- include/clang/Basic/BuiltinsX86.def
+++ include/clang/Basic/BuiltinsX86.def
@@ -671,6 +671,14 @@
BUILTIN(__builtin_ia32_fxsave, "vv*", "")
BUILTIN(__builtin_ia32_fxsave64, "vv*", "")
+// SMAP
+BUILTIN(__builtin_ia32_clac, "v", "")
+BUILTIN(__builtin_ia32_stac, "v", "")
+
+// LGDT, SGDT
+BUILTIN(__builtin_ia32_sgdt, "vv*", "")
+BUILTIN(__builtin_ia32_lgdt, "vv*", "")
+
// ADX
TARGET_BUILTIN(__builtin_ia32_addcarryx_u32, "UcUcUiUiUi*", "", "adx")
TARGET_BUILTIN(__builtin_ia32_addcarryx_u64, "UcUcULLiULLiULLi*", "", "adx")
Index: test/CodeGen/builtins-x86.c
===================================================================
--- test/CodeGen/builtins-x86.c
+++ test/CodeGen/builtins-x86.c
@@ -264,6 +264,10 @@
(void)__builtin_ia32_fxsave64(tmp_vp);
(void)__builtin_ia32_fxrstor(tmp_vp);
(void)__builtin_ia32_fxrstor64(tmp_vp);
+ (void)__builtin_ia32_clac();
+ (void)__builtin_ia32_stac();
+ (void)__builtin_ia32_sgdt(tmp_vp);
+ (void)__builtin_ia32_lgdt(tmp_vp);
tmp_V4f = __builtin_ia32_cvtpi2ps(tmp_V4f, tmp_V2i);
tmp_V2i = __builtin_ia32_cvtps2pi(tmp_V4f);
tmp_i = __builtin_ia32_cvtss2si(tmp_V4f);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12278.32947.patch
Type: text/x-patch
Size: 3014 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150824/aa00bb84/attachment-0001.bin>
More information about the cfe-commits
mailing list