[clang] [compiler-rt] [llvm] [X86] Sync compiler-rt cpu subtypes and vendors with libgcc and refactor internal cpu type tables in LLVM (PR #171172)
Phoebe Wang via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 6 19:23:04 PDT 2026
================
@@ -0,0 +1,93 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm < %s | FileCheck %s
+
+// Test that __builtin_cpu_is emits the correct ABI value for every CPU type,
+// in llvm/include/llvm/TargetParser/X86TargetParser.def.
+extern void a(const char *);
+
+// CHECK: @__cpu_model = external dso_local global { i32, i32, i32, [1 x i32] }
+
+#define TEST_CPU_IS(NAME, STR) \
+ void test_##NAME(void) { \
+ if (__builtin_cpu_is(STR)) \
+ a(STR); \
+ }
+
+// CHECK-LABEL: define{{.*}} void @test_bonnell(
+// CHECK: [[LOAD:%[^ ]+]] = load i32, ptr getelementptr inbounds nuw (i8, ptr @__cpu_model, i64 4)
+// CHECK: = icmp eq i32 [[LOAD]], 1
+TEST_CPU_IS(bonnell, "bonnell")
+
+// CHECK: = icmp eq i32 {{.*}}, 2
----------------
phoebewang wrote:
Given each macro is a function, we should use CHECK-LABEL for each of them. We should also check the `load .. __cpu_model` to make sure we are reading the correct bit. This applies to the rest tests.
https://github.com/llvm/llvm-project/pull/171172
More information about the llvm-commits
mailing list