[OCaml] Refactor Llvm_target interface
[oota-llvm.git] / bindings / ocaml / target / llvm_target.mli
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   (** [of_string rep] parses the data layout string representation [rep].
25       See the constructor [llvm::DataLayout::DataLayout]. *)
26   val of_string : string -> t
27
28   (** [as_string dl] is the string representation of the data layout [dl].
29       See the method [llvm::DataLayout::getStringRepresentation]. *)
30   val as_string : t -> string
31
32   (** [add_to_pass_manager dl pm] adds the target data [dl] to
33       the pass manager [pm].
34       See the method [llvm::PassManagerBase::add]. *)
35   val add_to_pass_manager : [<Llvm.PassManager.any] Llvm.PassManager.t ->
36                             t -> unit
37
38   (** Returns the byte order of a target, either [Endian.Big] or
39       [Endian.Little].
40       See the method [llvm::DataLayout::isLittleEndian]. *)
41   val byte_order : t -> Endian.t
42
43   (** Returns the pointer size in bytes for a target.
44       See the method [llvm::DataLayout::getPointerSize]. *)
45   val pointer_size : t -> int
46
47   (** Returns the integer type that is the same size as a pointer on a target.
48       See the method [llvm::DataLayout::getIntPtrType]. *)
49   val intptr_type : Llvm.llcontext -> t -> Llvm.lltype
50
51   (** Returns the pointer size in bytes for a target in a given address space.
52       See the method [llvm::DataLayout::getPointerSize]. *)
53   val qualified_pointer_size : int -> t -> int
54
55   (** Returns the integer type that is the same size as a pointer on a target
56       in a given address space.
57       See the method [llvm::DataLayout::getIntPtrType]. *)
58   val qualified_intptr_type : Llvm.llcontext -> int -> t -> Llvm.lltype
59
60   (** Computes the size of a type in bits for a target.
61       See the method [llvm::DataLayout::getTypeSizeInBits]. *)
62   val size_in_bits : Llvm.lltype -> t -> Int64.t
63
64   (** Computes the storage size of a type in bytes for a target.
65       See the method [llvm::DataLayout::getTypeStoreSize]. *)
66   val store_size : Llvm.lltype -> t -> Int64.t
67
68   (** Computes the ABI size of a type in bytes for a target.
69       See the method [llvm::DataLayout::getTypeAllocSize]. *)
70   val abi_size : Llvm.lltype -> t -> Int64.t
71
72   (** Computes the ABI alignment of a type in bytes for a target.
73       See the method [llvm::DataLayout::getTypeABISize]. *)
74   val abi_align : Llvm.lltype -> t -> int
75
76   (** Computes the call frame alignment of a type in bytes for a target.
77       See the method [llvm::DataLayout::getTypeABISize]. *)
78   val stack_align : Llvm.lltype -> t -> int
79
80   (** Computes the preferred alignment of a type in bytes for a target.
81       See the method [llvm::DataLayout::getTypeABISize]. *)
82   val preferred_align : Llvm.lltype -> t -> int
83
84   (** Computes the preferred alignment of a global variable in bytes for
85       a target. See the method [llvm::DataLayout::getPreferredAlignment]. *)
86   val preferred_align_of_global : Llvm.llvalue -> t -> int
87
88   (** Computes the structure element that contains the byte offset for a target.
89       See the method [llvm::StructLayout::getElementContainingOffset]. *)
90   val element_at_offset : Llvm.lltype -> Int64.t -> t -> int
91
92   (** Computes the byte offset of the indexed struct element for a target.
93       See the method [llvm::StructLayout::getElementContainingOffset]. *)
94   val offset_of_element : Llvm.lltype -> int -> t -> Int64.t
95 end