Home | History | Annotate | Download | only in target
      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 DataLayout : sig
     22   type t
     23 
     24   (** [DataLayout.create rep] parses the target data string representation [rep].
     25       See the constructor llvm::DataLayout::DataLayout. *)
     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::DataLayout::DataLayout. *)
     36   external as_string : t -> string = "llvm_targetdata_as_string"
     37 
     38   (** Deallocates a DataLayout.
     39       See the destructor llvm::DataLayout::~DataLayout. *)
     40   external dispose : t -> unit = "llvm_targetdata_dispose"
     41 end
     42 
     43 (** Returns the byte order of a target, either LLVMBigEndian or
     44     LLVMLittleEndian.
     45     See the method llvm::DataLayout::isLittleEndian. *)
     46 external byte_order : DataLayout.t -> Endian.t = "llvm_byte_order"
     47 
     48 (** Returns the pointer size in bytes for a target.
     49     See the method llvm::DataLayout::getPointerSize. *)
     50 external pointer_size : DataLayout.t -> int = "llvm_pointer_size"
     51 
     52 (** Returns the integer type that is the same size as a pointer on a target.
     53     See the method llvm::DataLayout::getIntPtrType. *)
     54 external intptr_type : DataLayout.t -> Llvm.lltype = "LLVMIntPtrType"
     55 
     56 (** Computes the size of a type in bytes for a target.
     57     See the method llvm::DataLayout::getTypeSizeInBits. *)
     58 external size_in_bits : DataLayout.t -> Llvm.lltype -> Int64.t
     59                       = "llvm_size_in_bits"
     60 
     61 (** Computes the storage size of a type in bytes for a target.
     62     See the method llvm::DataLayout::getTypeStoreSize. *)
     63 external store_size : DataLayout.t -> Llvm.lltype -> Int64.t = "llvm_store_size"
     64 
     65 (** Computes the ABI size of a type in bytes for a target.
     66     See the method llvm::DataLayout::getTypeAllocSize. *)
     67 external abi_size : DataLayout.t -> Llvm.lltype -> Int64.t = "llvm_abi_size"
     68 
     69 (** Computes the ABI alignment of a type in bytes for a target.
     70     See the method llvm::DataLayout::getTypeABISize. *)
     71 external abi_align : DataLayout.t -> Llvm.lltype -> int = "llvm_abi_align"
     72 
     73 (** Computes the call frame alignment of a type in bytes for a target.
     74     See the method llvm::DataLayout::getTypeABISize. *)
     75 external stack_align : DataLayout.t -> Llvm.lltype -> int = "llvm_stack_align"
     76 
     77 (** Computes the preferred alignment of a type in bytes for a target.
     78     See the method llvm::DataLayout::getTypeABISize. *)
     79 external preferred_align : DataLayout.t -> Llvm.lltype -> int
     80                          = "llvm_preferred_align"
     81 
     82 (** Computes the preferred alignment of a global variable in bytes for a target.
     83     See the method llvm::DataLayout::getPreferredAlignment. *)
     84 external preferred_align_of_global : DataLayout.t -> Llvm.llvalue -> int
     85                                    = "llvm_preferred_align_of_global"
     86 
     87 (** Computes the structure element that contains the byte offset for a target.
     88     See the method llvm::StructLayout::getElementContainingOffset. *)
     89 external element_at_offset : DataLayout.t -> Llvm.lltype -> Int64.t -> int
     90                            = "llvm_element_at_offset"
     91 
     92 (** Computes the byte offset of the indexed struct element for a target.
     93     See the method llvm::StructLayout::getElementContainingOffset. *)
     94 external offset_of_element : DataLayout.t -> Llvm.lltype -> int -> Int64.t
     95                            = "llvm_offset_of_element"
     96