X-Git-Url: https://git.xandkar.net/?a=blobdiff_plain;f=compiler%2Fsrc%2Flib%2Ftiger%2Ftiger_mips_frame.ml;h=f373b0e4d51753cd07c312ac4bbf5593dc099611;hb=refs%2Fheads%2Fir-translation-wip;hp=4131702eb9ddeb7617168b7f08c6bd6bc087c49c;hpb=68e4b4a947a95a965381457c2dc80bef05f8f58a;p=tiger.ml.git diff --git a/compiler/src/lib/tiger/tiger_mips_frame.ml b/compiler/src/lib/tiger/tiger_mips_frame.ml index 4131702..f373b0e 100644 --- a/compiler/src/lib/tiger/tiger_mips_frame.ml +++ b/compiler/src/lib/tiger/tiger_mips_frame.ml @@ -1,6 +1,7 @@ module List = ListLabels module Temp = Tiger_temp +module T = Tiger_tree type access = | InFrame of {offset_from_frame_pointer : int} @@ -19,6 +20,8 @@ type t = ; instructions : unit (* TODO: instructions for view shift *) } +let pointer = Temp.Temp.gen () + let word_size_bits = 32 let word_size_bytes = word_size_bits / 8 let word_size = word_size_bytes @@ -57,3 +60,12 @@ let make ~name ~formals = ; locals_count ; instructions = () (* TODO: instructions for view shift *) } + +(*failwith ("NOT IMPLEMENTED: " ^ __MODULE__ ^ ".exp")*) + +let exp ~access ~pointer = + match access with + | InReg {register} -> + T.TEMP register + | InFrame {offset_from_frame_pointer} -> + T.MEM (T.BINOP (T.PLUS, pointer, T.CONST offset_from_frame_pointer))