ソースを参照

Simplified LoadImm instruction format

Taddeus Kroes 12 年 前
コミット
95036e3719
3 ファイル変更7 行追加7 行削除
  1. 2 2
      phases/assemble.ml
  2. 4 4
      phases/print.ml
  3. 1 1
      types.ml

+ 2 - 2
phases/assemble.ml

@@ -126,8 +126,8 @@ let assemble program =
             (trav value) @ pop
 
         (* Expressions *)
-        | Const (BoolVal _, _) ->
-            [LoadImm node]
+        | Const (BoolVal _ as value, _) ->
+            [LoadImm value]
 
         | Const (value, _) ->
             Hashtbl.replace consts value (typeof node, indexof node);

+ 4 - 4
phases/print.ml

@@ -79,13 +79,13 @@ let rec instr2str = function
         tab ^ prefix ctype ^ "load" ^ suffix scope ^ " " ^ si index
     | LoadConst (ctype, index) ->
         tab ^ prefix ctype ^ "loadc " ^ si index
-    | LoadImm (Const (BoolVal b, _)) ->
+    | LoadImm (BoolVal b) ->
         tab ^ "bloadc_" ^ (if b then "t" else "f")
-    | LoadImm (Const (IntVal i, _)) when i < 0 ->
+    | LoadImm (IntVal i) when i < 0 ->
         tab ^ "iloadc_m" ^ si (-i)
-    | LoadImm (Const (IntVal i, _)) ->
+    | LoadImm (IntVal i) ->
         tab ^ "iloadc_" ^ si i
-    | LoadImm (Const (FloatVal i, _)) ->
+    | LoadImm (FloatVal i) ->
         tab ^ "floadc_" ^ si (int_of_float i)
 
     (* Operators *)

+ 1 - 1
types.ml

@@ -95,7 +95,7 @@ type instr =
 
     | Load of ctype * stack_scope * int  (* [ifb]load[ gn] G *)
     | LoadConst of ctype * int           (* [ifb]loadc C *)
-    | LoadImm of node                    (* [ifb]load_[01tf] <value> *)
+    | LoadImm of const                   (* [ifb]load_[01tf] <value> *)
 
     | Op of operator * ctype             (* [ifb]() *)
     | Convert of ctype * ctype           (* i2f|f2i *)