Gordon Henriksen | 3e0c835 | 2008-03-16 20:08:03 +0000 | [diff] [blame^] | 1 | (*===-- llvm_target.mli - LLVM Ocaml Interface -----------------*- OCaml -*-===* |
| 2 | * |
| 3 | * The LLVM Compiler Infrastructure |
| 4 | * |
| 5 | * This file is distributed under the University of Illinois Open Source |
| 6 | * License. See LICENSE.TXT for details. |
| 7 | * |
| 8 | *===----------------------------------------------------------------------===*) |
| 9 | |
| 10 | (** Target Information. |
| 11 | |
| 12 | This interface provides an ocaml API for LLVM target information, |
| 13 | the classes in the Target library. *) |
| 14 | |
| 15 | module Endian : sig |
| 16 | type t = |
| 17 | | Big |
| 18 | | Little |
| 19 | end |
| 20 | |
| 21 | module TargetData : sig |
| 22 | type t |
| 23 | |
| 24 | (** [TargetData.create rep] parses the target data string representation [rep]. |
| 25 | See the constructor llvm::TargetData::TargetData. *) |
| 26 | external create : string -> t = "llvm_targetdata_create" |
| 27 | |
| 28 | (** [add_target_data td pm] adds the target data [td] to the pass manager [pm]. |
| 29 | Does not take ownership of the target data. |
| 30 | See the method llvm::PassManagerBase::add. *) |
| 31 | external add : t -> [<Llvm.PassManager.any] Llvm.PassManager.t -> unit |
| 32 | = "llvm_targetdata_add" |
| 33 | |
| 34 | (** [as_string td] is the string representation of the target data [td]. |
| 35 | See the constructor llvm::TargetData::TargetData. *) |
| 36 | external as_string : t -> string = "llvm_targetdata_as_string" |
| 37 | |
| 38 | (** Struct layouts are speculatively cached. If a TargetDataRef is alive when |
| 39 | types are being refined and removed, this method must be called whenever a |
| 40 | struct type is removed to avoid a dangling pointer in this cache. |
| 41 | See the method llvm::TargetData::InvalidateStructLayoutInfo. *) |
| 42 | external invalidate_struct_layout : t -> Llvm.lltype -> unit |
| 43 | = "llvm_targetdata_invalidate_struct_layout" |
| 44 | |
| 45 | (** Deallocates a TargetData. |
| 46 | See the destructor llvm::TargetData::~TargetData. *) |
| 47 | external dispose : t -> unit = "llvm_targetdata_dispose" |
| 48 | end |
| 49 | |
| 50 | (** Returns the byte order of a target, either LLVMBigEndian or |
| 51 | LLVMLittleEndian. |
| 52 | See the method llvm::TargetData::isLittleEndian. *) |
| 53 | external byte_order : TargetData.t -> Endian.t = "llvm_byte_order" |
| 54 | |
| 55 | (** Returns the pointer size in bytes for a target. |
| 56 | See the method llvm::TargetData::getPointerSize. *) |
| 57 | external pointer_size : TargetData.t -> int = "llvm_pointer_size" |
| 58 | |
| 59 | (** Returns the integer type that is the same size as a pointer on a target. |
| 60 | See the method llvm::TargetData::getIntPtrType. *) |
| 61 | external intptr_type : TargetData.t -> Llvm.lltype = "LLVMIntPtrType" |
| 62 | |
| 63 | (** Computes the size of a type in bytes for a target. |
| 64 | See the method llvm::TargetData::getTypeSizeInBits. *) |
| 65 | external size_in_bits : TargetData.t -> Llvm.lltype -> Int64.t |
| 66 | = "llvm_size_in_bits" |
| 67 | |
| 68 | (** Computes the storage size of a type in bytes for a target. |
| 69 | See the method llvm::TargetData::getTypeStoreSize. *) |
| 70 | external store_size : TargetData.t -> Llvm.lltype -> Int64.t = "llvm_store_size" |
| 71 | |
| 72 | (** Computes the ABI size of a type in bytes for a target. |
| 73 | See the method llvm::TargetData::getABITypeSize. *) |
| 74 | external abi_size : TargetData.t -> Llvm.lltype -> Int64.t = "llvm_abi_size" |
| 75 | |
| 76 | (** Computes the ABI alignment of a type in bytes for a target. |
| 77 | See the method llvm::TargetData::getTypeABISize. *) |
| 78 | external abi_align : TargetData.t -> Llvm.lltype -> int = "llvm_abi_align" |
| 79 | |
| 80 | (** Computes the call frame alignment of a type in bytes for a target. |
| 81 | See the method llvm::TargetData::getTypeABISize. *) |
| 82 | external stack_align : TargetData.t -> Llvm.lltype -> int = "llvm_stack_align" |
| 83 | |
| 84 | (** Computes the preferred alignment of a type in bytes for a target. |
| 85 | See the method llvm::TargetData::getTypeABISize. *) |
| 86 | external preferred_align : TargetData.t -> Llvm.lltype -> int |
| 87 | = "llvm_preferred_align" |
| 88 | |
| 89 | (** Computes the preferred alignment of a global variable in bytes for a target. |
| 90 | See the method llvm::TargetData::getPreferredAlignment. *) |
| 91 | external preferred_align_of_global : TargetData.t -> Llvm.llvalue -> int |
| 92 | = "llvm_preferred_align_of_global" |
| 93 | |
| 94 | (** Computes the structure element that contains the byte offset for a target. |
| 95 | See the method llvm::StructLayout::getElementContainingOffset. *) |
| 96 | external element_at_offset : TargetData.t -> Llvm.lltype -> Int64.t -> int |
| 97 | = "llvm_element_at_offset" |
| 98 | |
| 99 | (** Computes the byte offset of the indexed struct element for a target. |
| 100 | See the method llvm::StructLayout::getElementContainingOffset. *) |
| 101 | external offset_of_element : TargetData.t -> Llvm.lltype -> int -> Int64.t |
| 102 | = "llvm_offset_of_element" |