Expose Function::viewCFG and Function::viewCFGOnly to bindings.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48982 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Erick Tryzelaar 2008-03-31 16:22:09 +00:00
parent 86550b0a14
commit d6d018589c
5 changed files with 39 additions and 0 deletions

View File

@ -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;
}

View File

@ -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"

View File

@ -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"

View File

@ -43,6 +43,10 @@ int LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action,
for debugging. */
int LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action);
/* Open up a ghostview window that displays the CFG of the current function.
Useful for debugging. */
void LLVMViewFunctionCFG(LLVMValueRef Fn);
void LLVMViewFunctionCFGOnly(LLVMValueRef Fn);
#ifdef __cplusplus
}

View File

@ -33,3 +33,12 @@ int LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action) {
static_cast<VerifierFailureAction>(Action));
}
void LLVMViewFunctionCFG(LLVMValueRef Fn) {
Function *F = unwrap<Function>(Fn);
F->viewCFG();
}
void LLVMViewFunctionCFGOnly(LLVMValueRef Fn) {
Function *F = unwrap<Function>(Fn);
F->viewCFGOnly();
}