For PR761:

The Module::setEndianness and Module::setPointerSize methods have been
removed. Instead you can get/set the DataLayout. Adjust thise accordingly.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33530 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Reid Spencer 2007-01-26 08:11:39 +00:00
parent aacc35a794
commit 26f238589f
4 changed files with 28 additions and 42 deletions

View File

@ -39,18 +39,17 @@ ExecutionEngine *Interpreter::create(ModuleProvider *MP) {
return 0; // error materializing the module.
}
if (M->getEndianness() == Module::AnyEndianness) {
// FIXME: This should probably compute the entire data layout
std::string DataLayout;
int Test = 0;
*(char*)&Test = 1; // Return true if the host is little endian
bool isLittleEndian = (Test == 1);
M->setEndianness(isLittleEndian ? Module::LittleEndian : Module::BigEndian);
}
DataLayout.append(isLittleEndian ? "e" : "E");
if (M->getPointerSize() == Module::AnyPointerSize) {
// Follow host.
bool Ptr64 = sizeof(void*) == 8;
M->setPointerSize(Ptr64 ? Module::Pointer64 : Module::Pointer32);
}
DataLayout.append(Ptr64 ? "-p:64:64" : "-p:32:32");
M->setDataLayout(DataLayout);
return new Interpreter(M);
}

View File

@ -849,19 +849,25 @@ Linker::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) {
assert(Dest != 0 && "Invalid Destination module");
assert(Src != 0 && "Invalid Source Module");
std::string DataLayout;
if (Dest->getEndianness() == Module::AnyEndianness)
Dest->setEndianness(Src->getEndianness());
if (Src->getEndianness() == Module::BigEndian)
DataLayout.append("E");
else if (Src->getEndianness() == Module::LittleEndian)
DataLayout.append("e");
if (Dest->getPointerSize() == Module::AnyPointerSize)
Dest->setPointerSize(Src->getPointerSize());
if (Src->getPointerSize() == Module::Pointer64)
DataLayout.append(DataLayout.length() == 0 ? "p:64:64" : "-p:64:64");
else if (Src->getPointerSize() == Module::Pointer32)
DataLayout.append(DataLayout.length() == 0 ? "p:32:32" : "-p:32:32");
if (Dest->getTargetTriple().empty())
Dest->setTargetTriple(Src->getTargetTriple());
Dest->setDataLayout(DataLayout);
if (Src->getEndianness() != Module::AnyEndianness &&
Dest->getEndianness() != Src->getEndianness())
cerr << "WARNING: Linking two modules of different endianness!\n";
if (Src->getPointerSize() != Module::AnyPointerSize &&
Dest->getPointerSize() != Src->getPointerSize())
cerr << "WARNING: Linking two modules of different pointer size!\n";
if (Src->getDataLayout().length() > 0 && Dest->getDataLayout().length() > 0 &&
Src->getDataLayout().compare(Dest->getDataLayout()) != 0)
cerr << "WARNING: Linking two modules of different data layouts!\n";
if (!Src->getTargetTriple().empty() &&
Dest->getTargetTriple() != Src->getTargetTriple())
cerr << "WARNING: Linking two modules of different target triples!\n";

View File

@ -189,8 +189,8 @@ void TargetData::init(const std::string &TargetDescription) {
}
}
// Unless explicitly specified, the alignments for longs and doubles is capped by
// pointer size.
// Unless explicitly specified, the alignments for longs and doubles is
// capped by pointer size.
if (LongABIAlignment == 0)
LongABIAlignment = LongPrefAlignment = PointerMemSize;
if (DoubleABIAlignment == 0)
@ -198,25 +198,7 @@ void TargetData::init(const std::string &TargetDescription) {
}
TargetData::TargetData(const Module *M) {
LittleEndian = M->getEndianness() != Module::BigEndian;
PointerMemSize = M->getPointerSize() != Module::Pointer64 ? 4 : 8;
PointerABIAlignment = PointerMemSize;
DoubleABIAlignment = PointerMemSize;
FloatABIAlignment = 4;
LongABIAlignment = PointerMemSize;
IntABIAlignment = 4;
ShortABIAlignment = 2;
ByteABIAlignment = 1;
BoolABIAlignment = 1;
BoolPrefAlignment = BoolABIAlignment;
BytePrefAlignment = ByteABIAlignment;
ShortPrefAlignment = ShortABIAlignment;
IntPrefAlignment = IntABIAlignment;
LongPrefAlignment = LongABIAlignment;
FloatPrefAlignment = FloatABIAlignment;
DoublePrefAlignment = DoubleABIAlignment;
PointerPrefAlignment = PointerABIAlignment;
AggMinPrefAlignment = 0;
init(M->getDataLayout());
}
/// Layouts - The lazy cache of structure layout information maintained by

View File

@ -37,8 +37,7 @@ Module *llvm::CloneModule(const Module *M) {
Module *llvm::CloneModule(const Module *M, std::map<const Value*, Value*> &ValueMap) {
// First off, we need to create the new module...
Module *New = new Module(M->getModuleIdentifier());
New->setEndianness(M->getEndianness());
New->setPointerSize(M->getPointerSize());
New->setDataLayout(M->getDataLayout());
New->setTargetTriple(M->getTargetTriple());
New->setModuleInlineAsm(M->getModuleInlineAsm());