aboutsummaryrefslogtreecommitdiffstats
path: root/bindings
diff options
context:
space:
mode:
authorErick Tryzelaar <idadesub@users.sourceforge.net>2010-02-28 09:46:06 +0000
committerErick Tryzelaar <idadesub@users.sourceforge.net>2010-02-28 09:46:06 +0000
commitc59286bff1cca8c4fa15f390c9002db94117614e (patch)
treea814f992425526d661e141c95d4a273cc32bd19a /bindings
parent46c80e0c5653e11ada7cebcb46f9a8f7df758e41 (diff)
downloadexternal_llvm-c59286bff1cca8c4fa15f390c9002db94117614e.zip
external_llvm-c59286bff1cca8c4fa15f390c9002db94117614e.tar.gz
external_llvm-c59286bff1cca8c4fa15f390c9002db94117614e.tar.bz2
Add indirect br support to llvm-c and ocaml.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@97376 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r--bindings/ocaml/llvm/llvm.ml5
-rw-r--r--bindings/ocaml/llvm/llvm.mli18
-rw-r--r--bindings/ocaml/llvm/llvm_ocaml.c14
3 files changed, 37 insertions, 0 deletions
diff --git a/bindings/ocaml/llvm/llvm.ml b/bindings/ocaml/llvm/llvm.ml
index 837f6a3..7017b4a 100644
--- a/bindings/ocaml/llvm/llvm.ml
+++ b/bindings/ocaml/llvm/llvm.ml
@@ -351,6 +351,7 @@ external const_extractvalue : llvalue -> int array -> llvalue
= "llvm_const_extractvalue"
external const_insertvalue : llvalue -> llvalue -> int array -> llvalue
= "llvm_const_insertvalue"
+external block_address : llvalue -> llbasicblock -> llvalue = "LLVMBlockAddress"
(*--... Operations on global variables, functions, and aliases (globals) ...--*)
external global_parent : llvalue -> llmodule = "LLVMGetGlobalParent"
@@ -729,6 +730,10 @@ external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
= "llvm_build_switch"
external add_case : llvalue -> llvalue -> llbasicblock -> unit
= "llvm_add_case"
+external build_indirect_br : llvalue -> int -> llbuilder -> llvalue
+ = "llvm_build_indirect_br"
+external add_destination : llvalue -> llbasicblock -> unit
+ = "llvm_add_destination"
external build_invoke : llvalue -> llvalue array -> llbasicblock ->
llbasicblock -> string -> llbuilder -> llvalue
= "llvm_build_invoke_bc" "llvm_build_invoke_nat"
diff --git a/bindings/ocaml/llvm/llvm.mli b/bindings/ocaml/llvm/llvm.mli
index 5a15642..c7fa30a 100644
--- a/bindings/ocaml/llvm/llvm.mli
+++ b/bindings/ocaml/llvm/llvm.mli
@@ -950,6 +950,10 @@ external const_extractvalue : llvalue -> int array -> llvalue
external const_insertvalue : llvalue -> llvalue -> int array -> llvalue
= "llvm_const_insertvalue"
+(** [block_address f bb] returns the address of the basic block [bb] in the
+ function [f]. See the method [llvm::BasicBlock::get]. *)
+external block_address : llvalue -> llbasicblock -> llvalue = "LLVMBlockAddress"
+
(** {7 Operations on global variables, functions, and aliases (globals)} *)
@@ -1562,6 +1566,20 @@ external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
external add_case : llvalue -> llvalue -> llbasicblock -> unit
= "llvm_add_case"
+(** [build_indirect_br addr count b] creates a
+ [indirectbr %addr]
+ instruction at the position specified by the instruction builder [b] with
+ space reserved for [count] destinations.
+ See the method [llvm::LLVMBuilder::CreateIndirectBr]. *)
+external build_indirect_br : llvalue -> int -> llbuilder -> llvalue
+ = "llvm_build_indirect_br"
+
+(** [add_destination br bb] adds the basic block [bb] as a possible branch
+ location for the indirectbr instruction [br].
+ See the method [llvm::IndirectBrInst::addDestination]. **)
+external add_destination : llvalue -> llbasicblock -> unit
+ = "llvm_add_destination"
+
(** [build_invoke fn args tobb unwindbb name b] creates an
[%name = invoke %fn(args) to %tobb unwind %unwindbb]
instruction at the position specified by the instruction builder [b].
diff --git a/bindings/ocaml/llvm/llvm_ocaml.c b/bindings/ocaml/llvm/llvm_ocaml.c
index e56af1e..3964ff7 100644
--- a/bindings/ocaml/llvm/llvm_ocaml.c
+++ b/bindings/ocaml/llvm/llvm_ocaml.c
@@ -1138,6 +1138,20 @@ CAMLprim value llvm_add_case(LLVMValueRef Switch, LLVMValueRef OnVal,
return Val_unit;
}
+/* llvalue -> llbasicblock -> llbuilder -> llvalue */
+CAMLprim LLVMValueRef llvm_build_indirect_br(LLVMValueRef Addr,
+ value EstimatedDests,
+ value B) {
+ return LLVMBuildIndirectBr(Builder_val(B), Addr, EstimatedDests);
+}
+
+/* llvalue -> llvalue -> llbasicblock -> unit */
+CAMLprim value llvm_add_destination(LLVMValueRef IndirectBr,
+ LLVMBasicBlockRef Dest) {
+ LLVMAddDestination(IndirectBr, Dest);
+ return Val_unit;
+}
+
/* llvalue -> llvalue array -> llbasicblock -> llbasicblock -> string ->
llbuilder -> llvalue */
CAMLprim LLVMValueRef llvm_build_invoke_nat(LLVMValueRef Fn, value Args,