Skip to content

Commit

Permalink
Move TargetData to DataLayout.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165403 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
mvillmow committed Oct 8, 2012
1 parent 3574eca commit 791cfc2
Show file tree
Hide file tree
Showing 32 changed files with 157 additions and 157 deletions.
4 changes: 2 additions & 2 deletions bindings/ocaml/executionengine/llvm_executionengine.ml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ module ExecutionEngine = struct
external free_machine_code: Llvm.llvalue -> t -> unit
= "llvm_ee_free_machine_code"

external target_data: t -> Llvm_target.TargetData.t
= "LLVMGetExecutionEngineTargetData"
external target_data: t -> Llvm_target.DataLayout.t
= "LLVMGetExecutionEngineDataLayout"

(* The following are not bound. Patches are welcome.

Expand Down
2 changes: 1 addition & 1 deletion bindings/ocaml/executionengine/llvm_executionengine.mli
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ module ExecutionEngine: sig

(** [target_data ee] is the target data owned by the execution engine
[ee]. *)
val target_data : t -> Llvm_target.TargetData.t
val target_data : t -> Llvm_target.DataLayout.t

end

Expand Down
2 changes: 1 addition & 1 deletion bindings/ocaml/llvm/llvm.mli
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ val module_context : llmodule -> llcontext
val classify_type : lltype -> TypeKind.t

(** [type_is_sized ty] returns whether the type has a size or not.
* If it doesn't then it is not safe to call the [TargetData::] methods on it.
* If it doesn't then it is not safe to call the [DataLayout::] methods on it.
* *)
val type_is_sized : lltype -> bool

Expand Down
26 changes: 13 additions & 13 deletions bindings/ocaml/target/llvm_target.ml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ module Endian = struct
| Little
end

module TargetData = struct
module DataLayout = struct
type t

external create : string -> t = "llvm_targetdata_create"
Expand All @@ -23,20 +23,20 @@ module TargetData = struct
external dispose : t -> unit = "llvm_targetdata_dispose"
end

external byte_order : TargetData.t -> Endian.t = "llvm_byte_order"
external pointer_size : TargetData.t -> int = "llvm_pointer_size"
external intptr_type : TargetData.t -> Llvm.lltype = "LLVMIntPtrType"
external size_in_bits : TargetData.t -> Llvm.lltype -> Int64.t
external byte_order : DataLayout.t -> Endian.t = "llvm_byte_order"
external pointer_size : DataLayout.t -> int = "llvm_pointer_size"
external intptr_type : DataLayout.t -> Llvm.lltype = "LLVMIntPtrType"
external size_in_bits : DataLayout.t -> Llvm.lltype -> Int64.t
= "llvm_size_in_bits"
external store_size : TargetData.t -> Llvm.lltype -> Int64.t = "llvm_store_size"
external abi_size : TargetData.t -> Llvm.lltype -> Int64.t = "llvm_abi_size"
external abi_align : TargetData.t -> Llvm.lltype -> int = "llvm_abi_align"
external stack_align : TargetData.t -> Llvm.lltype -> int = "llvm_stack_align"
external preferred_align : TargetData.t -> Llvm.lltype -> int
external store_size : DataLayout.t -> Llvm.lltype -> Int64.t = "llvm_store_size"
external abi_size : DataLayout.t -> Llvm.lltype -> Int64.t = "llvm_abi_size"
external abi_align : DataLayout.t -> Llvm.lltype -> int = "llvm_abi_align"
external stack_align : DataLayout.t -> Llvm.lltype -> int = "llvm_stack_align"
external preferred_align : DataLayout.t -> Llvm.lltype -> int
= "llvm_preferred_align"
external preferred_align_of_global : TargetData.t -> Llvm.llvalue -> int
external preferred_align_of_global : DataLayout.t -> Llvm.llvalue -> int
= "llvm_preferred_align_of_global"
external element_at_offset : TargetData.t -> Llvm.lltype -> Int64.t -> int
external element_at_offset : DataLayout.t -> Llvm.lltype -> Int64.t -> int
= "llvm_element_at_offset"
external offset_of_element : TargetData.t -> Llvm.lltype -> int -> Int64.t
external offset_of_element : DataLayout.t -> Llvm.lltype -> int -> Int64.t
= "llvm_offset_of_element"
56 changes: 28 additions & 28 deletions bindings/ocaml/target/llvm_target.mli
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ module Endian : sig
| Little
end

module TargetData : sig
module DataLayout : sig
type t

(** [TargetData.create rep] parses the target data string representation [rep].
See the constructor llvm::TargetData::TargetData. *)
(** [DataLayout.create rep] parses the target data string representation [rep].
See the constructor llvm::DataLayout::DataLayout. *)
external create : string -> t = "llvm_targetdata_create"

(** [add_target_data td pm] adds the target data [td] to the pass manager [pm].
Expand All @@ -32,64 +32,64 @@ module TargetData : sig
= "llvm_targetdata_add"

(** [as_string td] is the string representation of the target data [td].
See the constructor llvm::TargetData::TargetData. *)
See the constructor llvm::DataLayout::DataLayout. *)
external as_string : t -> string = "llvm_targetdata_as_string"

(** Deallocates a TargetData.
See the destructor llvm::TargetData::~TargetData. *)
(** Deallocates a DataLayout.
See the destructor llvm::DataLayout::~DataLayout. *)
external dispose : t -> unit = "llvm_targetdata_dispose"
end

(** Returns the byte order of a target, either LLVMBigEndian or
LLVMLittleEndian.
See the method llvm::TargetData::isLittleEndian. *)
external byte_order : TargetData.t -> Endian.t = "llvm_byte_order"
See the method llvm::DataLayout::isLittleEndian. *)
external byte_order : DataLayout.t -> Endian.t = "llvm_byte_order"

(** Returns the pointer size in bytes for a target.
See the method llvm::TargetData::getPointerSize. *)
external pointer_size : TargetData.t -> int = "llvm_pointer_size"
See the method llvm::DataLayout::getPointerSize. *)
external pointer_size : DataLayout.t -> int = "llvm_pointer_size"

(** Returns the integer type that is the same size as a pointer on a target.
See the method llvm::TargetData::getIntPtrType. *)
external intptr_type : TargetData.t -> Llvm.lltype = "LLVMIntPtrType"
See the method llvm::DataLayout::getIntPtrType. *)
external intptr_type : DataLayout.t -> Llvm.lltype = "LLVMIntPtrType"

(** Computes the size of a type in bytes for a target.
See the method llvm::TargetData::getTypeSizeInBits. *)
external size_in_bits : TargetData.t -> Llvm.lltype -> Int64.t
See the method llvm::DataLayout::getTypeSizeInBits. *)
external size_in_bits : DataLayout.t -> Llvm.lltype -> Int64.t
= "llvm_size_in_bits"

(** Computes the storage size of a type in bytes for a target.
See the method llvm::TargetData::getTypeStoreSize. *)
external store_size : TargetData.t -> Llvm.lltype -> Int64.t = "llvm_store_size"
See the method llvm::DataLayout::getTypeStoreSize. *)
external store_size : DataLayout.t -> Llvm.lltype -> Int64.t = "llvm_store_size"

(** Computes the ABI size of a type in bytes for a target.
See the method llvm::TargetData::getTypeAllocSize. *)
external abi_size : TargetData.t -> Llvm.lltype -> Int64.t = "llvm_abi_size"
See the method llvm::DataLayout::getTypeAllocSize. *)
external abi_size : DataLayout.t -> Llvm.lltype -> Int64.t = "llvm_abi_size"

(** Computes the ABI alignment of a type in bytes for a target.
See the method llvm::TargetData::getTypeABISize. *)
external abi_align : TargetData.t -> Llvm.lltype -> int = "llvm_abi_align"
See the method llvm::DataLayout::getTypeABISize. *)
external abi_align : DataLayout.t -> Llvm.lltype -> int = "llvm_abi_align"

(** Computes the call frame alignment of a type in bytes for a target.
See the method llvm::TargetData::getTypeABISize. *)
external stack_align : TargetData.t -> Llvm.lltype -> int = "llvm_stack_align"
See the method llvm::DataLayout::getTypeABISize. *)
external stack_align : DataLayout.t -> Llvm.lltype -> int = "llvm_stack_align"

(** Computes the preferred alignment of a type in bytes for a target.
See the method llvm::TargetData::getTypeABISize. *)
external preferred_align : TargetData.t -> Llvm.lltype -> int
See the method llvm::DataLayout::getTypeABISize. *)
external preferred_align : DataLayout.t -> Llvm.lltype -> int
= "llvm_preferred_align"

(** Computes the preferred alignment of a global variable in bytes for a target.
See the method llvm::TargetData::getPreferredAlignment. *)
external preferred_align_of_global : TargetData.t -> Llvm.llvalue -> int
See the method llvm::DataLayout::getPreferredAlignment. *)
external preferred_align_of_global : DataLayout.t -> Llvm.llvalue -> int
= "llvm_preferred_align_of_global"

(** Computes the structure element that contains the byte offset for a target.
See the method llvm::StructLayout::getElementContainingOffset. *)
external element_at_offset : TargetData.t -> Llvm.lltype -> Int64.t -> int
external element_at_offset : DataLayout.t -> Llvm.lltype -> Int64.t -> int
= "llvm_element_at_offset"

(** Computes the byte offset of the indexed struct element for a target.
See the method llvm::StructLayout::getElementContainingOffset. *)
external offset_of_element : TargetData.t -> Llvm.lltype -> int -> Int64.t
external offset_of_element : DataLayout.t -> Llvm.lltype -> int -> Int64.t
= "llvm_offset_of_element"
68 changes: 34 additions & 34 deletions bindings/ocaml/target/target_ocaml.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,85 +18,85 @@
#include "llvm-c/Target.h"
#include "caml/alloc.h"

/* string -> TargetData.t */
CAMLprim LLVMTargetDataRef llvm_targetdata_create(value StringRep) {
return LLVMCreateTargetData(String_val(StringRep));
/* string -> DataLayout.t */
CAMLprim LLVMDataLayoutRef llvm_targetdata_create(value StringRep) {
return LLVMCreateDataLayout(String_val(StringRep));
}

/* TargetData.t -> [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
CAMLprim value llvm_targetdata_add(LLVMTargetDataRef TD, LLVMPassManagerRef PM){
LLVMAddTargetData(TD, PM);
/* DataLayout.t -> [<Llvm.PassManager.any] Llvm.PassManager.t -> unit */
CAMLprim value llvm_targetdata_add(LLVMDataLayoutRef TD, LLVMPassManagerRef PM){
LLVMAddDataLayout(TD, PM);
return Val_unit;
}

/* TargetData.t -> string */
CAMLprim value llvm_targetdata_as_string(LLVMTargetDataRef TD) {
char *StringRep = LLVMCopyStringRepOfTargetData(TD);
/* DataLayout.t -> string */
CAMLprim value llvm_targetdata_as_string(LLVMDataLayoutRef TD) {
char *StringRep = LLVMCopyStringRepOfDataLayout(TD);
value Copy = copy_string(StringRep);
LLVMDisposeMessage(StringRep);
return Copy;
}

/* TargetData.t -> unit */
CAMLprim value llvm_targetdata_dispose(LLVMTargetDataRef TD) {
LLVMDisposeTargetData(TD);
/* DataLayout.t -> unit */
CAMLprim value llvm_targetdata_dispose(LLVMDataLayoutRef TD) {
LLVMDisposeDataLayout(TD);
return Val_unit;
}

/* TargetData.t -> Endian.t */
CAMLprim value llvm_byte_order(LLVMTargetDataRef TD) {
/* DataLayout.t -> Endian.t */
CAMLprim value llvm_byte_order(LLVMDataLayoutRef TD) {
return Val_int(LLVMByteOrder(TD));
}

/* TargetData.t -> int */
CAMLprim value llvm_pointer_size(LLVMTargetDataRef TD) {
/* DataLayout.t -> int */
CAMLprim value llvm_pointer_size(LLVMDataLayoutRef TD) {
return Val_int(LLVMPointerSize(TD));
}

/* TargetData.t -> Llvm.lltype -> Int64.t */
CAMLprim value llvm_size_in_bits(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
/* DataLayout.t -> Llvm.lltype -> Int64.t */
CAMLprim value llvm_size_in_bits(LLVMDataLayoutRef TD, LLVMTypeRef Ty) {
return caml_copy_int64(LLVMSizeOfTypeInBits(TD, Ty));
}

/* TargetData.t -> Llvm.lltype -> Int64.t */
CAMLprim value llvm_store_size(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
/* DataLayout.t -> Llvm.lltype -> Int64.t */
CAMLprim value llvm_store_size(LLVMDataLayoutRef TD, LLVMTypeRef Ty) {
return caml_copy_int64(LLVMStoreSizeOfType(TD, Ty));
}

/* TargetData.t -> Llvm.lltype -> Int64.t */
CAMLprim value llvm_abi_size(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
/* DataLayout.t -> Llvm.lltype -> Int64.t */
CAMLprim value llvm_abi_size(LLVMDataLayoutRef TD, LLVMTypeRef Ty) {
return caml_copy_int64(LLVMABISizeOfType(TD, Ty));
}

/* TargetData.t -> Llvm.lltype -> int */
CAMLprim value llvm_abi_align(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
/* DataLayout.t -> Llvm.lltype -> int */
CAMLprim value llvm_abi_align(LLVMDataLayoutRef TD, LLVMTypeRef Ty) {
return Val_int(LLVMABIAlignmentOfType(TD, Ty));
}

/* TargetData.t -> Llvm.lltype -> int */
CAMLprim value llvm_stack_align(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
/* DataLayout.t -> Llvm.lltype -> int */
CAMLprim value llvm_stack_align(LLVMDataLayoutRef TD, LLVMTypeRef Ty) {
return Val_int(LLVMCallFrameAlignmentOfType(TD, Ty));
}

/* TargetData.t -> Llvm.lltype -> int */
CAMLprim value llvm_preferred_align(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
/* DataLayout.t -> Llvm.lltype -> int */
CAMLprim value llvm_preferred_align(LLVMDataLayoutRef TD, LLVMTypeRef Ty) {
return Val_int(LLVMPreferredAlignmentOfType(TD, Ty));
}

/* TargetData.t -> Llvm.llvalue -> int */
CAMLprim value llvm_preferred_align_of_global(LLVMTargetDataRef TD,
/* DataLayout.t -> Llvm.llvalue -> int */
CAMLprim value llvm_preferred_align_of_global(LLVMDataLayoutRef TD,
LLVMValueRef GlobalVar) {
return Val_int(LLVMPreferredAlignmentOfGlobal(TD, GlobalVar));
}

/* TargetData.t -> Llvm.lltype -> Int64.t -> int */
CAMLprim value llvm_element_at_offset(LLVMTargetDataRef TD, LLVMTypeRef Ty,
/* DataLayout.t -> Llvm.lltype -> Int64.t -> int */
CAMLprim value llvm_element_at_offset(LLVMDataLayoutRef TD, LLVMTypeRef Ty,
value Offset) {
return Val_int(LLVMElementAtOffset(TD, Ty, Int_val(Offset)));
}

/* TargetData.t -> Llvm.lltype -> int -> Int64.t */
CAMLprim value llvm_offset_of_element(LLVMTargetDataRef TD, LLVMTypeRef Ty,
/* DataLayout.t -> Llvm.lltype -> int -> Int64.t */
CAMLprim value llvm_offset_of_element(LLVMDataLayoutRef TD, LLVMTypeRef Ty,
value Index) {
return caml_copy_int64(LLVMOffsetOfElement(TD, Ty, Int_val(Index)));
}
14 changes: 7 additions & 7 deletions docs/CodeGenerator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Required components in the code generator
The two pieces of the LLVM code generator are the high-level interface to the
code generator and the set of reusable components that can be used to build
target-specific backends. The two most important interfaces (:raw-html:`<tt>`
`TargetMachine`_ :raw-html:`</tt>` and :raw-html:`<tt>` `TargetData`_
`TargetMachine`_ :raw-html:`</tt>` and :raw-html:`<tt>` `DataLayout`_
:raw-html:`</tt>`) are the only ones that are required to be defined for a
backend to fit into the LLVM system, but the others must be defined if the
reusable code generator components are going to be used.
Expand Down Expand Up @@ -197,7 +197,7 @@ any particular client. These classes are designed to capture the *abstract*
properties of the target (such as the instructions and registers it has), and do
not incorporate any particular pieces of code generation algorithms.

All of the target description classes (except the :raw-html:`<tt>` `TargetData`_
All of the target description classes (except the :raw-html:`<tt>` `DataLayout`_
:raw-html:`</tt>` class) are designed to be subclassed by the concrete target
implementation, and have virtual methods implemented. To get to these
implementations, the :raw-html:`<tt>` `TargetMachine`_ :raw-html:`</tt>` class
Expand All @@ -214,18 +214,18 @@ the ``get*Info`` methods (``getInstrInfo``, ``getRegisterInfo``,
``getFrameInfo``, etc.). This class is designed to be specialized by a concrete
target implementation (e.g., ``X86TargetMachine``) which implements the various
virtual methods. The only required target description class is the
:raw-html:`<tt>` `TargetData`_ :raw-html:`</tt>` class, but if the code
:raw-html:`<tt>` `DataLayout`_ :raw-html:`</tt>` class, but if the code
generator components are to be used, the other interfaces should be implemented
as well.

.. _TargetData:
.. _DataLayout:

The ``TargetData`` class
The ``DataLayout`` class
------------------------

The ``TargetData`` class is the only required target description class, and it
The ``DataLayout`` class is the only required target description class, and it
is the only class that is not extensible (you cannot derived a new class from
it). ``TargetData`` specifies information about how the target lays out memory
it). ``DataLayout`` specifies information about how the target lays out memory
for structures, the alignment requirements for various data types, the size of
pointers in the target, and whether the target is little-endian or
big-endian.
Expand Down
4 changes: 2 additions & 2 deletions docs/GarbageCollection.html
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ <h3>
>#include "llvm/CodeGen/AsmPrinter.h"
#include "llvm/Function.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetData.h"
#include "llvm/DataLayout.h"
#include "llvm/Target/TargetAsmInfo.h"

void MyGCPrinter::beginAssembly(std::ostream &amp;OS, AsmPrinter &amp;AP,
Expand All @@ -1266,7 +1266,7 @@ <h3>
// Set up for emitting addresses.
const char *AddressDirective;
int AddressAlignLog;
if (AP.TM.getTargetData()->getPointerSize() == sizeof(int32_t)) {
if (AP.TM.getDataLayout()->getPointerSize() == sizeof(int32_t)) {
AddressDirective = TAI.getData32bitsDirective();
AddressAlignLog = 2;
} else {
Expand Down
2 changes: 1 addition & 1 deletion docs/LangRef.html
Original file line number Diff line number Diff line change
Expand Up @@ -2104,7 +2104,7 @@ <h5>Overview:</h5>
<p>Structures may optionally be "packed" structures, which indicate that the
alignment of the struct is one byte, and that there is no padding between
the elements. In non-packed structs, padding between field types is inserted
as defined by the TargetData string in the module, which is required to match
as defined by the DataLayout string in the module, which is required to match
what the underlying code generator expects.</p>

<p>Structures can either be "literal" or "identified". A literal structure is
Expand Down
Loading

0 comments on commit 791cfc2

Please sign in to comment.