blob: c440f090d479238ea77938a3351342e88a28ade4 [file] [log] [blame]
johpow0150ccb552020-11-10 19:22:13 -06001/*
Jayanth Dodderi Chidanandb3ffd3c2023-02-13 12:15:11 +00002 * Copyright (c) 2021-2023, ARM Limited and Contributors. All rights reserved.
johpow0150ccb552020-11-10 19:22:13 -06003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <assert_macros.S>
10
johpow0150ccb552020-11-10 19:22:13 -060011 .arch armv8-a+sve
12 .globl sme_rdvl_1
13 .globl sme_try_illegal_instruction
Jayanth Dodderi Chidanandb3ffd3c2023-02-13 12:15:11 +000014 .globl sme_vector_to_ZA
15 .globl sme_ZA_to_vector
16
17
18/*
19 * TODO: Due to the limitation with toolchain, SME intrinsics, still not being
20 * supported, instructions are manually encoded using the opcodes.
21 * Further, when the toolchain supports the requirements, these macros could
22 * be refactored.
23 */
24
25
26/*
27 * LDR (Loads a vector (an array of elements ) to ZA array ):
28 * LDR ZA[\nw, #\offset], [X\nxbase, #\offset, MUL VL]
29 *
30 * Arguments/Opcode bit field:
31 * nw : the vector select register W12-W15
32 * nxbase : 64-bit name of the general-purpose base register.
33 * offset : vector select and optional memory offset. Default to 0.
34 */
35.macro _ldr_za nw, nxbase, offset=0
36 .inst 0xe1000000 \
37 | (((\nw) & 3) << 13) \
38 | ((\nxbase) << 5) \
39 | ((\offset) & 0xf)
40.endm
41
42/*
43 * STR ( It stores an array of elements from ZA array to a vector ).
44 * STR ZA[\nw, #\offset], [X\nxbase, #\offset, MUL VL]
45 *
46 * Arguments/Opcode bit field:
47 * nw : the vector select register W12-W15
48 * nxbase : 64-bit name of the general-purpose base register.
49 * offset : vector select and optional memory offset. Default to 0.
50 */
51.macro _str_za nw, nxbase, offset=0
52 .inst 0xe1200000 \
53 | (((\nw) & 3) << 13) \
54 | ((\nxbase) << 5) \
55 | ((\offset) & 0xf)
56.endm
johpow0150ccb552020-11-10 19:22:13 -060057
58/*
59 * uint64_t sme_rdvl_1(void);
60 *
61 * Run rdvl instruction with imm #1.
62 */
63func sme_rdvl_1
64 rdvl x0, #1
65 ret
66endfunc sme_rdvl_1
67
68/*
69 * void sme_try_illegal_instruction(void);
70 *
71 * This function tests that illegal instructions are allowed to run when
72 * FA64 is supported. RDFFR is explicitly stated to be illegal in the SME
73 * specification section F1.1.2 unless FA64 is supported and enabled.
74 */
75func sme_try_illegal_instruction
76 rdffr p0.b
77 ret
78endfunc sme_try_illegal_instruction
79
Jayanth Dodderi Chidanandb3ffd3c2023-02-13 12:15:11 +000080
81/**
82 * void sme_vector_to_ZA(uint64_t *input_vec)
83 *
84 * This function loads an vector of elements to an ZA Array storage
85 */
86func sme_vector_to_ZA
87 mov w12, wzr
88 _ldr_za 12, 0 // ZA.H[W12] loaded from [X0 / input_vector]
89 ret
90endfunc sme_vector_to_ZA
91
92/**
93 * void sme_ZA_to_vector(uint64_t *out_vec)
94 *
95 * This function stores elements from ZA Array storage to an ZA vector
96 */
97func sme_ZA_to_vector
98 mov w12, wzr
99 _str_za 12, 0 // ZA.H[W12] stored to [X0 / out_vector]
100 ret
101endfunc sme_ZA_to_vector