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