|
@@ -2526,6 +2526,11 @@ programs, so we define an abstract syntax for x86 in
|
|
|
Figure~\ref{fig:x86-int-ast}. We refer to this language as
|
|
|
\LangXInt{}.
|
|
|
%
|
|
|
+{\if\edition\pythonEd%
|
|
|
+ The main difference compared to the concrete syntax of \LangXInt{}
|
|
|
+ (Figure~\ref{fig:x86-int-concrete}) is that labels, instruction
|
|
|
+ names, and register names are explicitly represented by strings.
|
|
|
+\fi} %
|
|
|
{\if\edition\racketEd
|
|
|
The main difference compared to the concrete syntax of \LangXInt{}
|
|
|
(Figure~\ref{fig:x86-int-concrete}) is that labels are not allowed in
|
|
@@ -2545,6 +2550,12 @@ node includes an integer for representing the arity of the function,
|
|
|
i.e., the number of arguments, which is helpful to know during
|
|
|
register allocation (Chapter~\ref{ch:register-allocation-Lvar}).
|
|
|
|
|
|
+\newcommand{\allastregisters}{\skey{rsp} \MID \skey{rbp} \MID \skey{rax} \MID \skey{rbx} \MID \skey{rcx}
|
|
|
+ \MID \skey{rdx} \MID \skey{rsi} \MID \skey{rdi} \MID \\
|
|
|
+ && \skey{r8} \MID \skey{r9} \MID \skey{r10}
|
|
|
+ \MID \skey{r11} \MID \skey{r12} \MID \skey{r13}
|
|
|
+ \MID \skey{r14} \MID \skey{r15}}
|
|
|
+
|
|
|
\begin{figure}[tp]
|
|
|
\fbox{
|
|
|
\begin{minipage}{0.98\textwidth}
|
|
@@ -2569,13 +2580,13 @@ register allocation (Chapter~\ref{ch:register-allocation-Lvar}).
|
|
|
{\if\edition\pythonEd
|
|
|
\[
|
|
|
\begin{array}{lcl}
|
|
|
-\Reg &::=& \allregisters{} \\
|
|
|
+\Reg &::=& \allastregisters{} \\
|
|
|
\Arg &::=& \IMM{\Int} \MID \REG{\Reg}
|
|
|
\MID \DEREF{\Reg}{\Int} \\
|
|
|
-\Instr &::=& \BININSTR{\code{addq}}{\Arg}{\Arg}
|
|
|
- \MID \BININSTR{\code{subq}}{\Arg}{\Arg} \\
|
|
|
- &\MID& \BININSTR{\code{movq}}{\Arg}{\Arg}
|
|
|
- \MID \UNIINSTR{\code{negq}}{\Arg}\\
|
|
|
+\Instr &::=& \BININSTR{\scode{addq}}{\Arg}{\Arg}
|
|
|
+ \MID \BININSTR{\scode{subq}}{\Arg}{\Arg} \\
|
|
|
+ &\MID& \BININSTR{\scode{movq}}{\Arg}{\Arg}
|
|
|
+ \MID \UNIINSTR{\scode{negq}}{\Arg}\\
|
|
|
&\MID& \CALLQ{\itm{label}}{\itm{int}} \MID \RETQ{}
|
|
|
\MID \PUSHQ{\Arg} \MID \POPQ{\Arg} \MID \JMP{\itm{label}} \\
|
|
|
\LangXIntM{} &::= & \XPROGRAM{}{\Instr^{*}}{}
|