Peter Thiemann 3 anni fa
parent
commit
97813d3040
2 ha cambiato i file con 18 aggiunte e 5 eliminazioni
  1. 16 5
      book.tex
  2. 2 0
      defs.tex

+ 16 - 5
book.tex

@@ -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
 Figure~\ref{fig:x86-int-ast}. We refer to this language as
 \LangXInt{}.
 \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  
 {\if\edition\racketEd  
 The main difference compared to the concrete syntax of \LangXInt{}
 The main difference compared to the concrete syntax of \LangXInt{}
 (Figure~\ref{fig:x86-int-concrete}) is that labels are not allowed in
 (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
 i.e., the number of arguments, which is helpful to know during
 register allocation (Chapter~\ref{ch:register-allocation-Lvar}).
 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]
 \begin{figure}[tp]
 \fbox{
 \fbox{
 \begin{minipage}{0.98\textwidth}
 \begin{minipage}{0.98\textwidth}
@@ -2569,13 +2580,13 @@ register allocation (Chapter~\ref{ch:register-allocation-Lvar}).
 {\if\edition\pythonEd
 {\if\edition\pythonEd
 \[
 \[
 \begin{array}{lcl}
 \begin{array}{lcl}
-\Reg &::=& \allregisters{} \\
+\Reg &::=& \allastregisters{} \\
 \Arg &::=&  \IMM{\Int} \MID \REG{\Reg}
 \Arg &::=&  \IMM{\Int} \MID \REG{\Reg}
    \MID \DEREF{\Reg}{\Int} \\
    \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& \CALLQ{\itm{label}}{\itm{int}} \MID \RETQ{} 
        \MID \PUSHQ{\Arg} \MID \POPQ{\Arg} \MID \JMP{\itm{label}} \\
        \MID \PUSHQ{\Arg} \MID \POPQ{\Arg} \MID \JMP{\itm{label}} \\
 \LangXIntM{} &::= & \XPROGRAM{}{\Instr^{*}}{}
 \LangXIntM{} &::= & \XPROGRAM{}{\Instr^{*}}{}

+ 2 - 0
defs.tex

@@ -107,7 +107,9 @@
 \newcommand{\Var}{\itm{var}}
 \newcommand{\Var}{\itm{var}}
 \newcommand{\Op}{\itm{op}}
 \newcommand{\Op}{\itm{op}}
 \newcommand{\key}[1]{\texttt{#1}}
 \newcommand{\key}[1]{\texttt{#1}}
+\newcommand{\skey}[1]{\texttt{'#1'}}
 \newcommand{\code}[1]{\texttt{#1}}
 \newcommand{\code}[1]{\texttt{#1}}
+\newcommand{\scode}[1]{\texttt{'#1'}}
 
 
 \newcommand{\LP}{\key{(}}
 \newcommand{\LP}{\key{(}}
 \newcommand{\RP}{\key{)}}
 \newcommand{\RP}{\key{)}}