r197604 - Make setABIAPCS and setABIAAPCS easier to reason about.
Rafael Espindola
rafael.espindola at gmail.com
Wed Dec 18 12:24:51 PST 2013
Author: rafael
Date: Wed Dec 18 14:24:51 2013
New Revision: 197604
URL: http://llvm.org/viewvc/llvm-project?rev=197604&view=rev
Log:
Make setABIAPCS and setABIAAPCS easier to reason about.
These functions now always set the same variables in the same order and they
don't overlap with thep constructor.
Modified:
cfe/trunk/lib/Basic/Targets.cpp
Modified: cfe/trunk/lib/Basic/Targets.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets.cpp?rev=197604&r1=197603&r2=197604&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Targets.cpp (original)
+++ cfe/trunk/lib/Basic/Targets.cpp Wed Dec 18 14:24:51 2013
@@ -3678,18 +3678,48 @@ class ARMTargetInfo : public TargetInfo
}
void setABIAAPCS() {
- // FIXME: Enumerated types are variable width in straight AAPCS.
+ IsAAPCS = true;
+
+ DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 64;
- // size_t is unsigned long on Darwin.
- if (getTriple().isOSDarwin())
+ // size_t is unsigned long on Darwin and netbsd.
+ if (getTriple().isOSDarwin() || getTriple().getOS() == llvm::Triple::NetBSD)
SizeType = UnsignedLong;
- IsAAPCS = true;
+ else
+ SizeType = UnsignedInt;
+
+ if (getTriple().getOS() == llvm::Triple::NetBSD) {
+ WCharType = SignedInt;
+ } else {
+ // AAPCS 7.1.1, ARM-Linux ABI 2.4: type of wchar_t is unsigned int.
+ WCharType = UnsignedInt;
+ }
+
+ UseBitFieldTypeAlignment = true;
+
+ ZeroLengthBitfieldBoundary = 0;
+
+ if (IsThumb) {
+ // Thumb1 add sp, #imm requires the immediate value be multiple of 4,
+ // so set preferred for small types to 32.
+ DescriptionString = ("e-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:64-"
+ "v128:64:128-a:0:32-n32-S64");
+ } else {
+ DescriptionString = ("e-p:32:32-i64:64-v128:64:128-n32-S64");
+ }
+
+ // FIXME: Enumerated types are variable width in straight AAPCS.
}
void setABIAPCS() {
+ IsAAPCS = false;
+
DoubleAlign = LongLongAlign = LongDoubleAlign = SuitableAlign = 32;
+
// size_t is unsigned int on FreeBSD.
- if (getTriple().getOS() != llvm::Triple::FreeBSD)
+ if (getTriple().getOS() == llvm::Triple::FreeBSD)
+ SizeType = UnsignedInt;
+ else
SizeType = UnsignedLong;
// Revert to using SignedInt on apcs-gnu to comply with existing behaviour.
@@ -3704,8 +3734,6 @@ class ARMTargetInfo : public TargetInfo
/// gcc.
ZeroLengthBitfieldBoundary = 32;
- IsAAPCS = false;
-
if (IsThumb) {
// Thumb1 add sp, #imm requires the immediate value be multiple of 4,
// so set preferred for small types to 32.
@@ -3721,19 +3749,14 @@ class ARMTargetInfo : public TargetInfo
public:
ARMTargetInfo(const llvm::Triple &Triple)
- : TargetInfo(Triple), ABI("aapcs-linux"), CPU("arm1136j-s"),
- FPMath(FP_Default), IsAAPCS(true) {
+ : TargetInfo(Triple), CPU("arm1136j-s"), FPMath(FP_Default),
+ IsAAPCS(true) {
BigEndian = false;
switch (getTriple().getOS()) {
case llvm::Triple::NetBSD:
- SizeType = UnsignedLong;
PtrDiffType = SignedLong;
- WCharType = SignedInt;
break;
default:
- // AAPCS 7.1.1, ARM-Linux ABI 2.4: type of wchar_t is unsigned int.
- WCharType = UnsignedInt;
- SizeType = UnsignedInt;
PtrDiffType = SignedInt;
break;
}
@@ -3744,17 +3767,8 @@ public:
// FIXME: Should we just treat this as a feature?
IsThumb = getTriple().getArchName().startswith("thumb");
- if (IsThumb) {
- // Thumb1 add sp, #imm requires the immediate value be multiple of 4,
- // so set preferred for small types to 32.
- DescriptionString = ("e-p:32:32-i1:8:32-i8:8:32-i16:16:32-"
- "i64:64-"
- "v128:64:128-a:0:32-n32-S64");
- } else {
- DescriptionString = ("e-p:32:32-"
- "i64:64-"
- "v128:64:128-n32-S64");
- }
+
+ setABI("aapcs-linux");
// ARM targets default to using the ARM C++ ABI.
TheCXXABI.set(TargetCXXABI::GenericARM);
More information about the cfe-commits
mailing list