llvm.org GIT mirror llvm / 6b228e5
bindings: named struct support git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@141993 91177308-0d34-0410-b5e6-96231b3b80d8 Torok Edwin 7 years ago
3 changed file(s) with 50 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
293293 external packed_struct_type : llcontext -> lltype array -> lltype
294294 = "llvm_packed_struct_type"
295295 external struct_name : lltype -> string option = "llvm_struct_name"
296 external named_struct_type : llcontext -> string -> lltype =
297 "llvm_named_struct_type"
298 external struct_set_body : lltype -> lltype array -> bool -> unit =
299 "llvm_struct_set_body"
296300 external struct_element_types : lltype -> lltype array
297301 = "llvm_struct_element_types"
298302 external is_packed : lltype -> bool = "llvm_is_packed"
303 external is_opaque : lltype -> bool = "llvm_is_opaque"
299304
300305 (*--... Operations on pointer, vector, and array types .....................--*)
301306 external array_type : lltype -> int -> lltype = "llvm_array_type"
399404 external const_array : lltype -> llvalue array -> llvalue = "llvm_const_array"
400405 external const_struct : llcontext -> llvalue array -> llvalue
401406 = "llvm_const_struct"
407 external const_named_struct : lltype -> llvalue array -> llvalue
408 = "llvm_const_named_struct"
402409 external const_packed_struct : llcontext -> llvalue array -> llvalue
403410 = "llvm_const_packed_struct"
404411 external const_vector : llvalue array -> llvalue = "llvm_const_vector"
477477 * or None if the structure type is not named *)
478478 val struct_name : lltype -> string option
479479
480 (** [named_struct_type context name] returns the named structure type [name]
481 * in the context [context].
482 * See the method [llvm::StructType::get]. *)
483 val named_struct_type : llcontext -> string -> lltype
484
485 (** [struct_set_body ty elts ispacked] sets the body of the named struct [ty]
486 * to the [elts] elements.
487 * See the moethd [llvm::StructType::setBody]. *)
488 val struct_set_body : lltype -> lltype array -> bool -> unit
480489
481490 (** [struct_element_types sty] returns the constituent types of the struct type
482491 [sty]. See the method [llvm::StructType::getElementType]. *)
487496 [false] otherwise. See the method [llvm::StructType::isPacked]. *)
488497 val is_packed : lltype -> bool
489498
499 (** [is_opaque sty] returns [true] if the structure type [sty] is opaque.
500 [false] otherwise. See the method [llvm::StructType::isOpaque]. *)
501 val is_opaque : lltype -> bool
490502
491503 (** {7 Operations on pointer, vector, and array types} *)
492504
737749 (** [const_struct context elts] returns the structured constant of type
738750 [struct_type (Array.map type_of elts)] and containing the values [elts]
739751 in the context [context]. This value can in turn be used as the initializer
752 for a global variable. See the method [llvm::ConstantStruct::getAnon]. *)
753 val const_struct : llcontext -> llvalue array -> llvalue
754
755 (** [const_named_struct namedty elts] returns the structured constant of type
756 [namedty] (which must be a named structure type) and containing the values [elts].
757 This value can in turn be used as the initializer
740758 for a global variable. See the method [llvm::ConstantStruct::get]. *)
741 val const_struct : llcontext -> llvalue array -> llvalue
742
759 val const_named_struct : lltype -> llvalue array -> llvalue
743760
744761 (** [const_packed_struct context elts] returns the structured constant of
745762 type {!packed_struct_type} [(Array.map type_of elts)] and containing the
291291 Wosize_val(ElementTypes), 1);
292292 }
293293
294 /* llcontext -> string -> lltype */
295 CAMLprim LLVMTypeRef llvm_named_struct_type(LLVMContextRef C,
296 value Name) {
297 return LLVMStructCreateNamed(C, String_val(Name));
298 }
299
300 CAMLprim value llvm_struct_set_body(LLVMTypeRef Ty,
301 value ElementTypes,
302 value Packed) {
303 LLVMStructSetBody(Ty, (LLVMTypeRef *) ElementTypes,
304 Wosize_val(ElementTypes), Bool_val(Packed));
305 return Val_unit;
306 }
307
294308 /* lltype -> string option */
295309 CAMLprim value llvm_struct_name(LLVMTypeRef Ty)
296310 {
315329 /* lltype -> bool */
316330 CAMLprim value llvm_is_packed(LLVMTypeRef StructTy) {
317331 return Val_bool(LLVMIsPackedStruct(StructTy));
332 }
333
334 /* lltype -> bool */
335 CAMLprim value llvm_is_opaque(LLVMTypeRef StructTy) {
336 return Val_bool(LLVMIsOpaqueStruct(StructTy));
318337 }
319338
320339 /*--... Operations on array, pointer, and vector types .....................--*/
640659 Wosize_val(ElementVals), 0);
641660 }
642661
662 /* lltype -> llvalue array -> llvalue */
663 CAMLprim LLVMValueRef llvm_const_named_struct(LLVMTypeRef Ty, value ElementVals) {
664 return LLVMConstNamedStruct(Ty, (LLVMValueRef *) Op_val(ElementVals), Wosize_val(ElementVals));
665 }
666
643667 /* llcontext -> llvalue array -> llvalue */
644668 CAMLprim LLVMValueRef llvm_const_packed_struct(LLVMContextRef C,
645669 value ElementVals) {