llvm.org GIT mirror llvm / 07cabf6
PR2731: C and Ocaml bindings for setTailCall and isTailCall. Based on patch by Giorgos Korfiatis. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55570 91177308-0d34-0410-b5e6-96231b3b80d8 Gordon Henriksen 12 years ago
6 changed file(s) with 47 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
585585 external set_instruction_call_conv: int -> llvalue -> unit
586586 = "llvm_set_instruction_call_conv"
587587
588 (*--... Operations on call instructions (only) .............................--*)
589 external is_tail_call : llvalue -> bool = "llvm_is_tail_call"
590 external set_tail_call : bool -> llvalue -> unit = "llvm_set_tail_call"
591
588592 (*--... Operations on phi nodes ............................................--*)
589593 external add_incoming : (llvalue * llbasicblock) -> llvalue -> unit
590594 = "llvm_add_incoming"
11251125 external set_instruction_call_conv: int -> llvalue -> unit
11261126 = "llvm_set_instruction_call_conv"
11271127
1128 (** {Operations on call instructions (only)} *)
1129
1130 (** [is_tail_call ci] is [true] if the call instruction [ci] is flagged as
1131 eligible for tail call optimization, [false] otherwise.
1132 See the method [llvm::CallInst::isTailCall]. *)
1133 external is_tail_call : llvalue -> bool = "llvm_is_tail_call"
1134
1135 (** [set_tail_call tc ci] flags the call instruction [ci] as eligible for tail
1136 call optimization if [tc] is [true], clears otherwise.
1137 See the method [llvm::CallInst::setTailCall]. *)
1138 external set_tail_call : bool -> llvalue -> unit = "llvm_set_tail_call"
11281139
11291140 (** {7 Operations on phi nodes} *)
11301141
732732 return Val_unit;
733733 }
734734
735 /*--... Operations on call instructions (only) .............................--*/
736
737 /* llvalue -> bool */
738 CAMLprim value llvm_is_tail_call(LLVMValueRef CallInst) {
739 return Val_bool(LLVMIsTailCall(CallInst));
740 }
741
742 /* bool -> llvalue -> unit */
743 CAMLprim value llvm_set_tail_call(value IsTailCall,
744 LLVMValueRef CallInst) {
745 LLVMSetTailCall(CallInst, Bool_val(IsTailCall));
746 return Val_unit;
747 }
748
735749 /*--... Operations on phi nodes ............................................--*/
736750
737751 /* (llvalue * llbasicblock) -> llvalue -> unit */
459459 void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
460460 unsigned align);
461461
462 /* Operations on call instructions (only) */
463 int LLVMIsTailCall(LLVMValueRef CallInst);
464 void LLVMSetTailCall(LLVMValueRef CallInst, int IsTailCall);
465
462466 /* Operations on phi nodes */
463467 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
464468 LLVMBasicBlockRef *IncomingBlocks, unsigned Count);
962962 ParamAttr::constructAlignmentFromInt(align)));
963963 }
964964
965 /*--.. Operations on call instructions (only) ..............................--*/
966
967 int LLVMIsTailCall(LLVMValueRef Call) {
968 return unwrap(Call)->isTailCall();
969 }
970
971 void LLVMSetTailCall(LLVMValueRef Call, int isTailCall) {
972 unwrap(Call)->setTailCall(isTailCall);
973 }
974
965975 /*--.. Operations on phi nodes .............................................--*/
966976
967977 void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues,
978978 * RUN: grep {Inst49.*extractelement.*Vec1.*P2} < %t.ll
979979 * RUN: grep {Inst50.*insertelement.*Vec1.*P1.*P2} < %t.ll
980980 * RUN: grep {Inst51.*shufflevector.*Vec1.*Vec2.*1.*1.*0.*0} < %t.ll
981 * RUN: grep {CallInst.*tail call} < %t.ll
981982 *)
982983 let ci = build_call fn [| p2; p1 |] "CallInst" atentry in
983984 insist (CallConv.c = instruction_call_conv ci);
984985 set_instruction_call_conv 63 ci;
985986 insist (63 = instruction_call_conv ci);
987 insist (not (is_tail_call ci));
988 set_tail_call true ci;
989 insist (is_tail_call ci);
986990
987991 let inst46 = build_icmp Icmp.Eq p1 p2 "Inst46" atentry in
988992 ignore (build_select inst46 p1 p2 "Inst47" atentry);