1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

Move TargetData to DataLayout.

llvm-svn: 165403
This commit is contained in:
Micah Villmow 2012-10-08 16:39:34 +00:00
parent bb1a25cd67
commit fe3338a7eb
32 changed files with 157 additions and 157 deletions

View File

@ -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.

View File

@ -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

View File

@ -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

View File

@ -13,7 +13,7 @@ module Endian = struct
| Little
end
module TargetData = struct
module DataLayout = struct
type t
external create : string -> t = "llvm_targetdata_create"
@ -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"

View File

@ -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].
@ -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"

View File

@ -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)));
}

View File

@ -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.
@ -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
@ -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.

View File

@ -1253,7 +1253,7 @@ methods. Here's a realistic example:</p>
>#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,
@ -1266,7 +1266,7 @@ void MyGCPrinter::finishAssembly(std::ostream &amp;OS, AsmPrinter &amp;AP,
// 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 {

View File

@ -2104,7 +2104,7 @@ in signal handlers).</p>
<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

View File

@ -314,14 +314,14 @@ represent target components. These methods are named <tt>get*Info</tt>, and are
intended to obtain the instruction set (<tt>getInstrInfo</tt>), register set
(<tt>getRegisterInfo</tt>), stack frame layout (<tt>getFrameInfo</tt>), and
similar information. <tt>XXXTargetMachine</tt> must also implement the
<tt>getTargetData</tt> method to access an object with target-specific data
<tt>getDataLayout</tt> method to access an object with target-specific data
characteristics, such as data type size and alignment requirements.
</p>
<p>
For instance, for the SPARC target, the header file
<tt>SparcTargetMachine.h</tt> declares prototypes for several <tt>get*Info</tt>
and <tt>getTargetData</tt> methods that simply return a class member.
and <tt>getDataLayout</tt> methods that simply return a class member.
</p>
<div class="doc_code">
@ -331,7 +331,7 @@ namespace llvm {
class Module;
class SparcTargetMachine : public LLVMTargetMachine {
const TargetData DataLayout; // Calculates type size &amp; alignment
const DataLayout DataLayout; // Calculates type size &amp; alignment
SparcSubtarget Subtarget;
SparcInstrInfo InstrInfo;
TargetFrameInfo FrameInfo;
@ -348,7 +348,7 @@ public:
virtual const TargetRegisterInfo *getRegisterInfo() const {
return &amp;InstrInfo.getRegisterInfo();
}
virtual const TargetData *getTargetData() const { return &amp;DataLayout; }
virtual const DataLayout *getDataLayout() const { return &amp;DataLayout; }
static unsigned getModuleMatchQuality(const Module &amp;M);
// Pass Pipeline Configuration
@ -364,7 +364,7 @@ public:
<li><tt>getInstrInfo()</tt></li>
<li><tt>getRegisterInfo()</tt></li>
<li><tt>getFrameInfo()</tt></li>
<li><tt>getTargetData()</tt></li>
<li><tt>getDataLayout()</tt></li>
<li><tt>getSubtargetImpl()</tt></li>
</ul>

View File

@ -173,7 +173,7 @@ add a set of optimizations to run. The code looks like this:</p>
// Set up the optimizer pipeline. Start with registering info about how the
// target lays out data structures.
OurFPM.add(new TargetData(*TheExecutionEngine->getTargetData()));
OurFPM.add(new DataLayout(*TheExecutionEngine->getDataLayout()));
// Provide basic AliasAnalysis support for GVN.
OurFPM.add(createBasicAliasAnalysisPass());
// Do simple "peephole" optimizations and bit-twiddling optzns.
@ -523,7 +523,7 @@ at runtime.</p>
#include "llvm/PassManager.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Target/TargetData.h"
#include "llvm/DataLayout.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Support/TargetSelect.h"
#include &lt;cstdio&gt;
@ -1103,7 +1103,7 @@ int main() {
// Set up the optimizer pipeline. Start with registering info about how the
// target lays out data structures.
OurFPM.add(new TargetData(*TheExecutionEngine-&gt;getTargetData()));
OurFPM.add(new DataLayout(*TheExecutionEngine-&gt;getDataLayout()));
// Provide basic AliasAnalysis support for GVN.
OurFPM.add(createBasicAliasAnalysisPass());
// Do simple "peephole" optimizations and bit-twiddling optzns.

View File

@ -901,7 +901,7 @@ clang++ -g toy.cpp `llvm-config --cppflags --ldflags --libs core jit native` -O3
#include "llvm/PassManager.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Target/TargetData.h"
#include "llvm/DataLayout.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Support/TargetSelect.h"
#include &lt;cstdio&gt;
@ -1723,7 +1723,7 @@ int main() {
// Set up the optimizer pipeline. Start with registering info about how the
// target lays out data structures.
OurFPM.add(new TargetData(*TheExecutionEngine-&gt;getTargetData()));
OurFPM.add(new DataLayout(*TheExecutionEngine-&gt;getDataLayout()));
// Provide basic AliasAnalysis support for GVN.
OurFPM.add(createBasicAliasAnalysisPass());
// Do simple "peephole" optimizations and bit-twiddling optzns.

View File

@ -840,7 +840,7 @@ library, although doing that will cause problems on Windows.</p>
#include "llvm/PassManager.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Target/TargetData.h"
#include "llvm/DataLayout.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Support/TargetSelect.h"
#include &lt;cstdio&gt;
@ -1780,7 +1780,7 @@ int main() {
// Set up the optimizer pipeline. Start with registering info about how the
// target lays out data structures.
OurFPM.add(new TargetData(*TheExecutionEngine-&gt;getTargetData()));
OurFPM.add(new DataLayout(*TheExecutionEngine-&gt;getDataLayout()));
// Provide basic AliasAnalysis support for GVN.
OurFPM.add(createBasicAliasAnalysisPass());
// Do simple "peephole" optimizations and bit-twiddling optzns.

View File

@ -524,7 +524,7 @@ good codegen once again:</p>
<pre>
// Set up the optimizer pipeline. Start with registering info about how the
// target lays out data structures.
OurFPM.add(new TargetData(*TheExecutionEngine-&gt;getTargetData()));
OurFPM.add(new DataLayout(*TheExecutionEngine-&gt;getDataLayout()));
<b>// Promote allocas to registers.
OurFPM.add(createPromoteMemoryToRegisterPass());</b>
// Do simple "peephole" optimizations and bit-twiddling optzns.
@ -1008,7 +1008,7 @@ clang++ -g toy.cpp `llvm-config --cppflags --ldflags --libs core jit native` -O3
#include "llvm/PassManager.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/Analysis/Passes.h"
#include "llvm/Target/TargetData.h"
#include "llvm/DataLayout.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Support/TargetSelect.h"
#include &lt;cstdio&gt;
@ -2113,7 +2113,7 @@ int main() {
// Set up the optimizer pipeline. Start with registering info about how the
// target lays out data structures.
OurFPM.add(new TargetData(*TheExecutionEngine-&gt;getTargetData()));
OurFPM.add(new DataLayout(*TheExecutionEngine-&gt;getDataLayout()));
// Provide basic AliasAnalysis support for GVN.
OurFPM.add(createBasicAliasAnalysisPass());
// Promote allocas to registers.

View File

@ -189,7 +189,7 @@ add a set of optimizations to run. The code looks like this:</p>
(* Set up the optimizer pipeline. Start with registering info about how the
* target lays out data structures. *)
TargetData.add (ExecutionEngine.target_data the_execution_engine) the_fpm;
DataLayout.add (ExecutionEngine.target_data the_execution_engine) the_fpm;
(* Do simple "peephole" optimizations and bit-twiddling optzn. *)
add_instruction_combining the_fpm;
@ -965,7 +965,7 @@ let main () =
(* Set up the optimizer pipeline. Start with registering info about how the
* target lays out data structures. *)
TargetData.add (ExecutionEngine.target_data the_execution_engine) the_fpm;
DataLayout.add (ExecutionEngine.target_data the_execution_engine) the_fpm;
(* Do simple "peephole" optimizations and bit-twiddling optzn. *)
add_instruction_combination the_fpm;

View File

@ -1498,7 +1498,7 @@ let main () =
(* Set up the optimizer pipeline. Start with registering info about how the
* target lays out data structures. *)
TargetData.add (ExecutionEngine.target_data the_execution_engine) the_fpm;
DataLayout.add (ExecutionEngine.target_data the_execution_engine) the_fpm;
(* Do simple "peephole" optimizations and bit-twiddling optzn. *)
add_instruction_combination the_fpm;

View File

@ -1506,7 +1506,7 @@ let main () =
(* Set up the optimizer pipeline. Start with registering info about how the
* target lays out data structures. *)
TargetData.add (ExecutionEngine.target_data the_execution_engine) the_fpm;
DataLayout.add (ExecutionEngine.target_data the_execution_engine) the_fpm;
(* Do simple "peephole" optimizations and bit-twiddling optzn. *)
add_instruction_combination the_fpm;

View File

@ -545,7 +545,7 @@ let main () =
(* Set up the optimizer pipeline. Start with registering info about how the
* target lays out data structures. *)
TargetData.add (ExecutionEngine.target_data the_execution_engine) the_fpm;
DataLayout.add (ExecutionEngine.target_data the_execution_engine) the_fpm;
<b>(* Promote allocas to registers. *)
add_memory_to_register_promotion the_fpm;</b>
@ -1834,7 +1834,7 @@ let main () =
(* Set up the optimizer pipeline. Start with registering info about how the
* target lays out data structures. *)
TargetData.add (ExecutionEngine.target_data the_execution_engine) the_fpm;
DataLayout.add (ExecutionEngine.target_data the_execution_engine) the_fpm;
(* Promote allocas to registers. *)
add_memory_to_register_promotion the_fpm;

View File

@ -43,10 +43,10 @@ let test_transforms () =
ignore (build_ret (build_call fn [| |] "" b) b);
end;
let td = TargetData.create (target_triple m) in
let td = DataLayout.create (target_triple m) in
ignore (PassManager.create ()
++ TargetData.add td
++ DataLayout.add td
++ add_argument_promotion
++ add_constant_merge
++ add_dead_arg_elimination
@ -63,7 +63,7 @@ let test_transforms () =
++ PassManager.run_module m
++ PassManager.dispose);
TargetData.dispose td
DataLayout.dispose td
(*===-- Driver ------------------------------------------------------------===*)

View File

@ -38,10 +38,10 @@ let test_transforms () =
let fn = define_function "fn" fty m in
ignore (build_ret_void (builder_at_end context (entry_block fn)));
let td = TargetData.create (target_triple m) in
let td = DataLayout.create (target_triple m) in
ignore (PassManager.create_function m
++ TargetData.add td
++ DataLayout.add td
++ add_verifier
++ add_constant_propagation
++ add_sccp
@ -78,7 +78,7 @@ let test_transforms () =
++ PassManager.finalize
++ PassManager.dispose);
TargetData.dispose td
DataLayout.dispose td
(*===-- Driver ------------------------------------------------------------===*)

View File

@ -33,10 +33,10 @@ let m = create_module context filename
(*===-- Target Data -------------------------------------------------------===*)
let test_target_data () =
let td = TargetData.create (target_triple m) in
let td = DataLayout.create (target_triple m) in
let sty = struct_type context [| i32_type; i64_type |] in
ignore (TargetData.as_string td);
ignore (DataLayout.as_string td);
ignore (byte_order td);
ignore (pointer_size td);
ignore (intptr_type td);
@ -49,7 +49,7 @@ let test_target_data () =
ignore (element_at_offset td sty (Int64.of_int 1));
ignore (offset_of_element td sty 1);
TargetData.dispose td
DataLayout.dispose td
(*===-- Driver ------------------------------------------------------------===*)

View File

@ -39,11 +39,11 @@
%"struct.llvm::SymbolTable" = type opaque
%"struct.llvm::SymbolTableListTraits<llvm::Argument,llvm::Function,llvm::Function,llvm::ilist_traits<llvm::Argument> >" = type { %"struct.llvm::Function"*, %"struct.llvm::Function"* }
%"struct.llvm::SymbolTableListTraits<llvm::Instruction,llvm::BasicBlock,llvm::Function,llvm::ilist_traits<llvm::Instruction> >" = type { %"struct.llvm::Function"*, %"struct.llvm::BasicBlock"* }
%"struct.llvm::TargetData" = type { %"struct.llvm::FunctionPass", i1, i8, i8, i8, i8, i8, i8, i8, i8 }
%"struct.llvm::DataLayout" = type { %"struct.llvm::FunctionPass", i1, i8, i8, i8, i8, i8, i8, i8, i8 }
%"struct.llvm::TargetFrameInfo" = type { i32 (...)**, i32, i32, i32 }
%"struct.llvm::TargetInstrDescriptor" = type { i8*, i32, i32, i32, i1, i32, i32, i32, i32, i32, i32*, i32* }
%"struct.llvm::TargetInstrInfo" = type { i32 (...)**, %"struct.llvm::TargetInstrDescriptor"*, i32, i32 }
%"struct.llvm::TargetMachine" = type { i32 (...)**, %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >", %"struct.llvm::TargetData", %"struct.llvm::IntrinsicLowering"* }
%"struct.llvm::TargetMachine" = type { i32 (...)**, %"struct.std::basic_string<char,std::char_traits<char>,std::allocator<char> >", %"struct.llvm::DataLayout", %"struct.llvm::IntrinsicLowering"* }
%"struct.llvm::TargetRegClassInfo" = type { i32 (...)**, i32, i32, i32 }
%"struct.llvm::TargetRegInfo" = type { i32 (...)**, %"struct.std::vector<const llvm::TargetRegClassInfo*,std::allocator<const llvm::TargetRegClassInfo*> >", %"struct.llvm::TargetMachine"* }
%"struct.llvm::Type" = type { %"struct.llvm::Value", i32, i32, i1, i32, %"struct.llvm::Type"*, %"struct.std::vector<llvm::PATypeHandle,std::allocator<llvm::PATypeHandle> >" }

View File

@ -14,6 +14,7 @@
#include "BugDriver.h"
#include "llvm/Constants.h"
#include "llvm/DataLayout.h"
#include "llvm/DerivedTypes.h"
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
@ -25,7 +26,6 @@
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/Utils/CodeExtractor.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FileUtilities.h"

View File

@ -16,11 +16,11 @@
//===----------------------------------------------------------------------===//
#include "BugDriver.h"
#include "llvm/DataLayout.h"
#include "llvm/Module.h"
#include "llvm/PassManager.h"
#include "llvm/Analysis/Verifier.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/SystemUtils.h"

View File

@ -14,6 +14,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/LLVMContext.h"
#include "llvm/DataLayout.h"
#include "llvm/Module.h"
#include "llvm/PassManager.h"
#include "llvm/Pass.h"
@ -34,7 +35,6 @@
#include "llvm/Support/Signals.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetLibraryInfo.h"
#include "llvm/Target/TargetMachine.h"
#include <memory>
@ -506,10 +506,10 @@ int main(int argc, char **argv) {
PM.add(TLI);
// Add the target data from the target machine, if it exists, or the module.
if (const TargetData *TD = Target.getTargetData())
PM.add(new TargetData(*TD));
if (const DataLayout *TD = Target.getDataLayout())
PM.add(new DataLayout(*TD));
else
PM.add(new TargetData(mod));
PM.add(new DataLayout(mod));
// Override default to generate verbose assembly.
Target.setAsmVerbosityDefault(true);

View File

@ -18,7 +18,7 @@
#include "llvm/Assembly/PrintModulePass.h"
#include "llvm/Bitcode/ReaderWriter.h"
#include "llvm/Transforms/IPO.h"
#include "llvm/Target/TargetData.h"
#include "llvm/DataLayout.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/IRReader.h"
#include "llvm/Support/ManagedStatic.h"
@ -206,7 +206,7 @@ int main(int argc, char **argv) {
// In addition to deleting all other functions, we also want to spiff it
// up a little bit. Do this now.
PassManager Passes;
Passes.add(new TargetData(M.get())); // Use correct TargetData
Passes.add(new DataLayout(M.get())); // Use correct DataLayout
std::vector<GlobalValue*> Gvs(GVs.begin(), GVs.end());

View File

@ -15,6 +15,7 @@
#include "LTOCodeGenerator.h"
#include "LTOModule.h"
#include "llvm/Constants.h"
#include "llvm/DataLayout.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Linker.h"
#include "llvm/LLVMContext.h"
@ -29,7 +30,6 @@
#include "llvm/MC/SubtargetFeature.h"
#include "llvm/Target/Mangler.h"
#include "llvm/Target/TargetOptions.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Target/TargetRegisterInfo.h"
#include "llvm/Transforms/IPO.h"
@ -293,7 +293,7 @@ void LTOCodeGenerator::applyScopeRestrictions() {
// mark which symbols can not be internalized
MCContext Context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(),NULL);
Mangler mangler(Context, *_target->getTargetData());
Mangler mangler(Context, *_target->getDataLayout());
std::vector<const char*> mustPreserveList;
SmallPtrSet<GlobalValue*, 8> asmUsed;
@ -361,8 +361,8 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
// Start off with a verification pass.
passes.add(createVerifierPass());
// Add an appropriate TargetData instance for this module...
passes.add(new TargetData(*_target->getTargetData()));
// Add an appropriate DataLayout instance for this module...
passes.add(new DataLayout(*_target->getDataLayout()));
// Enabling internalize here would use its AllButMain variant. It
// keeps only main if it exists and does nothing for libraries. Instead
@ -376,7 +376,7 @@ bool LTOCodeGenerator::generateObjectFile(raw_ostream &out,
FunctionPassManager *codeGenPasses = new FunctionPassManager(mergedModule);
codeGenPasses->add(new TargetData(*_target->getTargetData()));
codeGenPasses->add(new DataLayout(*_target->getDataLayout()));
formatted_raw_ostream Out(out);

View File

@ -158,7 +158,7 @@ SSPBufferSize("stack-protector-buffer-size", cl::init(8),
LTOModule::LTOModule(llvm::Module *m, llvm::TargetMachine *t)
: _module(m), _target(t),
_context(*_target->getMCAsmInfo(), *_target->getRegisterInfo(), NULL),
_mangler(_context, *_target->getTargetData()) {}
_mangler(_context, *_target->getDataLayout()) {}
/// isBitcodeFile - Returns 'true' if the file (or memory contents) is LLVM
/// bitcode.

View File

@ -13,6 +13,7 @@
//===----------------------------------------------------------------------===//
#include "llvm/LLVMContext.h"
#include "llvm/DataLayout.h"
#include "llvm/DebugInfo.h"
#include "llvm/Module.h"
#include "llvm/PassManager.h"
@ -23,7 +24,6 @@
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/RegionPass.h"
#include "llvm/Analysis/CallGraph.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetLibraryInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/ADT/StringSet.h"
@ -568,13 +568,13 @@ int main(int argc, char **argv) {
TLI->disableAllFunctions();
Passes.add(TLI);
// Add an appropriate TargetData instance for this module.
TargetData *TD = 0;
// Add an appropriate DataLayout instance for this module.
DataLayout *TD = 0;
const std::string &ModuleDataLayout = M.get()->getDataLayout();
if (!ModuleDataLayout.empty())
TD = new TargetData(ModuleDataLayout);
TD = new DataLayout(ModuleDataLayout);
else if (!DefaultDataLayout.empty())
TD = new TargetData(DefaultDataLayout);
TD = new DataLayout(DefaultDataLayout);
if (TD)
Passes.add(TD);
@ -583,7 +583,7 @@ int main(int argc, char **argv) {
if (OptLevelO1 || OptLevelO2 || OptLevelOs || OptLevelOz || OptLevelO3) {
FPasses.reset(new FunctionPassManager(M.get()));
if (TD)
FPasses->add(new TargetData(*TD));
FPasses->add(new DataLayout(*TD));
}
if (PrintBreakpoints) {

View File

@ -9,6 +9,7 @@
#include "llvm/BasicBlock.h"
#include "llvm/Constants.h"
#include "llvm/DataLayout.h"
#include "llvm/DerivedTypes.h"
#include "llvm/IRBuilder.h"
#include "llvm/Instructions.h"
@ -17,7 +18,6 @@
#include "llvm/Operator.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/Analysis/ValueTracking.h"
#include "llvm/Target/TargetData.h"
#include "gtest/gtest.h"
namespace llvm {
@ -183,7 +183,7 @@ TEST(InstructionsTest, VectorGep) {
EXPECT_NE(S3, Gep3);
int64_t Offset;
TargetData TD("e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3"
DataLayout TD("e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3"
"2:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80"
":128:128-n8:16:32:64-S128");
// Make sure we don't crash

View File

@ -14,7 +14,7 @@
#include "llvm/Pass.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/CallGraphSCCPass.h"
#include "llvm/Target/TargetData.h"
#include "llvm/DataLayout.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Constants.h"
@ -94,7 +94,7 @@ namespace llvm {
initializeModuleNDMPass(*PassRegistry::getPassRegistry());
}
virtual bool runOnModule(Module &M) {
EXPECT_TRUE(getAnalysisIfAvailable<TargetData>());
EXPECT_TRUE(getAnalysisIfAvailable<DataLayout>());
run++;
return false;
}
@ -167,7 +167,7 @@ namespace llvm {
initializeCGPassPass(*PassRegistry::getPassRegistry());
}
virtual bool runOnSCC(CallGraphSCC &SCMM) {
EXPECT_TRUE(getAnalysisIfAvailable<TargetData>());
EXPECT_TRUE(getAnalysisIfAvailable<DataLayout>());
run();
return false;
}
@ -177,7 +177,7 @@ namespace llvm {
public:
virtual bool runOnFunction(Function &F) {
// FIXME: PR4112
// EXPECT_TRUE(getAnalysisIfAvailable<TargetData>());
// EXPECT_TRUE(getAnalysisIfAvailable<DataLayout>());
run();
return false;
}
@ -204,7 +204,7 @@ namespace llvm {
return false;
}
virtual bool runOnLoop(Loop *L, LPPassManager &LPM) {
EXPECT_TRUE(getAnalysisIfAvailable<TargetData>());
EXPECT_TRUE(getAnalysisIfAvailable<DataLayout>());
run();
return false;
}
@ -241,7 +241,7 @@ namespace llvm {
return false;
}
virtual bool runOnBasicBlock(BasicBlock &BB) {
EXPECT_TRUE(getAnalysisIfAvailable<TargetData>());
EXPECT_TRUE(getAnalysisIfAvailable<DataLayout>());
run();
return false;
}
@ -266,7 +266,7 @@ namespace llvm {
initializeFPassPass(*PassRegistry::getPassRegistry());
}
virtual bool runOnModule(Module &M) {
EXPECT_TRUE(getAnalysisIfAvailable<TargetData>());
EXPECT_TRUE(getAnalysisIfAvailable<DataLayout>());
for (Module::iterator I=M.begin(),E=M.end(); I != E; ++I) {
Function &F = *I;
{
@ -292,7 +292,7 @@ namespace llvm {
mNDM->run = mNDNM->run = mDNM->run = mNDM2->run = 0;
PassManager Passes;
Passes.add(new TargetData(&M));
Passes.add(new DataLayout(&M));
Passes.add(mNDM2);
Passes.add(mNDM);
Passes.add(mNDNM);
@ -316,7 +316,7 @@ namespace llvm {
mNDM->run = mNDNM->run = mDNM->run = mNDM2->run = 0;
PassManager Passes;
Passes.add(new TargetData(&M));
Passes.add(new DataLayout(&M));
Passes.add(mNDM);
Passes.add(mNDNM);
Passes.add(mNDM2);// invalidates mNDM needed by mDNM
@ -338,7 +338,7 @@ namespace llvm {
OwningPtr<Module> M(makeLLVMModule());
T *P = new T();
PassManager Passes;
Passes.add(new TargetData(M.get()));
Passes.add(new DataLayout(M.get()));
Passes.add(P);
Passes.run(*M);
T::finishedOK(run);
@ -349,7 +349,7 @@ namespace llvm {
Module *M = makeLLVMModule();
T *P = new T();
PassManager Passes;
Passes.add(new TargetData(M));
Passes.add(new DataLayout(M));
Passes.add(P);
Passes.run(*M);
T::finishedOK(run, N);
@ -387,7 +387,7 @@ namespace llvm {
SCOPED_TRACE("Running OnTheFlyTest");
struct OnTheFlyTest *O = new OnTheFlyTest();
PassManager Passes;
Passes.add(new TargetData(M));
Passes.add(new DataLayout(M));
Passes.add(O);
Passes.run(*M);

View File

@ -177,12 +177,12 @@ void CallingConvEmitter::EmitAction(Record *Action,
if (Size)
O << Size << ", ";
else
O << "\n" << IndentStr << " State.getTarget().getTargetData()"
O << "\n" << IndentStr << " State.getTarget().getDataLayout()"
"->getTypeAllocSize(EVT(LocVT).getTypeForEVT(State.getContext())), ";
if (Align)
O << Align;
else
O << "\n" << IndentStr << " State.getTarget().getTargetData()"
O << "\n" << IndentStr << " State.getTarget().getDataLayout()"
"->getABITypeAlignment(EVT(LocVT).getTypeForEVT(State.getContext()))";
if (Action->isSubClassOf("CCAssignToStackWithShadow"))
O << ", " << getQualifiedName(Action->getValueAsDef("ShadowReg"));