Skip to content

Commit 6cea8e8

Browse files
Codegen tests for Arm Cortex-R82
This PR adds checks to the `aarch64v8r-unknown-none` target to verify that if the Cortex-R82 CPU is enabled (with `-Ctarget-cpu=cortex-r82`), that the appropriate additional AArch64 features are enabled. This is important because Cortex-R82 is (currently) the only processor implementing Armv8-R AArch64 and it implements a number of Armv8 features over and above the baseline for the architecture. Many of these features are of interest to safety-critical firmware development (for example `FEAT_RASv1p1`, which adds support for the *RAS Common Fault Injection Model Extension*) and so we anticipate them being enabled when building such firmware. We are offering these tests upstream in-lieu of a full Cortex-R82 specific target because we understand the Project has a preference for architecture-baseline targets over CPU-specific targets. This PR builds on and requires #150863, but we've pulled them out as a separate PR. This PR was developed by Ferrous Systems on behalf of Arm. Arm is the owner of these changes.
1 parent 6ecb3f3 commit 6cea8e8

File tree

2 files changed

+181
-1
lines changed

2 files changed

+181
-1
lines changed

tests/ui/asm/aarch64v8r.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
// Codegen test of mandatory Armv8-R AArch64 extensions
22

3+
// The Cortex-R82 CPU is an implementation of the Arm v8-R AArch64 ISA so
4+
// it also implements the ISA-level mandatory extensions. We check that with a revision
35
//@ add-minicore
4-
//@ revisions: hf sf
6+
//@ revisions: hf sf r82
57
//@ [hf] compile-flags: --target aarch64v8r-unknown-none
68
//@ [hf] needs-llvm-components: aarch64
79
//@ [sf] compile-flags: --target aarch64v8r-unknown-none-softfloat
810
//@ [sf] needs-llvm-components: aarch64
11+
//@ [r82] compile-flags: --target aarch64v8r-unknown-none -C target-cpu=cortex-r82
12+
//@ [r82] needs-llvm-components: aarch64
913
//@ build-pass
1014
//@ ignore-backends: gcc
1115

tests/ui/asm/cortex-r82.rs

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
// Codegen test of mandatory Cortex-R82 extensions
2+
3+
//@ add-minicore
4+
//@ compile-flags: --target aarch64v8r-unknown-none -C target-cpu=cortex-r82
5+
//@ needs-llvm-components: aarch64
6+
//@ build-pass
7+
//@ ignore-backends: gcc
8+
9+
#![deny(dead_code)]
10+
#![feature(no_core)]
11+
#![no_core]
12+
#![no_main]
13+
#![crate_type = "rlib"]
14+
15+
extern crate minicore;
16+
use minicore::*;
17+
18+
/* # Mandatory extensions
19+
*
20+
* A `//` comment indicates that the extension has no associated assembly instruction and cannot
21+
* be codegen tested
22+
* A `/* */` comment indicates that the extension is being tested in the ISA level codegen test
23+
* (`tests/ui/asm/aarch64v8r.rs`)
24+
*
25+
* ## References:
26+
*
27+
* - Arm Cortex-R82 Processor Technical Reference Manual Revision r3p1 (102670_0301_06_en Issue 6)
28+
* section 3.2.1 has the list of mandatory extensions
29+
* - Arm Architecture Reference Manual for A-profile architecture (ARM DDI 0487) -- has the
30+
* mapping from features to instructions
31+
* - Feature names in A-profile architecture (109697_0100_02_en Version 1.0) -- overview of what
32+
* each extension mean
33+
* */
34+
pub fn mandatory_extensions() {
35+
// FEAT_GICv3
36+
// FEAT_GICv3p1
37+
// FEAT_GICv3_TDIR
38+
feat_pmuv3();
39+
// FEAT_ETMv4
40+
// FEAT_ETMv4p1
41+
// FEAT_ETMv4p2
42+
// FEAT_ETMv4p3
43+
// FEAT_ETMv4p4
44+
// FEAT_ETMv4p5
45+
/* FEAT_RAS */
46+
// FEAT_PCSRv8
47+
feat_ssbs();
48+
feat_ssbs2();
49+
// FEAT_CSV2
50+
// FEAT_CSV2_1p1
51+
// FEAT_CSV3
52+
feat_sb();
53+
feat_specres();
54+
feat_dgh();
55+
// FEAT_nTLBPA
56+
/* FEAT_CRC32 */
57+
/* FEAT_LSE */
58+
feat_rdm();
59+
/* FEAT_HPDS */
60+
/* FEAT_PAN */
61+
// FEAT_HAFDBS
62+
// FEAT_PMUv3p1
63+
// FEAT_TTCNP
64+
// FEAT_XNX
65+
/* FEAT_UAO */
66+
feat_pan2();
67+
feat_dpb();
68+
/* FEAT_Debugv8p2 */
69+
/* FEAT_ASMv8p2 */
70+
// FEAT_IESB
71+
feat_fp16();
72+
// FEAT_PCSRv8p2
73+
feat_dotprod();
74+
feat_fhm();
75+
feat_dpb2();
76+
/* FEAT_PAuth */
77+
// FEAT_PACQARMA3
78+
// FEAT_PAuth2
79+
// FEAT_FPAC
80+
// FEAT_FPACCOMBINE
81+
// FEAT_CONSTPACFIELD
82+
feat_jscvt();
83+
/* FEAT_LRCPC */
84+
feat_fcma();
85+
// FEAT_DoPD
86+
// FEAT_SEL2
87+
/* FEAT_S2FWB */
88+
/* FEAT_DIT */
89+
/* FEAT_IDST */
90+
/* FEAT_FlagM */
91+
/* FEAT_LSE2 */
92+
/* FEAT_LRCPC2 */
93+
/* FEAT_TLBIOS */
94+
/* FEAT_TLBIRANGE */
95+
/* FEAT_TTL */
96+
// FEAT_BBM
97+
// FEAT_CNTSC
98+
feat_rasv1p1();
99+
// FEAT_Debugv8p4
100+
feat_pmuv3p4();
101+
feat_trf();
102+
// FEAT_TTST
103+
// FEAT_E0PD
104+
}
105+
106+
fn feat_pmuv3() {
107+
unsafe { asm!("mrs x0, PMCCFILTR_EL0") }
108+
}
109+
110+
fn feat_ssbs() {
111+
unsafe { asm!("msr SSBS, 1") }
112+
}
113+
114+
fn feat_ssbs2() {
115+
unsafe { asm!("mrs x0, SSBS") }
116+
}
117+
118+
fn feat_sb() {
119+
unsafe { asm!("sb") }
120+
}
121+
122+
fn feat_specres() {
123+
unsafe { asm!("cfp rctx, x0") }
124+
}
125+
126+
fn feat_dgh() {
127+
unsafe { asm!("dgh") }
128+
}
129+
130+
fn feat_rdm() {
131+
unsafe { asm!("sqrdmlah v0.4h, v1.4h, v2.4h") }
132+
}
133+
134+
fn feat_pan2() {
135+
unsafe { asm!("AT S1E1RP, x0") }
136+
}
137+
138+
fn feat_dpb() {
139+
unsafe { asm!("DC CVAP, x0") }
140+
}
141+
142+
fn feat_fp16() {
143+
unsafe { asm!("fmulx h0, h1, h2") }
144+
}
145+
146+
fn feat_dotprod() {
147+
unsafe { asm!("sdot V0.4S, V1.16B, V2.16B") }
148+
}
149+
150+
fn feat_fhm() {
151+
unsafe { asm!("fmlal v0.2s, v1.2h, v2.2h") }
152+
}
153+
154+
fn feat_dpb2() {
155+
unsafe { asm!("DC CVADP, x0") }
156+
}
157+
158+
fn feat_jscvt() {
159+
unsafe { asm!("fjcvtzs w0, d1") }
160+
}
161+
162+
fn feat_fcma() {
163+
unsafe { asm!("fcadd v0.4h, v1.4h, v2.4h, #90") }
164+
}
165+
166+
fn feat_rasv1p1() {
167+
unsafe { asm!("mrs x0, ERXMISC2_EL1") }
168+
}
169+
170+
fn feat_pmuv3p4() {
171+
unsafe { asm!("mrs x0, PMMIR_EL1") }
172+
}
173+
174+
fn feat_trf() {
175+
unsafe { asm!("tsb csync") }
176+
}

0 commit comments

Comments
 (0)