llvm.org GIT mirror llvm / 9dd2a3b
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173175 91177308-0d34-0410-b5e6-96231b3b80d8 Eli Bendersky 7 years ago
6 changed file(s) with 34 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
110110 GNU,
111111 GNUEABI,
112112 GNUEABIHF,
113 GNUX32,
113114 EABI,
114115 MachO,
115116 Android,
4747 /// Default is 4.
4848 unsigned PointerSize;
4949
50 /// CalleeSaveStackSlotSize - Size of the stack slot reserved for
51 /// callee-saved registers, in bytes.
52 /// Default is same as pointer size.
53 unsigned CalleeSaveStackSlotSize;
54
5055 /// IsLittleEndian - True if target is little endian.
5156 /// Default is true.
5257 bool IsLittleEndian;
342347 return PointerSize;
343348 }
344349
345 /// islittleendian - True if the target is little endian.
350 /// getCalleeSaveStackSlotSize - Get the callee-saved register stack slot
351 /// size in bytes.
352 unsigned getCalleeSaveStackSlotSize() const {
353 // If a target doesn't explicitly initialize this member, PointerSize is
354 // used by default.
355 if (CalleeSaveStackSlotSize == 0)
356 return PointerSize;
357 else
358 return CalleeSaveStackSlotSize;
359 }
360
361 /// isLittleEndian - True if the target is little endian.
346362 bool isLittleEndian() const {
347363 return IsLittleEndian;
348364 }
2323
2424 MCAsmInfo::MCAsmInfo() {
2525 PointerSize = 4;
26 CalleeSaveStackSlotSize = 0; // 0 means PointerSize is used in getter.
27
2628 IsLittleEndian = true;
2729 StackGrowsUp = false;
2830 HasSubsectionsViaSymbols = false;
791791 static int getDataAlignmentFactor(MCStreamer &streamer) {
792792 MCContext &context = streamer.getContext();
793793 const MCAsmInfo &asmInfo = context.getAsmInfo();
794 int size = asmInfo.getPointerSize();
794 int size = asmInfo.getCalleeSaveStackSlotSize();
795795 if (asmInfo.isStackGrowthDirectionUp())
796796 return size;
797797 else
139139 case GNU: return "gnu";
140140 case GNUEABIHF: return "gnueabihf";
141141 case GNUEABI: return "gnueabi";
142 case GNUX32: return "gnux32";
142143 case EABI: return "eabi";
143144 case MachO: return "macho";
144145 case Android: return "android";
283284 .StartsWith("eabi", Triple::EABI)
284285 .StartsWith("gnueabihf", Triple::GNUEABIHF)
285286 .StartsWith("gnueabi", Triple::GNUEABI)
287 .StartsWith("gnux32", Triple::GNUX32)
286288 .StartsWith("gnu", Triple::GNU)
287289 .StartsWith("macho", Triple::MachO)
288290 .StartsWith("android", Triple::Android)
4343 X86MCAsmInfoDarwin::X86MCAsmInfoDarwin(const Triple &T) {
4444 bool is64Bit = T.getArch() == Triple::x86_64;
4545 if (is64Bit)
46 PointerSize = 8;
46 PointerSize = CalleeSaveStackSlotSize = 8;
4747
4848 AssemblerDialect = AsmWriterFlavor;
4949
7575 void X86ELFMCAsmInfo::anchor() { }
7676
7777 X86ELFMCAsmInfo::X86ELFMCAsmInfo(const Triple &T) {
78 if (T.getArch() == Triple::x86_64)
79 PointerSize = 8;
78 bool is64Bit = T.getArch() == Triple::x86_64;
79 bool isX32 = T.getEnvironment() == Triple::GNUX32;
80
81 // For ELF, x86-64 pointer size depends on the ABI.
82 // For x86-64 without the x32 ABI, pointer size is 8. For x86 and for x86-64
83 // with the x32 ABI, pointer size remains the default 4.
84 PointerSize = (is64Bit && !isX32) ? 8 : 4;
85
86 // OTOH, stack slot size is always 8 for x86-64, even with the x32 ABI.
87 CalleeSaveStackSlotSize = is64Bit ? 8 : 4;
8088
8189 AssemblerDialect = AsmWriterFlavor;
8290