diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2014-11-24 09:15:30 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2014-11-24 09:15:30 +0000 | 
| commit | 9f4dbff6669c8037f3b036bcf580d14f1a4f12a5 (patch) | |
| tree | 47df2c12b57214af6c31e47404b005675b8b7ffc /lib/Basic/TargetInfo.cpp | |
| parent | f73d5f23a889b93d89ddef61ac0995df40286bb8 (diff) | |
Notes
Diffstat (limited to 'lib/Basic/TargetInfo.cpp')
| -rw-r--r-- | lib/Basic/TargetInfo.cpp | 70 | 
1 files changed, 58 insertions, 12 deletions
diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp index e993055cc8819..aecf13b008549 100644 --- a/lib/Basic/TargetInfo.cpp +++ b/lib/Basic/TargetInfo.cpp @@ -52,7 +52,6 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) {    SizeType = UnsignedLong;    PtrDiffType = SignedLong;    IntMaxType = SignedLongLong; -  UIntMaxType = UnsignedLongLong;    IntPtrType = SignedLong;    WCharType = SignedInt;    WIntType = SignedInt; @@ -69,8 +68,7 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) {    FloatFormat = &llvm::APFloat::IEEEsingle;    DoubleFormat = &llvm::APFloat::IEEEdouble;    LongDoubleFormat = &llvm::APFloat::IEEEdouble; -  DescriptionString = "E-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-" -                      "i64:64:64-f32:32:32-f64:64:64-n32"; +  DescriptionString = nullptr;    UserLabelPrefix = "_";    MCountName = "mcount";    RegParmMax = 0; @@ -83,8 +81,10 @@ TargetInfo::TargetInfo(const llvm::Triple &T) : TargetOpts(), Triple(T) {    // Default to not using fp2ret for __Complex long double    ComplexLongDoubleUsesFP2Ret = false; -  // Default to using the Itanium ABI. -  TheCXXABI.set(TargetCXXABI::GenericItanium); +  // Set the C++ ABI based on the triple. +  TheCXXABI.set(Triple.isKnownWindowsMSVCEnvironment() +                    ? TargetCXXABI::Microsoft +                    : TargetCXXABI::GenericItanium);    // Default to an empty address space map.    AddrSpaceMap = &DefaultAddrSpaceMap; @@ -103,7 +103,7 @@ TargetInfo::~TargetInfo() {}  const char *TargetInfo::getTypeName(IntType T) {    switch (T) {    default: llvm_unreachable("not an integer!"); -  case SignedChar:       return "char"; +  case SignedChar:       return "signed char";    case UnsignedChar:     return "unsigned char";    case SignedShort:      return "short";    case UnsignedShort:    return "unsigned short"; @@ -118,7 +118,7 @@ const char *TargetInfo::getTypeName(IntType T) {  /// getTypeConstantSuffix - Return the constant suffix for the specified  /// integer type enum. For example, SignedLong -> "L". -const char *TargetInfo::getTypeConstantSuffix(IntType T) { +const char *TargetInfo::getTypeConstantSuffix(IntType T) const {    switch (T) {    default: llvm_unreachable("not an integer!");    case SignedChar: @@ -127,13 +127,36 @@ const char *TargetInfo::getTypeConstantSuffix(IntType T) {    case SignedLong:       return "L";    case SignedLongLong:   return "LL";    case UnsignedChar: +    if (getCharWidth() < getIntWidth()) +      return "";    case UnsignedShort: +    if (getShortWidth() < getIntWidth()) +      return "";    case UnsignedInt:      return "U";    case UnsignedLong:     return "UL";    case UnsignedLongLong: return "ULL";    }  } +/// getTypeFormatModifier - Return the printf format modifier for the +/// specified integer type enum. For example, SignedLong -> "l". + +const char *TargetInfo::getTypeFormatModifier(IntType T) { +  switch (T) { +  default: llvm_unreachable("not an integer!"); +  case SignedChar: +  case UnsignedChar:     return "hh"; +  case SignedShort: +  case UnsignedShort:    return "h"; +  case SignedInt: +  case UnsignedInt:      return ""; +  case SignedLong: +  case UnsignedLong:     return "l"; +  case SignedLongLong: +  case UnsignedLongLong: return "ll"; +  } +} +  /// getTypeWidth - Return the width (in bits) of the specified integer type  /// enum. For example, SignedInt -> getIntWidth().  unsigned TargetInfo::getTypeWidth(IntType T) const { @@ -167,6 +190,21 @@ TargetInfo::IntType TargetInfo::getIntTypeByWidth(    return NoInt;  } +TargetInfo::IntType TargetInfo::getLeastIntTypeByWidth(unsigned BitWidth, +                                                       bool IsSigned) const { +  if (getCharWidth() >= BitWidth) +    return IsSigned ? SignedChar : UnsignedChar; +  if (getShortWidth() >= BitWidth) +    return IsSigned ? SignedShort : UnsignedShort; +  if (getIntWidth() >= BitWidth) +    return IsSigned ? SignedInt : UnsignedInt; +  if (getLongWidth() >= BitWidth) +    return IsSigned ? SignedLong : UnsignedLong; +  if (getLongLongWidth() >= BitWidth) +    return IsSigned ? SignedLongLong : UnsignedLongLong; +  return NoInt; +} +  TargetInfo::RealType TargetInfo::getRealTypeByWidth(unsigned BitWidth) const {    if (getFloatWidth() == BitWidth)      return Float; @@ -226,10 +264,10 @@ bool TargetInfo::isTypeSigned(IntType T) {    };  } -/// setForcedLangOptions - Set forced language options. +/// adjust - Set forced language options.  /// Apply changes to the target information with respect to certain  /// language options which change the target configuration. -void TargetInfo::setForcedLangOptions(LangOptions &Opts) { +void TargetInfo::adjust(const LangOptions &Opts) {    if (Opts.NoBitFieldTypeAlign)      UseBitFieldTypeAlignment = false;    if (Opts.ShortWChar) @@ -245,7 +283,14 @@ void TargetInfo::setForcedLangOptions(LangOptions &Opts) {      LongLongWidth = LongLongAlign = 128;      HalfWidth = HalfAlign = 16;      FloatWidth = FloatAlign = 32; -    DoubleWidth = DoubleAlign = 64; +     +    // Embedded 32-bit targets (OpenCL EP) might have double C type  +    // defined as float. Let's not override this as it might lead  +    // to generating illegal code that uses 64bit doubles. +    if (DoubleWidth != FloatWidth) { +      DoubleWidth = DoubleAlign = 64; +      DoubleFormat = &llvm::APFloat::IEEEdouble; +    }      LongDoubleWidth = LongDoubleAlign = 128;      assert(PointerWidth == 32 || PointerWidth == 64); @@ -255,12 +300,10 @@ void TargetInfo::setForcedLangOptions(LangOptions &Opts) {      IntPtrType = Is32BitArch ? SignedInt : SignedLong;      IntMaxType = SignedLongLong; -    UIntMaxType = UnsignedLongLong;      Int64Type = SignedLong;      HalfFormat = &llvm::APFloat::IEEEhalf;      FloatFormat = &llvm::APFloat::IEEEsingle; -    DoubleFormat = &llvm::APFloat::IEEEdouble;      LongDoubleFormat = &llvm::APFloat::IEEEquad;    }  } @@ -483,6 +526,9 @@ bool TargetInfo::validateInputConstraint(ConstraintInfo *OutputConstraints,                                           ConstraintInfo &Info) const {    const char *Name = Info.ConstraintStr.c_str(); +  if (!*Name) +    return false; +    while (*Name) {      switch (*Name) {      default:  | 
