[llvm-commits] [llvm] r42701 - in /llvm/trunk: bindings/ocaml/llvm/llvm.ml bindings/ocaml/llvm/llvm.mli bindings/ocaml/llvm/llvm_ocaml.c test/Bindings/Ocaml/vmcore.ml

Gordon Henriksen gordonhenriksen at mac.com
Sat Oct 6 09:56:09 PDT 2007


Author: gordon
Date: Sat Oct  6 11:56:09 2007
New Revision: 42701

URL: http://llvm.org/viewvc/llvm-project?rev=42701&view=rev
Log:
Adopting a uniform naming convention for type constructors in
bindings (part le deux).

Modified:
    llvm/trunk/bindings/ocaml/llvm/llvm.ml
    llvm/trunk/bindings/ocaml/llvm/llvm.mli
    llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
    llvm/trunk/test/Bindings/Ocaml/vmcore.ml

Modified: llvm/trunk/bindings/ocaml/llvm/llvm.ml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.ml?rev=42701&r1=42700&r2=42701&view=diff

==============================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm.ml (original)
+++ llvm/trunk/bindings/ocaml/llvm/llvm.ml Sat Oct  6 11:56:09 2007
@@ -128,7 +128,7 @@
 let i32_type = _i32_type ()
 let i64_type = _i64_type ()
 
-external make_integer_type : int -> lltype = "llvm_make_integer_type"
+external integer_type : int -> lltype = "llvm_integer_type"
 external integer_bitwidth : lltype -> int = "llvm_integer_bitwidth"
 
 (*--... Operations on real types ...........................................--*)
@@ -146,29 +146,30 @@
 
 (*--... Operations on function types .......................................--*)
 (* FIXME: handle parameter attributes *)
-external make_function_type : lltype -> lltype array -> bool -> lltype
-                            = "llvm_make_function_type"
+external function_type : lltype -> lltype array -> lltype = "llvm_function_type"
+external var_arg_function_type : lltype -> lltype array -> lltype
+                               = "llvm_var_arg_function_type"
 external is_var_arg : lltype -> bool = "llvm_is_var_arg"
 external return_type : lltype -> lltype = "llvm_return_type"
 external param_types : lltype -> lltype array = "llvm_param_types"
 
 (*--... Operations on struct types .........................................--*)
-external make_struct_type : lltype array -> bool -> lltype
-                          = "llvm_make_struct_type"
+external struct_type : lltype array -> lltype = "llvm_struct_type"
+external packed_struct_type : lltype array -> lltype = "llvm_packed_struct_type"
 external element_types : lltype -> lltype array = "llvm_element_types"
 external is_packed : lltype -> bool = "llvm_is_packed"
 
 (*--... Operations on pointer, vector, and array types .....................--*)
-external make_array_type : lltype -> int -> lltype = "llvm_make_array_type"
-external make_pointer_type : lltype -> lltype = "llvm_make_pointer_type"
-external make_vector_type : lltype -> int -> lltype = "llvm_make_vector_type"
+external array_type : lltype -> int -> lltype = "llvm_array_type"
+external pointer_type : lltype -> lltype = "llvm_pointer_type"
+external vector_type : lltype -> int -> lltype = "llvm_vector_type"
 
 external element_type : lltype -> lltype = "llvm_element_type"
 external array_length : lltype -> int = "llvm_array_length"
 external vector_size : lltype -> int = "llvm_vector_size"
 
 (*--... Operations on other types ..........................................--*)
-external make_opaque_type : unit -> lltype = "llvm_make_opaque_type"
+external opaque_type : unit -> lltype = "llvm_opaque_type"
 external _void_type : unit -> lltype = "llvm_void_type"
 external _label_type : unit -> lltype = "llvm_label_type"
 

Modified: llvm/trunk/bindings/ocaml/llvm/llvm.mli
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm.mli?rev=42701&r1=42700&r2=42701&view=diff

==============================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm.mli (original)
+++ llvm/trunk/bindings/ocaml/llvm/llvm.mli Sat Oct  6 11:56:09 2007
@@ -121,7 +121,7 @@
 val i16_type : lltype
 val i32_type : lltype
 val i64_type : lltype
-external make_integer_type : int -> lltype = "llvm_make_integer_type"
+external integer_type : int -> lltype = "llvm_integer_type"
 external integer_bitwidth : lltype -> int = "llvm_integer_bitwidth"
 
 (*--... Operations on real types ...........................................--*)
@@ -133,29 +133,30 @@
 
 (*--... Operations on function types .......................................--*)
 (* FIXME: handle parameter attributes                                         *)
-external make_function_type : lltype -> lltype array -> bool -> lltype
-                            = "llvm_make_function_type"
+external function_type : lltype -> lltype array -> lltype = "llvm_function_type"
+external var_arg_function_type : lltype -> lltype array -> lltype
+                               = "llvm_var_arg_function_type"
 external is_var_arg : lltype -> bool = "llvm_is_var_arg"
 external return_type : lltype -> lltype = "llvm_return_type"
 external param_types : lltype -> lltype array = "llvm_param_types"
 
 (*--... Operations on struct types .........................................--*)
-external make_struct_type : lltype array -> bool -> lltype
-                          = "llvm_make_struct_type"
+external struct_type : lltype array -> lltype = "llvm_struct_type"
+external packed_struct_type : lltype array -> lltype = "llvm_packed_struct_type"
 external element_types : lltype -> lltype array = "llvm_element_types"
 external is_packed : lltype -> bool = "llvm_is_packed"
 
 (*--... Operations on pointer, vector, and array types .....................--*)
-external make_array_type : lltype -> int -> lltype = "llvm_make_array_type"
-external make_pointer_type : lltype -> lltype = "llvm_make_pointer_type"
-external make_vector_type : lltype -> int -> lltype = "llvm_make_vector_type"
+external array_type : lltype -> int -> lltype = "llvm_array_type"
+external pointer_type : lltype -> lltype = "llvm_pointer_type"
+external vector_type : lltype -> int -> lltype = "llvm_vector_type"
 
 external element_type : lltype -> lltype = "llvm_element_type"
 external array_length : lltype -> int = "llvm_array_length"
 external vector_size : lltype -> int = "llvm_vector_size"
 
 (*--... Operations on other types ..........................................--*)
-external make_opaque_type : unit -> lltype = "llvm_make_opaque_type"
+external opaque_type : unit -> lltype = "llvm_opaque_type"
 val void_type : lltype
 val label_type : lltype
 

Modified: llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c?rev=42701&r1=42700&r2=42701&view=diff

==============================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c (original)
+++ llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Sat Oct  6 11:56:09 2007
@@ -73,7 +73,7 @@
 CAMLprim LLVMTypeRef llvm_i64_type(value Unit) { return LLVMInt64Type(); }
 
 /* int -> lltype */
-CAMLprim LLVMTypeRef llvm_make_integer_type(value Width) {
+CAMLprim LLVMTypeRef llvm_integer_type(value Width) {
   return LLVMIntType(Int_val(Width));
 }
 
@@ -111,12 +111,17 @@
 
 /*--... Operations on function types .......................................--*/
 
-/* lltype -> lltype array -> bool -> lltype */
-CAMLprim LLVMTypeRef llvm_make_function_type(LLVMTypeRef RetTy, value ParamTys,
-                                             value IsVarArg) {
+/* lltype -> lltype array -> lltype */
+CAMLprim LLVMTypeRef llvm_function_type(LLVMTypeRef RetTy, value ParamTys) {
   return LLVMFunctionType(RetTy, (LLVMTypeRef *) ParamTys,
-                          Wosize_val(ParamTys),
-                          Bool_val(IsVarArg));
+                          Wosize_val(ParamTys), 0);
+}
+
+/* lltype -> lltype array -> lltype */
+CAMLprim LLVMTypeRef llvm_var_arg_function_type(LLVMTypeRef RetTy,
+                                                value ParamTys) {
+  return LLVMFunctionType(RetTy, (LLVMTypeRef *) ParamTys,
+                          Wosize_val(ParamTys), 1);
 }
 
 /* lltype -> bool */
@@ -138,11 +143,16 @@
 
 /*--... Operations on struct types .........................................--*/
 
-/* lltype array -> bool -> lltype */
-CAMLprim LLVMTypeRef llvm_make_struct_type(value ElementTypes, value Packed) {
+/* lltype array -> lltype */
+CAMLprim LLVMTypeRef llvm_struct_type(value ElementTypes) {
+  return LLVMStructType((LLVMTypeRef *) ElementTypes,
+                        Wosize_val(ElementTypes), 0);
+}
+
+/* lltype array -> lltype */
+CAMLprim LLVMTypeRef llvm_packed_struct_type(value ElementTypes) {
   return LLVMStructType((LLVMTypeRef *) ElementTypes,
-                        Wosize_val(ElementTypes),
-                        Bool_val(Packed));
+                        Wosize_val(ElementTypes), 1);
 }
 
 /* lltype -> lltype array */
@@ -160,17 +170,17 @@
 /*--... Operations on array, pointer, and vector types .....................--*/
 
 /* lltype -> int -> lltype */
-CAMLprim LLVMTypeRef llvm_make_array_type(LLVMTypeRef ElementTy, value Count) {
+CAMLprim LLVMTypeRef llvm_array_type(LLVMTypeRef ElementTy, value Count) {
   return LLVMArrayType(ElementTy, Int_val(Count));
 }
 
 /* lltype -> lltype */
-CAMLprim LLVMTypeRef llvm_make_pointer_type(LLVMTypeRef ElementTy) {
+CAMLprim LLVMTypeRef llvm_pointer_type(LLVMTypeRef ElementTy) {
   return LLVMPointerType(ElementTy);
 }
 
 /* lltype -> int -> lltype */
-CAMLprim LLVMTypeRef llvm_make_vector_type(LLVMTypeRef ElementTy, value Count) {
+CAMLprim LLVMTypeRef llvm_vector_type(LLVMTypeRef ElementTy, value Count) {
   return LLVMVectorType(ElementTy, Int_val(Count));
 }
 
@@ -196,7 +206,7 @@
 CAMLprim LLVMTypeRef llvm_label_type(value Unit) { return LLVMLabelType(); }
 
 /* unit -> lltype */
-CAMLprim LLVMTypeRef llvm_make_opaque_type(value Unit) {
+CAMLprim LLVMTypeRef llvm_opaque_type(value Unit) {
   return LLVMOpaqueType();
 }
 

Modified: llvm/trunk/test/Bindings/Ocaml/vmcore.ml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Ocaml/vmcore.ml?rev=42701&r1=42700&r2=42701&view=diff

==============================================================================
--- llvm/trunk/test/Bindings/Ocaml/vmcore.ml (original)
+++ llvm/trunk/test/Bindings/Ocaml/vmcore.ml Sat Oct  6 11:56:09 2007
@@ -61,7 +61,7 @@
   (* RUN: grep {Ty04.*i42} < %t.ll
    *)
   group "i42";
-  let ty = make_integer_type 42 in
+  let ty = integer_type 42 in
   insist (define_type_name "Ty04" ty m);
 
   (* RUN: grep {Ty05.*float} < %t.ll
@@ -79,7 +79,7 @@
   (* RUN: grep {Ty07.*i32.*i1, double} < %t.ll
    *)
   group "function";
-  let ty = make_function_type i32_type [| i1_type; double_type |] false in
+  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 (not (is_var_arg ty));
@@ -88,15 +88,15 @@
   
   (* RUN: grep {Ty08.*\.\.\.} < %t.ll
    *)
-  group "vararg";
-  let ty = make_function_type void_type [| i32_type |] true in
+  group "var arg function";
+  let ty = var_arg_function_type void_type [| i32_type |] in
   insist (define_type_name "Ty08" ty m);
   insist (is_var_arg ty);
   
   (* RUN: grep {Ty09.*\\\[7 x i8\\\]} < %t.ll
    *)
   group "array";
-  let ty = make_array_type i8_type 7 in
+  let ty = array_type i8_type 7 in
   insist (define_type_name "Ty09" ty m);
   insist (7 = array_length ty);
   insist (i8_type == element_type ty);
@@ -105,7 +105,7 @@
   (* RUN: grep {Ty10.*float\*} < %t.ll
    *)
   group "pointer";
-  let ty = make_pointer_type float_type in
+  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);
@@ -113,7 +113,7 @@
   (* RUN: grep {Ty11.*\<4 x i16\>} < %t.ll
    *)
   group "vector";
-  let ty = make_vector_type i16_type 4 in
+  let ty = vector_type i16_type 4 in
   insist (define_type_name "Ty11" ty m);
   insist (i16_type == element_type ty);
   insist (4 = vector_size ty);
@@ -121,15 +121,15 @@
   (* RUN: grep {Ty12.*opaque} < %t.ll
    *)
   group "opaque";
-  let ty = make_opaque_type () in
+  let ty = opaque_type () in
   insist (define_type_name "Ty12" ty m);
   insist (ty == ty);
-  insist (ty <> make_opaque_type ());
+  insist (ty <> opaque_type ());
   
   (* RUN: grep -v {Ty13} < %t.ll
    *)
   group "delete";
-  let ty = make_opaque_type () in
+  let ty = opaque_type () in
   insist (define_type_name "Ty13" ty m);
   delete_type_name "Ty13" m
 
@@ -164,14 +164,14 @@
   group "string";
   let c = const_string "cruel\000world" in
   ignore (define_global "Const04" c m);
-  insist ((make_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
    *)
   group "stringz";
   let c = const_stringz "hi\000again" in
   ignore (define_global "Const05" c m);
-  insist ((make_array_type i8_type 9) = type_of c);
+  insist ((array_type i8_type 9) = type_of c);
 
   (* RUN: grep {Const06.*3.1459} < %t.ll
    *)
@@ -190,7 +190,7 @@
   group "array";
   let c = const_array i32_type [| three; four |] in
   ignore (define_global "Const07" c m);
-  insist ((make_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
    *)
@@ -198,21 +198,21 @@
   let c = const_vector [| one; two; one; two;
                           one; two; one; two |] in
   ignore (define_global "Const08" c m);
-  insist ((make_vector_type i16_type 8) = (type_of c));
+  insist ((vector_type i16_type 8) = (type_of c));
   
   (* RUN: grep {Const09.*\{ i16, i16, i32, i32 \} \{} < %t.ll
    *)
   group "structure";
   let c = const_struct [| one; two; three; four |] in
   ignore (define_global "Const09" c m);
-  insist ((make_struct_type [| i16_type; i16_type; i32_type; i32_type |] false)
+  insist ((struct_type [| i16_type; i16_type; i32_type; i32_type |])
         = (type_of c));
   
   (* RUN: grep {Const10.*zeroinit} < %t.ll
    *)
   group "null";
-  let c = const_null (make_struct_type [| i1_type; i8_type;
-                                          i64_type; double_type |] true) in
+  let c = const_null (packed_struct_type [| i1_type; i8_type;
+                                            i64_type; double_type |]) in
   ignore (define_global "Const10" c m);
   
   (* RUN: grep {Const11.*-1} < %t.ll
@@ -247,7 +247,7 @@
    * RUN: grep {ConstICmp.*icmp} < %t.ll
    * RUN: grep {ConstFCmp.*fcmp} < %t.ll
    *)
-  let void_ptr = make_pointer_type i8_type in
+  let void_ptr = pointer_type i8_type in
   let five = const_int i64_type 5 in
   let ffive = const_uitofp five double_type in
   let foldbomb_gv = define_global "FoldBomb" (const_null i8_type) m in
@@ -284,7 +284,7 @@
    * RUN: grep {ConstIntToPtr.*inttoptr} < %t.ll
    * RUN: grep {ConstBitCast.*bitcast} < %t.ll
    *)
-  let i128_type = make_integer_type 128 in
+  let i128_type = integer_type 128 in
   ignore (define_global "ConstTrunc" (const_trunc (const_add foldbomb five)
                                                i8_type) m);
   ignore (define_global "ConstSExt" (const_sext foldbomb i128_type) m);
@@ -296,7 +296,7 @@
   ignore (define_global "ConstFPToUI" (const_fptoui ffoldbomb i32_type) m);
   ignore (define_global "ConstFPToSI" (const_fptosi ffoldbomb i32_type) m);
   ignore (define_global "ConstPtrToInt" (const_ptrtoint 
-    (const_gep (const_null (make_pointer_type i8_type))
+    (const_gep (const_null (pointer_type i8_type))
                [| const_int i32_type 1 |])
     i32_type) m);
   ignore (define_global "ConstIntToPtr" (const_inttoptr (const_add foldbomb five)
@@ -311,7 +311,7 @@
    * RUN: grep {ConstInsertElement.*insertelement} < %t.ll
    * RUN: grep {ConstShuffleVector.*shufflevector} < %t.ll
    *)
-  ignore (define_global "ConstSizeOf" (size_of (make_pointer_type i8_type)) m);
+  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)
@@ -328,7 +328,7 @@
   ignore (define_global "ConstShuffleVector" (const_shufflevector
     (const_vector [| zero; one |])
     (const_vector [| one; zero |])
-    (const_bitcast foldbomb (make_vector_type i32_type 2))) m)
+    (const_bitcast foldbomb (vector_type i32_type 2))) m)
 
 
 (*===-- Global Values -----------------------------------------------------===*)
@@ -414,8 +414,8 @@
 (*===-- Functions ---------------------------------------------------------===*)
 
 let test_functions () =
-  let ty = make_function_type i32_type [| i32_type; i64_type |] false in
-  let pty = make_pointer_type ty in
+  let ty = function_type i32_type [| i32_type; i64_type |] in
+  let pty = pointer_type ty in
   
   (* RUN: grep {declare i32 @Fn1\(i32, i64\)} < %t.ll
    *)
@@ -465,7 +465,7 @@
 (*===-- Basic Blocks ------------------------------------------------------===*)
 
 let test_basic_blocks () =
-  let ty = make_function_type void_type [| |] false in
+  let ty = function_type void_type [| |] in
   
   (* RUN: grep {Bb1} < %t.ll
    *)
@@ -513,14 +513,14 @@
   begin
     (* RUN: grep {ret void} < %t.ll
      *)
-    let fty = make_function_type void_type [| |] false in
+    let fty = function_type void_type [| |] in
     let fn = declare_function "X6" fty m in
     let b = builder_at_end (append_block "Bb01" fn) in
     ignore (build_ret_void b)
   end;
   
   (* The rest of the tests will use one big function. *)
-  let fty = make_function_type i32_type [| i32_type; i32_type |] false in
+  let fty = function_type i32_type [| i32_type; i32_type |] in
   let fn = define_function "X7" fty m in
   let atentry = builder_at_end (entry_block fn) in
   let p1 = param fn 0 ++ set_value_name "P1" in
@@ -647,7 +647,7 @@
   end;
   
   group "casts"; begin
-    let void_ptr = make_pointer_type i8_type in
+    let void_ptr = pointer_type i8_type in
     
     (* RUN: grep {Inst28.*trunc.*P1.*i8} < %t.ll
      * RUN: grep {Inst29.*zext.*Inst28.*i32} < %t.ll
@@ -703,7 +703,7 @@
     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 (make_pointer_type (make_pointer_type i8_type)))
+                  (const_null (pointer_type (pointer_type i8_type)))
                   i32_type "Inst48" atentry);
     
     (* Set up some vector vregs. *)





More information about the llvm-commits mailing list