Skip to content

Commit 01e3313

Browse files
charlie-rivospalmer-dabbelt
authored andcommitted
riscv: Add xtheadvector instruction definitions
xtheadvector uses different encodings than standard vector for vsetvli and vector loads/stores. Write the instruction formats to be used in assembly code. Co-developed-by: Heiko Stuebner <[email protected]> Signed-off-by: Heiko Stuebner <[email protected]> Signed-off-by: Charlie Jenkins <[email protected]> Tested-by: Yangyu Chen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent b9a9314 commit 01e3313

File tree

1 file changed

+25
-0
lines changed
  • arch/riscv/include/asm/vendor_extensions

1 file changed

+25
-0
lines changed

arch/riscv/include/asm/vendor_extensions/thead.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,29 @@ void disable_xtheadvector(void);
1919
static inline void disable_xtheadvector(void) { }
2020
#endif
2121

22+
/* Extension specific helpers */
23+
24+
/*
25+
* Vector 0.7.1 as used for example on T-Head Xuantie cores, uses an older
26+
* encoding for vsetvli (ta, ma vs. d1), so provide an instruction for
27+
* vsetvli t4, x0, e8, m8, d1
28+
*/
29+
#define THEAD_VSETVLI_T4X0E8M8D1 ".long 0x00307ed7\n\t"
30+
31+
/*
32+
* While in theory, the vector-0.7.1 vsb.v and vlb.v result in the same
33+
* encoding as the standard vse8.v and vle8.v, compilers seem to optimize
34+
* the call resulting in a different encoding and then using a value for
35+
* the "mop" field that is not part of vector-0.7.1
36+
* So encode specific variants for vstate_save and _restore.
37+
*/
38+
#define THEAD_VSB_V_V0T0 ".long 0x02028027\n\t"
39+
#define THEAD_VSB_V_V8T0 ".long 0x02028427\n\t"
40+
#define THEAD_VSB_V_V16T0 ".long 0x02028827\n\t"
41+
#define THEAD_VSB_V_V24T0 ".long 0x02028c27\n\t"
42+
#define THEAD_VLB_V_V0T0 ".long 0x012028007\n\t"
43+
#define THEAD_VLB_V_V8T0 ".long 0x012028407\n\t"
44+
#define THEAD_VLB_V_V16T0 ".long 0x012028807\n\t"
45+
#define THEAD_VLB_V_V24T0 ".long 0x012028c07\n\t"
46+
2247
#endif

0 commit comments

Comments
 (0)