[X86] Support __SSC_MARK(const int id)
authorXiang1 Zhang <xiang1.zhang@intel.com>
Mon, 30 Aug 2021 01:55:19 +0000 (09:55 +0800)
committerXiang1 Zhang <xiang1.zhang@intel.com>
Mon, 30 Aug 2021 01:55:35 +0000 (09:55 +0800)
Differential Revision: https://reviews.llvm.org/D108682

clang/lib/Headers/x86gprintrin.h
clang/test/CodeGen/X86/x86-ssc-mark.c [new file with mode: 0644]

index 1fc6cab..327ccb7 100644 (file)
@@ -20,4 +20,9 @@
 #include <uintrintrin.h>
 #endif
 
+#define __SSC_MARK(Tag)                                                        \
+  __asm__ __volatile__("movl %%ebx, %%eax; movl %0, %%ebx; .byte 0x64, 0x67, " \
+                       "0x90; movl %%eax, %%ebx;" ::"i"(Tag)                   \
+                       : "%eax");
+
 #endif /* __X86GPRINTRIN_H */
diff --git a/clang/test/CodeGen/X86/x86-ssc-mark.c b/clang/test/CodeGen/X86/x86-ssc-mark.c
new file mode 100644 (file)
index 0000000..a2a57a1
--- /dev/null
@@ -0,0 +1,20 @@
+// REQUIRES: x86-registered-target
+// RUN: %clang_cc1 %s -triple=x86_64-unknown-unknown -S -ffreestanding -o - | FileCheck %s
+// RUN: %clang_cc1 %s -triple=i386-unknown-unknown -S -ffreestanding -o - | FileCheck %s
+
+#include <immintrin.h>
+
+// The ebx may be use for base pointer, we need to restore it in time.
+void ssc_mark() {
+// CHECK-LABEL: ssc_mark
+// CHECK: #APP
+// CHECK: movl    %ebx, %eax
+// CHECK: movl    $0, %ebx
+// CHECK: .byte   100
+// CHECK: .byte   103
+// CHECK: .byte   144
+// CHECK: movl    %eax, %ebx
+// CHECK: #NO_APP
+
+  __SSC_MARK(0x0);
+}