diff --git a/include/llvm/Attributes.h b/include/llvm/Attributes.h index d1497b5005c..cf37e93718d 100644 --- a/include/llvm/Attributes.h +++ b/include/llvm/Attributes.h @@ -106,6 +106,87 @@ public: Attributes() : Bits(0) { } explicit Attributes(uint64_t Val) : Bits(Val) { } /*implicit*/ Attributes(Attribute::AttrConst Val) : Bits(Val.v) { } + + // Attribute query methods. + // FIXME: StackAlignment & Alignment attributes have no predicate methods. + bool hasAttributes() const { return Bits != 0; } + + bool hasZExtAttr() const { + return Bits & Attribute::ZExt_i; + } + bool hasSExtAttr() const { + return Bits & Attribute::SExt_i; + } + bool hasNoReturnAttr() const { + return Bits & Attribute::NoReturn_i; + } + bool hasInRegAttr() const { + return Bits & Attribute::InReg_i; + } + bool hasStructRetAttr() const { + return Bits & Attribute::StructRet_i; + } + bool hasNoUnwindAttr() const { + return Bits & Attribute::NoUnwind_i; + } + bool hasNoAliasAttr() const { + return Bits & Attribute::NoAlias_i; + } + bool hasByValAttr() const { + return Bits & Attribute::ByVal_i; + } + bool hasNestAttr() const { + return Bits & Attribute::Nest_i; + } + bool hasReadNoneAttr() const { + return Bits & Attribute::ReadNone_i; + } + bool hasReadOnlyAttr() const { + return Bits & Attribute::ReadOnly_i; + } + bool hasNoInlineAttr() const { + return Bits & Attribute::NoInline_i; + } + bool hasAlwaysInlineAttr() const { + return Bits & Attribute::AlwaysInline_i; + } + bool hasOptimizeForSizeAttr() const { + return Bits & Attribute::OptimizeForSize_i; + } + bool hasStackProtectAttr() const { + return Bits & Attribute::StackProtect_i; + } + bool hasStackProtectReqAttr() const { + return Bits & Attribute::StackProtectReq_i; + } + bool hasNoCaptureAttr() const { + return Bits & Attribute::NoCapture_i; + } + bool hasNoRedZoneAttr() const { + return Bits & Attribute::NoRedZone_i; + } + bool hasNoImplicitFloatAttr() const { + return Bits & Attribute::NoImplicitFloat_i; + } + bool hasNakedAttr() const { + return Bits & Attribute::Naked_i; + } + bool hasInlineHintAttr() const { + return Bits & Attribute::InlineHint_i; + } + bool hasReturnsTwiceAttr() const { + return Bits & Attribute::ReturnsTwice_i; + } + bool hasUWTableAttr() const { + return Bits & Attribute::UWTable_i; + } + bool hasNonLazyBindAttr() const { + return Bits & Attribute::NonLazyBind_i; + } + bool hasAddressSafetyAttr() const { + return Bits & Attribute::AddressSafety_i; + } + // This is a "safe bool() operator". operator const void *() const { return Bits ? this : 0; } bool isEmptyOrSingleton() const { return (Bits & (Bits - 1)) == 0; } diff --git a/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/lib/CodeGen/SelectionDAG/TargetLowering.cpp index dcaa9ba9230..56f3a45c9a6 100644 --- a/lib/CodeGen/SelectionDAG/TargetLowering.cpp +++ b/lib/CodeGen/SelectionDAG/TargetLowering.cpp @@ -996,9 +996,9 @@ void llvm::GetReturnInfo(Type* ReturnType, Attributes attr, EVT VT = ValueVTs[j]; ISD::NodeType ExtendKind = ISD::ANY_EXTEND; - if (attr & Attribute::SExt) + if (attr.hasSExtAttr()) ExtendKind = ISD::SIGN_EXTEND; - else if (attr & Attribute::ZExt) + else if (attr.hasZExtAttr()) ExtendKind = ISD::ZERO_EXTEND; // FIXME: C calling convention requires the return type to be promoted to @@ -1016,18 +1016,17 @@ void llvm::GetReturnInfo(Type* ReturnType, Attributes attr, // 'inreg' on function refers to return value ISD::ArgFlagsTy Flags = ISD::ArgFlagsTy(); - if (attr & Attribute::InReg) + if (attr.hasInRegAttr()) Flags.setInReg(); // Propagate extension type if any - if (attr & Attribute::SExt) + if (attr.hasSExtAttr()) Flags.setSExt(); - else if (attr & Attribute::ZExt) + else if (attr.hasZExtAttr()) Flags.setZExt(); - for (unsigned i = 0; i < NumParts; ++i) { + for (unsigned i = 0; i < NumParts; ++i) Outs.push_back(ISD::OutputArg(Flags, PartVT, /*isFixed=*/true)); - } } }