1 // CHERI triple without any flags should set 128 defines
2 // RUN: %plain_clang_cheri_triple_allowed -target cheri-unknown-freebsd11  \
3 // RUN:  -mabi=purecap -E -dM -xc /dev/null 2>&1 | FileCheck --check-prefixes=PURECAP,PURECAP-128,CHERI128 %s
4 // or with -cheri
5 // RUN: %plain_clang_cheri_triple_allowed -target cheri-unknown-freebsd11 -cheri \
6 // RUN:   -mabi=purecap -E -dM -xc /dev/null 2>&1 | FileCheck --check-prefixes=PURECAP,PURECAP-128,CHERI128 %s
7 // or with -cheri=128
8 // RUN: %plain_clang_cheri_triple_allowed -target cheri-unknown-freebsd11 -cheri=128 \
9 // RUN:   -mabi=purecap -E -dM -xc /dev/null 2>&1 | FileCheck --check-prefixes=PURECAP,PURECAP-128,CHERI128 %s
10 // or with both
11 // RUN: %plain_clang_cheri_triple_allowed -target cheri-unknown-freebsd11 -cheri=128 -mcpu=cheri128 \
12 // RUN:   -mabi=purecap -E -dM -xc /dev/null 2>&1 | FileCheck --check-prefixes=PURECAP,PURECAP-128,CHERI128 %s
13 
14 // Try with -march=mips64
15 // RUN: %plain_clang_cheri_triple_allowed -target cheri-unknown-freebsd11 -mcpu=mips4 -cheri=128 \
16 // RUN:   -mabi=purecap -E -dM -xc /dev/null 2>&1 | FileCheck --check-prefixes=PURECAP,PURECAP-128,CHERI128 %s
17 // and -mcpu=mips4
18 // RUN: %plain_clang_cheri_triple_allowed -target cheri-unknown-freebsd11 -march=mips64 -cheri=128 \
19 // RUN:   -mabi=purecap -E -dM -xc /dev/null 2>&1 | FileCheck --check-prefixes=PURECAP,PURECAP-128,CHERI128 %s
20 
21 // now try a non-cheri triple but -mcpu=cheri128
22 // RUN: %plain_clang_cheri_triple_allowed -target mips64-unknown-freebsd11 -mcpu=cheri128 \
23 // RUN:   -mabi=n64 -E -dM -xc /dev/null 2>&1 | FileCheck --check-prefixes=MIPS,CHERI128 -DARCHNAME=CHERI128 %s
24 
25 // now try a non-cheri triple with -cheri
26 // RUN: %plain_clang_cheri_triple_allowed -target mips64-unknown-freebsd11 -cheri \
27 // RUN:   -mabi=n64 -E -dM -xc /dev/null 2>&1 | FileCheck --check-prefixes=MIPS,CHERI128 -DARCHNAME=MIPS3 %s
28 // RUN: %plain_clang_cheri_triple_allowed -target mips64-unknown-freebsd11 -cheri=128 \
29 // RUN:   -mabi=n64 -E -dM -xc /dev/null 2>&1 | FileCheck --check-prefixes=MIPS,CHERI128 -DARCHNAME=MIPS3 %s
30 // RUN: %plain_clang_cheri_triple_allowed -target mips64-unknown-freebsd11 -cheri=128 \
31 // RUN:   -mabi=n64 -E -dM -xc /dev/null 2>&1 | FileCheck --check-prefixes=MIPS,128 -DARCHNAME=MIPS3 %s
32 
33 
34 // MIPS: #define _MIPS_ARCH_CHERI128 1
35 // CHERI128: #define _MIPS_CAP_ALIGN_MASK 0xfffffffffffffff0
36 // CHERI128: #define _MIPS_SZCAP 128
37 // CHECK: #define __CHERI_ADDRESS_BITS__ 64
38 // CHERI128: #define __CHERI_CAPABILITY_WIDTH__ 128
39 // PURECAP: #define __CHERI_PURE_CAPABILITY__ 2
40 // MIPS-NOT: __CHERI_PURE_CAPABILITY__
41 // CHECK: #define __CHERI__ 1
42 // Note: 64-bit range for intcap makes more sense than the full range for pointers
43 // CHECK: #define __INTCAP_MAX__ 9223372036854775807L
44 
45 // CHERI128: #define __INTCAP_WIDTH__ 128
46 
47 // Using the 128/256-bit integer type for __INTPTR_MAX__ does not make sense
48 // See https://github.com/CTSRD-CHERI/llvm-project/issues/316
49 // CHECK:     #define __INTPTR_MAX__ 9223372036854775807L
50 // CHECK:     #define __INTPTR_TYPE__ __intcap_t
51 
52 // CHERI128: #define __SIZEOF_CHERI_CAPABILITY__ 16
53 // CHERI128: #define __SIZEOF_INTCAP__ 16
54 
55 // MIPS: #define __SIZEOF_POINTER__ 8
56 // PURECAP-128: #define __SIZEOF_POINTER__ 16
57 
58 // CHERI128: #define __SIZEOF_UINTCAP__ 16
59 // CHECK:    #define __UINTCAP_MAX__ 18446744073709551615UL
60 // CHERI128: #define __UINTCAP_WIDTH__ 128
61 
62 // MIPS:        #define __UINTPTR_MAX__ 18446744073709551615UL
63 // Using the 128/256-bit integer type for __UINTPTR_MAX__ does not make sense
64 // See https://github.com/CTSRD-CHERI/llvm-project/issues/316
65 // CHECK:     #define __UINTPTR_MAX__ 18446744073709551615UL
66 
67 // MIPS:        #define __UINTPTR_TYPE__ long unsigned int
68 // PURECAP:     #define __UINTPTR_TYPE__ __uintcap_t
69 // MIPS:        #define __UINTPTR_WIDTH__ 64
70 // PURECAP-128: #define __UINTPTR_WIDTH__ 128
71