LLVM API Documentation

llvm::TargetData Class Reference

#include <TargetData.h>

Inheritance diagram for llvm::TargetData:

Inheritance graph
[legend]
Collaboration diagram for llvm::TargetData:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 TargetData ()
 TargetData (const std::string &TargetDescription)
 Constructs a TargetData from a specification string. See init().
 TargetData (const Module *M)
 Initialize target data from properties stored in the module.
 TargetData (const TargetData &TD)
 ~TargetData ()
void init (const std::string &TargetDescription)
 Parse a target data layout string and initialize TargetData alignments.
bool isLittleEndian () const
 Target endianness...
bool isBigEndian () const
std::string getStringRepresentation () const
unsigned char getPointerABIAlignment () const
 Target pointer alignment.
unsigned char getPointerPrefAlignment () const
 Return target's alignment for stack-based pointers.
unsigned char getPointerSize () const
 Target pointer size.
unsigned char getPointerSizeInBits () const
 Target pointer size, in bits.
uint64_t getTypeSizeInBits (const Type *Ty) const
uint64_t getTypeStoreSize (const Type *Ty) const
uint64_t getTypeStoreSizeInBits (const Type *Ty) const
uint64_t getABITypeSize (const Type *Ty) const
uint64_t getABITypeSizeInBits (const Type *Ty) const
unsigned char getABITypeAlignment (const Type *Ty) const
unsigned char getCallFrameTypeAlignment (const Type *Ty) const
unsigned char getPrefTypeAlignment (const Type *Ty) const
unsigned char getPreferredTypeAlignmentShift (const Type *Ty) const
const TypegetIntPtrType () const
uint64_t getIndexedOffset (const Type *Ty, Value *const *Indices, unsigned NumIndices) const
const StructLayoutgetStructLayout (const StructType *Ty) const
void InvalidateStructLayoutInfo (const StructType *Ty) const
unsigned getPreferredAlignment (const GlobalVariable *GV) const
unsigned getPreferredAlignmentLog (const GlobalVariable *GV) const

Static Public Member Functions

template<typename UIntTy>
static UIntTy RoundUpAlignment (UIntTy Val, unsigned Alignment)

Static Public Attributes

static char ID = 0


Detailed Description

Definition at line 66 of file TargetData.h.


Constructor & Destructor Documentation

llvm::TargetData::TargetData (  )  [inline]

Default ctor.

Note:
This has to exist, because this is a pass, but it should never be used.

Definition at line 112 of file TargetData.h.

llvm::TargetData::TargetData ( const std::string &  TargetDescription  )  [inline, explicit]

Constructs a TargetData from a specification string. See init().

Definition at line 119 of file TargetData.h.

References init().

TargetData::TargetData ( const Module M  )  [explicit]

Initialize target data from properties stored in the module.

Definition at line 235 of file TargetData.cpp.

References llvm::Module::getDataLayout(), and init().

llvm::TargetData::TargetData ( const TargetData TD  )  [inline]

Definition at line 127 of file TargetData.h.

TargetData::~TargetData (  ) 


Member Function Documentation

void TargetData::init ( const std::string &  TargetDescription  ) 

Parse a target data layout string and initialize TargetData alignments.

A TargetDescription string consists of a sequence of hyphen-delimited specifiers for target endianness, pointer size and alignments, and various primitive type sizes and alignments. A typical string looks something like:

"E-p:32:32:32-i1:8:8-i8:8:8-i32:32:32-i64:32:64-f32:32:32-f64:32:64"

(note: this string is not fully specified and is only an example.) Alignments come in two flavors: ABI and preferred. ABI alignment (abi_align, below) dictates how a type will be aligned within an aggregate and when used as an argument. Preferred alignment (pref_align, below) determines a type's alignment when emitted as a global. Specifier string details:

[E|e]: Endianness. "E" specifies a big-endian target data model, "e" specifies a little-endian target data model.

p:

<size>:<abi_align>:<pref_align>
: Pointer size, ABI and preferred alignment.

<type><size>:<abi_align>:<pref_align>
: Numeric type alignment. Type is one of i|f|v|a, corresponding to integer, floating point, vector (aka packed) or aggregate. Size indicates the size, e.g., 32 or 64 bits. The default string, fully specified is:

"E-p:64:64:64-a0:0:0-f32:32:32-f64:0:64" "-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:0:64" "-v64:64:64-v128:128:128"

Note that in the case of aggregates, 0 is the default ABI and preferred alignment. This is a special case, where the aggregate's computed worst-case alignment will be used.

Definition at line 170 of file TargetData.cpp.

References llvm::AGGREGATE_ALIGN, llvm::FLOAT_ALIGN, llvm::getToken(), llvm::INTEGER_ALIGN, llvm::STACK_ALIGN, and llvm::VECTOR_ALIGN.

Referenced by TargetData().

bool llvm::TargetData::isLittleEndian (  )  const [inline]

bool llvm::TargetData::isBigEndian (  )  const [inline]

Definition at line 143 of file TargetData.h.

Referenced by llvm::AsmPrinter::EmitInt64(), and llvm::MachOWriter::InitMem().

std::string TargetData::getStringRepresentation (  )  const

getStringRepresentation - Return the string representation of the TargetData. This representation is in the same format accepted by the string constructor above.

Definition at line 402 of file TargetData.cpp.

References I, llvm::itostr(), and llvm::utostr().

unsigned char llvm::TargetData::getPointerABIAlignment (  )  const [inline]

Target pointer alignment.

Definition at line 150 of file TargetData.h.

unsigned char llvm::TargetData::getPointerPrefAlignment (  )  const [inline]

Return target's alignment for stack-based pointers.

Definition at line 152 of file TargetData.h.

unsigned char llvm::TargetData::getPointerSize (  )  const [inline]

unsigned char llvm::TargetData::getPointerSizeInBits (  )  const [inline]

uint64_t TargetData::getTypeSizeInBits ( const Type Ty  )  const

uint64_t llvm::TargetData::getTypeStoreSize ( const Type Ty  )  const [inline]

uint64_t llvm::TargetData::getTypeStoreSizeInBits ( const Type Ty  )  const [inline]

getTypeStoreSizeInBits - Return the maximum number of bits that may be overwritten by storing the specified type; always a multiple of 8. For example, returns 40 for i36 and 80 for x86_fp80.

Definition at line 172 of file TargetData.h.

References getTypeStoreSize().

Referenced by llvm::FindAvailableLoadedValue().

uint64_t llvm::TargetData::getABITypeSize ( const Type Ty  )  const [inline]

getABITypeSize - Return the offset in bytes between successive objects of the specified type, including alignment padding. This is the amount that alloca reserves for this type. For example, returns 12 or 16 for x86_fp80, depending on alignment.

Definition at line 180 of file TargetData.h.

References getABITypeAlignment(), getTypeStoreSize(), and RoundUpAlignment().

Referenced by calculateFunctionInfo(), ComputeValueVTs(), llvm::MachOCodeEmitter::emitConstantPool(), llvm::AsmPrinter::EmitConstantPool(), llvm::AsmPrinter::EmitConstantValueOnly(), EmitGEPOffset(), llvm::AsmPrinter::EmitGlobalConstant(), llvm::ExecutionEngine::EmitGlobalVariable(), EvaluateGEPOffsetExpression(), llvm::Interpreter::executeGEPOperation(), getABITypeSizeInBits(), llvm::MachineConstantPool::getConstantPoolIndex(), GetConstantPoolSizeInBytes(), getIndexedOffset(), llvm::JIT::getMemoryForGV(), llvm::ExecutionEngine::getMemoryForGV(), GetOffsetFromIndex(), llvm::JIT::getOrEmitGlobalVariable(), llvm::ExecutionEngine::InitializeMemory(), llvm::MachOWriter::InitMem(), IsConstantOffsetFromGlobal(), isObjectSmallerThan(), isSafeToEliminateVarargsCast(), llvm::TargetLowering::LowerArguments(), llvm::TargetLowering::LowerCallTo(), llvm::XCoreTargetAsmInfo::MergeableConstSection(), llvm::ELFTargetAsmInfo::MergeableConstSection(), llvm::DarwinTargetAsmInfo::MergeableConstSection(), llvm::ELFTargetAsmInfo::MergeableStringSection(), llvm::DarwinTargetAsmInfo::MergeableStringSection(), llvm::X86ATTAsmPrinter::printModuleLevelGV(), llvm::MipsTargetAsmInfo::SectionKindForGlobal(), llvm::FunctionLoweringInfo::set(), SRAGlobal(), TryToOptimizeStoreOfMallocToGlobal(), and llvm::Interpreter::visitAllocationInst().

uint64_t llvm::TargetData::getABITypeSizeInBits ( const Type Ty  )  const [inline]

getABITypeSizeInBits - Return the offset in bits between successive objects of the specified type, including alignment padding; always a multiple of 8. This is the amount that alloca reserves for this type. For example, returns 96 or 128 for x86_fp80, depending on alignment.

Definition at line 189 of file TargetData.h.

References getABITypeSize().

Referenced by llvm::AsmPrinter::EmitConstantValueOnly(), getTypeSizeInBits(), and HasPadding().

unsigned char TargetData::getABITypeAlignment ( const Type Ty  )  const

getABITypeAlignment - Return the minimum ABI-required alignment for the specified type.

Definition at line 514 of file TargetData.cpp.

Referenced by getABITypeSize(), llvm::X86TargetLowering::getByValTypeAlignment(), getCallFrameTypeAlignment(), llvm::TargetLowering::LowerArguments(), llvm::TargetLowering::LowerCallTo(), MeetsMaxMemopRequirement(), and SRAGlobal().

unsigned char TargetData::getCallFrameTypeAlignment ( const Type Ty  )  const

getCallFrameTypeAlignment - Return the minimum ABI-required alignment for the specified type when it is part of a call frame.

Definition at line 518 of file TargetData.cpp.

References getABITypeAlignment(), and llvm::STACK_ALIGN.

Referenced by llvm::TargetLowering::getByValTypeAlignment().

unsigned char TargetData::getPrefTypeAlignment ( const Type Ty  )  const

getPrefTypeAlignment - Return the preferred stack/global alignment for the specified type. This is always at least as good as the ABI alignment.

Definition at line 526 of file TargetData.cpp.

Referenced by llvm::ComputeMaskedBits(), llvm::SelectionDAG::CreateStackTemporary(), getPreferredAlignment(), getPreferredTypeAlignmentShift(), llvm::InlineFunction(), llvm::ELFTargetAsmInfo::MergeableStringSection(), llvm::FunctionLoweringInfo::set(), and llvm::MachOCodeEmitter::startFunction().

unsigned char TargetData::getPreferredTypeAlignmentShift ( const Type Ty  )  const

getPreferredTypeAlignmentShift - Return the preferred alignment for the specified type, returned as log2 of the value (a shift amount).

Definition at line 530 of file TargetData.cpp.

References getPrefTypeAlignment(), and llvm::Log2_32().

Referenced by llvm::SelectionDAG::getConstantPool().

const Type * TargetData::getIntPtrType (  )  const

uint64_t TargetData::getIndexedOffset ( const Type Ty,
Value *const *  Indices,
unsigned  NumIndices 
) const

getIndexedOffset - return the offset from the beginning of the type for the specified indices. This is used to implement getelementptr.

Definition at line 543 of file TargetData.cpp.

References llvm::gep_type_begin(), getABITypeSize(), llvm::StructLayout::getElementOffset(), getStructLayout(), llvm::Intrinsic::getType(), and llvm::Type::Int32Ty.

Referenced by llvm::AsmPrinter::EmitConstantValueOnly(), llvm::ExecutionEngine::getConstantValue(), llvm::MachOWriter::InitMem(), and SymbolicallyEvaluateGEP().

const StructLayout * TargetData::getStructLayout ( const StructType Ty  )  const

getStructLayout - Return a StructLayout object, indicating the alignment of the struct, its size, and the offsets of its fields. Note that this information is lazily cached.

Definition at line 366 of file TargetData.cpp.

References llvm::StructType::getNumElements(), L, and TheMap.

Referenced by ComputeValueVTs(), EmitGEPOffset(), EvaluateGEPOffsetExpression(), llvm::Interpreter::executeGEPOperation(), getIndexedOffset(), GetOffsetFromIndex(), getTypeSizeInBits(), HasPadding(), llvm::ExecutionEngine::InitializeMemory(), llvm::MachOWriter::InitMem(), IsConstantOffsetFromGlobal(), and SRAGlobal().

void TargetData::InvalidateStructLayoutInfo ( const StructType Ty  )  const

InvalidateStructLayoutInfo - TargetData speculatively caches StructLayout objects. If a TargetData object is alive when types are being refined and removed, this method must be called whenever a StructType is removed to avoid a dangling pointer in this cache.

InvalidateStructLayoutInfo - TargetData speculatively caches StructLayout objects. If a TargetData object is alive when types are being refined and removed, this method must be called whenever a StructType is removed to avoid a dangling pointer in this cache.

Definition at line 390 of file TargetData.cpp.

References I, and llvm::ManagedStaticBase::isConstructed().

unsigned TargetData::getPreferredAlignment ( const GlobalVariable GV  )  const

getPreferredAlignment - Return the preferred alignment of the specified global. This includes an explicitly requested alignment (if the global has one).

getPreferredAlignment - Return the preferred alignment of the specified global. This includes an explicitly requested alignment (if the global has one).

Definition at line 581 of file TargetData.cpp.

References Alignment, llvm::GlobalValue::getAlignment(), llvm::SequentialType::getElementType(), getPrefTypeAlignment(), llvm::GlobalValue::getType(), getTypeSizeInBits(), and llvm::GlobalVariable::hasInitializer().

Referenced by llvm::JIT::getOrEmitGlobalVariable(), getPreferredAlignmentLog(), and llvm::DarwinTargetAsmInfo::MergeableStringSection().

unsigned TargetData::getPreferredAlignmentLog ( const GlobalVariable GV  )  const

getPreferredAlignmentLog - Return the preferred alignment of the specified global, returned in log form. This includes an explicitly requested alignment (if the global has one).

getPreferredAlignmentLog - Return the preferred alignment of the specified global, returned in log form. This includes an explicitly requested alignment (if the global has one).

Definition at line 601 of file TargetData.cpp.

References getPreferredAlignment(), and llvm::Log2_32().

Referenced by llvm::X86IntelAsmPrinter::doFinalization(), and llvm::X86ATTAsmPrinter::printModuleLevelGV().

template<typename UIntTy>
static UIntTy llvm::TargetData::RoundUpAlignment ( UIntTy  Val,
unsigned  Alignment 
) [inline, static]

RoundUpAlignment - Round the specified value up to the next alignment boundary specified by Alignment. For example, 7 rounded up to an alignment boundary of 4 is 8. 8 rounded up to the alignment boundary of 4 is 8 because it is already aligned.

Definition at line 248 of file TargetData.h.

Referenced by getABITypeSize().


Member Data Documentation

char TargetData::ID = 0 [static]

Definition at line 253 of file TargetData.h.


The documentation for this class was generated from the following files:



This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.