defs.tex 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. \newcommand{\itm}[1]{\ensuremath{\mathit{#1}}}
  3. \newcommand{\ttm}[1]{\ensuremath{\text{\texttt{#1}}}}
  4. \newcommand{\sfm}[1]{\ensuremath{\mathsf{#1}}}
  5. \newcommand{\Lang}{\mathcal{L}}
  6. \newcommand{\CLang}{\mathcal{C}}
  7. \newcommand{\LangInt}{\ensuremath{\Lang_{\mathsf{Int}}}} % R0
  8. \newcommand{\LangVar}{$\Lang_{\mathsf{Var}}$} % R1
  9. \newcommand{\LangVarM}{\Lang_{\mathsf{Var}}}
  10. \newcommand{\RCO}{\mathit{mon}} % output of remove-complex-opera*
  11. \newcommand{\LangVarANF}{\ensuremath{\Lang^{\RCO}_{\mathsf{Var}}}}
  12. \newcommand{\LangVarANFM}{\Lang^{\RCO}_{\mathsf{Var}}}
  13. \newcommand{\LangIf}{$\Lang_{\mathsf{If}}$} %R2
  14. \newcommand{\LangIfM}{\ensuremath{\Lang_{\mathsf{If}}}} %R2
  15. \newcommand{\LangIfANF}{\ensuremath{\Lang^{\RCO}_{\mathsf{if}}}} %R2
  16. \newcommand{\LangCVar}{$\CLang_{\mathsf{Var}}$} % C0
  17. \newcommand{\LangCVarM}{\CLang_{\mathsf{Var}}} % C0
  18. \newcommand{\LangCIf}{$\CLang_{\mathsf{If}}$} %C1
  19. \newcommand{\LangCIfM}{\ensuremath{\CLang_{\mathsf{If}}}} %C1
  20. \newcommand{\LangVec}{$\Lang_{\mathsf{Tup}}$} %R3
  21. \newcommand{\LangVecM}{\Lang_{\mathsf{Tup}}} %R3
  22. \newcommand{\LangStruct}{\ensuremath{\Lang_{\mathsf{Struct}}}} %\Lang^s3
  23. \newcommand{\LangCVec}{$\CLang_{\mathsf{Tup}}$} %C2
  24. \newcommand{\LangCVecM}{\CLang_{\mathsf{Tup}}} %C2
  25. \newcommand{\LangVecANF}{\ensuremath{\Lang^{\RCO}_{\mathsf{Tup}}}} %R3
  26. \newcommand{\LangVecANFM}{\Lang^{\RCO}_{\mathsf{Tup}}} %R3
  27. \newcommand{\LangAlloc}{\ensuremath{\Lang_{\mathsf{Alloc}}}} %R3'
  28. \newcommand{\LangAllocANF}{\ensuremath{\Lang^{\RCO}_{\mathsf{Alloc}}}} %R3'
  29. \newcommand{\LangAllocANFM}{\Lang^{\RCO}_{\mathsf{Alloc}}} %R3'
  30. \newcommand{\LangFun}{$\Lang_{\mathsf{Fun}}$} %R4
  31. \newcommand{\LangFunM}{\Lang_{\mathsf{Fun}}} %R4
  32. \newcommand{\LangCFun}{$\CLang_{\mathsf{Fun}}$} %C3
  33. \newcommand{\LangCFunM}{\CLang_{\mathsf{Fun}}} %C3
  34. \newcommand{\LangFunANF}{\ensuremath{\Lang^{\RCO}_{\mathsf{FunRef}}}} %R4
  35. \newcommand{\LangFunANFM}{\Lang^{\RCO}_{\mathsf{FunRef}}} %R4
  36. \newcommand{\LangFunRef}{$\Lang_{\mathsf{FunRef}}$} %F1
  37. \newcommand{\LangFunRefM}{\Lang_{\mathsf{FunRef}}} %F1
  38. \newcommand{\LangFunRefAlloc}{\ensuremath{\Lang^{\mathsf{Alloc}}_{\mathsf{FunRef}}}} %R'4
  39. \newcommand{\LangLam}{$\Lang_\lambda$} %R5
  40. \newcommand{\LangLamFunRef}{$\Lang_\lambda^{\mathsf{FunRef}}$}
  41. \newcommand{\LangLamM}{\ensuremath{\Lang_\lambda}} %R5
  42. \newcommand{\LangCLam}{$\CLang_{\mathsf{Clos}}$} %C4
  43. \newcommand{\LangCLamM}{\CLang_{\mathsf{Clos}}} %C4
  44. \newcommand{\LangAny}{$\Lang_{\mathsf{Any}}$} %R6
  45. \newcommand{\LangAnyM}{\Lang_{\mathsf{Any}}} %R6
  46. \newcommand{\LangAnyFunRef}{\ensuremath{\Lang^{\mathsf{FunRef}}_{\mathsf{Any}}}} %R'6
  47. \newcommand{\LangAnyAlloc}{\ensuremath{\Lang^{\mathsf{Alloc}}_{\mathsf{Any}}}} %R'6
  48. \newcommand{\LangCAny}{$\CLang_{\mathsf{Any}}$} %C5
  49. \newcommand{\LangCAnyM}{\CLang_{\mathsf{Any}}} %C5
  50. \newcommand{\LangDyn}{$\Lang_{\mathsf{Dyn}}$} %R7
  51. \newcommand{\LangDynM}{\Lang_{\mathsf{Dyn}}} %R7
  52. \newcommand{\LangDynFunRef}{\ensuremath{\Lang^{\mathsf{FunRef}}_{\mathsf{Dyn}}}} %R'7
  53. \newcommand{\LangLoop}{$\Lang_{\mathsf{While}}$} %R8
  54. \newcommand{\LangLoopM}{\Lang_{\mathsf{While}}} %R8
  55. \newcommand{\LangLoopFunRef}{\ensuremath{\Lang^{\mathsf{FunRef}}_{\mathsf{While}}}} %R'8
  56. \newcommand{\LangLoopAlloc}{\ensuremath{\Lang^{\mathsf{Alloc}}_{\mathsf{While}}}} %R'8
  57. \newcommand{\LangCLoop}{$\CLang_{\circlearrowleft}$} %C7
  58. \newcommand{\LangCLoopM}{\CLang_{\circlearrowleft}} %C7
  59. \newcommand{\LangLoopANF}{\ensuremath{\Lang^{\RCO}_{\mathsf{While}}}} %R8
  60. \newcommand{\LangArray}{\ensuremath{\Lang_{\mathsf{Array}}}} %\Lang^s3
  61. \newcommand{\LangArrayM}{\Lang_{\mathsf{Array}}} %\Lang^s3
  62. \newcommand{\LangGrad}{$\Lang_{\mathsf{?}}$} %R9
  63. \newcommand{\LangGradM}{\Lang_{\mathsf{?}}} %R9
  64. \newcommand{\LangCast}{$\Lang_{\mathsf{Cast}}$} %R9'
  65. \newcommand{\LangCastM}{\Lang_{\mathsf{Cast}}} %R9'
  66. \newcommand{\LangProxy}{\ensuremath{\Lang_{\mathsf{Proxy}}}} %R8''
  67. \newcommand{\LangPVec}{\ensuremath{\Lang_{\mathsf{POr}}}} %R8''
  68. \newcommand{\LangPVecFunRef}{\ensuremath{\Lang^{\mathsf{FunRef}}_{\mathsf{POr}}}} %R8''
  69. \newcommand{\LangPVecAlloc}{\ensuremath{\Lang^{\mathsf{Alloc}}_{\mathsf{POr}}}} %R8''
  70. \newcommand{\LangPoly}{\ensuremath{\Lang_{\mathsf{Gen}}}} %R10
  71. \newcommand{\LangInst}{\ensuremath{\Lang_{\mathsf{Inst}}}} %R'10
  72. \newcommand{\LangCLoopPVec}{\ensuremath{\CLang^{\mathsf{POr}}_{\circlearrowleft}}} %Cp7
  73. \newcommand{\LangXVar}{$\mathrm{x86}_{\mathsf{Var}}$} % pseudo x86_0
  74. \newcommand{\LangXASTInt}{\ensuremath{\mathrm{x86}_{\mathsf{Int}}}} % x86_0
  75. \newcommand{\LangXInt}{$\mathrm{x86}_{\mathsf{Int}}$} %x86^{\dagger}_0
  76. \newcommand{\LangXIntM}{\mathrm{x86}_{\mathsf{Int}}} %x86^{\dagger}_0
  77. \newcommand{\LangXASTIf}{\ensuremath{\mathrm{x86}_{\mathsf{If}}}} %x86_1
  78. \newcommand{\LangXIf}{$\mathrm{x86}_{\mathsf{If}}$} %x86^{\dagger}_1
  79. \newcommand{\LangXIfM}{\mathrm{x86}_{\mathsf{If}}} %x86^{\dagger}_1
  80. \newcommand{\LangXIfVar}{\ensuremath{\mathrm{x86}^{\mathsf{Var}}_{\mathsf{If}}}} %x86^{*}_1
  81. \newcommand{\LangXASTGlobal}{\ensuremath{\mathrm{x86}_{\mathsf{Global}}}} %x86_2
  82. \newcommand{\LangXGlobal}{$\mathrm{x86}_{\mathsf{Global}}$} %x86^{\dagger}_2
  83. \newcommand{\LangXGlobalM}{\mathrm{x86}_{\mathsf{Global}}} %x86^{\dagger}_2
  84. \newcommand{\LangXGlobalVar}{\ensuremath{\mathrm{x86}^{\mathsf{Var}}_{\mathsf{Global}}}} %x86^{*}_2
  85. \newcommand{\LangXIndCall}{$\mathrm{x86}^{\mathsf{Def}}_{\mathsf{callq*}}$} %x86_3
  86. \newcommand{\LangXIndCallM}{\mathrm{x86}^{\mathsf{Def}}_{\mathsf{callq*}}} %x86_3
  87. \newcommand{\LangXIndCallFlat}{$\mathrm{x86}_{\mathsf{callq*}}$} %x86_3
  88. \newcommand{\LangXIndCallFlatM}{\mathrm{x86}_{\mathsf{callq*}}} %x86_3
  89. \newcommand{\LangXIndCallVar}{\ensuremath{\mathrm{x86}^{\mathsf{Var},\mathsf{Def}}_{\mathsf{callq*}}}} %x86^*_3
  90. \newcommand{\Stmt}{\itm{stmt}}
  91. \newcommand{\Exp}{\itm{exp}}
  92. \newcommand{\Def}{\itm{def}}
  93. \newcommand{\Type}{\itm{type}}
  94. \newcommand{\FType}{\itm{ftype}}
  95. \newcommand{\Instr}{\itm{instr}}
  96. \newcommand{\Block}{\itm{block}}
  97. \newcommand{\Blocks}{\itm{blocks}}
  98. \newcommand{\Param}{\itm{prm}}
  99. \newcommand{\Params}{\itm{params}}
  100. \newcommand{\Tail}{\itm{tail}}
  101. \newcommand{\Prog}{\itm{prog}}
  102. \newcommand{\Arg}{\itm{arg}}
  103. \newcommand{\Atm}{\itm{atm}}
  104. \newcommand{\Reg}{\itm{reg}}
  105. \newcommand{\Int}{\itm{int}}
  106. \newcommand{\Var}{\itm{var}}
  107. \newcommand{\Op}{\itm{op}}
  108. \newcommand{\key}[1]{\texttt{#1}}
  109. \newcommand{\skey}[1]{\texttt{\textquotesingle #1\textquotesingle}}
  110. \newcommand{\code}[1]{\texttt{#1}}
  111. \newcommand{\scode}[1]{\texttt{\textquotesingle #1\textquotesingle}}
  112. \newcommand{\LP}{\key{(}}
  113. \newcommand{\RP}{\key{)}}
  114. \newcommand{\LS}{\key{[}}
  115. \newcommand{\RS}{\key{]}}
  116. \newcommand{\LC}{\key{\{}}
  117. \newcommand{\RC}{\key{\}}}
  118. \newcommand{\MID}{\;\mid\;}
  119. \if\edition\racketEd
  120. \newcommand{\QUOTE}[1]{\code{\textquotesingle}#1}
  121. \newcommand{\INT}[1]{{\key{(Int}~#1\key{)}}}
  122. \newcommand{\READOP}{{\key{read}}}
  123. \newcommand{\READ}{{\key{(Prim}~\code{\textquotesingle read}~\key{())}}}
  124. \newcommand{\CREAD}{\key{(read)}}
  125. \newcommand{\NEG}[1]{{\key{(Prim}~\code{\textquotesingle -}~\code{(}#1\code{))}}}
  126. \newcommand{\ADD}[2]{{\key{(Prim}~\code{\textquotesingle +}~\code{(}#1~#2\code{))}}}
  127. \newcommand{\ADDP}[2]{{\key{(Prim}~\code{\textquotesingle +}~\code{(list}~#1~#2\code{))}}}
  128. \newcommand{\SUB}[2]{\key{(Prim}~\code{\textquotesingle -}~\code{(}#1~#2\code{))}}
  129. \newcommand{\PROGRAM}[2]{\LP\code{Program}~#1~#2\RP}
  130. \newcommand{\VAR}[1]{\key{(Var}~#1\key{)}}
  131. \newcommand{\BOOL}[1]{\key{(Bool}~#1\key{)}}
  132. \newcommand{\TRUE}{\key{\#t}}
  133. \newcommand{\FALSE}{\key{\#f}}
  134. \newcommand{\UNIOP}[2]{\key{(Prim}~#1~\code{(}#2\code{))}}
  135. \newcommand{\CUNIOP}[2]{\LP #1~#2 \RP}
  136. \newcommand{\BINOP}[3]{\key{(Prim}~#1~\code{(}#2~#3\code{))}}
  137. \newcommand{\CBINOP}[3]{\LP #1~#2~#3\RP}
  138. \newcommand{\EQNAME}{\key{eq?}}
  139. \newcommand{\CEQ}[2]{\LP\key{eq?}~#1~#2\RP}
  140. \newcommand{\IFNAME}{\key{If}}
  141. \newcommand{\IF}[3]{\key{(If}\,#1~#2~#3\key{)}}
  142. \newcommand{\CIF}[3]{\LP\key{if}~#1~#2~#3\RP}
  143. \newcommand{\ANDNAME}{\key{and}}
  144. \newcommand{\ORNAME}{\key{or}}
  145. \newcommand{\NOTNAME}{\key{not}}
  146. \newcommand{\AND}[2]{\key{(Prim}~\code{\textquotesingle and}~\code{(}#1~#2\code{))}}
  147. \newcommand{\OR}[2]{\key{(Prim}~\code{\textquotesingle or}~\code{(}#1~#2\code{))}}
  148. \newcommand{\CAND}[2]{\CBINOP{\key{and}}{#1}{#2}}
  149. \newcommand{\COR}[2]{\CBINOP{\key{or}}{#1}{#2}}
  150. \newcommand{\INTTY}{{\key{Integer}}}
  151. \newcommand{\INTTYPE}{{\key{Integer}}}
  152. \newcommand{\BOOLTY}{{\key{Boolean}}}
  153. \newcommand{\TUPLETYPENAME}{\key{Vector}}
  154. \newcommand{\ARRAYTYPENAME}{\key{Vectorof}}
  155. \newcommand{\VECTY}[1]{\LP\key{Vector}~#1\RP}
  156. \newcommand{\ARRAYTY}[1]{\LP\key{Vectorof}~#1\RP}
  157. \newcommand{\CARRAYTY}[1]{\LP\key{Vectorof}~#1\RP}
  158. \newcommand{\ANYTY}{\key{Any}}
  159. \newcommand{\CANYTY}{\key{Any}}
  160. \newcommand{\PTUPLETYNAME}{\key{PVector}}
  161. \newcommand{\PARRAYTYNAME}{\key{PVectorof}}
  162. \newcommand{\PTUPLETY}[1]{\LP\key{PVector}~#1\RP}
  163. \newcommand{\CPTUPLETY}[1]{\LP\key{PVector}~#1\RP}
  164. \newcommand{\CPROGRAM}[2]{\LP\code{CProgram}~#1~#2\RP}
  165. \newcommand{\CPROGRAMDEFS}[2]{\LP\code{CProgramDefs}~#1~#2\RP}
  166. \newcommand{\LET}[3]{\key{(Let}~#1~#2~#3\key{)}}
  167. \newcommand{\CLET}[3]{\LP\key{let}~\LP\LS#1~#2\RS\RP~#3\RP}
  168. \newcommand{\COLLECT}[1]{\LP\key{Collect}~#1\RP}
  169. \newcommand{\CCOLLECT}[1]{\LP\key{collect}~#1\RP}
  170. \newcommand{\ALLOCATE}[2]{\LP\key{Allocate}~#1~#2\RP}
  171. \newcommand{\CALLOCATE}[2]{\LP\key{allocate}~#1~#2\RP}
  172. \newcommand{\ALLOCARRAY}[2]{\LP\key{AllocateArray}~#1~#2\RP}
  173. \newcommand{\CALLOCARRAY}[2]{\LP\key{allocate\_array}~#1~#2\RP}
  174. \newcommand{\GLOBAL}[1]{\LP\key{Global}~#1\RP}
  175. \newcommand{\CGLOBAL}[1]{#1\key{(\%rip)}}
  176. \newcommand{\GLOBALVALUE}[1]{\LP\key{GlobalValue}~#1\RP}
  177. \newcommand{\CGLOBALVALUE}[1]{\LP\key{global-value}~#1\RP}
  178. \newcommand{\ARITY}[1]{\LP\key{Prim}~\code{\textquotesingle procedure-arity}~\LP#1\RP\RP}
  179. \newcommand{\CARITY}[1]{\LP\key{procedure-arity}~#1\RP}
  180. \fi
  181. \if\edition\pythonEd
  182. %% Use BEGIN instead of LET -Jeremy
  183. %% \newcommand{\LET}[3]{\key{Let}\LP #1 \key{,} #2 \key{,} #3 \RP}
  184. %% \newcommand{\CLET}[3]{\key{let}~#1~\key{=}~#2~\key{in}~#3}
  185. \newcommand{\PTUPLETYNAME}{\key{ProxyOrTupleType}}
  186. \newcommand{\PARRAYTYNAME}{\key{ProxyOrListType}}
  187. \newcommand{\PTUPLETY}[1]{\key{ProxyOrTupleType}\LP#1\RP}
  188. \newcommand{\CPTUPLETY}[1]{\key{ProxyOrTupleType}\LP#1\RP}
  189. \newcommand{\PARRAYTY}[1]{\key{ProxyOrListType}\LP#1\RP}
  190. \newcommand{\CPARRAYTY}[1]{\key{ProxyOrListType}\LP#1\RP}
  191. \newcommand{\QUOTE}[1]{\code{\textquotesingle}#1\code{\textquotesingle}}
  192. \newcommand{\INT}[1]{{\key{Constant}\LP#1\RP}}
  193. \newcommand{\READOP}{{\key{input\_int}}}
  194. \newcommand{\READ}{{\key{Call(Name(\textquotesingle input\_int\textquotesingle),[])}}}
  195. \newcommand{\CREAD}{\key{input\_int()}}
  196. \newcommand{\NEG}[1]{{\key{UnaryOp(USub(),} #1\code{)}}}
  197. \newcommand{\ADD}[2]{{\key{BinOp}\LP #1\code{,}\key{Add()}\key{,}#2\code{)}}}
  198. \newcommand{\ADDP}[2]{{\key{BinOp}\LP #1\code{,}\key{Add()}\key{,}#2\code{)}}}
  199. \newcommand{\SUB}[2]{{\key{BinOp}\LP #1\code{,}\key{Sub()}\key{,}#2\code{)}}}
  200. \newcommand{\PRINT}[1]{{\key{Expr}\LP\key{Call}\LP\key{Name}\LP\key{\textquotesingle print\textquotesingle}\RP\key{,}\LS#1\RS\RP\RP}}
  201. \newcommand{\CPRINT}[1]{\key{print}\LP #1\RP}
  202. \newcommand{\EXPR}[1]{{\key{Expr}\LP #1\RP}}
  203. \newcommand{\PROGRAM}[2]{\code{Module}\LP #2\RP}
  204. \newcommand{\CPROGRAM}[2]{\code{CProgram}\LP #2 \RP}
  205. \newcommand{\CPROGRAMDEFS}[1]{\code{CProgramDefs}\LP #1 \RP}
  206. \newcommand{\VAR}[1]{\key{Name}\LP #1\RP}
  207. \newcommand{\BOOL}[1]{\key{Constant}\LP #1 \RP}
  208. \newcommand{\UNIOP}[2]{\key{UnaryOp}\LP #1 \code{,} #2 \RP}
  209. \newcommand{\CUNIOP}[2]{#1~#2}
  210. \newcommand{\BINOP}[3]{\key{BinOp}\LP #1 \code{,} #2 \code{,} #3 \RP}
  211. \newcommand{\CBINOP}[3]{#2~#1~#3}
  212. \newcommand{\EQNAME}{\key{Eq}}
  213. \newcommand{\NOTEQNAME}{\key{NotEq}}
  214. \newcommand{\CEQ}[2]{#1~\code{==}~#2}
  215. \newcommand{\CIS}[2]{#1~\code{is}~#2}
  216. \newcommand{\CGET}[2]{#1 \LS #2 \RS}
  217. \newcommand{\GET}[2]{\key{Subscript}\LP #1 \code{,} #2 \code{,} \code{Load()} \RP}
  218. \newcommand{\CLEN}[1]{\code{len}\LP #1 \RP}
  219. \newcommand{\LEN}[1]{\code{Call}\LP \code{Name(\textquotesingle len\textquotesingle)} \code{,} \LS #1 \RS \RP}
  220. \newcommand{\PUT}[2]{\key{Subscript}\LP #1 \code{,} #2 \code{,} \code{Store()} \RP}
  221. \newcommand{\CPUT}[2]{#1[#2]}
  222. \newcommand{\TUPLE}[1]{\key{Tuple}\LP #1 \code{,} \code{Load()} \RP}
  223. \newcommand{\BOOLOP}[3]{\key{BoolOp}\LP #1 \code{,} \LS #2 \code{,} #3 \RS \RP}
  224. \newcommand{\CMP}[3]{\key{Compare}\LP #1\code{,}\LS #2 \RS \code{,} \LS #3 \RS\RP}
  225. \newcommand{\CCMP}[3]{#2~#1~#3}
  226. \newcommand{\TRUE}{\key{True}}
  227. \newcommand{\FALSE}{\key{False}}
  228. \newcommand{\IFNAME}{\key{IfExp}}
  229. \newcommand{\IF}[3]{\key{IfExp}\LP #1 \code{,} #2 \code{,} #3 \RP}
  230. \newcommand{\CIF}[3]{#2~\key{if}~#1~\key{else}~#3}
  231. \newcommand{\ANDNAME}{\key{and}}
  232. \newcommand{\ORNAME}{\key{or}}
  233. \newcommand{\NOTNAME}{\key{not}}
  234. \newcommand{\AND}[2]{\BOOLOP{\key{And()}}{#1}{#2}}
  235. \newcommand{\CAND}[2]{#1~\key{and}~#2}
  236. \newcommand{\OR}[2]{\BOOLOP{\key{Or()}}{#1}{#2}}
  237. \newcommand{\COR}[2]{#1~\key{or}~#2}
  238. \newcommand{\INTTY}{{\key{int}}}
  239. \newcommand{\BOOLTY}{{\key{bool}}}
  240. \newcommand{\ANYTY}{{\key{AnyType}}}
  241. \newcommand{\CANYTY}{{\key{Any}}}
  242. \newcommand{\TUPLETYPENAME}{\key{TupleType}}
  243. \newcommand{\ARRAYTYPENAME}{\key{ListType}}
  244. \newcommand{\VECTY}[1]{{\key{TupleType}\LP\LS #1 \RS\RP}}
  245. \newcommand{\ARRAYTY}[1]{\key{ListType}\LP#1\RP}
  246. \newcommand{\CARRAYTY}[1]{\key{list}\LS#1\RS}
  247. \newcommand{\INTTYPE}{{\key{IntType}}}
  248. \newcommand{\COLLECT}[1]{\key{Collect}\LP#1\RP}
  249. \newcommand{\CCOLLECT}[1]{\key{collect}\LP#1\RP}
  250. \newcommand{\ALLOCATE}[2]{\key{Allocate}\LP#1,#2\RP}
  251. \newcommand{\CALLOCATE}[2]{\key{allocate}\LP#1,#2\RP}
  252. \newcommand{\ALLOCARRAY}[2]{\key{AllocateArray}\LP#1\code{, }#2\RP}
  253. \newcommand{\CALLOCARRAY}[2]{\key{allocate\_arrray}\LP#1,#2\RP}
  254. \newcommand{\GLOBALVALUE}[1]{\key{GlobalValue}\LP#1\RP}
  255. \newcommand{\CGLOBALVALUE}[1]{\key{global\_value}\LP#1\RP}
  256. \newcommand{\GLOBAL}[1]{\key{Global}\LP#1\RP}
  257. \newcommand{\CGLOBAL}[1]{#1\LP\key{\%rip}\RP}
  258. \newcommand{\CNEG}[1]{\key{-}~#1}
  259. \newcommand{\CNOT}[1]{\key{not}~#1}
  260. \newcommand{\CALL}[2]{\key{Call}\LP#1\code{, }#2\RP}
  261. \newcommand{\APPLY}[2]{\key{Call}\LP#1\code{, }#2\RP}
  262. \newcommand{\CAPPLY}[2]{#1\LP#2\RP}
  263. \newcommand{\FUNREF}[2]{\key{FunRef}\LP#1\code{, }#2\RP}
  264. \newcommand{\CFUNREF}[2]{#1\code{(\%rip)}}
  265. \newcommand{\CLOSURE}[2]{\key{Closure}\LP#1\code{, }#2\RP}
  266. \newcommand{\ARITY}[1]{\key{Call}\LP\key{Name}\LP\code{\textquotesingle arity\textquotesingle}\RP \code{, }\LS#1\RS\RP}
  267. \newcommand{\CARITY}[1]{\key{arity}\LP#1\RP}
  268. \newcommand{\CMUL}[2]{#1~\key{*}~#2}
  269. \newcommand{\MUL}[2]{{\key{BinOp}\LP #1\code{,} \key{Mult()}\key{,}#2\code{)}}}
  270. \fi % pythonEd
  271. \if\edition\racketEd
  272. \newcommand{\BEGIN}[2]{\LP\key{Begin}~#1~#2\RP}
  273. \newcommand{\CBEGIN}[2]{\LP\key{begin}~#1~#2\RP}
  274. \newcommand{\CNEG}[1]{\LP\key{-}~#1\RP}
  275. \newcommand{\CNOT}[1]{\LP\key{not}~#1\RP}
  276. \newcommand{\CALL}[2]{\LP\key{Call}~#1~#2\RP}
  277. \newcommand{\APPLY}[2]{\LP\key{Apply}~#1~#2\RP}
  278. \newcommand{\CAPPLY}[2]{\LP#1~#2\RP}
  279. \newcommand{\FUNREF}[2]{\LP\key{FunRef}~#1~#2\RP}
  280. \newcommand{\CFUNREF}[2]{\LP\key{fun-ref}~#1~#2\RP}
  281. \newcommand{\CLOSURE}[2]{\LP\key{Closure}~#1~#2\RP}
  282. \newcommand{\CMUL}[2]{\LP\key{*}~#1~#2\RP}
  283. \newcommand{\MUL}[2]{{\key{(Prim}~\code{\textquotesingle *}~\code{(}#1~#2\code{))}}}
  284. \fi
  285. \newcommand{\PRIM}[2]{\LP\key{Prim}~#1~\LP #2\RP\RP}
  286. \newcommand{\PROGRAMDEFSEXP}[3]{\code{(ProgramDefsExp}~#1~#2~#3\code{)}}
  287. \newcommand{\PROGRAMDEFS}[2]{\code{(ProgramDefs}~#1~#2\code{)}}
  288. \newcommand{\CADD}[2]{\LP\key{+}~#1~#2\RP}
  289. \newcommand{\CSUB}[2]{\LP\key{-}~#1~#2\RP}
  290. \newcommand{\CWHILE}[2]{\LP\key{while}~#1~#2\RP}
  291. \newcommand{\WHILE}[2]{\LP\key{WhileLoop}~#1~#2\RP}
  292. \newcommand{\CMAKEVEC}[2]{\LP\key{make-vector}~#1~#2\RP}
  293. \newcommand{\MAKEVEC}[2]{\LP\key{make-vector}~#1~#2\RP}
  294. \newcommand{\CSETBANG}[2]{\LP\key{set!}~#1~#2\RP}
  295. \newcommand{\SETBANG}[2]{\LP\key{SetBang}~#1~#2\RP}
  296. \newcommand{\GETBANG}[1]{\LP\key{GetBang}~#1\RP}
  297. \newcommand{\NOT}[1]{\key{(Prim}~\code{not}~\code{(}#1~\code{))}}
  298. \newcommand{\CAST}[3]{\LP\key{Cast}~#1~#2~#3\RP}
  299. \newcommand{\VECTOR}[1]{\LP\key{Prim}~\code{vector}~\LP~#1\RP\RP}
  300. \newcommand{\VECREF}[2]{\LP\key{Prim}~\code{vector-ref}~\LP #1~#2\RP\RP}
  301. \newcommand{\VECSET}[3]{\LP\key{Prim}~\code{vector-set!}~\LP #1~#2~#3\RP\RP}
  302. \newcommand{\VECLEN}[1]{\LP\key{Prim}~\code{vector-length}~\LP #1\RP\RP}
  303. \newcommand{\ANYVECREF}[2]{\LP\key{Prim}~\code{any-vector-ref}~\LP #1~#2\RP\RP}
  304. \newcommand{\ANYVECSET}[3]{\LP\key{Prim}~\code{any-vector-set!}~\LP #1~#2~#3\RP\RP}
  305. \newcommand{\ANYVECLEN}[1]{\LP\key{Prim}~\code{any-vector-length}~\LP #1\RP\RP}
  306. \newcommand{\VOID}{\key{(Void)}}
  307. \newcommand{\VALUEOF}[2]{\LP\key{ValueOf}~#1~#2\RP}
  308. \if\edition\racketEd
  309. \newcommand{\CGLAMBDA}[3]{\LP\key{lambda:}\,#1\,#2~\Exp\RP}
  310. \newcommand{\ALLOC}[2]{\LP\key{Allocate}~#1~#2\RP}
  311. \newcommand{\ALLOCCLOS}[3]{\LP\key{AllocateClosure}~#1~#2~#3\RP}
  312. \newcommand{\INJECT}[2]{\LP\key{Inject}~#1~#2\RP}
  313. \newcommand{\PROJECT}[2]{\LP\key{Project}~#1~#2\RP}
  314. \newcommand{\CINJECT}[2]{\LP\key{inject}~#1~#2\RP}
  315. \newcommand{\CPROJECT}[2]{\LP\key{project}~#1~#2\RP}
  316. \newcommand{\LAMBDA}[3]{\key{(Lambda}~#1~#2~#3\code{)}}
  317. \newcommand{\CLAMBDA}[3]{\LP\key{lambda:}\,#1\,\key{:}\,#2~\Exp\RP}
  318. \newcommand{\TAILCALL}[2]{\key{(TailCall}~#1~#2\code{)}}
  319. \newcommand{\CASSIGN}[2]{#1~\key{=}~#2\key{;}}
  320. \newcommand{\ASSIGN}[2]{\key{(Assign}~#1~#2\key{)}}
  321. \newcommand{\IFSTMTNAME}{\key{IfStmt}}
  322. \newcommand{\IFSTMT}[3]{\key{(IfStmt}\,#1~#2~#3\key{)}}
  323. \newcommand{\RETURN}[1]{\key{(Return}~#1\key{)}}
  324. \newcommand{\CRETURN}[1]{\key{return}~#1\key{;}}
  325. \newcommand{\GOTO}[1]{\key{(Goto}~#1\key{)}}
  326. \newcommand{\CGOTO}[1]{\key{goto}~#1\key{;}}
  327. \newcommand{\FUNDEF}[5]{\key{(Def}~#1~#2~#3~#4~#5\code{)}}
  328. \fi
  329. \if\edition\pythonEd
  330. \newcommand{\CGLAMBDA}[3]{\key{lambda}\,#1\,#2\code{:}~\Exp}
  331. \newcommand{\ALLOC}[2]{\key{Allocate}\LP#1\code{, }#2\RP}
  332. \newcommand{\ALLOCCLOS}[3]{\key{AllocateClosure}\LP#1\code{, }#2\code{, }#3\RP}
  333. \newcommand{\INJECT}[2]{\key{Inject}\LP#1\key{, }#2\RP}
  334. \newcommand{\PROJECT}[2]{\key{Project}\LP#1\key{, }#2\RP}
  335. \newcommand{\CINJECT}[2]{\sfm{inject}\LP#1\key{, }#2\RP}
  336. \newcommand{\CPROJECT}[2]{\sfm{project}\LP#1\key{, }~#2\RP}
  337. \newcommand{\LAMBDA}[2]{\key{Lambda}\LP#1\code{, }#2\RP}
  338. \newcommand{\CLAMBDA}[2]{\key{lambda}\,#1\,\key{:}\,#2}
  339. \newcommand{\TAILCALL}[2]{\key{TailCall}\LP#1\code{, }#2\RP}
  340. \newcommand{\CASSIGN}[2]{#1~\key{=}~#2}
  341. \newcommand{\ASSIGN}[2]{\key{Assign}\LP\LS #1\RS\key{, }#2\RP}
  342. \newcommand{\CANNASSIGN}[3]{#1~\key{:}~#2~\key{=}~#3}
  343. \newcommand{\ANNASSIGN}[3]{\key{AnnAssign}\LP#1\key{, }#2\key{, }#3\key{, 0}\RP}
  344. \newcommand{\IFSTMTNAME}{\key{If}}
  345. \newcommand{\IFSTMT}[3]{\key{If}\LP #1 \code{, } #2 \code{, } #3 \RP}
  346. \newcommand{\CIFSTMT}[3]{\key{if}~#1\code{:}~#2~\code{else:}~#3}
  347. \newcommand{\CBEGIN}[2]{\key{begin:}~#1~#2}
  348. \newcommand{\BEGIN}[2]{\key{Begin}\LP#1\code{, }#2\RP}
  349. \newcommand{\WHILESTMT}[2]{\key{While}\LP #1 \code{, } #2 \code{, []}\RP}
  350. \newcommand{\RETURN}[1]{\key{Return}\LP #1 \RP}
  351. \newcommand{\CRETURN}[1]{\key{return}~#1}
  352. \newcommand{\GOTO}[1]{\key{Goto}\LP #1 \RP}
  353. \newcommand{\CGOTO}[1]{\key{goto}~#1}
  354. \newcommand{\FUNDEF}[5]{\key{FunctionDef}\LP#1\key{, }#2\key{, }#5\key{, None}\key{, }#3\key{, None}\RP}
  355. \fi
  356. \newcommand{\SEQ}[2]{\key{(Seq}~#1~#2\key{)}}
  357. \if\edition\racketEd
  358. \newcommand{\XVAR}[1]{\key{(Var}~#1\key{)}}
  359. \newcommand{\CGDEF}[4]{\LP\key{define}~\LP#1~#2\RP\,#3~#4\RP}
  360. \newcommand{\IMM}[1]{\key{(Imm}~#1\key{)}}
  361. \newcommand{\REG}[1]{\key{(Reg}~#1\key{)}}
  362. \newcommand{\DEREF}[2]{\key{(Deref}~#1~#2\key{)}}
  363. \newcommand{\BININSTR}[3]{\key{(Instr}~#1~\key{(}#2~#3\key{))}}
  364. \newcommand{\UNIINSTR}[2]{\key{(Instr}~#1~\key{(}#2\key{))}}
  365. \newcommand{\CALLQ}[2]{\LP\key{Callq}~#1~#2\RP}
  366. \newcommand{\PUSHQ}[1]{\LP\key{Instr}~\key{pushq}~\LP#1\RP\RP}
  367. \newcommand{\POPQ}[1]{\LP\key{Instr}~\key{popq}~\LP#1\RP\RP}
  368. \newcommand{\JMP}[1]{\key{(Jmp}~#1\key{)}}
  369. \newcommand{\JMPIF}[2]{\key{(JmpIf}~#1~#2\key{)}}
  370. \newcommand{\RETQ}{\key{(Retq)}}
  371. \newcommand{\XPROGRAM}[2]{\LP\code{X86Program}~#1~#2\RP}
  372. \newcommand{\XPROGRAMDEFS}[2]{\LP\code{X86Program}~#1~#2\RP}
  373. \newcommand{\BYTEREG}[1]{\key{(ByteReg}~#1\key{)}}
  374. \newcommand{\CDEF}[4]{\LP\key{define}~\LP#1~#2\RP\,\key{:}\,#3~#4\RP}
  375. \newcommand{\DEF}[5]{\LP\key{Def}~#1~#2~#3~#4~#5\RP}
  376. \newcommand{\INDCALLQ}[2]{\key{(IndirectCallq}~#1~#2\key{)}}
  377. \newcommand{\TAILJMP}[2]{\key{(TailJmp}~#1~#2\key{)}}
  378. \newcommand{\INST}[3]{\LP\key{Inst}~#1~#2~#3\RP}
  379. \fi
  380. \if\edition\pythonEd
  381. \newcommand{\XVAR}[1]{\key{Variable}\LP #1 \RP}
  382. \newcommand{\CGDEF}[4]{\key{def}~#1\LP #2 \RP~#3 \code{:}~#4}
  383. \newcommand{\TAILJMP}[2]{\key{TailJmp}\LP#1\code{, }#2\RP}
  384. \newcommand{\INDCALLQ}[2]{\key{IndirectCallq}\LP#1\code{, }#2\RP}
  385. \newcommand{\IMM}[1]{\key{Immediate}\LP #1\RP}
  386. \newcommand{\REG}[1]{\key{Reg}\LP #1\RP}
  387. \newcommand{\DEREF}[2]{\key{Deref}\LP #1 \key{,} #2 \RP}
  388. \newcommand{\BININSTR}[3]{\key{Instr}\LP #1 \key{,} \LS #2 \key{,} #3 \RS \RP}
  389. \newcommand{\UNIINSTR}[2]{\key{Instr}\LP #1 \key{,} \LS #2 \RS \RP}
  390. \newcommand{\CALLQ}[2]{\key{Callq}\LP #1 \key{,} #2 \RP}
  391. \newcommand{\PUSHQ}[1]{\key{Instr}\LP \skey{pushq} \key{,} \LS #1 \RS \RP}
  392. \newcommand{\POPQ}[1]{\key{Instr}\LP \skey{popq} \key{,} \LS #1 \RS \RP}
  393. \newcommand{\JMP}[1]{\key{Jump}\LP #1 \RP}
  394. \newcommand{\JMPIF}[2]{\key{JumpIf}\LP #1 \key{,} #2 \RP}
  395. \newcommand{\RETQ}{\key{Instr}\LP \skey{retq} \key{,} \LS \RS \RP}
  396. % TODO: change \XPROGRAM to 1 parameter
  397. \newcommand{\XPROGRAM}[2]{\code{X86Program}\LP #2 \RP}
  398. \newcommand{\XPROGRAMDEFS}[1]{\code{X86ProgramDefs}\LP #1 \RP}
  399. \newcommand{\BYTEREG}[1]{\key{ByteReg}\LP #1 \RP}
  400. \newcommand{\CDEF}[4]{\key{def}~#1\LP #2 \RP ~\key{->}~ #3 \key{:}~#4}
  401. \newcommand{\CDEFU}[3]{\key{def}~#1\LP #2 \RP \key{:}~#3}
  402. \newcommand{\DEF}[6]{\key{FunctionDef}\LP#1\key{, }#2\key{, }#3\key{, }#4\key{, }#5\key{, }#6\RP}
  403. \newcommand{\INST}[2]{\key{Inst}\LP#1\key{, }#2\RP}
  404. \fi
  405. \newcommand{\DECL}[2]{\LP\key{Decl}~#1~#2\RP}
  406. \newcommand{\CFG}[1]{\key{(CFG}~#1\key{)}}
  407. \newcommand{\BLOCK}[2]{\key{(Block}~#1~#2\key{)}}
  408. \newcommand{\STACKLOC}[1]{(\key{stack}~#1)}
  409. \newcommand{\TTKEY}[1]{{\normalfont\tt #1}}
  410. \newenvironment{transformation}{
  411. \newcommand{\compilesto}{%
  412. \end{minipage}&$\Rightarrow$&\begin{minipage}{0.4\textwidth}}
  413. \begin{center}\begin{tabular}{lll}\begin{minipage}{0.4\textwidth}
  414. }{%
  415. \end{minipage}\end{tabular}\end{center}%
  416. }