Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGen / arm-cmse-secure.c
blob132172b6c8702e57753364d2faacc6da50eed817
1 // RUN: %clang_cc1 -triple thumbv8m.base-unknown-unknown-eabi -emit-llvm -mrelocation-model static -mcmse -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple thumbebv8m.base-unknown-unknown-eabi -emit-llvm -mrelocation-model static -mcmse -o - %s | FileCheck %s
4 #include <arm_cmse.h>
6 unsigned test_cmse_primitives(void *p) {
7 // CHECK: define {{.*}} i32 @test_cmse_primitives
8 cmse_address_info_t tt_val, ttt_val;
9 cmse_address_info_t tta_val, ttat_val;
10 unsigned sum;
12 tt_val = cmse_TT(p);
13 ttt_val = cmse_TTT(p);
14 tta_val = cmse_TTA(p);
15 ttat_val = cmse_TTAT(p);
16 // CHECK: call i32 @llvm.arm.cmse.tt
17 // CHECK: call i32 @llvm.arm.cmse.ttt
18 // CHECK: call i32 @llvm.arm.cmse.tta
19 // CHECK: call i32 @llvm.arm.cmse.ttat
21 sum = tt_val.value;
22 sum += ttt_val.value;
23 sum += tta_val.value;
24 sum += ttat_val.value;
26 sum += tt_val.flags.mpu_region;
27 sum += tt_val.flags.sau_region;
28 sum += tt_val.flags.mpu_region_valid;
29 sum += tt_val.flags.sau_region_valid;
30 sum += tt_val.flags.read_ok;
31 sum += tt_val.flags.readwrite_ok;
32 sum += tt_val.flags.nonsecure_read_ok;
33 sum += tt_val.flags.nonsecure_readwrite_ok;
34 sum += tt_val.flags.secure;
35 sum += tt_val.flags.idau_region_valid;
36 sum += tt_val.flags.idau_region;
38 return sum;
41 void *test_address_range(void *p) {
42 // CHECK: define {{.*}} ptr @test_address_range
43 return cmse_check_address_range(p, 128, CMSE_MPU_UNPRIV
44 | CMSE_MPU_NONSECURE
45 | CMSE_MPU_READWRITE);
46 // CHECK: call i32 @llvm.arm.cmse.tt
47 // CHECK: call i32 @llvm.arm.cmse.ttt
48 // CHECK: call i32 @llvm.arm.cmse.tta
49 // CHECK: call i32 @llvm.arm.cmse.ttat
52 typedef struct {
53 int x, y, z;
54 } Point;
56 void *test_pointed_object(void *p) {
57 // CHECK: define {{.*}} ptr @test_pointed_object
58 Point *pt = (Point *)p;
59 cmse_check_pointed_object(pt, CMSE_NONSECURE
60 | CMSE_MPU_READ
61 | CMSE_AU_NONSECURE);
62 // CHECK: call i32 @llvm.arm.cmse.tt
63 // CHECK: call i32 @llvm.arm.cmse.ttt
64 // CHECK: call i32 @llvm.arm.cmse.tta
65 // CHECK: call i32 @llvm.arm.cmse.ttat