llvm.org GIT mirror llvm / 26f2385
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 Reid Spencer 13 years ago
4 changed file(s) with 29 addition(s) and 43 deletion(s). Raw diff Collapse all Expand all
3838 return 0; // error materializing the module.
3939 }
4040
41 if (M->getEndianness() == Module::AnyEndianness) {
42 int Test = 0;
43 *(char*)&Test = 1; // Return true if the host is little endian
44 bool isLittleEndian = (Test == 1);
45 M->setEndianness(isLittleEndian ? Module::LittleEndian : Module::BigEndian);
46 }
41 // FIXME: This should probably compute the entire data layout
42 std::string DataLayout;
43 int Test = 0;
44 *(char*)&Test = 1; // Return true if the host is little endian
45 bool isLittleEndian = (Test == 1);
46 DataLayout.append(isLittleEndian ? "e" : "E");
4747
48 if (M->getPointerSize() == Module::AnyPointerSize) {
49 // Follow host.
50 bool Ptr64 = sizeof(void*) == 8;
51 M->setPointerSize(Ptr64 ? Module::Pointer64 : Module::Pointer32);
52 }
48 bool Ptr64 = sizeof(void*) == 8;
49 DataLayout.append(Ptr64 ? "-p:64:64" : "-p:32:32");
50
51 M->setDataLayout(DataLayout);
5352
5453 return new Interpreter(M);
5554 }
848848 assert(Dest != 0 && "Invalid Destination module");
849849 assert(Src != 0 && "Invalid Source Module");
850850
851 std::string DataLayout;
852
851853 if (Dest->getEndianness() == Module::AnyEndianness)
852 Dest->setEndianness(Src->getEndianness());
854 if (Src->getEndianness() == Module::BigEndian)
855 DataLayout.append("E");
856 else if (Src->getEndianness() == Module::LittleEndian)
857 DataLayout.append("e");
853858 if (Dest->getPointerSize() == Module::AnyPointerSize)
854 Dest->setPointerSize(Src->getPointerSize());
859 if (Src->getPointerSize() == Module::Pointer64)
860 DataLayout.append(DataLayout.length() == 0 ? "p:64:64" : "-p:64:64");
861 else if (Src->getPointerSize() == Module::Pointer32)
862 DataLayout.append(DataLayout.length() == 0 ? "p:32:32" : "-p:32:32");
855863 if (Dest->getTargetTriple().empty())
856864 Dest->setTargetTriple(Src->getTargetTriple());
857
858 if (Src->getEndianness() != Module::AnyEndianness &&
859 Dest->getEndianness() != Src->getEndianness())
860 cerr << "WARNING: Linking two modules of different endianness!\n";
861 if (Src->getPointerSize() != Module::AnyPointerSize &&
862 Dest->getPointerSize() != Src->getPointerSize())
863 cerr << "WARNING: Linking two modules of different pointer size!\n";
865 Dest->setDataLayout(DataLayout);
866
867 if (Src->getDataLayout().length() > 0 && Dest->getDataLayout().length() > 0 &&
868 Src->getDataLayout().compare(Dest->getDataLayout()) != 0)
869 cerr << "WARNING: Linking two modules of different data layouts!\n";
864870 if (!Src->getTargetTriple().empty() &&
865871 Dest->getTargetTriple() != Src->getTargetTriple())
866872 cerr << "WARNING: Linking two modules of different target triples!\n";
188188 }
189189 }
190190
191 // Unless explicitly specified, the alignments for longs and doubles is capped by
192 // pointer size.
191 // Unless explicitly specified, the alignments for longs and doubles is
192 // capped by pointer size.
193193 if (LongABIAlignment == 0)
194194 LongABIAlignment = LongPrefAlignment = PointerMemSize;
195195 if (DoubleABIAlignment == 0)
197197 }
198198
199199 TargetData::TargetData(const Module *M) {
200 LittleEndian = M->getEndianness() != Module::BigEndian;
201 PointerMemSize = M->getPointerSize() != Module::Pointer64 ? 4 : 8;
202 PointerABIAlignment = PointerMemSize;
203 DoubleABIAlignment = PointerMemSize;
204 FloatABIAlignment = 4;
205 LongABIAlignment = PointerMemSize;
206 IntABIAlignment = 4;
207 ShortABIAlignment = 2;
208 ByteABIAlignment = 1;
209 BoolABIAlignment = 1;
210 BoolPrefAlignment = BoolABIAlignment;
211 BytePrefAlignment = ByteABIAlignment;
212 ShortPrefAlignment = ShortABIAlignment;
213 IntPrefAlignment = IntABIAlignment;
214 LongPrefAlignment = LongABIAlignment;
215 FloatPrefAlignment = FloatABIAlignment;
216 DoublePrefAlignment = DoubleABIAlignment;
217 PointerPrefAlignment = PointerABIAlignment;
218 AggMinPrefAlignment = 0;
200 init(M->getDataLayout());
219201 }
220202
221203 /// Layouts - The lazy cache of structure layout information maintained by
3636 Module *llvm::CloneModule(const Module *M, std::map &ValueMap) {
3737 // First off, we need to create the new module...
3838 Module *New = new Module(M->getModuleIdentifier());
39 New->setEndianness(M->getEndianness());
40 New->setPointerSize(M->getPointerSize());
39 New->setDataLayout(M->getDataLayout());
4140 New->setTargetTriple(M->getTargetTriple());
4241 New->setModuleInlineAsm(M->getModuleInlineAsm());
4342