================
@@ -0,0 +1,46 @@
+// RUN: %clang_cc1 -x c -ffreestanding -triple x86_64-unknown-linux -fclangir 
-emit-cir -o %t.cir %s
+// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
+
+// RUN: %clang_cc1 -x c -ffreestanding -triple x86_64-unknown-linux -fclangir 
-emit-llvm -o %t.ll %s
+// RUN: FileCheck --check-prefix=LLVM --input-file=%t.ll %s
+
+// RUN: %clang_cc1 -x c -ffreestanding -triple=x86_64-unknown-linux -emit-llvm 
-o - %s | FileCheck %s -check-prefix=OGCG
+
+// This test mimics clang/test/CodeGen/X86/rd-builtins.c, which eventually
+// CIR shall be able to support fully.
+
+unsigned long long test_rdtsc(void) {
+  // CIR-LABEL: @test_rdtsc
+  // CIR: {{%.*}} = cir.call_llvm_intrinsic "x86.rdtsc"() : () -> !u64i
+
+  // LLVM-LABEL: @test_rdtsc
+  // LLVM: call i64 @llvm.x86.rdtsc()
+
+  // OGCG-LABEL: @test_rdtsc
+  // OGCG: call i64 @llvm.x86.rdtsc()
+
+  return __rdtsc();
+}
+
+unsigned long long test_rdtscp(unsigned int *a) {
+  // CIR-LABEL: @test_rdtscp
+  // CIR: {{%.*}} = cir.call_llvm_intrinsic "x86.rdtscp"() : () -> 
!cir.record<!anon
+  // CIR: {{%.*}} = cir.extract_member {{%.*}}[1] : !cir.record<!anon
+  // CIR: cir.store {{%.*}}, {{%.*}} : !u32i
+  // CIR: {{%.*}} = cir.extract_member {{%.*}}[0] : !cir.record<!anon
+
+  // LLVM-LABEL: @test_rdtscp
+  // LLVM: call { i64, i32 } @llvm.x86.rdtscp()
+  // LLVM: extractvalue { i64, i32 } {{%.*}}, 1
+  // LLVM: store i32 {{%.*}}, ptr {{%.*}}
+  // LLVM: extractvalue { i64, i32 } {{%.*}}, 0
+
+  // OGCG-LABEL: @test_rdtscp
+  // OGCG: [[RDTSCP:%.*]] = call { i64, i32 } @llvm.x86.rdtscp
----------------
Priyanshu3820 wrote:

``

https://github.com/llvm/llvm-project/pull/180714
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to