home
/
code
/
tiger.ml.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
6ca1afb
)
WIP
ir-translation-wip
author
Siraaj Khandkar
<siraaj@khandkar.net>
Thu, 22 Aug 2019 19:09:13 +0000
(15:09 -0400)
committer
Siraaj Khandkar
<siraaj@khandkar.net>
Thu, 22 Aug 2019 19:09:13 +0000
(15:09 -0400)
compiler/src/lib/tiger/tiger_frame_sig.ml
patch
|
blob
|
blame
|
history
compiler/src/lib/tiger/tiger_mips_frame.ml
patch
|
blob
|
blame
|
history
compiler/src/lib/tiger/tiger_translate.ml
patch
|
blob
|
blame
|
history
compiler/src/lib/tiger/tiger_translate.mli
patch
|
blob
|
blame
|
history
diff --git
a/compiler/src/lib/tiger/tiger_frame_sig.ml
b/compiler/src/lib/tiger/tiger_frame_sig.ml
index
2da5d57
..
5ab7718
100644
(file)
--- a/
compiler/src/lib/tiger/tiger_frame_sig.ml
+++ b/
compiler/src/lib/tiger/tiger_frame_sig.ml
@@
-3,7
+3,11
@@
module type S = sig
type access
type access
- val word_size : int
+ val word_size :
+ int
+
+ val pointer :
+ Tiger_temp.Temp.t
val make :
name:Tiger_temp.Label.t -> formals:bool list -> t
val make :
name:Tiger_temp.Label.t -> formals:bool list -> t
@@
-16,4
+20,7
@@
module type S = sig
val alloc_local :
t -> escapes:bool -> access
val alloc_local :
t -> escapes:bool -> access
+
+ val exp :
+ access:access -> pointer:Tiger_tree.exp -> Tiger_tree.exp
end
end
diff --git
a/compiler/src/lib/tiger/tiger_mips_frame.ml
b/compiler/src/lib/tiger/tiger_mips_frame.ml
index
4131702
..
f373b0e
100644
(file)
--- 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 List = ListLabels
module Temp = Tiger_temp
+module T = Tiger_tree
type access =
| InFrame of {offset_from_frame_pointer : int}
type access =
| InFrame of {offset_from_frame_pointer : int}
@@
-19,6
+20,8
@@
type t =
; instructions : unit (* TODO: instructions for view shift *)
}
; 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
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 *)
}
; 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))
diff --git
a/compiler/src/lib/tiger/tiger_translate.ml
b/compiler/src/lib/tiger/tiger_translate.ml
index
483335a
..
9295df9
100644
(file)
--- a/
compiler/src/lib/tiger/tiger_translate.ml
+++ b/
compiler/src/lib/tiger/tiger_translate.ml
@@
-47,13
+47,13
@@
type exp =
type access =
(* must know about static links *)
type access =
(* must know about static links *)
- { level
: Level.t
- ;
frame_
access : Frame.access
+ { level : Level.t
+ ; access : Frame.access
}
let alloc_local ~level ~escapes =
{ level
}
let alloc_local ~level ~escapes =
{ level
- ;
frame_
access = Frame.alloc_local (Level.frame level) ~escapes
+ ; access = Frame.alloc_local (Level.frame level) ~escapes
}
let formals ~level =
}
let formals ~level =
@@
-62,6
+62,9
@@
let formals ~level =
alloc_local ~level ~escapes
)
alloc_local ~level ~escapes
)
+let not_implemented func =
+ failwith (Printf.sprintf "Not implemented: %s.%s" __MODULE__ func)
+
let rec seq = function
(* TODO: Is appending 0 OK? How else can the empty case be handled? *)
| [] -> T.EXP (T.CONST 0)
let rec seq = function
(* TODO: Is appending 0 OK? How else can the empty case be handled? *)
| [] -> T.EXP (T.CONST 0)
@@
-100,3
+103,7
@@
let unCx = function
| Cx g -> g
let dummy__FIXME = Ex (T.CONST 0)
| Cx g -> g
let dummy__FIXME = Ex (T.CONST 0)
+
+let simple_var {level; access} =
+ let pointer = not_implemented "simple_var frame pointer" in
+ Ex (Frame.exp ~access ~pointer)
diff --git
a/compiler/src/lib/tiger/tiger_translate.mli
b/compiler/src/lib/tiger/tiger_translate.mli
index
ca4b0b2
..
5250b50
100644
(file)
--- a/
compiler/src/lib/tiger/tiger_translate.mli
+++ b/
compiler/src/lib/tiger/tiger_translate.mli
@@
-24,3
+24,5
@@
val unNx : exp -> Tiger_tree.stm
val unCx : exp -> gen_stm
val dummy__FIXME : exp (* FIXME: Remove dummy when real is ready *)
val unCx : exp -> gen_stm
val dummy__FIXME : exp (* FIXME: Remove dummy when real is ready *)
+
+val simple_var : access -> exp
This page took
0.029677 seconds
and
4
git commands to generate.