diff options
Diffstat (limited to 'contrib/llvm/include/llvm/Support')
73 files changed, 3006 insertions, 2285 deletions
diff --git a/contrib/llvm/include/llvm/Support/ARMBuildAttributes.h b/contrib/llvm/include/llvm/Support/ARMBuildAttributes.h index f63e0a61f639..96a8219bfb85 100644 --- a/contrib/llvm/include/llvm/Support/ARMBuildAttributes.h +++ b/contrib/llvm/include/llvm/Support/ARMBuildAttributes.h @@ -16,8 +16,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_SUPPORT_ARM_BUILD_ATTRIBUTES_H -#define LLVM_SUPPORT_ARM_BUILD_ATTRIBUTES_H +#ifndef LLVM_SUPPORT_ARMBUILDATTRIBUTES_H +#define LLVM_SUPPORT_ARMBUILDATTRIBUTES_H namespace llvm { class StringRef; @@ -146,6 +146,12 @@ enum { AllowNeon2 = 2, // SIMDv2 was permitted (Half-precision FP, MAC operations) AllowNeonARMv8 = 3, // ARM v8-A SIMD was permitted + // Tag_ABI_PCS_R9_use, (=14), uleb128 + R9IsGPR = 0, // R9 used as v6 (just another callee-saved register) + R9IsSB = 1, // R9 used as a global static base rgister + R9IsTLSPointer = 2, // R9 used as a thread local storage pointer + R9Reserved = 3, // R9 not used by code associated with attributed entity + // Tag_ABI_PCS_RW_data, (=15), uleb128 AddressRWPCRel = 1, // Address RW static data PC-relative AddressRWSBRel = 2, // Address RW static data SB-relative @@ -165,6 +171,8 @@ enum { WCharWidth4Bytes = 4, // sizeof(wchar_t) == 4 // Tag_ABI_FP_denormal, (=20), uleb128 + PositiveZero = 0, + IEEEDenormals = 1, PreserveFPSign = 2, // sign when flushed-to-zero is preserved // Tag_ABI_FP_number_model, (=23), uleb128 @@ -192,6 +200,9 @@ enum { // Tag_FP_HP_extension, (=36), uleb128 AllowHPFP = 1, // Allow use of Half Precision FP + // Tag_FP_16bit_format, (=38), uleb128 + FP16FormatIEEE = 1, + // Tag_MPextension_use, (=42), uleb128 AllowMP = 1, // Allow use of MP extensions @@ -214,4 +225,4 @@ enum { } // namespace ARMBuildAttrs } // namespace llvm -#endif // LLVM_SUPPORT_ARM_BUILD_ATTRIBUTES_H +#endif diff --git a/contrib/llvm/include/llvm/Support/ARMEHABI.h b/contrib/llvm/include/llvm/Support/ARMEHABI.h index c7ac54aeb6de..9b052df0a908 100644 --- a/contrib/llvm/include/llvm/Support/ARMEHABI.h +++ b/contrib/llvm/include/llvm/Support/ARMEHABI.h @@ -19,8 +19,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_SUPPORT_ARM_EHABI_H -#define LLVM_SUPPORT_ARM_EHABI_H +#ifndef LLVM_SUPPORT_ARMEHABI_H +#define LLVM_SUPPORT_ARMEHABI_H namespace llvm { namespace ARM { @@ -131,4 +131,4 @@ namespace EHABI { } } -#endif // ARM_UNWIND_OP_H +#endif diff --git a/contrib/llvm/include/llvm/Support/ARMWinEH.h b/contrib/llvm/include/llvm/Support/ARMWinEH.h index 78deb8d36a98..1463629f45dc 100644 --- a/contrib/llvm/include/llvm/Support/ARMWinEH.h +++ b/contrib/llvm/include/llvm/Support/ARMWinEH.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_SUPPORT_WINARMEH_H -#define LLVM_SUPPORT_WINARMEH_H +#ifndef LLVM_SUPPORT_ARMWINEH_H +#define LLVM_SUPPORT_ARMWINEH_H #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/Endian.h" @@ -350,16 +350,15 @@ struct ExceptionDataRecord { ArrayRef<support::ulittle32_t> EpilogueScopes() const { assert(E() == 0 && "epilogue scopes are only present when the E bit is 0"); size_t Offset = HeaderWords(*this); - return ArrayRef<support::ulittle32_t>(&Data[Offset], EpilogueCount()); + return makeArrayRef(&Data[Offset], EpilogueCount()); } - ArrayRef<support::ulittle8_t> UnwindByteCode() const { + ArrayRef<uint8_t> UnwindByteCode() const { const size_t Offset = HeaderWords(*this) + (E() ? 0 : EpilogueCount()); - const support::ulittle8_t *ByteCode = - reinterpret_cast<const support::ulittle8_t *>(&Data[Offset]); - return ArrayRef<support::ulittle8_t>(ByteCode, - CodeWords() * sizeof(uint32_t)); + const uint8_t *ByteCode = + reinterpret_cast<const uint8_t *>(&Data[Offset]); + return makeArrayRef(ByteCode, CodeWords() * sizeof(uint32_t)); } uint32_t ExceptionHandlerRVA() const { @@ -381,4 +380,3 @@ inline size_t HeaderWords(const ExceptionDataRecord &XR) { } #endif - diff --git a/contrib/llvm/include/llvm/Support/Allocator.h b/contrib/llvm/include/llvm/Support/Allocator.h index 7a7e4c0a13e2..de317719714d 100644 --- a/contrib/llvm/include/llvm/Support/Allocator.h +++ b/contrib/llvm/include/llvm/Support/Allocator.h @@ -90,7 +90,10 @@ class MallocAllocator : public AllocatorBase<MallocAllocator> { public: void Reset() {} - void *Allocate(size_t Size, size_t /*Alignment*/) { return malloc(Size); } + LLVM_ATTRIBUTE_RETURNS_NONNULL void *Allocate(size_t Size, + size_t /*Alignment*/) { + return malloc(Size); + } // Pull in base class overloads. using AllocatorBase<MallocAllocator>::Allocate; @@ -116,8 +119,8 @@ void printBumpPtrAllocatorStats(unsigned NumSlabs, size_t BytesAllocated, /// \brief Allocate memory in an ever growing pool, as if by bump-pointer. /// /// This isn't strictly a bump-pointer allocator as it uses backing slabs of -/// memory rather than relying on boundless contiguous heap. However, it has -/// bump-pointer semantics in that is a monotonically growing pool of memory +/// memory rather than relying on a boundless contiguous heap. However, it has +/// bump-pointer semantics in that it is a monotonically growing pool of memory /// where every allocation is found by merely allocating the next N bytes in /// the slab, or the next N bytes in the next slab. /// @@ -200,28 +203,24 @@ public: } /// \brief Allocate space at the specified alignment. - void *Allocate(size_t Size, size_t Alignment) { - if (!CurPtr) // Start a new slab if we haven't allocated one already. - StartNewSlab(); + LLVM_ATTRIBUTE_RETURNS_NONNULL void *Allocate(size_t Size, size_t Alignment) { + assert(Alignment > 0 && "0-byte alignnment is not allowed. Use 1 instead."); // Keep track of how many bytes we've allocated. BytesAllocated += Size; - // 0-byte alignment means 1-byte alignment. - if (Alignment == 0) - Alignment = 1; - - // Allocate the aligned space, going forwards from CurPtr. - char *Ptr = alignPtr(CurPtr, Alignment); + size_t Adjustment = alignmentAdjustment(CurPtr, Alignment); + assert(Adjustment + Size >= Size && "Adjustment + Size must not overflow"); - // Check if we can hold it. - if (Ptr + Size <= End) { - CurPtr = Ptr + Size; + // Check if we have enough space. + if (Adjustment + Size <= size_t(End - CurPtr)) { + char *AlignedPtr = CurPtr + Adjustment; + CurPtr = AlignedPtr + Size; // Update the allocation point of this memory block in MemorySanitizer. // Without this, MemorySanitizer messages for values originated from here // will point to the allocation of the entire slab. - __msan_allocated_memory(Ptr, Size); - return Ptr; + __msan_allocated_memory(AlignedPtr, Size); + return AlignedPtr; } // If Size is really big, allocate a separate slab for it. @@ -230,19 +229,22 @@ public: void *NewSlab = Allocator.Allocate(PaddedSize, 0); CustomSizedSlabs.push_back(std::make_pair(NewSlab, PaddedSize)); - Ptr = alignPtr((char *)NewSlab, Alignment); - assert((uintptr_t)Ptr + Size <= (uintptr_t)NewSlab + PaddedSize); - __msan_allocated_memory(Ptr, Size); - return Ptr; + uintptr_t AlignedAddr = alignAddr(NewSlab, Alignment); + assert(AlignedAddr + Size <= (uintptr_t)NewSlab + PaddedSize); + char *AlignedPtr = (char*)AlignedAddr; + __msan_allocated_memory(AlignedPtr, Size); + return AlignedPtr; } // Otherwise, start a new slab and try again. StartNewSlab(); - Ptr = alignPtr(CurPtr, Alignment); - CurPtr = Ptr + Size; - assert(CurPtr <= End && "Unable to allocate memory!"); - __msan_allocated_memory(Ptr, Size); - return Ptr; + uintptr_t AlignedAddr = alignAddr(CurPtr, Alignment); + assert(AlignedAddr + Size <= (uintptr_t)End && + "Unable to allocate memory!"); + char *AlignedPtr = (char*)AlignedAddr; + CurPtr = AlignedPtr + Size; + __msan_allocated_memory(AlignedPtr, Size); + return AlignedPtr; } // Pull in base class overloads. @@ -320,8 +322,10 @@ private: #ifndef NDEBUG // Poison the memory so stale pointers crash sooner. Note we must // preserve the Size and NextPtr fields at the beginning. - sys::Memory::setRangeWritable(*I, AllocatedSlabSize); - memset(*I, 0xCD, AllocatedSlabSize); + if (AllocatedSlabSize != 0) { + sys::Memory::setRangeWritable(*I, AllocatedSlabSize); + memset(*I, 0xCD, AllocatedSlabSize); + } #endif Allocator.Deallocate(*I, AllocatedSlabSize); } @@ -373,7 +377,7 @@ public: /// all memory allocated so far. void DestroyAll() { auto DestroyElements = [](char *Begin, char *End) { - assert(Begin == alignPtr(Begin, alignOf<T>())); + assert(Begin == (char*)alignAddr(Begin, alignOf<T>())); for (char *Ptr = Begin; Ptr + sizeof(T) <= End; Ptr += sizeof(T)) reinterpret_cast<T *>(Ptr)->~T(); }; @@ -382,7 +386,7 @@ public: ++I) { size_t AllocatedSlabSize = BumpPtrAllocator::computeSlabSize( std::distance(Allocator.Slabs.begin(), I)); - char *Begin = alignPtr((char *)*I, alignOf<T>()); + char *Begin = (char*)alignAddr(*I, alignOf<T>()); char *End = *I == Allocator.Slabs.back() ? Allocator.CurPtr : (char *)*I + AllocatedSlabSize; @@ -392,7 +396,7 @@ public: for (auto &PtrAndSize : Allocator.CustomSizedSlabs) { void *Ptr = PtrAndSize.first; size_t Size = PtrAndSize.second; - DestroyElements(alignPtr((char *)Ptr, alignOf<T>()), (char *)Ptr + Size); + DestroyElements((char*)alignAddr(Ptr, alignOf<T>()), (char *)Ptr + Size); } Allocator.Reset(); diff --git a/contrib/llvm/include/llvm/Support/CBindingWrapping.h b/contrib/llvm/include/llvm/Support/CBindingWrapping.h index 51097b820220..786ba183b3b0 100644 --- a/contrib/llvm/include/llvm/Support/CBindingWrapping.h +++ b/contrib/llvm/include/llvm/Support/CBindingWrapping.h @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_C_BINDING_WRAPPING_H -#define LLVM_C_BINDING_WRAPPING_H +#ifndef LLVM_SUPPORT_CBINDINGWRAPPING_H +#define LLVM_SUPPORT_CBINDINGWRAPPING_H #include "llvm/Support/Casting.h" diff --git a/contrib/llvm/include/llvm/Support/COFF.h b/contrib/llvm/include/llvm/Support/COFF.h index e09ef07d81db..150bce50d9ae 100644 --- a/contrib/llvm/include/llvm/Support/COFF.h +++ b/contrib/llvm/include/llvm/Support/COFF.h @@ -31,23 +31,30 @@ namespace llvm { namespace COFF { // The maximum number of sections that a COFF object can have (inclusive). - const int MaxNumberOfSections = 65299; + const int32_t MaxNumberOfSections16 = 65279; // The PE signature bytes that follows the DOS stub header. static const char PEMagic[] = { 'P', 'E', '\0', '\0' }; + static const char BigObjMagic[] = { + '\xc7', '\xa1', '\xba', '\xd1', '\xee', '\xba', '\xa9', '\x4b', + '\xaf', '\x20', '\xfa', '\xf6', '\x6a', '\xa4', '\xdc', '\xb8', + }; + // Sizes in bytes of various things in the COFF format. enum { - HeaderSize = 20, + Header16Size = 20, + Header32Size = 56, NameSize = 8, - SymbolSize = 18, + Symbol16Size = 18, + Symbol32Size = 20, SectionSize = 40, RelocationSize = 10 }; struct header { uint16_t Machine; - uint16_t NumberOfSections; + int32_t NumberOfSections; uint32_t TimeDateStamp; uint32_t PointerToSymbolTable; uint32_t NumberOfSymbols; @@ -55,6 +62,24 @@ namespace COFF { uint16_t Characteristics; }; + struct BigObjHeader { + enum : uint16_t { MinBigObjectVersion = 2 }; + + uint16_t Sig1; ///< Must be IMAGE_FILE_MACHINE_UNKNOWN (0). + uint16_t Sig2; ///< Must be 0xFFFF. + uint16_t Version; + uint16_t Machine; + uint32_t TimeDateStamp; + uint8_t UUID[16]; + uint32_t unused1; + uint32_t unused2; + uint32_t unused3; + uint32_t unused4; + uint32_t NumberOfSections; + uint32_t PointerToSymbolTable; + uint32_t NumberOfSymbols; + }; + enum MachineTypes { MT_Invalid = 0xffff, @@ -124,7 +149,7 @@ namespace COFF { struct symbol { char Name[NameSize]; uint32_t Value; - uint16_t SectionNumber; + int32_t SectionNumber; uint16_t Type; uint8_t StorageClass; uint8_t NumberOfAuxSymbols; @@ -140,9 +165,9 @@ namespace COFF { SF_WeakExternal = 0x01000000 }; - enum SymbolSectionNumber { - IMAGE_SYM_DEBUG = 0xFFFE, - IMAGE_SYM_ABSOLUTE = 0xFFFF, + enum SymbolSectionNumber : int32_t { + IMAGE_SYM_DEBUG = -2, + IMAGE_SYM_ABSOLUTE = -1, IMAGE_SYM_UNDEFINED = 0 }; @@ -367,18 +392,14 @@ namespace COFF { IMAGE_WEAK_EXTERN_SEARCH_ALIAS = 3 }; - struct AuxiliaryFile { - uint8_t FileName[18]; - }; - struct AuxiliarySectionDefinition { uint32_t Length; uint16_t NumberOfRelocations; uint16_t NumberOfLinenumbers; uint32_t CheckSum; - uint16_t Number; + uint32_t Number; uint8_t Selection; - char unused[3]; + char unused; }; struct AuxiliaryCLRToken { @@ -392,7 +413,6 @@ namespace COFF { AuxiliaryFunctionDefinition FunctionDefinition; AuxiliarybfAndefSymbol bfAndefSymbol; AuxiliaryWeakExternal WeakExternal; - AuxiliaryFile File; AuxiliarySectionDefinition SectionDefinition; }; @@ -495,12 +515,14 @@ namespace COFF { uint32_t SizeOfHeaders; uint32_t CheckSum; uint16_t Subsystem; + // FIXME: This should be DllCharacteristics to match the COFF spec. uint16_t DLLCharacteristics; uint32_t SizeOfStackReserve; uint32_t SizeOfStackCommit; uint32_t SizeOfHeapReserve; uint32_t SizeOfHeapCommit; uint32_t LoaderFlags; + // FIXME: This should be NumberOfRvaAndSizes to match the COFF spec. uint32_t NumberOfRvaAndSize; }; @@ -524,7 +546,9 @@ namespace COFF { BOUND_IMPORT, IAT, DELAY_IMPORT_DESCRIPTOR, - CLR_RUNTIME_HEADER + CLR_RUNTIME_HEADER, + + NUM_DATA_DIRECTORIES }; enum WindowsSubsystem { @@ -642,13 +666,18 @@ namespace COFF { enum CodeViewLineTableIdentifiers { DEBUG_SECTION_MAGIC = 0x4, + DEBUG_SYMBOL_SUBSECTION = 0xF1, DEBUG_LINE_TABLE_SUBSECTION = 0xF2, DEBUG_STRING_TABLE_SUBSECTION = 0xF3, - DEBUG_INDEX_SUBSECTION = 0xF4 + DEBUG_INDEX_SUBSECTION = 0xF4, + + // Symbol subsections are split into records of different types. + DEBUG_SYMBOL_TYPE_PROC_START = 0x1147, + DEBUG_SYMBOL_TYPE_PROC_END = 0x114F }; - inline bool isReservedSectionNumber(int N) { - return N == IMAGE_SYM_UNDEFINED || N > MaxNumberOfSections; + inline bool isReservedSectionNumber(int32_t SectionNumber) { + return SectionNumber <= 0; } } // End namespace COFF. diff --git a/contrib/llvm/include/llvm/Support/Casting.h b/contrib/llvm/include/llvm/Support/Casting.h index beed31a4084f..6ba5efa47554 100644 --- a/contrib/llvm/include/llvm/Support/Casting.h +++ b/contrib/llvm/include/llvm/Support/Casting.h @@ -243,6 +243,26 @@ inline typename cast_retty<X, Y *>::ret_type cast(Y *Val) { // accepted. // template <class X, class Y> +LLVM_ATTRIBUTE_UNUSED_RESULT inline typename std::enable_if< + !is_simple_type<Y>::value, typename cast_retty<X, const Y>::ret_type>::type +cast_or_null(const Y &Val) { + if (!Val) + return nullptr; + assert(isa<X>(Val) && "cast_or_null<Ty>() argument of incompatible type!"); + return cast<X>(Val); +} + +template <class X, class Y> +LLVM_ATTRIBUTE_UNUSED_RESULT inline typename std::enable_if< + !is_simple_type<Y>::value, typename cast_retty<X, Y>::ret_type>::type +cast_or_null(Y &Val) { + if (!Val) + return nullptr; + assert(isa<X>(Val) && "cast_or_null<Ty>() argument of incompatible type!"); + return cast<X>(Val); +} + +template <class X, class Y> LLVM_ATTRIBUTE_UNUSED_RESULT inline typename cast_retty<X, Y *>::ret_type cast_or_null(Y *Val) { if (!Val) return nullptr; @@ -282,6 +302,20 @@ dyn_cast(Y *Val) { // value is accepted. // template <class X, class Y> +LLVM_ATTRIBUTE_UNUSED_RESULT inline typename std::enable_if< + !is_simple_type<Y>::value, typename cast_retty<X, const Y>::ret_type>::type +dyn_cast_or_null(const Y &Val) { + return (Val && isa<X>(Val)) ? cast<X>(Val) : nullptr; +} + +template <class X, class Y> +LLVM_ATTRIBUTE_UNUSED_RESULT inline typename std::enable_if< + !is_simple_type<Y>::value, typename cast_retty<X, Y>::ret_type>::type +dyn_cast_or_null(Y &Val) { + return (Val && isa<X>(Val)) ? cast<X>(Val) : nullptr; +} + +template <class X, class Y> LLVM_ATTRIBUTE_UNUSED_RESULT inline typename cast_retty<X, Y *>::ret_type dyn_cast_or_null(Y *Val) { return (Val && isa<X>(Val)) ? cast<X>(Val) : nullptr; diff --git a/contrib/llvm/include/llvm/Support/CommandLine.h b/contrib/llvm/include/llvm/Support/CommandLine.h index fdd901200fe9..1c06bf5f8c07 100644 --- a/contrib/llvm/include/llvm/Support/CommandLine.h +++ b/contrib/llvm/include/llvm/Support/CommandLine.h @@ -40,7 +40,7 @@ namespace cl { //===----------------------------------------------------------------------===// // ParseCommandLineOptions - Command line option processing entry point. // -void ParseCommandLineOptions(int argc, const char * const *argv, +void ParseCommandLineOptions(int argc, const char *const *argv, const char *Overview = nullptr); //===----------------------------------------------------------------------===// @@ -66,7 +66,6 @@ void SetVersionPrinter(void (*func)()); /// information specific to the tool. void AddExtraVersionPrinter(void (*func)()); - // PrintOptionValues - Print option values. // With -print-options print the difference between option values and defaults. // With -print-all-options print all option values. @@ -80,11 +79,11 @@ void MarkOptionsChanged(); // Flags permitted to be passed to command line arguments // -enum NumOccurrencesFlag { // Flags for the number of occurrences allowed - Optional = 0x00, // Zero or One occurrence - ZeroOrMore = 0x01, // Zero or more occurrences allowed - Required = 0x02, // One occurrence required - OneOrMore = 0x03, // One or more occurrences required +enum NumOccurrencesFlag { // Flags for the number of occurrences allowed + Optional = 0x00, // Zero or One occurrence + ZeroOrMore = 0x01, // Zero or more occurrences allowed + Required = 0x02, // One occurrence required + OneOrMore = 0x03, // One or more occurrences required // ConsumeAfter - Indicates that this option is fed anything that follows the // last positional argument required by the application (it is an error if @@ -93,20 +92,20 @@ enum NumOccurrencesFlag { // Flags for the number of occurrences allowed // found. Once a filename is found, all of the succeeding arguments are // passed, unprocessed, to the ConsumeAfter option. // - ConsumeAfter = 0x04 + ConsumeAfter = 0x04 }; -enum ValueExpected { // Is a value required for the option? +enum ValueExpected { // Is a value required for the option? // zero reserved for the unspecified value - ValueOptional = 0x01, // The value can appear... or not - ValueRequired = 0x02, // The value is required to appear! - ValueDisallowed = 0x03 // A value may not be specified (for flags) + ValueOptional = 0x01, // The value can appear... or not + ValueRequired = 0x02, // The value is required to appear! + ValueDisallowed = 0x03 // A value may not be specified (for flags) }; -enum OptionHidden { // Control whether -help shows this option - NotHidden = 0x00, // Option included in -help & -help-hidden - Hidden = 0x01, // -help doesn't, but -help-hidden does - ReallyHidden = 0x02 // Neither -help nor -help-hidden show this arg +enum OptionHidden { // Control whether -help shows this option + NotHidden = 0x00, // Option included in -help & -help-hidden + Hidden = 0x01, // -help doesn't, but -help-hidden does + ReallyHidden = 0x02 // Neither -help nor -help-hidden show this arg }; // Formatting flags - This controls special features that the option might have @@ -125,16 +124,16 @@ enum OptionHidden { // Control whether -help shows this option // enum FormattingFlags { - NormalFormatting = 0x00, // Nothing special - Positional = 0x01, // Is a positional argument, no '-' required - Prefix = 0x02, // Can this option directly prefix its value? - Grouping = 0x03 // Can this option group with other options? + NormalFormatting = 0x00, // Nothing special + Positional = 0x01, // Is a positional argument, no '-' required + Prefix = 0x02, // Can this option directly prefix its value? + Grouping = 0x03 // Can this option group with other options? }; -enum MiscFlags { // Miscellaneous flags to adjust argument - CommaSeparated = 0x01, // Should this cl::list split between commas? - PositionalEatsArgs = 0x02, // Should this positional cl::list eat -args? - Sink = 0x04 // Should this cl::list eat all unknown options? +enum MiscFlags { // Miscellaneous flags to adjust argument + CommaSeparated = 0x01, // Should this cl::list split between commas? + PositionalEatsArgs = 0x02, // Should this positional cl::list eat -args? + Sink = 0x04 // Should this cl::list eat all unknown options? }; //===----------------------------------------------------------------------===// @@ -145,9 +144,13 @@ private: const char *const Name; const char *const Description; void registerCategory(); + public: - OptionCategory(const char *const Name, const char *const Description = nullptr) - : Name(Name), Description(Description) { registerCategory(); } + OptionCategory(const char *const Name, + const char *const Description = nullptr) + : Name(Name), Description(Description) { + registerCategory(); + } const char *getName() const { return Name; } const char *getDescription() const { return Description; } }; @@ -176,7 +179,7 @@ class Option { // Out of line virtual function to provide home for the class. virtual void anchor(); - int NumOccurrences; // The number of times specified + int NumOccurrences; // The number of times specified // Occurrences, HiddenFlag, and Formatting are all enum types but to avoid // problems with signed enums in bitfields. unsigned Occurrences : 3; // enum NumOccurrencesFlag @@ -186,9 +189,9 @@ class Option { unsigned HiddenFlag : 2; // enum OptionHidden unsigned Formatting : 2; // enum FormattingFlags unsigned Misc : 3; - unsigned Position; // Position of last occurrence of the option - unsigned AdditionalVals;// Greater than 0 for multi-valued option. - Option *NextRegistered; // Singly linked list of registered options. + unsigned Position; // Position of last occurrence of the option + unsigned AdditionalVals; // Greater than 0 for multi-valued option. + Option *NextRegistered; // Singly linked list of registered options. public: const char *ArgStr; // The argument string itself (ex: "help", "o") @@ -200,8 +203,7 @@ public: return (enum NumOccurrencesFlag)Occurrences; } inline enum ValueExpected getValueExpectedFlag() const { - return Value ? ((enum ValueExpected)Value) - : getValueExpectedFlagDefault(); + return Value ? ((enum ValueExpected)Value) : getValueExpectedFlagDefault(); } inline enum OptionHidden getOptionHiddenFlag() const { return (enum OptionHidden)HiddenFlag; @@ -209,9 +211,7 @@ public: inline enum FormattingFlags getFormattingFlag() const { return (enum FormattingFlags)Formatting; } - inline unsigned getMiscFlags() const { - return Misc; - } + inline unsigned getMiscFlags() const { return Misc; } inline unsigned getPosition() const { return Position; } inline unsigned getNumAdditionalVals() const { return AdditionalVals; } @@ -224,25 +224,24 @@ public: void setArgStr(const char *S) { ArgStr = S; } void setDescription(const char *S) { HelpStr = S; } void setValueStr(const char *S) { ValueStr = S; } - void setNumOccurrencesFlag(enum NumOccurrencesFlag Val) { - Occurrences = Val; - } + void setNumOccurrencesFlag(enum NumOccurrencesFlag Val) { Occurrences = Val; } void setValueExpectedFlag(enum ValueExpected Val) { Value = Val; } void setHiddenFlag(enum OptionHidden Val) { HiddenFlag = Val; } void setFormattingFlag(enum FormattingFlags V) { Formatting = V; } void setMiscFlag(enum MiscFlags M) { Misc |= M; } void setPosition(unsigned pos) { Position = pos; } void setCategory(OptionCategory &C) { Category = &C; } + protected: explicit Option(enum NumOccurrencesFlag OccurrencesFlag, enum OptionHidden Hidden) - : NumOccurrences(0), Occurrences(OccurrencesFlag), Value(0), - HiddenFlag(Hidden), Formatting(NormalFormatting), Misc(0), - Position(0), AdditionalVals(0), NextRegistered(nullptr), - ArgStr(""), HelpStr(""), ValueStr(""), Category(&GeneralCategory) { - } + : NumOccurrences(0), Occurrences(OccurrencesFlag), Value(0), + HiddenFlag(Hidden), Formatting(NormalFormatting), Misc(0), Position(0), + AdditionalVals(0), NextRegistered(nullptr), ArgStr(""), HelpStr(""), + ValueStr(""), Category(&GeneralCategory) {} inline void setNumAdditionalVals(unsigned n) { AdditionalVals = n; } + public: // addArgument - Register this argument with the commandline system. // @@ -266,12 +265,12 @@ public: virtual void printOptionValue(size_t GlobalWidth, bool Force) const = 0; - virtual void getExtraOptionNames(SmallVectorImpl<const char*> &) {} + virtual void getExtraOptionNames(SmallVectorImpl<const char *> &) {} // addOccurrence - Wrapper around handleOccurrence that enforces Flags. // - virtual bool addOccurrence(unsigned pos, StringRef ArgName, - StringRef Value, bool MultiArg = false); + virtual bool addOccurrence(unsigned pos, StringRef ArgName, StringRef Value, + bool MultiArg = false); // Prints option name followed by message. Always returns true. bool error(const Twine &Message, StringRef ArgName = StringRef()); @@ -281,7 +280,6 @@ public: virtual ~Option() {} }; - //===----------------------------------------------------------------------===// // Command line option modifiers that can be used to modify the behavior of // command line option parsers... @@ -306,36 +304,31 @@ struct value_desc { // the default constructor for the argument type does not give you what you // want. This is only valid on "opt" arguments, not on "list" arguments. // -template<class Ty> -struct initializer { +template <class Ty> struct initializer { const Ty &Init; initializer(const Ty &Val) : Init(Val) {} - template<class Opt> - void apply(Opt &O) const { O.setInitialValue(Init); } + template <class Opt> void apply(Opt &O) const { O.setInitialValue(Init); } }; -template<class Ty> -initializer<Ty> init(const Ty &Val) { +template <class Ty> initializer<Ty> init(const Ty &Val) { return initializer<Ty>(Val); } - // location - Allow the user to specify which external variable they want to // store the results of the command line argument processing into, if they don't // want to store it in the option itself. // -template<class Ty> -struct LocationClass { +template <class Ty> struct LocationClass { Ty &Loc; LocationClass(Ty &L) : Loc(L) {} - template<class Opt> - void apply(Opt &O) const { O.setLocation(O, Loc); } + template <class Opt> void apply(Opt &O) const { O.setLocation(O, Loc); } }; -template<class Ty> -LocationClass<Ty> location(Ty &L) { return LocationClass<Ty>(L); } +template <class Ty> LocationClass<Ty> location(Ty &L) { + return LocationClass<Ty>(L); +} // cat - Specifiy the Option category for the command line argument to belong // to. @@ -343,11 +336,9 @@ struct cat { OptionCategory &Category; cat(OptionCategory &c) : Category(c) {} - template<class Opt> - void apply(Opt &O) const { O.setCategory(Category); } + template <class Opt> void apply(Opt &O) const { O.setCategory(Category); } }; - //===----------------------------------------------------------------------===// // OptionValue class @@ -360,11 +351,11 @@ private: virtual void anchor(); }; -template<class DataType> struct OptionValue; +template <class DataType> struct OptionValue; // The default value safely does nothing. Option value printing is only // best-effort. -template<class DataType, bool isClass> +template <class DataType, bool isClass> struct OptionValueBase : public GenericOptionValue { // Temporary storage for argument passing. typedef OptionValue<DataType> WrapperType; @@ -374,21 +365,20 @@ struct OptionValueBase : public GenericOptionValue { const DataType &getValue() const { llvm_unreachable("no default value"); } // Some options may take their value from a different data type. - template<class DT> - void setValue(const DT& /*V*/) {} + template <class DT> void setValue(const DT & /*V*/) {} - bool compare(const DataType &/*V*/) const { return false; } + bool compare(const DataType & /*V*/) const { return false; } - bool compare(const GenericOptionValue& /*V*/) const override { + bool compare(const GenericOptionValue & /*V*/) const override { return false; } }; // Simple copy of the option value. -template<class DataType> -class OptionValueCopy : public GenericOptionValue { +template <class DataType> class OptionValueCopy : public GenericOptionValue { DataType Value; bool Valid; + public: OptionValueCopy() : Valid(false) {} @@ -399,37 +389,36 @@ public: return Value; } - void setValue(const DataType &V) { Valid = true; Value = V; } - - bool compare(const DataType &V) const { - return Valid && (Value != V); + void setValue(const DataType &V) { + Valid = true; + Value = V; } + bool compare(const DataType &V) const { return Valid && (Value != V); } + bool compare(const GenericOptionValue &V) const override { const OptionValueCopy<DataType> &VC = - static_cast< const OptionValueCopy<DataType>& >(V); - if (!VC.hasValue()) return false; + static_cast<const OptionValueCopy<DataType> &>(V); + if (!VC.hasValue()) + return false; return compare(VC.getValue()); } }; // Non-class option values. -template<class DataType> +template <class DataType> struct OptionValueBase<DataType, false> : OptionValueCopy<DataType> { typedef DataType WrapperType; }; // Top-level option class. -template<class DataType> +template <class DataType> struct OptionValue : OptionValueBase<DataType, std::is_class<DataType>::value> { OptionValue() {} - OptionValue(const DataType& V) { - this->setValue(V); - } + OptionValue(const DataType &V) { this->setValue(V); } // Some options may take their value from a different data type. - template<class DT> - OptionValue<DataType> &operator=(const DT& V) { + template <class DT> OptionValue<DataType> &operator=(const DT &V) { this->setValue(V); return *this; } @@ -437,36 +426,33 @@ struct OptionValue : OptionValueBase<DataType, std::is_class<DataType>::value> { // Other safe-to-copy-by-value common option types. enum boolOrDefault { BOU_UNSET, BOU_TRUE, BOU_FALSE }; -template<> +template <> struct OptionValue<cl::boolOrDefault> : OptionValueCopy<cl::boolOrDefault> { typedef cl::boolOrDefault WrapperType; OptionValue() {} - OptionValue(const cl::boolOrDefault& V) { - this->setValue(V); - } - OptionValue<cl::boolOrDefault> &operator=(const cl::boolOrDefault& V) { + OptionValue(const cl::boolOrDefault &V) { this->setValue(V); } + OptionValue<cl::boolOrDefault> &operator=(const cl::boolOrDefault &V) { setValue(V); return *this; } + private: void anchor() override; }; -template<> -struct OptionValue<std::string> : OptionValueCopy<std::string> { +template <> struct OptionValue<std::string> : OptionValueCopy<std::string> { typedef StringRef WrapperType; OptionValue() {} - OptionValue(const std::string& V) { - this->setValue(V); - } - OptionValue<std::string> &operator=(const std::string& V) { + OptionValue(const std::string &V) { this->setValue(V); } + OptionValue<std::string> &operator=(const std::string &V) { setValue(V); return *this; } + private: void anchor() override; }; @@ -476,20 +462,20 @@ private: // #define clEnumVal(ENUMVAL, DESC) #ENUMVAL, int(ENUMVAL), DESC #define clEnumValN(ENUMVAL, FLAGNAME, DESC) FLAGNAME, int(ENUMVAL), DESC -#define clEnumValEnd (reinterpret_cast<void*>(0)) +#define clEnumValEnd (reinterpret_cast<void *>(0)) // values - For custom data types, allow specifying a group of values together // as the values that go into the mapping that the option handler uses. Note // that the values list must always have a 0 at the end of the list to indicate // that the list has ended. // -template<class DataType> -class ValuesClass { +template <class DataType> class ValuesClass { // Use a vector instead of a map, because the lists should be short, // the overhead is less, and most importantly, it keeps them in the order // inserted so we can print our option out nicely. - SmallVector<std::pair<const char *, std::pair<int, const char *> >,4> Values; + SmallVector<std::pair<const char *, std::pair<int, const char *>>, 4> Values; void processValues(va_list Vals); + public: ValuesClass(const char *EnumName, DataType Val, const char *Desc, va_list ValueArgs) { @@ -500,27 +486,26 @@ public: while (const char *enumName = va_arg(ValueArgs, const char *)) { DataType EnumVal = static_cast<DataType>(va_arg(ValueArgs, int)); const char *EnumDesc = va_arg(ValueArgs, const char *); - Values.push_back(std::make_pair(enumName, // Add value to value map + Values.push_back(std::make_pair(enumName, // Add value to value map std::make_pair(EnumVal, EnumDesc))); } } - template<class Opt> - void apply(Opt &O) const { + template <class Opt> void apply(Opt &O) const { for (size_t i = 0, e = Values.size(); i != e; ++i) O.getParser().addLiteralOption(Values[i].first, Values[i].second.first, Values[i].second.second); } }; -template<class DataType> -ValuesClass<DataType> END_WITH_NULL values(const char *Arg, DataType Val, - const char *Desc, ...) { - va_list ValueArgs; - va_start(ValueArgs, Desc); - ValuesClass<DataType> Vals(Arg, Val, Desc, ValueArgs); - va_end(ValueArgs); - return Vals; +template <class DataType> +ValuesClass<DataType> LLVM_END_WITH_NULL +values(const char *Arg, DataType Val, const char *Desc, ...) { + va_list ValueArgs; + va_start(ValueArgs, Desc); + ValuesClass<DataType> Vals(Arg, Val, Desc, ValueArgs); + va_end(ValueArgs); + return Vals; } //===----------------------------------------------------------------------===// @@ -539,13 +524,14 @@ class generic_parser_base { protected: class GenericOptionInfo { public: - GenericOptionInfo(const char *name, const char *helpStr) : - Name(name), HelpStr(helpStr) {} + GenericOptionInfo(const char *name, const char *helpStr) + : Name(name), HelpStr(helpStr) {} const char *Name; const char *HelpStr; }; + public: - virtual ~generic_parser_base() {} // Base class should have virtual-dtor + virtual ~generic_parser_base() {} // Base class should have virtual-dtor // getNumOptions - Virtual function implemented by generic subclass to // indicate how many entries are in Values. @@ -576,7 +562,7 @@ public: // // Template definition ensures that the option and default have the same // DataType (via the same AnyOptionValue). - template<class AnyOptionValue> + template <class AnyOptionValue> void printOptionDiff(const Option &O, const AnyOptionValue &V, const AnyOptionValue &Default, size_t GlobalWidth) const { @@ -590,7 +576,7 @@ public: hasArgStr = O.hasArgStr(); } - void getExtraOptionNames(SmallVectorImpl<const char*> &OptionNames) { + void getExtraOptionNames(SmallVectorImpl<const char *> &OptionNames) { // If there has been no argstr specified, that means that we need to add an // argument for every possible option. This ensures that our options are // vectored to us. @@ -599,7 +585,6 @@ public: OptionNames.push_back(getOption(i)); } - enum ValueExpected getValueExpectedFlagDefault() const { // If there is an ArgStr specified, then we are of the form: // @@ -633,16 +618,16 @@ protected: // command line option for -help. Because this is a simple mapping parser, the // data type can be any unsupported type. // -template <class DataType> -class parser : public generic_parser_base { +template <class DataType> class parser : public generic_parser_base { protected: class OptionInfo : public GenericOptionInfo { public: - OptionInfo(const char *name, DataType v, const char *helpStr) : - GenericOptionInfo(name, helpStr), V(v) {} + OptionInfo(const char *name, DataType v, const char *helpStr) + : GenericOptionInfo(name, helpStr), V(v) {} OptionValue<DataType> V; }; SmallVector<OptionInfo, 8> Values; + public: typedef DataType parser_data_type; @@ -690,14 +675,14 @@ public: void removeLiteralOption(const char *Name) { unsigned N = findOption(Name); assert(N != Values.size() && "Option not found!"); - Values.erase(Values.begin()+N); + Values.erase(Values.begin() + N); } }; //-------------------------------------------------- // basic_parser - Super class of parsers to provide boilerplate code // -class basic_parser_impl { // non-template implementation of basic_parser<t> +class basic_parser_impl { // non-template implementation of basic_parser<t> public: virtual ~basic_parser_impl() {} @@ -705,7 +690,7 @@ public: return ValueRequired; } - void getExtraOptionNames(SmallVectorImpl<const char*> &) {} + void getExtraOptionNames(SmallVectorImpl<const char *> &) {} void initialize(Option &) {} @@ -735,8 +720,7 @@ protected: // basic_parser - The real basic parser is just a template wrapper that provides // a typedef for the provided data type. // -template<class DataType> -class basic_parser : public basic_parser_impl { +template <class DataType> class basic_parser : public basic_parser_impl { public: typedef DataType parser_data_type; typedef OptionValue<DataType> OptVal; @@ -745,18 +729,14 @@ public: //-------------------------------------------------- // parser<bool> // -template<> -class parser<bool> : public basic_parser<bool> { +template <> class parser<bool> : public basic_parser<bool> { const char *ArgStr; -public: +public: // parse - Return true on error. bool parse(Option &O, StringRef ArgName, StringRef Arg, bool &Val); - template <class Opt> - void initialize(Opt &O) { - ArgStr = O.ArgStr; - } + template <class Opt> void initialize(Opt &O) { ArgStr = O.ArgStr; } enum ValueExpected getValueExpectedFlagDefault() const { return ValueOptional; @@ -776,8 +756,7 @@ EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<bool>); //-------------------------------------------------- // parser<boolOrDefault> -template<> -class parser<boolOrDefault> : public basic_parser<boolOrDefault> { +template <> class parser<boolOrDefault> : public basic_parser<boolOrDefault> { public: // parse - Return true on error. bool parse(Option &O, StringRef ArgName, StringRef Arg, boolOrDefault &Val); @@ -801,8 +780,7 @@ EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<boolOrDefault>); //-------------------------------------------------- // parser<int> // -template<> -class parser<int> : public basic_parser<int> { +template <> class parser<int> : public basic_parser<int> { public: // parse - Return true on error. bool parse(Option &O, StringRef ArgName, StringRef Arg, int &Val); @@ -819,12 +797,10 @@ public: EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<int>); - //-------------------------------------------------- // parser<unsigned> // -template<> -class parser<unsigned> : public basic_parser<unsigned> { +template <> class parser<unsigned> : public basic_parser<unsigned> { public: // parse - Return true on error. bool parse(Option &O, StringRef ArgName, StringRef Arg, unsigned &Val); @@ -844,7 +820,7 @@ EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<unsigned>); //-------------------------------------------------- // parser<unsigned long long> // -template<> +template <> class parser<unsigned long long> : public basic_parser<unsigned long long> { public: // parse - Return true on error. @@ -866,8 +842,7 @@ EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<unsigned long long>); //-------------------------------------------------- // parser<double> // -template<> -class parser<double> : public basic_parser<double> { +template <> class parser<double> : public basic_parser<double> { public: // parse - Return true on error. bool parse(Option &O, StringRef ArgName, StringRef Arg, double &Val); @@ -887,8 +862,7 @@ EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<double>); //-------------------------------------------------- // parser<float> // -template<> -class parser<float> : public basic_parser<float> { +template <> class parser<float> : public basic_parser<float> { public: // parse - Return true on error. bool parse(Option &O, StringRef ArgName, StringRef Arg, float &Val); @@ -908,8 +882,7 @@ EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<float>); //-------------------------------------------------- // parser<std::string> // -template<> -class parser<std::string> : public basic_parser<std::string> { +template <> class parser<std::string> : public basic_parser<std::string> { public: // parse - Return true on error. bool parse(Option &, StringRef, StringRef Arg, std::string &Value) { @@ -932,8 +905,7 @@ EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<std::string>); //-------------------------------------------------- // parser<char> // -template<> -class parser<char> : public basic_parser<char> { +template <> class parser<char> : public basic_parser<char> { public: // parse - Return true on error. bool parse(Option &, StringRef, StringRef Arg, char &Value) { @@ -960,7 +932,7 @@ EXTERN_TEMPLATE_INSTANTIATION(class basic_parser<char>); // parser to handle all the template nastiness. // This overloaded function is selected by the generic parser. -template<class ParserClass, class DT> +template <class ParserClass, class DT> void printOptionDiff(const Option &O, const generic_parser_base &P, const DT &V, const OptionValue<DT> &Default, size_t GlobalWidth) { OptionValue<DT> OV = V; @@ -969,18 +941,16 @@ void printOptionDiff(const Option &O, const generic_parser_base &P, const DT &V, // This is instantiated for basic parsers when the parsed value has a different // type than the option value. e.g. HelpPrinter. -template<class ParserDT, class ValDT> -struct OptionDiffPrinter { - void print(const Option &O, const parser<ParserDT> P, const ValDT &/*V*/, - const OptionValue<ValDT> &/*Default*/, size_t GlobalWidth) { +template <class ParserDT, class ValDT> struct OptionDiffPrinter { + void print(const Option &O, const parser<ParserDT> P, const ValDT & /*V*/, + const OptionValue<ValDT> & /*Default*/, size_t GlobalWidth) { P.printOptionNoValue(O, GlobalWidth); } }; // This is instantiated for basic parsers when the parsed value has the same // type as the option value. -template<class DT> -struct OptionDiffPrinter<DT, DT> { +template <class DT> struct OptionDiffPrinter<DT, DT> { void print(const Option &O, const parser<DT> P, const DT &V, const OptionValue<DT> &Default, size_t GlobalWidth) { P.printOptionDiff(O, V, Default, GlobalWidth); @@ -989,15 +959,14 @@ struct OptionDiffPrinter<DT, DT> { // This overloaded function is selected by the basic parser, which may parse a // different type than the option type. -template<class ParserClass, class ValDT> +template <class ParserClass, class ValDT> void printOptionDiff( - const Option &O, - const basic_parser<typename ParserClass::parser_data_type> &P, - const ValDT &V, const OptionValue<ValDT> &Default, - size_t GlobalWidth) { + const Option &O, + const basic_parser<typename ParserClass::parser_data_type> &P, + const ValDT &V, const OptionValue<ValDT> &Default, size_t GlobalWidth) { OptionDiffPrinter<typename ParserClass::parser_data_type, ValDT> printer; - printer.print(O, static_cast<const ParserClass&>(P), V, Default, + printer.print(O, static_cast<const ParserClass &>(P), V, Default, GlobalWidth); } @@ -1007,46 +976,47 @@ void printOptionDiff( // not correctly respond to the apply method). Because the syntax to use this // is a pain, we have the 'apply' method below to handle the nastiness... // -template<class Mod> struct applicator { - template<class Opt> - static void opt(const Mod &M, Opt &O) { M.apply(O); } +template <class Mod> struct applicator { + template <class Opt> static void opt(const Mod &M, Opt &O) { M.apply(O); } }; // Handle const char* as a special case... -template<unsigned n> struct applicator<char[n]> { - template<class Opt> - static void opt(const char *Str, Opt &O) { O.setArgStr(Str); } +template <unsigned n> struct applicator<char[n]> { + template <class Opt> static void opt(const char *Str, Opt &O) { + O.setArgStr(Str); + } }; -template<unsigned n> struct applicator<const char[n]> { - template<class Opt> - static void opt(const char *Str, Opt &O) { O.setArgStr(Str); } +template <unsigned n> struct applicator<const char[n]> { + template <class Opt> static void opt(const char *Str, Opt &O) { + O.setArgStr(Str); + } }; -template<> struct applicator<const char*> { - template<class Opt> - static void opt(const char *Str, Opt &O) { O.setArgStr(Str); } +template <> struct applicator<const char *> { + template <class Opt> static void opt(const char *Str, Opt &O) { + O.setArgStr(Str); + } }; -template<> struct applicator<NumOccurrencesFlag> { +template <> struct applicator<NumOccurrencesFlag> { static void opt(NumOccurrencesFlag N, Option &O) { O.setNumOccurrencesFlag(N); } }; -template<> struct applicator<ValueExpected> { +template <> struct applicator<ValueExpected> { static void opt(ValueExpected VE, Option &O) { O.setValueExpectedFlag(VE); } }; -template<> struct applicator<OptionHidden> { +template <> struct applicator<OptionHidden> { static void opt(OptionHidden OH, Option &O) { O.setHiddenFlag(OH); } }; -template<> struct applicator<FormattingFlags> { +template <> struct applicator<FormattingFlags> { static void opt(FormattingFlags FF, Option &O) { O.setFormattingFlag(FF); } }; -template<> struct applicator<MiscFlags> { +template <> struct applicator<MiscFlags> { static void opt(MiscFlags MF, Option &O) { O.setMiscFlag(MF); } }; // apply method - Apply a modifier to an option in a type safe way. -template<class Mod, class Opt> -void apply(const Mod &M, Opt *O) { +template <class Mod, class Opt> void apply(const Mod &M, Opt *O) { applicator<Mod>::opt(M, *O); } @@ -1057,16 +1027,17 @@ void apply(const Mod &M, Opt *O) { // assumes the user will specify a variable to store the data into with the // cl::location(x) modifier. // -template<class DataType, bool ExternalStorage, bool isClass> +template <class DataType, bool ExternalStorage, bool isClass> class opt_storage { - DataType *Location; // Where to store the object... + DataType *Location; // Where to store the object... OptionValue<DataType> Default; void check_location() const { assert(Location && "cl::location(...) not specified for a command " - "line option with external storage, " - "or cl::init specified before cl::location()!!"); + "line option with external storage, " + "or cl::init specified before cl::location()!!"); } + public: opt_storage() : Location(nullptr) {} @@ -1078,16 +1049,21 @@ public: return false; } - template<class T> - void setValue(const T &V, bool initial = false) { + template <class T> void setValue(const T &V, bool initial = false) { check_location(); *Location = V; if (initial) Default = V; } - DataType &getValue() { check_location(); return *Location; } - const DataType &getValue() const { check_location(); return *Location; } + DataType &getValue() { + check_location(); + return *Location; + } + const DataType &getValue() const { + check_location(); + return *Location; + } operator DataType() const { return this->getValue(); } @@ -1098,13 +1074,12 @@ public: // inherit from a class, we do so. This makes us exactly compatible with the // object in all cases that it is used. // -template<class DataType> -class opt_storage<DataType,false,true> : public DataType { +template <class DataType> +class opt_storage<DataType, false, true> : public DataType { public: OptionValue<DataType> Default; - template<class T> - void setValue(const T &V, bool initial = false) { + template <class T> void setValue(const T &V, bool initial = false) { DataType::operator=(V); if (initial) Default = V; @@ -1120,8 +1095,7 @@ public: // this case, we store an instance through containment, and overload operators // to get at the value. // -template<class DataType> -class opt_storage<DataType, false, false> { +template <class DataType> class opt_storage<DataType, false, false> { public: DataType Value; OptionValue<DataType> Default; @@ -1130,8 +1104,7 @@ public: // type. opt_storage() : Value(DataType()), Default(DataType()) {} - template<class T> - void setValue(const T &V, bool initial = false) { + template <class T> void setValue(const T &V, bool initial = false) { Value = V; if (initial) Default = V; @@ -1147,12 +1120,11 @@ public: DataType operator->() const { return Value; } }; - //===----------------------------------------------------------------------===// // opt - A scalar command line option. // template <class DataType, bool ExternalStorage = false, - class ParserClass = parser<DataType> > + class ParserClass = parser<DataType>> class opt : public Option, public opt_storage<DataType, ExternalStorage, std::is_class<DataType>::value> { @@ -1161,9 +1133,9 @@ class opt : public Option, bool handleOccurrence(unsigned pos, StringRef ArgName, StringRef Arg) override { typename ParserClass::parser_data_type Val = - typename ParserClass::parser_data_type(); + typename ParserClass::parser_data_type(); if (Parser.parse(*this, ArgName, Arg, Val)) - return true; // Parse error! + return true; // Parse error! this->setValue(Val); this->setPosition(pos); return false; @@ -1172,20 +1144,23 @@ class opt : public Option, enum ValueExpected getValueExpectedFlagDefault() const override { return Parser.getValueExpectedFlagDefault(); } - void getExtraOptionNames(SmallVectorImpl<const char*> &OptionNames) override { + void + getExtraOptionNames(SmallVectorImpl<const char *> &OptionNames) override { return Parser.getExtraOptionNames(OptionNames); } // Forward printing stuff to the parser... - size_t getOptionWidth() const override {return Parser.getOptionWidth(*this);} + size_t getOptionWidth() const override { + return Parser.getOptionWidth(*this); + } void printOptionInfo(size_t GlobalWidth) const override { Parser.printOptionInfo(*this, GlobalWidth); } void printOptionValue(size_t GlobalWidth, bool Force) const override { if (Force || this->getDefault().compare(this->getValue())) { - cl::printOptionDiff<ParserClass>( - *this, Parser, this->getValue(), this->getDefault(), GlobalWidth); + cl::printOptionDiff<ParserClass>(*this, Parser, this->getValue(), + this->getDefault(), GlobalWidth); } } @@ -1193,81 +1168,107 @@ class opt : public Option, addArgument(); Parser.initialize(*this); } + public: // setInitialValue - Used by the cl::init modifier... void setInitialValue(const DataType &V) { this->setValue(V, true); } ParserClass &getParser() { return Parser; } - template<class T> - DataType &operator=(const T &Val) { + template <class T> DataType &operator=(const T &Val) { this->setValue(Val); return this->getValue(); } // One option... - template<class M0t> - explicit opt(const M0t &M0) : Option(Optional, NotHidden) { + template <class M0t> + explicit opt(const M0t &M0) + : Option(Optional, NotHidden) { apply(M0, this); done(); } // Two options... - template<class M0t, class M1t> - opt(const M0t &M0, const M1t &M1) : Option(Optional, NotHidden) { - apply(M0, this); apply(M1, this); + template <class M0t, class M1t> + opt(const M0t &M0, const M1t &M1) + : Option(Optional, NotHidden) { + apply(M0, this); + apply(M1, this); done(); } // Three options... - template<class M0t, class M1t, class M2t> - opt(const M0t &M0, const M1t &M1, - const M2t &M2) : Option(Optional, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); + template <class M0t, class M1t, class M2t> + opt(const M0t &M0, const M1t &M1, const M2t &M2) + : Option(Optional, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); done(); } // Four options... - template<class M0t, class M1t, class M2t, class M3t> - opt(const M0t &M0, const M1t &M1, const M2t &M2, - const M3t &M3) : Option(Optional, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + template <class M0t, class M1t, class M2t, class M3t> + opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) + : Option(Optional, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); + apply(M3, this); done(); } // Five options... - template<class M0t, class M1t, class M2t, class M3t, class M4t> - opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4) : Option(Optional, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + template <class M0t, class M1t, class M2t, class M3t, class M4t> + opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, const M4t &M4) + : Option(Optional, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); + apply(M3, this); apply(M4, this); done(); } // Six options... - template<class M0t, class M1t, class M2t, class M3t, - class M4t, class M5t> - opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4, const M5t &M5) : Option(Optional, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - apply(M4, this); apply(M5, this); + template <class M0t, class M1t, class M2t, class M3t, class M4t, class M5t> + opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, const M4t &M4, + const M5t &M5) + : Option(Optional, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); + apply(M3, this); + apply(M4, this); + apply(M5, this); done(); } // Seven options... - template<class M0t, class M1t, class M2t, class M3t, - class M4t, class M5t, class M6t> - opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4, const M5t &M5, - const M6t &M6) : Option(Optional, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - apply(M4, this); apply(M5, this); apply(M6, this); + template <class M0t, class M1t, class M2t, class M3t, class M4t, class M5t, + class M6t> + opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, const M4t &M4, + const M5t &M5, const M6t &M6) + : Option(Optional, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); + apply(M3, this); + apply(M4, this); + apply(M5, this); + apply(M6, this); done(); } // Eight options... - template<class M0t, class M1t, class M2t, class M3t, - class M4t, class M5t, class M6t, class M7t> - opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4, const M5t &M5, const M6t &M6, - const M7t &M7) : Option(Optional, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - apply(M4, this); apply(M5, this); apply(M6, this); apply(M7, this); + template <class M0t, class M1t, class M2t, class M3t, class M4t, class M5t, + class M6t, class M7t> + opt(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, const M4t &M4, + const M5t &M5, const M6t &M6, const M7t &M7) + : Option(Optional, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); + apply(M3, this); + apply(M4, this); + apply(M5, this); + apply(M6, this); + apply(M7, this); done(); } }; @@ -1285,9 +1286,8 @@ EXTERN_TEMPLATE_INSTANTIATION(class opt<bool>); // assumes the user will specify a variable to store the data into with the // cl::location(x) modifier. // -template<class DataType, class StorageClass> -class list_storage { - StorageClass *Location; // Where to store the object... +template <class DataType, class StorageClass> class list_storage { + StorageClass *Location; // Where to store the object... public: list_storage() : Location(0) {} @@ -1299,32 +1299,30 @@ public: return false; } - template<class T> - void addValue(const T &V) { + template <class T> void addValue(const T &V) { assert(Location != 0 && "cl::location(...) not specified for a command " - "line option with external storage!"); + "line option with external storage!"); Location->push_back(V); } }; - // Define how to hold a class type object, such as a string. Since we can // inherit from a class, we do so. This makes us exactly compatible with the // object in all cases that it is used. // -template<class DataType> +template <class DataType> class list_storage<DataType, bool> : public std::vector<DataType> { public: - template<class T> - void addValue(const T &V) { std::vector<DataType>::push_back(V); } + template <class T> void addValue(const T &V) { + std::vector<DataType>::push_back(V); + } }; - //===----------------------------------------------------------------------===// // list - A list of command line options. // template <class DataType, class Storage = bool, - class ParserClass = parser<DataType> > + class ParserClass = parser<DataType>> class list : public Option, public list_storage<DataType, Storage> { std::vector<unsigned> Positions; ParserClass Parser; @@ -1332,16 +1330,17 @@ class list : public Option, public list_storage<DataType, Storage> { enum ValueExpected getValueExpectedFlagDefault() const override { return Parser.getValueExpectedFlagDefault(); } - void getExtraOptionNames(SmallVectorImpl<const char*> &OptionNames) override { + void + getExtraOptionNames(SmallVectorImpl<const char *> &OptionNames) override { return Parser.getExtraOptionNames(OptionNames); } bool handleOccurrence(unsigned pos, StringRef ArgName, StringRef Arg) override { typename ParserClass::parser_data_type Val = - typename ParserClass::parser_data_type(); + typename ParserClass::parser_data_type(); if (Parser.parse(*this, ArgName, Arg, Val)) - return true; // Parse Error! + return true; // Parse Error! list_storage<DataType, Storage>::addValue(Val); setPosition(pos); Positions.push_back(pos); @@ -1349,19 +1348,22 @@ class list : public Option, public list_storage<DataType, Storage> { } // Forward printing stuff to the parser... - size_t getOptionWidth() const override {return Parser.getOptionWidth(*this);} + size_t getOptionWidth() const override { + return Parser.getOptionWidth(*this); + } void printOptionInfo(size_t GlobalWidth) const override { Parser.printOptionInfo(*this, GlobalWidth); } // Unimplemented: list options don't currently store their default value. - void printOptionValue(size_t /*GlobalWidth*/, - bool /*Force*/) const override {} + void printOptionValue(size_t /*GlobalWidth*/, bool /*Force*/) const override { + } void done() { addArgument(); Parser.initialize(*this); } + public: ParserClass &getParser() { return Parser; } @@ -1370,71 +1372,96 @@ public: return Positions[optnum]; } - void setNumAdditionalVals(unsigned n) { - Option::setNumAdditionalVals(n); - } + void setNumAdditionalVals(unsigned n) { Option::setNumAdditionalVals(n); } // One option... - template<class M0t> - explicit list(const M0t &M0) : Option(ZeroOrMore, NotHidden) { + template <class M0t> + explicit list(const M0t &M0) + : Option(ZeroOrMore, NotHidden) { apply(M0, this); done(); } // Two options... - template<class M0t, class M1t> - list(const M0t &M0, const M1t &M1) : Option(ZeroOrMore, NotHidden) { - apply(M0, this); apply(M1, this); + template <class M0t, class M1t> + list(const M0t &M0, const M1t &M1) + : Option(ZeroOrMore, NotHidden) { + apply(M0, this); + apply(M1, this); done(); } // Three options... - template<class M0t, class M1t, class M2t> + template <class M0t, class M1t, class M2t> list(const M0t &M0, const M1t &M1, const M2t &M2) - : Option(ZeroOrMore, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); + : Option(ZeroOrMore, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); done(); } // Four options... - template<class M0t, class M1t, class M2t, class M3t> + template <class M0t, class M1t, class M2t, class M3t> list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) - : Option(ZeroOrMore, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + : Option(ZeroOrMore, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); + apply(M3, this); done(); } // Five options... - template<class M0t, class M1t, class M2t, class M3t, class M4t> + template <class M0t, class M1t, class M2t, class M3t, class M4t> list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4) : Option(ZeroOrMore, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + const M4t &M4) + : Option(ZeroOrMore, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); + apply(M3, this); apply(M4, this); done(); } // Six options... - template<class M0t, class M1t, class M2t, class M3t, - class M4t, class M5t> + template <class M0t, class M1t, class M2t, class M3t, class M4t, class M5t> list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4, const M5t &M5) : Option(ZeroOrMore, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - apply(M4, this); apply(M5, this); + const M4t &M4, const M5t &M5) + : Option(ZeroOrMore, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); + apply(M3, this); + apply(M4, this); + apply(M5, this); done(); } // Seven options... - template<class M0t, class M1t, class M2t, class M3t, - class M4t, class M5t, class M6t> + template <class M0t, class M1t, class M2t, class M3t, class M4t, class M5t, + class M6t> list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, const M4t &M4, const M5t &M5, const M6t &M6) - : Option(ZeroOrMore, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - apply(M4, this); apply(M5, this); apply(M6, this); + : Option(ZeroOrMore, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); + apply(M3, this); + apply(M4, this); + apply(M5, this); + apply(M6, this); done(); } // Eight options... - template<class M0t, class M1t, class M2t, class M3t, - class M4t, class M5t, class M6t, class M7t> + template <class M0t, class M1t, class M2t, class M3t, class M4t, class M5t, + class M6t, class M7t> list(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4, const M5t &M5, const M6t &M6, - const M7t &M7) : Option(ZeroOrMore, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - apply(M4, this); apply(M5, this); apply(M6, this); apply(M7, this); + const M4t &M4, const M5t &M5, const M6t &M6, const M7t &M7) + : Option(ZeroOrMore, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); + apply(M3, this); + apply(M4, this); + apply(M5, this); + apply(M6, this); + apply(M7, this); done(); } }; @@ -1445,10 +1472,11 @@ struct multi_val { explicit multi_val(unsigned N) : AdditionalVals(N) {} template <typename D, typename S, typename P> - void apply(list<D, S, P> &L) const { L.setNumAdditionalVals(AdditionalVals); } + void apply(list<D, S, P> &L) const { + L.setNumAdditionalVals(AdditionalVals); + } }; - //===----------------------------------------------------------------------===// // bits_storage class @@ -1456,15 +1484,13 @@ struct multi_val { // assumes the user will specify a variable to store the data into with the // cl::location(x) modifier. // -template<class DataType, class StorageClass> -class bits_storage { - unsigned *Location; // Where to store the bits... +template <class DataType, class StorageClass> class bits_storage { + unsigned *Location; // Where to store the bits... - template<class T> - static unsigned Bit(const T &V) { + template <class T> static unsigned Bit(const T &V) { unsigned BitPos = reinterpret_cast<unsigned>(V); assert(BitPos < sizeof(unsigned) * CHAR_BIT && - "enum exceeds width of bit vector!"); + "enum exceeds width of bit vector!"); return 1 << BitPos; } @@ -1478,57 +1504,45 @@ public: return false; } - template<class T> - void addValue(const T &V) { + template <class T> void addValue(const T &V) { assert(Location != 0 && "cl::location(...) not specified for a command " - "line option with external storage!"); + "line option with external storage!"); *Location |= Bit(V); } unsigned getBits() { return *Location; } - template<class T> - bool isSet(const T &V) { + template <class T> bool isSet(const T &V) { return (*Location & Bit(V)) != 0; } }; - // Define how to hold bits. Since we can inherit from a class, we do so. // This makes us exactly compatible with the bits in all cases that it is used. // -template<class DataType> -class bits_storage<DataType, bool> { - unsigned Bits; // Where to store the bits... +template <class DataType> class bits_storage<DataType, bool> { + unsigned Bits; // Where to store the bits... - template<class T> - static unsigned Bit(const T &V) { + template <class T> static unsigned Bit(const T &V) { unsigned BitPos = (unsigned)V; assert(BitPos < sizeof(unsigned) * CHAR_BIT && - "enum exceeds width of bit vector!"); + "enum exceeds width of bit vector!"); return 1 << BitPos; } public: - template<class T> - void addValue(const T &V) { - Bits |= Bit(V); - } + template <class T> void addValue(const T &V) { Bits |= Bit(V); } unsigned getBits() { return Bits; } - template<class T> - bool isSet(const T &V) { - return (Bits & Bit(V)) != 0; - } + template <class T> bool isSet(const T &V) { return (Bits & Bit(V)) != 0; } }; - //===----------------------------------------------------------------------===// // bits - A bit vector of command options. // template <class DataType, class Storage = bool, - class ParserClass = parser<DataType> > + class ParserClass = parser<DataType>> class bits : public Option, public bits_storage<DataType, Storage> { std::vector<unsigned> Positions; ParserClass Parser; @@ -1536,16 +1550,17 @@ class bits : public Option, public bits_storage<DataType, Storage> { enum ValueExpected getValueExpectedFlagDefault() const override { return Parser.getValueExpectedFlagDefault(); } - void getExtraOptionNames(SmallVectorImpl<const char*> &OptionNames) override { + void + getExtraOptionNames(SmallVectorImpl<const char *> &OptionNames) override { return Parser.getExtraOptionNames(OptionNames); } bool handleOccurrence(unsigned pos, StringRef ArgName, StringRef Arg) override { typename ParserClass::parser_data_type Val = - typename ParserClass::parser_data_type(); + typename ParserClass::parser_data_type(); if (Parser.parse(*this, ArgName, Arg, Val)) - return true; // Parse Error! + return true; // Parse Error! this->addValue(Val); setPosition(pos); Positions.push_back(pos); @@ -1553,19 +1568,22 @@ class bits : public Option, public bits_storage<DataType, Storage> { } // Forward printing stuff to the parser... - size_t getOptionWidth() const override {return Parser.getOptionWidth(*this);} + size_t getOptionWidth() const override { + return Parser.getOptionWidth(*this); + } void printOptionInfo(size_t GlobalWidth) const override { Parser.printOptionInfo(*this, GlobalWidth); } // Unimplemented: bits options don't currently store their default values. - void printOptionValue(size_t /*GlobalWidth*/, - bool /*Force*/) const override {} + void printOptionValue(size_t /*GlobalWidth*/, bool /*Force*/) const override { + } void done() { addArgument(); Parser.initialize(*this); } + public: ParserClass &getParser() { return Parser; } @@ -1575,66 +1593,93 @@ public: } // One option... - template<class M0t> - explicit bits(const M0t &M0) : Option(ZeroOrMore, NotHidden) { + template <class M0t> + explicit bits(const M0t &M0) + : Option(ZeroOrMore, NotHidden) { apply(M0, this); done(); } // Two options... - template<class M0t, class M1t> - bits(const M0t &M0, const M1t &M1) : Option(ZeroOrMore, NotHidden) { - apply(M0, this); apply(M1, this); + template <class M0t, class M1t> + bits(const M0t &M0, const M1t &M1) + : Option(ZeroOrMore, NotHidden) { + apply(M0, this); + apply(M1, this); done(); } // Three options... - template<class M0t, class M1t, class M2t> + template <class M0t, class M1t, class M2t> bits(const M0t &M0, const M1t &M1, const M2t &M2) - : Option(ZeroOrMore, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); + : Option(ZeroOrMore, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); done(); } // Four options... - template<class M0t, class M1t, class M2t, class M3t> + template <class M0t, class M1t, class M2t, class M3t> bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) - : Option(ZeroOrMore, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + : Option(ZeroOrMore, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); + apply(M3, this); done(); } // Five options... - template<class M0t, class M1t, class M2t, class M3t, class M4t> + template <class M0t, class M1t, class M2t, class M3t, class M4t> bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4) : Option(ZeroOrMore, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + const M4t &M4) + : Option(ZeroOrMore, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); + apply(M3, this); apply(M4, this); done(); } // Six options... - template<class M0t, class M1t, class M2t, class M3t, - class M4t, class M5t> + template <class M0t, class M1t, class M2t, class M3t, class M4t, class M5t> bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4, const M5t &M5) : Option(ZeroOrMore, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - apply(M4, this); apply(M5, this); + const M4t &M4, const M5t &M5) + : Option(ZeroOrMore, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); + apply(M3, this); + apply(M4, this); + apply(M5, this); done(); } // Seven options... - template<class M0t, class M1t, class M2t, class M3t, - class M4t, class M5t, class M6t> + template <class M0t, class M1t, class M2t, class M3t, class M4t, class M5t, + class M6t> bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, const M4t &M4, const M5t &M5, const M6t &M6) - : Option(ZeroOrMore, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - apply(M4, this); apply(M5, this); apply(M6, this); + : Option(ZeroOrMore, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); + apply(M3, this); + apply(M4, this); + apply(M5, this); + apply(M6, this); done(); } // Eight options... - template<class M0t, class M1t, class M2t, class M3t, - class M4t, class M5t, class M6t, class M7t> + template <class M0t, class M1t, class M2t, class M3t, class M4t, class M5t, + class M6t, class M7t> bits(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3, - const M4t &M4, const M5t &M5, const M6t &M6, - const M7t &M7) : Option(ZeroOrMore, NotHidden) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); - apply(M4, this); apply(M5, this); apply(M6, this); apply(M7, this); + const M4t &M4, const M5t &M5, const M6t &M6, const M7t &M7) + : Option(ZeroOrMore, NotHidden) { + apply(M0, this); + apply(M1, this); + apply(M2, this); + apply(M3, this); + apply(M4, this); + apply(M5, this); + apply(M6, this); + apply(M7, this); done(); } }; @@ -1646,11 +1691,11 @@ public: class alias : public Option { Option *AliasFor; bool handleOccurrence(unsigned pos, StringRef /*ArgName*/, - StringRef Arg) override { + StringRef Arg) override { return AliasFor->handleOccurrence(pos, AliasFor->ArgStr, Arg); } - bool addOccurrence(unsigned pos, StringRef /*ArgName*/, - StringRef Value, bool MultiArg = false) override { + bool addOccurrence(unsigned pos, StringRef /*ArgName*/, StringRef Value, + bool MultiArg = false) override { return AliasFor->addOccurrence(pos, AliasFor->ArgStr, Value, MultiArg); } // Handle printing stuff... @@ -1658,8 +1703,8 @@ class alias : public Option { void printOptionInfo(size_t GlobalWidth) const override; // Aliases do not need to print their values. - void printOptionValue(size_t /*GlobalWidth*/, - bool /*Force*/) const override {} + void printOptionValue(size_t /*GlobalWidth*/, bool /*Force*/) const override { + } ValueExpected getValueExpectedFlagDefault() const override { return AliasFor->getValueExpectedFlag(); @@ -1670,8 +1715,9 @@ class alias : public Option { error("cl::alias must have argument name specified!"); if (!AliasFor) error("cl::alias must have an cl::aliasopt(option) specified!"); - addArgument(); + addArgument(); } + public: void setAliasFor(Option &O) { if (AliasFor) @@ -1680,30 +1726,37 @@ public: } // One option... - template<class M0t> - explicit alias(const M0t &M0) : Option(Optional, Hidden), AliasFor(nullptr) { + template <class M0t> + explicit alias(const M0t &M0) + : Option(Optional, Hidden), AliasFor(nullptr) { apply(M0, this); done(); } // Two options... - template<class M0t, class M1t> + template <class M0t, class M1t> alias(const M0t &M0, const M1t &M1) - : Option(Optional, Hidden), AliasFor(nullptr) { - apply(M0, this); apply(M1, this); + : Option(Optional, Hidden), AliasFor(nullptr) { + apply(M0, this); + apply(M1, this); done(); } // Three options... - template<class M0t, class M1t, class M2t> + template <class M0t, class M1t, class M2t> alias(const M0t &M0, const M1t &M1, const M2t &M2) - : Option(Optional, Hidden), AliasFor(nullptr) { - apply(M0, this); apply(M1, this); apply(M2, this); + : Option(Optional, Hidden), AliasFor(nullptr) { + apply(M0, this); + apply(M1, this); + apply(M2, this); done(); } // Four options... - template<class M0t, class M1t, class M2t, class M3t> + template <class M0t, class M1t, class M2t, class M3t> alias(const M0t &M0, const M1t &M1, const M2t &M2, const M3t &M3) - : Option(Optional, Hidden), AliasFor(nullptr) { - apply(M0, this); apply(M1, this); apply(M2, this); apply(M3, this); + : Option(Optional, Hidden), AliasFor(nullptr) { + apply(M0, this); + apply(M1, this); + apply(M2, this); + apply(M3, this); done(); } }; @@ -1720,8 +1773,8 @@ struct aliasopt { // printed to stderr at the end of the regular help, just before // exit is called. struct extrahelp { - const char * morehelp; - explicit extrahelp(const char* help); + const char *morehelp; + explicit extrahelp(const char *help); }; void PrintVersionMessage(); @@ -1733,8 +1786,7 @@ void PrintVersionMessage(); /// /// \param Hidden if true will print hidden options /// \param Categorized if true print options in categories -void PrintHelpMessage(bool Hidden=false, bool Categorized=false); - +void PrintHelpMessage(bool Hidden = false, bool Categorized = false); //===----------------------------------------------------------------------===// // Public interface for accessing registered options. @@ -1766,7 +1818,7 @@ void PrintHelpMessage(bool Hidden=false, bool Categorized=false); /// This interface is useful for modifying options in libraries that are out of /// the control of the client. The options should be modified before calling /// llvm::cl::ParseCommandLineOptions(). -void getRegisteredOptions(StringMap<Option*> &Map); +void getRegisteredOptions(StringMap<Option *> &Map); //===----------------------------------------------------------------------===// // Standalone command line processing utilities. @@ -1776,9 +1828,10 @@ void getRegisteredOptions(StringMap<Option*> &Map); /// raw character pointer. class StringSaver { virtual void anchor(); + public: virtual const char *SaveString(const char *Str) = 0; - virtual ~StringSaver() {}; // Pacify -Wnon-virtual-dtor. + virtual ~StringSaver(){}; // Pacify -Wnon-virtual-dtor. }; /// \brief Tokenizes a command line that can contain escapes and quotes. @@ -1790,9 +1843,12 @@ public: /// /// \param [in] Source The string to be split on whitespace with quotes. /// \param [in] Saver Delegates back to the caller for saving parsed strings. +/// \param [in] MarkEOLs true if tokenizing a response file and you want end of +/// lines and end of the response file to be marked with a nullptr string. /// \param [out] NewArgv All parsed strings are appended to NewArgv. void TokenizeGNUCommandLine(StringRef Source, StringSaver &Saver, - SmallVectorImpl<const char *> &NewArgv); + SmallVectorImpl<const char *> &NewArgv, + bool MarkEOLs = false); /// \brief Tokenizes a Windows command line which may contain quotes and escaped /// quotes. @@ -1802,25 +1858,36 @@ void TokenizeGNUCommandLine(StringRef Source, StringSaver &Saver, /// /// \param [in] Source The string to be split on whitespace with quotes. /// \param [in] Saver Delegates back to the caller for saving parsed strings. +/// \param [in] MarkEOLs true if tokenizing a response file and you want end of +/// lines and end of the response file to be marked with a nullptr string. /// \param [out] NewArgv All parsed strings are appended to NewArgv. void TokenizeWindowsCommandLine(StringRef Source, StringSaver &Saver, - SmallVectorImpl<const char *> &NewArgv); + SmallVectorImpl<const char *> &NewArgv, + bool MarkEOLs = false); /// \brief String tokenization function type. Should be compatible with either /// Windows or Unix command line tokenizers. typedef void (*TokenizerCallback)(StringRef Source, StringSaver &Saver, - SmallVectorImpl<const char *> &NewArgv); + SmallVectorImpl<const char *> &NewArgv, + bool MarkEOLs); /// \brief Expand response files on a command line recursively using the given /// StringSaver and tokenization strategy. Argv should contain the command line -/// before expansion and will be modified in place. +/// before expansion and will be modified in place. If requested, Argv will +/// also be populated with nullptrs indicating where each response file line +/// ends, which is useful for the "/link" argument that needs to consume all +/// remaining arguments only until the next end of line, when in a response +/// file. /// /// \param [in] Saver Delegates back to the caller for saving parsed strings. /// \param [in] Tokenizer Tokenization strategy. Typically Unix or Windows. /// \param [in,out] Argv Command line into which to expand response files. +/// \param [in] MarkEOLs Mark end of lines and the end of the response file +/// with nullptrs in the Argv vector. /// \return true if all @files were expanded successfully or there were none. bool ExpandResponseFiles(StringSaver &Saver, TokenizerCallback Tokenizer, - SmallVectorImpl<const char *> &Argv); + SmallVectorImpl<const char *> &Argv, + bool MarkEOLs = false); } // End namespace cl diff --git a/contrib/llvm/include/llvm/Support/Compiler.h b/contrib/llvm/include/llvm/Support/Compiler.h index 25bf32ade5f8..d008fec89d64 100644 --- a/contrib/llvm/include/llvm/Support/Compiler.h +++ b/contrib/llvm/include/llvm/Support/Compiler.h @@ -33,14 +33,19 @@ # define __has_builtin(x) 0 #endif -/// \macro __GNUC_PREREQ -/// \brief Defines __GNUC_PREREQ if glibc's features.h isn't available. -#ifndef __GNUC_PREREQ -# if defined(__GNUC__) && defined(__GNUC_MINOR__) -# define __GNUC_PREREQ(maj, min) \ - ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +/// \macro LLVM_GNUC_PREREQ +/// \brief Extend the default __GNUC_PREREQ even if glibc's features.h isn't +/// available. +#ifndef LLVM_GNUC_PREREQ +# if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) +# define LLVM_GNUC_PREREQ(maj, min, patch) \ + ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) + __GNUC_PATCHLEVEL__ >= \ + ((maj) << 20) + ((min) << 10) + (patch)) +# elif defined(__GNUC__) && defined(__GNUC_MINOR__) +# define LLVM_GNUC_PREREQ(maj, min, patch) \ + ((__GNUC__ << 20) + (__GNUC_MINOR__ << 10) >= ((maj) << 20) + ((min) << 10)) # else -# define __GNUC_PREREQ(maj, min) 0 +# define LLVM_GNUC_PREREQ(maj, min, patch) 0 # endif #endif @@ -61,7 +66,7 @@ #define LLVM_MSC_PREREQ(version) 0 #endif -#ifndef _MSC_VER +#if !defined(_MSC_VER) || defined(__clang__) || LLVM_MSC_PREREQ(1900) #define LLVM_NOEXCEPT noexcept #else #define LLVM_NOEXCEPT @@ -70,10 +75,8 @@ /// \brief Does the compiler support r-value reference *this? /// /// Sadly, this is separate from just r-value reference support because GCC -/// implemented everything but this thus far. No release of GCC yet has support -/// for this feature so it is enabled with Clang only. -/// FIXME: This should change to a version check when GCC grows support for it. -#if __has_feature(cxx_rvalue_references) +/// implemented this later than everything else. +#if __has_feature(cxx_rvalue_references) || LLVM_GNUC_PREREQ(4, 8, 1) #define LLVM_HAS_RVALUE_REFERENCE_THIS 1 #else #define LLVM_HAS_RVALUE_REFERENCE_THIS 0 @@ -128,20 +131,26 @@ /// not accessible from outside it. Can also be used to mark variables and /// functions, making them private to any shared library they are linked into. /// On PE/COFF targets, library visibility is the default, so this isn't needed. -#if (__has_attribute(visibility) || __GNUC_PREREQ(4, 0)) && \ +#if (__has_attribute(visibility) || LLVM_GNUC_PREREQ(4, 0, 0)) && \ !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(LLVM_ON_WIN32) #define LLVM_LIBRARY_VISIBILITY __attribute__ ((visibility("hidden"))) #else #define LLVM_LIBRARY_VISIBILITY #endif -#if __has_attribute(used) || __GNUC_PREREQ(3, 1) +#if __has_attribute(sentinel) || LLVM_GNUC_PREREQ(3, 0, 0) +#define LLVM_END_WITH_NULL __attribute__((sentinel)) +#else +#define LLVM_END_WITH_NULL +#endif + +#if __has_attribute(used) || LLVM_GNUC_PREREQ(3, 1, 0) #define LLVM_ATTRIBUTE_USED __attribute__((__used__)) #else #define LLVM_ATTRIBUTE_USED #endif -#if __has_attribute(warn_unused_result) || __GNUC_PREREQ(3, 4) +#if __has_attribute(warn_unused_result) || LLVM_GNUC_PREREQ(3, 4, 0) #define LLVM_ATTRIBUTE_UNUSED_RESULT __attribute__((__warn_unused_result__)) #else #define LLVM_ATTRIBUTE_UNUSED_RESULT @@ -155,14 +164,14 @@ // more portable solution: // (void)unused_var_name; // Prefer cast-to-void wherever it is sufficient. -#if __has_attribute(unused) || __GNUC_PREREQ(3, 1) +#if __has_attribute(unused) || LLVM_GNUC_PREREQ(3, 1, 0) #define LLVM_ATTRIBUTE_UNUSED __attribute__((__unused__)) #else #define LLVM_ATTRIBUTE_UNUSED #endif // FIXME: Provide this for PE/COFF targets. -#if (__has_attribute(weak) || __GNUC_PREREQ(4, 0)) && \ +#if (__has_attribute(weak) || LLVM_GNUC_PREREQ(4, 0, 0)) && \ (!defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(LLVM_ON_WIN32)) #define LLVM_ATTRIBUTE_WEAK __attribute__((__weak__)) #else @@ -185,7 +194,7 @@ #define LLVM_READONLY #endif -#if __has_builtin(__builtin_expect) || __GNUC_PREREQ(4, 0) +#if __has_builtin(__builtin_expect) || LLVM_GNUC_PREREQ(4, 0, 0) #define LLVM_LIKELY(EXPR) __builtin_expect((bool)(EXPR), true) #define LLVM_UNLIKELY(EXPR) __builtin_expect((bool)(EXPR), false) #else @@ -208,7 +217,7 @@ /// LLVM_ATTRIBUTE_NOINLINE - On compilers where we have a directive to do so, /// mark a method "not for inlining". -#if __has_attribute(noinline) || __GNUC_PREREQ(3, 4) +#if __has_attribute(noinline) || LLVM_GNUC_PREREQ(3, 4, 0) #define LLVM_ATTRIBUTE_NOINLINE __attribute__((noinline)) #elif defined(_MSC_VER) #define LLVM_ATTRIBUTE_NOINLINE __declspec(noinline) @@ -220,7 +229,7 @@ /// so, mark a method "always inline" because it is performance sensitive. GCC /// 3.4 supported this but is buggy in various cases and produces unimplemented /// errors, just use it in GCC 4.0 and later. -#if __has_attribute(always_inline) || __GNUC_PREREQ(4, 0) +#if __has_attribute(always_inline) || LLVM_GNUC_PREREQ(4, 0, 0) #define LLVM_ATTRIBUTE_ALWAYS_INLINE inline __attribute__((always_inline)) #elif defined(_MSC_VER) #define LLVM_ATTRIBUTE_ALWAYS_INLINE __forceinline @@ -236,6 +245,12 @@ #define LLVM_ATTRIBUTE_NORETURN #endif +#if __has_attribute(returns_nonnull) || LLVM_GNUC_PREREQ(4, 9, 0) +#define LLVM_ATTRIBUTE_RETURNS_NONNULL __attribute__((returns_nonnull)) +#else +#define LLVM_ATTRIBUTE_RETURNS_NONNULL +#endif + /// LLVM_EXTENSION - Support compilers where we have a keyword to suppress /// pedantic diagnostics. #ifdef __GNUC__ @@ -262,7 +277,7 @@ /// LLVM_BUILTIN_UNREACHABLE - On compilers which support it, expands /// to an expression which states that it is undefined behavior for the /// compiler to reach this point. Otherwise is not defined. -#if __has_builtin(__builtin_unreachable) || __GNUC_PREREQ(4, 5) +#if __has_builtin(__builtin_unreachable) || LLVM_GNUC_PREREQ(4, 5, 0) # define LLVM_BUILTIN_UNREACHABLE __builtin_unreachable() #elif defined(_MSC_VER) # define LLVM_BUILTIN_UNREACHABLE __assume(false) @@ -270,7 +285,7 @@ /// LLVM_BUILTIN_TRAP - On compilers which support it, expands to an expression /// which causes the program to exit abnormally. -#if __has_builtin(__builtin_trap) || __GNUC_PREREQ(4, 3) +#if __has_builtin(__builtin_trap) || LLVM_GNUC_PREREQ(4, 3, 0) # define LLVM_BUILTIN_TRAP __builtin_trap() #else # define LLVM_BUILTIN_TRAP *(volatile int*)0x11 = 0 @@ -278,7 +293,7 @@ /// \macro LLVM_ASSUME_ALIGNED /// \brief Returns a pointer with an assumed alignment. -#if __has_builtin(__builtin_assume_aligned) && __GNUC_PREREQ(4, 7) +#if __has_builtin(__builtin_assume_aligned) || LLVM_GNUC_PREREQ(4, 7, 0) # define LLVM_ASSUME_ALIGNED(p, a) __builtin_assume_aligned(p, a) #elif defined(LLVM_BUILTIN_UNREACHABLE) // As of today, clang does not support __builtin_assume_aligned. diff --git a/contrib/llvm/include/llvm/Support/Compression.h b/contrib/llvm/include/llvm/Support/Compression.h index 8152b60eb098..88727fa3fcfc 100644 --- a/contrib/llvm/include/llvm/Support/Compression.h +++ b/contrib/llvm/include/llvm/Support/Compression.h @@ -14,9 +14,9 @@ #ifndef LLVM_SUPPORT_COMPRESSION_H #define LLVM_SUPPORT_COMPRESSION_H +#include "llvm/ADT/SmallVector.h" #include "llvm/Support/DataTypes.h" #include <memory> -#include "llvm/ADT/SmallVector.h" namespace llvm { diff --git a/contrib/llvm/include/llvm/Support/CrashRecoveryContext.h b/contrib/llvm/include/llvm/Support/CrashRecoveryContext.h index 3869ebdc4a93..1f3965c8ade4 100644 --- a/contrib/llvm/include/llvm/Support/CrashRecoveryContext.h +++ b/contrib/llvm/include/llvm/Support/CrashRecoveryContext.h @@ -10,9 +10,8 @@ #ifndef LLVM_SUPPORT_CRASHRECOVERYCONTEXT_H #define LLVM_SUPPORT_CRASHRECOVERYCONTEXT_H -#include <string> - #include "llvm/ADT/STLExtras.h" +#include <string> namespace llvm { class StringRef; @@ -166,9 +165,7 @@ public: : CrashRecoveryContextCleanupBase< CrashRecoveryContextDeleteCleanup<T>, T>(context, resource) {} - virtual void recoverResources() { - delete this->resource; - } + void recoverResources() override { delete this->resource; } }; template <typename T> @@ -181,9 +178,7 @@ public: : CrashRecoveryContextCleanupBase<CrashRecoveryContextReleaseRefCleanup<T>, T>(context, resource) {} - virtual void recoverResources() { - this->resource->Release(); - } + void recoverResources() override { this->resource->Release(); } }; template <typename T, typename Cleanup = CrashRecoveryContextDeleteCleanup<T> > diff --git a/contrib/llvm/include/llvm/Support/DataExtractor.h b/contrib/llvm/include/llvm/Support/DataExtractor.h index e8a19cd773b5..48235d4145bd 100644 --- a/contrib/llvm/include/llvm/Support/DataExtractor.h +++ b/contrib/llvm/include/llvm/Support/DataExtractor.h @@ -348,6 +348,17 @@ public: bool isValidOffsetForDataOfSize(uint32_t offset, uint32_t length) const { return offset + length >= offset && isValidOffset(offset + length - 1); } + + /// Test the availability of enough bytes of data for a pointer from + /// \a offset. The size of a pointer is \a getAddressSize(). + /// + /// @return + /// \b true if \a offset is a valid offset and there are enough + /// bytes for a pointer available at that offset, \b false + /// otherwise. + bool isValidOffsetForAddress(uint32_t offset) const { + return isValidOffsetForDataOfSize(offset, AddressSize); + } }; } // namespace llvm diff --git a/contrib/llvm/include/llvm/Support/DataTypes.h.in b/contrib/llvm/include/llvm/Support/DataTypes.h.in index 09cfcdf3b56b..b8b2ba56ff30 100644 --- a/contrib/llvm/include/llvm/Support/DataTypes.h.in +++ b/contrib/llvm/include/llvm/Support/DataTypes.h.in @@ -116,12 +116,6 @@ typedef signed int ssize_t; # define UINT64_MAX 0xffffffffffffffffULL #endif -#if __GNUC__ > 3 -#define END_WITH_NULL __attribute__((sentinel)) -#else -#define END_WITH_NULL -#endif - #ifndef HUGE_VALF #define HUGE_VALF (float)HUGE_VAL #endif diff --git a/contrib/llvm/include/llvm/Support/Dwarf.h b/contrib/llvm/include/llvm/Support/Dwarf.h index cd9f75600cbc..47b00b1f09d8 100644 --- a/contrib/llvm/include/llvm/Support/Dwarf.h +++ b/contrib/llvm/include/llvm/Support/Dwarf.h @@ -7,9 +7,13 @@ // //===----------------------------------------------------------------------===// // -// This file contains constants used for implementing Dwarf debug support. For -// Details on the Dwarf 3 specfication see DWARF Debugging Information Format -// V.3 reference manual http://dwarf.freestandards.org , +// \file +// \brief This file contains constants used for implementing Dwarf +// debug support. +// +// For details on the Dwarf specfication see the latest DWARF Debugging +// Information Format standard document on http://www.dwarfstd.org. This +// file often includes support for non-released standard features. // //===----------------------------------------------------------------------===// @@ -21,22 +25,6 @@ namespace llvm { -//===----------------------------------------------------------------------===// -// Debug info constants. - -enum : uint32_t { - LLVMDebugVersion = (12 << 16), // Current version of debug information. - LLVMDebugVersion11 = (11 << 16), // Constant for version 11. - LLVMDebugVersion10 = (10 << 16), // Constant for version 10. - LLVMDebugVersion9 = (9 << 16), // Constant for version 9. - LLVMDebugVersion8 = (8 << 16), // Constant for version 8. - LLVMDebugVersion7 = (7 << 16), // Constant for version 7. - LLVMDebugVersion6 = (6 << 16), // Constant for version 6. - LLVMDebugVersion5 = (5 << 16), // Constant for version 5. - LLVMDebugVersion4 = (4 << 16), // Constant for version 4. - LLVMDebugVersionMask = 0xffff0000 // Mask for version number. -}; - namespace dwarf { //===----------------------------------------------------------------------===// @@ -53,6 +41,7 @@ enum LLVMConstants : uint32_t { DW_TAG_auto_variable = 0x100, // Tag for local (auto) variables. DW_TAG_arg_variable = 0x101, // Tag for argument variables. + DW_TAG_expression = 0x102, // Tag for complex address expressions. DW_TAG_user_base = 0x1000, // Recommended base for user tags. @@ -779,100 +768,24 @@ enum LocationListEntry : unsigned char { DW_LLE_offset_pair_entry }; +/// Contstants for the DW_APPLE_PROPERTY_attributes attribute. +/// Keep this list in sync with clang's DeclSpec.h ObjCPropertyAttributeKind. enum ApplePropertyAttributes { // Apple Objective-C Property Attributes DW_APPLE_PROPERTY_readonly = 0x01, - DW_APPLE_PROPERTY_readwrite = 0x02, + DW_APPLE_PROPERTY_getter = 0x02, DW_APPLE_PROPERTY_assign = 0x04, - DW_APPLE_PROPERTY_retain = 0x08, - DW_APPLE_PROPERTY_copy = 0x10, - DW_APPLE_PROPERTY_nonatomic = 0x20 + DW_APPLE_PROPERTY_readwrite = 0x08, + DW_APPLE_PROPERTY_retain = 0x10, + DW_APPLE_PROPERTY_copy = 0x20, + DW_APPLE_PROPERTY_nonatomic = 0x40, + DW_APPLE_PROPERTY_setter = 0x80, + DW_APPLE_PROPERTY_atomic = 0x100, + DW_APPLE_PROPERTY_weak = 0x200, + DW_APPLE_PROPERTY_strong = 0x400, + DW_APPLE_PROPERTY_unsafe_unretained = 0x800 }; -/// TagString - Return the string for the specified tag. -/// -const char *TagString(unsigned Tag); - -/// ChildrenString - Return the string for the specified children flag. -/// -const char *ChildrenString(unsigned Children); - -/// AttributeString - Return the string for the specified attribute. -/// -const char *AttributeString(unsigned Attribute); - -/// FormEncodingString - Return the string for the specified form encoding. -/// -const char *FormEncodingString(unsigned Encoding); - -/// OperationEncodingString - Return the string for the specified operation -/// encoding. -const char *OperationEncodingString(unsigned Encoding); - -/// AttributeEncodingString - Return the string for the specified attribute -/// encoding. -const char *AttributeEncodingString(unsigned Encoding); - -/// DecimalSignString - Return the string for the specified decimal sign -/// attribute. -const char *DecimalSignString(unsigned Sign); - -/// EndianityString - Return the string for the specified endianity. -/// -const char *EndianityString(unsigned Endian); - -/// AccessibilityString - Return the string for the specified accessibility. -/// -const char *AccessibilityString(unsigned Access); - -/// VisibilityString - Return the string for the specified visibility. -/// -const char *VisibilityString(unsigned Visibility); - -/// VirtualityString - Return the string for the specified virtuality. -/// -const char *VirtualityString(unsigned Virtuality); - -/// LanguageString - Return the string for the specified language. -/// -const char *LanguageString(unsigned Language); - -/// CaseString - Return the string for the specified identifier case. -/// -const char *CaseString(unsigned Case); - -/// ConventionString - Return the string for the specified calling convention. -/// -const char *ConventionString(unsigned Convention); - -/// InlineCodeString - Return the string for the specified inline code. -/// -const char *InlineCodeString(unsigned Code); - -/// ArrayOrderString - Return the string for the specified array order. -/// -const char *ArrayOrderString(unsigned Order); - -/// DiscriminantString - Return the string for the specified discriminant -/// descriptor. -const char *DiscriminantString(unsigned Discriminant); - -/// LNStandardString - Return the string for the specified line number standard. -/// -const char *LNStandardString(unsigned Standard); - -/// LNExtendedString - Return the string for the specified line number extended -/// opcode encodings. -const char *LNExtendedString(unsigned Encoding); - -/// MacinfoString - Return the string for the specified macinfo type encodings. -/// -const char *MacinfoString(unsigned Encoding); - -/// CallFrameString - Return the string for the specified call frame instruction -/// encodings. -const char *CallFrameString(unsigned Encoding); - // Constants for the DWARF5 Accelerator Table Proposal enum AcceleratorTable { // Data layout descriptors. @@ -895,9 +808,6 @@ enum AcceleratorTable { DW_hash_function_djb = 0u }; -/// AtomTypeString - Return the string for the specified Atom type. -const char *AtomTypeString(unsigned Atom); - // Constants for the GNU pubnames/pubtypes extensions supporting gdb index. enum GDBIndexEntryKind { GIEK_NONE, @@ -910,15 +820,51 @@ enum GDBIndexEntryKind { GIEK_UNUSED7 }; -const char *GDBIndexEntryKindString(GDBIndexEntryKind Kind); - enum GDBIndexEntryLinkage { GIEL_EXTERNAL, GIEL_STATIC }; +/// \defgroup DwarfConstantsDumping Dwarf constants dumping functions +/// +/// All these functions map their argument's value back to the +/// corresponding enumerator name or return nullptr if the value isn't +/// known. +/// +/// @{ +const char *TagString(unsigned Tag); +const char *ChildrenString(unsigned Children); +const char *AttributeString(unsigned Attribute); +const char *FormEncodingString(unsigned Encoding); +const char *OperationEncodingString(unsigned Encoding); +const char *AttributeEncodingString(unsigned Encoding); +const char *DecimalSignString(unsigned Sign); +const char *EndianityString(unsigned Endian); +const char *AccessibilityString(unsigned Access); +const char *VisibilityString(unsigned Visibility); +const char *VirtualityString(unsigned Virtuality); +const char *LanguageString(unsigned Language); +const char *CaseString(unsigned Case); +const char *ConventionString(unsigned Convention); +const char *InlineCodeString(unsigned Code); +const char *ArrayOrderString(unsigned Order); +const char *DiscriminantString(unsigned Discriminant); +const char *LNStandardString(unsigned Standard); +const char *LNExtendedString(unsigned Encoding); +const char *MacinfoString(unsigned Encoding); +const char *CallFrameString(unsigned Encoding); +const char *ApplePropertyString(unsigned); +const char *AtomTypeString(unsigned Atom); +const char *GDBIndexEntryKindString(GDBIndexEntryKind Kind); const char *GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage); +/// @} +/// \brief Returns the symbolic string representing Val when used as a value +/// for attribute Attr. +const char *AttributeValueString(uint16_t Attr, unsigned Val); + +/// \brief Decsribes an entry of the various gnu_pub* debug sections. +/// /// The gnu_pub* kind looks like: /// /// 0-3 reserved @@ -950,6 +896,7 @@ private: }; }; + } // End of namespace dwarf } // End of namespace llvm diff --git a/contrib/llvm/include/llvm/Support/DynamicLibrary.h b/contrib/llvm/include/llvm/Support/DynamicLibrary.h index 2bb31a7be04a..a7d22212dbdb 100644 --- a/contrib/llvm/include/llvm/Support/DynamicLibrary.h +++ b/contrib/llvm/include/llvm/Support/DynamicLibrary.h @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_SYSTEM_DYNAMICLIBRARY_H -#define LLVM_SYSTEM_DYNAMICLIBRARY_H +#ifndef LLVM_SUPPORT_DYNAMICLIBRARY_H +#define LLVM_SUPPORT_DYNAMICLIBRARY_H #include <string> @@ -102,4 +102,4 @@ namespace sys { } // End sys namespace } // End llvm namespace -#endif // LLVM_SYSTEM_DYNAMIC_LIBRARY_H +#endif diff --git a/contrib/llvm/include/llvm/Support/ELF.h b/contrib/llvm/include/llvm/Support/ELF.h index ddc7ff8c4737..3d49205fa168 100644 --- a/contrib/llvm/include/llvm/Support/ELF.h +++ b/contrib/llvm/include/llvm/Support/ELF.h @@ -350,152 +350,21 @@ enum { ELFOSABI_STANDALONE = 255 // Standalone (embedded) application }; +#define ELF_RELOC(name, value) name = value, + // X86_64 relocations. enum { - R_X86_64_NONE = 0, - R_X86_64_64 = 1, - R_X86_64_PC32 = 2, - R_X86_64_GOT32 = 3, - R_X86_64_PLT32 = 4, - R_X86_64_COPY = 5, - R_X86_64_GLOB_DAT = 6, - R_X86_64_JUMP_SLOT = 7, - R_X86_64_RELATIVE = 8, - R_X86_64_GOTPCREL = 9, - R_X86_64_32 = 10, - R_X86_64_32S = 11, - R_X86_64_16 = 12, - R_X86_64_PC16 = 13, - R_X86_64_8 = 14, - R_X86_64_PC8 = 15, - R_X86_64_DTPMOD64 = 16, - R_X86_64_DTPOFF64 = 17, - R_X86_64_TPOFF64 = 18, - R_X86_64_TLSGD = 19, - R_X86_64_TLSLD = 20, - R_X86_64_DTPOFF32 = 21, - R_X86_64_GOTTPOFF = 22, - R_X86_64_TPOFF32 = 23, - R_X86_64_PC64 = 24, - R_X86_64_GOTOFF64 = 25, - R_X86_64_GOTPC32 = 26, - R_X86_64_GOT64 = 27, - R_X86_64_GOTPCREL64 = 28, - R_X86_64_GOTPC64 = 29, - R_X86_64_GOTPLT64 = 30, - R_X86_64_PLTOFF64 = 31, - R_X86_64_SIZE32 = 32, - R_X86_64_SIZE64 = 33, - R_X86_64_GOTPC32_TLSDESC = 34, - R_X86_64_TLSDESC_CALL = 35, - R_X86_64_TLSDESC = 36, - R_X86_64_IRELATIVE = 37 +#include "ELFRelocs/x86_64.def" }; // i386 relocations. -// TODO: this is just a subset enum { - R_386_NONE = 0, - R_386_32 = 1, - R_386_PC32 = 2, - R_386_GOT32 = 3, - R_386_PLT32 = 4, - R_386_COPY = 5, - R_386_GLOB_DAT = 6, - R_386_JUMP_SLOT = 7, - R_386_RELATIVE = 8, - R_386_GOTOFF = 9, - R_386_GOTPC = 10, - R_386_32PLT = 11, - R_386_TLS_TPOFF = 14, - R_386_TLS_IE = 15, - R_386_TLS_GOTIE = 16, - R_386_TLS_LE = 17, - R_386_TLS_GD = 18, - R_386_TLS_LDM = 19, - R_386_16 = 20, - R_386_PC16 = 21, - R_386_8 = 22, - R_386_PC8 = 23, - R_386_TLS_GD_32 = 24, - R_386_TLS_GD_PUSH = 25, - R_386_TLS_GD_CALL = 26, - R_386_TLS_GD_POP = 27, - R_386_TLS_LDM_32 = 28, - R_386_TLS_LDM_PUSH = 29, - R_386_TLS_LDM_CALL = 30, - R_386_TLS_LDM_POP = 31, - R_386_TLS_LDO_32 = 32, - R_386_TLS_IE_32 = 33, - R_386_TLS_LE_32 = 34, - R_386_TLS_DTPMOD32 = 35, - R_386_TLS_DTPOFF32 = 36, - R_386_TLS_TPOFF32 = 37, - R_386_TLS_GOTDESC = 39, - R_386_TLS_DESC_CALL = 40, - R_386_TLS_DESC = 41, - R_386_IRELATIVE = 42, - R_386_NUM = 43 +#include "ELFRelocs/i386.def" }; // ELF Relocation types for PPC32 enum { - R_PPC_NONE = 0, /* No relocation. */ - R_PPC_ADDR32 = 1, - R_PPC_ADDR24 = 2, - R_PPC_ADDR16 = 3, - R_PPC_ADDR16_LO = 4, - R_PPC_ADDR16_HI = 5, - R_PPC_ADDR16_HA = 6, - R_PPC_ADDR14 = 7, - R_PPC_ADDR14_BRTAKEN = 8, - R_PPC_ADDR14_BRNTAKEN = 9, - R_PPC_REL24 = 10, - R_PPC_REL14 = 11, - R_PPC_REL14_BRTAKEN = 12, - R_PPC_REL14_BRNTAKEN = 13, - R_PPC_GOT16 = 14, - R_PPC_GOT16_LO = 15, - R_PPC_GOT16_HI = 16, - R_PPC_GOT16_HA = 17, - R_PPC_PLTREL24 = 18, - R_PPC_JMP_SLOT = 21, - R_PPC_LOCAL24PC = 23, - R_PPC_REL32 = 26, - R_PPC_TLS = 67, - R_PPC_DTPMOD32 = 68, - R_PPC_TPREL16 = 69, - R_PPC_TPREL16_LO = 70, - R_PPC_TPREL16_HI = 71, - R_PPC_TPREL16_HA = 72, - R_PPC_TPREL32 = 73, - R_PPC_DTPREL16 = 74, - R_PPC_DTPREL16_LO = 75, - R_PPC_DTPREL16_HI = 76, - R_PPC_DTPREL16_HA = 77, - R_PPC_DTPREL32 = 78, - R_PPC_GOT_TLSGD16 = 79, - R_PPC_GOT_TLSGD16_LO = 80, - R_PPC_GOT_TLSGD16_HI = 81, - R_PPC_GOT_TLSGD16_HA = 82, - R_PPC_GOT_TLSLD16 = 83, - R_PPC_GOT_TLSLD16_LO = 84, - R_PPC_GOT_TLSLD16_HI = 85, - R_PPC_GOT_TLSLD16_HA = 86, - R_PPC_GOT_TPREL16 = 87, - R_PPC_GOT_TPREL16_LO = 88, - R_PPC_GOT_TPREL16_HI = 89, - R_PPC_GOT_TPREL16_HA = 90, - R_PPC_GOT_DTPREL16 = 91, - R_PPC_GOT_DTPREL16_LO = 92, - R_PPC_GOT_DTPREL16_HI = 93, - R_PPC_GOT_DTPREL16_HA = 94, - R_PPC_TLSGD = 95, - R_PPC_TLSLD = 96, - R_PPC_REL16 = 249, - R_PPC_REL16_LO = 250, - R_PPC_REL16_HI = 251, - R_PPC_REL16_HA = 252 +#include "ELFRelocs/PowerPC.def" }; // Specific e_flags for PPC64 @@ -531,192 +400,12 @@ encodePPC64LocalEntryOffset(int64_t Offset) { // ELF Relocation types for PPC64 enum { - R_PPC64_NONE = 0, - R_PPC64_ADDR32 = 1, - R_PPC64_ADDR24 = 2, - R_PPC64_ADDR16 = 3, - R_PPC64_ADDR16_LO = 4, - R_PPC64_ADDR16_HI = 5, - R_PPC64_ADDR16_HA = 6, - R_PPC64_ADDR14 = 7, - R_PPC64_ADDR14_BRTAKEN = 8, - R_PPC64_ADDR14_BRNTAKEN = 9, - R_PPC64_REL24 = 10, - R_PPC64_REL14 = 11, - R_PPC64_REL14_BRTAKEN = 12, - R_PPC64_REL14_BRNTAKEN = 13, - R_PPC64_GOT16 = 14, - R_PPC64_GOT16_LO = 15, - R_PPC64_GOT16_HI = 16, - R_PPC64_GOT16_HA = 17, - R_PPC64_JMP_SLOT = 21, - R_PPC64_REL32 = 26, - R_PPC64_ADDR64 = 38, - R_PPC64_ADDR16_HIGHER = 39, - R_PPC64_ADDR16_HIGHERA = 40, - R_PPC64_ADDR16_HIGHEST = 41, - R_PPC64_ADDR16_HIGHESTA = 42, - R_PPC64_REL64 = 44, - R_PPC64_TOC16 = 47, - R_PPC64_TOC16_LO = 48, - R_PPC64_TOC16_HI = 49, - R_PPC64_TOC16_HA = 50, - R_PPC64_TOC = 51, - R_PPC64_ADDR16_DS = 56, - R_PPC64_ADDR16_LO_DS = 57, - R_PPC64_GOT16_DS = 58, - R_PPC64_GOT16_LO_DS = 59, - R_PPC64_TOC16_DS = 63, - R_PPC64_TOC16_LO_DS = 64, - R_PPC64_TLS = 67, - R_PPC64_DTPMOD64 = 68, - R_PPC64_TPREL16 = 69, - R_PPC64_TPREL16_LO = 70, - R_PPC64_TPREL16_HI = 71, - R_PPC64_TPREL16_HA = 72, - R_PPC64_TPREL64 = 73, - R_PPC64_DTPREL16 = 74, - R_PPC64_DTPREL16_LO = 75, - R_PPC64_DTPREL16_HI = 76, - R_PPC64_DTPREL16_HA = 77, - R_PPC64_DTPREL64 = 78, - R_PPC64_GOT_TLSGD16 = 79, - R_PPC64_GOT_TLSGD16_LO = 80, - R_PPC64_GOT_TLSGD16_HI = 81, - R_PPC64_GOT_TLSGD16_HA = 82, - R_PPC64_GOT_TLSLD16 = 83, - R_PPC64_GOT_TLSLD16_LO = 84, - R_PPC64_GOT_TLSLD16_HI = 85, - R_PPC64_GOT_TLSLD16_HA = 86, - R_PPC64_GOT_TPREL16_DS = 87, - R_PPC64_GOT_TPREL16_LO_DS = 88, - R_PPC64_GOT_TPREL16_HI = 89, - R_PPC64_GOT_TPREL16_HA = 90, - R_PPC64_GOT_DTPREL16_DS = 91, - R_PPC64_GOT_DTPREL16_LO_DS = 92, - R_PPC64_GOT_DTPREL16_HI = 93, - R_PPC64_GOT_DTPREL16_HA = 94, - R_PPC64_TPREL16_DS = 95, - R_PPC64_TPREL16_LO_DS = 96, - R_PPC64_TPREL16_HIGHER = 97, - R_PPC64_TPREL16_HIGHERA = 98, - R_PPC64_TPREL16_HIGHEST = 99, - R_PPC64_TPREL16_HIGHESTA = 100, - R_PPC64_DTPREL16_DS = 101, - R_PPC64_DTPREL16_LO_DS = 102, - R_PPC64_DTPREL16_HIGHER = 103, - R_PPC64_DTPREL16_HIGHERA = 104, - R_PPC64_DTPREL16_HIGHEST = 105, - R_PPC64_DTPREL16_HIGHESTA = 106, - R_PPC64_TLSGD = 107, - R_PPC64_TLSLD = 108, - R_PPC64_REL16 = 249, - R_PPC64_REL16_LO = 250, - R_PPC64_REL16_HI = 251, - R_PPC64_REL16_HA = 252 +#include "ELFRelocs/PowerPC64.def" }; // ELF Relocation types for AArch64 - enum { - R_AARCH64_NONE = 0x100, - - R_AARCH64_ABS64 = 0x101, - R_AARCH64_ABS32 = 0x102, - R_AARCH64_ABS16 = 0x103, - R_AARCH64_PREL64 = 0x104, - R_AARCH64_PREL32 = 0x105, - R_AARCH64_PREL16 = 0x106, - - R_AARCH64_MOVW_UABS_G0 = 0x107, - R_AARCH64_MOVW_UABS_G0_NC = 0x108, - R_AARCH64_MOVW_UABS_G1 = 0x109, - R_AARCH64_MOVW_UABS_G1_NC = 0x10a, - R_AARCH64_MOVW_UABS_G2 = 0x10b, - R_AARCH64_MOVW_UABS_G2_NC = 0x10c, - R_AARCH64_MOVW_UABS_G3 = 0x10d, - R_AARCH64_MOVW_SABS_G0 = 0x10e, - R_AARCH64_MOVW_SABS_G1 = 0x10f, - R_AARCH64_MOVW_SABS_G2 = 0x110, - - R_AARCH64_LD_PREL_LO19 = 0x111, - R_AARCH64_ADR_PREL_LO21 = 0x112, - R_AARCH64_ADR_PREL_PG_HI21 = 0x113, - R_AARCH64_ADD_ABS_LO12_NC = 0x115, - R_AARCH64_LDST8_ABS_LO12_NC = 0x116, - - R_AARCH64_TSTBR14 = 0x117, - R_AARCH64_CONDBR19 = 0x118, - R_AARCH64_JUMP26 = 0x11a, - R_AARCH64_CALL26 = 0x11b, - - R_AARCH64_LDST16_ABS_LO12_NC = 0x11c, - R_AARCH64_LDST32_ABS_LO12_NC = 0x11d, - R_AARCH64_LDST64_ABS_LO12_NC = 0x11e, - - R_AARCH64_LDST128_ABS_LO12_NC = 0x12b, - - R_AARCH64_GOTREL64 = 0x133, - R_AARCH64_GOTREL32 = 0x134, - - R_AARCH64_ADR_GOT_PAGE = 0x137, - R_AARCH64_LD64_GOT_LO12_NC = 0x138, - - R_AARCH64_TLSLD_MOVW_DTPREL_G2 = 0x20b, - R_AARCH64_TLSLD_MOVW_DTPREL_G1 = 0x20c, - R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC = 0x20d, - R_AARCH64_TLSLD_MOVW_DTPREL_G0 = 0x20e, - R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC = 0x20f, - R_AARCH64_TLSLD_ADD_DTPREL_HI12 = 0x210, - R_AARCH64_TLSLD_ADD_DTPREL_LO12 = 0x211, - R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC = 0x212, - R_AARCH64_TLSLD_LDST8_DTPREL_LO12 = 0x213, - R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC = 0x214, - R_AARCH64_TLSLD_LDST16_DTPREL_LO12 = 0x215, - R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC = 0x216, - R_AARCH64_TLSLD_LDST32_DTPREL_LO12 = 0x217, - R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC = 0x218, - R_AARCH64_TLSLD_LDST64_DTPREL_LO12 = 0x219, - R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC = 0x21a, - - R_AARCH64_TLSIE_MOVW_GOTTPREL_G1 = 0x21b, - R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC = 0x21c, - R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21 = 0x21d, - R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC = 0x21e, - R_AARCH64_TLSIE_LD_GOTTPREL_PREL19 = 0x21f, - - R_AARCH64_TLSLE_MOVW_TPREL_G2 = 0x220, - R_AARCH64_TLSLE_MOVW_TPREL_G1 = 0x221, - R_AARCH64_TLSLE_MOVW_TPREL_G1_NC = 0x222, - R_AARCH64_TLSLE_MOVW_TPREL_G0 = 0x223, - R_AARCH64_TLSLE_MOVW_TPREL_G0_NC = 0x224, - R_AARCH64_TLSLE_ADD_TPREL_HI12 = 0x225, - R_AARCH64_TLSLE_ADD_TPREL_LO12 = 0x226, - R_AARCH64_TLSLE_ADD_TPREL_LO12_NC = 0x227, - R_AARCH64_TLSLE_LDST8_TPREL_LO12 = 0x228, - R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC = 0x229, - R_AARCH64_TLSLE_LDST16_TPREL_LO12 = 0x22a, - R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC = 0x22b, - R_AARCH64_TLSLE_LDST32_TPREL_LO12 = 0x22c, - R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC = 0x22d, - R_AARCH64_TLSLE_LDST64_TPREL_LO12 = 0x22e, - R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC = 0x22f, - - R_AARCH64_TLSDESC_ADR_PAGE = 0x232, - R_AARCH64_TLSDESC_LD64_LO12_NC = 0x233, - R_AARCH64_TLSDESC_ADD_LO12_NC = 0x234, - - R_AARCH64_TLSDESC_CALL = 0x239, - - R_AARCH64_COPY = 0x400, - R_AARCH64_GLOB_DAT = 0x401, - R_AARCH64_JUMP_SLOT = 0x402, - R_AARCH64_RELATIVE = 0x403, - R_AARCH64_TLS_DTPREL64 = 0x404, - R_AARCH64_TLS_DTPMOD64 = 0x405, - R_AARCH64_TLS_TPREL64 = 0x406, - R_AARCH64_TLSDESC = 0x407, - R_AARCH64_IRELATIVE = 0x408 +#include "ELFRelocs/AArch64.def" }; // ARM Specific e_flags @@ -733,140 +422,8 @@ enum : unsigned { }; // ELF Relocation types for ARM -// Meets 2.08 ABI Specs. - enum { - R_ARM_NONE = 0x00, - R_ARM_PC24 = 0x01, - R_ARM_ABS32 = 0x02, - R_ARM_REL32 = 0x03, - R_ARM_LDR_PC_G0 = 0x04, - R_ARM_ABS16 = 0x05, - R_ARM_ABS12 = 0x06, - R_ARM_THM_ABS5 = 0x07, - R_ARM_ABS8 = 0x08, - R_ARM_SBREL32 = 0x09, - R_ARM_THM_CALL = 0x0a, - R_ARM_THM_PC8 = 0x0b, - R_ARM_BREL_ADJ = 0x0c, - R_ARM_TLS_DESC = 0x0d, - R_ARM_THM_SWI8 = 0x0e, - R_ARM_XPC25 = 0x0f, - R_ARM_THM_XPC22 = 0x10, - R_ARM_TLS_DTPMOD32 = 0x11, - R_ARM_TLS_DTPOFF32 = 0x12, - R_ARM_TLS_TPOFF32 = 0x13, - R_ARM_COPY = 0x14, - R_ARM_GLOB_DAT = 0x15, - R_ARM_JUMP_SLOT = 0x16, - R_ARM_RELATIVE = 0x17, - R_ARM_GOTOFF32 = 0x18, - R_ARM_BASE_PREL = 0x19, - R_ARM_GOT_BREL = 0x1a, - R_ARM_PLT32 = 0x1b, - R_ARM_CALL = 0x1c, - R_ARM_JUMP24 = 0x1d, - R_ARM_THM_JUMP24 = 0x1e, - R_ARM_BASE_ABS = 0x1f, - R_ARM_ALU_PCREL_7_0 = 0x20, - R_ARM_ALU_PCREL_15_8 = 0x21, - R_ARM_ALU_PCREL_23_15 = 0x22, - R_ARM_LDR_SBREL_11_0_NC = 0x23, - R_ARM_ALU_SBREL_19_12_NC = 0x24, - R_ARM_ALU_SBREL_27_20_CK = 0x25, - R_ARM_TARGET1 = 0x26, - R_ARM_SBREL31 = 0x27, - R_ARM_V4BX = 0x28, - R_ARM_TARGET2 = 0x29, - R_ARM_PREL31 = 0x2a, - R_ARM_MOVW_ABS_NC = 0x2b, - R_ARM_MOVT_ABS = 0x2c, - R_ARM_MOVW_PREL_NC = 0x2d, - R_ARM_MOVT_PREL = 0x2e, - R_ARM_THM_MOVW_ABS_NC = 0x2f, - R_ARM_THM_MOVT_ABS = 0x30, - R_ARM_THM_MOVW_PREL_NC = 0x31, - R_ARM_THM_MOVT_PREL = 0x32, - R_ARM_THM_JUMP19 = 0x33, - R_ARM_THM_JUMP6 = 0x34, - R_ARM_THM_ALU_PREL_11_0 = 0x35, - R_ARM_THM_PC12 = 0x36, - R_ARM_ABS32_NOI = 0x37, - R_ARM_REL32_NOI = 0x38, - R_ARM_ALU_PC_G0_NC = 0x39, - R_ARM_ALU_PC_G0 = 0x3a, - R_ARM_ALU_PC_G1_NC = 0x3b, - R_ARM_ALU_PC_G1 = 0x3c, - R_ARM_ALU_PC_G2 = 0x3d, - R_ARM_LDR_PC_G1 = 0x3e, - R_ARM_LDR_PC_G2 = 0x3f, - R_ARM_LDRS_PC_G0 = 0x40, - R_ARM_LDRS_PC_G1 = 0x41, - R_ARM_LDRS_PC_G2 = 0x42, - R_ARM_LDC_PC_G0 = 0x43, - R_ARM_LDC_PC_G1 = 0x44, - R_ARM_LDC_PC_G2 = 0x45, - R_ARM_ALU_SB_G0_NC = 0x46, - R_ARM_ALU_SB_G0 = 0x47, - R_ARM_ALU_SB_G1_NC = 0x48, - R_ARM_ALU_SB_G1 = 0x49, - R_ARM_ALU_SB_G2 = 0x4a, - R_ARM_LDR_SB_G0 = 0x4b, - R_ARM_LDR_SB_G1 = 0x4c, - R_ARM_LDR_SB_G2 = 0x4d, - R_ARM_LDRS_SB_G0 = 0x4e, - R_ARM_LDRS_SB_G1 = 0x4f, - R_ARM_LDRS_SB_G2 = 0x50, - R_ARM_LDC_SB_G0 = 0x51, - R_ARM_LDC_SB_G1 = 0x52, - R_ARM_LDC_SB_G2 = 0x53, - R_ARM_MOVW_BREL_NC = 0x54, - R_ARM_MOVT_BREL = 0x55, - R_ARM_MOVW_BREL = 0x56, - R_ARM_THM_MOVW_BREL_NC = 0x57, - R_ARM_THM_MOVT_BREL = 0x58, - R_ARM_THM_MOVW_BREL = 0x59, - R_ARM_TLS_GOTDESC = 0x5a, - R_ARM_TLS_CALL = 0x5b, - R_ARM_TLS_DESCSEQ = 0x5c, - R_ARM_THM_TLS_CALL = 0x5d, - R_ARM_PLT32_ABS = 0x5e, - R_ARM_GOT_ABS = 0x5f, - R_ARM_GOT_PREL = 0x60, - R_ARM_GOT_BREL12 = 0x61, - R_ARM_GOTOFF12 = 0x62, - R_ARM_GOTRELAX = 0x63, - R_ARM_GNU_VTENTRY = 0x64, - R_ARM_GNU_VTINHERIT = 0x65, - R_ARM_THM_JUMP11 = 0x66, - R_ARM_THM_JUMP8 = 0x67, - R_ARM_TLS_GD32 = 0x68, - R_ARM_TLS_LDM32 = 0x69, - R_ARM_TLS_LDO32 = 0x6a, - R_ARM_TLS_IE32 = 0x6b, - R_ARM_TLS_LE32 = 0x6c, - R_ARM_TLS_LDO12 = 0x6d, - R_ARM_TLS_LE12 = 0x6e, - R_ARM_TLS_IE12GP = 0x6f, - R_ARM_PRIVATE_0 = 0x70, - R_ARM_PRIVATE_1 = 0x71, - R_ARM_PRIVATE_2 = 0x72, - R_ARM_PRIVATE_3 = 0x73, - R_ARM_PRIVATE_4 = 0x74, - R_ARM_PRIVATE_5 = 0x75, - R_ARM_PRIVATE_6 = 0x76, - R_ARM_PRIVATE_7 = 0x77, - R_ARM_PRIVATE_8 = 0x78, - R_ARM_PRIVATE_9 = 0x79, - R_ARM_PRIVATE_10 = 0x7a, - R_ARM_PRIVATE_11 = 0x7b, - R_ARM_PRIVATE_12 = 0x7c, - R_ARM_PRIVATE_13 = 0x7d, - R_ARM_PRIVATE_14 = 0x7e, - R_ARM_PRIVATE_15 = 0x7f, - R_ARM_ME_TOO = 0x80, - R_ARM_THM_TLS_DESCSEQ16 = 0x81, - R_ARM_THM_TLS_DESCSEQ32 = 0x82 +#include "ELFRelocs/ARM.def" }; // Mips Specific e_flags @@ -877,7 +434,13 @@ enum : unsigned { EF_MIPS_ABI2 = 0x00000020, EF_MIPS_32BITMODE = 0x00000100, EF_MIPS_NAN2008 = 0x00000400, // Uses IEE 754-2008 NaN encoding + + // ABI flags EF_MIPS_ABI_O32 = 0x00001000, // This file follows the first MIPS 32 bit ABI + EF_MIPS_ABI_O64 = 0x00002000, // O32 ABI extended for 64-bit architecture. + EF_MIPS_ABI_EABI32 = 0x00003000, // EABI in 32 bit mode. + EF_MIPS_ABI_EABI64 = 0x00004000, // EABI in 64 bit mode. + EF_MIPS_ABI = 0x0000f000, // Mask for selecting EF_MIPS_ABI_ variant. //ARCH_ASE EF_MIPS_MICROMIPS = 0x02000000, // microMIPS @@ -900,85 +463,7 @@ enum : unsigned { // ELF Relocation types for Mips enum { - R_MIPS_NONE = 0, - R_MIPS_16 = 1, - R_MIPS_32 = 2, - R_MIPS_REL32 = 3, - R_MIPS_26 = 4, - R_MIPS_HI16 = 5, - R_MIPS_LO16 = 6, - R_MIPS_GPREL16 = 7, - R_MIPS_LITERAL = 8, - R_MIPS_GOT16 = 9, - R_MIPS_PC16 = 10, - R_MIPS_CALL16 = 11, - R_MIPS_GPREL32 = 12, - R_MIPS_UNUSED1 = 13, - R_MIPS_UNUSED2 = 14, - R_MIPS_SHIFT5 = 16, - R_MIPS_SHIFT6 = 17, - R_MIPS_64 = 18, - R_MIPS_GOT_DISP = 19, - R_MIPS_GOT_PAGE = 20, - R_MIPS_GOT_OFST = 21, - R_MIPS_GOT_HI16 = 22, - R_MIPS_GOT_LO16 = 23, - R_MIPS_SUB = 24, - R_MIPS_INSERT_A = 25, - R_MIPS_INSERT_B = 26, - R_MIPS_DELETE = 27, - R_MIPS_HIGHER = 28, - R_MIPS_HIGHEST = 29, - R_MIPS_CALL_HI16 = 30, - R_MIPS_CALL_LO16 = 31, - R_MIPS_SCN_DISP = 32, - R_MIPS_REL16 = 33, - R_MIPS_ADD_IMMEDIATE = 34, - R_MIPS_PJUMP = 35, - R_MIPS_RELGOT = 36, - R_MIPS_JALR = 37, - R_MIPS_TLS_DTPMOD32 = 38, - R_MIPS_TLS_DTPREL32 = 39, - R_MIPS_TLS_DTPMOD64 = 40, - R_MIPS_TLS_DTPREL64 = 41, - R_MIPS_TLS_GD = 42, - R_MIPS_TLS_LDM = 43, - R_MIPS_TLS_DTPREL_HI16 = 44, - R_MIPS_TLS_DTPREL_LO16 = 45, - R_MIPS_TLS_GOTTPREL = 46, - R_MIPS_TLS_TPREL32 = 47, - R_MIPS_TLS_TPREL64 = 48, - R_MIPS_TLS_TPREL_HI16 = 49, - R_MIPS_TLS_TPREL_LO16 = 50, - R_MIPS_GLOB_DAT = 51, - R_MIPS_PC21_S2 = 60, - R_MIPS_PC26_S2 = 61, - R_MIPS_PC18_S3 = 62, - R_MIPS_PC19_S2 = 63, - R_MIPS_PCHI16 = 64, - R_MIPS_PCLO16 = 65, - R_MIPS16_GOT16 = 102, - R_MIPS16_HI16 = 104, - R_MIPS16_LO16 = 105, - R_MIPS_COPY = 126, - R_MIPS_JUMP_SLOT = 127, - R_MICROMIPS_26_S1 = 133, - R_MICROMIPS_HI16 = 134, - R_MICROMIPS_LO16 = 135, - R_MICROMIPS_GOT16 = 138, - R_MICROMIPS_PC16_S1 = 141, - R_MICROMIPS_CALL16 = 142, - R_MICROMIPS_GOT_DISP = 145, - R_MICROMIPS_GOT_PAGE = 146, - R_MICROMIPS_GOT_OFST = 147, - R_MICROMIPS_TLS_GD = 162, - R_MICROMIPS_TLS_LDM = 163, - R_MICROMIPS_TLS_DTPREL_HI16 = 164, - R_MICROMIPS_TLS_DTPREL_LO16 = 165, - R_MICROMIPS_TLS_TPREL_HI16 = 169, - R_MICROMIPS_TLS_TPREL_LO16 = 170, - R_MIPS_NUM = 218, - R_MIPS_PC32 = 248 +#include "ELFRelocs/Mips.def" }; // Special values for the st_other field in the symbol table entry for MIPS. @@ -1019,250 +504,22 @@ enum { }; // ELF Relocation types for Hexagon -// Release 5 ABI enum { - R_HEX_NONE = 0, - R_HEX_B22_PCREL = 1, - R_HEX_B15_PCREL = 2, - R_HEX_B7_PCREL = 3, - R_HEX_LO16 = 4, - R_HEX_HI16 = 5, - R_HEX_32 = 6, - R_HEX_16 = 7, - R_HEX_8 = 8, - R_HEX_GPREL16_0 = 9, - R_HEX_GPREL16_1 = 10, - R_HEX_GPREL16_2 = 11, - R_HEX_GPREL16_3 = 12, - R_HEX_HL16 = 13, - R_HEX_B13_PCREL = 14, - R_HEX_B9_PCREL = 15, - R_HEX_B32_PCREL_X = 16, - R_HEX_32_6_X = 17, - R_HEX_B22_PCREL_X = 18, - R_HEX_B15_PCREL_X = 19, - R_HEX_B13_PCREL_X = 20, - R_HEX_B9_PCREL_X = 21, - R_HEX_B7_PCREL_X = 22, - R_HEX_16_X = 23, - R_HEX_12_X = 24, - R_HEX_11_X = 25, - R_HEX_10_X = 26, - R_HEX_9_X = 27, - R_HEX_8_X = 28, - R_HEX_7_X = 29, - R_HEX_6_X = 30, - R_HEX_32_PCREL = 31, - R_HEX_COPY = 32, - R_HEX_GLOB_DAT = 33, - R_HEX_JMP_SLOT = 34, - R_HEX_RELATIVE = 35, - R_HEX_PLT_B22_PCREL = 36, - R_HEX_GOTREL_LO16 = 37, - R_HEX_GOTREL_HI16 = 38, - R_HEX_GOTREL_32 = 39, - R_HEX_GOT_LO16 = 40, - R_HEX_GOT_HI16 = 41, - R_HEX_GOT_32 = 42, - R_HEX_GOT_16 = 43, - R_HEX_DTPMOD_32 = 44, - R_HEX_DTPREL_LO16 = 45, - R_HEX_DTPREL_HI16 = 46, - R_HEX_DTPREL_32 = 47, - R_HEX_DTPREL_16 = 48, - R_HEX_GD_PLT_B22_PCREL = 49, - R_HEX_GD_GOT_LO16 = 50, - R_HEX_GD_GOT_HI16 = 51, - R_HEX_GD_GOT_32 = 52, - R_HEX_GD_GOT_16 = 53, - R_HEX_IE_LO16 = 54, - R_HEX_IE_HI16 = 55, - R_HEX_IE_32 = 56, - R_HEX_IE_GOT_LO16 = 57, - R_HEX_IE_GOT_HI16 = 58, - R_HEX_IE_GOT_32 = 59, - R_HEX_IE_GOT_16 = 60, - R_HEX_TPREL_LO16 = 61, - R_HEX_TPREL_HI16 = 62, - R_HEX_TPREL_32 = 63, - R_HEX_TPREL_16 = 64, - R_HEX_6_PCREL_X = 65, - R_HEX_GOTREL_32_6_X = 66, - R_HEX_GOTREL_16_X = 67, - R_HEX_GOTREL_11_X = 68, - R_HEX_GOT_32_6_X = 69, - R_HEX_GOT_16_X = 70, - R_HEX_GOT_11_X = 71, - R_HEX_DTPREL_32_6_X = 72, - R_HEX_DTPREL_16_X = 73, - R_HEX_DTPREL_11_X = 74, - R_HEX_GD_GOT_32_6_X = 75, - R_HEX_GD_GOT_16_X = 76, - R_HEX_GD_GOT_11_X = 77, - R_HEX_IE_32_6_X = 78, - R_HEX_IE_16_X = 79, - R_HEX_IE_GOT_32_6_X = 80, - R_HEX_IE_GOT_16_X = 81, - R_HEX_IE_GOT_11_X = 82, - R_HEX_TPREL_32_6_X = 83, - R_HEX_TPREL_16_X = 84, - R_HEX_TPREL_11_X = 85 +#include "ELFRelocs/Hexagon.def" }; // ELF Relocation types for S390/zSeries enum { - R_390_NONE = 0, - R_390_8 = 1, - R_390_12 = 2, - R_390_16 = 3, - R_390_32 = 4, - R_390_PC32 = 5, - R_390_GOT12 = 6, - R_390_GOT32 = 7, - R_390_PLT32 = 8, - R_390_COPY = 9, - R_390_GLOB_DAT = 10, - R_390_JMP_SLOT = 11, - R_390_RELATIVE = 12, - R_390_GOTOFF = 13, - R_390_GOTPC = 14, - R_390_GOT16 = 15, - R_390_PC16 = 16, - R_390_PC16DBL = 17, - R_390_PLT16DBL = 18, - R_390_PC32DBL = 19, - R_390_PLT32DBL = 20, - R_390_GOTPCDBL = 21, - R_390_64 = 22, - R_390_PC64 = 23, - R_390_GOT64 = 24, - R_390_PLT64 = 25, - R_390_GOTENT = 26, - R_390_GOTOFF16 = 27, - R_390_GOTOFF64 = 28, - R_390_GOTPLT12 = 29, - R_390_GOTPLT16 = 30, - R_390_GOTPLT32 = 31, - R_390_GOTPLT64 = 32, - R_390_GOTPLTENT = 33, - R_390_PLTOFF16 = 34, - R_390_PLTOFF32 = 35, - R_390_PLTOFF64 = 36, - R_390_TLS_LOAD = 37, - R_390_TLS_GDCALL = 38, - R_390_TLS_LDCALL = 39, - R_390_TLS_GD32 = 40, - R_390_TLS_GD64 = 41, - R_390_TLS_GOTIE12 = 42, - R_390_TLS_GOTIE32 = 43, - R_390_TLS_GOTIE64 = 44, - R_390_TLS_LDM32 = 45, - R_390_TLS_LDM64 = 46, - R_390_TLS_IE32 = 47, - R_390_TLS_IE64 = 48, - R_390_TLS_IEENT = 49, - R_390_TLS_LE32 = 50, - R_390_TLS_LE64 = 51, - R_390_TLS_LDO32 = 52, - R_390_TLS_LDO64 = 53, - R_390_TLS_DTPMOD = 54, - R_390_TLS_DTPOFF = 55, - R_390_TLS_TPOFF = 56, - R_390_20 = 57, - R_390_GOT20 = 58, - R_390_GOTPLT20 = 59, - R_390_TLS_GOTIE20 = 60, - R_390_IRELATIVE = 61 +#include "ELFRelocs/SystemZ.def" }; // ELF Relocation type for Sparc. enum { - R_SPARC_NONE = 0, - R_SPARC_8 = 1, - R_SPARC_16 = 2, - R_SPARC_32 = 3, - R_SPARC_DISP8 = 4, - R_SPARC_DISP16 = 5, - R_SPARC_DISP32 = 6, - R_SPARC_WDISP30 = 7, - R_SPARC_WDISP22 = 8, - R_SPARC_HI22 = 9, - R_SPARC_22 = 10, - R_SPARC_13 = 11, - R_SPARC_LO10 = 12, - R_SPARC_GOT10 = 13, - R_SPARC_GOT13 = 14, - R_SPARC_GOT22 = 15, - R_SPARC_PC10 = 16, - R_SPARC_PC22 = 17, - R_SPARC_WPLT30 = 18, - R_SPARC_COPY = 19, - R_SPARC_GLOB_DAT = 20, - R_SPARC_JMP_SLOT = 21, - R_SPARC_RELATIVE = 22, - R_SPARC_UA32 = 23, - R_SPARC_PLT32 = 24, - R_SPARC_HIPLT22 = 25, - R_SPARC_LOPLT10 = 26, - R_SPARC_PCPLT32 = 27, - R_SPARC_PCPLT22 = 28, - R_SPARC_PCPLT10 = 29, - R_SPARC_10 = 30, - R_SPARC_11 = 31, - R_SPARC_64 = 32, - R_SPARC_OLO10 = 33, - R_SPARC_HH22 = 34, - R_SPARC_HM10 = 35, - R_SPARC_LM22 = 36, - R_SPARC_PC_HH22 = 37, - R_SPARC_PC_HM10 = 38, - R_SPARC_PC_LM22 = 39, - R_SPARC_WDISP16 = 40, - R_SPARC_WDISP19 = 41, - R_SPARC_7 = 43, - R_SPARC_5 = 44, - R_SPARC_6 = 45, - R_SPARC_DISP64 = 46, - R_SPARC_PLT64 = 47, - R_SPARC_HIX22 = 48, - R_SPARC_LOX10 = 49, - R_SPARC_H44 = 50, - R_SPARC_M44 = 51, - R_SPARC_L44 = 52, - R_SPARC_REGISTER = 53, - R_SPARC_UA64 = 54, - R_SPARC_UA16 = 55, - R_SPARC_TLS_GD_HI22 = 56, - R_SPARC_TLS_GD_LO10 = 57, - R_SPARC_TLS_GD_ADD = 58, - R_SPARC_TLS_GD_CALL = 59, - R_SPARC_TLS_LDM_HI22 = 60, - R_SPARC_TLS_LDM_LO10 = 61, - R_SPARC_TLS_LDM_ADD = 62, - R_SPARC_TLS_LDM_CALL = 63, - R_SPARC_TLS_LDO_HIX22 = 64, - R_SPARC_TLS_LDO_LOX10 = 65, - R_SPARC_TLS_LDO_ADD = 66, - R_SPARC_TLS_IE_HI22 = 67, - R_SPARC_TLS_IE_LO10 = 68, - R_SPARC_TLS_IE_LD = 69, - R_SPARC_TLS_IE_LDX = 70, - R_SPARC_TLS_IE_ADD = 71, - R_SPARC_TLS_LE_HIX22 = 72, - R_SPARC_TLS_LE_LOX10 = 73, - R_SPARC_TLS_DTPMOD32 = 74, - R_SPARC_TLS_DTPMOD64 = 75, - R_SPARC_TLS_DTPOFF32 = 76, - R_SPARC_TLS_DTPOFF64 = 77, - R_SPARC_TLS_TPOFF32 = 78, - R_SPARC_TLS_TPOFF64 = 79, - R_SPARC_GOTDATA_HIX22 = 80, - R_SPARC_GOTDATA_LOX22 = 81, - R_SPARC_GOTDATA_OP_HIX22 = 82, - R_SPARC_GOTDATA_OP_LOX22 = 83, - R_SPARC_GOTDATA_OP = 84 +#include "ELFRelocs/Sparc.def" }; +#undef ELF_RELOC + // Section header. struct Elf32_Shdr { Elf32_Word sh_name; // Section name (index into string table) diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/AArch64.def b/contrib/llvm/include/llvm/Support/ELFRelocs/AArch64.def new file mode 100644 index 000000000000..aa0c560f3e50 --- /dev/null +++ b/contrib/llvm/include/llvm/Support/ELFRelocs/AArch64.def @@ -0,0 +1,147 @@ + +#ifndef ELF_RELOC +#error "ELF_RELOC must be defined" +#endif + +// ABI release 1.0 +ELF_RELOC(R_AARCH64_NONE, 0) + +ELF_RELOC(R_AARCH64_ABS64, 0x101) +ELF_RELOC(R_AARCH64_ABS32, 0x102) +ELF_RELOC(R_AARCH64_ABS16, 0x103) +ELF_RELOC(R_AARCH64_PREL64, 0x104) +ELF_RELOC(R_AARCH64_PREL32, 0x105) +ELF_RELOC(R_AARCH64_PREL16, 0x106) + +ELF_RELOC(R_AARCH64_MOVW_UABS_G0, 0x107) +ELF_RELOC(R_AARCH64_MOVW_UABS_G0_NC, 0x108) +ELF_RELOC(R_AARCH64_MOVW_UABS_G1, 0x109) +ELF_RELOC(R_AARCH64_MOVW_UABS_G1_NC, 0x10a) +ELF_RELOC(R_AARCH64_MOVW_UABS_G2, 0x10b) +ELF_RELOC(R_AARCH64_MOVW_UABS_G2_NC, 0x10c) +ELF_RELOC(R_AARCH64_MOVW_UABS_G3, 0x10d) +ELF_RELOC(R_AARCH64_MOVW_SABS_G0, 0x10e) +ELF_RELOC(R_AARCH64_MOVW_SABS_G1, 0x10f) +ELF_RELOC(R_AARCH64_MOVW_SABS_G2, 0x110) + +ELF_RELOC(R_AARCH64_LD_PREL_LO19, 0x111) +ELF_RELOC(R_AARCH64_ADR_PREL_LO21, 0x112) +ELF_RELOC(R_AARCH64_ADR_PREL_PG_HI21, 0x113) +ELF_RELOC(R_AARCH64_ADR_PREL_PG_HI21_NC, 0x114) +ELF_RELOC(R_AARCH64_ADD_ABS_LO12_NC, 0x115) +ELF_RELOC(R_AARCH64_LDST8_ABS_LO12_NC, 0x116) + +ELF_RELOC(R_AARCH64_TSTBR14, 0x117) +ELF_RELOC(R_AARCH64_CONDBR19, 0x118) +ELF_RELOC(R_AARCH64_JUMP26, 0x11a) +ELF_RELOC(R_AARCH64_CALL26, 0x11b) + +ELF_RELOC(R_AARCH64_LDST16_ABS_LO12_NC, 0x11c) +ELF_RELOC(R_AARCH64_LDST32_ABS_LO12_NC, 0x11d) +ELF_RELOC(R_AARCH64_LDST64_ABS_LO12_NC, 0x11e) + +ELF_RELOC(R_AARCH64_MOVW_PREL_G0, 0x11f) +ELF_RELOC(R_AARCH64_MOVW_PREL_G0_NC, 0x120) +ELF_RELOC(R_AARCH64_MOVW_PREL_G1, 0x121) +ELF_RELOC(R_AARCH64_MOVW_PREL_G1_NC, 0x122) +ELF_RELOC(R_AARCH64_MOVW_PREL_G2, 0x123) +ELF_RELOC(R_AARCH64_MOVW_PREL_G2_NC, 0x124) +ELF_RELOC(R_AARCH64_MOVW_PREL_G3, 0x125) + +ELF_RELOC(R_AARCH64_LDST128_ABS_LO12_NC, 0x12b) + +ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G0, 0x12c) +ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G0_NC, 0x12d) +ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G1, 0x12e) +ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G1_NC, 0x12f) +ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G2, 0x130) +ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G2_NC, 0x131) +ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G3, 0x132) + +ELF_RELOC(R_AARCH64_GOTREL64, 0x133) +ELF_RELOC(R_AARCH64_GOTREL32, 0x134) + +ELF_RELOC(R_AARCH64_GOT_LD_PREL19, 0x135) +ELF_RELOC(R_AARCH64_LD64_GOTOFF_LO15, 0x136) +ELF_RELOC(R_AARCH64_ADR_GOT_PAGE, 0x137) +ELF_RELOC(R_AARCH64_LD64_GOT_LO12_NC, 0x138) +ELF_RELOC(R_AARCH64_LD64_GOTPAGE_LO15, 0x139) + +ELF_RELOC(R_AARCH64_TLSGD_ADR_PREL21, 0x200) +ELF_RELOC(R_AARCH64_TLSGD_ADR_PAGE21, 0x201) +ELF_RELOC(R_AARCH64_TLSGD_ADD_LO12_NC, 0x202) +ELF_RELOC(R_AARCH64_TLSGD_MOVW_G1, 0x203) +ELF_RELOC(R_AARCH64_TLSGD_MOVW_G0_NC, 0x204) + +ELF_RELOC(R_AARCH64_TLSLD_ADR_PREL21, 0x205) +ELF_RELOC(R_AARCH64_TLSLD_ADR_PAGE21, 0x206) +ELF_RELOC(R_AARCH64_TLSLD_ADD_LO12_NC, 0x207) +ELF_RELOC(R_AARCH64_TLSLD_MOVW_G1, 0x208) +ELF_RELOC(R_AARCH64_TLSLD_MOVW_G0_NC, 0x209) +ELF_RELOC(R_AARCH64_TLSLD_LD_PREL19, 0x20a) +ELF_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G2, 0x20b) +ELF_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G1, 0x20c) +ELF_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC, 0x20d) +ELF_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G0, 0x20e) +ELF_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC, 0x20f) +ELF_RELOC(R_AARCH64_TLSLD_ADD_DTPREL_HI12, 0x210) +ELF_RELOC(R_AARCH64_TLSLD_ADD_DTPREL_LO12, 0x211) +ELF_RELOC(R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC, 0x212) +ELF_RELOC(R_AARCH64_TLSLD_LDST8_DTPREL_LO12, 0x213) +ELF_RELOC(R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC, 0x214) +ELF_RELOC(R_AARCH64_TLSLD_LDST16_DTPREL_LO12, 0x215) +ELF_RELOC(R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC, 0x216) +ELF_RELOC(R_AARCH64_TLSLD_LDST32_DTPREL_LO12, 0x217) +ELF_RELOC(R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC, 0x218) +ELF_RELOC(R_AARCH64_TLSLD_LDST64_DTPREL_LO12, 0x219) +ELF_RELOC(R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC, 0x21a) + +ELF_RELOC(R_AARCH64_TLSIE_MOVW_GOTTPREL_G1, 0x21b) +ELF_RELOC(R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC, 0x21c) +ELF_RELOC(R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21, 0x21d) +ELF_RELOC(R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC, 0x21e) +ELF_RELOC(R_AARCH64_TLSIE_LD_GOTTPREL_PREL19, 0x21f) + +ELF_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G2, 0x220) +ELF_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G1, 0x221) +ELF_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G1_NC, 0x222) +ELF_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G0, 0x223) +ELF_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G0_NC, 0x224) +ELF_RELOC(R_AARCH64_TLSLE_ADD_TPREL_HI12, 0x225) +ELF_RELOC(R_AARCH64_TLSLE_ADD_TPREL_LO12, 0x226) +ELF_RELOC(R_AARCH64_TLSLE_ADD_TPREL_LO12_NC, 0x227) +ELF_RELOC(R_AARCH64_TLSLE_LDST8_TPREL_LO12, 0x228) +ELF_RELOC(R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC, 0x229) +ELF_RELOC(R_AARCH64_TLSLE_LDST16_TPREL_LO12, 0x22a) +ELF_RELOC(R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC, 0x22b) +ELF_RELOC(R_AARCH64_TLSLE_LDST32_TPREL_LO12, 0x22c) +ELF_RELOC(R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC, 0x22d) +ELF_RELOC(R_AARCH64_TLSLE_LDST64_TPREL_LO12, 0x22e) +ELF_RELOC(R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC, 0x22f) + +ELF_RELOC(R_AARCH64_TLSDESC_LD_PREL19, 0x230) +ELF_RELOC(R_AARCH64_TLSDESC_ADR_PREL21, 0x231) +ELF_RELOC(R_AARCH64_TLSDESC_ADR_PAGE21, 0x232) +ELF_RELOC(R_AARCH64_TLSDESC_LD64_LO12_NC, 0x233) +ELF_RELOC(R_AARCH64_TLSDESC_ADD_LO12_NC, 0x234) +ELF_RELOC(R_AARCH64_TLSDESC_OFF_G1, 0x235) +ELF_RELOC(R_AARCH64_TLSDESC_OFF_G0_NC, 0x236) +ELF_RELOC(R_AARCH64_TLSDESC_LDR, 0x237) +ELF_RELOC(R_AARCH64_TLSDESC_ADD, 0x238) +ELF_RELOC(R_AARCH64_TLSDESC_CALL, 0x239) + +ELF_RELOC(R_AARCH64_TLSLE_LDST128_TPREL_LO12, 0x23a) +ELF_RELOC(R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC, 0x23b) + +ELF_RELOC(R_AARCH64_TLSLD_LDST128_DTPREL_LO12, 0x23c) +ELF_RELOC(R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC, 0x23d) + +ELF_RELOC(R_AARCH64_COPY, 0x400) +ELF_RELOC(R_AARCH64_GLOB_DAT, 0x401) +ELF_RELOC(R_AARCH64_JUMP_SLOT, 0x402) +ELF_RELOC(R_AARCH64_RELATIVE, 0x403) +ELF_RELOC(R_AARCH64_TLS_DTPREL64, 0x404) +ELF_RELOC(R_AARCH64_TLS_DTPMOD64, 0x405) +ELF_RELOC(R_AARCH64_TLS_TPREL64, 0x406) +ELF_RELOC(R_AARCH64_TLSDESC, 0x407) +ELF_RELOC(R_AARCH64_IRELATIVE, 0x408) diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/ARM.def b/contrib/llvm/include/llvm/Support/ELFRelocs/ARM.def new file mode 100644 index 000000000000..730fc5b8836c --- /dev/null +++ b/contrib/llvm/include/llvm/Support/ELFRelocs/ARM.def @@ -0,0 +1,138 @@ + +#ifndef ELF_RELOC +#error "ELF_RELOC must be defined" +#endif + +// Meets 2.09 ABI Specs. +ELF_RELOC(R_ARM_NONE, 0x00) +ELF_RELOC(R_ARM_PC24, 0x01) +ELF_RELOC(R_ARM_ABS32, 0x02) +ELF_RELOC(R_ARM_REL32, 0x03) +ELF_RELOC(R_ARM_LDR_PC_G0, 0x04) +ELF_RELOC(R_ARM_ABS16, 0x05) +ELF_RELOC(R_ARM_ABS12, 0x06) +ELF_RELOC(R_ARM_THM_ABS5, 0x07) +ELF_RELOC(R_ARM_ABS8, 0x08) +ELF_RELOC(R_ARM_SBREL32, 0x09) +ELF_RELOC(R_ARM_THM_CALL, 0x0a) +ELF_RELOC(R_ARM_THM_PC8, 0x0b) +ELF_RELOC(R_ARM_BREL_ADJ, 0x0c) +ELF_RELOC(R_ARM_TLS_DESC, 0x0d) +ELF_RELOC(R_ARM_THM_SWI8, 0x0e) +ELF_RELOC(R_ARM_XPC25, 0x0f) +ELF_RELOC(R_ARM_THM_XPC22, 0x10) +ELF_RELOC(R_ARM_TLS_DTPMOD32, 0x11) +ELF_RELOC(R_ARM_TLS_DTPOFF32, 0x12) +ELF_RELOC(R_ARM_TLS_TPOFF32, 0x13) +ELF_RELOC(R_ARM_COPY, 0x14) +ELF_RELOC(R_ARM_GLOB_DAT, 0x15) +ELF_RELOC(R_ARM_JUMP_SLOT, 0x16) +ELF_RELOC(R_ARM_RELATIVE, 0x17) +ELF_RELOC(R_ARM_GOTOFF32, 0x18) +ELF_RELOC(R_ARM_BASE_PREL, 0x19) +ELF_RELOC(R_ARM_GOT_BREL, 0x1a) +ELF_RELOC(R_ARM_PLT32, 0x1b) +ELF_RELOC(R_ARM_CALL, 0x1c) +ELF_RELOC(R_ARM_JUMP24, 0x1d) +ELF_RELOC(R_ARM_THM_JUMP24, 0x1e) +ELF_RELOC(R_ARM_BASE_ABS, 0x1f) +ELF_RELOC(R_ARM_ALU_PCREL_7_0, 0x20) +ELF_RELOC(R_ARM_ALU_PCREL_15_8, 0x21) +ELF_RELOC(R_ARM_ALU_PCREL_23_15, 0x22) +ELF_RELOC(R_ARM_LDR_SBREL_11_0_NC, 0x23) +ELF_RELOC(R_ARM_ALU_SBREL_19_12_NC, 0x24) +ELF_RELOC(R_ARM_ALU_SBREL_27_20_CK, 0x25) +ELF_RELOC(R_ARM_TARGET1, 0x26) +ELF_RELOC(R_ARM_SBREL31, 0x27) +ELF_RELOC(R_ARM_V4BX, 0x28) +ELF_RELOC(R_ARM_TARGET2, 0x29) +ELF_RELOC(R_ARM_PREL31, 0x2a) +ELF_RELOC(R_ARM_MOVW_ABS_NC, 0x2b) +ELF_RELOC(R_ARM_MOVT_ABS, 0x2c) +ELF_RELOC(R_ARM_MOVW_PREL_NC, 0x2d) +ELF_RELOC(R_ARM_MOVT_PREL, 0x2e) +ELF_RELOC(R_ARM_THM_MOVW_ABS_NC, 0x2f) +ELF_RELOC(R_ARM_THM_MOVT_ABS, 0x30) +ELF_RELOC(R_ARM_THM_MOVW_PREL_NC, 0x31) +ELF_RELOC(R_ARM_THM_MOVT_PREL, 0x32) +ELF_RELOC(R_ARM_THM_JUMP19, 0x33) +ELF_RELOC(R_ARM_THM_JUMP6, 0x34) +ELF_RELOC(R_ARM_THM_ALU_PREL_11_0, 0x35) +ELF_RELOC(R_ARM_THM_PC12, 0x36) +ELF_RELOC(R_ARM_ABS32_NOI, 0x37) +ELF_RELOC(R_ARM_REL32_NOI, 0x38) +ELF_RELOC(R_ARM_ALU_PC_G0_NC, 0x39) +ELF_RELOC(R_ARM_ALU_PC_G0, 0x3a) +ELF_RELOC(R_ARM_ALU_PC_G1_NC, 0x3b) +ELF_RELOC(R_ARM_ALU_PC_G1, 0x3c) +ELF_RELOC(R_ARM_ALU_PC_G2, 0x3d) +ELF_RELOC(R_ARM_LDR_PC_G1, 0x3e) +ELF_RELOC(R_ARM_LDR_PC_G2, 0x3f) +ELF_RELOC(R_ARM_LDRS_PC_G0, 0x40) +ELF_RELOC(R_ARM_LDRS_PC_G1, 0x41) +ELF_RELOC(R_ARM_LDRS_PC_G2, 0x42) +ELF_RELOC(R_ARM_LDC_PC_G0, 0x43) +ELF_RELOC(R_ARM_LDC_PC_G1, 0x44) +ELF_RELOC(R_ARM_LDC_PC_G2, 0x45) +ELF_RELOC(R_ARM_ALU_SB_G0_NC, 0x46) +ELF_RELOC(R_ARM_ALU_SB_G0, 0x47) +ELF_RELOC(R_ARM_ALU_SB_G1_NC, 0x48) +ELF_RELOC(R_ARM_ALU_SB_G1, 0x49) +ELF_RELOC(R_ARM_ALU_SB_G2, 0x4a) +ELF_RELOC(R_ARM_LDR_SB_G0, 0x4b) +ELF_RELOC(R_ARM_LDR_SB_G1, 0x4c) +ELF_RELOC(R_ARM_LDR_SB_G2, 0x4d) +ELF_RELOC(R_ARM_LDRS_SB_G0, 0x4e) +ELF_RELOC(R_ARM_LDRS_SB_G1, 0x4f) +ELF_RELOC(R_ARM_LDRS_SB_G2, 0x50) +ELF_RELOC(R_ARM_LDC_SB_G0, 0x51) +ELF_RELOC(R_ARM_LDC_SB_G1, 0x52) +ELF_RELOC(R_ARM_LDC_SB_G2, 0x53) +ELF_RELOC(R_ARM_MOVW_BREL_NC, 0x54) +ELF_RELOC(R_ARM_MOVT_BREL, 0x55) +ELF_RELOC(R_ARM_MOVW_BREL, 0x56) +ELF_RELOC(R_ARM_THM_MOVW_BREL_NC, 0x57) +ELF_RELOC(R_ARM_THM_MOVT_BREL, 0x58) +ELF_RELOC(R_ARM_THM_MOVW_BREL, 0x59) +ELF_RELOC(R_ARM_TLS_GOTDESC, 0x5a) +ELF_RELOC(R_ARM_TLS_CALL, 0x5b) +ELF_RELOC(R_ARM_TLS_DESCSEQ, 0x5c) +ELF_RELOC(R_ARM_THM_TLS_CALL, 0x5d) +ELF_RELOC(R_ARM_PLT32_ABS, 0x5e) +ELF_RELOC(R_ARM_GOT_ABS, 0x5f) +ELF_RELOC(R_ARM_GOT_PREL, 0x60) +ELF_RELOC(R_ARM_GOT_BREL12, 0x61) +ELF_RELOC(R_ARM_GOTOFF12, 0x62) +ELF_RELOC(R_ARM_GOTRELAX, 0x63) +ELF_RELOC(R_ARM_GNU_VTENTRY, 0x64) +ELF_RELOC(R_ARM_GNU_VTINHERIT, 0x65) +ELF_RELOC(R_ARM_THM_JUMP11, 0x66) +ELF_RELOC(R_ARM_THM_JUMP8, 0x67) +ELF_RELOC(R_ARM_TLS_GD32, 0x68) +ELF_RELOC(R_ARM_TLS_LDM32, 0x69) +ELF_RELOC(R_ARM_TLS_LDO32, 0x6a) +ELF_RELOC(R_ARM_TLS_IE32, 0x6b) +ELF_RELOC(R_ARM_TLS_LE32, 0x6c) +ELF_RELOC(R_ARM_TLS_LDO12, 0x6d) +ELF_RELOC(R_ARM_TLS_LE12, 0x6e) +ELF_RELOC(R_ARM_TLS_IE12GP, 0x6f) +ELF_RELOC(R_ARM_PRIVATE_0, 0x70) +ELF_RELOC(R_ARM_PRIVATE_1, 0x71) +ELF_RELOC(R_ARM_PRIVATE_2, 0x72) +ELF_RELOC(R_ARM_PRIVATE_3, 0x73) +ELF_RELOC(R_ARM_PRIVATE_4, 0x74) +ELF_RELOC(R_ARM_PRIVATE_5, 0x75) +ELF_RELOC(R_ARM_PRIVATE_6, 0x76) +ELF_RELOC(R_ARM_PRIVATE_7, 0x77) +ELF_RELOC(R_ARM_PRIVATE_8, 0x78) +ELF_RELOC(R_ARM_PRIVATE_9, 0x79) +ELF_RELOC(R_ARM_PRIVATE_10, 0x7a) +ELF_RELOC(R_ARM_PRIVATE_11, 0x7b) +ELF_RELOC(R_ARM_PRIVATE_12, 0x7c) +ELF_RELOC(R_ARM_PRIVATE_13, 0x7d) +ELF_RELOC(R_ARM_PRIVATE_14, 0x7e) +ELF_RELOC(R_ARM_PRIVATE_15, 0x7f) +ELF_RELOC(R_ARM_ME_TOO, 0x80) +ELF_RELOC(R_ARM_THM_TLS_DESCSEQ16, 0x81) +ELF_RELOC(R_ARM_THM_TLS_DESCSEQ32, 0x82) +ELF_RELOC(R_ARM_IRELATIVE, 0xa0) diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/Hexagon.def b/contrib/llvm/include/llvm/Support/ELFRelocs/Hexagon.def new file mode 100644 index 000000000000..c9d35b8bd75e --- /dev/null +++ b/contrib/llvm/include/llvm/Support/ELFRelocs/Hexagon.def @@ -0,0 +1,92 @@ + +#ifndef ELF_RELOC +#error "ELF_RELOC must be defined" +#endif + +// Release 5 ABI +ELF_RELOC(R_HEX_NONE, 0) +ELF_RELOC(R_HEX_B22_PCREL, 1) +ELF_RELOC(R_HEX_B15_PCREL, 2) +ELF_RELOC(R_HEX_B7_PCREL, 3) +ELF_RELOC(R_HEX_LO16, 4) +ELF_RELOC(R_HEX_HI16, 5) +ELF_RELOC(R_HEX_32, 6) +ELF_RELOC(R_HEX_16, 7) +ELF_RELOC(R_HEX_8, 8) +ELF_RELOC(R_HEX_GPREL16_0, 9) +ELF_RELOC(R_HEX_GPREL16_1, 10) +ELF_RELOC(R_HEX_GPREL16_2, 11) +ELF_RELOC(R_HEX_GPREL16_3, 12) +ELF_RELOC(R_HEX_HL16, 13) +ELF_RELOC(R_HEX_B13_PCREL, 14) +ELF_RELOC(R_HEX_B9_PCREL, 15) +ELF_RELOC(R_HEX_B32_PCREL_X, 16) +ELF_RELOC(R_HEX_32_6_X, 17) +ELF_RELOC(R_HEX_B22_PCREL_X, 18) +ELF_RELOC(R_HEX_B15_PCREL_X, 19) +ELF_RELOC(R_HEX_B13_PCREL_X, 20) +ELF_RELOC(R_HEX_B9_PCREL_X, 21) +ELF_RELOC(R_HEX_B7_PCREL_X, 22) +ELF_RELOC(R_HEX_16_X, 23) +ELF_RELOC(R_HEX_12_X, 24) +ELF_RELOC(R_HEX_11_X, 25) +ELF_RELOC(R_HEX_10_X, 26) +ELF_RELOC(R_HEX_9_X, 27) +ELF_RELOC(R_HEX_8_X, 28) +ELF_RELOC(R_HEX_7_X, 29) +ELF_RELOC(R_HEX_6_X, 30) +ELF_RELOC(R_HEX_32_PCREL, 31) +ELF_RELOC(R_HEX_COPY, 32) +ELF_RELOC(R_HEX_GLOB_DAT, 33) +ELF_RELOC(R_HEX_JMP_SLOT, 34) +ELF_RELOC(R_HEX_RELATIVE, 35) +ELF_RELOC(R_HEX_PLT_B22_PCREL, 36) +ELF_RELOC(R_HEX_GOTREL_LO16, 37) +ELF_RELOC(R_HEX_GOTREL_HI16, 38) +ELF_RELOC(R_HEX_GOTREL_32, 39) +ELF_RELOC(R_HEX_GOT_LO16, 40) +ELF_RELOC(R_HEX_GOT_HI16, 41) +ELF_RELOC(R_HEX_GOT_32, 42) +ELF_RELOC(R_HEX_GOT_16, 43) +ELF_RELOC(R_HEX_DTPMOD_32, 44) +ELF_RELOC(R_HEX_DTPREL_LO16, 45) +ELF_RELOC(R_HEX_DTPREL_HI16, 46) +ELF_RELOC(R_HEX_DTPREL_32, 47) +ELF_RELOC(R_HEX_DTPREL_16, 48) +ELF_RELOC(R_HEX_GD_PLT_B22_PCREL, 49) +ELF_RELOC(R_HEX_GD_GOT_LO16, 50) +ELF_RELOC(R_HEX_GD_GOT_HI16, 51) +ELF_RELOC(R_HEX_GD_GOT_32, 52) +ELF_RELOC(R_HEX_GD_GOT_16, 53) +ELF_RELOC(R_HEX_IE_LO16, 54) +ELF_RELOC(R_HEX_IE_HI16, 55) +ELF_RELOC(R_HEX_IE_32, 56) +ELF_RELOC(R_HEX_IE_GOT_LO16, 57) +ELF_RELOC(R_HEX_IE_GOT_HI16, 58) +ELF_RELOC(R_HEX_IE_GOT_32, 59) +ELF_RELOC(R_HEX_IE_GOT_16, 60) +ELF_RELOC(R_HEX_TPREL_LO16, 61) +ELF_RELOC(R_HEX_TPREL_HI16, 62) +ELF_RELOC(R_HEX_TPREL_32, 63) +ELF_RELOC(R_HEX_TPREL_16, 64) +ELF_RELOC(R_HEX_6_PCREL_X, 65) +ELF_RELOC(R_HEX_GOTREL_32_6_X, 66) +ELF_RELOC(R_HEX_GOTREL_16_X, 67) +ELF_RELOC(R_HEX_GOTREL_11_X, 68) +ELF_RELOC(R_HEX_GOT_32_6_X, 69) +ELF_RELOC(R_HEX_GOT_16_X, 70) +ELF_RELOC(R_HEX_GOT_11_X, 71) +ELF_RELOC(R_HEX_DTPREL_32_6_X, 72) +ELF_RELOC(R_HEX_DTPREL_16_X, 73) +ELF_RELOC(R_HEX_DTPREL_11_X, 74) +ELF_RELOC(R_HEX_GD_GOT_32_6_X, 75) +ELF_RELOC(R_HEX_GD_GOT_16_X, 76) +ELF_RELOC(R_HEX_GD_GOT_11_X, 77) +ELF_RELOC(R_HEX_IE_32_6_X, 78) +ELF_RELOC(R_HEX_IE_16_X, 79) +ELF_RELOC(R_HEX_IE_GOT_32_6_X, 80) +ELF_RELOC(R_HEX_IE_GOT_16_X, 81) +ELF_RELOC(R_HEX_IE_GOT_11_X, 82) +ELF_RELOC(R_HEX_TPREL_32_6_X, 83) +ELF_RELOC(R_HEX_TPREL_16_X, 84) +ELF_RELOC(R_HEX_TPREL_11_X, 85) diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/Mips.def b/contrib/llvm/include/llvm/Support/ELFRelocs/Mips.def new file mode 100644 index 000000000000..dc573464dcf2 --- /dev/null +++ b/contrib/llvm/include/llvm/Support/ELFRelocs/Mips.def @@ -0,0 +1,112 @@ + +#ifndef ELF_RELOC +#error "ELF_RELOC must be defined" +#endif + +ELF_RELOC(R_MIPS_NONE, 0) +ELF_RELOC(R_MIPS_16, 1) +ELF_RELOC(R_MIPS_32, 2) +ELF_RELOC(R_MIPS_REL32, 3) +ELF_RELOC(R_MIPS_26, 4) +ELF_RELOC(R_MIPS_HI16, 5) +ELF_RELOC(R_MIPS_LO16, 6) +ELF_RELOC(R_MIPS_GPREL16, 7) +ELF_RELOC(R_MIPS_LITERAL, 8) +ELF_RELOC(R_MIPS_GOT16, 9) +ELF_RELOC(R_MIPS_PC16, 10) +ELF_RELOC(R_MIPS_CALL16, 11) +ELF_RELOC(R_MIPS_GPREL32, 12) +ELF_RELOC(R_MIPS_UNUSED1, 13) +ELF_RELOC(R_MIPS_UNUSED2, 14) +ELF_RELOC(R_MIPS_UNUSED3, 15) +ELF_RELOC(R_MIPS_SHIFT5, 16) +ELF_RELOC(R_MIPS_SHIFT6, 17) +ELF_RELOC(R_MIPS_64, 18) +ELF_RELOC(R_MIPS_GOT_DISP, 19) +ELF_RELOC(R_MIPS_GOT_PAGE, 20) +ELF_RELOC(R_MIPS_GOT_OFST, 21) +ELF_RELOC(R_MIPS_GOT_HI16, 22) +ELF_RELOC(R_MIPS_GOT_LO16, 23) +ELF_RELOC(R_MIPS_SUB, 24) +ELF_RELOC(R_MIPS_INSERT_A, 25) +ELF_RELOC(R_MIPS_INSERT_B, 26) +ELF_RELOC(R_MIPS_DELETE, 27) +ELF_RELOC(R_MIPS_HIGHER, 28) +ELF_RELOC(R_MIPS_HIGHEST, 29) +ELF_RELOC(R_MIPS_CALL_HI16, 30) +ELF_RELOC(R_MIPS_CALL_LO16, 31) +ELF_RELOC(R_MIPS_SCN_DISP, 32) +ELF_RELOC(R_MIPS_REL16, 33) +ELF_RELOC(R_MIPS_ADD_IMMEDIATE, 34) +ELF_RELOC(R_MIPS_PJUMP, 35) +ELF_RELOC(R_MIPS_RELGOT, 36) +ELF_RELOC(R_MIPS_JALR, 37) +ELF_RELOC(R_MIPS_TLS_DTPMOD32, 38) +ELF_RELOC(R_MIPS_TLS_DTPREL32, 39) +ELF_RELOC(R_MIPS_TLS_DTPMOD64, 40) +ELF_RELOC(R_MIPS_TLS_DTPREL64, 41) +ELF_RELOC(R_MIPS_TLS_GD, 42) +ELF_RELOC(R_MIPS_TLS_LDM, 43) +ELF_RELOC(R_MIPS_TLS_DTPREL_HI16, 44) +ELF_RELOC(R_MIPS_TLS_DTPREL_LO16, 45) +ELF_RELOC(R_MIPS_TLS_GOTTPREL, 46) +ELF_RELOC(R_MIPS_TLS_TPREL32, 47) +ELF_RELOC(R_MIPS_TLS_TPREL64, 48) +ELF_RELOC(R_MIPS_TLS_TPREL_HI16, 49) +ELF_RELOC(R_MIPS_TLS_TPREL_LO16, 50) +ELF_RELOC(R_MIPS_GLOB_DAT, 51) +ELF_RELOC(R_MIPS_PC21_S2, 60) +ELF_RELOC(R_MIPS_PC26_S2, 61) +ELF_RELOC(R_MIPS_PC18_S3, 62) +ELF_RELOC(R_MIPS_PC19_S2, 63) +ELF_RELOC(R_MIPS_PCHI16, 64) +ELF_RELOC(R_MIPS_PCLO16, 65) +ELF_RELOC(R_MIPS16_26, 100) +ELF_RELOC(R_MIPS16_GPREL, 101) +ELF_RELOC(R_MIPS16_GOT16, 102) +ELF_RELOC(R_MIPS16_CALL16, 103) +ELF_RELOC(R_MIPS16_HI16, 104) +ELF_RELOC(R_MIPS16_LO16, 105) +ELF_RELOC(R_MIPS16_TLS_GD, 106) +ELF_RELOC(R_MIPS16_TLS_LDM, 107) +ELF_RELOC(R_MIPS16_TLS_DTPREL_HI16, 108) +ELF_RELOC(R_MIPS16_TLS_DTPREL_LO16, 109) +ELF_RELOC(R_MIPS16_TLS_GOTTPREL, 110) +ELF_RELOC(R_MIPS16_TLS_TPREL_HI16, 111) +ELF_RELOC(R_MIPS16_TLS_TPREL_LO16, 112) +ELF_RELOC(R_MIPS_COPY, 126) +ELF_RELOC(R_MIPS_JUMP_SLOT, 127) +ELF_RELOC(R_MICROMIPS_26_S1, 133) +ELF_RELOC(R_MICROMIPS_HI16, 134) +ELF_RELOC(R_MICROMIPS_LO16, 135) +ELF_RELOC(R_MICROMIPS_GPREL16, 136) +ELF_RELOC(R_MICROMIPS_LITERAL, 137) +ELF_RELOC(R_MICROMIPS_GOT16, 138) +ELF_RELOC(R_MICROMIPS_PC7_S1, 139) +ELF_RELOC(R_MICROMIPS_PC10_S1, 140) +ELF_RELOC(R_MICROMIPS_PC16_S1, 141) +ELF_RELOC(R_MICROMIPS_CALL16, 142) +ELF_RELOC(R_MICROMIPS_GOT_DISP, 145) +ELF_RELOC(R_MICROMIPS_GOT_PAGE, 146) +ELF_RELOC(R_MICROMIPS_GOT_OFST, 147) +ELF_RELOC(R_MICROMIPS_GOT_HI16, 148) +ELF_RELOC(R_MICROMIPS_GOT_LO16, 149) +ELF_RELOC(R_MICROMIPS_SUB, 150) +ELF_RELOC(R_MICROMIPS_HIGHER, 151) +ELF_RELOC(R_MICROMIPS_HIGHEST, 152) +ELF_RELOC(R_MICROMIPS_CALL_HI16, 153) +ELF_RELOC(R_MICROMIPS_CALL_LO16, 154) +ELF_RELOC(R_MICROMIPS_SCN_DISP, 155) +ELF_RELOC(R_MICROMIPS_JALR, 156) +ELF_RELOC(R_MICROMIPS_HI0_LO16, 157) +ELF_RELOC(R_MICROMIPS_TLS_GD, 162) +ELF_RELOC(R_MICROMIPS_TLS_LDM, 163) +ELF_RELOC(R_MICROMIPS_TLS_DTPREL_HI16, 164) +ELF_RELOC(R_MICROMIPS_TLS_DTPREL_LO16, 165) +ELF_RELOC(R_MICROMIPS_TLS_GOTTPREL, 166) +ELF_RELOC(R_MICROMIPS_TLS_TPREL_HI16, 169) +ELF_RELOC(R_MICROMIPS_TLS_TPREL_LO16, 170) +ELF_RELOC(R_MICROMIPS_GPREL7_S2, 172) +ELF_RELOC(R_MICROMIPS_PC23_S2, 173) +ELF_RELOC(R_MIPS_NUM, 218) +ELF_RELOC(R_MIPS_PC32, 248) diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/PowerPC.def b/contrib/llvm/include/llvm/Support/ELFRelocs/PowerPC.def new file mode 100644 index 000000000000..b6c39419b0f7 --- /dev/null +++ b/contrib/llvm/include/llvm/Support/ELFRelocs/PowerPC.def @@ -0,0 +1,61 @@ + +#ifndef ELF_RELOC +#error "ELF_RELOC must be defined" +#endif + +ELF_RELOC(R_PPC_NONE, 0) /* No relocation. */ +ELF_RELOC(R_PPC_ADDR32, 1) +ELF_RELOC(R_PPC_ADDR24, 2) +ELF_RELOC(R_PPC_ADDR16, 3) +ELF_RELOC(R_PPC_ADDR16_LO, 4) +ELF_RELOC(R_PPC_ADDR16_HI, 5) +ELF_RELOC(R_PPC_ADDR16_HA, 6) +ELF_RELOC(R_PPC_ADDR14, 7) +ELF_RELOC(R_PPC_ADDR14_BRTAKEN, 8) +ELF_RELOC(R_PPC_ADDR14_BRNTAKEN, 9) +ELF_RELOC(R_PPC_REL24, 10) +ELF_RELOC(R_PPC_REL14, 11) +ELF_RELOC(R_PPC_REL14_BRTAKEN, 12) +ELF_RELOC(R_PPC_REL14_BRNTAKEN, 13) +ELF_RELOC(R_PPC_GOT16, 14) +ELF_RELOC(R_PPC_GOT16_LO, 15) +ELF_RELOC(R_PPC_GOT16_HI, 16) +ELF_RELOC(R_PPC_GOT16_HA, 17) +ELF_RELOC(R_PPC_PLTREL24, 18) +ELF_RELOC(R_PPC_JMP_SLOT, 21) +ELF_RELOC(R_PPC_LOCAL24PC, 23) +ELF_RELOC(R_PPC_REL32, 26) +ELF_RELOC(R_PPC_TLS, 67) +ELF_RELOC(R_PPC_DTPMOD32, 68) +ELF_RELOC(R_PPC_TPREL16, 69) +ELF_RELOC(R_PPC_TPREL16_LO, 70) +ELF_RELOC(R_PPC_TPREL16_HI, 71) +ELF_RELOC(R_PPC_TPREL16_HA, 72) +ELF_RELOC(R_PPC_TPREL32, 73) +ELF_RELOC(R_PPC_DTPREL16, 74) +ELF_RELOC(R_PPC_DTPREL16_LO, 75) +ELF_RELOC(R_PPC_DTPREL16_HI, 76) +ELF_RELOC(R_PPC_DTPREL16_HA, 77) +ELF_RELOC(R_PPC_DTPREL32, 78) +ELF_RELOC(R_PPC_GOT_TLSGD16, 79) +ELF_RELOC(R_PPC_GOT_TLSGD16_LO, 80) +ELF_RELOC(R_PPC_GOT_TLSGD16_HI, 81) +ELF_RELOC(R_PPC_GOT_TLSGD16_HA, 82) +ELF_RELOC(R_PPC_GOT_TLSLD16, 83) +ELF_RELOC(R_PPC_GOT_TLSLD16_LO, 84) +ELF_RELOC(R_PPC_GOT_TLSLD16_HI, 85) +ELF_RELOC(R_PPC_GOT_TLSLD16_HA, 86) +ELF_RELOC(R_PPC_GOT_TPREL16, 87) +ELF_RELOC(R_PPC_GOT_TPREL16_LO, 88) +ELF_RELOC(R_PPC_GOT_TPREL16_HI, 89) +ELF_RELOC(R_PPC_GOT_TPREL16_HA, 90) +ELF_RELOC(R_PPC_GOT_DTPREL16, 91) +ELF_RELOC(R_PPC_GOT_DTPREL16_LO, 92) +ELF_RELOC(R_PPC_GOT_DTPREL16_HI, 93) +ELF_RELOC(R_PPC_GOT_DTPREL16_HA, 94) +ELF_RELOC(R_PPC_TLSGD, 95) +ELF_RELOC(R_PPC_TLSLD, 96) +ELF_RELOC(R_PPC_REL16, 249) +ELF_RELOC(R_PPC_REL16_LO, 250) +ELF_RELOC(R_PPC_REL16_HI, 251) +ELF_RELOC(R_PPC_REL16_HA, 252) diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/PowerPC64.def b/contrib/llvm/include/llvm/Support/ELFRelocs/PowerPC64.def new file mode 100644 index 000000000000..7b2a3cb2235b --- /dev/null +++ b/contrib/llvm/include/llvm/Support/ELFRelocs/PowerPC64.def @@ -0,0 +1,88 @@ + +#ifndef ELF_RELOC +#error "ELF_RELOC must be defined" +#endif + +ELF_RELOC(R_PPC64_NONE, 0) +ELF_RELOC(R_PPC64_ADDR32, 1) +ELF_RELOC(R_PPC64_ADDR24, 2) +ELF_RELOC(R_PPC64_ADDR16, 3) +ELF_RELOC(R_PPC64_ADDR16_LO, 4) +ELF_RELOC(R_PPC64_ADDR16_HI, 5) +ELF_RELOC(R_PPC64_ADDR16_HA, 6) +ELF_RELOC(R_PPC64_ADDR14, 7) +ELF_RELOC(R_PPC64_ADDR14_BRTAKEN, 8) +ELF_RELOC(R_PPC64_ADDR14_BRNTAKEN, 9) +ELF_RELOC(R_PPC64_REL24, 10) +ELF_RELOC(R_PPC64_REL14, 11) +ELF_RELOC(R_PPC64_REL14_BRTAKEN, 12) +ELF_RELOC(R_PPC64_REL14_BRNTAKEN, 13) +ELF_RELOC(R_PPC64_GOT16, 14) +ELF_RELOC(R_PPC64_GOT16_LO, 15) +ELF_RELOC(R_PPC64_GOT16_HI, 16) +ELF_RELOC(R_PPC64_GOT16_HA, 17) +ELF_RELOC(R_PPC64_JMP_SLOT, 21) +ELF_RELOC(R_PPC64_REL32, 26) +ELF_RELOC(R_PPC64_ADDR64, 38) +ELF_RELOC(R_PPC64_ADDR16_HIGHER, 39) +ELF_RELOC(R_PPC64_ADDR16_HIGHERA, 40) +ELF_RELOC(R_PPC64_ADDR16_HIGHEST, 41) +ELF_RELOC(R_PPC64_ADDR16_HIGHESTA, 42) +ELF_RELOC(R_PPC64_REL64, 44) +ELF_RELOC(R_PPC64_TOC16, 47) +ELF_RELOC(R_PPC64_TOC16_LO, 48) +ELF_RELOC(R_PPC64_TOC16_HI, 49) +ELF_RELOC(R_PPC64_TOC16_HA, 50) +ELF_RELOC(R_PPC64_TOC, 51) +ELF_RELOC(R_PPC64_ADDR16_DS, 56) +ELF_RELOC(R_PPC64_ADDR16_LO_DS, 57) +ELF_RELOC(R_PPC64_GOT16_DS, 58) +ELF_RELOC(R_PPC64_GOT16_LO_DS, 59) +ELF_RELOC(R_PPC64_TOC16_DS, 63) +ELF_RELOC(R_PPC64_TOC16_LO_DS, 64) +ELF_RELOC(R_PPC64_TLS, 67) +ELF_RELOC(R_PPC64_DTPMOD64, 68) +ELF_RELOC(R_PPC64_TPREL16, 69) +ELF_RELOC(R_PPC64_TPREL16_LO, 70) +ELF_RELOC(R_PPC64_TPREL16_HI, 71) +ELF_RELOC(R_PPC64_TPREL16_HA, 72) +ELF_RELOC(R_PPC64_TPREL64, 73) +ELF_RELOC(R_PPC64_DTPREL16, 74) +ELF_RELOC(R_PPC64_DTPREL16_LO, 75) +ELF_RELOC(R_PPC64_DTPREL16_HI, 76) +ELF_RELOC(R_PPC64_DTPREL16_HA, 77) +ELF_RELOC(R_PPC64_DTPREL64, 78) +ELF_RELOC(R_PPC64_GOT_TLSGD16, 79) +ELF_RELOC(R_PPC64_GOT_TLSGD16_LO, 80) +ELF_RELOC(R_PPC64_GOT_TLSGD16_HI, 81) +ELF_RELOC(R_PPC64_GOT_TLSGD16_HA, 82) +ELF_RELOC(R_PPC64_GOT_TLSLD16, 83) +ELF_RELOC(R_PPC64_GOT_TLSLD16_LO, 84) +ELF_RELOC(R_PPC64_GOT_TLSLD16_HI, 85) +ELF_RELOC(R_PPC64_GOT_TLSLD16_HA, 86) +ELF_RELOC(R_PPC64_GOT_TPREL16_DS, 87) +ELF_RELOC(R_PPC64_GOT_TPREL16_LO_DS, 88) +ELF_RELOC(R_PPC64_GOT_TPREL16_HI, 89) +ELF_RELOC(R_PPC64_GOT_TPREL16_HA, 90) +ELF_RELOC(R_PPC64_GOT_DTPREL16_DS, 91) +ELF_RELOC(R_PPC64_GOT_DTPREL16_LO_DS, 92) +ELF_RELOC(R_PPC64_GOT_DTPREL16_HI, 93) +ELF_RELOC(R_PPC64_GOT_DTPREL16_HA, 94) +ELF_RELOC(R_PPC64_TPREL16_DS, 95) +ELF_RELOC(R_PPC64_TPREL16_LO_DS, 96) +ELF_RELOC(R_PPC64_TPREL16_HIGHER, 97) +ELF_RELOC(R_PPC64_TPREL16_HIGHERA, 98) +ELF_RELOC(R_PPC64_TPREL16_HIGHEST, 99) +ELF_RELOC(R_PPC64_TPREL16_HIGHESTA, 100) +ELF_RELOC(R_PPC64_DTPREL16_DS, 101) +ELF_RELOC(R_PPC64_DTPREL16_LO_DS, 102) +ELF_RELOC(R_PPC64_DTPREL16_HIGHER, 103) +ELF_RELOC(R_PPC64_DTPREL16_HIGHERA, 104) +ELF_RELOC(R_PPC64_DTPREL16_HIGHEST, 105) +ELF_RELOC(R_PPC64_DTPREL16_HIGHESTA, 106) +ELF_RELOC(R_PPC64_TLSGD, 107) +ELF_RELOC(R_PPC64_TLSLD, 108) +ELF_RELOC(R_PPC64_REL16, 249) +ELF_RELOC(R_PPC64_REL16_LO, 250) +ELF_RELOC(R_PPC64_REL16_HI, 251) +ELF_RELOC(R_PPC64_REL16_HA, 252) diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/Sparc.def b/contrib/llvm/include/llvm/Support/ELFRelocs/Sparc.def new file mode 100644 index 000000000000..d6772ea675d6 --- /dev/null +++ b/contrib/llvm/include/llvm/Support/ELFRelocs/Sparc.def @@ -0,0 +1,89 @@ + +#ifndef ELF_RELOC +#error "ELF_RELOC must be defined" +#endif + +ELF_RELOC(R_SPARC_NONE, 0) +ELF_RELOC(R_SPARC_8, 1) +ELF_RELOC(R_SPARC_16, 2) +ELF_RELOC(R_SPARC_32, 3) +ELF_RELOC(R_SPARC_DISP8, 4) +ELF_RELOC(R_SPARC_DISP16, 5) +ELF_RELOC(R_SPARC_DISP32, 6) +ELF_RELOC(R_SPARC_WDISP30, 7) +ELF_RELOC(R_SPARC_WDISP22, 8) +ELF_RELOC(R_SPARC_HI22, 9) +ELF_RELOC(R_SPARC_22, 10) +ELF_RELOC(R_SPARC_13, 11) +ELF_RELOC(R_SPARC_LO10, 12) +ELF_RELOC(R_SPARC_GOT10, 13) +ELF_RELOC(R_SPARC_GOT13, 14) +ELF_RELOC(R_SPARC_GOT22, 15) +ELF_RELOC(R_SPARC_PC10, 16) +ELF_RELOC(R_SPARC_PC22, 17) +ELF_RELOC(R_SPARC_WPLT30, 18) +ELF_RELOC(R_SPARC_COPY, 19) +ELF_RELOC(R_SPARC_GLOB_DAT, 20) +ELF_RELOC(R_SPARC_JMP_SLOT, 21) +ELF_RELOC(R_SPARC_RELATIVE, 22) +ELF_RELOC(R_SPARC_UA32, 23) +ELF_RELOC(R_SPARC_PLT32, 24) +ELF_RELOC(R_SPARC_HIPLT22, 25) +ELF_RELOC(R_SPARC_LOPLT10, 26) +ELF_RELOC(R_SPARC_PCPLT32, 27) +ELF_RELOC(R_SPARC_PCPLT22, 28) +ELF_RELOC(R_SPARC_PCPLT10, 29) +ELF_RELOC(R_SPARC_10, 30) +ELF_RELOC(R_SPARC_11, 31) +ELF_RELOC(R_SPARC_64, 32) +ELF_RELOC(R_SPARC_OLO10, 33) +ELF_RELOC(R_SPARC_HH22, 34) +ELF_RELOC(R_SPARC_HM10, 35) +ELF_RELOC(R_SPARC_LM22, 36) +ELF_RELOC(R_SPARC_PC_HH22, 37) +ELF_RELOC(R_SPARC_PC_HM10, 38) +ELF_RELOC(R_SPARC_PC_LM22, 39) +ELF_RELOC(R_SPARC_WDISP16, 40) +ELF_RELOC(R_SPARC_WDISP19, 41) +ELF_RELOC(R_SPARC_7, 43) +ELF_RELOC(R_SPARC_5, 44) +ELF_RELOC(R_SPARC_6, 45) +ELF_RELOC(R_SPARC_DISP64, 46) +ELF_RELOC(R_SPARC_PLT64, 47) +ELF_RELOC(R_SPARC_HIX22, 48) +ELF_RELOC(R_SPARC_LOX10, 49) +ELF_RELOC(R_SPARC_H44, 50) +ELF_RELOC(R_SPARC_M44, 51) +ELF_RELOC(R_SPARC_L44, 52) +ELF_RELOC(R_SPARC_REGISTER, 53) +ELF_RELOC(R_SPARC_UA64, 54) +ELF_RELOC(R_SPARC_UA16, 55) +ELF_RELOC(R_SPARC_TLS_GD_HI22, 56) +ELF_RELOC(R_SPARC_TLS_GD_LO10, 57) +ELF_RELOC(R_SPARC_TLS_GD_ADD, 58) +ELF_RELOC(R_SPARC_TLS_GD_CALL, 59) +ELF_RELOC(R_SPARC_TLS_LDM_HI22, 60) +ELF_RELOC(R_SPARC_TLS_LDM_LO10, 61) +ELF_RELOC(R_SPARC_TLS_LDM_ADD, 62) +ELF_RELOC(R_SPARC_TLS_LDM_CALL, 63) +ELF_RELOC(R_SPARC_TLS_LDO_HIX22, 64) +ELF_RELOC(R_SPARC_TLS_LDO_LOX10, 65) +ELF_RELOC(R_SPARC_TLS_LDO_ADD, 66) +ELF_RELOC(R_SPARC_TLS_IE_HI22, 67) +ELF_RELOC(R_SPARC_TLS_IE_LO10, 68) +ELF_RELOC(R_SPARC_TLS_IE_LD, 69) +ELF_RELOC(R_SPARC_TLS_IE_LDX, 70) +ELF_RELOC(R_SPARC_TLS_IE_ADD, 71) +ELF_RELOC(R_SPARC_TLS_LE_HIX22, 72) +ELF_RELOC(R_SPARC_TLS_LE_LOX10, 73) +ELF_RELOC(R_SPARC_TLS_DTPMOD32, 74) +ELF_RELOC(R_SPARC_TLS_DTPMOD64, 75) +ELF_RELOC(R_SPARC_TLS_DTPOFF32, 76) +ELF_RELOC(R_SPARC_TLS_DTPOFF64, 77) +ELF_RELOC(R_SPARC_TLS_TPOFF32, 78) +ELF_RELOC(R_SPARC_TLS_TPOFF64, 79) +ELF_RELOC(R_SPARC_GOTDATA_HIX22, 80) +ELF_RELOC(R_SPARC_GOTDATA_LOX22, 81) +ELF_RELOC(R_SPARC_GOTDATA_OP_HIX22, 82) +ELF_RELOC(R_SPARC_GOTDATA_OP_LOX22, 83) +ELF_RELOC(R_SPARC_GOTDATA_OP, 84) diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/SystemZ.def b/contrib/llvm/include/llvm/Support/ELFRelocs/SystemZ.def new file mode 100644 index 000000000000..711f94011f2c --- /dev/null +++ b/contrib/llvm/include/llvm/Support/ELFRelocs/SystemZ.def @@ -0,0 +1,67 @@ + +#ifndef ELF_RELOC +#error "ELF_RELOC must be defined" +#endif + +ELF_RELOC(R_390_NONE, 0) +ELF_RELOC(R_390_8, 1) +ELF_RELOC(R_390_12, 2) +ELF_RELOC(R_390_16, 3) +ELF_RELOC(R_390_32, 4) +ELF_RELOC(R_390_PC32, 5) +ELF_RELOC(R_390_GOT12, 6) +ELF_RELOC(R_390_GOT32, 7) +ELF_RELOC(R_390_PLT32, 8) +ELF_RELOC(R_390_COPY, 9) +ELF_RELOC(R_390_GLOB_DAT, 10) +ELF_RELOC(R_390_JMP_SLOT, 11) +ELF_RELOC(R_390_RELATIVE, 12) +ELF_RELOC(R_390_GOTOFF, 13) +ELF_RELOC(R_390_GOTPC, 14) +ELF_RELOC(R_390_GOT16, 15) +ELF_RELOC(R_390_PC16, 16) +ELF_RELOC(R_390_PC16DBL, 17) +ELF_RELOC(R_390_PLT16DBL, 18) +ELF_RELOC(R_390_PC32DBL, 19) +ELF_RELOC(R_390_PLT32DBL, 20) +ELF_RELOC(R_390_GOTPCDBL, 21) +ELF_RELOC(R_390_64, 22) +ELF_RELOC(R_390_PC64, 23) +ELF_RELOC(R_390_GOT64, 24) +ELF_RELOC(R_390_PLT64, 25) +ELF_RELOC(R_390_GOTENT, 26) +ELF_RELOC(R_390_GOTOFF16, 27) +ELF_RELOC(R_390_GOTOFF64, 28) +ELF_RELOC(R_390_GOTPLT12, 29) +ELF_RELOC(R_390_GOTPLT16, 30) +ELF_RELOC(R_390_GOTPLT32, 31) +ELF_RELOC(R_390_GOTPLT64, 32) +ELF_RELOC(R_390_GOTPLTENT, 33) +ELF_RELOC(R_390_PLTOFF16, 34) +ELF_RELOC(R_390_PLTOFF32, 35) +ELF_RELOC(R_390_PLTOFF64, 36) +ELF_RELOC(R_390_TLS_LOAD, 37) +ELF_RELOC(R_390_TLS_GDCALL, 38) +ELF_RELOC(R_390_TLS_LDCALL, 39) +ELF_RELOC(R_390_TLS_GD32, 40) +ELF_RELOC(R_390_TLS_GD64, 41) +ELF_RELOC(R_390_TLS_GOTIE12, 42) +ELF_RELOC(R_390_TLS_GOTIE32, 43) +ELF_RELOC(R_390_TLS_GOTIE64, 44) +ELF_RELOC(R_390_TLS_LDM32, 45) +ELF_RELOC(R_390_TLS_LDM64, 46) +ELF_RELOC(R_390_TLS_IE32, 47) +ELF_RELOC(R_390_TLS_IE64, 48) +ELF_RELOC(R_390_TLS_IEENT, 49) +ELF_RELOC(R_390_TLS_LE32, 50) +ELF_RELOC(R_390_TLS_LE64, 51) +ELF_RELOC(R_390_TLS_LDO32, 52) +ELF_RELOC(R_390_TLS_LDO64, 53) +ELF_RELOC(R_390_TLS_DTPMOD, 54) +ELF_RELOC(R_390_TLS_DTPOFF, 55) +ELF_RELOC(R_390_TLS_TPOFF, 56) +ELF_RELOC(R_390_20, 57) +ELF_RELOC(R_390_GOT20, 58) +ELF_RELOC(R_390_GOTPLT20, 59) +ELF_RELOC(R_390_TLS_GOTIE20, 60) +ELF_RELOC(R_390_IRELATIVE, 61) diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/i386.def b/contrib/llvm/include/llvm/Support/ELFRelocs/i386.def new file mode 100644 index 000000000000..45eae7fe426b --- /dev/null +++ b/contrib/llvm/include/llvm/Support/ELFRelocs/i386.def @@ -0,0 +1,47 @@ + +#ifndef ELF_RELOC +#error "ELF_RELOC must be defined" +#endif + +// TODO: this is just a subset +ELF_RELOC(R_386_NONE, 0) +ELF_RELOC(R_386_32, 1) +ELF_RELOC(R_386_PC32, 2) +ELF_RELOC(R_386_GOT32, 3) +ELF_RELOC(R_386_PLT32, 4) +ELF_RELOC(R_386_COPY, 5) +ELF_RELOC(R_386_GLOB_DAT, 6) +ELF_RELOC(R_386_JUMP_SLOT, 7) +ELF_RELOC(R_386_RELATIVE, 8) +ELF_RELOC(R_386_GOTOFF, 9) +ELF_RELOC(R_386_GOTPC, 10) +ELF_RELOC(R_386_32PLT, 11) +ELF_RELOC(R_386_TLS_TPOFF, 14) +ELF_RELOC(R_386_TLS_IE, 15) +ELF_RELOC(R_386_TLS_GOTIE, 16) +ELF_RELOC(R_386_TLS_LE, 17) +ELF_RELOC(R_386_TLS_GD, 18) +ELF_RELOC(R_386_TLS_LDM, 19) +ELF_RELOC(R_386_16, 20) +ELF_RELOC(R_386_PC16, 21) +ELF_RELOC(R_386_8, 22) +ELF_RELOC(R_386_PC8, 23) +ELF_RELOC(R_386_TLS_GD_32, 24) +ELF_RELOC(R_386_TLS_GD_PUSH, 25) +ELF_RELOC(R_386_TLS_GD_CALL, 26) +ELF_RELOC(R_386_TLS_GD_POP, 27) +ELF_RELOC(R_386_TLS_LDM_32, 28) +ELF_RELOC(R_386_TLS_LDM_PUSH, 29) +ELF_RELOC(R_386_TLS_LDM_CALL, 30) +ELF_RELOC(R_386_TLS_LDM_POP, 31) +ELF_RELOC(R_386_TLS_LDO_32, 32) +ELF_RELOC(R_386_TLS_IE_32, 33) +ELF_RELOC(R_386_TLS_LE_32, 34) +ELF_RELOC(R_386_TLS_DTPMOD32, 35) +ELF_RELOC(R_386_TLS_DTPOFF32, 36) +ELF_RELOC(R_386_TLS_TPOFF32, 37) +ELF_RELOC(R_386_TLS_GOTDESC, 39) +ELF_RELOC(R_386_TLS_DESC_CALL, 40) +ELF_RELOC(R_386_TLS_DESC, 41) +ELF_RELOC(R_386_IRELATIVE, 42) +ELF_RELOC(R_386_NUM, 43) diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/x86_64.def b/contrib/llvm/include/llvm/Support/ELFRelocs/x86_64.def new file mode 100644 index 000000000000..36ad0618eb2d --- /dev/null +++ b/contrib/llvm/include/llvm/Support/ELFRelocs/x86_64.def @@ -0,0 +1,44 @@ + +#ifndef ELF_RELOC +#error "ELF_RELOC must be defined" +#endif + +ELF_RELOC(R_X86_64_NONE, 0) +ELF_RELOC(R_X86_64_64, 1) +ELF_RELOC(R_X86_64_PC32, 2) +ELF_RELOC(R_X86_64_GOT32, 3) +ELF_RELOC(R_X86_64_PLT32, 4) +ELF_RELOC(R_X86_64_COPY, 5) +ELF_RELOC(R_X86_64_GLOB_DAT, 6) +ELF_RELOC(R_X86_64_JUMP_SLOT, 7) +ELF_RELOC(R_X86_64_RELATIVE, 8) +ELF_RELOC(R_X86_64_GOTPCREL, 9) +ELF_RELOC(R_X86_64_32, 10) +ELF_RELOC(R_X86_64_32S, 11) +ELF_RELOC(R_X86_64_16, 12) +ELF_RELOC(R_X86_64_PC16, 13) +ELF_RELOC(R_X86_64_8, 14) +ELF_RELOC(R_X86_64_PC8, 15) +ELF_RELOC(R_X86_64_DTPMOD64, 16) +ELF_RELOC(R_X86_64_DTPOFF64, 17) +ELF_RELOC(R_X86_64_TPOFF64, 18) +ELF_RELOC(R_X86_64_TLSGD, 19) +ELF_RELOC(R_X86_64_TLSLD, 20) +ELF_RELOC(R_X86_64_DTPOFF32, 21) +ELF_RELOC(R_X86_64_GOTTPOFF, 22) +ELF_RELOC(R_X86_64_TPOFF32, 23) +ELF_RELOC(R_X86_64_PC64, 24) +ELF_RELOC(R_X86_64_GOTOFF64, 25) +ELF_RELOC(R_X86_64_GOTPC32, 26) +ELF_RELOC(R_X86_64_GOT64, 27) +ELF_RELOC(R_X86_64_GOTPCREL64, 28) +ELF_RELOC(R_X86_64_GOTPC64, 29) +ELF_RELOC(R_X86_64_GOTPLT64, 30) +ELF_RELOC(R_X86_64_PLTOFF64, 31) +ELF_RELOC(R_X86_64_SIZE32, 32) +ELF_RELOC(R_X86_64_SIZE64, 33) +ELF_RELOC(R_X86_64_GOTPC32_TLSDESC, 34) +ELF_RELOC(R_X86_64_TLSDESC_CALL, 35) +ELF_RELOC(R_X86_64_TLSDESC, 36) +ELF_RELOC(R_X86_64_IRELATIVE, 37) + diff --git a/contrib/llvm/include/llvm/Support/Endian.h b/contrib/llvm/include/llvm/Support/Endian.h index 455d0fc241f2..47b82fdc4975 100644 --- a/contrib/llvm/include/llvm/Support/Endian.h +++ b/contrib/llvm/include/llvm/Support/Endian.h @@ -93,15 +93,40 @@ struct packed_endian_specific_integral { (void*)Value.buffer, newValue); } + packed_endian_specific_integral &operator+=(value_type newValue) { + *this = *this + newValue; + return *this; + } + + packed_endian_specific_integral &operator-=(value_type newValue) { + *this = *this - newValue; + return *this; + } + private: AlignedCharArray<PickAlignment<value_type, alignment>::value, sizeof(value_type)> Value; + +public: + struct ref { + explicit ref(void *Ptr) : Ptr(Ptr) {} + + operator value_type() const { + return endian::read<value_type, endian, alignment>(Ptr); + } + + void operator=(value_type NewValue) { + endian::write<value_type, endian, alignment>(Ptr, NewValue); + } + + private: + void *Ptr; + }; }; + } // end namespace detail typedef detail::packed_endian_specific_integral - <uint8_t, little, unaligned> ulittle8_t; -typedef detail::packed_endian_specific_integral <uint16_t, little, unaligned> ulittle16_t; typedef detail::packed_endian_specific_integral <uint32_t, little, unaligned> ulittle32_t; @@ -109,8 +134,6 @@ typedef detail::packed_endian_specific_integral <uint64_t, little, unaligned> ulittle64_t; typedef detail::packed_endian_specific_integral - <int8_t, little, unaligned> little8_t; -typedef detail::packed_endian_specific_integral <int16_t, little, unaligned> little16_t; typedef detail::packed_endian_specific_integral <int32_t, little, unaligned> little32_t; @@ -118,8 +141,6 @@ typedef detail::packed_endian_specific_integral <int64_t, little, unaligned> little64_t; typedef detail::packed_endian_specific_integral - <uint8_t, little, aligned> aligned_ulittle8_t; -typedef detail::packed_endian_specific_integral <uint16_t, little, aligned> aligned_ulittle16_t; typedef detail::packed_endian_specific_integral <uint32_t, little, aligned> aligned_ulittle32_t; @@ -127,8 +148,6 @@ typedef detail::packed_endian_specific_integral <uint64_t, little, aligned> aligned_ulittle64_t; typedef detail::packed_endian_specific_integral - <int8_t, little, aligned> aligned_little8_t; -typedef detail::packed_endian_specific_integral <int16_t, little, aligned> aligned_little16_t; typedef detail::packed_endian_specific_integral <int32_t, little, aligned> aligned_little32_t; @@ -136,8 +155,6 @@ typedef detail::packed_endian_specific_integral <int64_t, little, aligned> aligned_little64_t; typedef detail::packed_endian_specific_integral - <uint8_t, big, unaligned> ubig8_t; -typedef detail::packed_endian_specific_integral <uint16_t, big, unaligned> ubig16_t; typedef detail::packed_endian_specific_integral <uint32_t, big, unaligned> ubig32_t; @@ -145,8 +162,6 @@ typedef detail::packed_endian_specific_integral <uint64_t, big, unaligned> ubig64_t; typedef detail::packed_endian_specific_integral - <int8_t, big, unaligned> big8_t; -typedef detail::packed_endian_specific_integral <int16_t, big, unaligned> big16_t; typedef detail::packed_endian_specific_integral <int32_t, big, unaligned> big32_t; @@ -154,8 +169,6 @@ typedef detail::packed_endian_specific_integral <int64_t, big, unaligned> big64_t; typedef detail::packed_endian_specific_integral - <uint8_t, big, aligned> aligned_ubig8_t; -typedef detail::packed_endian_specific_integral <uint16_t, big, aligned> aligned_ubig16_t; typedef detail::packed_endian_specific_integral <uint32_t, big, aligned> aligned_ubig32_t; @@ -163,8 +176,6 @@ typedef detail::packed_endian_specific_integral <uint64_t, big, aligned> aligned_ubig64_t; typedef detail::packed_endian_specific_integral - <int8_t, big, aligned> aligned_big8_t; -typedef detail::packed_endian_specific_integral <int16_t, big, aligned> aligned_big16_t; typedef detail::packed_endian_specific_integral <int32_t, big, aligned> aligned_big32_t; diff --git a/contrib/llvm/include/llvm/Support/EndianStream.h b/contrib/llvm/include/llvm/Support/EndianStream.h index 89c66d3b8480..94f372f020b4 100644 --- a/contrib/llvm/include/llvm/Support/EndianStream.h +++ b/contrib/llvm/include/llvm/Support/EndianStream.h @@ -12,11 +12,11 @@ // //===----------------------------------------------------------------------===// -#ifndef _LLVM_SUPPORT_ENDIAN_STREAM_H_ -#define _LLVM_SUPPORT_ENDIAN_STREAM_H_ +#ifndef LLVM_SUPPORT_ENDIANSTREAM_H +#define LLVM_SUPPORT_ENDIANSTREAM_H -#include <llvm/Support/Endian.h> -#include <llvm/Support/raw_ostream.h> +#include "llvm/Support/Endian.h" +#include "llvm/Support/raw_ostream.h" namespace llvm { namespace support { @@ -36,4 +36,4 @@ template <endianness endian> struct Writer { } // end namespace support } // end namespace llvm -#endif // _LLVM_SUPPORT_ENDIAN_STREAM_H_ +#endif diff --git a/contrib/llvm/include/llvm/Support/ErrorOr.h b/contrib/llvm/include/llvm/Support/ErrorOr.h index 0742a2d06f71..84763deea0f9 100644 --- a/contrib/llvm/include/llvm/Support/ErrorOr.h +++ b/contrib/llvm/include/llvm/Support/ErrorOr.h @@ -13,8 +13,8 @@ /// //===----------------------------------------------------------------------===// -#ifndef LLVM_SUPPORT_ERROR_OR_H -#define LLVM_SUPPORT_ERROR_OR_H +#ifndef LLVM_SUPPORT_ERROROR_H +#define LLVM_SUPPORT_ERROROR_H #include "llvm/ADT/PointerIntPair.h" #include "llvm/Support/AlignOf.h" @@ -68,9 +68,9 @@ public: /// \endcode /// /// -/// An implicit conversion to bool provides a way to check if there was an -/// error. The unary * and -> operators provide pointer like access to the -/// value. Accessing the value when there is an error has undefined behavior. +/// Implicit conversion to bool returns true if there is a usable value. The +/// unary * and -> operators provide pointer like access to the value. Accessing +/// the value when there is an error has undefined behavior. /// /// When T is a reference type the behaivor is slightly different. The reference /// is held in a std::reference_wrapper<std::remove_reference<T>::type>, and @@ -115,19 +115,19 @@ public: } template <class OtherT> - ErrorOr(const ErrorOr<OtherT> &Other) { + ErrorOr( + const ErrorOr<OtherT> &Other, + typename std::enable_if<std::is_convertible<OtherT, T>::value>::type * = + nullptr) { copyConstruct(Other); } - ErrorOr &operator =(const ErrorOr &Other) { - copyAssign(Other); - return *this; - } - template <class OtherT> - ErrorOr &operator =(const ErrorOr<OtherT> &Other) { - copyAssign(Other); - return *this; + explicit ErrorOr( + const ErrorOr<OtherT> &Other, + typename std::enable_if< + !std::is_convertible<OtherT, const T &>::value>::type * = nullptr) { + copyConstruct(Other); } ErrorOr(ErrorOr &&Other) { @@ -135,17 +135,29 @@ public: } template <class OtherT> - ErrorOr(ErrorOr<OtherT> &&Other) { + ErrorOr( + ErrorOr<OtherT> &&Other, + typename std::enable_if<std::is_convertible<OtherT, T>::value>::type * = + nullptr) { moveConstruct(std::move(Other)); } - ErrorOr &operator =(ErrorOr &&Other) { - moveAssign(std::move(Other)); + // This might eventually need SFINAE but it's more complex than is_convertible + // & I'm too lazy to write it right now. + template <class OtherT> + explicit ErrorOr( + ErrorOr<OtherT> &&Other, + typename std::enable_if<!std::is_convertible<OtherT, T>::value>::type * = + nullptr) { + moveConstruct(std::move(Other)); + } + + ErrorOr &operator=(const ErrorOr &Other) { + copyAssign(Other); return *this; } - template <class OtherT> - ErrorOr &operator =(ErrorOr<OtherT> &&Other) { + ErrorOr &operator=(ErrorOr &&Other) { moveAssign(std::move(Other)); return *this; } @@ -161,7 +173,7 @@ public: } reference get() { return *getStorage(); } - const_reference get() const { return const_cast<ErrorOr<T> >(this)->get(); } + const_reference get() const { return const_cast<ErrorOr<T> *>(this)->get(); } std::error_code getError() const { return HasError ? *getErrorStorage() : std::error_code(); diff --git a/contrib/llvm/include/llvm/Support/FileOutputBuffer.h b/contrib/llvm/include/llvm/Support/FileOutputBuffer.h index 0a9a97995156..9f02a16e3d65 100644 --- a/contrib/llvm/include/llvm/Support/FileOutputBuffer.h +++ b/contrib/llvm/include/llvm/Support/FileOutputBuffer.h @@ -66,7 +66,7 @@ public: /// is called, the file is deleted in the destructor. The optional parameter /// is used if it turns out you want the file size to be smaller than /// initially requested. - std::error_code commit(int64_t NewSmallerSize = -1); + std::error_code commit(); /// If this object was previously committed, the destructor just deletes /// this object. If this object was not committed, the destructor @@ -77,7 +77,7 @@ private: FileOutputBuffer(const FileOutputBuffer &) LLVM_DELETED_FUNCTION; FileOutputBuffer &operator=(const FileOutputBuffer &) LLVM_DELETED_FUNCTION; - FileOutputBuffer(llvm::sys::fs::mapped_file_region *R, + FileOutputBuffer(std::unique_ptr<llvm::sys::fs::mapped_file_region> R, StringRef Path, StringRef TempPath); std::unique_ptr<llvm::sys::fs::mapped_file_region> Region; diff --git a/contrib/llvm/include/llvm/Support/FileSystem.h b/contrib/llvm/include/llvm/Support/FileSystem.h index 556701c3ba34..b60c1b07043b 100644 --- a/contrib/llvm/include/llvm/Support/FileSystem.h +++ b/contrib/llvm/include/llvm/Support/FileSystem.h @@ -226,6 +226,7 @@ struct file_magic { unknown = 0, ///< Unrecognized file bitcode, ///< Bitcode file archive, ///< ar style archive file + elf, ///< ELF Unknown type elf_relocatable, ///< ELF Relocatable object file elf_executable, ///< ELF Executable image elf_shared_object, ///< ELF dynamically linked shared lib @@ -276,14 +277,6 @@ private: /// platform-specific error_code. std::error_code make_absolute(SmallVectorImpl<char> &path); -/// @brief Normalize path separators in \a Path -/// -/// If the path contains any '\' separators, they are transformed into '/'. -/// This is particularly useful when cross-compiling Windows on Linux, but is -/// safe to invoke on Windows, which accepts both characters as a path -/// separator. -std::error_code normalize_separators(SmallVectorImpl<char> &Path); - /// @brief Create all the non-existent directories in path. /// /// @param path Directories to create. @@ -343,11 +336,11 @@ std::error_code copy_file(const Twine &From, const Twine &To); /// @brief Resize path to size. File is resized as if by POSIX truncate(). /// -/// @param path Input path. -/// @param size Size to resize to. +/// @param FD Input file descriptor. +/// @param Size Size to resize to. /// @returns errc::success if \a path has been resized to \a size, otherwise a /// platform-specific error_code. -std::error_code resize_file(const Twine &path, uint64_t size); +std::error_code resize_file(int FD, uint64_t Size); /// @} /// @name Physical Observers @@ -360,33 +353,38 @@ std::error_code resize_file(const Twine &path, uint64_t size); /// not. bool exists(file_status status); -/// @brief Does file exist? +enum class AccessMode { Exist, Write, Execute }; + +/// @brief Can the file be accessed? /// -/// @param path Input path. -/// @param result Set to true if the file represented by status exists, false if -/// it does not. Undefined otherwise. -/// @returns errc::success if result has been successfully set, otherwise a +/// @param Path Input path. +/// @returns errc::success if the path can be accessed, otherwise a /// platform-specific error_code. -std::error_code exists(const Twine &path, bool &result); +std::error_code access(const Twine &Path, AccessMode Mode); -/// @brief Simpler version of exists for clients that don't need to -/// differentiate between an error and false. -inline bool exists(const Twine &path) { - bool result; - return !exists(path, result) && result; +/// @brief Does file exist? +/// +/// @param Path Input path. +/// @returns True if it exists, false otherwise. +inline bool exists(const Twine &Path) { + return !access(Path, AccessMode::Exist); } /// @brief Can we execute this file? /// /// @param Path Input path. /// @returns True if we can execute it, false otherwise. -bool can_execute(const Twine &Path); +inline bool can_execute(const Twine &Path) { + return !access(Path, AccessMode::Execute); +} /// @brief Can we write this file? /// /// @param Path Input path. /// @returns True if we can write to it, false otherwise. -bool can_write(const Twine &Path); +inline bool can_write(const Twine &Path) { + return !access(Path, AccessMode::Write); +} /// @brief Do file_status's represent the same thing? /// @@ -639,49 +637,20 @@ public: private: /// Platform-specific mapping state. - mapmode Mode; uint64_t Size; void *Mapping; -#ifdef LLVM_ON_WIN32 - int FileDescriptor; - void *FileHandle; - void *FileMappingHandle; -#endif - std::error_code init(int FD, bool CloseFD, uint64_t Offset); + std::error_code init(int FD, uint64_t Offset, mapmode Mode); public: - typedef char char_type; - - mapped_file_region(mapped_file_region&&); - mapped_file_region &operator =(mapped_file_region&&); - - /// Construct a mapped_file_region at \a path starting at \a offset of length - /// \a length and with access \a mode. - /// - /// \param path Path to the file to map. If it does not exist it will be - /// created. - /// \param mode How to map the memory. - /// \param length Number of bytes to map in starting at \a offset. If the file - /// is shorter than this, it will be extended. If \a length is - /// 0, the entire file will be mapped. - /// \param offset Byte offset from the beginning of the file where the map - /// should begin. Must be a multiple of - /// mapped_file_region::alignment(). - /// \param ec This is set to errc::success if the map was constructed - /// successfully. Otherwise it is set to a platform dependent error. - mapped_file_region(const Twine &path, mapmode mode, uint64_t length, - uint64_t offset, std::error_code &ec); - /// \param fd An open file descriptor to map. mapped_file_region takes /// ownership if closefd is true. It must have been opended in the correct /// mode. - mapped_file_region(int fd, bool closefd, mapmode mode, uint64_t length, - uint64_t offset, std::error_code &ec); + mapped_file_region(int fd, mapmode mode, uint64_t length, uint64_t offset, + std::error_code &ec); ~mapped_file_region(); - mapmode flags() const; uint64_t size() const; char *data() const; diff --git a/contrib/llvm/include/llvm/Support/Format.h b/contrib/llvm/include/llvm/Support/Format.h index b713cc72e852..5d599e96ec3a 100644 --- a/contrib/llvm/include/llvm/Support/Format.h +++ b/contrib/llvm/include/llvm/Support/Format.h @@ -23,6 +23,8 @@ #ifndef LLVM_SUPPORT_FORMAT_H #define LLVM_SUPPORT_FORMAT_H +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/DataTypes.h" #include <cassert> #include <cstdio> #ifdef _MSC_VER @@ -41,6 +43,7 @@ namespace llvm { class format_object_base { protected: const char *Fmt; + ~format_object_base() {} // Disallow polymorphic deletion. virtual void home(); // Out of line virtual method. /// Call snprintf() for this object, on the given buffer and size. @@ -48,7 +51,6 @@ protected: public: format_object_base(const char *fmt) : Fmt(fmt) {} - virtual ~format_object_base() {} /// Format the object into the specified buffer. On success, this returns /// the length of the formatted string. If the buffer is too small, this @@ -79,7 +81,7 @@ public: /// returns whether or not it is big enough. template <typename T> -class format_object1 : public format_object_base { +class format_object1 final : public format_object_base { T Val; public: format_object1(const char *fmt, const T &val) @@ -92,7 +94,7 @@ public: }; template <typename T1, typename T2> -class format_object2 : public format_object_base { +class format_object2 final : public format_object_base { T1 Val1; T2 Val2; public: @@ -106,7 +108,7 @@ public: }; template <typename T1, typename T2, typename T3> -class format_object3 : public format_object_base { +class format_object3 final : public format_object_base { T1 Val1; T2 Val2; T3 Val3; @@ -121,7 +123,7 @@ public: }; template <typename T1, typename T2, typename T3, typename T4> -class format_object4 : public format_object_base { +class format_object4 final : public format_object_base { T1 Val1; T2 Val2; T3 Val3; @@ -138,7 +140,7 @@ public: }; template <typename T1, typename T2, typename T3, typename T4, typename T5> -class format_object5 : public format_object_base { +class format_object5 final : public format_object_base { T1 Val1; T2 Val2; T3 Val3; @@ -158,7 +160,7 @@ public: template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6> -class format_object6 : public format_object_base { +class format_object6 final : public format_object_base { T1 Val1; T2 Val2; T3 Val3; @@ -225,6 +227,66 @@ format(const char *Fmt, const T1 &Val1, const T2 &Val2, const T3 &Val3, Val5, Val6); } +/// This is a helper class used for left_justify() and right_justify(). +class FormattedString { + StringRef Str; + unsigned Width; + bool RightJustify; + friend class raw_ostream; +public: + FormattedString(StringRef S, unsigned W, bool R) + : Str(S), Width(W), RightJustify(R) { } +}; + +/// left_justify - append spaces after string so total output is +/// \p Width characters. If \p Str is larger that \p Width, full string +/// is written with no padding. +inline FormattedString left_justify(StringRef Str, unsigned Width) { + return FormattedString(Str, Width, false); +} + +/// right_justify - add spaces before string so total output is +/// \p Width characters. If \p Str is larger that \p Width, full string +/// is written with no padding. +inline FormattedString right_justify(StringRef Str, unsigned Width) { + return FormattedString(Str, Width, true); +} + +/// This is a helper class used for format_hex() and format_decimal(). +class FormattedNumber { + uint64_t HexValue; + int64_t DecValue; + unsigned Width; + bool Hex; + bool Upper; + friend class raw_ostream; +public: + FormattedNumber(uint64_t HV, int64_t DV, unsigned W, bool H, bool U) + : HexValue(HV), DecValue(DV), Width(W), Hex(H), Upper(U) { } +}; + +/// format_hex - Output \p N as a fixed width hexadecimal. If number will not +/// fit in width, full number is still printed. Examples: +/// OS << format_hex(255, 4) => 0xff +/// OS << format_hex(255, 4, true) => 0xFF +/// OS << format_hex(255, 6) => 0x00ff +/// OS << format_hex(255, 2) => 0xff +inline FormattedNumber format_hex(uint64_t N, unsigned Width, bool Upper=false) { + assert(Width <= 18 && "hex width must be <= 18"); + return FormattedNumber(N, 0, Width, true, Upper); +} + +/// format_decimal - Output \p N as a right justified, fixed-width decimal. If +/// number will not fit in width, full number is still printed. Examples: +/// OS << format_decimal(0, 5) => " 0" +/// OS << format_decimal(255, 5) => " 255" +/// OS << format_decimal(-1, 3) => " -1" +/// OS << format_decimal(12345, 3) => "12345" +inline FormattedNumber format_decimal(int64_t N, unsigned Width) { + return FormattedNumber(0, N, Width, false, false); +} + + } // end namespace llvm #endif diff --git a/contrib/llvm/include/llvm/Support/GCOV.h b/contrib/llvm/include/llvm/Support/GCOV.h index 0cb6cfd62ccb..e378602c7bb3 100644 --- a/contrib/llvm/include/llvm/Support/GCOV.h +++ b/contrib/llvm/include/llvm/Support/GCOV.h @@ -100,7 +100,7 @@ public: /// cursor and return true otherwise return false. bool readFunctionTag() { StringRef Tag = Buffer->getBuffer().slice(Cursor, Cursor+4); - if (Tag.empty() || + if (Tag.empty() || Tag[0] != '\0' || Tag[1] != '\0' || Tag[2] != '\0' || Tag[3] != '\1') { return false; @@ -113,7 +113,7 @@ public: /// cursor and return true otherwise return false. bool readBlockTag() { StringRef Tag = Buffer->getBuffer().slice(Cursor, Cursor+4); - if (Tag.empty() || + if (Tag.empty() || Tag[0] != '\0' || Tag[1] != '\0' || Tag[2] != '\x41' || Tag[3] != '\x01') { return false; @@ -126,7 +126,7 @@ public: /// cursor and return true otherwise return false. bool readEdgeTag() { StringRef Tag = Buffer->getBuffer().slice(Cursor, Cursor+4); - if (Tag.empty() || + if (Tag.empty() || Tag[0] != '\0' || Tag[1] != '\0' || Tag[2] != '\x43' || Tag[3] != '\x01') { return false; @@ -139,7 +139,7 @@ public: /// cursor and return true otherwise return false. bool readLineTag() { StringRef Tag = Buffer->getBuffer().slice(Cursor, Cursor+4); - if (Tag.empty() || + if (Tag.empty() || Tag[0] != '\0' || Tag[1] != '\0' || Tag[2] != '\x45' || Tag[3] != '\x01') { return false; @@ -152,7 +152,7 @@ public: /// cursor and return true otherwise return false. bool readArcTag() { StringRef Tag = Buffer->getBuffer().slice(Cursor, Cursor+4); - if (Tag.empty() || + if (Tag.empty() || Tag[0] != '\0' || Tag[1] != '\0' || Tag[2] != '\xa1' || Tag[3] != '\1') { return false; diff --git a/contrib/llvm/include/llvm/Support/GenericDomTree.h b/contrib/llvm/include/llvm/Support/GenericDomTree.h index 876ab6ec71a5..fde56135a962 100644 --- a/contrib/llvm/include/llvm/Support/GenericDomTree.h +++ b/contrib/llvm/include/llvm/Support/GenericDomTree.h @@ -15,8 +15,8 @@ /// //===----------------------------------------------------------------------===// -#ifndef LLVM_SUPPORT_GENERIC_DOM_TREE_H -#define LLVM_SUPPORT_GENERIC_DOM_TREE_H +#ifndef LLVM_SUPPORT_GENERICDOMTREE_H +#define LLVM_SUPPORT_GENERICDOMTREE_H #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/DepthFirstIterator.h" @@ -29,76 +29,78 @@ namespace llvm { -//===----------------------------------------------------------------------===// -/// DominatorBase - Base class that other, more interesting dominator analyses +/// \brief Base class that other, more interesting dominator analyses /// inherit from. -/// -template <class NodeT> -class DominatorBase { +template <class NodeT> class DominatorBase { protected: - std::vector<NodeT*> Roots; - const bool IsPostDominators; - inline explicit DominatorBase(bool isPostDom) : - Roots(), IsPostDominators(isPostDom) {} -public: + std::vector<NodeT *> Roots; + bool IsPostDominators; + explicit DominatorBase(bool isPostDom) + : Roots(), IsPostDominators(isPostDom) {} + DominatorBase(DominatorBase &&Arg) + : Roots(std::move(Arg.Roots)), + IsPostDominators(std::move(Arg.IsPostDominators)) { + Arg.Roots.clear(); + } + DominatorBase &operator=(DominatorBase &&RHS) { + Roots = std::move(RHS.Roots); + IsPostDominators = std::move(RHS.IsPostDominators); + RHS.Roots.clear(); + return *this; + } +public: /// getRoots - Return the root blocks of the current CFG. This may include /// multiple blocks if we are computing post dominators. For forward /// dominators, this will always be a single block (the entry node). /// - inline const std::vector<NodeT*> &getRoots() const { return Roots; } + const std::vector<NodeT *> &getRoots() const { return Roots; } /// isPostDominator - Returns true if analysis based of postdoms /// bool isPostDominator() const { return IsPostDominators; } }; - -//===----------------------------------------------------------------------===// -// DomTreeNodeBase - Dominator Tree Node -template<class NodeT> class DominatorTreeBase; +template <class NodeT> class DominatorTreeBase; struct PostDominatorTree; -template <class NodeT> -class DomTreeNodeBase { +/// \brief Base class for the actual dominator tree node. +template <class NodeT> class DomTreeNodeBase { NodeT *TheBB; DomTreeNodeBase<NodeT> *IDom; std::vector<DomTreeNodeBase<NodeT> *> Children; mutable int DFSNumIn, DFSNumOut; - template<class N> friend class DominatorTreeBase; + template <class N> friend class DominatorTreeBase; friend struct PostDominatorTree; + public: typedef typename std::vector<DomTreeNodeBase<NodeT> *>::iterator iterator; typedef typename std::vector<DomTreeNodeBase<NodeT> *>::const_iterator - const_iterator; + const_iterator; - iterator begin() { return Children.begin(); } - iterator end() { return Children.end(); } + iterator begin() { return Children.begin(); } + iterator end() { return Children.end(); } const_iterator begin() const { return Children.begin(); } - const_iterator end() const { return Children.end(); } + const_iterator end() const { return Children.end(); } NodeT *getBlock() const { return TheBB; } DomTreeNodeBase<NodeT> *getIDom() const { return IDom; } - const std::vector<DomTreeNodeBase<NodeT>*> &getChildren() const { + const std::vector<DomTreeNodeBase<NodeT> *> &getChildren() const { return Children; } DomTreeNodeBase(NodeT *BB, DomTreeNodeBase<NodeT> *iDom) - : TheBB(BB), IDom(iDom), DFSNumIn(-1), DFSNumOut(-1) { } + : TheBB(BB), IDom(iDom), DFSNumIn(-1), DFSNumOut(-1) {} DomTreeNodeBase<NodeT> *addChild(DomTreeNodeBase<NodeT> *C) { Children.push_back(C); return C; } - size_t getNumChildren() const { - return Children.size(); - } + size_t getNumChildren() const { return Children.size(); } - void clearAllChildren() { - Children.clear(); - } + void clearAllChildren() { Children.clear(); } bool compare(const DomTreeNodeBase<NodeT> *Other) const { if (getNumChildren() != Other->getNumChildren()) @@ -121,8 +123,8 @@ public: void setIDom(DomTreeNodeBase<NodeT> *NewIDom) { assert(IDom && "No immediate dominator?"); if (IDom != NewIDom) { - typename std::vector<DomTreeNodeBase<NodeT>*>::iterator I = - std::find(IDom->Children.begin(), IDom->Children.end(), this); + typename std::vector<DomTreeNodeBase<NodeT> *>::iterator I = + std::find(IDom->Children.begin(), IDom->Children.end(), this); assert(I != IDom->Children.end() && "Not in immediate dominator children set!"); // I am no longer your child... @@ -138,18 +140,18 @@ public: /// not call them. unsigned getDFSNumIn() const { return DFSNumIn; } unsigned getDFSNumOut() const { return DFSNumOut; } + private: // Return true if this node is dominated by other. Use this only if DFS info // is valid. bool DominatedBy(const DomTreeNodeBase<NodeT> *other) const { return this->DFSNumIn >= other->DFSNumIn && - this->DFSNumOut <= other->DFSNumOut; + this->DFSNumOut <= other->DFSNumOut; } }; -template<class NodeT> -inline raw_ostream &operator<<(raw_ostream &o, - const DomTreeNodeBase<NodeT> *Node) { +template <class NodeT> +raw_ostream &operator<<(raw_ostream &o, const DomTreeNodeBase<NodeT> *Node) { if (Node->getBlock()) Node->getBlock()->printAsOperand(o, false); else @@ -160,25 +162,29 @@ inline raw_ostream &operator<<(raw_ostream &o, return o << "\n"; } -template<class NodeT> -inline void PrintDomTree(const DomTreeNodeBase<NodeT> *N, raw_ostream &o, - unsigned Lev) { - o.indent(2*Lev) << "[" << Lev << "] " << N; +template <class NodeT> +void PrintDomTree(const DomTreeNodeBase<NodeT> *N, raw_ostream &o, + unsigned Lev) { + o.indent(2 * Lev) << "[" << Lev << "] " << N; for (typename DomTreeNodeBase<NodeT>::const_iterator I = N->begin(), - E = N->end(); I != E; ++I) - PrintDomTree<NodeT>(*I, o, Lev+1); + E = N->end(); + I != E; ++I) + PrintDomTree<NodeT>(*I, o, Lev + 1); } -//===----------------------------------------------------------------------===// -/// DominatorTree - Calculate the immediate dominator tree for a function. -/// +// The calculate routine is provided in a separate header but referenced here. +template <class FuncT, class N> +void Calculate(DominatorTreeBase<typename GraphTraits<N>::NodeType> &DT, + FuncT &F); -template<class FuncT, class N> -void Calculate(DominatorTreeBase<typename GraphTraits<N>::NodeType>& DT, - FuncT& F); +/// \brief Core dominator tree base class. +/// +/// This class is a generic template over graph nodes. It is instantiated for +/// various graphs in the LLVM IR or in the code generator. +template <class NodeT> class DominatorTreeBase : public DominatorBase<NodeT> { + DominatorTreeBase(const DominatorTreeBase &) LLVM_DELETED_FUNCTION; + DominatorTreeBase &operator=(const DominatorTreeBase &) LLVM_DELETED_FUNCTION; -template<class NodeT> -class DominatorTreeBase : public DominatorBase<NodeT> { bool dominatedBySlowTreeWalk(const DomTreeNodeBase<NodeT> *A, const DomTreeNodeBase<NodeT> *B) const { assert(A != B); @@ -187,12 +193,24 @@ class DominatorTreeBase : public DominatorBase<NodeT> { const DomTreeNodeBase<NodeT> *IDom; while ((IDom = B->getIDom()) != nullptr && IDom != A && IDom != B) - B = IDom; // Walk up the tree + B = IDom; // Walk up the tree return IDom != nullptr; } + /// \brief Wipe this tree's state without releasing any resources. + /// + /// This is essentially a post-move helper only. It leaves the object in an + /// assignable and destroyable state, but otherwise invalid. + void wipe() { + DomTreeNodes.clear(); + IDoms.clear(); + Vertex.clear(); + Info.clear(); + RootNode = nullptr; + } + protected: - typedef DenseMap<NodeT*, DomTreeNodeBase<NodeT>*> DomTreeNodeMapType; + typedef DenseMap<NodeT *, DomTreeNodeBase<NodeT> *> DomTreeNodeMapType; DomTreeNodeMapType DomTreeNodes; DomTreeNodeBase<NodeT> *RootNode; @@ -208,17 +226,18 @@ protected: InfoRec() : DFSNum(0), Parent(0), Semi(0), Label(nullptr) {} }; - DenseMap<NodeT*, NodeT*> IDoms; + DenseMap<NodeT *, NodeT *> IDoms; // Vertex - Map the DFS number to the NodeT* - std::vector<NodeT*> Vertex; + std::vector<NodeT *> Vertex; // Info - Collection of information used during the computation of idoms. - DenseMap<NodeT*, InfoRec> Info; + DenseMap<NodeT *, InfoRec> Info; void reset() { for (typename DomTreeNodeMapType::iterator I = this->DomTreeNodes.begin(), - E = DomTreeNodes.end(); I != E; ++I) + E = DomTreeNodes.end(); + I != E; ++I) delete I->second; DomTreeNodes.clear(); IDoms.clear(); @@ -229,27 +248,29 @@ protected: // NewBB is split and now it has one successor. Update dominator tree to // reflect this change. - template<class N, class GraphT> - void Split(DominatorTreeBase<typename GraphT::NodeType>& DT, - typename GraphT::NodeType* NewBB) { + template <class N, class GraphT> + void Split(DominatorTreeBase<typename GraphT::NodeType> &DT, + typename GraphT::NodeType *NewBB) { assert(std::distance(GraphT::child_begin(NewBB), GraphT::child_end(NewBB)) == 1 && "NewBB should have a single successor!"); - typename GraphT::NodeType* NewBBSucc = *GraphT::child_begin(NewBB); - - std::vector<typename GraphT::NodeType*> PredBlocks; - typedef GraphTraits<Inverse<N> > InvTraits; - for (typename InvTraits::ChildIteratorType PI = - InvTraits::child_begin(NewBB), - PE = InvTraits::child_end(NewBB); PI != PE; ++PI) + typename GraphT::NodeType *NewBBSucc = *GraphT::child_begin(NewBB); + + std::vector<typename GraphT::NodeType *> PredBlocks; + typedef GraphTraits<Inverse<N>> InvTraits; + for (typename InvTraits::ChildIteratorType + PI = InvTraits::child_begin(NewBB), + PE = InvTraits::child_end(NewBB); + PI != PE; ++PI) PredBlocks.push_back(*PI); assert(!PredBlocks.empty() && "No predblocks?"); bool NewBBDominatesNewBBSucc = true; - for (typename InvTraits::ChildIteratorType PI = - InvTraits::child_begin(NewBBSucc), - E = InvTraits::child_end(NewBBSucc); PI != E; ++PI) { + for (typename InvTraits::ChildIteratorType + PI = InvTraits::child_begin(NewBBSucc), + E = InvTraits::child_end(NewBBSucc); + PI != E; ++PI) { typename InvTraits::NodeType *ND = *PI; if (ND != NewBB && !DT.dominates(NewBBSucc, ND) && DT.isReachableFromEntry(ND)) { @@ -292,8 +313,32 @@ protected: public: explicit DominatorTreeBase(bool isPostDom) - : DominatorBase<NodeT>(isPostDom), DFSInfoValid(false), SlowQueries(0) {} - virtual ~DominatorTreeBase() { reset(); } + : DominatorBase<NodeT>(isPostDom), DFSInfoValid(false), SlowQueries(0) {} + ~DominatorTreeBase() { reset(); } + + DominatorTreeBase(DominatorTreeBase &&Arg) + : DominatorBase<NodeT>( + std::move(static_cast<DominatorBase<NodeT> &>(Arg))), + DomTreeNodes(std::move(Arg.DomTreeNodes)), + RootNode(std::move(Arg.RootNode)), + DFSInfoValid(std::move(Arg.DFSInfoValid)), + SlowQueries(std::move(Arg.SlowQueries)), IDoms(std::move(Arg.IDoms)), + Vertex(std::move(Arg.Vertex)), Info(std::move(Arg.Info)) { + Arg.wipe(); + } + DominatorTreeBase &operator=(DominatorTreeBase &&RHS) { + DominatorBase<NodeT>::operator=( + std::move(static_cast<DominatorBase<NodeT> &>(RHS))); + DomTreeNodes = std::move(RHS.DomTreeNodes); + RootNode = std::move(RHS.RootNode); + DFSInfoValid = std::move(RHS.DFSInfoValid); + SlowQueries = std::move(RHS.SlowQueries); + IDoms = std::move(RHS.IDoms); + Vertex = std::move(RHS.Vertex); + Info = std::move(RHS.Info); + RHS.wipe(); + return *this; + } /// compare - Return false if the other dominator tree base matches this /// dominator tree base. Otherwise return true. @@ -304,15 +349,17 @@ public: return true; for (typename DomTreeNodeMapType::const_iterator - I = this->DomTreeNodes.begin(), - E = this->DomTreeNodes.end(); I != E; ++I) { + I = this->DomTreeNodes.begin(), + E = this->DomTreeNodes.end(); + I != E; ++I) { NodeT *BB = I->first; - typename DomTreeNodeMapType::const_iterator OI = OtherDomTreeNodes.find(BB); + typename DomTreeNodeMapType::const_iterator OI = + OtherDomTreeNodes.find(BB); if (OI == OtherDomTreeNodes.end()) return true; - DomTreeNodeBase<NodeT>* MyNd = I->second; - DomTreeNodeBase<NodeT>* OtherNd = OI->second; + DomTreeNodeBase<NodeT> *MyNd = I->second; + DomTreeNodeBase<NodeT> *OtherNd = OI->second; if (MyNd->compare(OtherNd)) return true; @@ -321,18 +368,16 @@ public: return false; } - virtual void releaseMemory() { reset(); } + void releaseMemory() { reset(); } /// getNode - return the (Post)DominatorTree node for the specified basic /// block. This is the same as using operator[] on this class. /// - inline DomTreeNodeBase<NodeT> *getNode(NodeT *BB) const { + DomTreeNodeBase<NodeT> *getNode(NodeT *BB) const { return DomTreeNodes.lookup(BB); } - inline DomTreeNodeBase<NodeT> *operator[](NodeT *BB) const { - return getNode(BB); - } + DomTreeNodeBase<NodeT> *operator[](NodeT *BB) const { return getNode(BB); } /// getRootNode - This returns the entry node for the CFG of the function. If /// this tree represents the post-dominance relations for a function, however, @@ -376,21 +421,19 @@ public: /// isReachableFromEntry - Return true if A is dominated by the entry /// block of the function containing it. - bool isReachableFromEntry(const NodeT* A) const { + bool isReachableFromEntry(const NodeT *A) const { assert(!this->isPostDominator() && "This is not implemented for post dominators"); return isReachableFromEntry(getNode(const_cast<NodeT *>(A))); } - inline bool isReachableFromEntry(const DomTreeNodeBase<NodeT> *A) const { - return A; - } + bool isReachableFromEntry(const DomTreeNodeBase<NodeT> *A) const { return A; } /// dominates - Returns true iff A dominates B. Note that this is not a /// constant time operation! /// - inline bool dominates(const DomTreeNodeBase<NodeT> *A, - const DomTreeNodeBase<NodeT> *B) const { + bool dominates(const DomTreeNodeBase<NodeT> *A, + const DomTreeNodeBase<NodeT> *B) const { // A node trivially dominates itself. if (B == A) return true; @@ -473,7 +516,7 @@ public: } // Collect NodeA dominators set. - SmallPtrSet<DomTreeNodeBase<NodeT>*, 16> NodeADoms; + SmallPtrSet<DomTreeNodeBase<NodeT> *, 16> NodeADoms; NodeADoms.insert(NodeA); DomTreeNodeBase<NodeT> *IDomA = NodeA->getIDom(); while (IDomA) { @@ -513,7 +556,7 @@ public: assert(IDomNode && "Not immediate dominator specified for block!"); DFSInfoValid = false; return DomTreeNodes[BB] = - IDomNode->addChild(new DomTreeNodeBase<NodeT>(BB, IDomNode)); + IDomNode->addChild(new DomTreeNodeBase<NodeT>(BB, IDomNode)); } /// changeImmediateDominator - This method is used to update the dominator @@ -538,11 +581,11 @@ public: assert(Node && "Removing node that isn't in dominator tree."); assert(Node->getChildren().empty() && "Node is not a leaf node."); - // Remove node from immediate dominator's children list. + // Remove node from immediate dominator's children list. DomTreeNodeBase<NodeT> *IDom = Node->getIDom(); if (IDom) { - typename std::vector<DomTreeNodeBase<NodeT>*>::iterator I = - std::find(IDom->Children.begin(), IDom->Children.end(), Node); + typename std::vector<DomTreeNodeBase<NodeT> *>::iterator I = + std::find(IDom->Children.begin(), IDom->Children.end(), Node); assert(I != IDom->Children.end() && "Not in immediate dominator children set!"); // I am no longer your child... @@ -563,11 +606,12 @@ public: /// splitBlock - BB is split and now it has one successor. Update dominator /// tree to reflect this change. - void splitBlock(NodeT* NewBB) { + void splitBlock(NodeT *NewBB) { if (this->IsPostDominators) - this->Split<Inverse<NodeT*>, GraphTraits<Inverse<NodeT*> > >(*this, NewBB); + this->Split<Inverse<NodeT *>, GraphTraits<Inverse<NodeT *>>>(*this, + NewBB); else - this->Split<NodeT*, GraphTraits<NodeT*> >(*this, NewBB); + this->Split<NodeT *, GraphTraits<NodeT *>>(*this, NewBB); } /// print - Convert to human readable form @@ -588,28 +632,27 @@ public: } protected: - template<class GraphT> - friend typename GraphT::NodeType* Eval( - DominatorTreeBase<typename GraphT::NodeType>& DT, - typename GraphT::NodeType* V, - unsigned LastLinked); + template <class GraphT> + friend typename GraphT::NodeType * + Eval(DominatorTreeBase<typename GraphT::NodeType> &DT, + typename GraphT::NodeType *V, unsigned LastLinked); - template<class GraphT> - friend unsigned DFSPass(DominatorTreeBase<typename GraphT::NodeType>& DT, - typename GraphT::NodeType* V, - unsigned N); + template <class GraphT> + friend unsigned DFSPass(DominatorTreeBase<typename GraphT::NodeType> &DT, + typename GraphT::NodeType *V, unsigned N); - template<class FuncT, class N> - friend void Calculate(DominatorTreeBase<typename GraphTraits<N>::NodeType>& DT, - FuncT& F); + template <class FuncT, class N> + friend void + Calculate(DominatorTreeBase<typename GraphTraits<N>::NodeType> &DT, FuncT &F); /// updateDFSNumbers - Assign In and Out numbers to the nodes while walking /// dominator tree in dfs order. void updateDFSNumbers() const { unsigned DFSNum = 0; - SmallVector<std::pair<const DomTreeNodeBase<NodeT>*, - typename DomTreeNodeBase<NodeT>::const_iterator>, 32> WorkStack; + SmallVector<std::pair<const DomTreeNodeBase<NodeT> *, + typename DomTreeNodeBase<NodeT>::const_iterator>, + 32> WorkStack; const DomTreeNodeBase<NodeT> *ThisRoot = getRootNode(); @@ -626,7 +669,7 @@ protected: while (!WorkStack.empty()) { const DomTreeNodeBase<NodeT> *Node = WorkStack.back().first; typename DomTreeNodeBase<NodeT>::const_iterator ChildIt = - WorkStack.back().second; + WorkStack.back().second; // If we visited all of the children of this node, "recurse" back up the // stack setting the DFOutNum. @@ -664,19 +707,14 @@ protected: return this->DomTreeNodes[BB] = IDomNode->addChild(C); } - inline NodeT *getIDom(NodeT *BB) const { - return IDoms.lookup(BB); - } + NodeT *getIDom(NodeT *BB) const { return IDoms.lookup(BB); } - inline void addRoot(NodeT* BB) { - this->Roots.push_back(BB); - } + void addRoot(NodeT *BB) { this->Roots.push_back(BB); } public: /// recalculate - compute a dominator tree for the given function - template<class FT> - void recalculate(FT& F) { - typedef GraphTraits<FT*> TraitsTy; + template <class FT> void recalculate(FT &F) { + typedef GraphTraits<FT *> TraitsTy; reset(); this->Vertex.push_back(nullptr); @@ -687,27 +725,29 @@ public: this->IDoms[entry] = nullptr; this->DomTreeNodes[entry] = nullptr; - Calculate<FT, NodeT*>(*this, F); + Calculate<FT, NodeT *>(*this, F); } else { // Initialize the roots list for (typename TraitsTy::nodes_iterator I = TraitsTy::nodes_begin(&F), - E = TraitsTy::nodes_end(&F); I != E; ++I) { + E = TraitsTy::nodes_end(&F); + I != E; ++I) { if (TraitsTy::child_begin(I) == TraitsTy::child_end(I)) addRoot(I); - // Prepopulate maps so that we don't get iterator invalidation issues later. + // Prepopulate maps so that we don't get iterator invalidation issues + // later. this->IDoms[I] = nullptr; this->DomTreeNodes[I] = nullptr; } - Calculate<FT, Inverse<NodeT*> >(*this, F); + Calculate<FT, Inverse<NodeT *>>(*this, F); } } }; // These two functions are declared out of line as a workaround for building // with old (< r147295) versions of clang because of pr11642. -template<class NodeT> +template <class NodeT> bool DominatorTreeBase<NodeT>::dominates(const NodeT *A, const NodeT *B) const { if (A == B) return true; @@ -718,9 +758,9 @@ bool DominatorTreeBase<NodeT>::dominates(const NodeT *A, const NodeT *B) const { return dominates(getNode(const_cast<NodeT *>(A)), getNode(const_cast<NodeT *>(B))); } -template<class NodeT> -bool -DominatorTreeBase<NodeT>::properlyDominates(const NodeT *A, const NodeT *B) const { +template <class NodeT> +bool DominatorTreeBase<NodeT>::properlyDominates(const NodeT *A, + const NodeT *B) const { if (A == B) return false; diff --git a/contrib/llvm/include/llvm/Support/GenericDomTreeConstruction.h b/contrib/llvm/include/llvm/Support/GenericDomTreeConstruction.h index bcba5e0aeb43..ad4f8a9f429a 100644 --- a/contrib/llvm/include/llvm/Support/GenericDomTreeConstruction.h +++ b/contrib/llvm/include/llvm/Support/GenericDomTreeConstruction.h @@ -22,8 +22,8 @@ //===----------------------------------------------------------------------===// -#ifndef LLVM_SUPPORT_GENERIC_DOM_TREE_CONSTRUCTION_H -#define LLVM_SUPPORT_GENERIC_DOM_TREE_CONSTRUCTION_H +#ifndef LLVM_SUPPORT_GENERICDOMTREECONSTRUCTION_H +#define LLVM_SUPPORT_GENERICDOMTREECONSTRUCTION_H #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Support/GenericDomTree.h" @@ -125,7 +125,7 @@ Eval(DominatorTreeBase<typename GraphT::NodeType>& DT, typename GraphT::NodeType* VAncestor = DT.Vertex[VInfo.Parent]; // Process Ancestor first - if (Visited.insert(VAncestor) && VInfo.Parent >= LastLinked) { + if (Visited.insert(VAncestor).second && VInfo.Parent >= LastLinked) { Work.push_back(VAncestor); continue; } diff --git a/contrib/llvm/include/llvm/Support/IncludeFile.h b/contrib/llvm/include/llvm/Support/IncludeFile.h deleted file mode 100644 index 2067e34f0d71..000000000000 --- a/contrib/llvm/include/llvm/Support/IncludeFile.h +++ /dev/null @@ -1,79 +0,0 @@ -//===- llvm/Support/IncludeFile.h - Ensure Linking Of Library ---*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file defines the FORCE_DEFINING_FILE_TO_BE_LINKED and DEFINE_FILE_FOR -// macros. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_INCLUDEFILE_H -#define LLVM_SUPPORT_INCLUDEFILE_H - -/// This macro is the public interface that IncludeFile.h exports. This gives -/// us the option to implement the "link the definition" capability in any -/// manner that we choose. All header files that depend on a specific .cpp -/// file being linked at run time should use this macro instead of the -/// IncludeFile class directly. -/// -/// For example, foo.h would use:<br/> -/// <tt>FORCE_DEFINING_FILE_TO_BE_LINKED(foo)</tt><br/> -/// -/// And, foo.cp would use:<br/> -/// <tt>DEFINING_FILE_FOR(foo)</tt><br/> -#ifdef __GNUC__ -// If the `used' attribute is available, use it to create a variable -// with an initializer that will force the linking of the defining file. -#define FORCE_DEFINING_FILE_TO_BE_LINKED(name) \ - namespace llvm { \ - extern const char name ## LinkVar; \ - __attribute__((used)) static const char *const name ## LinkObj = \ - &name ## LinkVar; \ - } -#else -// Otherwise use a constructor call. -#define FORCE_DEFINING_FILE_TO_BE_LINKED(name) \ - namespace llvm { \ - extern const char name ## LinkVar; \ - static const IncludeFile name ## LinkObj ( &name ## LinkVar ); \ - } -#endif - -/// This macro is the counterpart to FORCE_DEFINING_FILE_TO_BE_LINKED. It should -/// be used in a .cpp file to define the name referenced in a header file that -/// will cause linkage of the .cpp file. It should only be used at extern level. -#define DEFINING_FILE_FOR(name) \ - namespace llvm { const char name ## LinkVar = 0; } - -namespace llvm { - -/// This class is used in the implementation of FORCE_DEFINING_FILE_TO_BE_LINKED -/// macro to make sure that the implementation of a header file is included -/// into a tool that uses the header. This is solely -/// to overcome problems linking .a files and not getting the implementation -/// of compilation units we need. This is commonly an issue with the various -/// Passes but also occurs elsewhere in LLVM. We like to use .a files because -/// they link faster and provide the smallest executables. However, sometimes -/// those executables are too small, if the program doesn't reference something -/// that might be needed, especially by a loaded share object. This little class -/// helps to resolve that problem. The basic strategy is to use this class in -/// a header file and pass the address of a variable to the constructor. If the -/// variable is defined in the header file's corresponding .cpp file then all -/// tools/libraries that \#include the header file will require the .cpp as -/// well. -/// For example:<br/> -/// <tt>extern int LinkMyCodeStub;</tt><br/> -/// <tt>static IncludeFile LinkMyModule(&LinkMyCodeStub);</tt><br/> -/// @brief Class to ensure linking of corresponding object file. -struct IncludeFile { - explicit IncludeFile(const void *); -}; - -} - -#endif diff --git a/contrib/llvm/include/llvm/Support/LEB128.h b/contrib/llvm/include/llvm/Support/LEB128.h index ea76c9b58922..6a95432ca2d9 100644 --- a/contrib/llvm/include/llvm/Support/LEB128.h +++ b/contrib/llvm/include/llvm/Support/LEB128.h @@ -82,7 +82,7 @@ inline uint64_t decodeULEB128(const uint8_t *p, unsigned *n = nullptr) { uint64_t Value = 0; unsigned Shift = 0; do { - Value += (*p & 0x7f) << Shift; + Value += uint64_t(*p & 0x7f) << Shift; Shift += 7; } while (*p++ >= 128); if (n) @@ -90,6 +90,26 @@ inline uint64_t decodeULEB128(const uint8_t *p, unsigned *n = nullptr) { return Value; } +/// Utility function to decode a SLEB128 value. +inline int64_t decodeSLEB128(const uint8_t *p, unsigned *n = nullptr) { + const uint8_t *orig_p = p; + int64_t Value = 0; + unsigned Shift = 0; + uint8_t Byte; + do { + Byte = *p++; + Value |= ((Byte & 0x7f) << Shift); + Shift += 7; + } while (Byte >= 128); + // Sign extend negative numbers. + if (Byte & 0x40) + Value |= (-1ULL) << Shift; + if (n) + *n = (unsigned)(p - orig_p); + return Value; +} + + /// Utility function to get the size of the ULEB128-encoded value. extern unsigned getULEB128Size(uint64_t Value); diff --git a/contrib/llvm/include/llvm/Support/LineIterator.h b/contrib/llvm/include/llvm/Support/LineIterator.h index 2a5826200143..9d4cd3bd4c6d 100644 --- a/contrib/llvm/include/llvm/Support/LineIterator.h +++ b/contrib/llvm/include/llvm/Support/LineIterator.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_SUPPORT_LINEITERATOR_H__ -#define LLVM_SUPPORT_LINEITERATOR_H__ +#ifndef LLVM_SUPPORT_LINEITERATOR_H +#define LLVM_SUPPORT_LINEITERATOR_H #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" @@ -18,20 +18,22 @@ namespace llvm { class MemoryBuffer; -/// \brief A forward iterator which reads non-blank text lines from a buffer. +/// \brief A forward iterator which reads text lines from a buffer. /// /// This class provides a forward iterator interface for reading one line at /// a time from a buffer. When default constructed the iterator will be the /// "end" iterator. /// -/// The iterator also is aware of what line number it is currently processing -/// and can strip comment lines given the comment-starting character. +/// The iterator is aware of what line number it is currently processing. It +/// strips blank lines by default, and comment lines given a comment-starting +/// character. /// /// Note that this iterator requires the buffer to be nul terminated. class line_iterator : public std::iterator<std::forward_iterator_tag, StringRef> { const MemoryBuffer *Buffer; char CommentMarker; + bool SkipBlanks; unsigned LineNumber; StringRef CurrentLine; @@ -41,7 +43,8 @@ public: line_iterator() : Buffer(nullptr) {} /// \brief Construct a new iterator around some memory buffer. - explicit line_iterator(const MemoryBuffer &Buffer, char CommentMarker = '\0'); + explicit line_iterator(const MemoryBuffer &Buffer, bool SkipBlanks = true, + char CommentMarker = '\0'); /// \brief Return true if we've reached EOF or are an "end" iterator. bool is_at_eof() const { return !Buffer; } @@ -82,4 +85,4 @@ private: }; } -#endif // LLVM_SUPPORT_LINEITERATOR_H__ +#endif diff --git a/contrib/llvm/include/llvm/Support/MD5.h b/contrib/llvm/include/llvm/Support/MD5.h index 4eb8507ea34f..f6e1e92c9fa8 100644 --- a/contrib/llvm/include/llvm/Support/MD5.h +++ b/contrib/llvm/include/llvm/Support/MD5.h @@ -25,8 +25,8 @@ * See md5.c for more information. */ -#ifndef LLVM_SYSTEM_MD5_H -#define LLVM_SYSTEM_MD5_H +#ifndef LLVM_SUPPORT_MD5_H +#define LLVM_SUPPORT_MD5_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallString.h" @@ -55,11 +55,11 @@ public: void update(StringRef Str); /// \brief Finishes off the hash and puts the result in result. - void final(MD5Result &result); + void final(MD5Result &Result); /// \brief Translates the bytes in \p Res to a hex string that is /// deposited into \p Str. The result will be of length 32. - static void stringifyResult(MD5Result &Res, SmallString<32> &Str); + static void stringifyResult(MD5Result &Result, SmallString<32> &Str); private: const uint8_t *body(ArrayRef<uint8_t> Data); diff --git a/contrib/llvm/include/llvm/Support/MachO.h b/contrib/llvm/include/llvm/Support/MachO.h index 90df1f4f140f..775127505923 100644 --- a/contrib/llvm/include/llvm/Support/MachO.h +++ b/contrib/llvm/include/llvm/Support/MachO.h @@ -73,7 +73,10 @@ namespace llvm { MH_SETUID_SAFE = 0x00080000u, MH_NO_REEXPORTED_DYLIBS = 0x00100000u, MH_PIE = 0x00200000u, - MH_DEAD_STRIPPABLE_DYLIB = 0x00400000u + MH_DEAD_STRIPPABLE_DYLIB = 0x00400000u, + MH_HAS_TLV_DESCRIPTORS = 0x00800000u, + MH_NO_HEAP_EXECUTION = 0x01000000u, + MH_APP_EXTENSION_SAFE = 0x02000000u }; enum : uint32_t { @@ -127,8 +130,8 @@ namespace llvm { LC_DATA_IN_CODE = 0x00000029u, LC_SOURCE_VERSION = 0x0000002Au, LC_DYLIB_CODE_SIGN_DRS = 0x0000002Bu, - // 0x0000002Cu, - LC_LINKER_OPTIONS = 0x0000002Du, + LC_ENCRYPTION_INFO_64 = 0x0000002Cu, + LC_LINKER_OPTION = 0x0000002Du, LC_LINKER_OPTIMIZATION_HINT = 0x0000002Eu }; @@ -327,7 +330,8 @@ namespace llvm { enum ExportSymbolKind { EXPORT_SYMBOL_FLAGS_KIND_REGULAR = 0x00u, - EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL = 0x01u + EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL = 0x01u, + EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE = 0x02u }; @@ -838,12 +842,21 @@ namespace llvm { uint32_t cryptid; }; + struct encryption_info_command_64 { + uint32_t cmd; + uint32_t cmdsize; + uint32_t cryptoff; + uint32_t cryptsize; + uint32_t cryptid; + uint32_t pad; + }; + struct version_min_command { uint32_t cmd; // LC_VERSION_MIN_MACOSX or // LC_VERSION_MIN_IPHONEOS uint32_t cmdsize; // sizeof(struct version_min_command) uint32_t version; // X.Y.Z is encoded in nibbles xxxx.yy.zz - uint32_t reserved; + uint32_t sdk; // X.Y.Z is encoded in nibbles xxxx.yy.zz }; struct dyld_info_command { @@ -861,7 +874,7 @@ namespace llvm { uint32_t export_size; }; - struct linker_options_command { + struct linker_option_command { uint32_t cmd; uint32_t cmdsize; uint32_t count; @@ -1094,12 +1107,84 @@ namespace llvm { sys::swapByteOrder(d.dylib.compatibility_version); } + inline void swapStruct(sub_framework_command &s) { + sys::swapByteOrder(s.cmd); + sys::swapByteOrder(s.cmdsize); + sys::swapByteOrder(s.umbrella); + } + + inline void swapStruct(sub_umbrella_command &s) { + sys::swapByteOrder(s.cmd); + sys::swapByteOrder(s.cmdsize); + sys::swapByteOrder(s.sub_umbrella); + } + + inline void swapStruct(sub_library_command &s) { + sys::swapByteOrder(s.cmd); + sys::swapByteOrder(s.cmdsize); + sys::swapByteOrder(s.sub_library); + } + + inline void swapStruct(sub_client_command &s) { + sys::swapByteOrder(s.cmd); + sys::swapByteOrder(s.cmdsize); + sys::swapByteOrder(s.client); + } + + inline void swapStruct(routines_command &r) { + sys::swapByteOrder(r.cmd); + sys::swapByteOrder(r.cmdsize); + sys::swapByteOrder(r.init_address); + sys::swapByteOrder(r.init_module); + sys::swapByteOrder(r.reserved1); + sys::swapByteOrder(r.reserved2); + sys::swapByteOrder(r.reserved3); + sys::swapByteOrder(r.reserved4); + sys::swapByteOrder(r.reserved5); + sys::swapByteOrder(r.reserved6); + } + + inline void swapStruct(routines_command_64 &r) { + sys::swapByteOrder(r.cmd); + sys::swapByteOrder(r.cmdsize); + sys::swapByteOrder(r.init_address); + sys::swapByteOrder(r.init_module); + sys::swapByteOrder(r.reserved1); + sys::swapByteOrder(r.reserved2); + sys::swapByteOrder(r.reserved3); + sys::swapByteOrder(r.reserved4); + sys::swapByteOrder(r.reserved5); + sys::swapByteOrder(r.reserved6); + } + + inline void swapStruct(thread_command &t) { + sys::swapByteOrder(t.cmd); + sys::swapByteOrder(t.cmdsize); + } + inline void swapStruct(dylinker_command &d) { sys::swapByteOrder(d.cmd); sys::swapByteOrder(d.cmdsize); sys::swapByteOrder(d.name); } + inline void swapStruct(uuid_command &u) { + sys::swapByteOrder(u.cmd); + sys::swapByteOrder(u.cmdsize); + } + + inline void swapStruct(rpath_command &r) { + sys::swapByteOrder(r.cmd); + sys::swapByteOrder(r.cmdsize); + sys::swapByteOrder(r.path); + } + + inline void swapStruct(source_version_command &s) { + sys::swapByteOrder(s.cmd); + sys::swapByteOrder(s.cmdsize); + sys::swapByteOrder(s.version); + } + inline void swapStruct(entry_point_command &e) { sys::swapByteOrder(e.cmd); sys::swapByteOrder(e.cmdsize); @@ -1107,6 +1192,23 @@ namespace llvm { sys::swapByteOrder(e.stacksize); } + inline void swapStruct(encryption_info_command &e) { + sys::swapByteOrder(e.cmd); + sys::swapByteOrder(e.cmdsize); + sys::swapByteOrder(e.cryptoff); + sys::swapByteOrder(e.cryptsize); + sys::swapByteOrder(e.cryptid); + } + + inline void swapStruct(encryption_info_command_64 &e) { + sys::swapByteOrder(e.cmd); + sys::swapByteOrder(e.cmdsize); + sys::swapByteOrder(e.cryptoff); + sys::swapByteOrder(e.cryptsize); + sys::swapByteOrder(e.cryptid); + sys::swapByteOrder(e.pad); + } + inline void swapStruct(dysymtab_command &dst) { sys::swapByteOrder(dst.cmd); sys::swapByteOrder(dst.cmdsize); @@ -1159,7 +1261,7 @@ namespace llvm { sys::swapByteOrder(C.datasize); } - inline void swapStruct(linker_options_command &C) { + inline void swapStruct(linker_option_command &C) { sys::swapByteOrder(C.cmd); sys::swapByteOrder(C.cmdsize); sys::swapByteOrder(C.count); @@ -1169,7 +1271,7 @@ namespace llvm { sys::swapByteOrder(C.cmd); sys::swapByteOrder(C.cmdsize); sys::swapByteOrder(C.version); - sys::swapByteOrder(C.reserved); + sys::swapByteOrder(C.sdk); } inline void swapStruct(data_in_code_entry &C) { @@ -1316,6 +1418,262 @@ namespace llvm { CPU_SUBTYPE_MC980000_ALL = CPU_SUBTYPE_POWERPC_ALL, CPU_SUBTYPE_MC98601 = CPU_SUBTYPE_POWERPC_601 }; + + struct x86_thread_state64_t { + uint64_t rax; + uint64_t rbx; + uint64_t rcx; + uint64_t rdx; + uint64_t rdi; + uint64_t rsi; + uint64_t rbp; + uint64_t rsp; + uint64_t r8; + uint64_t r9; + uint64_t r10; + uint64_t r11; + uint64_t r12; + uint64_t r13; + uint64_t r14; + uint64_t r15; + uint64_t rip; + uint64_t rflags; + uint64_t cs; + uint64_t fs; + uint64_t gs; + }; + + enum x86_fp_control_precis { + x86_FP_PREC_24B = 0, + x86_FP_PREC_53B = 2, + x86_FP_PREC_64B = 3 + }; + + enum x86_fp_control_rc { + x86_FP_RND_NEAR = 0, + x86_FP_RND_DOWN = 1, + x86_FP_RND_UP = 2, + x86_FP_CHOP = 3 + }; + + struct fp_control_t { + unsigned short + invalid :1, + denorm :1, + zdiv :1, + ovrfl :1, + undfl :1, + precis :1, + :2, + pc :2, + rc :2, + :1, + :3; + }; + + struct fp_status_t { + unsigned short + invalid :1, + denorm :1, + zdiv :1, + ovrfl :1, + undfl :1, + precis :1, + stkflt :1, + errsumm :1, + c0 :1, + c1 :1, + c2 :1, + tos :3, + c3 :1, + busy :1; + }; + + struct mmst_reg_t { + char mmst_reg[10]; + char mmst_rsrv[6]; + }; + + struct xmm_reg_t { + char xmm_reg[16]; + }; + + struct x86_float_state64_t { + int32_t fpu_reserved[2]; + fp_control_t fpu_fcw; + fp_status_t fpu_fsw; + uint8_t fpu_ftw; + uint8_t fpu_rsrv1; + uint16_t fpu_fop; + uint32_t fpu_ip; + uint16_t fpu_cs; + uint16_t fpu_rsrv2; + uint32_t fpu_dp; + uint16_t fpu_ds; + uint16_t fpu_rsrv3; + uint32_t fpu_mxcsr; + uint32_t fpu_mxcsrmask; + mmst_reg_t fpu_stmm0; + mmst_reg_t fpu_stmm1; + mmst_reg_t fpu_stmm2; + mmst_reg_t fpu_stmm3; + mmst_reg_t fpu_stmm4; + mmst_reg_t fpu_stmm5; + mmst_reg_t fpu_stmm6; + mmst_reg_t fpu_stmm7; + xmm_reg_t fpu_xmm0; + xmm_reg_t fpu_xmm1; + xmm_reg_t fpu_xmm2; + xmm_reg_t fpu_xmm3; + xmm_reg_t fpu_xmm4; + xmm_reg_t fpu_xmm5; + xmm_reg_t fpu_xmm6; + xmm_reg_t fpu_xmm7; + xmm_reg_t fpu_xmm8; + xmm_reg_t fpu_xmm9; + xmm_reg_t fpu_xmm10; + xmm_reg_t fpu_xmm11; + xmm_reg_t fpu_xmm12; + xmm_reg_t fpu_xmm13; + xmm_reg_t fpu_xmm14; + xmm_reg_t fpu_xmm15; + char fpu_rsrv4[6*16]; + uint32_t fpu_reserved1; + }; + + struct x86_exception_state64_t { + uint16_t trapno; + uint16_t cpu; + uint32_t err; + uint64_t faultvaddr; + }; + + inline void swapStruct(x86_thread_state64_t &x) { + sys::swapByteOrder(x.rax); + sys::swapByteOrder(x.rbx); + sys::swapByteOrder(x.rcx); + sys::swapByteOrder(x.rdx); + sys::swapByteOrder(x.rdi); + sys::swapByteOrder(x.rsi); + sys::swapByteOrder(x.rbp); + sys::swapByteOrder(x.rsp); + sys::swapByteOrder(x.r8); + sys::swapByteOrder(x.r9); + sys::swapByteOrder(x.r10); + sys::swapByteOrder(x.r11); + sys::swapByteOrder(x.r12); + sys::swapByteOrder(x.r13); + sys::swapByteOrder(x.r14); + sys::swapByteOrder(x.r15); + sys::swapByteOrder(x.rip); + sys::swapByteOrder(x.rflags); + sys::swapByteOrder(x.cs); + sys::swapByteOrder(x.fs); + sys::swapByteOrder(x.gs); + } + + inline void swapStruct(x86_float_state64_t &x) { + sys::swapByteOrder(x.fpu_reserved[0]); + sys::swapByteOrder(x.fpu_reserved[1]); + // TODO swap: fp_control_t fpu_fcw; + // TODO swap: fp_status_t fpu_fsw; + sys::swapByteOrder(x.fpu_fop); + sys::swapByteOrder(x.fpu_ip); + sys::swapByteOrder(x.fpu_cs); + sys::swapByteOrder(x.fpu_rsrv2); + sys::swapByteOrder(x.fpu_dp); + sys::swapByteOrder(x.fpu_ds); + sys::swapByteOrder(x.fpu_rsrv3); + sys::swapByteOrder(x.fpu_mxcsr); + sys::swapByteOrder(x.fpu_mxcsrmask); + sys::swapByteOrder(x.fpu_reserved1); + } + + inline void swapStruct(x86_exception_state64_t &x) { + sys::swapByteOrder(x.trapno); + sys::swapByteOrder(x.cpu); + sys::swapByteOrder(x.err); + sys::swapByteOrder(x.faultvaddr); + } + + struct x86_state_hdr_t { + uint32_t flavor; + uint32_t count; + }; + + struct x86_thread_state_t { + x86_state_hdr_t tsh; + union { + x86_thread_state64_t ts64; + } uts; + }; + + struct x86_float_state_t { + x86_state_hdr_t fsh; + union { + x86_float_state64_t fs64; + } ufs; + }; + + struct x86_exception_state_t { + x86_state_hdr_t esh; + union { + x86_exception_state64_t es64; + } ues; + }; + + inline void swapStruct(x86_state_hdr_t &x) { + sys::swapByteOrder(x.flavor); + sys::swapByteOrder(x.count); + } + + enum X86ThreadFlavors { + x86_THREAD_STATE32 = 1, + x86_FLOAT_STATE32 = 2, + x86_EXCEPTION_STATE32 = 3, + x86_THREAD_STATE64 = 4, + x86_FLOAT_STATE64 = 5, + x86_EXCEPTION_STATE64 = 6, + x86_THREAD_STATE = 7, + x86_FLOAT_STATE = 8, + x86_EXCEPTION_STATE = 9, + x86_DEBUG_STATE32 = 10, + x86_DEBUG_STATE64 = 11, + x86_DEBUG_STATE = 12 + }; + + inline void swapStruct(x86_thread_state_t &x) { + swapStruct(x.tsh); + if (x.tsh.flavor == x86_THREAD_STATE64) + swapStruct(x.uts.ts64); + } + + inline void swapStruct(x86_float_state_t &x) { + swapStruct(x.fsh); + if (x.fsh.flavor == x86_FLOAT_STATE64) + swapStruct(x.ufs.fs64); + } + + inline void swapStruct(x86_exception_state_t &x) { + swapStruct(x.esh); + if (x.esh.flavor == x86_EXCEPTION_STATE64) + swapStruct(x.ues.es64); + } + + const uint32_t x86_THREAD_STATE64_COUNT = + sizeof(x86_thread_state64_t) / sizeof(uint32_t); + const uint32_t x86_FLOAT_STATE64_COUNT = + sizeof(x86_float_state64_t) / sizeof(uint32_t); + const uint32_t x86_EXCEPTION_STATE64_COUNT = + sizeof(x86_exception_state64_t) / sizeof(uint32_t); + + const uint32_t x86_THREAD_STATE_COUNT = + sizeof(x86_thread_state_t) / sizeof(uint32_t); + const uint32_t x86_FLOAT_STATE_COUNT = + sizeof(x86_float_state_t) / sizeof(uint32_t); + const uint32_t x86_EXCEPTION_STATE_COUNT = + sizeof(x86_exception_state_t) / sizeof(uint32_t); + } // end namespace MachO } // end namespace llvm diff --git a/contrib/llvm/include/llvm/Support/ManagedStatic.h b/contrib/llvm/include/llvm/Support/ManagedStatic.h index d8fbfeb8e20c..addd34e704bc 100644 --- a/contrib/llvm/include/llvm/Support/ManagedStatic.h +++ b/contrib/llvm/include/llvm/Support/ManagedStatic.h @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_SUPPORT_MANAGED_STATIC_H -#define LLVM_SUPPORT_MANAGED_STATIC_H +#ifndef LLVM_SUPPORT_MANAGEDSTATIC_H +#define LLVM_SUPPORT_MANAGEDSTATIC_H #include "llvm/Support/Atomic.h" #include "llvm/Support/Threading.h" diff --git a/contrib/llvm/include/llvm/Support/MathExtras.h b/contrib/llvm/include/llvm/Support/MathExtras.h index 0abba62a2c23..698363614ac5 100644 --- a/contrib/llvm/include/llvm/Support/MathExtras.h +++ b/contrib/llvm/include/llvm/Support/MathExtras.h @@ -22,7 +22,6 @@ #ifdef _MSC_VER #include <intrin.h> -#include <limits> #endif namespace llvm { @@ -73,7 +72,7 @@ countTrailingZeros(T Val, ZeroBehavior ZB = ZB_Width) { template <typename T> typename std::enable_if<std::numeric_limits<T>::is_integer && std::numeric_limits<T>::is_signed, std::size_t>::type -countTrailingZeros(T Val, ZeroBehavior ZB = ZB_Width) LLVM_DELETED_FUNCTION; +countTrailingZeros(T, ZeroBehavior = ZB_Width) LLVM_DELETED_FUNCTION; #if __GNUC__ >= 4 || _MSC_VER template <> @@ -81,7 +80,7 @@ inline std::size_t countTrailingZeros<uint32_t>(uint32_t Val, ZeroBehavior ZB) { if (ZB != ZB_Undefined && Val == 0) return 32; -#if __has_builtin(__builtin_ctz) || __GNUC_PREREQ(4, 0) +#if __has_builtin(__builtin_ctz) || LLVM_GNUC_PREREQ(4, 0, 0) return __builtin_ctz(Val); #elif _MSC_VER unsigned long Index; @@ -96,7 +95,7 @@ inline std::size_t countTrailingZeros<uint64_t>(uint64_t Val, ZeroBehavior ZB) { if (ZB != ZB_Undefined && Val == 0) return 64; -#if __has_builtin(__builtin_ctzll) || __GNUC_PREREQ(4, 0) +#if __has_builtin(__builtin_ctzll) || LLVM_GNUC_PREREQ(4, 0, 0) return __builtin_ctzll(Val); #elif _MSC_VER unsigned long Index; @@ -139,7 +138,7 @@ countLeadingZeros(T Val, ZeroBehavior ZB = ZB_Width) { template <typename T> typename std::enable_if<std::numeric_limits<T>::is_integer && std::numeric_limits<T>::is_signed, std::size_t>::type -countLeadingZeros(T Val, ZeroBehavior ZB = ZB_Width) LLVM_DELETED_FUNCTION; +countLeadingZeros(T, ZeroBehavior = ZB_Width) LLVM_DELETED_FUNCTION; #if __GNUC__ >= 4 || _MSC_VER template <> @@ -147,7 +146,7 @@ inline std::size_t countLeadingZeros<uint32_t>(uint32_t Val, ZeroBehavior ZB) { if (ZB != ZB_Undefined && Val == 0) return 32; -#if __has_builtin(__builtin_clz) || __GNUC_PREREQ(4, 0) +#if __has_builtin(__builtin_clz) || LLVM_GNUC_PREREQ(4, 0, 0) return __builtin_clz(Val); #elif _MSC_VER unsigned long Index; @@ -162,7 +161,7 @@ inline std::size_t countLeadingZeros<uint64_t>(uint64_t Val, ZeroBehavior ZB) { if (ZB != ZB_Undefined && Val == 0) return 64; -#if __has_builtin(__builtin_clzll) || __GNUC_PREREQ(4, 0) +#if __has_builtin(__builtin_clzll) || LLVM_GNUC_PREREQ(4, 0, 0) return __builtin_clzll(Val); #elif _MSC_VER unsigned long Index; @@ -194,7 +193,7 @@ findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) { template <typename T> typename std::enable_if<std::numeric_limits<T>::is_integer && std::numeric_limits<T>::is_signed, T>::type -findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) LLVM_DELETED_FUNCTION; +findFirstSet(T, ZeroBehavior = ZB_Max) LLVM_DELETED_FUNCTION; /// \brief Get the index of the last set bit starting from the least /// significant bit. @@ -220,7 +219,7 @@ findLastSet(T Val, ZeroBehavior ZB = ZB_Max) { template <typename T> typename std::enable_if<std::numeric_limits<T>::is_integer && std::numeric_limits<T>::is_signed, T>::type -findLastSet(T Val, ZeroBehavior ZB = ZB_Max) LLVM_DELETED_FUNCTION; +findLastSet(T, ZeroBehavior = ZB_Max) LLVM_DELETED_FUNCTION; /// \brief Macro compressed bit reversal table for 256 bits. /// @@ -550,16 +549,23 @@ inline uint64_t MinAlign(uint64_t A, uint64_t B) { return (A | B) & (1 + ~(A | B)); } -/// \brief Aligns \c Ptr to \c Alignment bytes, rounding up. +/// \brief Aligns \c Addr to \c Alignment bytes, rounding up. /// /// Alignment should be a power of two. This method rounds up, so -/// AlignPtr(7, 4) == 8 and AlignPtr(8, 4) == 8. -inline char *alignPtr(char *Ptr, size_t Alignment) { +/// alignAddr(7, 4) == 8 and alignAddr(8, 4) == 8. +inline uintptr_t alignAddr(void *Addr, size_t Alignment) { assert(Alignment && isPowerOf2_64((uint64_t)Alignment) && "Alignment is not a power of two!"); - return (char *)(((uintptr_t)Ptr + Alignment - 1) & - ~(uintptr_t)(Alignment - 1)); + assert((uintptr_t)Addr + Alignment - 1 >= (uintptr_t)Addr); + + return (((uintptr_t)Addr + Alignment - 1) & ~(uintptr_t)(Alignment - 1)); +} + +/// \brief Returns the necessary adjustment for aligning \c Ptr to \c Alignment +/// bytes, rounding up. +inline size_t alignmentAdjustment(void *Ptr, size_t Alignment) { + return alignAddr(Ptr, Alignment) - (uintptr_t)Ptr; } /// NextPowerOf2 - Returns the next power of two (in 64-bits) @@ -589,9 +595,10 @@ inline uint64_t PowerOf2Floor(uint64_t A) { /// RoundUpToAlignment(5, 8) = 8 /// RoundUpToAlignment(17, 8) = 24 /// RoundUpToAlignment(~0LL, 8) = 0 +/// RoundUpToAlignment(321, 255) = 510 /// \endcode inline uint64_t RoundUpToAlignment(uint64_t Value, uint64_t Align) { - return ((Value + Align - 1) / Align) * Align; + return (Value + Align - 1) / Align * Align; } /// Returns the offset to the next integer (mod 2**64) that is greater than @@ -632,13 +639,7 @@ inline int64_t SignExtend64(uint64_t X, unsigned B) { return int64_t(X << (64 - B)) >> (64 - B); } -#if defined(_MSC_VER) - // Visual Studio defines the HUGE_VAL class of macros using purposeful - // constant arithmetic overflow, which it then warns on when encountered. - const float huge_valf = std::numeric_limits<float>::infinity(); -#else - const float huge_valf = HUGE_VALF; -#endif +extern const float huge_valf; } // End llvm namespace #endif diff --git a/contrib/llvm/include/llvm/Support/MemoryBuffer.h b/contrib/llvm/include/llvm/Support/MemoryBuffer.h index 147be47e1c8f..e2f8d7e90fef 100644 --- a/contrib/llvm/include/llvm/Support/MemoryBuffer.h +++ b/contrib/llvm/include/llvm/Support/MemoryBuffer.h @@ -24,11 +24,13 @@ #include <system_error> namespace llvm { -/// MemoryBuffer - This interface provides simple read-only access to a block -/// of memory, and provides simple methods for reading files and standard input -/// into a memory buffer. In addition to basic access to the characters in the -/// file, this interface guarantees you can read one character past the end of -/// the file, and that this character will read as '\0'. +class MemoryBufferRef; + +/// This interface provides simple read-only access to a block of memory, and +/// provides simple methods for reading files and standard input into a memory +/// buffer. In addition to basic access to the characters in the file, this +/// interface guarantees you can read one character past the end of the file, +/// and that this character will read as '\0'. /// /// The '\0' guarantee is needed to support an optimization -- it's intended to /// be more efficient for clients which are reading all the data to stop @@ -55,8 +57,8 @@ public: return StringRef(BufferStart, getBufferSize()); } - /// getBufferIdentifier - Return an identifier for this buffer, typically the - /// filename it was read from. + /// Return an identifier for this buffer, typically the filename it was read + /// from. virtual const char *getBufferIdentifier() const { return "Unknown buffer"; } @@ -70,19 +72,15 @@ public: /// changing, e.g. when libclang tries to parse while the user is /// editing/updating the file. static ErrorOr<std::unique_ptr<MemoryBuffer>> - getFile(Twine Filename, int64_t FileSize = -1, + getFile(const Twine &Filename, int64_t FileSize = -1, bool RequiresNullTerminator = true, bool IsVolatileSize = false); /// Given an already-open file descriptor, map some slice of it into a /// MemoryBuffer. The slice is specified by an \p Offset and \p MapSize. /// Since this is in the middle of a file, the buffer is not null terminated. - /// - /// \param IsVolatileSize Set to true to indicate that the file size may be - /// changing, e.g. when libclang tries to parse while the user is - /// editing/updating the file. static ErrorOr<std::unique_ptr<MemoryBuffer>> - getOpenFileSlice(int FD, const char *Filename, uint64_t MapSize, - int64_t Offset, bool IsVolatileSize = false); + getOpenFileSlice(int FD, const Twine &Filename, uint64_t MapSize, + int64_t Offset); /// Given an already-open file descriptor, read the file and return a /// MemoryBuffer. @@ -91,33 +89,34 @@ public: /// changing, e.g. when libclang tries to parse while the user is /// editing/updating the file. static ErrorOr<std::unique_ptr<MemoryBuffer>> - getOpenFile(int FD, const char *Filename, uint64_t FileSize, + getOpenFile(int FD, const Twine &Filename, uint64_t FileSize, bool RequiresNullTerminator = true, bool IsVolatileSize = false); - /// getMemBuffer - Open the specified memory range as a MemoryBuffer. Note - /// that InputData must be null terminated if RequiresNullTerminator is true. - static MemoryBuffer *getMemBuffer(StringRef InputData, - StringRef BufferName = "", - bool RequiresNullTerminator = true); - - /// getMemBufferCopy - Open the specified memory range as a MemoryBuffer, - /// copying the contents and taking ownership of it. InputData does not - /// have to be null terminated. - static MemoryBuffer *getMemBufferCopy(StringRef InputData, - StringRef BufferName = ""); - - /// getNewMemBuffer - Allocate a new MemoryBuffer of the specified size that - /// is completely initialized to zeros. Note that the caller should - /// initialize the memory allocated by this method. The memory is owned by - /// the MemoryBuffer object. - static MemoryBuffer *getNewMemBuffer(size_t Size, StringRef BufferName = ""); - - /// getNewUninitMemBuffer - Allocate a new MemoryBuffer of the specified size - /// that is not initialized. Note that the caller should initialize the - /// memory allocated by this method. The memory is owned by the MemoryBuffer - /// object. - static MemoryBuffer *getNewUninitMemBuffer(size_t Size, - StringRef BufferName = ""); + /// Open the specified memory range as a MemoryBuffer. Note that InputData + /// must be null terminated if RequiresNullTerminator is true. + static std::unique_ptr<MemoryBuffer> + getMemBuffer(StringRef InputData, StringRef BufferName = "", + bool RequiresNullTerminator = true); + + static std::unique_ptr<MemoryBuffer> + getMemBuffer(MemoryBufferRef Ref, bool RequiresNullTerminator = true); + + /// Open the specified memory range as a MemoryBuffer, copying the contents + /// and taking ownership of it. InputData does not have to be null terminated. + static std::unique_ptr<MemoryBuffer> + getMemBufferCopy(StringRef InputData, const Twine &BufferName = ""); + + /// Allocate a new zero-initialized MemoryBuffer of the specified size. Note + /// that the caller need not initialize the memory allocated by this method. + /// The memory is owned by the MemoryBuffer object. + static std::unique_ptr<MemoryBuffer> + getNewMemBuffer(size_t Size, StringRef BufferName = ""); + + /// Allocate a new MemoryBuffer of the specified size that is not initialized. + /// Note that the caller should initialize the memory allocated by this + /// method. The memory is owned by the MemoryBuffer object. + static std::unique_ptr<MemoryBuffer> + getNewUninitMemBuffer(size_t Size, const Twine &BufferName = ""); /// Read all of stdin into a file buffer, and return it. static ErrorOr<std::unique_ptr<MemoryBuffer>> getSTDIN(); @@ -125,7 +124,11 @@ public: /// Open the specified file as a MemoryBuffer, or open stdin if the Filename /// is "-". static ErrorOr<std::unique_ptr<MemoryBuffer>> - getFileOrSTDIN(StringRef Filename, int64_t FileSize = -1); + getFileOrSTDIN(const Twine &Filename, int64_t FileSize = -1); + + /// Map a subrange of the the specified file as a MemoryBuffer. + static ErrorOr<std::unique_ptr<MemoryBuffer>> + getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset); //===--------------------------------------------------------------------===// // Provided for performance analysis. @@ -139,7 +142,27 @@ public: /// Return information on the memory mechanism used to support the /// MemoryBuffer. - virtual BufferKind getBufferKind() const = 0; + virtual BufferKind getBufferKind() const = 0; + + MemoryBufferRef getMemBufferRef() const; +}; + +class MemoryBufferRef { + StringRef Buffer; + StringRef Identifier; + +public: + MemoryBufferRef() {} + MemoryBufferRef(StringRef Buffer, StringRef Identifier) + : Buffer(Buffer), Identifier(Identifier) {} + + StringRef getBuffer() const { return Buffer; } + + StringRef getBufferIdentifier() const { return Identifier; } + + const char *getBufferStart() const { return Buffer.begin(); } + const char *getBufferEnd() const { return Buffer.end(); } + size_t getBufferSize() const { return Buffer.size(); } }; // Create wrappers for C Binding types (see CBindingWrapping.h). diff --git a/contrib/llvm/include/llvm/Support/MemoryObject.h b/contrib/llvm/include/llvm/Support/MemoryObject.h index 17aa9d2f675a..e0c8749da346 100644 --- a/contrib/llvm/include/llvm/Support/MemoryObject.h +++ b/contrib/llvm/include/llvm/Support/MemoryObject.h @@ -14,49 +14,53 @@ namespace llvm { -/// MemoryObject - Abstract base class for contiguous addressable memory. -/// Necessary for cases in which the memory is in another process, in a -/// file, or on a remote machine. -/// All size and offset parameters are uint64_ts, to allow 32-bit processes -/// access to 64-bit address spaces. +/// Interface to data which might be streamed. Streamability has 2 important +/// implications/restrictions. First, the data might not yet exist in memory +/// when the request is made. This just means that readByte/readBytes might have +/// to block or do some work to get it. More significantly, the exact size of +/// the object might not be known until it has all been fetched. This means that +/// to return the right result, getExtent must also wait for all the data to +/// arrive; therefore it should not be called on objects which are actually +/// streamed (this would defeat the purpose of streaming). Instead, +/// isValidAddress can be used to test addresses without knowing the exact size +/// of the stream. Finally, getPointer can be used instead of readBytes to avoid +/// extra copying. class MemoryObject { public: - /// Destructor - Override as necessary. virtual ~MemoryObject(); - /// getBase - Returns the lowest valid address in the region. - /// - /// @result - The lowest valid address. - virtual uint64_t getBase() const = 0; - - /// getExtent - Returns the size of the region in bytes. (The region is - /// contiguous, so the highest valid address of the region - /// is getBase() + getExtent() - 1). + /// Returns the size of the region in bytes. (The region is contiguous, so + /// the highest valid address of the region is getExtent() - 1). /// /// @result - The size of the region. virtual uint64_t getExtent() const = 0; - /// readByte - Tries to read a single byte from the region. - /// - /// @param address - The address of the byte, in the same space as getBase(). - /// @param ptr - A pointer to a byte to be filled in. Must be non-NULL. - /// @result - 0 if successful; -1 if not. Failure may be due to a - /// bounds violation or an implementation-specific error. - virtual int readByte(uint64_t address, uint8_t *ptr) const = 0; - - /// readBytes - Tries to read a contiguous range of bytes from the - /// region, up to the end of the region. - /// You should override this function if there is a quicker - /// way than going back and forth with individual bytes. + /// Tries to read a contiguous range of bytes from the region, up to the end + /// of the region. /// - /// @param address - The address of the first byte, in the same space as - /// getBase(). - /// @param size - The number of bytes to copy. - /// @param buf - A pointer to a buffer to be filled in. Must be non-NULL + /// @param Buf - A pointer to a buffer to be filled in. Must be non-NULL /// and large enough to hold size bytes. - /// @result - 0 if successful; -1 if not. Failure may be due to a - /// bounds violation or an implementation-specific error. - virtual int readBytes(uint64_t address, uint64_t size, uint8_t *buf) const; + /// @param Size - The number of bytes to copy. + /// @param Address - The address of the first byte, in the same space as + /// getBase(). + /// @result - The number of bytes read. + virtual uint64_t readBytes(uint8_t *Buf, uint64_t Size, + uint64_t Address) const = 0; + + /// Ensures that the requested data is in memory, and returns a pointer to it. + /// More efficient than using readBytes if the data is already in memory. May + /// block until (address - base + size) bytes have been read + /// @param address - address of the byte, in the same space as getBase() + /// @param size - amount of data that must be available on return + /// @result - valid pointer to the requested data + virtual const uint8_t *getPointer(uint64_t address, uint64_t size) const = 0; + + /// Returns true if the address is within the object (i.e. between base and + /// base + extent - 1 inclusive). May block until (address - base) bytes have + /// been read + /// @param address - address of the byte, in the same space as getBase() + /// @result - true if the address may be read with readByte() + virtual bool isValidAddress(uint64_t address) const = 0; }; } diff --git a/contrib/llvm/include/llvm/Support/Mutex.h b/contrib/llvm/include/llvm/Support/Mutex.h index 496a4381f3fc..97dd50115322 100644 --- a/contrib/llvm/include/llvm/Support/Mutex.h +++ b/contrib/llvm/include/llvm/Support/Mutex.h @@ -86,16 +86,17 @@ namespace llvm /// indicates whether this mutex should become a no-op when we're not /// running in multithreaded mode. template<bool mt_only> - class SmartMutex : public MutexImpl { + class SmartMutex { + MutexImpl impl; unsigned acquired; bool recursive; public: explicit SmartMutex(bool rec = true) : - MutexImpl(rec), acquired(0), recursive(rec) { } + impl(rec), acquired(0), recursive(rec) { } - bool acquire() { + bool lock() { if (!mt_only || llvm_is_multithreaded()) { - return MutexImpl::acquire(); + return impl.acquire(); } else { // Single-threaded debugging code. This would be racy in // multithreaded mode, but provides not sanity checks in single @@ -106,9 +107,9 @@ namespace llvm } } - bool release() { + bool unlock() { if (!mt_only || llvm_is_multithreaded()) { - return MutexImpl::release(); + return impl.release(); } else { // Single-threaded debugging code. This would be racy in // multithreaded mode, but provides not sanity checks in single @@ -120,9 +121,9 @@ namespace llvm } } - bool tryacquire() { + bool try_lock() { if (!mt_only || llvm_is_multithreaded()) - return MutexImpl::tryacquire(); + return impl.tryacquire(); else return true; } @@ -140,11 +141,11 @@ namespace llvm public: SmartScopedLock(SmartMutex<mt_only>& m) : mtx(m) { - mtx.acquire(); + mtx.lock(); } ~SmartScopedLock() { - mtx.release(); + mtx.unlock(); } }; diff --git a/contrib/llvm/include/llvm/Support/MutexGuard.h b/contrib/llvm/include/llvm/Support/MutexGuard.h index 6bb162277e2b..b9f941dab323 100644 --- a/contrib/llvm/include/llvm/Support/MutexGuard.h +++ b/contrib/llvm/include/llvm/Support/MutexGuard.h @@ -29,8 +29,8 @@ namespace llvm { MutexGuard(const MutexGuard &) LLVM_DELETED_FUNCTION; void operator=(const MutexGuard &) LLVM_DELETED_FUNCTION; public: - MutexGuard(sys::Mutex &m) : M(m) { M.acquire(); } - ~MutexGuard() { M.release(); } + MutexGuard(sys::Mutex &m) : M(m) { M.lock(); } + ~MutexGuard() { M.unlock(); } /// holds - Returns true if this locker instance holds the specified lock. /// This is mostly used in assertions to validate that the correct mutex /// is held. diff --git a/contrib/llvm/include/llvm/Support/OnDiskHashTable.h b/contrib/llvm/include/llvm/Support/OnDiskHashTable.h index f6d43a440788..52f133ccff68 100644 --- a/contrib/llvm/include/llvm/Support/OnDiskHashTable.h +++ b/contrib/llvm/include/llvm/Support/OnDiskHashTable.h @@ -11,11 +11,11 @@ /// \brief Defines facilities for reading and writing on-disk hash tables. /// //===----------------------------------------------------------------------===// -#ifndef LLVM_SUPPORT_ON_DISK_HASH_TABLE_H -#define LLVM_SUPPORT_ON_DISK_HASH_TABLE_H +#ifndef LLVM_SUPPORT_ONDISKHASHTABLE_H +#define LLVM_SUPPORT_ONDISKHASHTABLE_H -#include "llvm/Support/Allocator.h" #include "llvm/Support/AlignOf.h" +#include "llvm/Support/Allocator.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/EndianStream.h" #include "llvm/Support/Host.h" @@ -568,4 +568,4 @@ public: } // end namespace llvm -#endif // LLVM_SUPPORT_ON_DISK_HASH_TABLE_H +#endif diff --git a/contrib/llvm/include/llvm/Support/Options.h b/contrib/llvm/include/llvm/Support/Options.h new file mode 100644 index 000000000000..4fd1bff358fd --- /dev/null +++ b/contrib/llvm/include/llvm/Support/Options.h @@ -0,0 +1,120 @@ +//===- llvm/Support/Options.h - Debug options support -----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +/// \file +/// This file declares helper objects for defining debug options that can be +/// configured via the command line. The new API currently builds on the cl::opt +/// API, but does not require the use of static globals. +/// +/// With this API options are registered during initialization. For passes, this +/// happens during pass initialization. Passes with options will call a static +/// registerOptions method during initialization that registers options with the +/// OptionRegistry. An example implementation of registerOptions is: +/// +/// static void registerOptions() { +/// OptionRegistry::registerOption<bool, Scalarizer, +/// &Scalarizer::ScalarizeLoadStore>( +/// "scalarize-load-store", +/// "Allow the scalarizer pass to scalarize loads and store", false); +/// } +/// +/// When reading data for options the interface is via the LLVMContext. Option +/// data for passes should be read from the context during doInitialization. An +/// example of reading the above option would be: +/// +/// ScalarizeLoadStore = +/// M.getContext().getOption<bool, +/// Scalarizer, +/// &Scalarizer::ScalarizeLoadStore>(); +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_OPTIONS_H +#define LLVM_SUPPORT_OPTIONS_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/Support/CommandLine.h" + +namespace llvm { + +namespace detail { + +// Options are keyed of the unique address of a static character synthesized +// based on template arguments. +template <typename ValT, typename Base, ValT(Base::*Mem)> class OptionKey { +public: + static char ID; +}; + +template <typename ValT, typename Base, ValT(Base::*Mem)> +char OptionKey<ValT, Base, Mem>::ID = 0; + +} // namespace detail + +/// \brief Singleton class used to register debug options. +/// +/// The OptionRegistry is responsible for managing lifetimes of the options and +/// provides interfaces for option registration and reading values from options. +/// This object is a singleton, only one instance should ever exist so that all +/// options are registered in teh same place. +class OptionRegistry { +private: + DenseMap<void *, cl::Option *> Options; + + /// \brief Adds a cl::Option to the registry. + /// + /// \param Key unique key for option + /// \param O option to map to \p Key + /// + /// Allocated cl::Options are owened by the OptionRegistry and are deallocated + /// on destruction or removal + void addOption(void *Key, cl::Option *O); + +public: + ~OptionRegistry(); + OptionRegistry() {} + + /// \brief Returns a reference to the singleton instance. + static OptionRegistry &instance(); + + /// \brief Registers an option with the OptionRegistry singleton. + /// + /// \tparam ValT type of the option's data + /// \tparam Base class used to key the option + /// \tparam Mem member of \p Base used for keying the option + /// + /// Options are keyed off the template parameters to generate unique static + /// characters. The template parameters are (1) the type of the data the + /// option stores (\p ValT), the class that will read the option (\p Base), + /// and the memeber that the class will store the data into (\p Mem). + template <typename ValT, typename Base, ValT(Base::*Mem)> + static void registerOption(const char *ArgStr, const char *Desc, + const ValT &InitValue) { + cl::opt<ValT> *Option = new cl::opt<ValT>(ArgStr, cl::desc(Desc), + cl::Hidden, cl::init(InitValue)); + instance().addOption(&detail::OptionKey<ValT, Base, Mem>::ID, Option); + } + + /// \brief Returns the value of the option. + /// + /// \tparam ValT type of the option's data + /// \tparam Base class used to key the option + /// \tparam Mem member of \p Base used for keying the option + /// + /// Reads option values based on the key generated by the template parameters. + /// Keying for get() is the same as keying for registerOption. + template <typename ValT, typename Base, ValT(Base::*Mem)> ValT get() const { + auto It = Options.find(&detail::OptionKey<ValT, Base, Mem>::ID); + assert(It != Options.end() && "Option not in OptionRegistry"); + return *(cl::opt<ValT> *)It->second; + } +}; + +} // namespace llvm + +#endif diff --git a/contrib/llvm/include/llvm/Support/Path.h b/contrib/llvm/include/llvm/Support/Path.h index cf821f0ef4a4..8fae853e2cf4 100644 --- a/contrib/llvm/include/llvm/Support/Path.h +++ b/contrib/llvm/include/llvm/Support/Path.h @@ -30,13 +30,13 @@ namespace path { /// @brief Path iterator. /// -/// This is a bidirectional iterator that iterates over the individual -/// components in \a path. The forward traversal order is as follows: +/// This is an input iterator that iterates over the individual components in +/// \a path. The traversal order is as follows: /// * The root-name element, if present. /// * The root-directory element, if present. /// * Each successive filename element, if present. /// * Dot, if one or more trailing non-root slash characters are present. -/// The backwards traversal order is the reverse of forward traversal. +/// Traversing backwards is possible with \a reverse_iterator /// /// Iteration examples. Each component is separated by ',': /// @code @@ -47,7 +47,8 @@ namespace path { /// ../ => ..,. /// C:\foo\bar => C:,/,foo,bar /// @endcode -class const_iterator { +class const_iterator + : public std::iterator<std::input_iterator_tag, const StringRef> { StringRef Path; ///< The entire path. StringRef Component; ///< The current component. Not necessarily in Path. size_t Position; ///< The iterators current position within Path. @@ -57,26 +58,39 @@ class const_iterator { friend const_iterator end(StringRef path); public: - typedef const StringRef value_type; - typedef ptrdiff_t difference_type; - typedef value_type &reference; - typedef value_type *pointer; - typedef std::bidirectional_iterator_tag iterator_category; - reference operator*() const { return Component; } pointer operator->() const { return &Component; } const_iterator &operator++(); // preincrement const_iterator &operator++(int); // postincrement - const_iterator &operator--(); // predecrement - const_iterator &operator--(int); // postdecrement bool operator==(const const_iterator &RHS) const; - bool operator!=(const const_iterator &RHS) const; + bool operator!=(const const_iterator &RHS) const { return !(*this == RHS); } /// @brief Difference in bytes between this and RHS. ptrdiff_t operator-(const const_iterator &RHS) const; }; -typedef std::reverse_iterator<const_iterator> reverse_iterator; +/// @brief Reverse path iterator. +/// +/// This is an input iterator that iterates over the individual components in +/// \a path in reverse order. The traversal order is exactly reversed from that +/// of \a const_iterator +class reverse_iterator + : public std::iterator<std::input_iterator_tag, const StringRef> { + StringRef Path; ///< The entire path. + StringRef Component; ///< The current component. Not necessarily in Path. + size_t Position; ///< The iterators current position within Path. + + friend reverse_iterator rbegin(StringRef path); + friend reverse_iterator rend(StringRef path); + +public: + reference operator*() const { return Component; } + pointer operator->() const { return &Component; } + reverse_iterator &operator++(); // preincrement + reverse_iterator &operator++(int); // postincrement + bool operator==(const reverse_iterator &RHS) const; + bool operator!=(const reverse_iterator &RHS) const { return !(*this == RHS); } +}; /// @brief Get begin iterator over \a path. /// @param path Input path. @@ -91,16 +105,12 @@ const_iterator end(StringRef path); /// @brief Get reverse begin iterator over \a path. /// @param path Input path. /// @returns Iterator initialized with the first reverse component of \a path. -inline reverse_iterator rbegin(StringRef path) { - return reverse_iterator(end(path)); -} +reverse_iterator rbegin(StringRef path); /// @brief Get reverse end iterator over \a path. /// @param path Input path. /// @returns Iterator initialized to the reverse end of \a path. -inline reverse_iterator rend(StringRef path) { - return reverse_iterator(begin(path)); -} +reverse_iterator rend(StringRef path); /// @} /// @name Lexical Modifiers @@ -194,7 +204,7 @@ void native(SmallVectorImpl<char> &path); /// /// @param path Input path. /// @result The root name of \a path if it has one, otherwise "". -const StringRef root_name(StringRef path); +StringRef root_name(StringRef path); /// @brief Get root directory. /// @@ -207,7 +217,7 @@ const StringRef root_name(StringRef path); /// @param path Input path. /// @result The root directory of \a path if it has one, otherwise /// "". -const StringRef root_directory(StringRef path); +StringRef root_directory(StringRef path); /// @brief Get root path. /// @@ -215,7 +225,7 @@ const StringRef root_directory(StringRef path); /// /// @param path Input path. /// @result The root path of \a path if it has one, otherwise "". -const StringRef root_path(StringRef path); +StringRef root_path(StringRef path); /// @brief Get relative path. /// @@ -227,7 +237,7 @@ const StringRef root_path(StringRef path); /// /// @param path Input path. /// @result The path starting after root_path if one exists, otherwise "". -const StringRef relative_path(StringRef path); +StringRef relative_path(StringRef path); /// @brief Get parent path. /// @@ -239,7 +249,7 @@ const StringRef relative_path(StringRef path); /// /// @param path Input path. /// @result The parent path of \a path if one exists, otherwise "". -const StringRef parent_path(StringRef path); +StringRef parent_path(StringRef path); /// @brief Get filename. /// @@ -253,7 +263,7 @@ const StringRef parent_path(StringRef path); /// @param path Input path. /// @result The filename part of \a path. This is defined as the last component /// of \a path. -const StringRef filename(StringRef path); +StringRef filename(StringRef path); /// @brief Get stem. /// @@ -271,7 +281,7 @@ const StringRef filename(StringRef path); /// /// @param path Input path. /// @result The stem of \a path. -const StringRef stem(StringRef path); +StringRef stem(StringRef path); /// @brief Get extension. /// @@ -287,7 +297,7 @@ const StringRef stem(StringRef path); /// /// @param path Input path. /// @result The extension of \a path. -const StringRef extension(StringRef path); +StringRef extension(StringRef path); /// @brief Check whether the given char is a path separator on the host OS. /// @@ -298,7 +308,7 @@ bool is_separator(char value); /// @brief Return the preferred separator for this platform. /// /// @result StringRef of the preferred separator, null-terminated. -const StringRef get_separator(); +StringRef get_separator(); /// @brief Get the typical temporary directory for the system, e.g., /// "/var/tmp" or "C:/TEMP" diff --git a/contrib/llvm/include/llvm/Support/Process.h b/contrib/llvm/include/llvm/Support/Process.h index 30973de3aac4..cfdd06c62f33 100644 --- a/contrib/llvm/include/llvm/Support/Process.h +++ b/contrib/llvm/include/llvm/Support/Process.h @@ -38,111 +38,13 @@ class StringRef; namespace sys { -class self_process; - -/// \brief Generic base class which exposes information about an operating -/// system process. -/// -/// This base class is the core interface behind any OS process. It exposes -/// methods to query for generic information about a particular process. -/// -/// Subclasses implement this interface based on the mechanisms available, and -/// can optionally expose more interfaces unique to certain process kinds. -class process { -protected: - /// \brief Only specific subclasses of process objects can be destroyed. - virtual ~process(); - -public: - /// \brief Operating system specific type to identify a process. - /// - /// Note that the windows one is defined to 'unsigned long' as this is the - /// documented type for DWORD on windows, and we don't want to pull in the - /// Windows headers here. -#if defined(LLVM_ON_UNIX) - typedef pid_t id_type; -#elif defined(LLVM_ON_WIN32) - typedef unsigned long id_type; // Must match the type of DWORD. -#else -#error Unsupported operating system. -#endif - - /// \brief Get the operating system specific identifier for this process. - virtual id_type get_id() = 0; - - /// \brief Get the user time consumed by this process. - /// - /// Note that this is often an approximation and may be zero on platforms - /// where we don't have good support for the functionality. - virtual TimeValue get_user_time() const = 0; - - /// \brief Get the system time consumed by this process. - /// - /// Note that this is often an approximation and may be zero on platforms - /// where we don't have good support for the functionality. - virtual TimeValue get_system_time() const = 0; - - /// \brief Get the wall time consumed by this process. - /// - /// Note that this is often an approximation and may be zero on platforms - /// where we don't have good support for the functionality. - virtual TimeValue get_wall_time() const = 0; - - /// \name Static factory routines for processes. - /// @{ - - /// \brief Get the process object for the current process. - static self_process *get_self(); - - /// @} - -}; - -/// \brief The specific class representing the current process. -/// -/// The current process can both specialize the implementation of the routines -/// and can expose certain information not available for other OS processes. -class self_process : public process { - friend class process; - - /// \brief Private destructor, as users shouldn't create objects of this - /// type. - virtual ~self_process(); - -public: - id_type get_id() override; - TimeValue get_user_time() const override; - TimeValue get_system_time() const override; - TimeValue get_wall_time() const override; - - /// \name Process configuration (sysconf on POSIX) - /// @{ - - /// \brief Get the virtual memory page size. - /// - /// Query the operating system for this process's page size. - size_t page_size() const { return PageSize; }; - - /// @} - -private: - /// \name Cached process state. - /// @{ - - /// \brief Cached page size, this cannot vary during the life of the process. - size_t PageSize; - - /// @} - - /// \brief Constructor, used by \c process::get_self() only. - self_process(); -}; - /// \brief A collection of legacy interfaces for querying information about the /// current executing process. class Process { public: + static unsigned getPageSize(); + /// \brief Return process memory usage. /// This static function will return the total amount of memory allocated /// by the process. This only counts the memory allocated via the malloc, @@ -186,6 +88,21 @@ public: ArrayRef<const char *> ArgsFromMain, SpecificBumpPtrAllocator<char> &ArgAllocator); + // This functions ensures that the standard file descriptors (input, output, + // and error) are properly mapped to a file descriptor before we use any of + // them. This should only be called by standalone programs, library + // components should not call this. + static std::error_code FixupStandardFileDescriptors(); + + // This function safely closes a file descriptor. It is not safe to retry + // close(2) when it returns with errno equivalent to EINTR; this is because + // *nixen cannot agree if the file descriptor is, in fact, closed when this + // occurs. + // + // N.B. Some operating systems, due to thread cancellation, cannot properly + // guarantee that it will or will not be closed one way or the other! + static std::error_code SafelyCloseFileDescriptor(int FD); + /// This function determines if the standard input is connected directly /// to a user's input (keyboard probably), rather than coming from a file /// or pipe. diff --git a/contrib/llvm/include/llvm/Support/Program.h b/contrib/llvm/include/llvm/Support/Program.h index 51279a9b864a..40dc60fa30d6 100644 --- a/contrib/llvm/include/llvm/Support/Program.h +++ b/contrib/llvm/include/llvm/Support/Program.h @@ -15,6 +15,7 @@ #define LLVM_SUPPORT_PROGRAM_H #include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/ErrorOr.h" #include "llvm/Support/Path.h" #include <system_error> @@ -51,17 +52,22 @@ struct ProcessInfo { ProcessInfo(); }; - /// This function attempts to locate a program in the operating - /// system's file system using some pre-determined set of locations to search - /// (e.g. the PATH on Unix). Paths with slashes are returned unmodified. + /// \brief Find the first executable file \p Name in \p Paths. /// - /// It does not perform hashing as a shell would but instead stats each PATH + /// This does not perform hashing as a shell would but instead stats each PATH /// entry individually so should generally be avoided. Core LLVM library /// functions and options should instead require fully specified paths. /// - /// @returns A string containing the path of the program or an empty string if - /// the program could not be found. - std::string FindProgramByName(const std::string& name); + /// \param Name name of the executable to find. If it contains any system + /// slashes, it will be returned as is. + /// \param Paths optional list of paths to search for \p Name. If empty it + /// will use the system PATH environment instead. + /// + /// \returns The fully qualified path to the first \p Name in \p Paths if it + /// exists. \p Name if \p Name has slashes in it. Otherwise an error. + ErrorOr<std::string> + findProgramByName(StringRef Name, + ArrayRef<StringRef> Paths = ArrayRef<StringRef>()); // These functions change the specified standard stream (stdin or stdout) to // binary mode. They return errc::success if the specified stream @@ -82,7 +88,7 @@ struct ProcessInfo { /// -2 indicates a crash during execution or timeout int ExecuteAndWait( StringRef Program, ///< Path of the program to be executed. It is - /// presumed this is the result of the FindProgramByName method. + /// presumed this is the result of the findProgramByName method. const char **args, ///< A vector of strings that are passed to the ///< program. The first element should be the name of the program. ///< The list *must* be terminated by a null char* entry. @@ -126,6 +132,40 @@ struct ProcessInfo { /// argument length limits. bool argumentsFitWithinSystemLimits(ArrayRef<const char*> Args); + /// File encoding options when writing contents that a non-UTF8 tool will + /// read (on Windows systems). For UNIX, we always use UTF-8. + enum WindowsEncodingMethod { + /// UTF-8 is the LLVM native encoding, being the same as "do not perform + /// encoding conversion". + WEM_UTF8, + WEM_CurrentCodePage, + WEM_UTF16 + }; + + /// Saves the UTF8-encoded \p contents string into the file \p FileName + /// using a specific encoding. + /// + /// This write file function adds the possibility to choose which encoding + /// to use when writing a text file. On Windows, this is important when + /// writing files with internationalization support with an encoding that is + /// different from the one used in LLVM (UTF-8). We use this when writing + /// response files, since GCC tools on MinGW only understand legacy code + /// pages, and VisualStudio tools only understand UTF-16. + /// For UNIX, using different encodings is silently ignored, since all tools + /// work well with UTF-8. + /// This function assumes that you only use UTF-8 *text* data and will convert + /// it to your desired encoding before writing to the file. + /// + /// FIXME: We use EM_CurrentCodePage to write response files for GNU tools in + /// a MinGW/MinGW-w64 environment, which has serious flaws but currently is + /// our best shot to make gcc/ld understand international characters. This + /// should be changed as soon as binutils fix this to support UTF16 on mingw. + /// + /// \returns non-zero error_code if failed + std::error_code + writeFileWithEncoding(StringRef FileName, StringRef Contents, + WindowsEncodingMethod Encoding = WEM_UTF8); + /// This function waits for the process specified by \p PI to finish. /// \returns A \see ProcessInfo struct with Pid set to: /// \li The process id of the child process if the child process has changed diff --git a/contrib/llvm/include/llvm/Support/RWMutex.h b/contrib/llvm/include/llvm/Support/RWMutex.h index 935b3075df58..b80b8557576b 100644 --- a/contrib/llvm/include/llvm/Support/RWMutex.h +++ b/contrib/llvm/include/llvm/Support/RWMutex.h @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_SYSTEM_RWMUTEX_H -#define LLVM_SYSTEM_RWMUTEX_H +#ifndef LLVM_SUPPORT_RWMUTEX_H +#define LLVM_SUPPORT_RWMUTEX_H #include "llvm/Support/Compiler.h" #include "llvm/Support/Threading.h" @@ -85,14 +85,15 @@ namespace llvm /// indicates whether this mutex should become a no-op when we're not /// running in multithreaded mode. template<bool mt_only> - class SmartRWMutex : public RWMutexImpl { + class SmartRWMutex { + RWMutexImpl impl; unsigned readers, writers; public: - explicit SmartRWMutex() : RWMutexImpl(), readers(0), writers(0) { } + explicit SmartRWMutex() : impl(), readers(0), writers(0) { } - bool reader_acquire() { + bool lock_shared() { if (!mt_only || llvm_is_multithreaded()) - return RWMutexImpl::reader_acquire(); + return impl.reader_acquire(); // Single-threaded debugging code. This would be racy in multithreaded // mode, but provides not sanity checks in single threaded mode. @@ -100,9 +101,9 @@ namespace llvm return true; } - bool reader_release() { + bool unlock_shared() { if (!mt_only || llvm_is_multithreaded()) - return RWMutexImpl::reader_release(); + return impl.reader_release(); // Single-threaded debugging code. This would be racy in multithreaded // mode, but provides not sanity checks in single threaded mode. @@ -111,9 +112,9 @@ namespace llvm return true; } - bool writer_acquire() { + bool lock() { if (!mt_only || llvm_is_multithreaded()) - return RWMutexImpl::writer_acquire(); + return impl.writer_acquire(); // Single-threaded debugging code. This would be racy in multithreaded // mode, but provides not sanity checks in single threaded mode. @@ -122,9 +123,9 @@ namespace llvm return true; } - bool writer_release() { + bool unlock() { if (!mt_only || llvm_is_multithreaded()) - return RWMutexImpl::writer_release(); + return impl.writer_release(); // Single-threaded debugging code. This would be racy in multithreaded // mode, but provides not sanity checks in single threaded mode. @@ -145,11 +146,11 @@ namespace llvm SmartRWMutex<mt_only>& mutex; explicit SmartScopedReader(SmartRWMutex<mt_only>& m) : mutex(m) { - mutex.reader_acquire(); + mutex.lock_shared(); } ~SmartScopedReader() { - mutex.reader_release(); + mutex.unlock_shared(); } }; typedef SmartScopedReader<false> ScopedReader; @@ -160,11 +161,11 @@ namespace llvm SmartRWMutex<mt_only>& mutex; explicit SmartScopedWriter(SmartRWMutex<mt_only>& m) : mutex(m) { - mutex.writer_acquire(); + mutex.lock(); } ~SmartScopedWriter() { - mutex.writer_release(); + mutex.unlock(); } }; typedef SmartScopedWriter<false> ScopedWriter; diff --git a/contrib/llvm/include/llvm/Support/RandomNumberGenerator.h b/contrib/llvm/include/llvm/Support/RandomNumberGenerator.h index cadc713659d2..7ada34f075e4 100644 --- a/contrib/llvm/include/llvm/Support/RandomNumberGenerator.h +++ b/contrib/llvm/include/llvm/Support/RandomNumberGenerator.h @@ -7,9 +7,9 @@ // //===----------------------------------------------------------------------===// // -// This file defines an abstraction for random number generation (RNG). -// Note that the current implementation is not cryptographically secure -// as it uses the C++11 <random> facilities. +// This file defines an abstraction for deterministic random number +// generation (RNG). Note that the current implementation is not +// cryptographically secure as it uses the C++11 <random> facilities. // //===----------------------------------------------------------------------===// @@ -24,26 +24,27 @@ namespace llvm { /// A random number generator. -/// Instances of this class should not be shared across threads. +/// +/// Instances of this class should not be shared across threads. The +/// seed should be set by passing the -rng-seed=<uint64> option. Use +/// Module::createRNG to create a new RNG instance for use with that +/// module. class RandomNumberGenerator { public: - /// Seeds and salts the underlying RNG engine. The salt of type StringRef - /// is passed into the constructor. The seed can be set on the command - /// line via -rng-seed=<uint64>. - /// The reason for the salt is to ensure different random streams even if - /// the same seed is used for multiple invocations of the compiler. - /// A good salt value should add additional entropy and be constant across - /// different machines (i.e., no paths) to allow for reproducible builds. - /// An instance of this class can be retrieved from the current Module. - /// \see Module::getRNG - RandomNumberGenerator(StringRef Salt); - /// Returns a random number in the range [0, Max). - uint64_t next(uint64_t Max); + uint_fast64_t operator()(); private: + /// Seeds and salts the underlying RNG engine. + /// + /// This constructor should not be used directly. Instead use + /// Module::createRNG to create a new RNG salted with the Module ID. + RandomNumberGenerator(StringRef Salt); + // 64-bit Mersenne Twister by Matsumoto and Nishimura, 2000 // http://en.cppreference.com/w/cpp/numeric/random/mersenne_twister_engine + // This RNG is deterministically portable across C++11 + // implementations. std::mt19937_64 Generator; // Noncopyable. @@ -51,6 +52,8 @@ private: LLVM_DELETED_FUNCTION; RandomNumberGenerator & operator=(const RandomNumberGenerator &other) LLVM_DELETED_FUNCTION; + + friend class Module; }; } diff --git a/contrib/llvm/include/llvm/Support/Registry.h b/contrib/llvm/include/llvm/Support/Registry.h index b0c2e899855d..e21269b2f1d5 100644 --- a/contrib/llvm/include/llvm/Support/Registry.h +++ b/contrib/llvm/include/llvm/Support/Registry.h @@ -16,7 +16,6 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Compiler.h" - #include <memory> namespace llvm { diff --git a/contrib/llvm/include/llvm/Support/ScaledNumber.h b/contrib/llvm/include/llvm/Support/ScaledNumber.h index 2bd7e741dd28..a1c4c80c356f 100644 --- a/contrib/llvm/include/llvm/Support/ScaledNumber.h +++ b/contrib/llvm/include/llvm/Support/ScaledNumber.h @@ -23,7 +23,6 @@ #define LLVM_SUPPORT_SCALEDNUMBER_H #include "llvm/Support/MathExtras.h" - #include <algorithm> #include <cstdint> #include <limits> diff --git a/contrib/llvm/include/llvm/Support/SourceMgr.h b/contrib/llvm/include/llvm/Support/SourceMgr.h index 4717553bd0de..f9e114b67cb4 100644 --- a/contrib/llvm/include/llvm/Support/SourceMgr.h +++ b/contrib/llvm/include/llvm/Support/SourceMgr.h @@ -19,11 +19,11 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/SMLoc.h" #include <string> namespace llvm { - class MemoryBuffer; class SourceMgr; class SMDiagnostic; class SMFixIt; @@ -47,10 +47,15 @@ public: private: struct SrcBuffer { /// The memory buffer for the file. - MemoryBuffer *Buffer; + std::unique_ptr<MemoryBuffer> Buffer; /// This is the location of the parent include, or null if at the top level. SMLoc IncludeLoc; + + SrcBuffer() {} + + SrcBuffer(SrcBuffer &&O) + : Buffer(std::move(O.Buffer)), IncludeLoc(O.IncludeLoc) {} }; /// This is all of the buffers that we are reading from. @@ -96,7 +101,7 @@ public: const MemoryBuffer *getMemoryBuffer(unsigned i) const { assert(isValidBufferID(i)); - return Buffers[i - 1].Buffer; + return Buffers[i - 1].Buffer.get(); } unsigned getNumBuffers() const { @@ -115,11 +120,12 @@ public: /// Add a new source buffer to this source manager. This takes ownership of /// the memory buffer. - unsigned AddNewSourceBuffer(MemoryBuffer *F, SMLoc IncludeLoc) { + unsigned AddNewSourceBuffer(std::unique_ptr<MemoryBuffer> F, + SMLoc IncludeLoc) { SrcBuffer NB; - NB.Buffer = F; + NB.Buffer = std::move(F); NB.IncludeLoc = IncludeLoc; - Buffers.push_back(NB); + Buffers.push_back(std::move(NB)); return Buffers.size(); } diff --git a/contrib/llvm/include/llvm/Support/SpecialCaseList.h b/contrib/llvm/include/llvm/Support/SpecialCaseList.h index 098b9c7a17b7..313212e59dd2 100644 --- a/contrib/llvm/include/llvm/Support/SpecialCaseList.h +++ b/contrib/llvm/include/llvm/Support/SpecialCaseList.h @@ -56,17 +56,19 @@ class Regex; class StringRef; class SpecialCaseList { - public: +public: /// Parses the special case list from a file. If Path is empty, returns /// an empty special case list. On failure, returns 0 and writes an error /// message to string. - static SpecialCaseList *create(const StringRef Path, std::string &Error); + static std::unique_ptr<SpecialCaseList> create(StringRef Path, + std::string &Error); /// Parses the special case list from a memory buffer. On failure, returns /// 0 and writes an error message to string. - static SpecialCaseList *create(const MemoryBuffer *MB, std::string &Error); + static std::unique_ptr<SpecialCaseList> create(const MemoryBuffer *MB, + std::string &Error); /// Parses the special case list from a file. On failure, reports a fatal /// error. - static SpecialCaseList *createOrDie(const StringRef Path); + static std::unique_ptr<SpecialCaseList> createOrDie(StringRef Path); ~SpecialCaseList(); @@ -75,10 +77,10 @@ class SpecialCaseList { /// @Section:<E>=@Category /// \endcode /// and @Query satisfies a wildcard expression <E>. - bool inSection(const StringRef Section, const StringRef Query, - const StringRef Category = StringRef()) const; + bool inSection(StringRef Section, StringRef Query, + StringRef Category = StringRef()) const; - private: +private: SpecialCaseList(SpecialCaseList const &) LLVM_DELETED_FUNCTION; SpecialCaseList &operator=(SpecialCaseList const &) LLVM_DELETED_FUNCTION; diff --git a/contrib/llvm/include/llvm/Support/StreamableMemoryObject.h b/contrib/llvm/include/llvm/Support/StreamableMemoryObject.h deleted file mode 100644 index 6e71ad47c8dd..000000000000 --- a/contrib/llvm/include/llvm/Support/StreamableMemoryObject.h +++ /dev/null @@ -1,178 +0,0 @@ -//===- StreamableMemoryObject.h - Streamable data interface -----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - - -#ifndef LLVM_SUPPORT_STREAMABLEMEMORYOBJECT_H -#define LLVM_SUPPORT_STREAMABLEMEMORYOBJECT_H - -#include "llvm/Support/Compiler.h" -#include "llvm/Support/DataStream.h" -#include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/MemoryObject.h" -#include <cassert> -#include <memory> -#include <vector> - -namespace llvm { - -/// StreamableMemoryObject - Interface to data which might be streamed. -/// Streamability has 2 important implications/restrictions. First, the data -/// might not yet exist in memory when the request is made. This just means -/// that readByte/readBytes might have to block or do some work to get it. -/// More significantly, the exact size of the object might not be known until -/// it has all been fetched. This means that to return the right result, -/// getExtent must also wait for all the data to arrive; therefore it should -/// not be called on objects which are actually streamed (this would defeat -/// the purpose of streaming). Instead, isValidAddress and isObjectEnd can be -/// used to test addresses without knowing the exact size of the stream. -/// Finally, getPointer can be used instead of readBytes to avoid extra copying. -class StreamableMemoryObject : public MemoryObject { - public: - /// Destructor - Override as necessary. - virtual ~StreamableMemoryObject(); - - /// getBase - Returns the lowest valid address in the region. - /// - /// @result - The lowest valid address. - uint64_t getBase() const override = 0; - - /// getExtent - Returns the size of the region in bytes. (The region is - /// contiguous, so the highest valid address of the region - /// is getBase() + getExtent() - 1). - /// May block until all bytes in the stream have been read - /// - /// @result - The size of the region. - uint64_t getExtent() const override = 0; - - /// readByte - Tries to read a single byte from the region. - /// May block until (address - base) bytes have been read - /// @param address - The address of the byte, in the same space as getBase(). - /// @param ptr - A pointer to a byte to be filled in. Must be non-NULL. - /// @result - 0 if successful; -1 if not. Failure may be due to a - /// bounds violation or an implementation-specific error. - int readByte(uint64_t address, uint8_t *ptr) const override = 0; - - /// readBytes - Tries to read a contiguous range of bytes from the - /// region, up to the end of the region. - /// May block until (address - base + size) bytes have - /// been read. Additionally, StreamableMemoryObjects will - /// not do partial reads - if size bytes cannot be read, - /// readBytes will fail. - /// - /// @param address - The address of the first byte, in the same space as - /// getBase(). - /// @param size - The number of bytes to copy. - /// @param buf - A pointer to a buffer to be filled in. Must be non-NULL - /// and large enough to hold size bytes. - /// @result - 0 if successful; -1 if not. Failure may be due to a - /// bounds violation or an implementation-specific error. - int readBytes(uint64_t address, uint64_t size, - uint8_t *buf) const override = 0; - - /// getPointer - Ensures that the requested data is in memory, and returns - /// A pointer to it. More efficient than using readBytes if the - /// data is already in memory. - /// May block until (address - base + size) bytes have been read - /// @param address - address of the byte, in the same space as getBase() - /// @param size - amount of data that must be available on return - /// @result - valid pointer to the requested data - virtual const uint8_t *getPointer(uint64_t address, uint64_t size) const = 0; - - /// isValidAddress - Returns true if the address is within the object - /// (i.e. between base and base + extent - 1 inclusive) - /// May block until (address - base) bytes have been read - /// @param address - address of the byte, in the same space as getBase() - /// @result - true if the address may be read with readByte() - virtual bool isValidAddress(uint64_t address) const = 0; - - /// isObjectEnd - Returns true if the address is one past the end of the - /// object (i.e. if it is equal to base + extent) - /// May block until (address - base) bytes have been read - /// @param address - address of the byte, in the same space as getBase() - /// @result - true if the address is equal to base + extent - virtual bool isObjectEnd(uint64_t address) const = 0; -}; - -/// StreamingMemoryObject - interface to data which is actually streamed from -/// a DataStreamer. In addition to inherited members, it has the -/// dropLeadingBytes and setKnownObjectSize methods which are not applicable -/// to non-streamed objects. -class StreamingMemoryObject : public StreamableMemoryObject { -public: - StreamingMemoryObject(DataStreamer *streamer); - uint64_t getBase() const override { return 0; } - uint64_t getExtent() const override; - int readByte(uint64_t address, uint8_t *ptr) const override; - int readBytes(uint64_t address, uint64_t size, - uint8_t *buf) const override; - const uint8_t *getPointer(uint64_t address, uint64_t size) const override { - // This could be fixed by ensuring the bytes are fetched and making a copy, - // requiring that the bitcode size be known, or otherwise ensuring that - // the memory doesn't go away/get reallocated, but it's - // not currently necessary. Users that need the pointer don't stream. - llvm_unreachable("getPointer in streaming memory objects not allowed"); - return nullptr; - } - bool isValidAddress(uint64_t address) const override; - bool isObjectEnd(uint64_t address) const override; - - /// Drop s bytes from the front of the stream, pushing the positions of the - /// remaining bytes down by s. This is used to skip past the bitcode header, - /// since we don't know a priori if it's present, and we can't put bytes - /// back into the stream once we've read them. - bool dropLeadingBytes(size_t s); - - /// If the data object size is known in advance, many of the operations can - /// be made more efficient, so this method should be called before reading - /// starts (although it can be called anytime). - void setKnownObjectSize(size_t size); - -private: - const static uint32_t kChunkSize = 4096 * 4; - mutable std::vector<unsigned char> Bytes; - std::unique_ptr<DataStreamer> Streamer; - mutable size_t BytesRead; // Bytes read from stream - size_t BytesSkipped;// Bytes skipped at start of stream (e.g. wrapper/header) - mutable size_t ObjectSize; // 0 if unknown, set if wrapper seen or EOF reached - mutable bool EOFReached; - - // Fetch enough bytes such that Pos can be read or EOF is reached - // (i.e. BytesRead > Pos). Return true if Pos can be read. - // Unlike most of the functions in BitcodeReader, returns true on success. - // Most of the requests will be small, but we fetch at kChunkSize bytes - // at a time to avoid making too many potentially expensive GetBytes calls - bool fetchToPos(size_t Pos) const { - if (EOFReached) return Pos < ObjectSize; - while (Pos >= BytesRead) { - Bytes.resize(BytesRead + BytesSkipped + kChunkSize); - size_t bytes = Streamer->GetBytes(&Bytes[BytesRead + BytesSkipped], - kChunkSize); - BytesRead += bytes; - if (bytes < kChunkSize) { - assert((!ObjectSize || BytesRead >= Pos) && - "Unexpected short read fetching bitcode"); - if (BytesRead <= Pos) { // reached EOF/ran out of bytes - ObjectSize = BytesRead; - EOFReached = true; - return false; - } - } - } - return true; - } - - StreamingMemoryObject(const StreamingMemoryObject&) LLVM_DELETED_FUNCTION; - void operator=(const StreamingMemoryObject&) LLVM_DELETED_FUNCTION; -}; - -StreamableMemoryObject *getNonStreamedMemoryObject( - const unsigned char *Start, const unsigned char *End); - -} -#endif // STREAMABLEMEMORYOBJECT_H_ diff --git a/contrib/llvm/include/llvm/Support/StreamingMemoryObject.h b/contrib/llvm/include/llvm/Support/StreamingMemoryObject.h new file mode 100644 index 000000000000..66ed521a411c --- /dev/null +++ b/contrib/llvm/include/llvm/Support/StreamingMemoryObject.h @@ -0,0 +1,92 @@ +//===- StreamingMemoryObject.h - Streamable data interface -----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_STREAMINGMEMORYOBJECT_H +#define LLVM_SUPPORT_STREAMINGMEMORYOBJECT_H + +#include "llvm/Support/Compiler.h" +#include "llvm/Support/DataStream.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/MemoryObject.h" +#include <cassert> +#include <memory> +#include <vector> + +namespace llvm { + +/// Interface to data which is actually streamed from a DataStreamer. In +/// addition to inherited members, it has the dropLeadingBytes and +/// setKnownObjectSize methods which are not applicable to non-streamed objects. +class StreamingMemoryObject : public MemoryObject { +public: + StreamingMemoryObject(DataStreamer *streamer); + uint64_t getExtent() const override; + uint64_t readBytes(uint8_t *Buf, uint64_t Size, + uint64_t Address) const override; + const uint8_t *getPointer(uint64_t address, uint64_t size) const override { + // This could be fixed by ensuring the bytes are fetched and making a copy, + // requiring that the bitcode size be known, or otherwise ensuring that + // the memory doesn't go away/get reallocated, but it's + // not currently necessary. Users that need the pointer don't stream. + llvm_unreachable("getPointer in streaming memory objects not allowed"); + return nullptr; + } + bool isValidAddress(uint64_t address) const override; + + /// Drop s bytes from the front of the stream, pushing the positions of the + /// remaining bytes down by s. This is used to skip past the bitcode header, + /// since we don't know a priori if it's present, and we can't put bytes + /// back into the stream once we've read them. + bool dropLeadingBytes(size_t s); + + /// If the data object size is known in advance, many of the operations can + /// be made more efficient, so this method should be called before reading + /// starts (although it can be called anytime). + void setKnownObjectSize(size_t size); + +private: + const static uint32_t kChunkSize = 4096 * 4; + mutable std::vector<unsigned char> Bytes; + std::unique_ptr<DataStreamer> Streamer; + mutable size_t BytesRead; // Bytes read from stream + size_t BytesSkipped;// Bytes skipped at start of stream (e.g. wrapper/header) + mutable size_t ObjectSize; // 0 if unknown, set if wrapper seen or EOF reached + mutable bool EOFReached; + + // Fetch enough bytes such that Pos can be read or EOF is reached + // (i.e. BytesRead > Pos). Return true if Pos can be read. + // Unlike most of the functions in BitcodeReader, returns true on success. + // Most of the requests will be small, but we fetch at kChunkSize bytes + // at a time to avoid making too many potentially expensive GetBytes calls + bool fetchToPos(size_t Pos) const { + if (EOFReached) + return Pos < ObjectSize; + while (Pos >= BytesRead) { + Bytes.resize(BytesRead + BytesSkipped + kChunkSize); + size_t bytes = Streamer->GetBytes(&Bytes[BytesRead + BytesSkipped], + kChunkSize); + BytesRead += bytes; + if (bytes != kChunkSize) { // reached EOF/ran out of bytes + ObjectSize = BytesRead; + EOFReached = true; + break; + } + } + return Pos < BytesRead; + } + + StreamingMemoryObject(const StreamingMemoryObject&) LLVM_DELETED_FUNCTION; + void operator=(const StreamingMemoryObject&) LLVM_DELETED_FUNCTION; +}; + +MemoryObject *getNonStreamedMemoryObject( + const unsigned char *Start, const unsigned char *End); + +} +#endif // STREAMINGMEMORYOBJECT_H_ diff --git a/contrib/llvm/include/llvm/Support/StringPool.h b/contrib/llvm/include/llvm/Support/StringPool.h index 3e0465340c3b..b51974c946e0 100644 --- a/contrib/llvm/include/llvm/Support/StringPool.h +++ b/contrib/llvm/include/llvm/Support/StringPool.h @@ -29,8 +29,8 @@ #ifndef LLVM_SUPPORT_STRINGPOOL_H #define LLVM_SUPPORT_STRINGPOOL_H -#include "llvm/Support/Compiler.h" #include "llvm/ADT/StringMap.h" +#include "llvm/Support/Compiler.h" #include <cassert> #include <new> diff --git a/contrib/llvm/include/llvm/Support/StringRefMemoryObject.h b/contrib/llvm/include/llvm/Support/StringRefMemoryObject.h deleted file mode 100644 index 8a349eab84c8..000000000000 --- a/contrib/llvm/include/llvm/Support/StringRefMemoryObject.h +++ /dev/null @@ -1,41 +0,0 @@ -//===- llvm/Support/StringRefMemoryObject.h ---------------------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file contains the declaration of the StringRefMemObject class, a simple -// wrapper around StringRef implementing the MemoryObject interface. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_STRINGREFMEMORYOBJECT_H -#define LLVM_SUPPORT_STRINGREFMEMORYOBJECT_H - -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/Compiler.h" -#include "llvm/Support/MemoryObject.h" - -namespace llvm { - -/// StringRefMemoryObject - Simple StringRef-backed MemoryObject -class StringRefMemoryObject : public MemoryObject { - StringRef Bytes; - uint64_t Base; -public: - StringRefMemoryObject(StringRef Bytes, uint64_t Base = 0) - : Bytes(Bytes), Base(Base) {} - - uint64_t getBase() const override { return Base; } - uint64_t getExtent() const override { return Bytes.size(); } - - int readByte(uint64_t Addr, uint8_t *Byte) const override; - int readBytes(uint64_t Addr, uint64_t Size, uint8_t *Buf) const override; -}; - -} - -#endif diff --git a/contrib/llvm/include/llvm/Support/SwapByteOrder.h b/contrib/llvm/include/llvm/Support/SwapByteOrder.h index 340954f4c893..9c5a3c59122e 100644 --- a/contrib/llvm/include/llvm/Support/SwapByteOrder.h +++ b/contrib/llvm/include/llvm/Support/SwapByteOrder.h @@ -15,6 +15,7 @@ #ifndef LLVM_SUPPORT_SWAPBYTEORDER_H #define LLVM_SUPPORT_SWAPBYTEORDER_H +#include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" #include <cstddef> #include <limits> @@ -39,8 +40,7 @@ inline uint16_t SwapByteOrder_16(uint16_t value) { /// SwapByteOrder_32 - This function returns a byte-swapped representation of /// the 32-bit argument. inline uint32_t SwapByteOrder_32(uint32_t value) { -#if defined(__llvm__) || \ -(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) && !defined(__ICC) +#if defined(__llvm__) || (LLVM_GNUC_PREREQ(4, 3, 0) && !defined(__ICC)) return __builtin_bswap32(value); #elif defined(_MSC_VER) && !defined(_DEBUG) return _byteswap_ulong(value); @@ -56,8 +56,7 @@ inline uint32_t SwapByteOrder_32(uint32_t value) { /// SwapByteOrder_64 - This function returns a byte-swapped representation of /// the 64-bit argument. inline uint64_t SwapByteOrder_64(uint64_t value) { -#if defined(__llvm__) || \ -(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) && !defined(__ICC) +#if defined(__llvm__) || (LLVM_GNUC_PREREQ(4, 3, 0) && !defined(__ICC)) return __builtin_bswap64(value); #elif defined(_MSC_VER) && !defined(_DEBUG) return _byteswap_uint64(value); diff --git a/contrib/llvm/include/llvm/Support/TargetRegistry.h b/contrib/llvm/include/llvm/Support/TargetRegistry.h index 5d5b86a6a2ae..8ac4b904bb88 100644 --- a/contrib/llvm/include/llvm/Support/TargetRegistry.h +++ b/contrib/llvm/include/llvm/Support/TargetRegistry.h @@ -123,15 +123,10 @@ namespace llvm { const MCRegisterInfo &MRI, const MCSubtargetInfo &STI, MCContext &Ctx); - typedef MCStreamer *(*MCObjectStreamerCtorTy)(const Target &T, - StringRef TT, - MCContext &Ctx, - MCAsmBackend &TAB, - raw_ostream &_OS, - MCCodeEmitter *_Emitter, - const MCSubtargetInfo &STI, - bool RelaxAll, - bool NoExecStack); + typedef MCStreamer *(*MCObjectStreamerCtorTy)( + const Target &T, StringRef TT, MCContext &Ctx, MCAsmBackend &TAB, + raw_ostream &_OS, MCCodeEmitter *_Emitter, const MCSubtargetInfo &STI, + bool RelaxAll); typedef MCStreamer *(*AsmStreamerCtorTy)(MCContext &Ctx, formatted_raw_ostream &OS, bool isVerboseAsm, @@ -423,18 +418,15 @@ namespace llvm { /// \param _OS The stream object. /// \param _Emitter The target independent assembler object.Takes ownership. /// \param RelaxAll Relax all fixups? - /// \param NoExecStack Mark file as not needing a executable stack. MCStreamer *createMCObjectStreamer(StringRef TT, MCContext &Ctx, - MCAsmBackend &TAB, - raw_ostream &_OS, + MCAsmBackend &TAB, raw_ostream &_OS, MCCodeEmitter *_Emitter, const MCSubtargetInfo &STI, - bool RelaxAll, - bool NoExecStack) const { + bool RelaxAll) const { if (!MCObjectStreamerCtorFn) return nullptr; return MCObjectStreamerCtorFn(*this, TT, Ctx, TAB, _OS, _Emitter, STI, - RelaxAll, NoExecStack); + RelaxAll); } /// createAsmStreamer - Create a target specific MCStreamer. diff --git a/contrib/llvm/include/llvm/Support/ThreadLocal.h b/contrib/llvm/include/llvm/Support/ThreadLocal.h index 7518626901e0..427a67e2a96d 100644 --- a/contrib/llvm/include/llvm/Support/ThreadLocal.h +++ b/contrib/llvm/include/llvm/Support/ThreadLocal.h @@ -36,7 +36,7 @@ namespace llvm { ThreadLocalImpl(); virtual ~ThreadLocalImpl(); void setInstance(const void* d); - const void* getInstance(); + void *getInstance(); void removeInstance(); }; diff --git a/contrib/llvm/include/llvm/Support/Threading.h b/contrib/llvm/include/llvm/Support/Threading.h index 7e8758407c7c..3cca1d6a9913 100644 --- a/contrib/llvm/include/llvm/Support/Threading.h +++ b/contrib/llvm/include/llvm/Support/Threading.h @@ -21,7 +21,8 @@ namespace llvm { bool llvm_is_multithreaded(); /// llvm_execute_on_thread - Execute the given \p UserFn on a separate - /// thread, passing it the provided \p UserData. + /// thread, passing it the provided \p UserData and waits for thread + /// completion. /// /// This function does not guarantee that the code will actually be executed /// on a separate thread or honoring the requested stack size, but tries to do diff --git a/contrib/llvm/include/llvm/Support/TimeValue.h b/contrib/llvm/include/llvm/Support/TimeValue.h index ee0e2866d59e..6bca58b6bc20 100644 --- a/contrib/llvm/include/llvm/Support/TimeValue.h +++ b/contrib/llvm/include/llvm/Support/TimeValue.h @@ -38,28 +38,38 @@ namespace sys { /// value permissible by the class. MinTime is some point /// in the distant past, about 300 billion years BCE. /// @brief The smallest possible time value. - static const TimeValue MinTime; + static TimeValue MinTime() { + return TimeValue ( INT64_MIN,0 ); + } /// A constant TimeValue representing the largest time /// value permissible by the class. MaxTime is some point /// in the distant future, about 300 billion years AD. /// @brief The largest possible time value. - static const TimeValue MaxTime; + static TimeValue MaxTime() { + return TimeValue ( INT64_MAX,0 ); + } /// A constant TimeValue representing the base time, /// or zero time of 00:00:00 (midnight) January 1st, 2000. /// @brief 00:00:00 Jan 1, 2000 UTC. - static const TimeValue ZeroTime; + static TimeValue ZeroTime() { + return TimeValue ( 0,0 ); + } /// A constant TimeValue for the Posix base time which is /// 00:00:00 (midnight) January 1st, 1970. /// @brief 00:00:00 Jan 1, 1970 UTC. - static const TimeValue PosixZeroTime; + static TimeValue PosixZeroTime() { + return TimeValue ( PosixZeroTimeSeconds,0 ); + } /// A constant TimeValue for the Win32 base time which is /// 00:00:00 (midnight) January 1st, 1601. /// @brief 00:00:00 Jan 1, 1601 UTC. - static const TimeValue Win32ZeroTime; + static TimeValue Win32ZeroTime() { + return TimeValue ( Win32ZeroTimeSeconds,0 ); + } /// @} /// @name Types diff --git a/contrib/llvm/include/llvm/Support/ToolOutputFile.h b/contrib/llvm/include/llvm/Support/ToolOutputFile.h index 88f8ccc292d3..d98e7bbd51d4 100644 --- a/contrib/llvm/include/llvm/Support/ToolOutputFile.h +++ b/contrib/llvm/include/llvm/Support/ToolOutputFile.h @@ -29,13 +29,13 @@ class tool_output_file { /// destructed after the raw_fd_ostream is destructed. It installs /// cleanups in its constructor and uninstalls them in its destructor. class CleanupInstaller { - /// Filename - The name of the file. + /// The name of the file. std::string Filename; public: - /// Keep - The flag which indicates whether we should not delete the file. + /// The flag which indicates whether we should not delete the file. bool Keep; - explicit CleanupInstaller(const char *filename); + explicit CleanupInstaller(StringRef ilename); ~CleanupInstaller(); } Installer; @@ -44,12 +44,12 @@ class tool_output_file { raw_fd_ostream OS; public: - /// tool_output_file - This constructor's arguments are passed to - /// to raw_fd_ostream's constructor. - tool_output_file(const char *filename, std::string &ErrorInfo, + /// This constructor's arguments are passed to to raw_fd_ostream's + /// constructor. + tool_output_file(StringRef Filename, std::error_code &EC, sys::fs::OpenFlags Flags); - tool_output_file(const char *Filename, int FD); + tool_output_file(StringRef Filename, int FD); /// os - Return the contained raw_fd_ostream. raw_fd_ostream &os() { return OS; } diff --git a/contrib/llvm/include/llvm/Support/UniqueLock.h b/contrib/llvm/include/llvm/Support/UniqueLock.h new file mode 100644 index 000000000000..5a4c273e83e2 --- /dev/null +++ b/contrib/llvm/include/llvm/Support/UniqueLock.h @@ -0,0 +1,67 @@ +//===-- Support/UniqueLock.h - Acquire/Release Mutex In Scope ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file defines a guard for a block of code that ensures a Mutex is locked +// upon construction and released upon destruction. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_UNIQUE_LOCK_H +#define LLVM_SUPPORT_UNIQUE_LOCK_H + +#include "llvm/Support/Mutex.h" + +namespace llvm { + /// A pared-down imitation of std::unique_lock from C++11. Contrary to the + /// name, it's really more of a wrapper for a lock. It may or may not have + /// an associated mutex, which is guaranteed to be locked upon creation + /// and unlocked after destruction. unique_lock can also unlock the mutex + /// and re-lock it freely during its lifetime. + /// @brief Guard a section of code with a mutex. + template<typename MutexT> + class unique_lock { + MutexT *M; + bool locked; + + unique_lock(const unique_lock &) LLVM_DELETED_FUNCTION; + void operator=(const unique_lock &) LLVM_DELETED_FUNCTION; + public: + unique_lock() : M(nullptr), locked(false) {} + explicit unique_lock(MutexT &m) : M(&m), locked(true) { M->lock(); } + + void operator=(unique_lock &&o) { + if (owns_lock()) + M->unlock(); + M = o.M; + locked = o.locked; + o.M = nullptr; + o.locked = false; + } + + ~unique_lock() { if (owns_lock()) M->unlock(); } + + void lock() { + assert(!locked && "mutex already locked!"); + assert(M && "no associated mutex!"); + M->lock(); + locked = true; + } + + void unlock() { + assert(locked && "unlocking a mutex that isn't locked!"); + assert(M && "no associated mutex!"); + M->unlock(); + locked = false; + } + + bool owns_lock() { return locked; } + }; +} + +#endif // LLVM_SUPPORT_UNIQUE_LOCK_H diff --git a/contrib/llvm/include/llvm/Support/Win64EH.h b/contrib/llvm/include/llvm/Support/Win64EH.h index 7ca218e87a77..f6c492794875 100644 --- a/contrib/llvm/include/llvm/Support/Win64EH.h +++ b/contrib/llvm/include/llvm/Support/Win64EH.h @@ -40,8 +40,8 @@ enum UnwindOpcodes { /// or part thereof. union UnwindCode { struct { - support::ulittle8_t CodeOffset; - support::ulittle8_t UnwindOpAndOpInfo; + uint8_t CodeOffset; + uint8_t UnwindOpAndOpInfo; } u; support::ulittle16_t FrameOffset; @@ -74,10 +74,10 @@ struct RuntimeFunction { /// UnwindInfo - An entry in the exception table. struct UnwindInfo { - support::ulittle8_t VersionAndFlags; - support::ulittle8_t PrologSize; - support::ulittle8_t NumCodes; - support::ulittle8_t FrameRegisterAndOffset; + uint8_t VersionAndFlags; + uint8_t PrologSize; + uint8_t NumCodes; + uint8_t FrameRegisterAndOffset; UnwindCode UnwindCodes[1]; uint8_t getVersion() const { diff --git a/contrib/llvm/include/llvm/Support/WindowsError.h b/contrib/llvm/include/llvm/Support/WindowsError.h index 0e909a05bf4a..63bfe5976546 100644 --- a/contrib/llvm/include/llvm/Support/WindowsError.h +++ b/contrib/llvm/include/llvm/Support/WindowsError.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_SUPPORT_WINDOWS_ERROR_H -#define LLVM_SUPPORT_WINDOWS_ERROR_H +#ifndef LLVM_SUPPORT_WINDOWSERROR_H +#define LLVM_SUPPORT_WINDOWSERROR_H #include <system_error> diff --git a/contrib/llvm/include/llvm/Support/YAMLParser.h b/contrib/llvm/include/llvm/Support/YAMLParser.h index c39874cbd2c5..de6e6544e25b 100644 --- a/contrib/llvm/include/llvm/Support/YAMLParser.h +++ b/contrib/llvm/include/llvm/Support/YAMLParser.h @@ -41,13 +41,13 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Allocator.h" +#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/SMLoc.h" #include <limits> #include <map> #include <utility> namespace llvm { -class MemoryBuffer; class SourceMgr; class raw_ostream; class Twine; @@ -79,8 +79,7 @@ public: /// \brief This keeps a reference to the string referenced by \p Input. Stream(StringRef Input, SourceMgr &); - /// \brief This takes ownership of \p InputBuffer. - Stream(MemoryBuffer *InputBuffer, SourceMgr &); + Stream(MemoryBufferRef InputBuffer, SourceMgr &); ~Stream(); document_iterator begin(); diff --git a/contrib/llvm/include/llvm/Support/YAMLTraits.h b/contrib/llvm/include/llvm/Support/YAMLTraits.h index a23faf65bb59..023dcee7d54c 100644 --- a/contrib/llvm/include/llvm/Support/YAMLTraits.h +++ b/contrib/llvm/include/llvm/Support/YAMLTraits.h @@ -943,16 +943,17 @@ private: }; class MapHNode : public HNode { + virtual void anchor(); + public: MapHNode(Node *n) : HNode(n) { } - virtual ~MapHNode(); static inline bool classof(const HNode *n) { return MappingNode::classof(n->_node); } static inline bool classof(const MapHNode *) { return true; } - typedef llvm::StringMap<HNode*> NameToNode; + typedef llvm::StringMap<std::unique_ptr<HNode>> NameToNode; bool isValidKey(StringRef key); @@ -961,19 +962,20 @@ private: }; class SequenceHNode : public HNode { + virtual void anchor(); + public: SequenceHNode(Node *n) : HNode(n) { } - virtual ~SequenceHNode(); static inline bool classof(const HNode *n) { return SequenceNode::classof(n->_node); } static inline bool classof(const SequenceHNode *) { return true; } - std::vector<HNode*> Entries; + std::vector<std::unique_ptr<HNode>> Entries; }; - Input::HNode *createHNodes(Node *node); + std::unique_ptr<Input::HNode> createHNodes(Node *node); void setError(HNode *hnode, const Twine &message); void setError(Node *node, const Twine &message); diff --git a/contrib/llvm/include/llvm/Support/raw_ostream.h b/contrib/llvm/include/llvm/Support/raw_ostream.h index 34fbe082cda8..c9ef637940db 100644 --- a/contrib/llvm/include/llvm/Support/raw_ostream.h +++ b/contrib/llvm/include/llvm/Support/raw_ostream.h @@ -17,9 +17,12 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" +#include <system_error> namespace llvm { class format_object_base; + class FormattedString; + class FormattedNumber; template <typename T> class SmallVectorImpl; @@ -210,6 +213,12 @@ public: // Formatted output, see the format() function in Support/Format.h. raw_ostream &operator<<(const format_object_base &Fmt); + // Formatted output, see the leftJustify() function in Support/Format.h. + raw_ostream &operator<<(const FormattedString &); + + // Formatted output, see the formatHex() function in Support/Format.h. + raw_ostream &operator<<(const FormattedNumber &); + /// indent - Insert 'NumSpaces' spaces. raw_ostream &indent(unsigned NumSpaces); @@ -341,17 +350,17 @@ class raw_fd_ostream : public raw_ostream { void error_detected() { Error = true; } public: - /// raw_fd_ostream - Open the specified file for writing. If an error occurs, - /// information about the error is put into ErrorInfo, and the stream should - /// be immediately destroyed; the string will be empty if no error occurred. - /// This allows optional flags to control how the file will be opened. + /// Open the specified file for writing. If an error occurs, information + /// about the error is put into EC, and the stream should be immediately + /// destroyed; + /// \p Flags allows optional flags to control how the file will be opened. /// /// As a special case, if Filename is "-", then the stream will use /// STDOUT_FILENO instead of opening a file. Note that it will still consider /// itself to own the file descriptor. In particular, it will close the /// file descriptor when it is done (this is necessary to detect /// output errors). - raw_fd_ostream(const char *Filename, std::string &ErrorInfo, + raw_fd_ostream(StringRef Filename, std::error_code &EC, sys::fs::OpenFlags Flags); /// raw_fd_ostream ctor - FD is the file descriptor that this writes to. If |