Skip to content

Commit 7d2476f

Browse files
committed
Add CGetHigh and CSetHigh to the RISC-V instruction reference
1 parent a5d945c commit 7d2476f

9 files changed

+75
-5
lines changed

app-isaquick-riscv.tex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ \chapter{CHERI-RISC-V ISA Quick Reference}
4747

4848
\rvcheriisaquick{CGetAddr}
4949

50+
\rvcheriisaquick{CGetHigh}
51+
5052
\rvcheriisaquick{CGetTop}
5153

5254
\dcnote{CGetPCC is a Special}
@@ -78,6 +80,8 @@ \chapter{CHERI-RISC-V ISA Quick Reference}
7880

7981
\rvcheriisaquick{CSetBoundsImm}
8082

83+
\rvcheriisaquick{CSetHigh}
84+
8185
\rvcheriisaquick{CClearTag}
8286

8387
\rvcheriisaquick{CBuildCap}

chap-isaref-riscv.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ \section{CHERI-RISC-V Instructions}
257257
\input{insn-riscv/cgetaddr}
258258
\input{insn-riscv/cgetbase}
259259
\input{insn-riscv/cgetflags}
260+
\input{insn-riscv/cgethigh}
260261
\input{insn-riscv/cgetlen}
261262
\input{insn-riscv/cgetoffset}
262263
\input{insn-riscv/cgetperm}
@@ -283,6 +284,7 @@ \section{CHERI-RISC-V Instructions}
283284
\input{insn-riscv/csetboundsimm}
284285
\input{insn-riscv/csetequalexact}
285286
\input{insn-riscv/csetflags}
287+
\input{insn-riscv/csethigh}
286288
\input{insn-riscv/csetoffset}
287289
\input{insn-riscv/cspecialrw}
288290
\input{insn-riscv/csub}

def-riscv-insns.tex

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,7 @@
2626
\rvcherisrcdest[name=CGetFlags]{7}{rd}{cs1}
2727
\rvcherisrcdest[name=CGetAddr]{F}{rd}{cs1}
2828
\rvcherisrcdest[name=CGetTop]{18}{cd}{cs1}
29-
30-
% Mark as noref and reserved until landing of
31-
% https://github.com/CTSRD-CHERI/sail-cheri-riscv/pull/55
32-
\rvcherisrcdest[name=CGetHigh,noref,tablesuffix=\rvcherireservedfootnotemark]{17}{cd}{cs1}
33-
\rvcherisrcsrcdest[name=CSetHigh,noref,tablesuffix=\rvcherireservedfootnotemark]{16}{cd}{cs1}{rs1}
29+
\rvcherisrcdest[name=CGetHigh]{17}{cd}{cs1}
3430

3531
\rvcherisrcsrcdest[name=CSeal]{B}{cd}{cs1}{cs2}
3632
\rvcherisrcsrcdest[name=CUnseal]{C}{cd}{cs1}{cs2}
@@ -43,6 +39,7 @@
4339
\rvcherisrcsrcdest[name=CSetBounds]{8}{cd}{cs1}{rs2}
4440
\rvcherisrcsrcdest[name=CSetBoundsExact]{9}{cd}{cs1}{rs2}
4541
\rvcherisrcsrcdestimm[name=CSetBoundsImm]{2}{cd}{cs1}{uimm}
42+
\rvcherisrcsrcdest[name=CSetHigh]{16}{cd}{cs1}{rs1}
4643
\rvcherisrcdest[name=CClearTag]{B}{cd}{cs1}
4744
\rvcherisrcsrcdest[name=CBuildCap]{1D}{cd}{cs1}{cs2}
4845
\rvcherisrcsrcdest[name=CCopyType]{1E}{cd}{cs1}{cs2}

insn-riscv/cgethigh.tex

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
\clearpage
2+
\phantomsection
3+
\addcontentsline{toc}{subsection}{CGetHigh}
4+
\insnriscvlabel{cgethigh}
5+
\subsection*{CGetHigh}
6+
7+
\subsubsection*{Format}
8+
9+
\rvcheriasm{CGetHigh}
10+
11+
\begin{center}
12+
\rvcheriheader
13+
\rvcheribitbox{CGetHigh}
14+
\end{center}
15+
16+
\sailRISCVisarefbody{CGetHigh}

insn-riscv/csethigh.tex

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
\clearpage
2+
\phantomsection
3+
\addcontentsline{toc}{subsection}{CSetHigh}
4+
\insnriscvlabel{csethigh}
5+
\subsection*{CSetHigh}
6+
7+
\subsubsection*{Format}
8+
9+
\rvcheriasm{CSetHigh}
10+
11+
\begin{center}
12+
\rvcheriheader
13+
\rvcheribitbox{CSetHigh}
14+
\end{center}
15+
16+
\sailRISCVisarefbody{CSetHigh}

sail_latex_riscv/commands.tex

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5233,6 +5233,30 @@ \subsection*{Exceptions}
52335233

52345234
}{\lstinputlisting[language=sail]{sail_latex_riscv/fclCGetOffsetzexecute33a689e3a631b9b905b85461d3814943.tex}}}}
52355235

5236+
\newcommand{\sailRISCVfclCGetHighexecute}{\saildoclabelled{sailRISCVfclCGetHighzexecute}{\saildocfcl{Integer register \emph{rd} is set equal to the \textbf{high half} of capability
5237+
register \emph{cs1}.
5238+
5239+
The bits returned here are of the \textbf{in-memory} form of the capability, which
5240+
may differ from microarchitectural forms in use within implementations.
5241+
(Notably, in the sail implementation, see the distinction between \hyperref[sailRISCVzcapToBits]{\lstinline{capToBits}}
5242+
and \hyperref[sailRISCVzcapToMemBits]{\lstinline{capToMemBits}}.) That is, applying \hyperref[sailRISCVzCGetHigh]{\lstinline{CGetHigh}} to a capability loaded
5243+
from address \emph{m} will yield the same result as loading the high half of the
5244+
capability-sized granule at \emph{m} (that is, bits above \textbf{XLEN} when a
5245+
capability is interpreted as a twice-\textbf{XLEN}-bit integer).
5246+
5247+
}{\lstinputlisting[language=sail]{sail_latex_riscv/fclCGetHighzexecute33a689e3a631b9b905b85461d3814943.tex}}}}
5248+
5249+
\newcommand{\sailRISCVfclCSetHighexecute}{\saildoclabelled{sailRISCVfclCSetHighzexecute}{\saildocfcl{Capability register \emph{cd} comes to hold the capability from \emph{cs1} with its
5250+
high bits replaced with the value in the integer register \emph{rs2}. The tag
5251+
of \emph{cd} is cleared.
5252+
5253+
\emph{rs2} holds the \textbf{in-memory} form of capability bits. That is, this
5254+
instruction yields the same result as writing \emph{cs1} out to memory,
5255+
overwriting the high word with \emph{rs2}, and loading that capability-sized
5256+
granule into \emph{cd}, although without the memory mutation side-effects.
5257+
5258+
}{\lstinputlisting[language=sail]{sail_latex_riscv/fclCSetHighzexecute33a689e3a631b9b905b85461d3814943.tex}}}}
5259+
52365260
\newcommand{\sailRISCVfclCGetLenexecute}{\saildoclabelled{sailRISCVfclCGetLenzexecute}{\saildocfcl{Integer register \emph{rd} is set equal to the \textbf{length} field of capability
52375261
register \emph{cs1}.
52385262

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let capVal : Capability = #\hyperref[sailRISCVzC]{C}#(cs1);
2+
#\hyperref[sailRISCVzX]{X}#(rd) = #\hyperref[sailRISCVzcapToMemBits]{capToMemBits}#(capVal)[sizeof(xlen) * 2 - 1 .. sizeof(xlen)];
3+
RETIRE_SUCCESS
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
let capVal = #\hyperref[sailRISCVzC]{C}#(cs1);
2+
let intVal = #\hyperref[sailRISCVzX]{X}#(rs2);
3+
let capLow : xlenbits = #\hyperref[sailRISCVzcapToMemBits]{capToMemBits}#(capVal)[sizeof(xlen) - 1 .. 0];
4+
let newCap : Capability = #\hyperref[sailRISCVzmemBitsToCapability]{memBitsToCapability}#(false, intVal @ capLow);
5+
#\hyperref[sailRISCVzC]{C}#(cd) = newCap;
6+
RETIRE_SUCCESS

sail_latex_riscv/fnzstepb001f84c8bf78b78b44b98d2b7f1f7d7.tex

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
},
2828
/* non-error cases: */
2929
#\hyperref[sailRISCVzFzyRVC]{F\_RVC}#(h) => {
30+
instbits = #\hyperref[sailRISCVzEXTZ]{EXTZ}#(h);
3031
let ast = #\hyperref[sailRISCVzdecodeCompressed]{decodeCompressed}#(h);
3132
if #\hyperref[sailRISCVzgetzyconfigzyprintzyinstr]{get\_config\_print\_instr}#()
3233
then {
@@ -42,6 +43,7 @@
4243
}
4344
},
4445
#\hyperref[sailRISCVzFzyBase]{F\_Base}#(w) => {
46+
instbits = #\hyperref[sailRISCVzEXTZ]{EXTZ}#(w);
4547
let ast = #\hyperref[sailRISCVzdecode]{decode}#(w);
4648
if #\hyperref[sailRISCVzgetzyconfigzyprintzyinstr]{get\_config\_print\_instr}#()
4749
then {

0 commit comments

Comments
 (0)