[PATCH] D136914: [llvm][ocaml] Remove or replace OCaml functions with deprecated C counterparts

Alan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 27 21:17:51 PDT 2022


alan created this revision.
Herald added a project: All.
alan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D136914

Files:
  llvm/bindings/ocaml/llvm/llvm.ml
  llvm/bindings/ocaml/llvm/llvm.mli
  llvm/bindings/ocaml/llvm/llvm_ocaml.c
  llvm/test/Bindings/OCaml/core.ml


Index: llvm/test/Bindings/OCaml/core.ml
===================================================================
--- llvm/test/Bindings/OCaml/core.ml
+++ llvm/test/Bindings/OCaml/core.ml
@@ -185,8 +185,6 @@
   let c = const_array i32_type [| three; four |] in
   ignore (define_global "const_array" c m);
   insist ((array_type i32_type 2) = (type_of c));
-  insist (three = (const_element c 0));
-  insist (four = (const_element c 1));
 
   (* CHECK: const_vector{{.*}}<i16 1, i16 2{{.*}}>
    *)
Index: llvm/bindings/ocaml/llvm/llvm_ocaml.c
===================================================================
--- llvm/bindings/ocaml/llvm/llvm_ocaml.c
+++ llvm/bindings/ocaml/llvm/llvm_ocaml.c
@@ -968,11 +968,6 @@
   return cstr_to_string_option(CStr, Len);
 }
 
-/* llvalue -> int -> llvalue */
-LLVMValueRef llvm_const_element(LLVMValueRef Const, value N) {
-  return LLVMGetElementAsConstant(Const, Int_val(N));
-}
-
 /*--... Constant expressions ...............................................--*/
 
 /* Icmp.t -> llvalue -> llvalue -> llvalue */
@@ -995,9 +990,10 @@
 }
 
 /* llvalue -> llvalue array -> llvalue */
-LLVMValueRef llvm_const_in_bounds_gep(LLVMValueRef ConstantVal, value Indices) {
-  return LLVMConstInBoundsGEP(ConstantVal, (LLVMValueRef *)Op_val(Indices),
-                              Wosize_val(Indices));
+LLVMValueRef llvm_const_in_bounds_gep(LLVMTypeRef Ty, LLVMValueRef ConstantVal,
+                                      value Indices) {
+  return LLVMConstInBoundsGEP2(Ty, ConstantVal, (LLVMValueRef *)Op_val(Indices),
+                               Wosize_val(Indices));
 }
 
 /* llvalue -> lltype -> is_signed:bool -> llvalue */
Index: llvm/bindings/ocaml/llvm/llvm.mli
===================================================================
--- llvm/bindings/ocaml/llvm/llvm.mli
+++ llvm/bindings/ocaml/llvm/llvm.mli
@@ -1044,10 +1044,6 @@
     or [None] if this is not a string constant. *)
 val string_of_const : llvalue -> string option
 
-(** [const_element c] returns a constant for a specified index's element.
-    See the method ConstantDataSequential::getElementAsConstant. *)
-val const_element : llvalue -> int -> llvalue
-
 
 (** {7 Constant expressions} *)
 
@@ -1169,10 +1165,10 @@
     See the method [llvm::ConstantExpr::getGetElementPtr]. *)
 val const_gep : lltype -> llvalue -> llvalue array -> llvalue
 
-(** [const_in_bounds_gep pc indices] returns the constant [getElementPtr] of [pc]
-    with the constant integers indices from the array [indices].
+(** [const_in_bounds_gep ty pc indices] returns the constant [getElementPtr] of
+    [pc] with the constant integers indices from the array [indices].
     See the method [llvm::ConstantExpr::getInBoundsGetElementPtr]. *)
-val const_in_bounds_gep : llvalue -> llvalue array -> llvalue
+val const_in_bounds_gep : lltype -> llvalue -> llvalue array -> llvalue
 
 (** [const_trunc c ty] returns the constant truncation of integer constant [c]
     to the smaller integer type [ty].
Index: llvm/bindings/ocaml/llvm/llvm.ml
===================================================================
--- llvm/bindings/ocaml/llvm/llvm.ml
+++ llvm/bindings/ocaml/llvm/llvm.ml
@@ -629,7 +629,6 @@
                              = "llvm_const_packed_struct"
 external const_vector : llvalue array -> llvalue = "llvm_const_vector"
 external string_of_const : llvalue -> string option = "llvm_string_of_const"
-external const_element : llvalue -> int -> llvalue = "llvm_const_element"
 
 (*--... Constant expressions ...............................................--*)
 external align_of : lltype -> llvalue = "LLVMAlignOf"
@@ -659,8 +658,8 @@
 external const_ashr : llvalue -> llvalue -> llvalue = "LLVMConstAShr"
 external const_gep : lltype -> llvalue -> llvalue array -> llvalue
                     = "llvm_const_gep"
-external const_in_bounds_gep : llvalue -> llvalue array -> llvalue
-                            = "llvm_const_in_bounds_gep"
+external const_in_bounds_gep : lltype -> llvalue -> llvalue array -> llvalue
+                             = "llvm_const_in_bounds_gep"
 external const_trunc : llvalue -> lltype -> llvalue = "LLVMConstTrunc"
 external const_sext : llvalue -> lltype -> llvalue = "LLVMConstSExt"
 external const_zext : llvalue -> lltype -> llvalue = "LLVMConstZExt"


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D136914.471392.patch
Type: text/x-patch
Size: 4281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221028/6bb04b2a/attachment.bin>


More information about the llvm-commits mailing list