Please use GitHub pull requests for new patches. Avoid migrating existing patches. Phabricator shutdown timeline
Changeset View
Changeset View
Standalone View
Standalone View
llvm/test/Bindings/OCaml/core.ml
Show All 28 Lines | |||||
let double_type = Llvm.double_type context | let double_type = Llvm.double_type context | ||||
let fp128_type = Llvm.fp128_type context | let fp128_type = Llvm.fp128_type context | ||||
(*===-- Fixture -----------------------------------------------------------===*) | (*===-- Fixture -----------------------------------------------------------===*) | ||||
let filename = Sys.argv.(1) | let filename = Sys.argv.(1) | ||||
let m = create_module context filename | let m = create_module context filename | ||||
(*===-- Modules ----------------------------------------------------------===*) | |||||
let test_modules () = | |||||
insist (module_context m = context) | |||||
(*===-- Contained types --------------------------------------------------===*) | (*===-- Contained types --------------------------------------------------===*) | ||||
let test_contained_types () = | let test_contained_types () = | ||||
let ar = struct_type context [| i32_type; i8_type |] in | let ar = struct_type context [| i32_type; i8_type |] in | ||||
insist (i32_type = (Array.get (subtypes ar)) 0); | insist (i32_type = (Array.get (subtypes ar)) 0); | ||||
insist (i8_type = (Array.get (subtypes ar)) 1) | insist (i8_type = (Array.get (subtypes ar)) 1) | ||||
(*===-- Pointer types ----------------------------------------------------===*) | (*===-- Pointer types ----------------------------------------------------===*) | ||||
▲ Show 20 Lines • Show All 135 Lines • ▼ Show 20 Lines | let test_constants () = | ||||
let four = const_int i32_type 4 in | let four = const_int i32_type 4 in | ||||
(* CHECK: const_array{{.*}}[i32 3, i32 4] | (* CHECK: const_array{{.*}}[i32 3, i32 4] | ||||
*) | *) | ||||
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 "const_array" 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)); | ||||
insist (element_type (type_of c) = i32_type); | |||||
insist (Some three = (aggregate_element c 0)); | insist (Some three = (aggregate_element c 0)); | ||||
insist (Some four = (aggregate_element c 1)); | insist (Some four = (aggregate_element c 1)); | ||||
insist (None = (aggregate_element c 2)); | insist (None = (aggregate_element c 2)); | ||||
(* CHECK: const_vector{{.*}}<i16 1, i16 2{{.*}}> | (* CHECK: const_vector{{.*}}<i16 1, i16 2{{.*}}> | ||||
*) | *) | ||||
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 "const_vector" 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)); | ||||
insist (element_type (type_of c) = i16_type); | |||||
(* CHECK: const_structure{{.*.}}i16 1, i16 2, i32 3, i32 4 | (* CHECK: const_structure{{.*.}}i16 1, i16 2, i32 3, i32 4 | ||||
*) | *) | ||||
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 "const_structure" 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)); | ||||
▲ Show 20 Lines • Show All 1,295 Lines • ▼ Show 20 Lines | let test_writer () = | ||||
insist (write_bitcode_file m filename); | insist (write_bitcode_file m filename); | ||||
dispose_module m | dispose_module m | ||||
(*===-- Driver ------------------------------------------------------------===*) | (*===-- Driver ------------------------------------------------------------===*) | ||||
let _ = | let _ = | ||||
suite "modules" test_modules; | |||||
suite "contained types" test_contained_types; | suite "contained types" test_contained_types; | ||||
suite "pointer types" test_pointer_types; | suite "pointer types" test_pointer_types; | ||||
suite "conversion" test_conversion; | suite "conversion" test_conversion; | ||||
suite "target" test_target; | suite "target" test_target; | ||||
suite "constants" test_constants; | suite "constants" test_constants; | ||||
suite "attributes" test_attributes; | suite "attributes" test_attributes; | ||||
suite "global values" test_global_values; | suite "global values" test_global_values; | ||||
suite "global variables" test_global_variables; | suite "global variables" test_global_variables; | ||||
Show All 12 Lines |