OpenCores
URL https://opencores.org/ocsvn/forwardcom/forwardcom/trunk

Subversion Repositories forwardcom

[/] [forwardcom/] [manual/] [fwc_multiple_instruction_sets.tex] - Blame information for rev 150

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 150 Agner
% chapter included in forwardcom.tex
2
\documentclass[forwardcom.tex]{subfiles}
3
\begin{document}
4
\RaggedRight
5
 
6
\chapter{Support for multiple instruction sets}
7
 
8
A microprocessor may support multiple instruction sets. It will be useful for compatibility with legacy software that a microprocessor with support for ForwardCom also supports one or more older instruction sets. Such a microprocessor will have different modes, one for each instruction set. Instructions of different instruction sets cannot be mixed freely. Virtualization support might be useful so that we can have one virtual machine for each instruction set.
9
\vv
10
 
11
The transitions between ForwardCom and other instruction sets can be implemented with instructions dedicated to this purpose or with software interrupts or system calls.
12
\vv
13
 
14
If mode transitions are allowed only in system code then it is not necessary to save any registers across the mode switch. But if mode transitions are possible also in application code then the following principles should be applied:
15
 
16
\begin{itemize}
17
\item The instruction that makes the mode switch must be aligned to an address divisible by 4.
18
 
19
\item The hardware or operating system must make sure that all general purpose registers are preserved across a mode switch between ForwardCom and another instruction set if similar registers exist in the other instruction set.
20
 
21
\item The software must set up stack pointers and other special registers immediately before or after the mode switch.
22
 
23
\item The software must take care of differences in function calling conventions between the two modes.
24
 
25
\item The hardware or operating system must make sure that the contents of at least the first eight vector registers is preserved across the mode switch. The remaining vector registers must be cleared if they are not preserved.
26
 
27
\item If the target instruction set has a lower maximum vector length than the actual length of a vector register before conversion, then the length is truncated to the maximum length for the target instruction set.
28
 
29
\item The vector length information is lost in the transition from ForwardCom to another instruction set if the other instruction set has no similar way of representing vector length.
30
 
31
\item The length of each vector register is set to a value that is sufficient to contain the nonzero part of the register, or longer, when converting from another instruction set to ForwardCom,
32
 
33
\end{itemize}
34
 
35
Details that are specific to a particular other instruction set are discussed in the following sections.
36
 
37
\subsection{Transitions between ForwardCom and x86-64}
38
Transitions between ForwardCom and the x86-64 instruction set (with the AVX512 extension) involve the following registers:
39
 
40
\begin{longtable} {|p{20mm}|p{20mm}|p{80mm}|}
41
\caption{ForwardCom and x86-64 registers}
42
\label{table:ForwardComAndX64Registers}
43
\\
44
\endfirsthead
45
\endhead
46
\hline
47
\bfseries x86-64 & \bfseries ForwardCom & \bfseries Comments  \\
48
\hline
49
rax & r0 &   \\
50
rcx & r1 &  \\
51
rdx & r2 &  \\
52
rbx & r3 &  \\
53
rsp & r4 & Stack pointer. Must be set before or after conversion to x86-64. \\
54
rbp & r5 &  \\
55
rsi & r6 &  \\
56
rdi & r7 &  \\
57
r8 - r15 & r8 - r15 &  \\
58
\hline
59
 & r16-r30  & Not converted \\
60
 & r31 & Stack pointer. Must be set after conversion to ForwardCom. \\
61
\hline
62
flags &  & Flags register. Not converted. \\
63
\hline
64
k0 - k7 &  & Mask registers. Not converted. \\
65
\hline
66
zmm0 - zmm7 & v0 - v7 & Vector registers. Converted. \\
67
zmm8 - zmm31 & v8 - v31 & Vector registers. Converted or cleared. \\
68
\hline
69
\end{longtable}
70
 
71
\vv
72
It is possible to make multi-mode functions that can be called from either ForwardCom or x86-64 mode in the following way. The first four bytes of the multi-mode function consist of a short x86-64 jump instruction, which is two bytes long, followed by two bytes of zero. The jump leads to an x86-64 implementation of the code. The four bytes will be interpreted as a NOP (no operation) if the processor is in ForwardCom mode. After this follows a ForwardCom implementation of the function.
73
 
74
 
75
\subsection{Transitions between ForwardCom and ARM}
76
 
77
Transitions between ForwardCom and the ARM (AArch64) instruction set involve the following registers:
78
 
79
\begin{longtable} {|p{20mm}|p{20mm}|p{80mm}|}
80
\caption{ForwardCom and ARM registers}
81
\label{table:ForwardComAndARMRegisters}
82
\\
83
\endfirsthead
84
\endhead
85
\hline
86
\bfseries ARM & \bfseries ForwardCom & \bfseries Comments  \\
87
\hline
88
r0 - r30 & r0 - r30 &   \\
89
\hline
90
r31 & r31 & Stack pointer in both instruction sets \\
91
\hline
92
v0 - v7 & v0 - v7 & Vector registers. Converted \\
93
\hline
94
v8 - v31 & v8 - v31 & Vector registers. Converted or cleared \\
95
\hline
96
p0 - p15 &  & Predicate registers. Not converted \\
97
\hline
98
\end{longtable}
99
 
100
\vv
101
The Scalable Vector Extensions (SVE) is a future extension to the ARM architecture that
102
allows the length of vector registers to vary from 128 to 2048 bits in increments of 128 bits. The vector length in SVE is apparently controlled through predicate masks. The vector length information cannot be converted to ForwardCom because there is no unambiguous connection between each vector register and the predicate register that contains the length information.
103
 
104
\subsection{Transitions between ForwardCom and RISC-V}
105
 
106
Transitions between ForwardCom and the RISC-V instruction set involve the following registers:
107
 
108
\begin{longtable} {|p{20mm}|p{20mm}|p{80mm}|}
109
\caption{ForwardCom and RISC-V registers}
110
\label{table:ForwardComAndRISCVRegisters}
111
\\
112
\endfirsthead
113
\endhead
114
\hline
115
\bfseries RISC-V & \bfseries ForwardCom & \bfseries Comments  \\
116
\hline
117
x0 &  &  Always zero. \\
118
\hline
119
x1 - x31 & r1 - r31 & General purpose registeers. x1 = link register,
120
x14 = stack pointer, x15 = thread pointer. \\
121
\hline
122
f0 - f7 & v0 - v7 & Floating point and vector registers. Converted. \\
123
\hline
124
f8 - f31 & v8 - v31 & Floating point and vector registers. Converted or cleared. \\
125
\hline
126
\end{longtable}
127
 
128
\vv
129
The SIMD / Vector Extensions to RISC-V are not fully developed yet (January 2017). It is therefore too early to tell whether the vector length information can be converted in a useful way during transitions between ForwardCom and RISC-V.
130
 
131
 
132
 
133
\end{document}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.