forked from OSchip/llvm-project
Initial patch for x32 ABI support.
Add the x32 environment kind to the triple, and separate the concept of pointer size and callee save stack slot size, since they're not equal on x32. llvm-svn: 173175
This commit is contained in:
parent
2446649c1e
commit
0893e1079d
|
@ -111,6 +111,7 @@ public:
|
||||||
GNU,
|
GNU,
|
||||||
GNUEABI,
|
GNUEABI,
|
||||||
GNUEABIHF,
|
GNUEABIHF,
|
||||||
|
GNUX32,
|
||||||
EABI,
|
EABI,
|
||||||
MachO,
|
MachO,
|
||||||
Android,
|
Android,
|
||||||
|
|
|
@ -48,6 +48,11 @@ namespace llvm {
|
||||||
/// Default is 4.
|
/// Default is 4.
|
||||||
unsigned PointerSize;
|
unsigned PointerSize;
|
||||||
|
|
||||||
|
/// CalleeSaveStackSlotSize - Size of the stack slot reserved for
|
||||||
|
/// callee-saved registers, in bytes.
|
||||||
|
/// Default is same as pointer size.
|
||||||
|
unsigned CalleeSaveStackSlotSize;
|
||||||
|
|
||||||
/// IsLittleEndian - True if target is little endian.
|
/// IsLittleEndian - True if target is little endian.
|
||||||
/// Default is true.
|
/// Default is true.
|
||||||
bool IsLittleEndian;
|
bool IsLittleEndian;
|
||||||
|
@ -343,7 +348,18 @@ namespace llvm {
|
||||||
return PointerSize;
|
return PointerSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// islittleendian - True if the target is little endian.
|
/// getCalleeSaveStackSlotSize - Get the callee-saved register stack slot
|
||||||
|
/// size in bytes.
|
||||||
|
unsigned getCalleeSaveStackSlotSize() const {
|
||||||
|
// If a target doesn't explicitly initialize this member, PointerSize is
|
||||||
|
// used by default.
|
||||||
|
if (CalleeSaveStackSlotSize == 0)
|
||||||
|
return PointerSize;
|
||||||
|
else
|
||||||
|
return CalleeSaveStackSlotSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// isLittleEndian - True if the target is little endian.
|
||||||
bool isLittleEndian() const {
|
bool isLittleEndian() const {
|
||||||
return IsLittleEndian;
|
return IsLittleEndian;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,8 @@ using namespace llvm;
|
||||||
|
|
||||||
MCAsmInfo::MCAsmInfo() {
|
MCAsmInfo::MCAsmInfo() {
|
||||||
PointerSize = 4;
|
PointerSize = 4;
|
||||||
|
CalleeSaveStackSlotSize = 0; // 0 means PointerSize is used in getter.
|
||||||
|
|
||||||
IsLittleEndian = true;
|
IsLittleEndian = true;
|
||||||
StackGrowsUp = false;
|
StackGrowsUp = false;
|
||||||
HasSubsectionsViaSymbols = false;
|
HasSubsectionsViaSymbols = false;
|
||||||
|
|
|
@ -792,7 +792,7 @@ void MCGenDwarfLabelEntry::Make(MCSymbol *Symbol, MCStreamer *MCOS,
|
||||||
static int getDataAlignmentFactor(MCStreamer &streamer) {
|
static int getDataAlignmentFactor(MCStreamer &streamer) {
|
||||||
MCContext &context = streamer.getContext();
|
MCContext &context = streamer.getContext();
|
||||||
const MCAsmInfo &asmInfo = context.getAsmInfo();
|
const MCAsmInfo &asmInfo = context.getAsmInfo();
|
||||||
int size = asmInfo.getPointerSize();
|
int size = asmInfo.getCalleeSaveStackSlotSize();
|
||||||
if (asmInfo.isStackGrowthDirectionUp())
|
if (asmInfo.isStackGrowthDirectionUp())
|
||||||
return size;
|
return size;
|
||||||
else
|
else
|
||||||
|
|
|
@ -140,6 +140,7 @@ const char *Triple::getEnvironmentTypeName(EnvironmentType Kind) {
|
||||||
case GNU: return "gnu";
|
case GNU: return "gnu";
|
||||||
case GNUEABIHF: return "gnueabihf";
|
case GNUEABIHF: return "gnueabihf";
|
||||||
case GNUEABI: return "gnueabi";
|
case GNUEABI: return "gnueabi";
|
||||||
|
case GNUX32: return "gnux32";
|
||||||
case EABI: return "eabi";
|
case EABI: return "eabi";
|
||||||
case MachO: return "macho";
|
case MachO: return "macho";
|
||||||
case Android: return "android";
|
case Android: return "android";
|
||||||
|
@ -284,6 +285,7 @@ static Triple::EnvironmentType parseEnvironment(StringRef EnvironmentName) {
|
||||||
.StartsWith("eabi", Triple::EABI)
|
.StartsWith("eabi", Triple::EABI)
|
||||||
.StartsWith("gnueabihf", Triple::GNUEABIHF)
|
.StartsWith("gnueabihf", Triple::GNUEABIHF)
|
||||||
.StartsWith("gnueabi", Triple::GNUEABI)
|
.StartsWith("gnueabi", Triple::GNUEABI)
|
||||||
|
.StartsWith("gnux32", Triple::GNUX32)
|
||||||
.StartsWith("gnu", Triple::GNU)
|
.StartsWith("gnu", Triple::GNU)
|
||||||
.StartsWith("macho", Triple::MachO)
|
.StartsWith("macho", Triple::MachO)
|
||||||
.StartsWith("android", Triple::Android)
|
.StartsWith("android", Triple::Android)
|
||||||
|
|
|
@ -44,7 +44,7 @@ void X86MCAsmInfoDarwin::anchor() { }
|
||||||
X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &T) {
|
X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &T) {
|
||||||
bool is64Bit = T.getArch() == Triple::x86_64;
|
bool is64Bit = T.getArch() == Triple::x86_64;
|
||||||
if (is64Bit)
|
if (is64Bit)
|
||||||
PointerSize = 8;
|
PointerSize = CalleeSaveStackSlotSize = 8;
|
||||||
|
|
||||||
AssemblerDialect = AsmWriterFlavor;
|
AssemblerDialect = AsmWriterFlavor;
|
||||||
|
|
||||||
|
@ -76,8 +76,16 @@ X86_64MCAsmInfoDarwin::X86_64MCAsmInfoDarwin(const Triple &Triple)
|
||||||
void X86ELFMCAsmInfo::anchor() { }
|
void X86ELFMCAsmInfo::anchor() { }
|
||||||
|
|
||||||
X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) {
|
X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) {
|
||||||
if (T.getArch() == Triple::x86_64)
|
bool is64Bit = T.getArch() == Triple::x86_64;
|
||||||
PointerSize = 8;
|
bool isX32 = T.getEnvironment() == Triple::GNUX32;
|
||||||
|
|
||||||
|
// For ELF, x86-64 pointer size depends on the ABI.
|
||||||
|
// For x86-64 without the x32 ABI, pointer size is 8. For x86 and for x86-64
|
||||||
|
// with the x32 ABI, pointer size remains the default 4.
|
||||||
|
PointerSize = (is64Bit && !isX32) ? 8 : 4;
|
||||||
|
|
||||||
|
// OTOH, stack slot size is always 8 for x86-64, even with the x32 ABI.
|
||||||
|
CalleeSaveStackSlotSize = is64Bit ? 8 : 4;
|
||||||
|
|
||||||
AssemblerDialect = AsmWriterFlavor;
|
AssemblerDialect = AsmWriterFlavor;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue