| Pointer
| Opaque
| Vector
+ | Metadata
end
(** The linkage of a global value, accessed with {!linkage} and
module Linkage : sig
type t =
External
+ | Available_externally
| Link_once
| Weak
| Appending
convention from C. *)
end
+module Attribute : sig
+ type t =
+ | Zext
+ | Sext
+ | Noreturn
+ | Inreg
+ | Structret
+ | Nounwind
+ | Noalias
+ | Byval
+ | Nest
+ | Readnone
+ | Readonly
+end
+
(** The predicate for an integer comparison ([icmp]) instruction.
See the [llvm::ICmpInst::Predicate] enumeration. *)
module Icmp : sig
= "llvm_const_of_int64"
(** [const_float ty n] returns the floating point constant of type [ty] and
- value [n]. See the method [llvm::ConstantInt::get]. *)
+ value [n]. See the method [llvm::ConstantFP::get]. *)
external const_float : lltype -> float -> llvalue = "llvm_const_float"
(** {7 Constant expressions} *)
+(** [align_of ty] returns the alignof constant for the type [ty]. This is
+ equivalent to [const_ptrtoint (const_gep (const_null (pointer_type {i8,ty}))
+ (const_int i32_type 0) (const_int i32_type 1)) i32_type], but considerably
+ more readable. See the method [llvm::ConstantExpr::getAlignOf]. *)
+external align_of : lltype -> llvalue = "LLVMAlignOf"
+
(** [size_of ty] returns the sizeof constant for the type [ty]. This is
equivalent to [const_ptrtoint (const_gep (const_null (pointer_type ty))
- (const_int i64_type 1)) i64_type], but considerably more readable.
+ (const_int i32_type 1)) i64_type], but considerably more readable.
See the method [llvm::ConstantExpr::getSizeOf]. *)
external size_of : lltype -> llvalue = "LLVMSizeOf"
external set_global_constant : bool -> llvalue -> unit
= "llvm_set_global_constant"
-(** [has_initializer gv] returns [true] if the global variable [gv] has an
- initializer and [false] otherwise.
- See the method [llvm::GlobalVariable::hasInitializer]. *)
-external has_initializer : llvalue -> bool = "llvm_has_initializer"
-
(** [global_initializer gv] returns the initializer for the global variable
[gv]. See the method [llvm::GlobalVariable::getInitializer]. *)
external global_initializer : llvalue -> llvalue = "LLVMGetInitializer"
external set_function_call_conv : int -> llvalue -> unit
= "llvm_set_function_call_conv"
-(** [collector f] returns [Some name] if the function [f] has a garbage
+(** [gc f] returns [Some name] if the function [f] has a garbage
collection algorithm specified and [None] otherwise.
- See the method [llvm::Function::getCollector]. *)
-external collector : llvalue -> string option = "llvm_collector"
+ See the method [llvm::Function::getGC]. *)
+external gc : llvalue -> string option = "llvm_gc"
+
+(** [set_gc gc f] sets the collection algorithm for the function [f] to
+ [gc]. See the method [llvm::Function::setGC]. *)
+external set_gc : string option -> llvalue -> unit = "llvm_set_gc"
-(** [set_collector gc f] sets the collection algorithm for the function [f] to
- [gc]. See the method [llvm::Function::setCollector]. *)
-external set_collector : string option -> llvalue -> unit = "llvm_set_collector"
+(** [add_function_attr f a] adds attribute [a] to the return type of function
+ [f]. *)
+external add_function_attr : llvalue -> Attribute.t -> unit
+ = "llvm_add_function_attr"
+(** [remove_function_attr f a] removes attribute [a] from the return type of
+ function [f]. *)
+external remove_function_attr : llvalue -> Attribute.t -> unit
+ = "llvm_remove_function_attr"
(** {7 Operations on params} *)
[b1,...,bN] are the parameters of function [fn]. Tail recursive. *)
val fold_right_params : (llvalue -> 'a -> 'a) -> llvalue -> 'a -> 'a
+(** [add_param p a] adds attribute [a] to parameter [p]. *)
+external add_param_attr : llvalue -> Attribute.t -> unit = "llvm_add_param_attr"
+
+(** [remove_param_attr p a] removes attribute [a] from parameter [p]. *)
+external remove_param_attr : llvalue -> Attribute.t -> unit
+ = "llvm_remove_param_attr"
+
+(** [set_param_alignment p a] set the alignment of parameter [p] to [a]. *)
+external set_param_alignment : llvalue -> int -> unit
+ = "llvm_set_param_alignment"
(** {7 Operations on basic blocks} *)
external set_instruction_call_conv: int -> llvalue -> unit
= "llvm_set_instruction_call_conv"
+(** [add_instruction_param_attr ci i a] adds attribute [a] to the [i]th
+ parameter of the call or invoke instruction [ci]. [i]=0 denotes the return
+ value. *)
+external add_instruction_param_attr : llvalue -> int -> Attribute.t -> unit
+ = "llvm_add_instruction_param_attr"
+
+(** [remove_instruction_param_attr ci i a] removes attribute [a] from the
+ [i]th parameter of the call or invoke instruction [ci]. [i]=0 denotes the
+ return value. *)
+external remove_instruction_param_attr : llvalue -> int -> Attribute.t -> unit
+ = "llvm_remove_instruction_param_attr"
+
+(** {Operations on call instructions (only)} *)
+
+(** [is_tail_call ci] is [true] if the call instruction [ci] is flagged as
+ eligible for tail call optimization, [false] otherwise.
+ See the method [llvm::CallInst::isTailCall]. *)
+external is_tail_call : llvalue -> bool = "llvm_is_tail_call"
+
+(** [set_tail_call tc ci] flags the call instruction [ci] as eligible for tail
+ call optimization if [tc] is [true], clears otherwise.
+ See the method [llvm::CallInst::setTailCall]. *)
+external set_tail_call : bool -> llvalue -> unit = "llvm_set_tail_call"
(** {7 Operations on phi nodes} *)