Craig Topper | 699ae0c | 2017-08-10 20:28:30 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -emit-llvm < %s| FileCheck %s |
| 2 | |
| 3 | // Test that we have the structure definition, the gep offsets, the name of the |
| 4 | // global, the bit grab, and the icmp correct. |
| 5 | extern void a(const char *); |
| 6 | |
Haibo Huang | 303b233 | 2018-12-20 21:33:59 +0000 | [diff] [blame] | 7 | // CHECK: @__cpu_model = external dso_local global { i32, i32, i32, [1 x i32] } |
| 8 | |
Craig Topper | 699ae0c | 2017-08-10 20:28:30 +0000 | [diff] [blame] | 9 | void intel() { |
| 10 | if (__builtin_cpu_is("intel")) |
| 11 | a("intel"); |
| 12 | |
| 13 | // CHECK: [[LOAD:%[^ ]+]] = load i32, i32* getelementptr inbounds ({ i32, i32, i32, [1 x i32] }, { i32, i32, i32, [1 x i32] }* @__cpu_model, i32 0, i32 0) |
| 14 | // CHECK: = icmp eq i32 [[LOAD]], 1 |
| 15 | } |
| 16 | |
| 17 | void amd() { |
| 18 | if (__builtin_cpu_is("amd")) |
| 19 | a("amd"); |
| 20 | |
| 21 | // CHECK: [[LOAD:%[^ ]+]] = load i32, i32* getelementptr inbounds ({ i32, i32, i32, [1 x i32] }, { i32, i32, i32, [1 x i32] }* @__cpu_model, i32 0, i32 0) |
| 22 | // CHECK: = icmp eq i32 [[LOAD]], 2 |
| 23 | } |
| 24 | |
| 25 | void atom() { |
| 26 | if (__builtin_cpu_is("atom")) |
| 27 | a("atom"); |
| 28 | |
| 29 | // CHECK: [[LOAD:%[^ ]+]] = load i32, i32* getelementptr inbounds ({ i32, i32, i32, [1 x i32] }, { i32, i32, i32, [1 x i32] }* @__cpu_model, i32 0, i32 1) |
| 30 | // CHECK: = icmp eq i32 [[LOAD]], 1 |
| 31 | } |
| 32 | |
| 33 | void amdfam10h() { |
| 34 | if (__builtin_cpu_is("amdfam10h")) |
| 35 | a("amdfam10h"); |
| 36 | |
| 37 | // CHECK: [[LOAD:%[^ ]+]] = load i32, i32* getelementptr inbounds ({ i32, i32, i32, [1 x i32] }, { i32, i32, i32, [1 x i32] }* @__cpu_model, i32 0, i32 1) |
| 38 | // CHECK: = icmp eq i32 [[LOAD]], 4 |
| 39 | } |
| 40 | |
| 41 | void barcelona() { |
| 42 | if (__builtin_cpu_is("barcelona")) |
| 43 | a("barcelona"); |
| 44 | |
| 45 | // CHECK: [[LOAD:%[^ ]+]] = load i32, i32* getelementptr inbounds ({ i32, i32, i32, [1 x i32] }, { i32, i32, i32, [1 x i32] }* @__cpu_model, i32 0, i32 2) |
| 46 | // CHECK: = icmp eq i32 [[LOAD]], 4 |
| 47 | } |
| 48 | |
| 49 | void nehalem() { |
| 50 | if (__builtin_cpu_is("nehalem")) |
| 51 | a("nehalem"); |
| 52 | |
| 53 | // CHECK: [[LOAD:%[^ ]+]] = load i32, i32* getelementptr inbounds ({ i32, i32, i32, [1 x i32] }, { i32, i32, i32, [1 x i32] }* @__cpu_model, i32 0, i32 2) |
| 54 | // CHECK: = icmp eq i32 [[LOAD]], 1 |
| 55 | } |