Skip to content

Commit d226244

Browse files
alan-j-huaeubanks
authored andcommitted
[llvm-ocaml] Replace all typed pointer functions with opaque pointer functions
Reviewed By: aeubanks Differential Revision: https://reviews.llvm.org/D135524
1 parent f2b73f5 commit d226244

File tree

7 files changed

+114
-269
lines changed

7 files changed

+114
-269
lines changed

llvm/bindings/ocaml/llvm/llvm.ml

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -505,11 +505,9 @@ external is_literal : lltype -> bool = "llvm_is_literal"
505505

506506
external subtypes : lltype -> lltype array = "llvm_subtypes"
507507
external array_type : lltype -> int -> lltype = "llvm_array_type"
508-
external pointer_type : lltype -> lltype = "llvm_pointer_type"
509-
external qualified_pointer_type : lltype -> int -> lltype
508+
external pointer_type : llcontext -> lltype = "llvm_pointer_type"
509+
external qualified_pointer_type : llcontext -> int -> lltype
510510
= "llvm_qualified_pointer_type"
511-
external pointer_type_in_context : llcontext -> int -> lltype
512-
= "llvm_pointer_type_in_context"
513511
external vector_type : lltype -> int -> lltype = "llvm_vector_type"
514512

515513
external element_type : lltype -> lltype = "LLVMGetElementType"
@@ -659,9 +657,8 @@ external const_fcmp : Fcmp.t -> llvalue -> llvalue -> llvalue
659657
external const_shl : llvalue -> llvalue -> llvalue = "LLVMConstShl"
660658
external const_lshr : llvalue -> llvalue -> llvalue = "LLVMConstLShr"
661659
external const_ashr : llvalue -> llvalue -> llvalue = "LLVMConstAShr"
662-
external const_gep : llvalue -> llvalue array -> llvalue = "llvm_const_gep"
663-
external const_gep2 : lltype -> llvalue -> llvalue array -> llvalue
664-
= "llvm_const_gep2"
660+
external const_gep : lltype -> llvalue -> llvalue array -> llvalue
661+
= "llvm_const_gep"
665662
external const_in_bounds_gep : llvalue -> llvalue array -> llvalue
666663
= "llvm_const_in_bounds_gep"
667664
external const_trunc : llvalue -> lltype -> llvalue = "LLVMConstTrunc"
@@ -798,12 +795,9 @@ let fold_right_globals f m init =
798795
fold_right_global_range f (global_end m) (At_start m) init
799796

800797
(*--... Operations on aliases ..............................................--*)
801-
external add_alias : llmodule -> lltype -> llvalue -> string -> llvalue
798+
external add_alias : llmodule -> lltype -> int -> llvalue -> string -> llvalue
802799
= "llvm_add_alias"
803800

804-
external add_alias2 : llmodule -> lltype -> int -> llvalue -> string -> llvalue
805-
= "llvm_add_alias2"
806-
807801
(*--... Operations on functions ............................................--*)
808802
external declare_function : string -> lltype -> llmodule -> llvalue
809803
= "llvm_declare_function"
@@ -1212,12 +1206,9 @@ external build_indirect_br : llvalue -> int -> llbuilder -> llvalue
12121206
= "llvm_build_indirect_br"
12131207
external add_destination : llvalue -> llbasicblock -> unit
12141208
= "llvm_add_destination"
1215-
external build_invoke : llvalue -> llvalue array -> llbasicblock ->
1209+
external build_invoke : lltype -> llvalue -> llvalue array -> llbasicblock ->
12161210
llbasicblock -> string -> llbuilder -> llvalue
12171211
= "llvm_build_invoke_bc" "llvm_build_invoke_nat"
1218-
external build_invoke2 : lltype -> llvalue -> llvalue array -> llbasicblock ->
1219-
llbasicblock -> string -> llbuilder -> llvalue
1220-
= "llvm_build_invoke2_bc" "llvm_build_invoke2_nat"
12211212
external build_landingpad : lltype -> llvalue -> int -> string -> llbuilder ->
12221213
llvalue = "llvm_build_landingpad"
12231214
external is_cleanup : llvalue -> bool = "llvm_is_cleanup"
@@ -1293,29 +1284,21 @@ external build_alloca : lltype -> string -> llbuilder -> llvalue
12931284
= "llvm_build_alloca"
12941285
external build_array_alloca : lltype -> llvalue -> string -> llbuilder ->
12951286
llvalue = "llvm_build_array_alloca"
1296-
external build_load : llvalue -> string -> llbuilder -> llvalue
1287+
external build_load : lltype -> llvalue -> string -> llbuilder -> llvalue
12971288
= "llvm_build_load"
1298-
external build_load2 : lltype -> llvalue -> string -> llbuilder -> llvalue
1299-
= "llvm_build_load2"
13001289
external build_store : llvalue -> llvalue -> llbuilder -> llvalue
13011290
= "llvm_build_store"
13021291
external build_atomicrmw : AtomicRMWBinOp.t -> llvalue -> llvalue ->
13031292
AtomicOrdering.t -> bool -> string -> llbuilder ->
13041293
llvalue
13051294
= "llvm_build_atomicrmw_bytecode"
13061295
"llvm_build_atomicrmw_native"
1307-
external build_gep : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1308-
= "llvm_build_gep"
1309-
external build_gep2 : lltype -> llvalue -> llvalue array -> string -> llbuilder
1310-
-> llvalue = "llvm_build_gep2"
1311-
external build_in_bounds_gep : llvalue -> llvalue array -> string ->
1296+
external build_gep : lltype -> llvalue -> llvalue array -> string -> llbuilder
1297+
-> llvalue = "llvm_build_gep"
1298+
external build_in_bounds_gep : lltype -> llvalue -> llvalue array -> string ->
13121299
llbuilder -> llvalue = "llvm_build_in_bounds_gep"
1313-
external build_in_bounds_gep2 : lltype -> llvalue -> llvalue array -> string ->
1314-
llbuilder -> llvalue = "llvm_build_in_bounds_gep2"
1315-
external build_struct_gep : llvalue -> int -> string -> llbuilder -> llvalue
1316-
= "llvm_build_struct_gep"
1317-
external build_struct_gep2 : lltype -> llvalue -> int -> string -> llbuilder ->
1318-
llvalue = "llvm_build_struct_gep2"
1300+
external build_struct_gep : lltype -> llvalue -> int -> string -> llbuilder ->
1301+
llvalue = "llvm_build_struct_gep"
13191302

13201303
external build_global_string : string -> string -> llbuilder -> llvalue
13211304
= "llvm_build_global_string"
@@ -1371,10 +1354,8 @@ external build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
13711354
llvalue = "llvm_build_phi"
13721355
external build_empty_phi : lltype -> string -> llbuilder -> llvalue
13731356
= "llvm_build_empty_phi"
1374-
external build_call : llvalue -> llvalue array -> string -> llbuilder -> llvalue
1375-
= "llvm_build_call"
1376-
external build_call2 : lltype -> llvalue -> llvalue array -> string ->
1377-
llbuilder -> llvalue = "llvm_build_call2"
1357+
external build_call : lltype -> llvalue -> llvalue array -> string ->
1358+
llbuilder -> llvalue = "llvm_build_call"
13781359
external build_select : llvalue -> llvalue -> llvalue -> string -> llbuilder ->
13791360
llvalue = "llvm_build_select"
13801361
external build_va_arg : llvalue -> lltype -> string -> llbuilder -> llvalue
@@ -1394,10 +1375,8 @@ external build_is_null : llvalue -> string -> llbuilder -> llvalue
13941375
= "llvm_build_is_null"
13951376
external build_is_not_null : llvalue -> string -> llbuilder -> llvalue
13961377
= "llvm_build_is_not_null"
1397-
external build_ptrdiff : llvalue -> llvalue -> string -> llbuilder -> llvalue
1398-
= "llvm_build_ptrdiff"
1399-
external build_ptrdiff2 : lltype -> llvalue -> llvalue -> string -> llbuilder ->
1400-
llvalue = "llvm_build_ptrdiff2"
1378+
external build_ptrdiff : lltype -> llvalue -> llvalue -> string -> llbuilder ->
1379+
llvalue = "llvm_build_ptrdiff"
14011380
external build_freeze : llvalue -> string -> llbuilder -> llvalue
14021381
= "llvm_build_freeze"
14031382

llvm/bindings/ocaml/llvm/llvm.mli

Lines changed: 31 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -716,20 +716,15 @@ val subtypes : lltype -> lltype array
716716
[ty]. See the method [llvm::ArrayType::get]. *)
717717
val array_type : lltype -> int -> lltype
718718

719-
(** [pointer_type ty] returns the pointer type referencing objects of type
720-
[ty] in the default address space (0).
719+
(** [pointer_type context] returns the pointer type in the default
720+
address space (0).
721721
See the method [llvm::PointerType::getUnqual]. *)
722-
val pointer_type : lltype -> lltype
722+
val pointer_type : llcontext -> lltype
723723

724-
(** [qualified_pointer_type ty as] returns the pointer type referencing objects
725-
of type [ty] in address space [as].
724+
(** [qualified_pointer_type context sp] returns the pointer type referencing
725+
objects in address space [sp].
726726
See the method [llvm::PointerType::get]. *)
727-
val qualified_pointer_type : lltype -> int -> lltype
728-
729-
(** [pointer_type_in_context context as] returns the opaque pointer type
730-
referencing objects in address space [as].
731-
See the method [llvm::PointerType::get]. *)
732-
val pointer_type_in_context : llcontext -> int -> lltype
727+
val qualified_pointer_type : llcontext -> int -> lltype
733728

734729
(** [vector_type ty n] returns the array type containing [n] elements of the
735730
primitive type [ty]. See the method [llvm::ArrayType::get]. *)
@@ -1168,16 +1163,11 @@ val const_lshr : llvalue -> llvalue -> llvalue
11681163
See the method [llvm::ConstantExpr::getAShr]. *)
11691164
val const_ashr : llvalue -> llvalue -> llvalue
11701165

1171-
(** [const_gep pc indices] returns the constant [getElementPtr] of [pc] with the
1172-
constant integers indices from the array [indices].
1173-
See the method [llvm::ConstantExpr::getGetElementPtr]. *)
1174-
val const_gep : llvalue -> llvalue array -> llvalue
1175-
1176-
(** [const_gep2 srcty pc indices] returns the constant [getElementPtr] of [pc]
1166+
(** [const_gep srcty pc indices] returns the constant [getElementPtr] of [pc]
11771167
with source element type [srcty] and the constant integers indices from the
11781168
array [indices].
11791169
See the method [llvm::ConstantExpr::getGetElementPtr]. *)
1180-
val const_gep2 : lltype -> llvalue -> llvalue array -> llvalue
1170+
val const_gep : lltype -> llvalue -> llvalue array -> llvalue
11811171

11821172
(** [const_in_bounds_gep pc indices] returns the constant [getElementPtr] of [pc]
11831173
with the constant integers indices from the array [indices].
@@ -1509,15 +1499,10 @@ val set_externally_initialized : bool -> llvalue -> unit
15091499

15101500
(** {7 Operations on aliases} *)
15111501

1512-
(** [add_alias m t a n] inserts an alias in the module [m] with the type [t] and
1513-
the aliasee [a] with the name [n].
1502+
(** [add_alias m vt sp a n] inserts an alias in the module [m] with the value
1503+
type [vt] the address space [sp] the aliasee [a] with the name [n].
15141504
See the constructor for [llvm::GlobalAlias]. *)
1515-
val add_alias : llmodule -> lltype -> llvalue -> string -> llvalue
1516-
1517-
(** [add_alias m vt as a n] inserts an alias in the module [m] with the value
1518-
type [vt] the address space [as] the aliasee [a] with the name [n].
1519-
See the constructor for [llvm::GlobalAlias]. *)
1520-
val add_alias2 : llmodule -> lltype -> int -> llvalue -> string -> llvalue
1505+
val add_alias : llmodule -> lltype -> int -> llvalue -> string -> llvalue
15211506

15221507
(** {7 Operations on functions} *)
15231508

@@ -2097,19 +2082,12 @@ val build_indirect_br : llvalue -> int -> llbuilder -> llvalue
20972082
See the method [llvm::IndirectBrInst::addDestination]. **)
20982083
val add_destination : llvalue -> llbasicblock -> unit
20992084

2100-
(** [build_invoke fn args tobb unwindbb name b] creates an
2085+
(** [build_invoke fnty fn args tobb unwindbb name b] creates an
21012086
[%name = invoke %fn(args) to %tobb unwind %unwindbb]
21022087
instruction at the position specified by the instruction builder [b].
21032088
See the method [llvm::LLVMBuilder::CreateInvoke]. *)
2104-
val build_invoke : llvalue -> llvalue array -> llbasicblock ->
2105-
llbasicblock -> string -> llbuilder -> llvalue
2106-
2107-
(** [build_invoke2 fnty fn args tobb unwindbb name b] creates an
2108-
[%name = invoke %fn(args) to %tobb unwind %unwindbb]
2109-
instruction at the position specified by the instruction builder [b].
2110-
See the method [llvm::LLVMBuilder::CreateInvoke]. *)
2111-
val build_invoke2 : lltype -> llvalue -> llvalue array -> llbasicblock ->
2112-
llbasicblock -> string -> llbuilder -> llvalue
2089+
val build_invoke : lltype -> llvalue -> llvalue array -> llbasicblock ->
2090+
llbasicblock -> string -> llbuilder -> llvalue
21132091

21142092
(** [build_landingpad ty persfn numclauses name b] creates an
21152093
[landingpad]
@@ -2345,17 +2323,11 @@ val build_alloca : lltype -> string -> llbuilder -> llvalue
23452323
val build_array_alloca : lltype -> llvalue -> string -> llbuilder ->
23462324
llvalue
23472325

2348-
(** [build_load v name b] creates a
2349-
[%name = load %v]
2350-
instruction at the position specified by the instruction builder [b].
2351-
See the method [llvm::LLVMBuilder::CreateLoad]. *)
2352-
val build_load : llvalue -> string -> llbuilder -> llvalue
2353-
2354-
(** [build_load2 ty v name b] creates a
2326+
(** [build_load ty v name b] creates a
23552327
[%name = load %ty, %v]
23562328
instruction at the position specified by the instruction builder [b].
23572329
See the method [llvm::LLVMBuilder::CreateLoad]. *)
2358-
val build_load2 : lltype -> llvalue -> string -> llbuilder -> llvalue
2330+
val build_load : lltype -> llvalue -> string -> llbuilder -> llvalue
23592331

23602332
(** [build_store v p b] creates a
23612333
[store %v, %p]
@@ -2371,46 +2343,26 @@ val build_store : llvalue -> llvalue -> llbuilder -> llvalue
23712343
val build_atomicrmw : AtomicRMWBinOp.t -> llvalue -> llvalue ->
23722344
AtomicOrdering.t -> bool -> string -> llbuilder -> llvalue
23732345

2374-
(** [build_gep p indices name b] creates a
2375-
[%name = getelementptr %p, indices...]
2376-
instruction at the position specified by the instruction builder [b].
2377-
See the method [llvm::LLVMBuilder::CreateGetElementPtr]. *)
2378-
val build_gep : llvalue -> llvalue array -> string -> llbuilder -> llvalue
2379-
2380-
(** [build_gep2 srcty p indices name b] creates a
2346+
(** [build_gep srcty p indices name b] creates a
23812347
[%name = getelementptr srcty, %p, indices...]
23822348
instruction at the position specified by the instruction builder [b].
23832349
See the method [llvm::LLVMBuilder::CreateGetElementPtr]. *)
2384-
val build_gep2 : lltype -> llvalue -> llvalue array -> string -> llbuilder ->
2385-
llvalue
2350+
val build_gep : lltype -> llvalue -> llvalue array -> string -> llbuilder ->
2351+
llvalue
23862352

2387-
(** [build_in_bounds_gep p indices name b] creates a
2388-
[%name = gelementptr inbounds %p, indices...]
2389-
instruction at the position specified by the instruction builder [b].
2390-
See the method [llvm::LLVMBuilder::CreateInBoundsGetElementPtr]. *)
2391-
val build_in_bounds_gep : llvalue -> llvalue array -> string -> llbuilder ->
2392-
llvalue
2393-
2394-
(** [build_in_bounds_gep2 srcty p indices name b] creates a
2353+
(** [build_in_bounds_gep srcty p indices name b] creates a
23952354
[%name = gelementptr inbounds srcty, %p, indices...]
23962355
instruction at the position specified by the instruction builder [b].
23972356
See the method [llvm::LLVMBuilder::CreateInBoundsGetElementPtr]. *)
2398-
val build_in_bounds_gep2 : lltype -> llvalue -> llvalue array -> string ->
2399-
llbuilder -> llvalue
2400-
2401-
(** [build_struct_gep p idx name b] creates a
2402-
[%name = getelementptr %p, 0, idx]
2403-
instruction at the position specified by the instruction builder [b].
2404-
See the method [llvm::LLVMBuilder::CreateStructGetElementPtr]. *)
2405-
val build_struct_gep : llvalue -> int -> string -> llbuilder ->
2406-
llvalue
2357+
val build_in_bounds_gep : lltype -> llvalue -> llvalue array -> string ->
2358+
llbuilder -> llvalue
24072359

2408-
(** [build_struct_gep2 srcty p idx name b] creates a
2360+
(** [build_struct_gep srcty p idx name b] creates a
24092361
[%name = getelementptr srcty, %p, 0, idx]
24102362
instruction at the position specified by the instruction builder [b].
24112363
See the method [llvm::LLVMBuilder::CreateStructGetElementPtr]. *)
2412-
val build_struct_gep2 : lltype -> llvalue -> int -> string -> llbuilder ->
2413-
llvalue
2364+
val build_struct_gep : lltype -> llvalue -> int -> string -> llbuilder ->
2365+
llvalue
24142366

24152367
(** [build_global_string str name b] creates a series of instructions that adds
24162368
a global string at the position specified by the instruction builder [b].
@@ -2565,18 +2517,12 @@ val build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
25652517
See the method [llvm::LLVMBuilder::CreatePHI]. *)
25662518
val build_empty_phi : lltype -> string -> llbuilder -> llvalue
25672519

2568-
(** [build_call fn args name b] creates a
2569-
[%name = call %fn(args...)]
2570-
instruction at the position specified by the instruction builder [b].
2571-
See the method [llvm::LLVMBuilder::CreateCall]. *)
2572-
val build_call : llvalue -> llvalue array -> string -> llbuilder -> llvalue
2573-
2574-
(** [build_call2 fnty fn args name b] creates a
2520+
(** [build_call fnty fn args name b] creates a
25752521
[%name = call %fn(args...)]
25762522
instruction at the position specified by the instruction builder [b].
25772523
See the method [llvm::LLVMBuilder::CreateCall]. *)
2578-
val build_call2 : lltype -> llvalue -> llvalue array -> string -> llbuilder ->
2579-
llvalue
2524+
val build_call : lltype -> llvalue -> llvalue array -> string -> llbuilder ->
2525+
llvalue
25802526

25812527
(** [build_select cond thenv elsev name b] creates a
25822528
[%name = select %cond, %thenv, %elsev]
@@ -2638,18 +2584,12 @@ val build_is_null : llvalue -> string -> llbuilder -> llvalue
26382584
See the method [llvm::LLVMBuilder::CreateIsNotNull]. *)
26392585
val build_is_not_null : llvalue -> string -> llbuilder -> llvalue
26402586

2641-
(** [build_ptrdiff lhs rhs name b] creates a series of instructions that measure
2642-
the difference between two pointer values at the position specified by the
2643-
instruction builder [b].
2644-
See the method [llvm::LLVMBuilder::CreatePtrDiff]. *)
2645-
val build_ptrdiff : llvalue -> llvalue -> string -> llbuilder -> llvalue
2646-
2647-
(** [build_ptrdiff2 elemty lhs rhs name b] creates a series of instructions
2587+
(** [build_ptrdiff elemty lhs rhs name b] creates a series of instructions
26482588
that measure the difference between two pointer values in multiples of
26492589
[elemty] at the position specified by the instruction builder [b].
26502590
See the method [llvm::LLVMBuilder::CreatePtrDiff]. *)
2651-
val build_ptrdiff2 : lltype -> llvalue -> llvalue -> string -> llbuilder ->
2652-
llvalue
2591+
val build_ptrdiff : lltype -> llvalue -> llvalue -> string -> llbuilder ->
2592+
llvalue
26532593

26542594
(** [build_freeze x name b] creates a
26552595
[%name = freeze %x]

0 commit comments

Comments
 (0)