forked from OSchip/llvm-project
Adding an uninitialized builder constructor to the Ocaml bindings.
llvm-svn: 45362
This commit is contained in:
parent
c9d41e7d27
commit
d4749de856
|
@ -327,6 +327,8 @@ external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming"
|
|||
|
||||
|
||||
(*===-- Instruction builders ----------------------------------------------===*)
|
||||
external builder: unit-> llbuilder
|
||||
= "llvm_builder"
|
||||
external builder_before : llvalue -> llbuilder = "llvm_builder_before"
|
||||
external builder_at_end : llbasicblock -> llbuilder = "llvm_builder_at_end"
|
||||
external position_before : llvalue -> llbuilder -> unit = "llvm_position_before"
|
||||
|
|
|
@ -847,6 +847,12 @@ external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming"
|
|||
|
||||
(*===-- Instruction builders ----------------------------------------------===*)
|
||||
|
||||
(** [builder] creates an instruction builder with no position. It is invalid to
|
||||
use this builder until its position is set with [position_before] or
|
||||
[position_at_end]. See the constructor for [llvm::LLVMBuilder]. **)
|
||||
external builder: unit-> llbuilder
|
||||
= "llvm_builder"
|
||||
|
||||
(** [builder_before ins] creates an instruction builder positioned before the
|
||||
instruction [isn]. See the constructor for [llvm::LLVMBuilder]. **)
|
||||
external builder_before : llvalue -> llbuilder = "llvm_builder_before"
|
||||
|
|
|
@ -668,7 +668,7 @@ CAMLprim value llvm_incoming(LLVMValueRef PhiNode) {
|
|||
|
||||
#define Builder_val(v) (*(LLVMBuilderRef *)(Data_custom_val(v)))
|
||||
|
||||
void llvm_finalize_builder(value B) {
|
||||
static void llvm_finalize_builder(value B) {
|
||||
LLVMDisposeBuilder(Builder_val(B));
|
||||
}
|
||||
|
||||
|
@ -681,24 +681,29 @@ static struct custom_operations builder_ops = {
|
|||
custom_deserialize_default
|
||||
};
|
||||
|
||||
/* llvalue -> llbuilder */
|
||||
CAMLprim value llvm_builder_before(LLVMValueRef Inst) {
|
||||
value V;
|
||||
LLVMBuilderRef B = LLVMCreateBuilder();
|
||||
LLVMPositionBuilderBefore(B, Inst);
|
||||
V = alloc_custom(&builder_ops, sizeof(LLVMBuilderRef), 0, 1);
|
||||
static value alloc_builder(LLVMBuilderRef B) {
|
||||
value V = alloc_custom(&builder_ops, sizeof(LLVMBuilderRef), 0, 1);
|
||||
Builder_val(V) = B;
|
||||
return V;
|
||||
}
|
||||
|
||||
/* unit-> llbuilder */
|
||||
CAMLprim value llvm_builder(value Unit) {
|
||||
return alloc_builder(LLVMCreateBuilder());
|
||||
}
|
||||
|
||||
/* llvalue -> llbuilder */
|
||||
CAMLprim value llvm_builder_before(LLVMValueRef Inst) {
|
||||
LLVMBuilderRef B = LLVMCreateBuilder();
|
||||
LLVMPositionBuilderBefore(B, Inst);
|
||||
return alloc_builder(B);
|
||||
}
|
||||
|
||||
/* llbasicblock -> llbuilder */
|
||||
CAMLprim value llvm_builder_at_end(LLVMBasicBlockRef BB) {
|
||||
value V;
|
||||
LLVMBuilderRef B = LLVMCreateBuilder();
|
||||
LLVMPositionBuilderAtEnd(B, BB);
|
||||
V = alloc_custom(&builder_ops, sizeof(LLVMBuilderRef), 0, 1);
|
||||
Builder_val(V) = B;
|
||||
return V;
|
||||
return alloc_builder(B);
|
||||
}
|
||||
|
||||
/* llvalue -> llbuilder -> unit */
|
||||
|
|
Loading…
Reference in New Issue