llvm.org GIT mirror llvm / f694368
[OCaml] Add Llvm.build_empty_phi. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228395 91177308-0d34-0410-b5e6-96231b3b80d8 Peter Zotov 4 years ago
4 changed file(s) with 26 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
12991299 (*--... Miscellaneous instructions .........................................--*)
13001300 external build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
13011301 llvalue = "llvm_build_phi"
1302 external build_empty_phi : lltype -> string -> llbuilder -> llvalue
1303 = "llvm_build_empty_phi"
13021304 external build_call : llvalue -> llvalue array -> string -> llbuilder -> llvalue
13031305 = "llvm_build_call"
13041306 external build_select : llvalue -> llvalue -> llvalue -> string -> llbuilder ->
24212421 val build_phi : (llvalue * llbasicblock) list -> string -> llbuilder ->
24222422 llvalue
24232423
2424 (** [build_empty_phi ty name b] creates a
2425 [%name = phi %ty] instruction at the position specified by
2426 the instruction builder [b]. [ty] is the type of the instruction.
2427 See the method [llvm::LLVMBuilder::CreatePHI]. *)
2428 val build_empty_phi : lltype -> string -> llbuilder -> llvalue
2429
24242430 (** [build_call fn args name b] creates a
24252431 [%name = call %fn(args...)]
24262432 instruction at the position specified by the instruction builder [b].
21902190 return PhiNode;
21912191 }
21922192
2193 /* lltype -> string -> llbuilder -> value */
2194 CAMLprim LLVMValueRef llvm_build_empty_phi(LLVMTypeRef Type, value Name, value B) {
2195 LLVMValueRef PhiNode;
2196
2197 return LLVMBuildPhi(Builder_val(B), Type, String_val(Name));
2198
2199 return PhiNode;
2200 }
2201
21932202 /* llvalue -> llvalue array -> string -> llbuilder -> llvalue */
21942203 CAMLprim LLVMValueRef llvm_build_call(LLVMValueRef Fn, value Params,
21952204 value Name, value B) {
14271427 add_incoming (p2, b2) phi;
14281428 insist ([(p1, b1); (p2, b2)] = incoming phi);
14291429
1430 (* CHECK: %PhiEmptyNode = phi i8
1431 *)
1432 let phi_empty = build_empty_phi i8_type "PhiEmptyNode" at_jb in
1433 insist ([] = incoming phi_empty);
1434
1435 (* can't emit an empty phi to bitcode *)
1436 add_incoming (const_int i8_type 1, b1) phi_empty;
1437 add_incoming (const_int i8_type 2, b2) phi_empty;
1438
14301439 ignore (build_unreachable at_jb);
14311440 end
14321441