From 5c1c2082968ff4c36063ed09c4eea772eb808b6a Mon Sep 17 00:00:00 2001 From: Erick Tryzelaar Date: Sun, 16 Aug 2009 02:20:57 +0000 Subject: Add an llvm-c function that lets you insert an instruction with a name. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79163 91177308-0d34-0410-b5e6-96231b3b80d8 --- bindings/ocaml/llvm/llvm.ml | 2 ++ bindings/ocaml/llvm/llvm.mli | 6 ++++++ bindings/ocaml/llvm/llvm_ocaml.c | 7 +++++++ include/llvm-c/Core.h | 2 ++ lib/VMCore/Core.cpp | 5 +++++ 5 files changed, 22 insertions(+) diff --git a/bindings/ocaml/llvm/llvm.ml b/bindings/ocaml/llvm/llvm.ml index 7f39284195..ed3e1865fc 100644 --- a/bindings/ocaml/llvm/llvm.ml +++ b/bindings/ocaml/llvm/llvm.ml @@ -654,6 +654,8 @@ external builder : unit -> llbuilder = "llvm_builder" external position_builder : (llbasicblock, llvalue) llpos -> llbuilder -> unit = "llvm_position_builder" external insertion_block : llbuilder -> llbasicblock = "llvm_insertion_block" +external insert_into_builder : llvalue -> string -> llbuilder -> unit + = "llvm_insert_into_builder" let builder_at ip = let b = builder () in diff --git a/bindings/ocaml/llvm/llvm.mli b/bindings/ocaml/llvm/llvm.mli index 3c58ce9b3a..f7fcfd999e 100644 --- a/bindings/ocaml/llvm/llvm.mli +++ b/bindings/ocaml/llvm/llvm.mli @@ -1324,6 +1324,12 @@ val position_at_end : llbasicblock -> llbuilder -> unit See the method [llvm::LLVMBuilder::GetInsertBlock]. *) external insertion_block : llbuilder -> llbasicblock = "llvm_insertion_block" +(** [insert_into_builder i name b] inserts the specified instruction [i] at the + position specified by the instruction builder [b]. + See the method [llvm::LLVMBuilder::Insert]. *) +external insert_into_builder : llvalue -> string -> llbuilder -> unit + = "llvm_insert_into_builder" + (** {7 Terminators} *) diff --git a/bindings/ocaml/llvm/llvm_ocaml.c b/bindings/ocaml/llvm/llvm_ocaml.c index d9d4e88ffb..88c9a23109 100644 --- a/bindings/ocaml/llvm/llvm_ocaml.c +++ b/bindings/ocaml/llvm/llvm_ocaml.c @@ -917,6 +917,13 @@ CAMLprim LLVMBasicBlockRef llvm_insertion_block(LLVMBuilderRef B) { return InsertBlock; } +/* llvalue -> string -> llbuilder -> unit */ +CAMLprim value llvm_insert_into_builder(LLVMValueRef I, value Name, + LLVMBuilderRef B) { + LLVMInsertIntoBuilderWithName(B, I, String_val(Name)); + return Val_unit; +} + /*--... Terminators ........................................................--*/ /* llbuilder -> llvalue */ diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 15f938d9b6..50985e9064 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -658,6 +658,8 @@ void LLVMPositionBuilderAtEnd(LLVMBuilderRef Builder, LLVMBasicBlockRef Block); LLVMBasicBlockRef LLVMGetInsertBlock(LLVMBuilderRef Builder); void LLVMClearInsertionPosition(LLVMBuilderRef Builder); void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr); +void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr, + const char *Name); void LLVMDisposeBuilder(LLVMBuilderRef Builder); /* Terminators */ diff --git a/lib/VMCore/Core.cpp b/lib/VMCore/Core.cpp index 3bac6beb60..1144e53a4d 100644 --- a/lib/VMCore/Core.cpp +++ b/lib/VMCore/Core.cpp @@ -1464,6 +1464,11 @@ void LLVMInsertIntoBuilder(LLVMBuilderRef Builder, LLVMValueRef Instr) { unwrap(Builder)->Insert(unwrap(Instr)); } +void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr, + const char *Name) { + unwrap(Builder)->Insert(unwrap(Instr), Name); +} + void LLVMDisposeBuilder(LLVMBuilderRef Builder) { delete unwrap(Builder); } -- cgit v1.2.3