[PATCH] OCaml bindings: volatile for load and store instructions
Peter Zotov
whitequark at whitequark.org
Mon Oct 28 13:28:20 PDT 2013
Removed instr_alignment as it was folded into regular alignment/set_alignment function pair
Hi sylvestre.ledru,
http://llvm-reviews.chandlerc.com/D1920
CHANGE SINCE LAST DIFF
http://llvm-reviews.chandlerc.com/D1920?vs=4875&id=5201#toc
Files:
bindings/ocaml/llvm/llvm.ml
bindings/ocaml/llvm/llvm.mli
bindings/ocaml/llvm/llvm_ocaml.c
test/Bindings/Ocaml/vmcore.ml
Index: bindings/ocaml/llvm/llvm.ml
===================================================================
--- bindings/ocaml/llvm/llvm.ml
+++ bindings/ocaml/llvm/llvm.ml
@@ -989,6 +989,10 @@
external is_tail_call : llvalue -> bool = "llvm_is_tail_call"
external set_tail_call : bool -> llvalue -> unit = "llvm_set_tail_call"
+(*--... Operations on load/store instructions (only) .......................--*)
+external is_volatile : llvalue -> bool = "llvm_is_volatile"
+external set_volatile : bool -> llvalue -> unit = "llvm_set_volatile"
+
(*--... Operations on phi nodes ............................................--*)
external add_incoming : (llvalue * llbasicblock) -> llvalue -> unit
= "llvm_add_incoming"
Index: bindings/ocaml/llvm/llvm.mli
===================================================================
--- bindings/ocaml/llvm/llvm.mli
+++ bindings/ocaml/llvm/llvm.mli
@@ -1720,6 +1720,21 @@
val set_tail_call : bool -> llvalue -> unit
+(** {Operations on load/store instructions (only)} *)
+
+(** [is_volatile i] is [true] if the load or store instruction [i] is marked
+ as volatile.
+ See the methods [llvm::LoadInst::isVolatile] and
+ [llvm::StoreInst::isVolatile]. *)
+val is_volatile : llvalue -> bool
+
+(** [set_volatile v i] marks the load or store instruction [i] as volatile
+ if [v] is [true], unmarks otherwise.
+ See the methods [llvm::LoadInst::setVolatile] and
+ [llvm::StoreInst::setVolatile]. *)
+val set_volatile : bool -> llvalue -> unit
+
+
(** {7 Operations on phi nodes} *)
(** [add_incoming (v, bb) pn] adds the value [v] to the phi node [pn] for use
Index: bindings/ocaml/llvm/llvm_ocaml.c
===================================================================
--- bindings/ocaml/llvm/llvm_ocaml.c
+++ bindings/ocaml/llvm/llvm_ocaml.c
@@ -1294,6 +1294,20 @@
return Val_unit;
}
+/*--... Operations on load/store instructions (only)........................--*/
+
+/* llvalue -> bool */
+CAMLprim value llvm_is_volatile(LLVMValueRef MemoryInst) {
+ return Val_bool(LLVMGetVolatile(MemoryInst));
+}
+
+/* bool -> llvalue -> unit */
+CAMLprim value llvm_set_volatile(value IsVolatile,
+ LLVMValueRef MemoryInst) {
+ LLVMSetVolatile(MemoryInst, Bool_val(IsVolatile));
+ return Val_unit;
+}
+
/*--... Operations on phi nodes ............................................--*/
/* (llvalue * llbasicblock) -> llvalue -> unit */
Index: test/Bindings/Ocaml/vmcore.ml
===================================================================
--- test/Bindings/Ocaml/vmcore.ml
+++ test/Bindings/Ocaml/vmcore.ml
@@ -1266,7 +1266,7 @@
(* CHECK: %build_alloca = alloca i32
* CHECK: %build_array_alloca = alloca i32, i32 %P2
* CHECK: %build_load = load i32* %build_array_alloca
- * CHECK: store i32 %P2, i32* %build_alloca
+ * CHECK: store volatile i32 %P2, i32* %build_alloca, align 4
* CHECK: %build_gep = getelementptr i32* %build_array_alloca, i32 %P2
* CHECK: %build_in_bounds_gep = getelementptr inbounds i32* %build_array_alloca, i32 %P2
* CHECK: %build_struct_gep = getelementptr inbounds{{.*}}%build_alloca2, i32 0, i32 1
@@ -1274,7 +1274,9 @@
let alloca = build_alloca i32_type "build_alloca" b in
let array_alloca = build_array_alloca i32_type p2 "build_array_alloca" b in
ignore(build_load array_alloca "build_load" b);
- ignore(build_store p2 alloca b);
+ let store = build_store p2 alloca b in
+ ignore(set_volatile true store);
+ insist(true = is_volatile store);
ignore(build_gep array_alloca [| p2 |] "build_gep" b);
ignore(build_in_bounds_gep array_alloca [| p2 |] "build_in_bounds_gep" b);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1920.2.patch
Type: text/x-patch
Size: 3700 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131028/60c41231/attachment.bin>
More information about the llvm-commits
mailing list