summaryrefslogtreecommitdiff
path: root/bindings
diff options
context:
space:
mode:
Diffstat (limited to 'bindings')
-rw-r--r--bindings/ocaml/analysis/analysis_ocaml.c12
-rw-r--r--bindings/ocaml/analysis/llvm_analysis.ml3
-rw-r--r--bindings/ocaml/analysis/llvm_analysis.mli11
3 files changed, 26 insertions, 0 deletions
diff --git a/bindings/ocaml/analysis/analysis_ocaml.c b/bindings/ocaml/analysis/analysis_ocaml.c
index e57c5a56d7..97167055f7 100644
--- a/bindings/ocaml/analysis/analysis_ocaml.c
+++ b/bindings/ocaml/analysis/analysis_ocaml.c
@@ -58,3 +58,15 @@ CAMLprim value llvm_assert_valid_function(LLVMValueRef Fn) {
LLVMVerifyFunction(Fn, LLVMAbortProcessAction);
return Val_unit;
}
+
+/* Llvm.llvalue -> unit */
+CAMLprim value llvm_view_function_cfg(LLVMValueRef Fn) {
+ LLVMViewFunctionCFG(Fn);
+ return Val_unit;
+}
+
+/* Llvm.llvalue -> unit */
+CAMLprim value llvm_view_function_cfg_only(LLVMValueRef Fn) {
+ LLVMViewFunctionCFGOnly(Fn);
+ return Val_unit;
+}
diff --git a/bindings/ocaml/analysis/llvm_analysis.ml b/bindings/ocaml/analysis/llvm_analysis.ml
index f4379f8f17..fc4d203707 100644
--- a/bindings/ocaml/analysis/llvm_analysis.ml
+++ b/bindings/ocaml/analysis/llvm_analysis.ml
@@ -17,3 +17,6 @@ external assert_valid_module : Llvm.llmodule -> unit
external assert_valid_function : Llvm.llvalue -> unit
= "llvm_assert_valid_function"
+external view_function_cfg : Llvm.llvalue -> unit = "llvm_view_function_cfg"
+external view_function_cfg_only : Llvm.llvalue -> unit
+ = "llvm_view_function_cfg_only"
diff --git a/bindings/ocaml/analysis/llvm_analysis.mli b/bindings/ocaml/analysis/llvm_analysis.mli
index a97bd7e9e2..793f482e3c 100644
--- a/bindings/ocaml/analysis/llvm_analysis.mli
+++ b/bindings/ocaml/analysis/llvm_analysis.mli
@@ -33,3 +33,14 @@ external assert_valid_module : Llvm.llmodule -> unit
[llvm::verifyFunction]. *)
external assert_valid_function : Llvm.llvalue -> unit
= "llvm_assert_valid_function"
+
+(** [view_function_cfg f] opens up a ghostscript window displaying the CFG of
+ the current function with the code for each basic block inside.
+ See [llvm::Function::viewCFG]. *)
+external view_function_cfg : Llvm.llvalue -> unit = "llvm_view_function_cfg"
+
+(** [view_function_cfg_only f] works just like [view_function_cfg], but does not
+ include the contents of basic blocks into the nodes.
+ See [llvm::Function::viewCFGOnly]. *)
+external view_function_cfg_only : Llvm.llvalue -> unit
+ = "llvm_view_function_cfg_only"