[PATCH] D116325: [X86] Add missing CET intrinsics support

Freddy, Ye via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 27 18:02:25 PST 2021


FreddyYe created this revision.
Herald added a subscriber: pengfei.
FreddyYe requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

These two intrinsics are documented o SDM and intrinsic guide.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116325

Files:
  clang/lib/Headers/cetintrin.h
  clang/test/CodeGen/X86/cetintrin.c


Index: clang/test/CodeGen/X86/cetintrin.c
===================================================================
--- clang/test/CodeGen/X86/cetintrin.c
+++ clang/test/CodeGen/X86/cetintrin.c
@@ -37,6 +37,12 @@
   return _rdsspd(a);
 }
 
+unsigned int test_rdsspd_i32() {
+  // CHECK-LABEL: @test_rdsspd_i32
+  // CHECK:       call i32 @llvm.x86.rdsspd(i32 %{{[a-z0-9.]+}})
+  return _rdsspd_i32();
+}
+
 #ifdef __x86_64__
 unsigned long long test_rdsspq(unsigned long long a) {
   // X86_64-LABEL: @test_rdsspq
@@ -44,6 +50,12 @@
   return _rdsspq(a);
 }
 
+unsigned long long test_rdsspq_i64() {
+  // X86_64-LABEL: @test_rdsspq_i64
+  // X86_64:       call i64 @llvm.x86.rdsspq(i64 %{{[a-z0-9.]+}})
+  return _rdsspq_i64();
+}
+
 unsigned long long test_get_ssp(void) {
   // X86_64-LABEL: @test_get_ssp
   // X86_64:       call i64 @llvm.x86.rdsspq(i64 0)
Index: clang/lib/Headers/cetintrin.h
===================================================================
--- clang/lib/Headers/cetintrin.h
+++ clang/lib/Headers/cetintrin.h
@@ -42,10 +42,20 @@
   return __builtin_ia32_rdsspd(__a);
 }
 
+static __inline__ unsigned int __DEFAULT_FN_ATTRS _rdsspd_i32() {
+  unsigned int t;
+  return __builtin_ia32_rdsspd(t);
+}
+
 #ifdef __x86_64__
 static __inline__ unsigned long long __DEFAULT_FN_ATTRS _rdsspq(unsigned long long __a) {
   return __builtin_ia32_rdsspq(__a);
 }
+
+static __inline__ unsigned long long __DEFAULT_FN_ATTRS _rdsspq_i64() {
+  unsigned long long t;
+  return __builtin_ia32_rdsspq(t);
+}
 #endif /* __x86_64__ */
 
 #ifdef __x86_64__


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116325.396355.patch
Type: text/x-patch
Size: 1555 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211228/e2c44e1f/attachment-0001.bin>


More information about the cfe-commits mailing list