more cleanup.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86369 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2009-11-07 09:23:04 +00:00
parent 8f9b0f6e88
commit 2e07494170
2 changed files with 28 additions and 26 deletions

View File

@ -21,10 +21,7 @@
#define LLVM_TARGET_TARGETDATA_H
#include "llvm/Pass.h"
#include "llvm/System/DataTypes.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/ADT/SmallVector.h"
#include <string>
namespace llvm {
@ -73,18 +70,16 @@ private:
unsigned char PointerABIAlign; ///< Pointer ABI alignment
unsigned char PointerPrefAlign; ///< Pointer preferred alignment
//! Where the primitive type alignment data is stored.
/*!
@sa init().
@note Could support multiple size pointer alignments, e.g., 32-bit pointers
vs. 64-bit pointers by extending TargetAlignment, but for now, we don't.
*/
/// Alignments- Where the primitive type alignment data is stored.
///
/// @sa init().
/// @note Could support multiple size pointer alignments, e.g., 32-bit
/// pointers vs. 64-bit pointers by extending TargetAlignment, but for now,
/// we don't.
SmallVector<TargetAlignElem, 16> Alignments;
//! Alignment iterator shorthand
typedef SmallVector<TargetAlignElem, 16>::iterator align_iterator;
//! Constant alignment iterator shorthand
typedef SmallVector<TargetAlignElem, 16>::const_iterator align_const_iterator;
//! Invalid alignment.
/*!
This member is a signal that a requested alignment type and bit width were
not found in the SmallVector.
@ -92,7 +87,7 @@ private:
static const TargetAlignElem InvalidAlignmentElem;
// Opaque pointer for the StructType -> StructLayout map.
mutable void* LayoutMap;
mutable void *LayoutMap;
//! Set/initialize target alignments
void setAlignment(AlignTypeEnum align_type, unsigned char abi_align,
@ -106,8 +101,8 @@ private:
///
/// Predicate that tests a TargetAlignElem reference returned by get() against
/// InvalidAlignmentElem.
inline bool validAlignment(const TargetAlignElem &align) const {
return (&align != &InvalidAlignmentElem);
bool validAlignment(const TargetAlignElem &align) const {
return &align != &InvalidAlignmentElem;
}
public:
@ -115,11 +110,8 @@ public:
///
/// @note This has to exist, because this is a pass, but it should never be
/// used.
TargetData() : ImmutablePass(&ID) {
llvm_report_error("Bad TargetData ctor used. "
"Tool did not specify a TargetData to use?");
}
TargetData();
/// Constructs a TargetData from a specification string. See init().
explicit TargetData(StringRef TargetDescription)
: ImmutablePass(&ID) {

View File

@ -258,6 +258,15 @@ void TargetData::init(StringRef Desc) {
}
}
/// Default ctor.
///
/// @note This has to exist, because this is a pass, but it should never be
/// used.
TargetData::TargetData() : ImmutablePass(&ID) {
llvm_report_error("Bad TargetData ctor used. "
"Tool did not specify a TargetData to use?");
}
TargetData::TargetData(const Module *M)
: ImmutablePass(&ID) {
init(M->getDataLayout());
@ -405,10 +414,11 @@ std::string TargetData::getStringRepresentation() const {
OS << (LittleEndian ? "e" : "E")
<< "-p:" << PointerMemSize*8 << ':' << PointerABIAlign*8
<< ':' << PointerPrefAlign*8;
for (align_const_iterator I = Alignments.begin(), E = Alignments.end();
I != E; ++I)
OS << '-' << (char)I->AlignType << I->TypeBitWidth << ':'
<< I->ABIAlign*8 << ':' << I->PrefAlign*8;
for (unsigned i = 0, e = Alignments.size(); i != e; ++i) {
const TargetAlignElem &AI = Alignments[i];
OS << '-' << (char)AI.AlignType << AI.TypeBitWidth << ':'
<< AI.ABIAlign*8 << ':' << AI.PrefAlign*8;
}
return OS.str();
}