mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-18 10:31:57 +00:00
[PR-2610] Adding Ocaml bindings for Switch::addCase.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54571 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
b75de8d843
commit
21491edbf4
@ -619,6 +619,8 @@ external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder ->
|
|||||||
llvalue = "llvm_build_cond_br"
|
llvalue = "llvm_build_cond_br"
|
||||||
external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
|
external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
|
||||||
= "llvm_build_switch"
|
= "llvm_build_switch"
|
||||||
|
external add_case : llvalue -> llvalue -> llbasicblock -> unit
|
||||||
|
= "llvm_add_case"
|
||||||
external build_invoke : llvalue -> llvalue array -> llbasicblock ->
|
external build_invoke : llvalue -> llvalue array -> llbasicblock ->
|
||||||
llbasicblock -> string -> llbuilder -> llvalue
|
llbasicblock -> string -> llbuilder -> llvalue
|
||||||
= "llvm_build_invoke_bc" "llvm_build_invoke_nat"
|
= "llvm_build_invoke_bc" "llvm_build_invoke_nat"
|
||||||
|
@ -1212,13 +1212,20 @@ external build_br : llbasicblock -> llbuilder -> llvalue = "llvm_build_br"
|
|||||||
external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder ->
|
external build_cond_br : llvalue -> llbasicblock -> llbasicblock -> llbuilder ->
|
||||||
llvalue = "llvm_build_cond_br"
|
llvalue = "llvm_build_cond_br"
|
||||||
|
|
||||||
(** [build_switch case elsebb b] creates an empty
|
(** [build_switch case elsebb count b] creates an empty
|
||||||
[switch %case, %elsebb]
|
[switch %case, %elsebb]
|
||||||
instruction at the position specified by the instruction builder [b].
|
instruction at the position specified by the instruction builder [b] with
|
||||||
|
space reserved for [count] cases.
|
||||||
See the method [llvm::LLVMBuilder::CreateSwitch]. *)
|
See the method [llvm::LLVMBuilder::CreateSwitch]. *)
|
||||||
external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
|
external build_switch : llvalue -> llbasicblock -> int -> llbuilder -> llvalue
|
||||||
= "llvm_build_switch"
|
= "llvm_build_switch"
|
||||||
|
|
||||||
|
(** [add_case sw onval bb] causes switch instruction [sw] to branch to [bb]
|
||||||
|
when its input matches the constant [onval].
|
||||||
|
See the method [llvm::SwitchInst::addCase]. **)
|
||||||
|
external add_case : llvalue -> llvalue -> llbasicblock -> unit
|
||||||
|
= "llvm_add_case"
|
||||||
|
|
||||||
(** [build_invoke fn args tobb unwindbb name b] creates an
|
(** [build_invoke fn args tobb unwindbb name b] creates an
|
||||||
[%name = invoke %fn(args) to %tobb unwind %unwindbb]
|
[%name = invoke %fn(args) to %tobb unwind %unwindbb]
|
||||||
instruction at the position specified by the instruction builder [b].
|
instruction at the position specified by the instruction builder [b].
|
||||||
|
@ -848,6 +848,13 @@ CAMLprim LLVMValueRef llvm_build_switch(LLVMValueRef Of,
|
|||||||
return LLVMBuildSwitch(Builder_val(B), Of, Else, Int_val(EstimatedCount));
|
return LLVMBuildSwitch(Builder_val(B), Of, Else, Int_val(EstimatedCount));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CAMLprim value llvm_add_case(LLVMValueRef Switch,
|
||||||
|
LLVMValueRef OnVal,
|
||||||
|
LLVMBasicBlockRef Dest) {
|
||||||
|
LLVMAddCase(Switch, OnVal, Dest);
|
||||||
|
return Val_unit;
|
||||||
|
}
|
||||||
|
|
||||||
/* llvalue -> llvalue array -> llbasicblock -> llbasicblock -> string ->
|
/* llvalue -> llvalue array -> llbasicblock -> llbasicblock -> string ->
|
||||||
llbuilder -> llvalue */
|
llbuilder -> llvalue */
|
||||||
CAMLprim LLVMValueRef llvm_build_invoke_nat(LLVMValueRef Fn, value Args,
|
CAMLprim LLVMValueRef llvm_build_invoke_nat(LLVMValueRef Fn, value Args,
|
||||||
|
@ -825,7 +825,18 @@ let test_builder () =
|
|||||||
ignore (build_cond_br cond bb03 bb00 b)
|
ignore (build_cond_br cond bb03 bb00 b)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
(* TODO: Switch *)
|
group "switch"; begin
|
||||||
|
(* RUN: grep {switch.*P1.*SwiBlock3} < %t.ll
|
||||||
|
* RUN: grep {2,.*SwiBlock2} < %t.ll
|
||||||
|
*)
|
||||||
|
let bb1 = append_block "SwiBlock1" fn in
|
||||||
|
let bb2 = append_block "SwiBlock2" fn in
|
||||||
|
ignore (build_unreachable (builder_at_end bb2));
|
||||||
|
let bb3 = append_block "SwiBlock3" fn in
|
||||||
|
ignore (build_unreachable (builder_at_end bb3));
|
||||||
|
let si = build_switch p1 bb3 1 (builder_at_end bb1) in
|
||||||
|
ignore (add_case si (const_int i32_type 2) bb2)
|
||||||
|
end;
|
||||||
|
|
||||||
group "invoke"; begin
|
group "invoke"; begin
|
||||||
(* RUN: grep {Inst02.*invoke.*P1.*P2} < %t.ll
|
(* RUN: grep {Inst02.*invoke.*P1.*P2} < %t.ll
|
||||||
|
Loading…
Reference in New Issue
Block a user