defs.tex 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. \newcommand{\itm}[1]{\ensuremath{\mathit{#1}}}
  3. \newcommand{\ttm}[1]{\ensuremath{\text{\texttt{#1}}}}
  4. \newcommand{\LangInt}{\ensuremath{R_{\mathsf{Int}}}} % R0
  5. \newcommand{\LangVar}{$R_{\mathsf{Var}}$} % R1
  6. \newcommand{\LangVarM}{R_{\mathsf{Var}}}
  7. \newcommand{\LangCVar}{$C_{\mathsf{Var}}$} % C0
  8. \newcommand{\LangCVarM}{C_{\mathsf{Var}}} % C0
  9. \newcommand{\LangVarANF}{\ensuremath{R^{\mathsf{ANF}}_{\mathsf{Var}}}}
  10. \newcommand{\LangVarANFM}{R^{\mathsf{ANF}}_{\mathsf{Var}}}
  11. \newcommand{\LangIf}{$R_{\mathsf{If}}$} %R2
  12. \newcommand{\LangIfM}{\ensuremath{R_{\mathsf{If}}}} %R2
  13. \newcommand{\LangCIf}{$C_{\mathsf{If}}$} %C1
  14. \newcommand{\LangCIfM}{\ensuremath{C_{\mathsf{If}}}} %C1
  15. \newcommand{\LangIfANF}{\ensuremath{R^{\mathsf{ANF}}_{\mathsf{if}}}} %R2
  16. \newcommand{\LangVec}{$R_{\mathsf{Vec}}$} %R3
  17. \newcommand{\LangVecM}{R_{\mathsf{Vec}}} %R3
  18. \newcommand{\LangStruct}{\ensuremath{R^{\mathsf{Struct}}_{\mathsf{Vec}}}} %R^s3
  19. \newcommand{\LangCVec}{$C_{\mathsf{Vec}}$} %C2
  20. \newcommand{\LangCVecM}{C_{\mathsf{Vec}}} %C2
  21. \newcommand{\LangVecANF}{\ensuremath{R^{\mathsf{ANF}}_{\mathsf{Vec}}}} %R3
  22. \newcommand{\LangVecANFM}{R^{\mathsf{ANF}}_{\mathsf{Vec}}} %R3
  23. \newcommand{\LangAlloc}{\ensuremath{R_{\mathsf{Alloc}}}} %R3'
  24. \newcommand{\LangFun}{$R_{\mathsf{Fun}}$} %R4
  25. \newcommand{\LangFunM}{R_{\mathsf{Fun}}} %R4
  26. \newcommand{\LangCFun}{$C_{\mathsf{Fun}}$} %C3
  27. \newcommand{\LangCFunM}{C_{\mathsf{Fun}}} %C3
  28. \newcommand{\LangFunANF}{\ensuremath{R^{\mathsf{ANF}}_{\mathsf{Fun}}}} %R4
  29. \newcommand{\LangFunRef}{$R_{\mathsf{FunRef}}$} %F1
  30. \newcommand{\LangFunRefM}{R_{\mathsf{FunRef}}} %F1
  31. \newcommand{\LangFunRefAlloc}{\ensuremath{R^{\mathsf{Alloc}}_{\mathsf{FunRef}}}} %R'4
  32. \newcommand{\LangLam}{$R_\lambda$} %R5
  33. \newcommand{\LangLamM}{\ensuremath{R_\lambda}} %R5
  34. \newcommand{\LangCLam}{$C_{\mathsf{Clos}}$} %C4
  35. \newcommand{\LangCLamM}{C_{\mathsf{Clos}}} %C4
  36. \newcommand{\LangAny}{$R_{\mathsf{Any}}$} %R6
  37. \newcommand{\LangAnyM}{R_{\mathsf{Any}}} %R6
  38. \newcommand{\LangAnyFunRef}{\ensuremath{R^{\mathsf{FunRef}}_{\mathsf{Any}}}} %R'6
  39. \newcommand{\LangAnyAlloc}{\ensuremath{R^{\mathsf{Alloc}}_{\mathsf{Any}}}} %R'6
  40. \newcommand{\LangCAny}{$C_{\mathsf{Any}}$} %C5
  41. \newcommand{\LangCAnyM}{C_{\mathsf{Any}}} %C5
  42. \newcommand{\LangDyn}{$R_{\mathsf{Dyn}}$} %R7
  43. \newcommand{\LangDynM}{R_{\mathsf{Dyn}}} %R7
  44. \newcommand{\LangDynFunRef}{\ensuremath{R^{\mathsf{FunRef}}_{\mathsf{Dyn}}}} %R'7
  45. \newcommand{\LangLoop}{$R_{\mathsf{While}}$} %R8
  46. \newcommand{\LangLoopM}{R_{\mathsf{While}}} %R8
  47. \newcommand{\LangLoopFunRef}{\ensuremath{R^{\mathsf{FunRef}}_{\mathsf{While}}}} %R'8
  48. \newcommand{\LangLoopAlloc}{\ensuremath{R^{\mathsf{Alloc}}_{\mathsf{While}}}} %R'8
  49. \newcommand{\LangCLoop}{$C_{\circlearrowleft}$} %C7
  50. \newcommand{\LangCLoopM}{C_{\circlearrowleft}} %C7
  51. \newcommand{\LangLoopANF}{\ensuremath{R^{\mathsf{ANF}}_{\mathsf{While}}}} %R8
  52. \newcommand{\LangArray}{\ensuremath{R^{\mathsf{Vecof}}_{\mathsf{While}}}} %R^s3
  53. \newcommand{\LangGrad}{$R_{\mathsf{?}}$} %R9
  54. \newcommand{\LangGradM}{R_{\mathsf{?}}} %R9
  55. \newcommand{\LangCast}{$R_{\mathsf{cast}}$} %R9'
  56. \newcommand{\LangCastM}{R_{\mathsf{cast}}} %R9'
  57. \newcommand{\LangProxy}{\ensuremath{R_{\mathsf{proxy}}}} %R8''
  58. \newcommand{\LangPVec}{\ensuremath{R_{\mathsf{PVec}}}} %R8''
  59. \newcommand{\LangPVecFunRef}{\ensuremath{R^{\mathsf{FunRef}}_{\mathsf{PVec}}}} %R8''
  60. \newcommand{\LangPVecAlloc}{\ensuremath{R^{\mathsf{Alloc}}_{\mathsf{PVec}}}} %R8''
  61. \newcommand{\LangPoly}{\ensuremath{R_{\mathsf{Poly}}}} %R10
  62. \newcommand{\LangInst}{\ensuremath{R_{\mathsf{Inst}}}} %R'10
  63. \newcommand{\LangCLoopPVec}{\ensuremath{C^{\mathsf{PVec}}_{\circlearrowleft}}} %Cp7
  64. \newcommand{\LangXVar}{\ensuremath{\mathrm{x86}_{\mathsf{Var}}}} % pseudo x86_0
  65. \newcommand{\LangXASTInt}{\ensuremath{\mathrm{x86}_{\mathsf{Int}}}} % x86_0
  66. \newcommand{\LangXInt}{$\mathrm{x86}_{\mathsf{Int}}$} %x86^{\dagger}_0
  67. \newcommand{\LangXIntM}{\mathrm{x86}_{\mathsf{Int}}} %x86^{\dagger}_0
  68. \newcommand{\LangXASTIf}{\ensuremath{\mathrm{x86}_{\mathsf{If}}}} %x86_1
  69. \newcommand{\LangXIf}{$\mathrm{x86}_{\mathsf{If}}$} %x86^{\dagger}_1
  70. \newcommand{\LangXIfM}{\mathrm{x86}_{\mathsf{If}}} %x86^{\dagger}_1
  71. \newcommand{\LangXIfVar}{\ensuremath{\mathrm{x86}^{\mathsf{Var}}_{\mathsf{If}}}} %x86^{*}_1
  72. \newcommand{\LangXASTGlobal}{\ensuremath{\mathrm{x86}_{\mathsf{Global}}}} %x86_2
  73. \newcommand{\LangXGlobal}{$\mathrm{x86}_{\mathsf{Global}}$} %x86^{\dagger}_2
  74. \newcommand{\LangXGlobalM}{\mathrm{x86}_{\mathsf{Global}}} %x86^{\dagger}_2
  75. \newcommand{\LangXGlobalVar}{\ensuremath{\mathrm{x86}^{\mathsf{Var}}_{\mathsf{Global}}}} %x86^{*}_2
  76. \newcommand{\LangXIndCall}{$\mathrm{x86}_{\mathsf{callq*}}$} %x86_3
  77. \newcommand{\LangXIndCallM}{\mathrm{x86}_{\mathsf{callq*}}} %x86_3
  78. \newcommand{\LangXIndCallVar}{\ensuremath{\mathrm{x86}^{\mathsf{Var}}_{\mathsf{callq*}}}} %x86^*_3
  79. \newcommand{\Stmt}{\itm{stmt}}
  80. \newcommand{\Exp}{\itm{exp}}
  81. \newcommand{\Def}{\itm{def}}
  82. \newcommand{\Type}{\itm{type}}
  83. \newcommand{\FType}{\itm{ftype}}
  84. \newcommand{\Instr}{\itm{instr}}
  85. \newcommand{\Block}{\itm{block}}
  86. \newcommand{\Tail}{\itm{tail}}
  87. \newcommand{\Prog}{\itm{prog}}
  88. \newcommand{\Arg}{\itm{arg}}
  89. \newcommand{\Atm}{\itm{atm}}
  90. \newcommand{\Reg}{\itm{reg}}
  91. \newcommand{\Int}{\itm{int}}
  92. \newcommand{\Var}{\itm{var}}
  93. \newcommand{\Op}{\itm{op}}
  94. \newcommand{\key}[1]{\texttt{#1}}
  95. \newcommand{\code}[1]{\texttt{#1}}
  96. \newcommand{\LP}[0]{\key{(}}
  97. \newcommand{\RP}[0]{\key{)}}
  98. \newcommand{\LS}[0]{\key{[}}
  99. \newcommand{\RS}[0]{\key{]}}
  100. \newcommand{\INT}[1]{\key{(Int}~#1\key{)}}
  101. \newcommand{\BOOL}[1]{\key{(Bool}~#1\key{)}}
  102. \newcommand{\PRIM}[2]{\LP\key{Prim}~#1~\LP #2\RP\RP}
  103. \newcommand{\READ}{\key{(Prim}~\code{read}~\key{())}}
  104. \newcommand{\CREAD}{\key{(read)}}
  105. \newcommand{\NEG}[1]{\key{(Prim}~\code{-}~\code{(}#1\code{))}}
  106. \newcommand{\CNEG}[1]{\LP\key{-}~#1\RP}
  107. \newcommand{\PROGRAM}[2]{\LP\code{Program}~#1~#2\RP}
  108. \newcommand{\CPROGRAM}[2]{\LP\code{CProgram}~#1~#2\RP}
  109. \newcommand{\XPROGRAM}[2]{\LP\code{X86Program}~#1~#2\RP}
  110. \newcommand{\PROGRAMDEFSEXP}[3]{\code{(ProgramDefsExp}~#1~#2~#3\code{)}}
  111. \newcommand{\PROGRAMDEFS}[2]{\code{(ProgramDefs}~#1~#2\code{)}}
  112. \newcommand{\ADD}[2]{\key{(Prim}~\code{+}~\code{(}#1~#2\code{))}}
  113. \newcommand{\CADD}[2]{\LP\key{+}~#1~#2\RP}
  114. \newcommand{\CMUL}[2]{\LP\key{*}~#1~#2\RP}
  115. \newcommand{\SUB}[2]{\key{(Prim}~\code{-}~\code{(}#1~#2\code{))}}
  116. \newcommand{\CSUB}[2]{\LP\key{-}~#1~#2\RP}
  117. \newcommand{\CWHILE}[2]{\LP\key{while}~#1~#2\RP}
  118. \newcommand{\WHILE}[2]{\LP\key{WhileLoop}~#1~#2\RP}
  119. \newcommand{\CBEGIN}[2]{\LP\key{begin}~#1~#2\RP}
  120. \newcommand{\CMAKEVEC}[2]{\LP\key{make-vector}~#1~#2\RP}
  121. \newcommand{\BEGIN}[2]{\LP\key{Begin}~#1~#2\RP}
  122. \newcommand{\CSETBANG}[2]{\LP\key{set!}~#1~#2\RP}
  123. \newcommand{\SETBANG}[2]{\LP\key{SetBang}~#1~#2\RP}
  124. \newcommand{\AND}[2]{\key{(Prim}~\code{and}~\code{(}#1~#2\code{))}}
  125. \newcommand{\OR}[2]{\key{(Prim}~\code{or}~\code{(}#1~#2\code{))}}
  126. \newcommand{\NOT}[1]{\key{(Prim}~\code{not}~\code{(}#1~\code{))}}
  127. \newcommand{\UNIOP}[2]{\key{(Prim}~#1~\code{(}#2\code{))}}
  128. \newcommand{\CUNIOP}[2]{\LP #1~#2 \RP}
  129. \newcommand{\BINOP}[3]{\key{(Prim}~#1~\code{(}#2~#3\code{))}}
  130. \newcommand{\CBINOP}[3]{\LP #1~#2~#3\RP}
  131. \newcommand{\CLET}[3]{\LP\key{let}~\LP\LS#1~#2\RS\RP~#3\RP}
  132. \newcommand{\CIF}[3]{\LP\key{if}~#1~#2~#3\RP}
  133. \newcommand{\VAR}[1]{\key{(Var}~#1\key{)}}
  134. \newcommand{\LET}[3]{\key{(Let}~#1~#2~#3\key{)}}
  135. \newcommand{\IF}[3]{\key{(If}\,#1~#2~#3\key{)}}
  136. \newcommand{\CAST}[3]{\LP\key{Cast}~#1~#2~#3\RP}
  137. \newcommand{\VECTOR}[1]{\LP\key{Prim}~\code{vector}~\LP~#1\RP\RP}
  138. \newcommand{\VECREF}[2]{\LP\key{Prim}~\code{vector-ref}~\LP~#1~#2\RP\RP}
  139. \newcommand{\VECSET}[3]{\LP\key{Prim}~\code{vector-set!}~\LP~#1~#2~#3\RP\RP}
  140. \newcommand{\VECLEN}[1]{\LP\key{Prim}~\code{vector-length}~\LP~#1\RP\RP}
  141. \newcommand{\ANYVECREF}[2]{\LP\key{Prim}~\code{any-vector-ref}~\LP~#1~#2\RP\RP}
  142. \newcommand{\ANYVECSET}[3]{\LP\key{Prim}~\code{any-vector-set!}~\LP~#1~#2~#3\RP\RP}
  143. \newcommand{\ANYVECLEN}[1]{\LP\key{Prim}~\code{any-vector-length}~\LP~#1\RP\RP}
  144. \newcommand{\CLOSURE}[2]{\LP\key{Closure}~#1~#2\RP}
  145. \newcommand{\ALLOC}[2]{\LP\key{Allocate}~#1~#2\RP}
  146. \newcommand{\ALLOCCLOS}[3]{\LP\key{AllocateClosure}~#1~#2~#3\RP}
  147. \newcommand{\VOID}[1]{\key{(Void)}}
  148. \newcommand{\APPLY}[2]{\key{(Apply}~#1~#2\code{)}}
  149. \newcommand{\CALL}[2]{\key{(Call}~#1~#2\code{)}}
  150. \newcommand{\TAILCALL}[2]{\key{(TailCall}~#1~#2\code{)}}
  151. \newcommand{\FUNDEF}[5]{\key{(Def}~#1~#2~#3~#4~#5\code{)}}
  152. \newcommand{\FUNREF}[1]{\key{(FunRef}~#1\code{)}}
  153. \newcommand{\CFUNREF}[1]{\key{(fun-ref}~#1\code{)}}
  154. \newcommand{\FUNREFARITY}[2]{\key{(FunRefArity}~#1~#2\code{)}}
  155. \newcommand{\CFUNREFARITY}[2]{\key{(fun-ref-arity}~#1~#2\code{)}}
  156. \newcommand{\LAMBDA}[3]{\key{(Lambda}~#1~#2~#3\code{)}}
  157. \newcommand{\CLAMBDA}[3]{\LP\key{lambda:}\,#1\,\key{:}\,#2~\Exp\RP}
  158. \newcommand{\CGLAMBDA}[3]{\LP\key{lambda:}\,#1\,#2~\Exp\RP}
  159. \newcommand{\INJECT}[2]{\LP\key{Inject}~#1~#2\RP}
  160. \newcommand{\PROJECT}[2]{\LP\key{Project}~#1~#2\RP}
  161. \newcommand{\CINJECT}[2]{\LP\key{inject}~#1~#2\RP}
  162. \newcommand{\CPROJECT}[2]{\LP\key{project}~#1~#2\RP}
  163. \newcommand{\VALUEOF}[2]{\LP\key{ValueOf}~#1~#2\RP}
  164. \newcommand{\ASSIGN}[2]{\key{(Assign}~#1~#2\key{)}}
  165. \newcommand{\RETURN}[1]{\key{(Return}~#1\key{)}}
  166. \newcommand{\SEQ}[2]{\key{(Seq}~#1~#2\key{)}}
  167. \newcommand{\GOTO}[1]{\key{(Goto}~#1\key{)}}
  168. \newcommand{\IFSTMT}[3]{\key{(IfStmt}\,#1~#2~#3\key{)}}
  169. \newcommand{\IMM}[1]{\key{(Imm}~#1\key{)}}
  170. \newcommand{\REG}[1]{\key{(Reg}~#1\key{)}}
  171. \newcommand{\BYTEREG}[1]{\key{(ByteReg}~#1\key{)}}
  172. \newcommand{\DEREF}[2]{\key{(Deref}~#1~#2\key{)}}
  173. \newcommand{\DEF}[5]{\LP\key{Def}~#1~#2~#3~#4~#5\RP}
  174. \newcommand{\CDEF}[4]{\LP\key{define}~\LP#1~#2\RP\,\key{:}\,#3~#4\RP}
  175. \newcommand{\CGDEF}[4]{\LP\key{define}~\LP#1~#2\RP\,#3~#4\RP}
  176. \newcommand{\DECL}[2]{\LP\key{Decl}~#1~#2\RP}
  177. \newcommand{\INST}[3]{\LP\key{Inst}~#1~#2~#3\RP}
  178. \newcommand{\CFG}[1]{\key{(CFG}~#1\key{)}}
  179. \newcommand{\BLOCK}[2]{\key{(Block}~#1~#2\key{)}}
  180. \newcommand{\STACKLOC}[1]{(\key{stack}~#1)}
  181. \newcommand{\BININSTR}[3]{\key{(Instr}~#1~\key{(}~#2~#3\key{))}}
  182. \newcommand{\UNIINSTR}[2]{\key{(Instr}~#1~\key{(}~#2\key{))}}
  183. \newcommand{\CALLQ}[2]{\key{(Callq}~#1~#2\key{)}}
  184. \newcommand{\INDCALLQ}[2]{\key{(IndirectCallq}~#1~#2\key{)}}
  185. \newcommand{\RETQ}{\key{(Retq)}}
  186. \newcommand{\PUSHQ}[1]{\key{(Pushq}~#1\key{)}}
  187. \newcommand{\POPQ}[1]{\key{(Popq}~#1\key{)}}
  188. \newcommand{\JMP}[1]{\key{(Jmp}~#1\key{)}}
  189. \newcommand{\TAILJMP}[2]{\key{(TailJmp}~#1~#2\key{)}}
  190. \newcommand{\JMPIF}[2]{\key{(JmpIf}~#1~#2\key{)}}
  191. \newcommand{\TTKEY}[1]{{\normalfont\tt #1}}
  192. \newenvironment{transformation}{
  193. \newcommand{\compilesto}{%
  194. \end{minipage}&$\Rightarrow$&\begin{minipage}{0.4\textwidth}}
  195. \begin{center}\begin{tabular}{lll}\begin{minipage}{0.4\textwidth}
  196. }{%
  197. \end{minipage}\end{tabular}\end{center}%
  198. }