X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=test%2FBindings%2FOcaml%2Fvmcore.ml;h=6b103cb8fc985c51987c1550e8a5cc14a832d978;hp=f17693258b4a4a2d393149f268304784edc23a8e;hb=a353ffa7e556bfd2864474911174da691117f691;hpb=80a75bfae980df96f969f1c05b0c4a80ce975240 diff --git a/test/Bindings/Ocaml/vmcore.ml b/test/Bindings/Ocaml/vmcore.ml index f17693258b4..6b103cb8fc9 100644 --- a/test/Bindings/Ocaml/vmcore.ml +++ b/test/Bindings/Ocaml/vmcore.ml @@ -1,4 +1,4 @@ -(* RUN: %ocamlc llvm.cma llvm_analysis.cma llvm_bitwriter.cma %s -o %t +(* RUN: %ocamlc -warn-error A llvm.cma llvm_analysis.cma llvm_bitwriter.cma %s -o %t * RUN: ./%t %t.bc * RUN: llvm-dis < %t.bc > %t.ll *) @@ -21,10 +21,7 @@ let group name = let insist cond = incr case_num; - let msg = if cond then " pass " else begin - exit_status := 10; - " FAIL " - end in + if not cond then exit_status := 10; prerr_endline (" " ^ (string_of_int !case_num) ^ if cond then "" else " FAIL") @@ -39,6 +36,25 @@ let filename = Sys.argv.(1) let m = create_module filename +(*===-- Target ------------------------------------------------------------===*) + +let test_target () = + begin group "triple"; + (* RUN: grep "i686-apple-darwin8" < %t.ll + *) + let trip = "i686-apple-darwin8" in + set_target_triple trip m; + insist (trip = target_triple m) + end; + + begin group "layout"; + (* RUN: grep "bogus" < %t.ll + *) + let layout = "bogus" in + set_data_layout layout m; + insist (layout = data_layout m) + end + (*===-- Types -------------------------------------------------------------===*) let test_types () = @@ -46,13 +62,13 @@ let test_types () = *) group "void"; insist (define_type_name "Ty01" void_type m); - insist (Void_type == classify_type void_type); + insist (TypeKind.Void == classify_type void_type); (* RUN: grep {Ty02.*i1} < %t.ll *) group "i1"; insist (define_type_name "Ty02" i1_type m); - insist (Integer_type == classify_type i1_type); + insist (TypeKind.Integer == classify_type i1_type); (* RUN: grep {Ty03.*i32} < %t.ll *) @@ -69,20 +85,20 @@ let test_types () = *) group "float"; insist (define_type_name "Ty05" float_type m); - insist (Float_type == classify_type float_type); + insist (TypeKind.Float == classify_type float_type); (* RUN: grep {Ty06.*double} < %t.ll *) group "double"; insist (define_type_name "Ty06" double_type m); - insist (Double_type == classify_type double_type); + insist (TypeKind.Double == classify_type double_type); (* RUN: grep {Ty07.*i32.*i1, double} < %t.ll *) group "function"; let ty = function_type i32_type [| i1_type; double_type |] in insist (define_type_name "Ty07" ty m); - insist (Function_type = classify_type ty); + insist (TypeKind.Function = classify_type ty); insist (not (is_var_arg ty)); insist (i32_type == return_type ty); insist (double_type == (param_types ty).(1)); @@ -101,15 +117,26 @@ let test_types () = insist (define_type_name "Ty09" ty m); insist (7 = array_length ty); insist (i8_type == element_type ty); - insist (Array_type == classify_type ty); + insist (TypeKind.Array == classify_type ty); - (* RUN: grep {Ty10.*float\*} < %t.ll - *) - group "pointer"; - let ty = pointer_type float_type in - insist (define_type_name "Ty10" ty m); - insist (float_type == element_type ty); - insist (Pointer_type == classify_type ty); + begin group "pointer"; + (* RUN: grep {UnqualPtrTy.*float\*} < %t.ll + *) + let ty = pointer_type float_type in + insist (define_type_name "UnqualPtrTy" ty m); + insist (float_type == element_type ty); + insist (0 == address_space ty); + insist (TypeKind.Pointer == classify_type ty) + end; + + begin group "qualified_pointer"; + (* RUN: grep {QualPtrTy.*i8.*3.*\*} < %t.ll + *) + let ty = qualified_pointer_type i8_type 3 in + insist (define_type_name "QualPtrTy" ty m); + insist (i8_type == element_type ty); + insist (3 == address_space ty) + end; (* RUN: grep {Ty11.*\<4 x i16\>} < %t.ll *) @@ -278,8 +305,8 @@ let test_constants () = ignore (define_global "ConstAnd" (const_and foldbomb five) m); ignore (define_global "ConstOr" (const_or foldbomb five) m); ignore (define_global "ConstXor" (const_xor foldbomb five) m); - ignore (define_global "ConstICmp" (const_icmp Icmp_sle foldbomb five) m); - ignore (define_global "ConstFCmp" (const_fcmp Fcmp_ole ffoldbomb ffive) m); + ignore (define_global "ConstICmp" (const_icmp Icmp.Sle foldbomb five) m); + ignore (define_global "ConstFCmp" (const_fcmp Fcmp.Ole ffoldbomb ffive) m); group "constant casts"; (* RUN: grep {ConstTrunc.*trunc} < %t.ll @@ -325,7 +352,7 @@ let test_constants () = ignore (define_global "ConstSizeOf" (size_of (pointer_type i8_type)) m); ignore (define_global "ConstGEP" (const_gep foldbomb_gv [| five |]) m); ignore (define_global "ConstSelect" (const_select - (const_icmp Icmp_sle foldbomb five) + (const_icmp Icmp.Sle foldbomb five) (const_int i8_type (-1)) (const_int i8_type 0)) m); let zero = const_int i32_type 0 in @@ -360,8 +387,8 @@ let test_global_values () = *) group "linkage"; let g = define_global "GVal02" zero32 m ++ - set_linkage Link_once_linkage in - insist (Link_once_linkage = linkage g); + set_linkage Linkage.Link_once in + insist (Linkage.Link_once = linkage g); (* RUN: grep {GVal03.*Hanalei} < %t.ll *) @@ -374,8 +401,8 @@ let test_global_values () = *) group "visibility"; let g = define_global "GVal04" zero32 m ++ - set_visibility Hidden_visibility in - insist (Hidden_visibility = visibility g); + set_visibility Visibility.Hidden in + insist (Visibility.Hidden = visibility g); (* RUN: grep {GVal05.*align 128} < %t.ll *) @@ -488,9 +515,9 @@ let test_functions () = *) group "callconv"; let fn = define_function "Fn5" ty m in - insist (ccc = function_call_conv fn); - set_function_call_conv fastcc fn; - insist (fastcc = function_call_conv fn); + insist (CallConv.c = function_call_conv fn); + set_function_call_conv CallConv.fast fn; + insist (CallConv.fast = function_call_conv fn); ignore (build_unreachable (builder_at_end (entry_block fn))); begin group "collector"; @@ -734,10 +761,10 @@ let test_builder () = * RUN: grep {Inst42.*fcmp.*false.*F1.*F2} < %t.ll * RUN: grep {Inst43.*fcmp.*true.*F2.*F1} < %t.ll *) - ignore (build_icmp Icmp_ne p1 p2 "Inst40" atentry); - ignore (build_icmp Icmp_sle p2 p1 "Inst41" atentry); - ignore (build_fcmp Fcmp_false f1 f2 "Inst42" atentry); - ignore (build_fcmp Fcmp_true f2 f1 "Inst43" atentry) + ignore (build_icmp Icmp.Ne p1 p2 "Inst40" atentry); + ignore (build_icmp Icmp.Sle p2 p1 "Inst41" atentry); + ignore (build_fcmp Fcmp.False f1 f2 "Inst42" atentry); + ignore (build_fcmp Fcmp.True f2 f1 "Inst43" atentry) end; group "miscellaneous"; begin @@ -749,7 +776,7 @@ let test_builder () = * RUN: grep {Inst51.*shufflevector.*Vec1.*Vec2.*1.*1.*0.*0} < %t.ll *) ignore (build_call fn [| p2; p1 |] "Inst45" atentry); - let inst46 = build_icmp Icmp_eq p1 p2 "Inst46" atentry in + let inst46 = build_icmp Icmp.Eq p1 p2 "Inst46" atentry in ignore (build_select inst46 p1 p2 "Inst47" atentry); ignore (build_va_arg (const_null (pointer_type (pointer_type i8_type))) @@ -790,6 +817,14 @@ let test_builder () = end +(*===-- Module Provider ---------------------------------------------------===*) + +let test_module_provider () = + let m = create_module "test" in + let mp = ModuleProvider.create m in + ModuleProvider.dispose mp + + (*===-- Writer ------------------------------------------------------------===*) let test_writer () = @@ -807,6 +842,7 @@ let test_writer () = (*===-- Driver ------------------------------------------------------------===*) let _ = + suite "target" test_target; suite "types" test_types; suite "constants" test_constants; suite "global values" test_global_values; @@ -814,5 +850,6 @@ let _ = suite "functions" test_functions; suite "basic blocks" test_basic_blocks; suite "builder" test_builder; + suite "module provider" test_module_provider; suite "writer" test_writer; exit !exit_status