diff options
author | Gordon Henriksen <gordonhenriksen@mac.com> | 2008-08-09 01:55:52 +0000 |
---|---|---|
committer | Gordon Henriksen <gordonhenriksen@mac.com> | 2008-08-09 01:55:52 +0000 |
commit | 21491edbf4027df4db559eb1a9aa8fbf3779cfab (patch) | |
tree | d36c2a72c7671302f4ed2520da5427d0d1f11a64 /bindings | |
parent | b75de8d843cf3574e99c8917c16adbb0e6575e7e (diff) |
[PR-2610] Adding Ocaml bindings for Switch::addCase.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54571 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/ocaml/llvm/llvm.ml | 2 | ||||
-rw-r--r-- | bindings/ocaml/llvm/llvm.mli | 11 | ||||
-rw-r--r-- | bindings/ocaml/llvm/llvm_ocaml.c | 7 |
3 files changed, 18 insertions, 2 deletions
diff --git a/bindings/ocaml/llvm/llvm.ml b/bindings/ocaml/llvm/llvm.ml index 85acc5e5787..d178dcc0018 100644 --- a/bindings/ocaml/llvm/llvm.ml +++ b/bindings/ocaml/llvm/llvm.ml @@ -619,6 +619,8 @@ external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder -> llvalue = "llvm_build_cond_br" external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue = "llvm_build_switch" +external add_case : llvalue -> llvalue -> llbasicblock -> unit + = "llvm_add_case" 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 5aedefb9257..a7d26def214 100644 --- a/bindings/ocaml/llvm/llvm.mli +++ b/bindings/ocaml/llvm/llvm.mli @@ -1212,13 +1212,20 @@ external build_br : llbasicblock -> llbuilder -> llvalue = "llvm_build_br" external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder -> llvalue = "llvm_build_cond_br" -(** [build_switch case elsebb b] creates an empty +(** [build_switch case elsebb count b] creates an empty [switch %case, %elsebb] - instruction at the position specified by the instruction builder [b]. + instruction at the position specified by the instruction builder [b] with + space reserved for [count] cases. See the method [llvm::LLVMBuilder::CreateSwitch]. *) external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue = "llvm_build_switch" +(** [add_case sw onval bb] causes switch instruction [sw] to branch to [bb] + when its input matches the constant [onval]. + See the method [llvm::SwitchInst::addCase]. **) +external add_case : llvalue -> llvalue -> llbasicblock -> unit + = "llvm_add_case" + (** [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 76ad408c358..94bd374594b 100644 --- a/bindings/ocaml/llvm/llvm_ocaml.c +++ b/bindings/ocaml/llvm/llvm_ocaml.c @@ -848,6 +848,13 @@ CAMLprim LLVMValueRef llvm_build_switch(LLVMValueRef Of, return LLVMBuildSwitch(Builder_val(B), Of, Else, Int_val(EstimatedCount)); } +CAMLprim value llvm_add_case(LLVMValueRef Switch, + LLVMValueRef OnVal, + LLVMBasicBlockRef Dest) { + LLVMAddCase(Switch, OnVal, Dest); + return Val_unit; +} + /* llvalue -> llvalue array -> llbasicblock -> llbasicblock -> string -> llbuilder -> llvalue */ CAMLprim LLVMValueRef llvm_build_invoke_nat(LLVMValueRef Fn, value Args, |