================
@@ -1,55 +1,705 @@
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm < %s| FileCheck %s
 
-// Test that we have the structure definition, the gep offsets, the name of the
-// global, the bit grab, and the icmp correct.
+// Test that __builtin_cpu_is emits the correct ABI value and field offset
+// for every vendor, cpu type, and cpu subtype (including aliases) listed in
+// llvm/include/llvm/TargetParser/X86TargetParser.def. These values are an ABI
+// contract shared with compiler-rt/libgcc.
 extern void a(const char *);
 
 // CHECK: @__cpu_model = external dso_local global { i32, i32, i32, [1 x i32] }
 
-void intel(void) {
+// Vendors (field offset 0).
+void test_intel(void) {
   if (__builtin_cpu_is("intel"))
     a("intel");
 
+  // CHECK-LABEL: define{{.*}} void @test_intel(
   // CHECK: [[LOAD:%[^ ]+]] = load i32, ptr @__cpu_model
   // CHECK: = icmp eq i32 [[LOAD]], 1
 }
 
-void amd(void) {
+void test_amd(void) {
   if (__builtin_cpu_is("amd"))
     a("amd");
 
+  // CHECK-LABEL: define{{.*}} void @test_amd(
   // CHECK: [[LOAD:%[^ ]+]] = load i32, ptr @__cpu_model
   // CHECK: = icmp eq i32 [[LOAD]], 2
 }
 
-void atom(void) {
-  if (__builtin_cpu_is("atom"))
-    a("atom");
+void test_other(void) {
+  if (__builtin_cpu_is("other"))
+    a("other");
+
+  // CHECK-LABEL: define{{.*}} void @test_other(
+  // CHECK: [[LOAD:%[^ ]+]] = load i32, ptr @__cpu_model
+  // CHECK: = icmp eq i32 [[LOAD]], 4
+}
+
+// CPU types (field offset 4).
+void test_bonnell(void) {
----------------
RKSimon wrote:

I don't suppose we can handle all these with less duplication using sed or 
something - so we have a lot of RUN lines that inject the type / subtype into 
single/fewer tests? Might need to split into a couple of test files 
(vendor/cputype/subtype)? Sorry for the bikeshedding.....

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

Reply via email to