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
This commit is contained in:
Erick Tryzelaar 2009-08-16 02:20:57 +00:00
parent 1b42cfd1ca
commit 5c1c208296
5 changed files with 22 additions and 0 deletions

View File

@ -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

View File

@ -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} *)

View File

@ -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 */

View File

@ -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 */

View File

@ -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);
}