Skip to content

Commit c908ea2

Browse files
authored
Rollup merge of rust-lang#151378 - ferrocene:add-cortexr82-testing, r=jdonszelmann
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 rust-lang#150863, but we've pulled them out as a separate PR.~~ That PR has been merged. ## Ownership This PR was developed by Ferrous Systems on behalf of Arm. Arm is the owner of these changes.
2 parents f60a0f1 + bdd19d0 commit c908ea2

2 files changed

Lines changed: 185 additions & 1 deletion

File tree

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: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
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+
* Note that as we use the hard-float `aarch64v8r-unknown-none` target as the base, the neon
26+
* extension is present (`NEON_FPm=1`). This affects which R82-specific extensions are enabled
27+
* (see "when `NEON_FPm == 1`" note in Cortex-R82 Processor Technical Reference Manual)
28+
*
29+
* ## References:
30+
*
31+
* - Arm Cortex-R82 Processor Technical Reference Manual Revision r3p1 (102670_0301_06_en Issue 6)
32+
* section 3.2.1 has the list of mandatory extensions
33+
* - Arm Architecture Reference Manual for A-profile architecture (ARM DDI 0487) -- has the
34+
* mapping from features to instructions
35+
* - Feature names in A-profile architecture (109697_0100_02_en Version 1.0) -- overview of what
36+
* each extension mean
37+
* */
38+
pub fn mandatory_extensions() {
39+
// FEAT_GICv3
40+
// FEAT_GICv3p1
41+
// FEAT_GICv3_TDIR
42+
feat_pmuv3();
43+
// FEAT_ETMv4
44+
// FEAT_ETMv4p1
45+
// FEAT_ETMv4p2
46+
// FEAT_ETMv4p3
47+
// FEAT_ETMv4p4
48+
// FEAT_ETMv4p5
49+
/* FEAT_RAS */
50+
// FEAT_PCSRv8
51+
feat_ssbs();
52+
feat_ssbs2();
53+
// FEAT_CSV2
54+
// FEAT_CSV2_1p1
55+
// FEAT_CSV3
56+
feat_sb();
57+
feat_specres();
58+
feat_dgh();
59+
// FEAT_nTLBPA
60+
/* FEAT_CRC32 */
61+
/* FEAT_LSE */
62+
feat_rdm(); // mandatory given that NEON_FPm=1
63+
/* FEAT_HPDS */
64+
/* FEAT_PAN */
65+
// FEAT_HAFDBS
66+
// FEAT_PMUv3p1
67+
// FEAT_TTCNP
68+
// FEAT_XNX
69+
/* FEAT_UAO */
70+
feat_pan2();
71+
feat_dpb();
72+
/* FEAT_Debugv8p2 */
73+
/* FEAT_ASMv8p2 */
74+
// FEAT_IESB
75+
feat_fp16(); // mandatory given that NEON_FPm=1
76+
// FEAT_PCSRv8p2
77+
feat_dotprod(); // mandatory given that NEON_FPm=1
78+
feat_fhm(); // mandatory given that NEON_FPm=1
79+
feat_dpb2();
80+
/* FEAT_PAuth */
81+
// FEAT_PACQARMA3
82+
// FEAT_PAuth2
83+
// FEAT_FPAC
84+
// FEAT_FPACCOMBINE
85+
// FEAT_CONSTPACFIELD
86+
feat_jscvt(); // mandatory given that NEON_FPm=1
87+
/* FEAT_LRCPC */
88+
feat_fcma(); // mandatory given that NEON_FPm=1
89+
// FEAT_DoPD
90+
// FEAT_SEL2
91+
/* FEAT_S2FWB */
92+
/* FEAT_DIT */
93+
/* FEAT_IDST */
94+
/* FEAT_FlagM */
95+
/* FEAT_LSE2 */
96+
/* FEAT_LRCPC2 */
97+
/* FEAT_TLBIOS */
98+
/* FEAT_TLBIRANGE */
99+
/* FEAT_TTL */
100+
// FEAT_BBM
101+
// FEAT_CNTSC
102+
feat_rasv1p1();
103+
// FEAT_Debugv8p4
104+
feat_pmuv3p4();
105+
feat_trf();
106+
// FEAT_TTST
107+
// FEAT_E0PD
108+
}
109+
110+
fn feat_pmuv3() {
111+
unsafe { asm!("mrs x0, PMCCFILTR_EL0") }
112+
}
113+
114+
fn feat_ssbs() {
115+
unsafe { asm!("msr SSBS, 1") }
116+
}
117+
118+
fn feat_ssbs2() {
119+
unsafe { asm!("mrs x0, SSBS") }
120+
}
121+
122+
fn feat_sb() {
123+
unsafe { asm!("sb") }
124+
}
125+
126+
fn feat_specres() {
127+
unsafe { asm!("cfp rctx, x0") }
128+
}
129+
130+
fn feat_dgh() {
131+
unsafe { asm!("dgh") }
132+
}
133+
134+
fn feat_rdm() {
135+
unsafe { asm!("sqrdmlah v0.4h, v1.4h, v2.4h") }
136+
}
137+
138+
fn feat_pan2() {
139+
unsafe { asm!("AT S1E1RP, x0") }
140+
}
141+
142+
fn feat_dpb() {
143+
unsafe { asm!("DC CVAP, x0") }
144+
}
145+
146+
fn feat_fp16() {
147+
unsafe { asm!("fmulx h0, h1, h2") }
148+
}
149+
150+
fn feat_dotprod() {
151+
unsafe { asm!("sdot V0.4S, V1.16B, V2.16B") }
152+
}
153+
154+
fn feat_fhm() {
155+
unsafe { asm!("fmlal v0.2s, v1.2h, v2.2h") }
156+
}
157+
158+
fn feat_dpb2() {
159+
unsafe { asm!("DC CVADP, x0") }
160+
}
161+
162+
fn feat_jscvt() {
163+
unsafe { asm!("fjcvtzs w0, d1") }
164+
}
165+
166+
fn feat_fcma() {
167+
unsafe { asm!("fcadd v0.4h, v1.4h, v2.4h, #90") }
168+
}
169+
170+
fn feat_rasv1p1() {
171+
unsafe { asm!("mrs x0, ERXMISC2_EL1") }
172+
}
173+
174+
fn feat_pmuv3p4() {
175+
unsafe { asm!("mrs x0, PMMIR_EL1") }
176+
}
177+
178+
fn feat_trf() {
179+
unsafe { asm!("tsb csync") }
180+
}

0 commit comments

Comments
 (0)