Permalink
Browse files

++

  • Loading branch information...
1 parent aa47e7d commit 08141f2f662eb4b5113efbac2a1675ef761eebbc @pikatchu committed Apr 25, 2011
Showing with 18 additions and 13 deletions.
  1. +18 −13 compiler/emit.ml
View
@@ -334,7 +334,7 @@ let optims pm =
()
; add_memory_to_register_demotion pm
; add_tail_call_elimination pm
-(* ; add_instruction_combination pm
+ ; add_instruction_combination pm
; add_memory_to_register_promotion pm
; add_constant_propagation pm
; add_sccp pm
@@ -365,7 +365,7 @@ let optims pm =
; add_scalar_repl_aggregation pm
; add_ind_var_simplification pm
; add_instruction_combination pm
-*)
+
let rec program base root no_opt dump_as mdl =
let ctx = global_context() in
@@ -416,6 +416,22 @@ and module_ no_opt dump_as mds ctx t orig_types md =
*)
md
+and cast env ty v =
+ let ty1 = ty in
+ let ty2 = type_of v in
+ match classify_type ty1, classify_type ty2 with
+ | TypeKind.Pointer, TypeKind.Pointer -> build_bitcast v ty1 "" env.builder
+ | TypeKind.Pointer, _ -> build_inttoptr v ty1 "" env.builder
+ | _, TypeKind.Pointer -> build_ptrtoint v ty1 "" env.builder
+ | TypeKind.Integer, TypeKind.Integer ->
+ build_intcast v ty1 "" env.builder
+ | _, _ -> build_bitcast v ty1 "" env.builder
+
+and find env (ty, v) acc =
+ let ty = Type.type_ env.mds env.types env.ctx ty in
+ let v = IMap.find v acc in
+ cast env ty v
+
and def env df =
function_ env df
@@ -621,17 +637,6 @@ and extract_values env acc xl v =
IMap.add x nv acc
) acc xl
-and cast env ty v =
- let ty1 = ty in
- let ty2 = type_of v in
- match classify_type ty1, classify_type ty2 with
- | TypeKind.Pointer, TypeKind.Pointer -> build_bitcast v ty1 "" env.builder
- | TypeKind.Pointer, _ -> build_inttoptr v ty1 "" env.builder
- | _, TypeKind.Pointer -> build_ptrtoint v ty1 "" env.builder
- | TypeKind.Integer, TypeKind.Integer ->
- build_intcast v ty1 "" env.builder
- | _, _ -> build_bitcast v ty1 "" env.builder
-
and expr bb env acc (ty, x) e =
let xs = Ident.to_string x in
match e with

0 comments on commit 08141f2

Please sign in to comment.