Rename ocaml vmcore tests to make it easier to insert tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97369 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Erick Tryzelaar 2010-02-28 05:51:21 +00:00
parent 628b76ecb3
commit 6e2ee569c5

View File

@ -83,181 +83,181 @@ let test_target () =
(*===-- Types -------------------------------------------------------------===*) (*===-- Types -------------------------------------------------------------===*)
let test_types () = let test_types () =
(* RUN: grep {Ty01.*void} < %t.ll (* RUN: grep {void_type.*void} < %t.ll
*) *)
group "void"; group "void";
insist (define_type_name "Ty01" void_type m); insist (define_type_name "void_type" void_type m);
insist (TypeKind.Void == classify_type void_type); insist (TypeKind.Void == classify_type void_type);
(* RUN: grep {Ty02.*i1} < %t.ll (* RUN: grep {i1_type.*i1} < %t.ll
*) *)
group "i1"; group "i1";
insist (define_type_name "Ty02" i1_type m); insist (define_type_name "i1_type" i1_type m);
insist (TypeKind.Integer == classify_type i1_type); insist (TypeKind.Integer == classify_type i1_type);
(* RUN: grep {Ty03.*i32} < %t.ll (* RUN: grep {i32_type.*i32} < %t.ll
*) *)
group "i32"; group "i32";
insist (define_type_name "Ty03" i32_type m); insist (define_type_name "i32_type" i32_type m);
(* RUN: grep {Ty04.*i42} < %t.ll (* RUN: grep {i42_type.*i42} < %t.ll
*) *)
group "i42"; group "i42";
let ty = integer_type context 42 in let ty = integer_type context 42 in
insist (define_type_name "Ty04" ty m); insist (define_type_name "i42_type" ty m);
(* RUN: grep {Ty05.*float} < %t.ll (* RUN: grep {float_type.*float} < %t.ll
*) *)
group "float"; group "float";
insist (define_type_name "Ty05" float_type m); insist (define_type_name "float_type" float_type m);
insist (TypeKind.Float == classify_type float_type); insist (TypeKind.Float == classify_type float_type);
(* RUN: grep {Ty06.*double} < %t.ll (* RUN: grep {double_type.*double} < %t.ll
*) *)
group "double"; group "double";
insist (define_type_name "Ty06" double_type m); insist (define_type_name "double_type" double_type m);
insist (TypeKind.Double == classify_type double_type); insist (TypeKind.Double == classify_type double_type);
(* RUN: grep {Ty07.*i32.*i1, double} < %t.ll (* RUN: grep {function_type.*i32.*i1, double} < %t.ll
*) *)
group "function"; group "function";
let ty = function_type i32_type [| i1_type; double_type |] in let ty = function_type i32_type [| i1_type; double_type |] in
insist (define_type_name "Ty07" ty m); insist (define_type_name "function_type" ty m);
insist (TypeKind.Function = classify_type ty); insist (TypeKind.Function = classify_type ty);
insist (not (is_var_arg ty)); insist (not (is_var_arg ty));
insist (i32_type == return_type ty); insist (i32_type == return_type ty);
insist (double_type == (param_types ty).(1)); insist (double_type == (param_types ty).(1));
(* RUN: grep {Ty08.*\.\.\.} < %t.ll (* RUN: grep {var_arg_type.*\.\.\.} < %t.ll
*) *)
group "var arg function"; group "var arg function";
let ty = var_arg_function_type void_type [| i32_type |] in let ty = var_arg_function_type void_type [| i32_type |] in
insist (define_type_name "Ty08" ty m); insist (define_type_name "var_arg_type" ty m);
insist (is_var_arg ty); insist (is_var_arg ty);
(* RUN: grep {Ty09.*\\\[7 x i8\\\]} < %t.ll (* RUN: grep {array_type.*\\\[7 x i8\\\]} < %t.ll
*) *)
group "array"; group "array";
let ty = array_type i8_type 7 in let ty = array_type i8_type 7 in
insist (define_type_name "Ty09" ty m); insist (define_type_name "array_type" ty m);
insist (7 = array_length ty); insist (7 = array_length ty);
insist (i8_type == element_type ty); insist (i8_type == element_type ty);
insist (TypeKind.Array == classify_type ty); insist (TypeKind.Array == classify_type ty);
begin group "pointer"; begin group "pointer";
(* RUN: grep {UnqualPtrTy.*float\*} < %t.ll (* RUN: grep {pointer_type.*float\*} < %t.ll
*) *)
let ty = pointer_type float_type in let ty = pointer_type float_type in
insist (define_type_name "UnqualPtrTy" ty m); insist (define_type_name "pointer_type" ty m);
insist (float_type == element_type ty); insist (float_type == element_type ty);
insist (0 == address_space ty); insist (0 == address_space ty);
insist (TypeKind.Pointer == classify_type ty) insist (TypeKind.Pointer == classify_type ty)
end; end;
begin group "qualified_pointer"; begin group "qualified_pointer";
(* RUN: grep {QualPtrTy.*i8.*3.*\*} < %t.ll (* RUN: grep {qualified_pointer_type.*i8.*3.*\*} < %t.ll
*) *)
let ty = qualified_pointer_type i8_type 3 in let ty = qualified_pointer_type i8_type 3 in
insist (define_type_name "QualPtrTy" ty m); insist (define_type_name "qualified_pointer_type" ty m);
insist (i8_type == element_type ty); insist (i8_type == element_type ty);
insist (3 == address_space ty) insist (3 == address_space ty)
end; end;
(* RUN: grep {Ty11.*\<4 x i16\>} < %t.ll (* RUN: grep {vector_type.*\<4 x i16\>} < %t.ll
*) *)
group "vector"; group "vector";
let ty = vector_type i16_type 4 in let ty = vector_type i16_type 4 in
insist (define_type_name "Ty11" ty m); insist (define_type_name "vector_type" ty m);
insist (i16_type == element_type ty); insist (i16_type == element_type ty);
insist (4 = vector_size ty); insist (4 = vector_size ty);
(* RUN: grep {Ty12.*opaque} < %t.ll (* RUN: grep {opaque_type.*opaque} < %t.ll
*) *)
group "opaque"; group "opaque";
let ty = opaque_type context in let ty = opaque_type context in
insist (define_type_name "Ty12" ty m); insist (define_type_name "opaque_type" ty m);
insist (ty == ty); insist (ty == ty);
insist (ty <> opaque_type context); insist (ty <> opaque_type context);
(* RUN: grep -v {Ty13} < %t.ll (* RUN: grep -v {delete_type} < %t.ll
*) *)
group "delete"; group "delete";
let ty = opaque_type context in let ty = opaque_type context in
insist (define_type_name "Ty13" ty m); insist (define_type_name "delete_type" ty m);
delete_type_name "Ty13" m; delete_type_name "delete_type" m;
(* RUN: grep -v {RecursiveTy.*RecursiveTy} < %t.ll (* RUN: grep -v {recursive_type.*recursive_type} < %t.ll
*) *)
group "recursive"; group "recursive";
let ty = opaque_type context in let ty = opaque_type context in
let th = handle_to_type ty in let th = handle_to_type ty in
refine_type ty (pointer_type ty); refine_type ty (pointer_type ty);
let ty = type_of_handle th in let ty = type_of_handle th in
insist (define_type_name "RecursiveTy" ty m); insist (define_type_name "recursive_type" ty m);
insist (ty == element_type ty) insist (ty == element_type ty)
(*===-- Constants ---------------------------------------------------------===*) (*===-- Constants ---------------------------------------------------------===*)
let test_constants () = let test_constants () =
(* RUN: grep {Const01.*i32.*-1} < %t.ll (* RUN: grep {const_int.*i32.*-1} < %t.ll
*) *)
group "int"; group "int";
let c = const_int i32_type (-1) in let c = const_int i32_type (-1) in
ignore (define_global "Const01" c m); ignore (define_global "const_int" c m);
insist (i32_type = type_of c); insist (i32_type = type_of c);
insist (is_constant c); insist (is_constant c);
(* RUN: grep {Const02.*i64.*-1} < %t.ll (* RUN: grep {const_sext_int.*i64.*-1} < %t.ll
*) *)
group "sext int"; group "sext int";
let c = const_int i64_type (-1) in let c = const_int i64_type (-1) in
ignore (define_global "Const02" c m); ignore (define_global "const_sext_int" c m);
insist (i64_type = type_of c); insist (i64_type = type_of c);
(* RUN: grep {Const03.*i64.*4294967295} < %t.ll (* RUN: grep {const_zext_int64.*i64.*4294967295} < %t.ll
*) *)
group "zext int64"; group "zext int64";
let c = const_of_int64 i64_type (Int64.of_string "4294967295") false in let c = const_of_int64 i64_type (Int64.of_string "4294967295") false in
ignore (define_global "Const03" c m); ignore (define_global "const_zext_int64" c m);
insist (i64_type = type_of c); insist (i64_type = type_of c);
(* RUN: grep {ConstIntString.*i32.*-1} < %t.ll (* RUN: grep {const_int_string.*i32.*-1} < %t.ll
*) *)
group "int string"; group "int string";
let c = const_int_of_string i32_type "-1" 10 in let c = const_int_of_string i32_type "-1" 10 in
ignore (define_global "ConstIntString" c m); ignore (define_global "const_int_string" c m);
insist (i32_type = type_of c); insist (i32_type = type_of c);
(* RUN: grep {Const04.*"cruel\\\\00world"} < %t.ll (* RUN: grep {const_string.*"cruel\\\\00world"} < %t.ll
*) *)
group "string"; group "string";
let c = const_string context "cruel\000world" in let c = const_string context "cruel\000world" in
ignore (define_global "Const04" c m); ignore (define_global "const_string" c m);
insist ((array_type i8_type 11) = type_of c); insist ((array_type i8_type 11) = type_of c);
(* RUN: grep {Const05.*"hi\\\\00again\\\\00"} < %t.ll (* RUN: grep {const_stringz.*"hi\\\\00again\\\\00"} < %t.ll
*) *)
group "stringz"; group "stringz";
let c = const_stringz context "hi\000again" in let c = const_stringz context "hi\000again" in
ignore (define_global "Const05" c m); ignore (define_global "const_stringz" c m);
insist ((array_type i8_type 9) = type_of c); insist ((array_type i8_type 9) = type_of c);
(* RUN: grep {ConstSingle.*2.75} < %t.ll (* RUN: grep {const_single.*2.75} < %t.ll
* RUN: grep {ConstDouble.*3.1459} < %t.ll * RUN: grep {const_double.*3.1459} < %t.ll
* RUN: grep {ConstDoubleString.*1.25} < %t.ll * RUN: grep {const_double_string.*1.25} < %t.ll
*) *)
begin group "real"; begin group "real";
let cs = const_float float_type 2.75 in let cs = const_float float_type 2.75 in
ignore (define_global "ConstSingle" cs m); ignore (define_global "const_single" cs m);
insist (float_type = type_of cs); insist (float_type = type_of cs);
let cd = const_float double_type 3.1459 in let cd = const_float double_type 3.1459 in
ignore (define_global "ConstDouble" cd m); ignore (define_global "const_double" cd m);
insist (double_type = type_of cd); insist (double_type = type_of cd);
let cd = const_float_of_string double_type "1.25" in let cd = const_float_of_string double_type "1.25" in
ignore (define_global "ConstDoubleString" cd m); ignore (define_global "const_double_string" cd m);
insist (double_type = type_of cd) insist (double_type = type_of cd)
end; end;
@ -266,67 +266,67 @@ let test_constants () =
let three = const_int i32_type 3 in let three = const_int i32_type 3 in
let four = const_int i32_type 4 in let four = const_int i32_type 4 in
(* RUN: grep {Const07.*\\\[i32 3, i32 4\\\]} < %t.ll (* RUN: grep {const_array.*\\\[i32 3, i32 4\\\]} < %t.ll
*) *)
group "array"; group "array";
let c = const_array i32_type [| three; four |] in let c = const_array i32_type [| three; four |] in
ignore (define_global "Const07" c m); ignore (define_global "const_array" c m);
insist ((array_type i32_type 2) = (type_of c)); insist ((array_type i32_type 2) = (type_of c));
(* RUN: grep {Const08.*<i16 1, i16 2.*>} < %t.ll (* RUN: grep {const_vector.*<i16 1, i16 2.*>} < %t.ll
*) *)
group "vector"; group "vector";
let c = const_vector [| one; two; one; two; let c = const_vector [| one; two; one; two;
one; two; one; two |] in one; two; one; two |] in
ignore (define_global "Const08" c m); ignore (define_global "const_vector" c m);
insist ((vector_type i16_type 8) = (type_of c)); insist ((vector_type i16_type 8) = (type_of c));
(* RUN: grep {Const09.*.i16 1, i16 2, i32 3, i32 4} < %t.ll (* RUN: grep {const_structure.*.i16 1, i16 2, i32 3, i32 4} < %t.ll
*) *)
group "structure"; group "structure";
let c = const_struct context [| one; two; three; four |] in let c = const_struct context [| one; two; three; four |] in
ignore (define_global "Const09" c m); ignore (define_global "const_structure" c m);
insist ((struct_type context [| i16_type; i16_type; i32_type; i32_type |]) insist ((struct_type context [| i16_type; i16_type; i32_type; i32_type |])
= (type_of c)); = (type_of c));
(* RUN: grep {Const10.*zeroinit} < %t.ll (* RUN: grep {const_null.*zeroinit} < %t.ll
*) *)
group "null"; group "null";
let c = const_null (packed_struct_type context [| i1_type; i8_type; i64_type; let c = const_null (packed_struct_type context [| i1_type; i8_type; i64_type;
double_type |]) in double_type |]) in
ignore (define_global "Const10" c m); ignore (define_global "const_null" c m);
(* RUN: grep {Const11.*-1} < %t.ll (* RUN: grep {const_all_ones.*-1} < %t.ll
*) *)
group "all ones"; group "all ones";
let c = const_all_ones i64_type in let c = const_all_ones i64_type in
ignore (define_global "Const11" c m); ignore (define_global "const_all_ones" c m);
(* RUN: grep {Const12.*undef} < %t.ll (* RUN: grep {const_undef.*undef} < %t.ll
*) *)
group "undef"; group "undef";
let c = undef i1_type in let c = undef i1_type in
ignore (define_global "Const12" c m); ignore (define_global "const_undef" c m);
insist (i1_type = type_of c); insist (i1_type = type_of c);
insist (is_undef c); insist (is_undef c);
group "constant arithmetic"; group "constant arithmetic";
(* RUN: grep {ConstNeg.*sub} < %t.ll (* RUN: grep {@const_neg = global i64 sub} < %t.ll
* RUN: grep {ConstNot.*xor} < %t.ll * RUN: grep {@const_not = global i64 xor } < %t.ll
* RUN: grep {ConstAdd.*add} < %t.ll * RUN: grep {@const_add = global i64 add } < %t.ll
* RUN: grep {ConstSub.*sub} < %t.ll * RUN: grep {@const_sub = global i64 sub } < %t.ll
* RUN: grep {ConstMul.*mul} < %t.ll * RUN: grep {@const_mul = global i64 mul } < %t.ll
* RUN: grep {ConstUDiv.*udiv} < %t.ll * RUN: grep {@const_udiv = global i64 udiv } < %t.ll
* RUN: grep {ConstSDiv.*sdiv} < %t.ll * RUN: grep {@const_sdiv = global i64 sdiv } < %t.ll
* RUN: grep {ConstFDiv.*fdiv} < %t.ll * RUN: grep {@const_fdiv = global double fdiv } < %t.ll
* RUN: grep {ConstURem.*urem} < %t.ll * RUN: grep {@const_urem = global i64 urem } < %t.ll
* RUN: grep {ConstSRem.*srem} < %t.ll * RUN: grep {@const_srem = global i64 srem } < %t.ll
* RUN: grep {ConstFRem.*frem} < %t.ll * RUN: grep {@const_frem = global double frem } < %t.ll
* RUN: grep {ConstAnd.*and} < %t.ll * RUN: grep {@const_and = global i64 and } < %t.ll
* RUN: grep {ConstOr.*or} < %t.ll * RUN: grep {@const_or = global i64 or } < %t.ll
* RUN: grep {ConstXor.*xor} < %t.ll * RUN: grep {@const_xor = global i64 xor } < %t.ll
* RUN: grep {ConstICmp.*icmp} < %t.ll * RUN: grep {@const_icmp = global i1 icmp sle } < %t.ll
* RUN: grep {ConstFCmp.*fcmp} < %t.ll * RUN: grep {@const_fcmp = global i1 fcmp ole } < %t.ll
*) *)
let void_ptr = pointer_type i8_type in let void_ptr = pointer_type i8_type in
let five = const_int i64_type 5 in let five = const_int i64_type 5 in
@ -334,79 +334,79 @@ let test_constants () =
let foldbomb_gv = define_global "FoldBomb" (const_null i8_type) m in let foldbomb_gv = define_global "FoldBomb" (const_null i8_type) m in
let foldbomb = const_ptrtoint foldbomb_gv i64_type in let foldbomb = const_ptrtoint foldbomb_gv i64_type in
let ffoldbomb = const_uitofp foldbomb double_type in let ffoldbomb = const_uitofp foldbomb double_type in
ignore (define_global "ConstNeg" (const_neg foldbomb) m); ignore (define_global "const_neg" (const_neg foldbomb) m);
ignore (define_global "ConstNot" (const_not foldbomb) m); ignore (define_global "const_not" (const_not foldbomb) m);
ignore (define_global "ConstAdd" (const_add foldbomb five) m); ignore (define_global "const_add" (const_add foldbomb five) m);
ignore (define_global "ConstSub" (const_sub foldbomb five) m); ignore (define_global "const_sub" (const_sub foldbomb five) m);
ignore (define_global "ConstMul" (const_mul foldbomb five) m); ignore (define_global "const_mul" (const_mul foldbomb five) m);
ignore (define_global "ConstUDiv" (const_udiv foldbomb five) m); ignore (define_global "const_udiv" (const_udiv foldbomb five) m);
ignore (define_global "ConstSDiv" (const_sdiv foldbomb five) m); ignore (define_global "const_sdiv" (const_sdiv foldbomb five) m);
ignore (define_global "ConstFDiv" (const_fdiv ffoldbomb ffive) m); ignore (define_global "const_fdiv" (const_fdiv ffoldbomb ffive) m);
ignore (define_global "ConstURem" (const_urem foldbomb five) m); ignore (define_global "const_urem" (const_urem foldbomb five) m);
ignore (define_global "ConstSRem" (const_srem foldbomb five) m); ignore (define_global "const_srem" (const_srem foldbomb five) m);
ignore (define_global "ConstFRem" (const_frem ffoldbomb ffive) m); ignore (define_global "const_frem" (const_frem ffoldbomb ffive) m);
ignore (define_global "ConstAnd" (const_and foldbomb five) m); ignore (define_global "const_and" (const_and foldbomb five) m);
ignore (define_global "ConstOr" (const_or foldbomb five) m); ignore (define_global "const_or" (const_or foldbomb five) m);
ignore (define_global "ConstXor" (const_xor foldbomb five) m); ignore (define_global "const_xor" (const_xor foldbomb five) m);
ignore (define_global "ConstICmp" (const_icmp Icmp.Sle foldbomb five) m); ignore (define_global "const_icmp" (const_icmp Icmp.Sle foldbomb five) m);
ignore (define_global "ConstFCmp" (const_fcmp Fcmp.Ole ffoldbomb ffive) m); ignore (define_global "const_fcmp" (const_fcmp Fcmp.Ole ffoldbomb ffive) m);
group "constant casts"; group "constant casts";
(* RUN: grep {ConstTrunc.*trunc} < %t.ll (* RUN: grep {const_trunc.*trunc} < %t.ll
* RUN: grep {ConstSExt.*sext} < %t.ll * RUN: grep {const_sext.*sext} < %t.ll
* RUN: grep {ConstZExt.*zext} < %t.ll * RUN: grep {const_zext.*zext} < %t.ll
* RUN: grep {ConstFPTrunc.*fptrunc} < %t.ll * RUN: grep {const_fptrunc.*fptrunc} < %t.ll
* RUN: grep {ConstFPExt.*fpext} < %t.ll * RUN: grep {const_fpext.*fpext} < %t.ll
* RUN: grep {ConstUIToFP.*uitofp} < %t.ll * RUN: grep {const_uitofp.*uitofp} < %t.ll
* RUN: grep {ConstSIToFP.*sitofp} < %t.ll * RUN: grep {const_sitofp.*sitofp} < %t.ll
* RUN: grep {ConstFPToUI.*fptoui} < %t.ll * RUN: grep {const_fptoui.*fptoui} < %t.ll
* RUN: grep {ConstFPToSI.*fptosi} < %t.ll * RUN: grep {const_fptosi.*fptosi} < %t.ll
* RUN: grep {ConstPtrToInt.*ptrtoint} < %t.ll * RUN: grep {const_ptrtoint.*ptrtoint} < %t.ll
* RUN: grep {ConstIntToPtr.*inttoptr} < %t.ll * RUN: grep {const_inttoptr.*inttoptr} < %t.ll
* RUN: grep {ConstBitCast.*bitcast} < %t.ll * RUN: grep {const_bitcast.*bitcast} < %t.ll
*) *)
let i128_type = integer_type context 128 in let i128_type = integer_type context 128 in
ignore (define_global "ConstTrunc" (const_trunc (const_add foldbomb five) ignore (define_global "const_trunc" (const_trunc (const_add foldbomb five)
i8_type) m); i8_type) m);
ignore (define_global "ConstSExt" (const_sext foldbomb i128_type) m); ignore (define_global "const_sext" (const_sext foldbomb i128_type) m);
ignore (define_global "ConstZExt" (const_zext foldbomb i128_type) m); ignore (define_global "const_zext" (const_zext foldbomb i128_type) m);
ignore (define_global "ConstFPTrunc" (const_fptrunc ffoldbomb float_type) m); ignore (define_global "const_fptrunc" (const_fptrunc ffoldbomb float_type) m);
ignore (define_global "ConstFPExt" (const_fpext ffoldbomb fp128_type) m); ignore (define_global "const_fpext" (const_fpext ffoldbomb fp128_type) m);
ignore (define_global "ConstUIToFP" (const_uitofp foldbomb double_type) m); ignore (define_global "const_uitofp" (const_uitofp foldbomb double_type) m);
ignore (define_global "ConstSIToFP" (const_sitofp foldbomb double_type) m); ignore (define_global "const_sitofp" (const_sitofp foldbomb double_type) m);
ignore (define_global "ConstFPToUI" (const_fptoui ffoldbomb i32_type) m); ignore (define_global "const_fptoui" (const_fptoui ffoldbomb i32_type) m);
ignore (define_global "ConstFPToSI" (const_fptosi ffoldbomb i32_type) m); ignore (define_global "const_fptosi" (const_fptosi ffoldbomb i32_type) m);
ignore (define_global "ConstPtrToInt" (const_ptrtoint ignore (define_global "const_ptrtoint" (const_ptrtoint
(const_gep (const_null (pointer_type i8_type)) (const_gep (const_null (pointer_type i8_type))
[| const_int i32_type 1 |]) [| const_int i32_type 1 |])
i32_type) m); i32_type) m);
ignore (define_global "ConstIntToPtr" (const_inttoptr (const_add foldbomb five) ignore (define_global "const_inttoptr" (const_inttoptr (const_add foldbomb five)
void_ptr) m); void_ptr) m);
ignore (define_global "ConstBitCast" (const_bitcast ffoldbomb i64_type) m); ignore (define_global "const_bitcast" (const_bitcast ffoldbomb i64_type) m);
group "misc constants"; group "misc constants";
(* RUN: grep {ConstSizeOf.*getelementptr.*null} < %t.ll (* RUN: grep {const_size_of.*getelementptr.*null} < %t.ll
* RUN: grep {ConstGEP.*getelementptr} < %t.ll * RUN: grep {const_gep.*getelementptr} < %t.ll
* RUN: grep {ConstSelect.*select} < %t.ll * RUN: grep {const_select.*select} < %t.ll
* RUN: grep {ConstExtractElement.*extractelement} < %t.ll * RUN: grep {const_extractelement.*extractelement} < %t.ll
* RUN: grep {ConstInsertElement.*insertelement} < %t.ll * RUN: grep {const_insertelement.*insertelement} < %t.ll
* RUN: grep {ConstShuffleVector.*shufflevector} < %t.ll * RUN: grep {const_shufflevector.*shufflevector} < %t.ll
*) *)
ignore (define_global "ConstSizeOf" (size_of (pointer_type i8_type)) m); ignore (define_global "const_size_of" (size_of (pointer_type i8_type)) m);
ignore (define_global "ConstGEP" (const_gep foldbomb_gv [| five |]) m); ignore (define_global "const_gep" (const_gep foldbomb_gv [| five |]) m);
ignore (define_global "ConstSelect" (const_select ignore (define_global "const_select" (const_select
(const_icmp Icmp.Sle foldbomb five) (const_icmp Icmp.Sle foldbomb five)
(const_int i8_type (-1)) (const_int i8_type (-1))
(const_int i8_type 0)) m); (const_int i8_type 0)) m);
let zero = const_int i32_type 0 in let zero = const_int i32_type 0 in
let one = const_int i32_type 1 in let one = const_int i32_type 1 in
ignore (define_global "ConstExtractElement" (const_extractelement ignore (define_global "const_extractelement" (const_extractelement
(const_vector [| zero; one; zero; one |]) (const_vector [| zero; one; zero; one |])
(const_trunc foldbomb i32_type)) m); (const_trunc foldbomb i32_type)) m);
ignore (define_global "ConstInsertElement" (const_insertelement ignore (define_global "const_insertelement" (const_insertelement
(const_vector [| zero; one; zero; one |]) (const_vector [| zero; one; zero; one |])
zero (const_trunc foldbomb i32_type)) m); zero (const_trunc foldbomb i32_type)) m);
ignore (define_global "ConstShuffleVector" (const_shufflevector ignore (define_global "const_shufflevector" (const_shufflevector
(const_vector [| zero; one |]) (const_vector [| zero; one |])
(const_vector [| one; zero |]) (const_vector [| one; zero |])
(const_bitcast foldbomb (vector_type i32_type 2))) m) (const_bitcast foldbomb (vector_type i32_type 2))) m)
@ -845,11 +845,11 @@ let test_builder () =
end; end;
group "cond_br"; begin group "cond_br"; begin
(* RUN: grep {br.*Inst01.*Bb03.*Bb00} < %t.ll (* RUN: grep {br.*build_br.*Bb03.*Bb00} < %t.ll
*) *)
let bb03 = append_block context "Bb03" fn in let bb03 = append_block context "Bb03" fn in
let b = builder_at_end context bb03 in let b = builder_at_end context bb03 in
let cond = build_trunc p1 i1_type "Inst01" b in let cond = build_trunc p1 i1_type "build_br" b in
ignore (build_cond_br cond bb03 bb00 b) ignore (build_cond_br cond bb03 bb00 b)
end; end;
@ -867,12 +867,12 @@ let test_builder () =
end; end;
group "invoke"; begin group "invoke"; begin
(* RUN: grep {Inst02.*invoke.*P1.*P2} < %t.ll (* RUN: grep {build_invoke.*invoke.*P1.*P2} < %t.ll
* RUN: grep {to.*Bb04.*unwind.*Bb00} < %t.ll * RUN: grep {to.*Bb04.*unwind.*Bb00} < %t.ll
*) *)
let bb04 = append_block context "Bb04" fn in let bb04 = append_block context "Bb04" fn in
let b = builder_at_end context bb04 in let b = builder_at_end context bb04 in
ignore (build_invoke fn [| p1; p2 |] bb04 bb00 "Inst02" b) ignore (build_invoke fn [| p1; p2 |] bb04 bb00 "build_invoke" b)
end; end;
group "unwind"; begin group "unwind"; begin
@ -895,41 +895,41 @@ let test_builder () =
let bb07 = append_block context "Bb07" fn in let bb07 = append_block context "Bb07" fn in
let b = builder_at_end context bb07 in let b = builder_at_end context bb07 in
(* RUN: grep {Inst03.*add.*P1.*P2} < %t.ll (* RUN: grep {%build_add = add i32 %P1, %P2} < %t.ll
* RUN: grep {Inst04.*sub.*P1.*Inst03} < %t.ll * RUN: grep {%build_sub = sub i32 %P1, %P2} < %t.ll
* RUN: grep {Inst05.*mul.*P1.*Inst04} < %t.ll * RUN: grep {%build_mul = mul i32 %P1, %P2} < %t.ll
* RUN: grep {Inst06.*udiv.*P1.*Inst05} < %t.ll * RUN: grep {%build_udiv = udiv i32 %P1, %P2} < %t.ll
* RUN: grep {Inst07.*sdiv.*P1.*Inst06} < %t.ll * RUN: grep {%build_sdiv = sdiv i32 %P1, %P2} < %t.ll
* RUN: grep {Inst08.*fdiv.*F1.*F2} < %t.ll * RUN: grep {%build_fdiv = fdiv float %F1, %F2} < %t.ll
* RUN: grep {Inst09.*urem.*P1.*Inst07} < %t.ll * RUN: grep {%build_urem = urem i32 %P1, %P2} < %t.ll
* RUN: grep {Inst10.*srem.*P1.*Inst09} < %t.ll * RUN: grep {%build_srem = srem i32 %P1, %P2} < %t.ll
* RUN: grep {Inst11.*frem.*F1.*Inst08} < %t.ll * RUN: grep {%build_frem = frem float %F1, %F2} < %t.ll
* RUN: grep {Inst12.*shl.*P1.*Inst10} < %t.ll * RUN: grep {%build_shl = shl i32 %P1, %P2} < %t.ll
* RUN: grep {Inst13.*lshr.*P1.*Inst12} < %t.ll * RUN: grep {%build_lshl = lshr i32 %P1, %P2} < %t.ll
* RUN: grep {Inst14.*ashr.*P1.*Inst13} < %t.ll * RUN: grep {%build_ashl = ashr i32 %P1, %P2} < %t.ll
* RUN: grep {Inst15.*and.*P1.*Inst14} < %t.ll * RUN: grep {%build_and = and i32 %P1, %P2} < %t.ll
* RUN: grep {Inst16.*or.*P1.*Inst15} < %t.ll * RUN: grep {%build_or = or i32 %P1, %P2} < %t.ll
* RUN: grep {Inst17.*xor.*P1.*Inst16} < %t.ll * RUN: grep {%build_xor = xor i32 %P1, %P2} < %t.ll
* RUN: grep {Inst18.*sub.*0.*Inst17} < %t.ll * RUN: grep {%build_neg = sub i32 0, %P1} < %t.ll
* RUN: grep {Inst19.*xor.*Inst18.*-1} < %t.ll * RUN: grep {%build_not = xor i32 %P1, -1} < %t.ll
*) *)
let inst03 = build_add p1 p2 "Inst03" b in ignore (build_add p1 p2 "build_add" b);
let inst04 = build_sub p1 inst03 "Inst04" b in ignore (build_sub p1 p2 "build_sub" b);
let inst05 = build_mul p1 inst04 "Inst05" b in ignore (build_mul p1 p2 "build_mul" b);
let inst06 = build_udiv p1 inst05 "Inst06" b in ignore (build_udiv p1 p2 "build_udiv" b);
let inst07 = build_sdiv p1 inst06 "Inst07" b in ignore (build_sdiv p1 p2 "build_sdiv" b);
let inst08 = build_fdiv f1 f2 "Inst08" b in ignore (build_fdiv f1 f2 "build_fdiv" b);
let inst09 = build_urem p1 inst07 "Inst09" b in ignore (build_urem p1 p2 "build_urem" b);
let inst10 = build_srem p1 inst09 "Inst10" b in ignore (build_srem p1 p2 "build_srem" b);
ignore(build_frem f1 inst08 "Inst11" b); ignore (build_frem f1 f2 "build_frem" b);
let inst12 = build_shl p1 inst10 "Inst12" b in ignore (build_shl p1 p2 "build_shl" b);
let inst13 = build_lshr p1 inst12 "Inst13" b in ignore (build_lshr p1 p2 "build_lshl" b);
let inst14 = build_ashr p1 inst13 "Inst14" b in ignore (build_ashr p1 p2 "build_ashl" b);
let inst15 = build_and p1 inst14 "Inst15" b in ignore (build_and p1 p2 "build_and" b);
let inst16 = build_or p1 inst15 "Inst16" b in ignore (build_or p1 p2 "build_or" b);
let inst17 = build_xor p1 inst16 "Inst17" b in ignore (build_xor p1 p2 "build_xor" b);
let inst18 = build_neg inst17 "Inst18" b in ignore (build_neg p1 "build_neg" b);
ignore (build_not inst18 "Inst19" b); ignore (build_not p1 "build_not" b);
ignore (build_unreachable b) ignore (build_unreachable b)
end; end;
@ -937,73 +937,71 @@ let test_builder () =
let bb08 = append_block context "Bb08" fn in let bb08 = append_block context "Bb08" fn in
let b = builder_at_end context bb08 in let b = builder_at_end context bb08 in
(* RUN: grep {Inst22.*alloca.*i32 } < %t.ll (* RUN: grep {%build_alloca = alloca i32} < %t.ll
* RUN: grep {Inst23.*alloca.*i32.*P2} < %t.ll * RUN: grep {%build_array_alloca = alloca i32, i32 %P2} < %t.ll
* RUN: grep {Inst25.*load.*Inst23} < %t.ll * RUN: grep {%build_load = load i32\\* %build_array_alloca} < %t.ll
* RUN: grep {store.*P2.*Inst22} < %t.ll * RUN: grep {store i32 %P2, i32\\* %build_alloca} < %t.ll
* RUN: grep {Inst27.*getelementptr.*Inst23.*P2} < %t.ll * RUN: grep {%build_gep = getelementptr i32\\* %build_array_alloca, i32 %P2} < %t.ll
*) *)
let inst22 = build_alloca i32_type "Inst22" b in let alloca = build_alloca i32_type "build_alloca" b in
let inst23 = build_array_alloca i32_type p2 "Inst23" b in let array_alloca = build_array_alloca i32_type p2 "build_array_alloca" b in
ignore(build_load inst23 "Inst25" b); ignore(build_load array_alloca "build_load" b);
ignore(build_store p2 inst22 b); ignore(build_store p2 alloca b);
ignore(build_gep inst23 [| p2 |] "Inst27" b); ignore(build_gep array_alloca [| p2 |] "build_gep" b);
ignore(build_unreachable b) ignore(build_unreachable b)
end; end;
group "casts"; begin group "casts"; begin
let void_ptr = pointer_type i8_type in let void_ptr = pointer_type i8_type in
(* RUN: grep {Inst28.*trunc.*P1.*i8} < %t.ll (* RUN: grep {%build_trunc = trunc i32 %P1 to i8} < %t.ll
* RUN: grep {Inst29.*zext.*Inst28.*i32} < %t.ll * RUN: grep {%build_zext = zext i8 %build_trunc to i32} < %t.ll
* RUN: grep {Inst30.*sext.*Inst29.*i64} < %t.ll * RUN: grep {%build_sext = sext i32 %build_zext to i64} < %t.ll
* RUN: grep {Inst31.*uitofp.*Inst30.*float} < %t.ll * RUN: grep {%build_uitofp = uitofp i64 %build_sext to float} < %t.ll
* RUN: grep {Inst32.*sitofp.*Inst29.*double} < %t.ll * RUN: grep {%build_sitofp = sitofp i32 %build_zext to double} < %t.ll
* RUN: grep {Inst33.*fptoui.*Inst31.*i32} < %t.ll * RUN: grep {%build_fptoui = fptoui float %build_uitofp to i32} < %t.ll
* RUN: grep {Inst34.*fptosi.*Inst32.*i64} < %t.ll * RUN: grep {%build_fptosi = fptosi double %build_sitofp to i64} < %t.ll
* RUN: grep {Inst35.*fptrunc.*Inst32.*float} < %t.ll * RUN: grep {%build_fptrunc = fptrunc double %build_sitofp to float} < %t.ll
* RUN: grep {Inst36.*fpext.*Inst35.*double} < %t.ll * RUN: grep {%build_fpext = fpext float %build_fptrunc to double} < %t.ll
* RUN: grep {Inst37.*inttoptr.*P1.*i8\*} < %t.ll * RUN: grep {%build_inttoptr = inttoptr i32 %P1 to i8\\*} < %t.ll
* RUN: grep {Inst38.*ptrtoint.*Inst37.*i64} < %t.ll * RUN: grep {%build_ptrtoint = ptrtoint i8\\* %build_inttoptr to i64} < %t.ll
* RUN: grep {Inst39.*bitcast.*Inst38.*double} < %t.ll * RUN: grep {%build_bitcast = bitcast i64 %build_ptrtoint to double} < %t.ll
*) *)
let inst28 = build_trunc p1 i8_type "Inst28" atentry in let inst28 = build_trunc p1 i8_type "build_trunc" atentry in
let inst29 = build_zext inst28 i32_type "Inst29" atentry in let inst29 = build_zext inst28 i32_type "build_zext" atentry in
let inst30 = build_sext inst29 i64_type "Inst30" atentry in let inst30 = build_sext inst29 i64_type "build_sext" atentry in
let inst31 = build_uitofp inst30 float_type "Inst31" atentry in let inst31 = build_uitofp inst30 float_type "build_uitofp" atentry in
let inst32 = build_sitofp inst29 double_type "Inst32" atentry in let inst32 = build_sitofp inst29 double_type "build_sitofp" atentry in
ignore(build_fptoui inst31 i32_type "Inst33" atentry); ignore(build_fptoui inst31 i32_type "build_fptoui" atentry);
ignore(build_fptosi inst32 i64_type "Inst34" atentry); ignore(build_fptosi inst32 i64_type "build_fptosi" atentry);
let inst35 = build_fptrunc inst32 float_type "Inst35" atentry in let inst35 = build_fptrunc inst32 float_type "build_fptrunc" atentry in
ignore(build_fpext inst35 double_type "Inst36" atentry); ignore(build_fpext inst35 double_type "build_fpext" atentry);
let inst37 = build_inttoptr p1 void_ptr "Inst37" atentry in let inst37 = build_inttoptr p1 void_ptr "build_inttoptr" atentry in
let inst38 = build_ptrtoint inst37 i64_type "Inst38" atentry in let inst38 = build_ptrtoint inst37 i64_type "build_ptrtoint" atentry in
ignore(build_bitcast inst38 double_type "Inst39" atentry) ignore(build_bitcast inst38 double_type "build_bitcast" atentry)
end; end;
group "comparisons"; begin group "comparisons"; begin
(* RUN: grep {Inst40.*icmp.*ne.*P1.*P2} < %t.ll (* RUN: grep {%build_icmp_ne = icmp ne i32 %P1, %P2} < %t.ll
* RUN: grep {Inst41.*icmp.*sle.*P2.*P1} < %t.ll * RUN: grep {%build_icmp_sle = icmp sle i32 %P2, %P1} < %t.ll
* RUN: grep {Inst42.*fcmp.*false.*F1.*F2} < %t.ll * RUN: grep {%build_icmp_false = fcmp false float %F1, %F2} < %t.ll
* RUN: grep {Inst43.*fcmp.*true.*F2.*F1} < %t.ll * RUN: grep {%build_icmp_true = fcmp true float %F2, %F1} < %t.ll
*) *)
ignore (build_icmp Icmp.Ne p1 p2 "Inst40" atentry); ignore (build_icmp Icmp.Ne p1 p2 "build_icmp_ne" atentry);
ignore (build_icmp Icmp.Sle p2 p1 "Inst41" atentry); ignore (build_icmp Icmp.Sle p2 p1 "build_icmp_sle" atentry);
ignore (build_fcmp Fcmp.False f1 f2 "Inst42" atentry); ignore (build_fcmp Fcmp.False f1 f2 "build_icmp_false" atentry);
ignore (build_fcmp Fcmp.True f2 f1 "Inst43" atentry) ignore (build_fcmp Fcmp.True f2 f1 "build_icmp_true" atentry)
end; end;
group "miscellaneous"; begin group "miscellaneous"; begin
(* RUN: grep {CallInst.*call.*P2.*P1} < %t.ll (* RUN: grep {%build_call = tail call cc63 i32 @.*(i32 signext %P2, i32 %P1)} < %t.ll
* RUN: grep {CallInst.*cc63} < %t.ll * RUN: grep {%build_select = select i1 %build_icmp, i32 %P1, i32 %P2} < %t.ll
* RUN: grep {Inst47.*select.*Inst46.*P1.*P2} < %t.ll * RUN: grep {%build_va_arg = va_arg i8\\*\\* null, i32} < %t.ll
* RUN: grep {Inst48.*va_arg.*null.*i32} < %t.ll * RUN: grep {%build_extractelement = extractelement <4 x i32> %Vec1, i32 %P2} < %t.ll
* RUN: grep {Inst49.*extractelement.*Vec1.*P2} < %t.ll * RUN: grep {%build_insertelement = insertelement <4 x i32> %Vec1, i32 %P1, i32 %P2} < %t.ll
* RUN: grep {Inst50.*insertelement.*Vec1.*P1.*P2} < %t.ll * RUN: grep {%build_shufflevector = shufflevector <4 x i32> %Vec1, <4 x i32> %Vec2, <4 x i32> <i32 1, i32 1, i32 0, i32 0>} < %t.ll
* RUN: grep {Inst51.*shufflevector.*Vec1.*Vec2.*1.*1.*0.*0} < %t.ll
* RUN: grep {CallInst.*tail call} < %t.ll
*) *)
let ci = build_call fn [| p2; p1 |] "CallInst" atentry in let ci = build_call fn [| p2; p1 |] "build_call" atentry in
insist (CallConv.c = instruction_call_conv ci); insist (CallConv.c = instruction_call_conv ci);
set_instruction_call_conv 63 ci; set_instruction_call_conv 63 ci;
insist (63 = instruction_call_conv ci); insist (63 = instruction_call_conv ci);
@ -1014,11 +1012,11 @@ let test_builder () =
add_instruction_param_attr ci 2 Attribute.Noalias; add_instruction_param_attr ci 2 Attribute.Noalias;
remove_instruction_param_attr ci 2 Attribute.Noalias; remove_instruction_param_attr ci 2 Attribute.Noalias;
let inst46 = build_icmp Icmp.Eq p1 p2 "Inst46" atentry in let inst46 = build_icmp Icmp.Eq p1 p2 "build_icmp" atentry in
ignore (build_select inst46 p1 p2 "Inst47" atentry); ignore (build_select inst46 p1 p2 "build_select" atentry);
ignore (build_va_arg ignore (build_va_arg
(const_null (pointer_type (pointer_type i8_type))) (const_null (pointer_type (pointer_type i8_type)))
i32_type "Inst48" atentry); i32_type "build_va_arg" atentry);
(* Set up some vector vregs. *) (* Set up some vector vregs. *)
let one = const_int i32_type 1 in let one = const_int i32_type 1 in
@ -1029,9 +1027,9 @@ let test_builder () =
let vec1 = build_insertelement t1 p1 p2 "Vec1" atentry in let vec1 = build_insertelement t1 p1 p2 "Vec1" atentry in
let vec2 = build_insertelement t2 p1 p2 "Vec2" atentry in let vec2 = build_insertelement t2 p1 p2 "Vec2" atentry in
ignore (build_extractelement vec1 p2 "Inst49" atentry); ignore (build_extractelement vec1 p2 "build_extractelement" atentry);
ignore (build_insertelement vec1 p1 p2 "Inst50" atentry); ignore (build_insertelement vec1 p1 p2 "build_insertelement" atentry);
ignore (build_shufflevector vec1 vec2 t3 "Inst51" atentry); ignore (build_shufflevector vec1 vec2 t3 "build_shufflevector" atentry);
end; end;
group "phi"; begin group "phi"; begin