a better encoding of the targets data layout, rather than trying to guess it
from the endianness and pointersize like before.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31030
91177308-0d34-0410-b5e6-
96231b3b80d8
/// @returns the module identifier as a string
const std::string &getModuleIdentifier() const { return ModuleID; }
+ /// Get the data layout string for the module's target platform. This encodes
+ /// the type sizes and alignments expected by this module.
+ /// @returns the data layout as a string
+ std::string getDataLayout() const { return DataLayout; }
+
/// Get the target triple which is a string describing the target host.
/// @returns a string containing the target triple.
const std::string &getTargetTriple() const { return TargetTriple; }
/// Set the module identifier.
void setModuleIdentifier(const std::string &ID) { ModuleID = ID; }
+ /// Set the data layout
+ void setDataLayout(std::string DL) { DataLayout = DL; }
+
/// Set the target triple.
void setTargetTriple(const std::string &T) { TargetTriple = T; }
deplibs { return DEPLIBS; }
endian { return ENDIAN; }
pointersize { return POINTERSIZE; }
+data { return DATA; }
little { return LITTLE; }
big { return BIG; }
volatile { return VOLATILE; }
%token DEPLIBS CALL TAIL ASM_TOK MODULE SIDEEFFECT
%token CC_TOK CCC_TOK CSRETCC_TOK FASTCC_TOK COLDCC_TOK
%token X86_STDCALLCC_TOK X86_FASTCALLCC_TOK
+%token DATA
%type <UIntVal> OptCallingConv
// Basic Block Terminating Operators
free($3);
CHECK_FOR_ERROR
};
+ | DATA '=' STRINGCONSTANT {
+ CurModule.CurrentModule->setDataLayout($3);
+ free($3);
+ CHECK_FOR_ERROR
+ };
LibrariesDefinition : '[' LibList ']';
M->getModuleIdentifier().find('\n') == std::string::npos)
Out << "; ModuleID = '" << M->getModuleIdentifier() << "'\n";
+ if (!M->getDataLayout().empty())
+ Out << "target data = \"" << M->getDataLayout() << "\"\n";
+
switch (M->getEndianness()) {
case Module::LittleEndian: Out << "target endian = little\n"; break;
case Module::BigEndian: Out << "target endian = big\n"; break;