From 6d27724d5a148f42a8fd3b491079687c0e12bcda Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 18 Dec 2013 20:24:51 +0000 Subject: [PATCH] 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@197604 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Basic/Targets.cpp | 64 ++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index 778f90a57e..b69b0dba54 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -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); -- 2.40.0