mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
bindings: named struct support
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141993 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
4c4b71cec5
commit
6b228e506f
@ -294,9 +294,14 @@ external struct_type : llcontext -> lltype array -> lltype = "llvm_struct_type"
|
||||
external packed_struct_type : llcontext -> lltype array -> lltype
|
||||
= "llvm_packed_struct_type"
|
||||
external struct_name : lltype -> string option = "llvm_struct_name"
|
||||
external named_struct_type : llcontext -> string -> lltype =
|
||||
"llvm_named_struct_type"
|
||||
external struct_set_body : lltype -> lltype array -> bool -> unit =
|
||||
"llvm_struct_set_body"
|
||||
external struct_element_types : lltype -> lltype array
|
||||
= "llvm_struct_element_types"
|
||||
external is_packed : lltype -> bool = "llvm_is_packed"
|
||||
external is_opaque : lltype -> bool = "llvm_is_opaque"
|
||||
|
||||
(*--... Operations on pointer, vector, and array types .....................--*)
|
||||
external array_type : lltype -> int -> lltype = "llvm_array_type"
|
||||
@ -400,6 +405,8 @@ external const_stringz : llcontext -> string -> llvalue = "llvm_const_stringz"
|
||||
external const_array : lltype -> llvalue array -> llvalue = "llvm_const_array"
|
||||
external const_struct : llcontext -> llvalue array -> llvalue
|
||||
= "llvm_const_struct"
|
||||
external const_named_struct : lltype -> llvalue array -> llvalue
|
||||
= "llvm_const_named_struct"
|
||||
external const_packed_struct : llcontext -> llvalue array -> llvalue
|
||||
= "llvm_const_packed_struct"
|
||||
external const_vector : llvalue array -> llvalue = "llvm_const_vector"
|
||||
|
@ -478,6 +478,15 @@ val packed_struct_type : llcontext -> lltype array -> lltype
|
||||
* or None if the structure type is not named *)
|
||||
val struct_name : lltype -> string option
|
||||
|
||||
(** [named_struct_type context name] returns the named structure type [name]
|
||||
* in the context [context].
|
||||
* See the method [llvm::StructType::get]. *)
|
||||
val named_struct_type : llcontext -> string -> lltype
|
||||
|
||||
(** [struct_set_body ty elts ispacked] sets the body of the named struct [ty]
|
||||
* to the [elts] elements.
|
||||
* See the moethd [llvm::StructType::setBody]. *)
|
||||
val struct_set_body : lltype -> lltype array -> bool -> unit
|
||||
|
||||
(** [struct_element_types sty] returns the constituent types of the struct type
|
||||
[sty]. See the method [llvm::StructType::getElementType]. *)
|
||||
@ -488,6 +497,9 @@ val struct_element_types : lltype -> lltype array
|
||||
[false] otherwise. See the method [llvm::StructType::isPacked]. *)
|
||||
val is_packed : lltype -> bool
|
||||
|
||||
(** [is_opaque sty] returns [true] if the structure type [sty] is opaque.
|
||||
[false] otherwise. See the method [llvm::StructType::isOpaque]. *)
|
||||
val is_opaque : lltype -> bool
|
||||
|
||||
(** {7 Operations on pointer, vector, and array types} *)
|
||||
|
||||
@ -738,9 +750,14 @@ val const_array : lltype -> llvalue array -> llvalue
|
||||
(** [const_struct context elts] returns the structured constant of type
|
||||
[struct_type (Array.map type_of elts)] and containing the values [elts]
|
||||
in the context [context]. This value can in turn be used as the initializer
|
||||
for a global variable. See the method [llvm::ConstantStruct::get]. *)
|
||||
for a global variable. See the method [llvm::ConstantStruct::getAnon]. *)
|
||||
val const_struct : llcontext -> llvalue array -> llvalue
|
||||
|
||||
(** [const_named_struct namedty elts] returns the structured constant of type
|
||||
[namedty] (which must be a named structure type) and containing the values [elts].
|
||||
This value can in turn be used as the initializer
|
||||
for a global variable. See the method [llvm::ConstantStruct::get]. *)
|
||||
val const_named_struct : lltype -> llvalue array -> llvalue
|
||||
|
||||
(** [const_packed_struct context elts] returns the structured constant of
|
||||
type {!packed_struct_type} [(Array.map type_of elts)] and containing the
|
||||
|
@ -292,6 +292,20 @@ CAMLprim LLVMTypeRef llvm_packed_struct_type(LLVMContextRef C,
|
||||
Wosize_val(ElementTypes), 1);
|
||||
}
|
||||
|
||||
/* llcontext -> string -> lltype */
|
||||
CAMLprim LLVMTypeRef llvm_named_struct_type(LLVMContextRef C,
|
||||
value Name) {
|
||||
return LLVMStructCreateNamed(C, String_val(Name));
|
||||
}
|
||||
|
||||
CAMLprim value llvm_struct_set_body(LLVMTypeRef Ty,
|
||||
value ElementTypes,
|
||||
value Packed) {
|
||||
LLVMStructSetBody(Ty, (LLVMTypeRef *) ElementTypes,
|
||||
Wosize_val(ElementTypes), Bool_val(Packed));
|
||||
return Val_unit;
|
||||
}
|
||||
|
||||
/* lltype -> string option */
|
||||
CAMLprim value llvm_struct_name(LLVMTypeRef Ty)
|
||||
{
|
||||
@ -318,6 +332,11 @@ CAMLprim value llvm_is_packed(LLVMTypeRef StructTy) {
|
||||
return Val_bool(LLVMIsPackedStruct(StructTy));
|
||||
}
|
||||
|
||||
/* lltype -> bool */
|
||||
CAMLprim value llvm_is_opaque(LLVMTypeRef StructTy) {
|
||||
return Val_bool(LLVMIsOpaqueStruct(StructTy));
|
||||
}
|
||||
|
||||
/*--... Operations on array, pointer, and vector types .....................--*/
|
||||
|
||||
/* lltype -> int -> lltype */
|
||||
@ -641,6 +660,11 @@ CAMLprim LLVMValueRef llvm_const_struct(LLVMContextRef C, value ElementVals) {
|
||||
Wosize_val(ElementVals), 0);
|
||||
}
|
||||
|
||||
/* lltype -> llvalue array -> llvalue */
|
||||
CAMLprim LLVMValueRef llvm_const_named_struct(LLVMTypeRef Ty, value ElementVals) {
|
||||
return LLVMConstNamedStruct(Ty, (LLVMValueRef *) Op_val(ElementVals), Wosize_val(ElementVals));
|
||||
}
|
||||
|
||||
/* llcontext -> llvalue array -> llvalue */
|
||||
CAMLprim LLVMValueRef llvm_const_packed_struct(LLVMContextRef C,
|
||||
value ElementVals) {
|
||||
|
Loading…
Reference in New Issue
Block a user