mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-05 13:26:55 +00:00
C and Objective Caml bindings for the various getParent methods of the IR.
Based on Erick Tryzelaar's patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@48523 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -270,6 +270,7 @@ external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
|
||||
= "LLVMConstShuffleVector"
|
||||
|
||||
(*--... Operations on global variables, functions, and aliases (globals) ...--*)
|
||||
external global_parent : llvalue -> llmodule = "LLVMGetGlobalParent"
|
||||
external is_declaration : llvalue -> bool = "llvm_is_declaration"
|
||||
external linkage : llvalue -> Linkage.t = "llvm_linkage"
|
||||
external set_linkage : Linkage.t -> llvalue -> unit = "llvm_set_linkage"
|
||||
@@ -306,8 +307,6 @@ external define_function : string -> lltype -> llmodule -> llvalue
|
||||
external lookup_function : string -> llmodule -> llvalue option
|
||||
= "llvm_lookup_function"
|
||||
external delete_function : llvalue -> unit = "llvm_delete_function"
|
||||
external params : llvalue -> llvalue array = "llvm_params"
|
||||
external param : llvalue -> int -> llvalue = "llvm_param"
|
||||
external is_intrinsic : llvalue -> bool = "llvm_is_intrinsic"
|
||||
external function_call_conv : llvalue -> int = "llvm_function_call_conv"
|
||||
external set_function_call_conv : int -> llvalue -> unit
|
||||
@@ -317,16 +316,25 @@ external set_collector : string option -> llvalue -> unit = "llvm_set_collector"
|
||||
|
||||
(* TODO: param attrs *)
|
||||
|
||||
(*--... Operations on params ...............................................--*)
|
||||
external params : llvalue -> llvalue array = "llvm_params"
|
||||
external param : llvalue -> int -> llvalue = "llvm_param"
|
||||
external param_parent : llvalue -> llvalue = "LLVMGetParamParent"
|
||||
|
||||
(*--... Operations on basic blocks .........................................--*)
|
||||
external value_of_block : llbasicblock -> llvalue = "LLVMBasicBlockAsValue"
|
||||
external value_is_block : llvalue -> bool = "llvm_value_is_block"
|
||||
external block_of_value : llvalue -> llbasicblock = "LLVMValueAsBasicBlock"
|
||||
external block_parent : llbasicblock -> llvalue = "LLVMGetBasicBlockParent"
|
||||
external basic_blocks : llvalue -> llbasicblock array = "llvm_basic_blocks"
|
||||
external entry_block : llvalue -> llbasicblock = "LLVMGetEntryBasicBlock"
|
||||
external delete_block : llbasicblock -> unit = "llvm_delete_block"
|
||||
external append_block : string -> llvalue -> llbasicblock = "llvm_append_block"
|
||||
external insert_block : string -> llbasicblock -> llbasicblock
|
||||
= "llvm_insert_block"
|
||||
external value_of_block : llbasicblock -> llvalue = "LLVMBasicBlockAsValue"
|
||||
external value_is_block : llvalue -> bool = "llvm_value_is_block"
|
||||
external block_of_value : llvalue -> llbasicblock = "LLVMValueAsBasicBlock"
|
||||
|
||||
(*--... Operations on instructions .........................................--*)
|
||||
external instr_parent : llvalue -> llbasicblock = "LLVMGetInstructionParent"
|
||||
|
||||
(*--... Operations on call sites ...........................................--*)
|
||||
external instruction_call_conv: llvalue -> int
|
||||
@@ -341,13 +349,13 @@ external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming"
|
||||
|
||||
|
||||
(*===-- Instruction builders ----------------------------------------------===*)
|
||||
external builder: unit-> llbuilder
|
||||
= "llvm_builder"
|
||||
external builder: unit-> llbuilder = "llvm_builder"
|
||||
external builder_before : llvalue -> llbuilder = "llvm_builder_before"
|
||||
external builder_at_end : llbasicblock -> llbuilder = "llvm_builder_at_end"
|
||||
external position_before : llvalue -> llbuilder -> unit = "llvm_position_before"
|
||||
external position_at_end : llbasicblock -> llbuilder -> unit
|
||||
= "llvm_position_at_end"
|
||||
external insertion_block : llbuilder -> llbasicblock = "llvm_insertion_block"
|
||||
|
||||
(*--... Terminators ........................................................--*)
|
||||
external build_ret_void : llbuilder -> llvalue = "llvm_build_ret_void"
|
||||
|
@@ -676,6 +676,10 @@ external const_shufflevector : llvalue -> llvalue -> llvalue -> llvalue
|
||||
|
||||
(** {7 Operations on global variables, functions, and aliases (globals)} *)
|
||||
|
||||
(** [global_parent g] is the enclosing module of the global value [g].
|
||||
See the method [llvm::GlobalValue::getParent]. *)
|
||||
external global_parent : llvalue -> llmodule = "LLVMGetGlobalParent"
|
||||
|
||||
(** [is_declaration g] returns [true] if the global value [g] is a declaration
|
||||
only. Returns [false] otherwise.
|
||||
See the method [llvm::GlobalValue::isDeclaration]. *)
|
||||
@@ -808,14 +812,6 @@ external lookup_function : string -> llmodule -> llvalue option
|
||||
See the method [llvm::Function::eraseFromParent]. *)
|
||||
external delete_function : llvalue -> unit = "llvm_delete_function"
|
||||
|
||||
(** [params f] returns the parameters of function [f].
|
||||
See the method [llvm::Function::getArgumentList]. *)
|
||||
external params : llvalue -> llvalue array = "llvm_params"
|
||||
|
||||
(** [param f n] returns the [n]th parameter of function [f].
|
||||
See the method [llvm::Function::getArgumentList]. *)
|
||||
external param : llvalue -> int -> llvalue = "llvm_param"
|
||||
|
||||
(** [is_intrinsic f] returns true if the function [f] is an intrinsic.
|
||||
See the method [llvm::Function::isIntrinsic]. *)
|
||||
external is_intrinsic : llvalue -> bool = "llvm_is_intrinsic"
|
||||
@@ -840,6 +836,21 @@ external collector : llvalue -> string option = "llvm_collector"
|
||||
external set_collector : string option -> llvalue -> unit = "llvm_set_collector"
|
||||
|
||||
|
||||
(** {7 Operations on params} *)
|
||||
|
||||
(** [params f] returns the parameters of function [f].
|
||||
See the method [llvm::Function::getArgumentList]. *)
|
||||
external params : llvalue -> llvalue array = "llvm_params"
|
||||
|
||||
(** [param f n] returns the [n]th parameter of function [f].
|
||||
See the method [llvm::Function::getArgumentList]. *)
|
||||
external param : llvalue -> int -> llvalue = "llvm_param"
|
||||
|
||||
(** [param_parent p] returns the parent function that owns the parameter.
|
||||
See the method [llvm::Argument::getParent]. *)
|
||||
external param_parent : llvalue -> llvalue = "LLVMGetParamParent"
|
||||
|
||||
|
||||
(** {7 Operations on basic blocks} *)
|
||||
|
||||
(** [basic_blocks fn] returns the basic blocks of the function [f].
|
||||
@@ -865,6 +876,10 @@ external append_block : string -> llvalue -> llbasicblock = "llvm_append_block"
|
||||
external insert_block : string -> llbasicblock -> llbasicblock
|
||||
= "llvm_insert_block"
|
||||
|
||||
(** [block_parent bb] returns the parent function that owns the basic block.
|
||||
See the method [llvm::BasicBlock::getParent]. *)
|
||||
external block_parent : llbasicblock -> llvalue = "LLVMGetBasicBlockParent"
|
||||
|
||||
(** [value_of_block bb] losslessly casts [bb] to an [llvalue]. *)
|
||||
external value_of_block : llbasicblock -> llvalue = "LLVMBasicBlockAsValue"
|
||||
|
||||
@@ -877,6 +892,13 @@ external value_is_block : llvalue -> bool = "llvm_value_is_block"
|
||||
external block_of_value : llvalue -> llbasicblock = "LLVMValueAsBasicBlock"
|
||||
|
||||
|
||||
(** {7 Operations on instructions} *)
|
||||
|
||||
(** [instr_parent i] is the enclosing basic block of the instruction [i].
|
||||
See the method [llvm::Instruction::getParent]. *)
|
||||
external instr_parent : llvalue -> llbasicblock = "LLVMGetInstructionParent"
|
||||
|
||||
|
||||
(** {7 Operations on call sites} *)
|
||||
|
||||
(** [instruction_call_conv ci] is the calling convention for the call or invoke
|
||||
@@ -886,9 +908,10 @@ external block_of_value : llvalue -> llbasicblock = "LLVMValueAsBasicBlock"
|
||||
external instruction_call_conv: llvalue -> int
|
||||
= "llvm_instruction_call_conv"
|
||||
|
||||
(** [set_inst_call_conv cc ci] sets the calling convention for the call or
|
||||
invoke instruction [ci] to the integer [cc], which can be one of the values
|
||||
from the module {!CallConv}. See the method [llvm::CallInst::setCallingConv]
|
||||
(** [set_instruction_call_conv cc ci] sets the calling convention for the call
|
||||
or invoke instruction [ci] to the integer [cc], which can be one of the
|
||||
values from the module {!CallConv}.
|
||||
See the method [llvm::CallInst::setCallingConv]
|
||||
and [llvm::InvokeInst::setCallingConv]. *)
|
||||
external set_instruction_call_conv: int -> llvalue -> unit
|
||||
= "llvm_set_instruction_call_conv"
|
||||
@@ -909,8 +932,8 @@ external incoming : llvalue -> (llvalue * llbasicblock) list = "llvm_incoming"
|
||||
|
||||
(** {6 Instruction builders} *)
|
||||
|
||||
(** [builder] creates an instruction builder with no position. It is invalid to
|
||||
use this builder until its position is set with {!position_before} or
|
||||
(** [builder ()] creates an instruction builder with no position. It is invalid
|
||||
to use this builder until its position is set with {!position_before} or
|
||||
{!position_at_end}. See the constructor for [llvm::LLVMBuilder]. *)
|
||||
external builder: unit-> llbuilder
|
||||
= "llvm_builder"
|
||||
@@ -932,6 +955,12 @@ external position_before : llvalue -> llbuilder -> unit = "llvm_position_before"
|
||||
external position_at_end : llbasicblock -> llbuilder -> unit
|
||||
= "llvm_position_at_end"
|
||||
|
||||
(** [insertion_block b] returns the basic block that the builder [b] is
|
||||
positioned to insert into. Raises [Not_Found] if the instruction builder is
|
||||
uninitialized.
|
||||
See the method [llvm::LLVMBuilder::GetInsertBlock]. *)
|
||||
external insertion_block : llbuilder -> llbasicblock = "llvm_insertion_block"
|
||||
|
||||
|
||||
(** {7 Terminators} *)
|
||||
|
||||
|
@@ -761,6 +761,14 @@ CAMLprim value llvm_position_at_end(LLVMBasicBlockRef BB, value B) {
|
||||
return Val_unit;
|
||||
}
|
||||
|
||||
/* llbuilder -> llbasicblock */
|
||||
CAMLprim LLVMBasicBlockRef llvm_insertion_block(LLVMBuilderRef B) {
|
||||
LLVMBasicBlockRef InsertBlock = LLVMGetInsertBlock(Builder_val(B));
|
||||
if (!InsertBlock)
|
||||
raise_not_found();
|
||||
return InsertBlock;
|
||||
}
|
||||
|
||||
/*--... Terminators ........................................................--*/
|
||||
|
||||
/* llbuilder -> llvalue */
|
||||
|
Reference in New Issue
Block a user