aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErick Tryzelaar <idadesub@users.sourceforge.net>2009-08-16 02:20:57 +0000
committerErick Tryzelaar <idadesub@users.sourceforge.net>2009-08-16 02:20:57 +0000
commit5c1c2082968ff4c36063ed09c4eea772eb808b6a (patch)
tree59a704db007774588645961bab39abd36d5fc0d0
parent1b42cfd1ca03e48835e8e4c91c5dbb598030257f (diff)
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
-rw-r--r--bindings/ocaml/llvm/llvm.ml2
-rw-r--r--bindings/ocaml/llvm/llvm.mli6
-rw-r--r--bindings/ocaml/llvm/llvm_ocaml.c7
-rw-r--r--include/llvm-c/Core.h2
-rw-r--r--lib/VMCore/Core.cpp5
5 files changed, 22 insertions, 0 deletions
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<Instruction>(Instr));
}
+void LLVMInsertIntoBuilderWithName(LLVMBuilderRef Builder, LLVMValueRef Instr,
+ const char *Name) {
+ unwrap(Builder)->Insert(unwrap<Instruction>(Instr), Name);
+}
+
void LLVMDisposeBuilder(LLVMBuilderRef Builder) {
delete unwrap(Builder);
}