[OCaml] Add Llvm.build_empty_phi.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228395 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Peter Zotov 2015-02-06 13:42:03 +00:00
parent 52e57900a3
commit f6943689d2
4 changed files with 26 additions and 0 deletions

View File

@ -1300,6 +1300,8 @@ external build_fcmp : Fcmp.t -> llvalue -> llvalue -> string ->
(*--... Miscellaneous instructions .........................................--*) (*--... Miscellaneous instructions .........................................--*)
external build_phi : (llvalue * llbasicblock) list -> string -> llbuilder -> external build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
llvalue = "llvm_build_phi" llvalue = "llvm_build_phi"
external build_empty_phi : lltype -> string -> llbuilder -> llvalue
= "llvm_build_empty_phi"
external build_call : llvalue -> llvalue array -> string -> llbuilder -> llvalue external build_call : llvalue -> llvalue array -> string -> llbuilder -> llvalue
= "llvm_build_call" = "llvm_build_call"
external build_select : llvalue -> llvalue -> llvalue -> string -> llbuilder -> external build_select : llvalue -> llvalue -> llvalue -> string -> llbuilder ->

View File

@ -2422,6 +2422,12 @@ val build_fcmp : Fcmp.t -> llvalue -> llvalue -> string ->
val build_phi : (llvalue * llbasicblock) list -> string -> llbuilder -> val build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
llvalue llvalue
(** [build_empty_phi ty name b] creates a
[%name = phi %ty] instruction at the position specified by
the instruction builder [b]. [ty] is the type of the instruction.
See the method [llvm::LLVMBuilder::CreatePHI]. *)
val build_empty_phi : lltype -> string -> llbuilder -> llvalue
(** [build_call fn args name b] creates a (** [build_call fn args name b] creates a
[%name = call %fn(args...)] [%name = call %fn(args...)]
instruction at the position specified by the instruction builder [b]. instruction at the position specified by the instruction builder [b].

View File

@ -2191,6 +2191,15 @@ CAMLprim LLVMValueRef llvm_build_phi(value Incoming, value Name, value B) {
return PhiNode; return PhiNode;
} }
/* lltype -> string -> llbuilder -> value */
CAMLprim LLVMValueRef llvm_build_empty_phi(LLVMTypeRef Type, value Name, value B) {
LLVMValueRef PhiNode;
return LLVMBuildPhi(Builder_val(B), Type, String_val(Name));
return PhiNode;
}
/* llvalue -> llvalue array -> string -> llbuilder -> llvalue */ /* llvalue -> llvalue array -> string -> llbuilder -> llvalue */
CAMLprim LLVMValueRef llvm_build_call(LLVMValueRef Fn, value Params, CAMLprim LLVMValueRef llvm_build_call(LLVMValueRef Fn, value Params,
value Name, value B) { value Name, value B) {

View File

@ -1428,6 +1428,15 @@ let test_builder () =
add_incoming (p2, b2) phi; add_incoming (p2, b2) phi;
insist ([(p1, b1); (p2, b2)] = incoming phi); insist ([(p1, b1); (p2, b2)] = incoming phi);
(* CHECK: %PhiEmptyNode = phi i8
*)
let phi_empty = build_empty_phi i8_type "PhiEmptyNode" at_jb in
insist ([] = incoming phi_empty);
(* can't emit an empty phi to bitcode *)
add_incoming (const_int i8_type 1, b1) phi_empty;
add_incoming (const_int i8_type 2, b2) phi_empty;
ignore (build_unreachable at_jb); ignore (build_unreachable at_jb);
end end