From 6fa33f5dd945015d79be42c5cff146e4e2b7c4f3 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 7 Aug 2013 22:47:18 +0000 Subject: DataFlowSanitizer; LLVM changes. DataFlowSanitizer is a generalised dynamic data flow analysis. Unlike other Sanitizer tools, this tool is not designed to detect a specific class of bugs on its own. Instead, it provides a generic dynamic data flow analysis framework to be used by clients to help detect application-specific issues within their own code. Differential Revision: http://llvm-reviews.chandlerc.com/D965 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187923 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/InitializePasses.h | 1 + include/llvm/Transforms/Instrumentation.h | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'include') diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h index d7d18d0..08f0c7a 100644 --- a/include/llvm/InitializePasses.h +++ b/include/llvm/InitializePasses.h @@ -122,6 +122,7 @@ void initializeAddressSanitizerPass(PassRegistry&); void initializeAddressSanitizerModulePass(PassRegistry&); void initializeMemorySanitizerPass(PassRegistry&); void initializeThreadSanitizerPass(PassRegistry&); +void initializeDataFlowSanitizerPass(PassRegistry&); void initializeEarlyCSEPass(PassRegistry&); void initializeExpandISelPseudosPass(PassRegistry&); void initializeFindUsedTypesPass(PassRegistry&); diff --git a/include/llvm/Transforms/Instrumentation.h b/include/llvm/Transforms/Instrumentation.h index d1b6fe1..a7e6cc5 100644 --- a/include/llvm/Transforms/Instrumentation.h +++ b/include/llvm/Transforms/Instrumentation.h @@ -16,6 +16,20 @@ #include "llvm/ADT/StringRef.h" +#ifdef __GNUC__ +inline void *getDFSanArgTLSPtrForJIT() { + extern __thread __attribute__((tls_model("initial-exec"))) + void *__dfsan_arg_tls; + return (void *)&__dfsan_arg_tls; +} + +inline void *getDFSanRetValTLSPtrForJIT() { + extern __thread __attribute__((tls_model("initial-exec"))) + void *__dfsan_retval_tls; + return (void *)&__dfsan_retval_tls; +} +#endif + namespace llvm { class ModulePass; @@ -74,6 +88,17 @@ FunctionPass *createMemorySanitizerPass(bool TrackOrigins = false, // Insert ThreadSanitizer (race detection) instrumentation FunctionPass *createThreadSanitizerPass(StringRef BlacklistFile = StringRef()); +// Insert DataFlowSanitizer (dynamic data flow analysis) instrumentation +ModulePass *createDataFlowSanitizerPass(void *(*getArgTLS)() = 0, + void *(*getRetValTLS)() = 0); + +#ifdef __GNUC__ +inline ModulePass *createDataFlowSanitizerPassForJIT() { + return createDataFlowSanitizerPass(getDFSanArgTLSPtrForJIT, + getDFSanRetValTLSPtrForJIT); +} +#endif + // BoundsChecking - This pass instruments the code to perform run-time bounds // checking on loads, stores, and other memory intrinsics. FunctionPass *createBoundsCheckingPass(); -- cgit v1.1 From 41418d17cced656f91038b2482bc9d173b4974b0 Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Wed, 7 Aug 2013 22:49:12 +0000 Subject: Add ISD::FROUND for libm round() All libm floating-point rounding functions, except for round(), had their own ISD nodes. Recent PowerPC cores have an instruction for round(), and so here I'm adding ISD::FROUND so that round() can be custom lowered as well. For the most part, this is straightforward. I've added an intrinsic and a matching ISD node just like those for nearbyint() and friends. The SelectionDAG pattern I've named frnd (because ISD::FP_ROUND has already claimed fround). This will be used by the PowerPC backend in a follow-up commit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187926 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/ISDOpcodes.h | 4 ++-- include/llvm/CodeGen/RuntimeLibcalls.h | 5 +++++ include/llvm/IR/Intrinsics.td | 1 + include/llvm/Target/TargetLibraryInfo.h | 1 + include/llvm/Target/TargetSelectionDAG.td | 1 + 5 files changed, 10 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/ISDOpcodes.h b/include/llvm/CodeGen/ISDOpcodes.h index 9466b90..45bb7e3 100644 --- a/include/llvm/CodeGen/ISDOpcodes.h +++ b/include/llvm/CodeGen/ISDOpcodes.h @@ -440,11 +440,11 @@ namespace ISD { /// FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, /// FLOG, FLOG2, FLOG10, FEXP, FEXP2, - /// FCEIL, FTRUNC, FRINT, FNEARBYINT, FFLOOR - Perform various unary + /// FCEIL, FTRUNC, FRINT, FNEARBYINT, FROUND, FFLOOR - Perform various unary /// floating point operations. These are inspired by libm. FNEG, FABS, FSQRT, FSIN, FCOS, FPOWI, FPOW, FLOG, FLOG2, FLOG10, FEXP, FEXP2, - FCEIL, FTRUNC, FRINT, FNEARBYINT, FFLOOR, + FCEIL, FTRUNC, FRINT, FNEARBYINT, FROUND, FFLOOR, /// FSINCOS - Compute both fsin and fcos as a single operation. FSINCOS, diff --git a/include/llvm/CodeGen/RuntimeLibcalls.h b/include/llvm/CodeGen/RuntimeLibcalls.h index 41289a4..e578b50 100644 --- a/include/llvm/CodeGen/RuntimeLibcalls.h +++ b/include/llvm/CodeGen/RuntimeLibcalls.h @@ -188,6 +188,11 @@ namespace RTLIB { NEARBYINT_F80, NEARBYINT_F128, NEARBYINT_PPCF128, + ROUND_F32, + ROUND_F64, + ROUND_F80, + ROUND_F128, + ROUND_PPCF128, FLOOR_F32, FLOOR_F64, FLOOR_F80, diff --git a/include/llvm/IR/Intrinsics.td b/include/llvm/IR/Intrinsics.td index 1a849c4..ffa121d 100644 --- a/include/llvm/IR/Intrinsics.td +++ b/include/llvm/IR/Intrinsics.td @@ -298,6 +298,7 @@ let Properties = [IntrReadMem] in { def int_trunc : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; def int_rint : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; def int_nearbyint : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; + def int_round : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; } let Properties = [IntrNoMem] in { diff --git a/include/llvm/Target/TargetLibraryInfo.h b/include/llvm/Target/TargetLibraryInfo.h index 8c1f223..d0245ba 100644 --- a/include/llvm/Target/TargetLibraryInfo.h +++ b/include/llvm/Target/TargetLibraryInfo.h @@ -695,6 +695,7 @@ public: case LibFunc::nearbyint: case LibFunc::nearbyintf: case LibFunc::nearbyintl: case LibFunc::ceil: case LibFunc::ceilf: case LibFunc::ceill: case LibFunc::rint: case LibFunc::rintf: case LibFunc::rintl: + case LibFunc::round: case LibFunc::roundf: case LibFunc::roundl: case LibFunc::trunc: case LibFunc::truncf: case LibFunc::truncl: case LibFunc::log2: case LibFunc::log2f: case LibFunc::log2l: case LibFunc::exp2: case LibFunc::exp2f: case LibFunc::exp2l: diff --git a/include/llvm/Target/TargetSelectionDAG.td b/include/llvm/Target/TargetSelectionDAG.td index befab43..72963da 100644 --- a/include/llvm/Target/TargetSelectionDAG.td +++ b/include/llvm/Target/TargetSelectionDAG.td @@ -383,6 +383,7 @@ def ftrunc : SDNode<"ISD::FTRUNC" , SDTFPUnaryOp>; def fceil : SDNode<"ISD::FCEIL" , SDTFPUnaryOp>; def ffloor : SDNode<"ISD::FFLOOR" , SDTFPUnaryOp>; def fnearbyint : SDNode<"ISD::FNEARBYINT" , SDTFPUnaryOp>; +def frnd : SDNode<"ISD::FROUND" , SDTFPUnaryOp>; def fround : SDNode<"ISD::FP_ROUND" , SDTFPRoundOp>; def fextend : SDNode<"ISD::FP_EXTEND" , SDTFPExtendOp>; -- cgit v1.1 From 32647ca140e0a654e6e9fdc98660493bee07f2ac Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 7 Aug 2013 23:29:46 +0000 Subject: Unbreak Mac build. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187937 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/Instrumentation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Transforms/Instrumentation.h b/include/llvm/Transforms/Instrumentation.h index a7e6cc5..9befe58 100644 --- a/include/llvm/Transforms/Instrumentation.h +++ b/include/llvm/Transforms/Instrumentation.h @@ -16,7 +16,7 @@ #include "llvm/ADT/StringRef.h" -#ifdef __GNUC__ +#if defined(__GNUC__) && defined(__linux__) inline void *getDFSanArgTLSPtrForJIT() { extern __thread __attribute__((tls_model("initial-exec"))) void *__dfsan_arg_tls; -- cgit v1.1 From c348ad00e5a0b04df6a7cba83b6e77ab81f28de1 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 7 Aug 2013 23:41:13 +0000 Subject: Really unbreak Mac build. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187938 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/Instrumentation.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Transforms/Instrumentation.h b/include/llvm/Transforms/Instrumentation.h index 9befe58..ecc470b 100644 --- a/include/llvm/Transforms/Instrumentation.h +++ b/include/llvm/Transforms/Instrumentation.h @@ -92,7 +92,7 @@ FunctionPass *createThreadSanitizerPass(StringRef BlacklistFile = StringRef()); ModulePass *createDataFlowSanitizerPass(void *(*getArgTLS)() = 0, void *(*getRetValTLS)() = 0); -#ifdef __GNUC__ +#if defined(__GNUC__) && defined(__linux__) inline ModulePass *createDataFlowSanitizerPassForJIT() { return createDataFlowSanitizerPass(getDFSanArgTLSPtrForJIT, getDFSanRetValTLSPtrForJIT); -- cgit v1.1 From bf473e22406143bcce9613b09f54adc1ba9301b8 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Thu, 8 Aug 2013 00:43:30 +0000 Subject: Forward resetColor() et al to the underlying stream. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187947 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/FormattedStream.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'include') diff --git a/include/llvm/Support/FormattedStream.h b/include/llvm/Support/FormattedStream.h index 18ee048..df1f218 100644 --- a/include/llvm/Support/FormattedStream.h +++ b/include/llvm/Support/FormattedStream.h @@ -129,6 +129,27 @@ public: /// getLine - Return the line number unsigned getLine() { return Position.second; } + + raw_ostream &resetColor() { + TheStream->resetColor(); + return *this; + } + + raw_ostream &reverseColor() { + TheStream->reverseColor(); + return *this; + } + + raw_ostream &changeColor(enum Colors Color, + bool Bold, + bool BG) { + TheStream->changeColor(Color, Bold, BG); + return *this; + } + + bool is_displayed() const { + return TheStream->is_displayed(); + } private: void releaseStream() { -- cgit v1.1 From 31667626106048c07866d996e667a3a10010ef4b Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 8 Aug 2013 01:41:00 +0000 Subject: Be more rigorous about the sizes of forms and attributes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187953 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index f7e6434..74416db 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -110,7 +110,7 @@ namespace llvm { return !operator==(Other); } - unsigned getTag() const { + uint16_t getTag() const { return getUnsignedField(0) & ~LLVMDebugVersionMask; } -- cgit v1.1 From d4f9d05fde4b2cfd202a5852ec1ec3e960ef53ed Mon Sep 17 00:00:00 2001 From: David Fang Date: Thu, 8 Aug 2013 20:14:40 +0000 Subject: initial draft of PPCMachObjectWriter.cpp this records relocation entries in the mach-o object file for PIC code generation. tested on powerpc-darwin8, validated against darwin otool -rvV git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188004 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/MachOFormat.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'include') diff --git a/include/llvm/Object/MachOFormat.h b/include/llvm/Object/MachOFormat.h index 96ee8a7..2bbad0a 100644 --- a/include/llvm/Object/MachOFormat.h +++ b/include/llvm/Object/MachOFormat.h @@ -425,6 +425,25 @@ namespace macho { }; + /// PPC relocation types from + enum RelocationInfoTypePPC { + RIT_PPC_BR14 = RIT_Pair +1, + RIT_PPC_BR24, + RIT_PPC_HI16, + RIT_PPC_LO16, + RIT_PPC_HA16, + RIT_PPC_LO14, + RIT_PPC_SECTDIFF, + RIT_PPC_PB_LA_PTR, + RIT_PPC_HI16_SECTDIFF, + RIT_PPC_LO16_SECTDIFF, + RIT_PPC_HA16_SECTDIFF, + RIT_PPC_JBSR, + RIT_PPC_LO14_SECTDIFF, + RIT_PPC_LOCAL_SECTDIFF, + RIT_PPC_TLV + }; + } // end namespace macho } // end namespace object -- cgit v1.1 From 081a1941b595f6294e4ce678fd61ef56a2ceb51e Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Thu, 8 Aug 2013 22:27:13 +0000 Subject: [Object] Split the ELF interface into 3 parts. * ELFTypes.h contains template magic for defining types based on endianess, size, and alignment. * ELFFile.h defines the ELFFile class which provides low level ELF specific access. * ELFObjectFile.h contains ELFObjectFile which uses ELFFile to implement the ObjectFile interface. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188022 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELF.h | 3001 ++++++----------------------------- include/llvm/Object/ELFObjectFile.h | 1098 +++++++++++++ include/llvm/Object/ELFTypes.h | 463 ++++++ include/llvm/Object/RelocVisitor.h | 2 +- 4 files changed, 2022 insertions(+), 2542 deletions(-) create mode 100644 include/llvm/Object/ELFObjectFile.h create mode 100644 include/llvm/Object/ELFTypes.h (limited to 'include') diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 8234916..8afbd45 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -7,23 +7,26 @@ // //===----------------------------------------------------------------------===// // -// This file declares the ELFObjectFile template class. +// This file declares the ELFFile template class. // //===----------------------------------------------------------------------===// #ifndef LLVM_OBJECT_ELF_H #define LLVM_OBJECT_ELF_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/PointerIntPair.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Triple.h" -#include "llvm/Object/ObjectFile.h" +#include "llvm/Object/ELFTypes.h" +#include "llvm/Object/Error.h" #include "llvm/Support/Casting.h" #include "llvm/Support/ELF.h" #include "llvm/Support/Endian.h" #include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/ErrorOr.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" #include @@ -33,22 +36,9 @@ namespace llvm { namespace object { -using support::endianness; +StringRef getELFRelocationTypeName(uint32_t Machine, uint32_t Type); -template -struct ELFType { - static const endianness TargetEndianness = target_endianness; - static const std::size_t MaxAlignment = max_alignment; - static const bool Is64Bits = is64Bits; -}; - -template -struct MaximumAlignment { - enum {value = AlignOf::Alignment > max_align ? max_align - : AlignOf::Alignment}; -}; - -// Subclasses of ELFObjectFile may need this for template instantiation +// Subclasses of ELFFile may need this for template instantiation inline std::pair getElfArchType(MemoryBuffer *Object) { if (Object->getBufferSize() < ELF::EI_NIDENT) @@ -57,442 +47,15 @@ getElfArchType(MemoryBuffer *Object) { (uint8_t) Object->getBufferStart()[ELF::EI_DATA]); } -// Templates to choose Elf_Addr and Elf_Off depending on is64Bits. -template -struct ELFDataTypeTypedefHelperCommon { - typedef support::detail::packed_endian_specific_integral - ::value> Elf_Half; - typedef support::detail::packed_endian_specific_integral - ::value> Elf_Word; - typedef support::detail::packed_endian_specific_integral - ::value> Elf_Sword; - typedef support::detail::packed_endian_specific_integral - ::value> Elf_Xword; - typedef support::detail::packed_endian_specific_integral - ::value> Elf_Sxword; -}; - -template -struct ELFDataTypeTypedefHelper; - -/// ELF 32bit types. -template -struct ELFDataTypeTypedefHelper > - : ELFDataTypeTypedefHelperCommon { - typedef uint32_t value_type; - typedef support::detail::packed_endian_specific_integral - ::value> Elf_Addr; - typedef support::detail::packed_endian_specific_integral - ::value> Elf_Off; -}; - -/// ELF 64bit types. -template -struct ELFDataTypeTypedefHelper > - : ELFDataTypeTypedefHelperCommon { - typedef uint64_t value_type; - typedef support::detail::packed_endian_specific_integral - ::value> Elf_Addr; - typedef support::detail::packed_endian_specific_integral - ::value> Elf_Off; -}; - -// I really don't like doing this, but the alternative is copypasta. -#define LLVM_ELF_IMPORT_TYPES(E, M, W) \ -typedef typename ELFDataTypeTypedefHelper >::Elf_Addr Elf_Addr; \ -typedef typename ELFDataTypeTypedefHelper >::Elf_Off Elf_Off; \ -typedef typename ELFDataTypeTypedefHelper >::Elf_Half Elf_Half; \ -typedef typename ELFDataTypeTypedefHelper >::Elf_Word Elf_Word; \ -typedef typename \ - ELFDataTypeTypedefHelper >::Elf_Sword Elf_Sword; \ -typedef typename \ - ELFDataTypeTypedefHelper >::Elf_Xword Elf_Xword; \ -typedef typename \ - ELFDataTypeTypedefHelper >::Elf_Sxword Elf_Sxword; - -#define LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) \ - LLVM_ELF_IMPORT_TYPES(ELFT::TargetEndianness, ELFT::MaxAlignment, \ - ELFT::Is64Bits) - -// Section header. -template -struct Elf_Shdr_Base; - -template -struct Elf_Shdr_Base > { - LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, false) - Elf_Word sh_name; // Section name (index into string table) - Elf_Word sh_type; // Section type (SHT_*) - Elf_Word sh_flags; // Section flags (SHF_*) - Elf_Addr sh_addr; // Address where section is to be loaded - Elf_Off sh_offset; // File offset of section data, in bytes - Elf_Word sh_size; // Size of section, in bytes - Elf_Word sh_link; // Section type-specific header table index link - Elf_Word sh_info; // Section type-specific extra information - Elf_Word sh_addralign;// Section address alignment - Elf_Word sh_entsize; // Size of records contained within the section -}; - -template -struct Elf_Shdr_Base > { - LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, true) - Elf_Word sh_name; // Section name (index into string table) - Elf_Word sh_type; // Section type (SHT_*) - Elf_Xword sh_flags; // Section flags (SHF_*) - Elf_Addr sh_addr; // Address where section is to be loaded - Elf_Off sh_offset; // File offset of section data, in bytes - Elf_Xword sh_size; // Size of section, in bytes - Elf_Word sh_link; // Section type-specific header table index link - Elf_Word sh_info; // Section type-specific extra information - Elf_Xword sh_addralign;// Section address alignment - Elf_Xword sh_entsize; // Size of records contained within the section -}; - -template -struct Elf_Shdr_Impl : Elf_Shdr_Base { - using Elf_Shdr_Base::sh_entsize; - using Elf_Shdr_Base::sh_size; - - /// @brief Get the number of entities this section contains if it has any. - unsigned getEntityCount() const { - if (sh_entsize == 0) - return 0; - return sh_size / sh_entsize; - } -}; - -template -struct Elf_Sym_Base; - -template -struct Elf_Sym_Base > { - LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, false) - Elf_Word st_name; // Symbol name (index into string table) - Elf_Addr st_value; // Value or address associated with the symbol - Elf_Word st_size; // Size of the symbol - unsigned char st_info; // Symbol's type and binding attributes - unsigned char st_other; // Must be zero; reserved - Elf_Half st_shndx; // Which section (header table index) it's defined in -}; - -template -struct Elf_Sym_Base > { - LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, true) - Elf_Word st_name; // Symbol name (index into string table) - unsigned char st_info; // Symbol's type and binding attributes - unsigned char st_other; // Must be zero; reserved - Elf_Half st_shndx; // Which section (header table index) it's defined in - Elf_Addr st_value; // Value or address associated with the symbol - Elf_Xword st_size; // Size of the symbol -}; - -template -struct Elf_Sym_Impl : Elf_Sym_Base { - using Elf_Sym_Base::st_info; - - // These accessors and mutators correspond to the ELF32_ST_BIND, - // ELF32_ST_TYPE, and ELF32_ST_INFO macros defined in the ELF specification: - unsigned char getBinding() const { return st_info >> 4; } - unsigned char getType() const { return st_info & 0x0f; } - void setBinding(unsigned char b) { setBindingAndType(b, getType()); } - void setType(unsigned char t) { setBindingAndType(getBinding(), t); } - void setBindingAndType(unsigned char b, unsigned char t) { - st_info = (b << 4) + (t & 0x0f); - } -}; - -/// Elf_Versym: This is the structure of entries in the SHT_GNU_versym section -/// (.gnu.version). This structure is identical for ELF32 and ELF64. -template -struct Elf_Versym_Impl { - LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) - Elf_Half vs_index; // Version index with flags (e.g. VERSYM_HIDDEN) -}; - -template -struct Elf_Verdaux_Impl; - -/// Elf_Verdef: This is the structure of entries in the SHT_GNU_verdef section -/// (.gnu.version_d). This structure is identical for ELF32 and ELF64. -template -struct Elf_Verdef_Impl { - LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) - typedef Elf_Verdaux_Impl Elf_Verdaux; - Elf_Half vd_version; // Version of this structure (e.g. VER_DEF_CURRENT) - Elf_Half vd_flags; // Bitwise flags (VER_DEF_*) - Elf_Half vd_ndx; // Version index, used in .gnu.version entries - Elf_Half vd_cnt; // Number of Verdaux entries - Elf_Word vd_hash; // Hash of name - Elf_Word vd_aux; // Offset to the first Verdaux entry (in bytes) - Elf_Word vd_next; // Offset to the next Verdef entry (in bytes) - - /// Get the first Verdaux entry for this Verdef. - const Elf_Verdaux *getAux() const { - return reinterpret_cast((const char*)this + vd_aux); - } -}; - -/// Elf_Verdaux: This is the structure of auxiliary data in the SHT_GNU_verdef -/// section (.gnu.version_d). This structure is identical for ELF32 and ELF64. -template -struct Elf_Verdaux_Impl { - LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) - Elf_Word vda_name; // Version name (offset in string table) - Elf_Word vda_next; // Offset to next Verdaux entry (in bytes) -}; - -/// Elf_Verneed: This is the structure of entries in the SHT_GNU_verneed -/// section (.gnu.version_r). This structure is identical for ELF32 and ELF64. -template -struct Elf_Verneed_Impl { - LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) - Elf_Half vn_version; // Version of this structure (e.g. VER_NEED_CURRENT) - Elf_Half vn_cnt; // Number of associated Vernaux entries - Elf_Word vn_file; // Library name (string table offset) - Elf_Word vn_aux; // Offset to first Vernaux entry (in bytes) - Elf_Word vn_next; // Offset to next Verneed entry (in bytes) -}; - -/// Elf_Vernaux: This is the structure of auxiliary data in SHT_GNU_verneed -/// section (.gnu.version_r). This structure is identical for ELF32 and ELF64. -template -struct Elf_Vernaux_Impl { - LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) - Elf_Word vna_hash; // Hash of dependency name - Elf_Half vna_flags; // Bitwise Flags (VER_FLAG_*) - Elf_Half vna_other; // Version index, used in .gnu.version entries - Elf_Word vna_name; // Dependency name - Elf_Word vna_next; // Offset to next Vernaux entry (in bytes) -}; - -/// Elf_Dyn_Base: This structure matches the form of entries in the dynamic -/// table section (.dynamic) look like. -template -struct Elf_Dyn_Base; - -template -struct Elf_Dyn_Base > { - LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, false) - Elf_Sword d_tag; - union { - Elf_Word d_val; - Elf_Addr d_ptr; - } d_un; -}; - -template -struct Elf_Dyn_Base > { - LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, true) - Elf_Sxword d_tag; - union { - Elf_Xword d_val; - Elf_Addr d_ptr; - } d_un; -}; - -/// Elf_Dyn_Impl: This inherits from Elf_Dyn_Base, adding getters and setters. -template -struct Elf_Dyn_Impl : Elf_Dyn_Base { - using Elf_Dyn_Base::d_tag; - using Elf_Dyn_Base::d_un; - int64_t getTag() const { return d_tag; } - uint64_t getVal() const { return d_un.d_val; } - uint64_t getPtr() const { return d_un.ptr; } -}; - -// Elf_Rel: Elf Relocation -template -struct Elf_Rel_Base; - -template -struct Elf_Rel_Base, false> { - LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, false) - Elf_Addr r_offset; // Location (file byte offset, or program virtual addr) - Elf_Word r_info; // Symbol table index and type of relocation to apply - - uint32_t getRInfo(bool isMips64EL) const { - assert(!isMips64EL); - return r_info; - } - void setRInfo(uint32_t R) { - r_info = R; - } -}; - -template -struct Elf_Rel_Base, false> { - LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, true) - Elf_Addr r_offset; // Location (file byte offset, or program virtual addr) - Elf_Xword r_info; // Symbol table index and type of relocation to apply - - uint64_t getRInfo(bool isMips64EL) const { - uint64_t t = r_info; - if (!isMips64EL) - return t; - // Mips64 little endian has a "special" encoding of r_info. Instead of one - // 64 bit little endian number, it is a little endian 32 bit number followed - // by a 32 bit big endian number. - return (t << 32) | ((t >> 8) & 0xff000000) | ((t >> 24) & 0x00ff0000) | - ((t >> 40) & 0x0000ff00) | ((t >> 56) & 0x000000ff); - } - void setRInfo(uint64_t R) { - // FIXME: Add mips64el support. - r_info = R; - } -}; - -template -struct Elf_Rel_Base, true> { - LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, false) - Elf_Addr r_offset; // Location (file byte offset, or program virtual addr) - Elf_Word r_info; // Symbol table index and type of relocation to apply - Elf_Sword r_addend; // Compute value for relocatable field by adding this - - uint32_t getRInfo(bool isMips64EL) const { - assert(!isMips64EL); - return r_info; - } - void setRInfo(uint32_t R) { - r_info = R; - } -}; - -template -struct Elf_Rel_Base, true> { - LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, true) - Elf_Addr r_offset; // Location (file byte offset, or program virtual addr) - Elf_Xword r_info; // Symbol table index and type of relocation to apply - Elf_Sxword r_addend; // Compute value for relocatable field by adding this. - - uint64_t getRInfo(bool isMips64EL) const { - // Mips64 little endian has a "special" encoding of r_info. Instead of one - // 64 bit little endian number, it is a little endian 32 bit number followed - // by a 32 bit big endian number. - uint64_t t = r_info; - if (!isMips64EL) - return t; - return (t << 32) | ((t >> 8) & 0xff000000) | ((t >> 24) & 0x00ff0000) | - ((t >> 40) & 0x0000ff00) | ((t >> 56) & 0x000000ff); - } - void setRInfo(uint64_t R) { - // FIXME: Add mips64el support. - r_info = R; - } -}; - -template -struct Elf_Rel_Impl; - -template -struct Elf_Rel_Impl, isRela> - : Elf_Rel_Base, isRela> { - LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, true) - - // These accessors and mutators correspond to the ELF64_R_SYM, ELF64_R_TYPE, - // and ELF64_R_INFO macros defined in the ELF specification: - uint32_t getSymbol(bool isMips64EL) const { - return (uint32_t) (this->getRInfo(isMips64EL) >> 32); - } - uint32_t getType(bool isMips64EL) const { - return (uint32_t) (this->getRInfo(isMips64EL) & 0xffffffffL); - } - void setSymbol(uint32_t s) { setSymbolAndType(s, getType()); } - void setType(uint32_t t) { setSymbolAndType(getSymbol(), t); } - void setSymbolAndType(uint32_t s, uint32_t t) { - this->setRInfo(((uint64_t)s << 32) + (t&0xffffffffL)); - } -}; - -template -struct Elf_Rel_Impl, isRela> - : Elf_Rel_Base, isRela> { - LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, false) - - // These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE, - // and ELF32_R_INFO macros defined in the ELF specification: - uint32_t getSymbol(bool isMips64EL) const { - return this->getRInfo(isMips64EL) >> 8; - } - unsigned char getType(bool isMips64EL) const { - return (unsigned char) (this->getRInfo(isMips64EL) & 0x0ff); - } - void setSymbol(uint32_t s) { setSymbolAndType(s, getType()); } - void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); } - void setSymbolAndType(uint32_t s, unsigned char t) { - this->setRInfo((s << 8) + t); - } -}; - -template -struct Elf_Ehdr_Impl { - LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) - unsigned char e_ident[ELF::EI_NIDENT]; // ELF Identification bytes - Elf_Half e_type; // Type of file (see ET_*) - Elf_Half e_machine; // Required architecture for this file (see EM_*) - Elf_Word e_version; // Must be equal to 1 - Elf_Addr e_entry; // Address to jump to in order to start program - Elf_Off e_phoff; // Program header table's file offset, in bytes - Elf_Off e_shoff; // Section header table's file offset, in bytes - Elf_Word e_flags; // Processor-specific flags - Elf_Half e_ehsize; // Size of ELF header, in bytes - Elf_Half e_phentsize;// Size of an entry in the program header table - Elf_Half e_phnum; // Number of entries in the program header table - Elf_Half e_shentsize;// Size of an entry in the section header table - Elf_Half e_shnum; // Number of entries in the section header table - Elf_Half e_shstrndx; // Section header table index of section name - // string table - bool checkMagic() const { - return (memcmp(e_ident, ELF::ElfMagic, strlen(ELF::ElfMagic))) == 0; - } - unsigned char getFileClass() const { return e_ident[ELF::EI_CLASS]; } - unsigned char getDataEncoding() const { return e_ident[ELF::EI_DATA]; } -}; - -template -struct Elf_Phdr_Impl; - -template -struct Elf_Phdr_Impl > { - LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, false) - Elf_Word p_type; // Type of segment - Elf_Off p_offset; // FileOffset where segment is located, in bytes - Elf_Addr p_vaddr; // Virtual Address of beginning of segment - Elf_Addr p_paddr; // Physical address of beginning of segment (OS-specific) - Elf_Word p_filesz; // Num. of bytes in file image of segment (may be zero) - Elf_Word p_memsz; // Num. of bytes in mem image of segment (may be zero) - Elf_Word p_flags; // Segment flags - Elf_Word p_align; // Segment alignment constraint -}; - -template -struct Elf_Phdr_Impl > { - LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, true) - Elf_Word p_type; // Type of segment - Elf_Word p_flags; // Segment flags - Elf_Off p_offset; // FileOffset where segment is located, in bytes - Elf_Addr p_vaddr; // Virtual Address of beginning of segment - Elf_Addr p_paddr; // Physical address of beginning of segment (OS-specific) - Elf_Xword p_filesz; // Num. of bytes in file image of segment (may be zero) - Elf_Xword p_memsz; // Num. of bytes in mem image of segment (may be zero) - Elf_Xword p_align; // Segment alignment constraint -}; - -template -class ELFObjectFile : public ObjectFile { +template +class ELFFile { +public: LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) + typedef typename conditional::type uintX_t; -public: /// \brief Iterate over constant sized entities. - template + template class ELFEntityIterator { public: typedef ptrdiff_t difference_type; @@ -503,9 +66,8 @@ public: /// \brief Default construct iterator. ELFEntityIterator() : EntitySize(0), Current(0) {} - ELFEntityIterator(uint64_t EntSize, const char *Start) - : EntitySize(EntSize) - , Current(Start) {} + ELFEntityIterator(uintX_t EntSize, const char *Start) + : EntitySize(EntSize), Current(Start) {} reference operator *() { assert(Current && "Attempted to dereference an invalid iterator!"); @@ -545,14 +107,16 @@ public: difference_type operator -(const ELFEntityIterator &Other) const { assert(EntitySize == Other.EntitySize && - "Subtracting iterators of different EntitiySize!"); + "Subtracting iterators of different EntitySize!"); return (Current - Other.Current) / EntitySize; } const char *get() const { return Current; } + uintX_t getEntSize() const { return EntitySize; } + private: - uint64_t EntitySize; + uintX_t EntitySize; const char *Current; }; @@ -568,40 +132,141 @@ public: typedef Elf_Verneed_Impl Elf_Verneed; typedef Elf_Vernaux_Impl Elf_Vernaux; typedef Elf_Versym_Impl Elf_Versym; - typedef ELFEntityIterator Elf_Dyn_iterator; - typedef ELFEntityIterator Elf_Sym_iterator; + typedef ELFEntityIterator Elf_Dyn_Iter; typedef ELFEntityIterator Elf_Rela_Iter; typedef ELFEntityIterator Elf_Rel_Iter; + typedef ELFEntityIterator Elf_Shdr_Iter; -protected: - // This flag is used for classof, to distinguish ELFObjectFile from - // its subclass. If more subclasses will be created, this flag will - // have to become an enum. - bool isDyldELFObject; + /// \brief Archive files are 2 byte aligned, so we need this for + /// PointerIntPair to work. + template + class ArchivePointerTypeTraits { + public: + static inline const void *getAsVoidPointer(T *P) { return P; } + static inline T *getFromVoidPointer(const void *P) { + return static_cast(P); + } + enum { NumLowBitsAvailable = 1 }; + }; + + class Elf_Sym_Iter { + public: + typedef ptrdiff_t difference_type; + typedef const Elf_Sym value_type; + typedef std::random_access_iterator_tag iterator_category; + typedef value_type &reference; + typedef value_type *pointer; + + /// \brief Default construct iterator. + Elf_Sym_Iter() : EntitySize(0), Current(0, false) {} + Elf_Sym_Iter(uintX_t EntSize, const char *Start, bool IsDynamic) + : EntitySize(EntSize), Current(Start, IsDynamic) {} + + reference operator*() { + assert(Current.getPointer() && + "Attempted to dereference an invalid iterator!"); + return *reinterpret_cast(Current.getPointer()); + } + + pointer operator->() { + assert(Current.getPointer() && + "Attempted to dereference an invalid iterator!"); + return reinterpret_cast(Current.getPointer()); + } + + bool operator==(const Elf_Sym_Iter &Other) { + return Current == Other.Current; + } + + bool operator!=(const Elf_Sym_Iter &Other) { return !(*this == Other); } + + Elf_Sym_Iter &operator++() { + assert(Current.getPointer() && + "Attempted to increment an invalid iterator!"); + Current.setPointer(Current.getPointer() + EntitySize); + return *this; + } + + Elf_Sym_Iter operator++(int) { + Elf_Sym_Iter Tmp = *this; + ++*this; + return Tmp; + } + + Elf_Sym_Iter operator+(difference_type Dist) { + assert(Current.getPointer() && + "Attempted to increment an invalid iterator!"); + Current.setPointer(Current.getPointer() + EntitySize * Dist); + return *this; + } + + Elf_Sym_Iter &operator=(const Elf_Sym_Iter &Other) { + EntitySize = Other.EntitySize; + Current = Other.Current; + return *this; + } + + difference_type operator-(const Elf_Sym_Iter &Other) const { + assert(EntitySize == Other.EntitySize && + "Subtracting iterators of different EntitySize!"); + return (Current.getPointer() - Other.Current.getPointer()) / EntitySize; + } + + const char *get() const { return Current.getPointer(); } + + bool isDynamic() const { return Current.getInt(); } + + uintX_t getEntSize() const { return EntitySize; } + + private: + uintX_t EntitySize; + PointerIntPair > Current; + }; private: + typedef SmallVector Sections_t; + typedef DenseMap IndexMap_t; + + MemoryBuffer *Buf; + + const uint8_t *base() const { + return reinterpret_cast(Buf->getBufferStart()); + } + const Elf_Ehdr *Header; const Elf_Shdr *SectionHeaderTable; const Elf_Shdr *dot_shstrtab_sec; // Section header string table. const Elf_Shdr *dot_strtab_sec; // Symbol header string table. - const Elf_Shdr *dot_dynstr_sec; // Dynamic symbol string table. + const Elf_Shdr *dot_symtab_sec; // Symbol table section. - int SymbolTableIndex; - int DynamicSymbolTableIndex; - DenseMap ExtendedSymbolTable; + const Elf_Shdr *SymbolTableSectionHeaderIndex; + DenseMap ExtendedSymbolTable; - const Elf_Shdr *dot_dynamic_sec; // .dynamic const Elf_Shdr *dot_gnu_version_sec; // .gnu.version const Elf_Shdr *dot_gnu_version_r_sec; // .gnu.version_r const Elf_Shdr *dot_gnu_version_d_sec; // .gnu.version_d + /// \brief Represents a region described by entries in the .dynamic table. + struct DynRegionInfo { + DynRegionInfo() : Addr(nullptr), Size(0), EntSize(0) {} + /// \brief Address in current address space. + const void *Addr; + /// \brief Size in bytes of the region. + uintX_t Size; + /// \brief Size of each entity in the region. + uintX_t EntSize; + }; + + DynRegionInfo DynamicRegion; + DynRegionInfo DynHashRegion; + DynRegionInfo DynStrRegion; + DynRegionInfo DynSymRegion; + // Pointer to SONAME entry in dynamic string table // This is set the first time getLoadName is called. mutable const char *dt_soname; -private: - uint64_t getROffset(DataRefImpl Rel) const; - // Records for each version index the corresponding Verdef or Vernaux entry. // This is filled the first time LoadVersionMap() is called. class VersionMapEntry : public PointerIntPair { @@ -628,99 +293,29 @@ private: void LoadVersionNeeds(const Elf_Shdr *ec) const; void LoadVersionMap() const; - /// @brief Get the relocation section that contains \a Rel. - const Elf_Shdr *getRelSection(DataRefImpl Rel) const { - return getSection(Rel.d.a); - } - public: - bool isRelocationHasAddend(DataRefImpl Rel) const; template const T *getEntry(uint32_t Section, uint32_t Entry) const; - template - const T *getEntry(const Elf_Shdr *Section, uint32_t Entry) const; - const Elf_Shdr *getSection(DataRefImpl index) const; - const Elf_Shdr *getSection(uint32_t index) const; - const Elf_Rel *getRel(DataRefImpl Rel) const; - const Elf_Rela *getRela(DataRefImpl Rela) const; + template + const T *getEntry(const Elf_Shdr *Section, uint32_t Entry) const; const char *getString(uint32_t section, uint32_t offset) const; const char *getString(const Elf_Shdr *section, uint32_t offset) const; - error_code getSymbolVersion(const Elf_Shdr *section, - const Elf_Sym *Symb, - StringRef &Version, - bool &IsDefault) const; + const char *getDynamicString(uintX_t Offset) const; + ErrorOr getSymbolVersion(const Elf_Shdr *section, + const Elf_Sym *Symb, + bool &IsDefault) const; void VerifyStrTab(const Elf_Shdr *sh) const; -protected: - const Elf_Sym *getSymbol(DataRefImpl Symb) const; // FIXME: Should be private? - void validateSymbol(DataRefImpl Symb) const; - StringRef getRelocationTypeName(uint32_t Type) const; + StringRef getRelocationTypeName(uint32_t Type) const; + void getRelocationTypeName(uint32_t Type, + SmallVectorImpl &Result) const; -public: - error_code getSymbolName(const Elf_Shdr *section, - const Elf_Sym *Symb, - StringRef &Res) const; - error_code getSectionName(const Elf_Shdr *section, - StringRef &Res) const; - const Elf_Dyn *getDyn(DataRefImpl DynData) const; - error_code getSymbolVersion(SymbolRef Symb, StringRef &Version, - bool &IsDefault) const; - uint64_t getSymbolIndex(const Elf_Sym *sym) const; - error_code getRelocationAddend(DataRefImpl Rel, int64_t &Res) const; -protected: - virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const; - virtual error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const; - virtual error_code getSymbolFileOffset(DataRefImpl Symb, uint64_t &Res) const; - virtual error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res) const; - virtual error_code getSymbolAlignment(DataRefImpl Symb, uint32_t &Res) const; - virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const; - virtual error_code getSymbolNMTypeChar(DataRefImpl Symb, char &Res) const; - virtual error_code getSymbolFlags(DataRefImpl Symb, uint32_t &Res) const; - virtual error_code getSymbolType(DataRefImpl Symb, - SymbolRef::Type &Res) const; - virtual error_code getSymbolSection(DataRefImpl Symb, - section_iterator &Res) const; - virtual error_code getSymbolValue(DataRefImpl Symb, uint64_t &Val) const; - - virtual error_code getLibraryNext(DataRefImpl Data, LibraryRef &Result) const; - virtual error_code getLibraryPath(DataRefImpl Data, StringRef &Res) const; - - virtual error_code getSectionNext(DataRefImpl Sec, SectionRef &Res) const; - virtual error_code getSectionName(DataRefImpl Sec, StringRef &Res) const; - virtual error_code getSectionAddress(DataRefImpl Sec, uint64_t &Res) const; - virtual error_code getSectionSize(DataRefImpl Sec, uint64_t &Res) const; - virtual error_code getSectionContents(DataRefImpl Sec, StringRef &Res) const; - virtual error_code getSectionAlignment(DataRefImpl Sec, uint64_t &Res) const; - virtual error_code isSectionText(DataRefImpl Sec, bool &Res) const; - virtual error_code isSectionData(DataRefImpl Sec, bool &Res) const; - virtual error_code isSectionBSS(DataRefImpl Sec, bool &Res) const; - virtual error_code isSectionRequiredForExecution(DataRefImpl Sec, - bool &Res) const; - virtual error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const; - virtual error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const; - virtual error_code isSectionReadOnlyData(DataRefImpl Sec, bool &Res) const; - virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, - bool &Result) const; - virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const; - virtual relocation_iterator getSectionRelEnd(DataRefImpl Sec) const; - virtual section_iterator getRelocatedSection(DataRefImpl Sec) const; - - virtual error_code getRelocationNext(DataRefImpl Rel, - RelocationRef &Res) const; - virtual error_code getRelocationAddress(DataRefImpl Rel, - uint64_t &Res) const; - virtual error_code getRelocationOffset(DataRefImpl Rel, - uint64_t &Res) const; - virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const; - virtual error_code getRelocationType(DataRefImpl Rel, - uint64_t &Res) const; - virtual error_code getRelocationTypeName(DataRefImpl Rel, - SmallVectorImpl &Result) const; - virtual error_code getRelocationValueString(DataRefImpl Rel, - SmallVectorImpl &Result) const; + /// \brief Get the symbol table section and symbol for a given relocation. + template + std::pair + getRelocationSymbol(const Elf_Shdr *RelSec, const RelT *Rel) const; -public: - ELFObjectFile(MemoryBuffer *Object, error_code &ec); + ELFFile(MemoryBuffer *Object, error_code &ec); bool isMips64EL() const { return Header->e_machine == ELF::EM_MIPS && @@ -728,65 +323,51 @@ public: Header->getDataEncoding() == ELF::ELFDATA2LSB; } - virtual symbol_iterator begin_symbols() const; - virtual symbol_iterator end_symbols() const; - - virtual symbol_iterator begin_dynamic_symbols() const; - virtual symbol_iterator end_dynamic_symbols() const; + Elf_Shdr_Iter begin_sections() const; + Elf_Shdr_Iter end_sections() const; - virtual section_iterator begin_sections() const; - virtual section_iterator end_sections() const; + Elf_Sym_Iter begin_symbols() const; + Elf_Sym_Iter end_symbols() const; - virtual library_iterator begin_libraries_needed() const; - virtual library_iterator end_libraries_needed() const; - - const Elf_Shdr *getDynamicSymbolTableSectionHeader() const { - return getSection(DynamicSymbolTableIndex); - } - - const Elf_Shdr *getDynamicStringTableSectionHeader() const { - return dot_dynstr_sec; - } - - Elf_Dyn_iterator begin_dynamic_table() const; + Elf_Dyn_Iter begin_dynamic_table() const; /// \param NULLEnd use one past the first DT_NULL entry as the end instead of /// the section size. - Elf_Dyn_iterator end_dynamic_table(bool NULLEnd = false) const; - - Elf_Sym_iterator begin_elf_dynamic_symbols() const { - const Elf_Shdr *DynSymtab = getDynamicSymbolTableSectionHeader(); - if (DynSymtab) - return Elf_Sym_iterator(DynSymtab->sh_entsize, - (const char *)base() + DynSymtab->sh_offset); - return Elf_Sym_iterator(0, 0); + Elf_Dyn_Iter end_dynamic_table(bool NULLEnd = false) const; + + Elf_Sym_Iter begin_dynamic_symbols() const { + if (DynSymRegion.Addr) + return Elf_Sym_Iter(DynSymRegion.EntSize, (const char *)DynSymRegion.Addr, + true); + return Elf_Sym_Iter(0, 0, true); } - Elf_Sym_iterator end_elf_dynamic_symbols() const { - const Elf_Shdr *DynSymtab = getDynamicSymbolTableSectionHeader(); - if (DynSymtab) - return Elf_Sym_iterator(DynSymtab->sh_entsize, (const char *)base() + - DynSymtab->sh_offset + DynSymtab->sh_size); - return Elf_Sym_iterator(0, 0); + Elf_Sym_Iter end_dynamic_symbols() const { + if (DynSymRegion.Addr) + return Elf_Sym_Iter(DynSymRegion.EntSize, + (const char *)DynSymRegion.Addr + DynSymRegion.Size, + true); + return Elf_Sym_Iter(0, 0, true); } - Elf_Rela_Iter beginELFRela(const Elf_Shdr *sec) const { + Elf_Rela_Iter begin_rela(const Elf_Shdr *sec) const { return Elf_Rela_Iter(sec->sh_entsize, (const char *)(base() + sec->sh_offset)); } - Elf_Rela_Iter endELFRela(const Elf_Shdr *sec) const { - return Elf_Rela_Iter(sec->sh_entsize, (const char *) - (base() + sec->sh_offset + sec->sh_size)); + Elf_Rela_Iter end_rela(const Elf_Shdr *sec) const { + return Elf_Rela_Iter( + sec->sh_entsize, + (const char *)(base() + sec->sh_offset + sec->sh_size)); } - Elf_Rel_Iter beginELFRel(const Elf_Shdr *sec) const { + Elf_Rel_Iter begin_rel(const Elf_Shdr *sec) const { return Elf_Rel_Iter(sec->sh_entsize, (const char *)(base() + sec->sh_offset)); } - Elf_Rel_Iter endELFRel(const Elf_Shdr *sec) const { - return Elf_Rel_Iter(sec->sh_entsize, (const char *) - (base() + sec->sh_offset + sec->sh_size)); + Elf_Rel_Iter end_rel(const Elf_Shdr *sec) const { + return Elf_Rel_Iter(sec->sh_entsize, + (const char *)(base() + sec->sh_offset + sec->sh_size)); } /// \brief Iterate over program header table. @@ -804,43 +385,42 @@ public: (Header->e_phnum * Header->e_phentsize)); } - virtual uint8_t getBytesInAddress() const; - virtual StringRef getFileFormatName() const; - virtual StringRef getObjectType() const { return "ELF"; } - virtual unsigned getArch() const; - virtual StringRef getLoadName() const; - virtual error_code getSectionContents(const Elf_Shdr *sec, - StringRef &Res) const; - uint64_t getNumSections() const; - uint64_t getStringTableIndex() const; + uintX_t getStringTableIndex() const; ELF::Elf64_Word getSymbolTableIndex(const Elf_Sym *symb) const; - const Elf_Ehdr *getElfHeader() const; + const Elf_Ehdr *getHeader() const { return Header; } const Elf_Shdr *getSection(const Elf_Sym *symb) const; - const Elf_Shdr *getElfSection(section_iterator &It) const; - const Elf_Sym *getElfSymbol(symbol_iterator &It) const; - const Elf_Sym *getElfSymbol(uint32_t index) const; - - // Methods for type inquiry through isa, cast, and dyn_cast - bool isDyldType() const { return isDyldELFObject; } - static inline bool classof(const Binary *v) { - return v->getType() == getELFType(ELFT::TargetEndianness == support::little, - ELFT::Is64Bits); - } + const Elf_Shdr *getSection(uint32_t Index) const; + const Elf_Sym *getSymbol(uint32_t index) const; + + ErrorOr getSymbolName(Elf_Sym_Iter Sym) const; + + /// \brief Get the name of \p Symb. + /// \param SymTab The symbol table section \p Symb is contained in. + /// \param Symb The symbol to get the name of. + /// + /// \p SymTab is used to lookup the string table to use to get the symbol's + /// name. + ErrorOr getSymbolName(const Elf_Shdr *SymTab, + const Elf_Sym *Symb) const; + ErrorOr getSectionName(const Elf_Shdr *Section) const; + uint64_t getSymbolIndex(const Elf_Sym *sym) const; + ErrorOr > getSectionContents(const Elf_Shdr *Sec) const; + StringRef getLoadName() const; }; // Use an alignment of 2 for the typedefs since that is the worst case for // ELF files in archives. -typedef ELFObjectFile > ELF32LEObjectFile; -typedef ELFObjectFile > ELF64LEObjectFile; -typedef ELFObjectFile > ELF32BEObjectFile; -typedef ELFObjectFile > ELF64BEObjectFile; +typedef ELFFile > ELF32LEFile; +typedef ELFFile > ELF64LEFile; +typedef ELFFile > ELF32BEFile; +typedef ELFFile > ELF64BEFile; // Iterate through the version definitions, and place each Elf_Verdef // in the VersionMap according to its index. -template -void ELFObjectFile::LoadVersionDefs(const Elf_Shdr *sec) const { - unsigned vd_size = sec->sh_size; // Size of section in bytes +template +void ELFFile::LoadVersionDefs(const Elf_Shdr *sec) const { + unsigned vd_size = sec->sh_size; // Size of section in bytes unsigned vd_count = sec->sh_info; // Number of Verdef entries const char *sec_start = (const char*)base() + sec->sh_offset; const char *sec_end = sec_start + vd_size; @@ -855,7 +435,7 @@ void ELFObjectFile::LoadVersionDefs(const Elf_Shdr *sec) const { report_fatal_error("Unexpected verdef version"); size_t index = vd->vd_ndx & ELF::VERSYM_VERSION; if (index >= VersionMap.size()) - VersionMap.resize(index+1); + VersionMap.resize(index + 1); VersionMap[index] = VersionMapEntry(vd); p += vd->vd_next; } @@ -863,11 +443,11 @@ void ELFObjectFile::LoadVersionDefs(const Elf_Shdr *sec) const { // Iterate through the versions needed section, and place each Elf_Vernaux // in the VersionMap according to its index. -template -void ELFObjectFile::LoadVersionNeeds(const Elf_Shdr *sec) const { - unsigned vn_size = sec->sh_size; // Size of section in bytes +template +void ELFFile::LoadVersionNeeds(const Elf_Shdr *sec) const { + unsigned vn_size = sec->sh_size; // Size of section in bytes unsigned vn_count = sec->sh_info; // Number of Verneed entries - const char *sec_start = (const char*)base() + sec->sh_offset; + const char *sec_start = (const char *)base() + sec->sh_offset; const char *sec_end = sec_start + vn_size; // The first Verneed entry is at the start of the section. const char *p = sec_start; @@ -887,7 +467,7 @@ void ELFObjectFile::LoadVersionNeeds(const Elf_Shdr *sec) const { const Elf_Vernaux *vna = reinterpret_cast(paux); size_t index = vna->vna_other & ELF::VERSYM_VERSION; if (index >= VersionMap.size()) - VersionMap.resize(index+1); + VersionMap.resize(index + 1); VersionMap[index] = VersionMapEntry(vna); paux += vna->vna_next; } @@ -895,11 +475,10 @@ void ELFObjectFile::LoadVersionNeeds(const Elf_Shdr *sec) const { } } -template -void ELFObjectFile::LoadVersionMap() const { +template +void ELFFile::LoadVersionMap() const { // If there is no dynamic symtab or version table, there is nothing to do. - if (getDynamicStringTableSectionHeader() == NULL || - dot_gnu_version_sec == NULL) + if (DynSymRegion.Addr == NULL || dot_gnu_version_sec == NULL) return; // Has the VersionMap already been loaded? @@ -918,64 +497,16 @@ void ELFObjectFile::LoadVersionMap() const { LoadVersionNeeds(dot_gnu_version_r_sec); } -template -void ELFObjectFile::validateSymbol(DataRefImpl Symb) const { -#ifndef NDEBUG - const Elf_Sym *symb = getSymbol(Symb); - const Elf_Shdr *SymbolTableSection = getSection(Symb.d.b); - // FIXME: We really need to do proper error handling in the case of an invalid - // input file. Because we don't use exceptions, I think we'll just pass - // an error object around. - if (!( symb - && SymbolTableSection - && symb >= (const Elf_Sym*)(base() - + SymbolTableSection->sh_offset) - && symb < (const Elf_Sym*)(base() - + SymbolTableSection->sh_offset - + SymbolTableSection->sh_size))) - // FIXME: Proper error handling. - report_fatal_error("Symb must point to a valid symbol!"); -#endif -} - -template -error_code ELFObjectFile::getSymbolNext(DataRefImpl Symb, - SymbolRef &Result) const { - validateSymbol(Symb); - ++Symb.d.a; - Result = SymbolRef(Symb, this); - return object_error::success; -} - -template -error_code ELFObjectFile::getSymbolName(DataRefImpl Symb, - StringRef &Result) const { - validateSymbol(Symb); - const Elf_Sym *symb = getSymbol(Symb); - return getSymbolName(getSection(Symb.d.b), symb, Result); -} - -template -error_code ELFObjectFile::getSymbolVersion(SymbolRef SymRef, - StringRef &Version, - bool &IsDefault) const { - DataRefImpl Symb = SymRef.getRawDataRefImpl(); - validateSymbol(Symb); - const Elf_Sym *symb = getSymbol(Symb); - return getSymbolVersion(getSection(Symb.d.b), symb, Version, IsDefault); -} - -template -ELF::Elf64_Word ELFObjectFile - ::getSymbolTableIndex(const Elf_Sym *symb) const { +template +ELF::Elf64_Word ELFFile::getSymbolTableIndex(const Elf_Sym *symb) const { if (symb->st_shndx == ELF::SHN_XINDEX) return ExtendedSymbolTable.lookup(symb); return symb->st_shndx; } -template -const typename ELFObjectFile::Elf_Shdr * -ELFObjectFile::getSection(const Elf_Sym *symb) const { +template +const typename ELFFile::Elf_Shdr * +ELFFile::getSection(const Elf_Sym *symb) const { if (symb->st_shndx == ELF::SHN_XINDEX) return getSection(ExtendedSymbolTable.lookup(symb)); if (symb->st_shndx >= ELF::SHN_LORESERVE) @@ -983,1282 +514,36 @@ ELFObjectFile::getSection(const Elf_Sym *symb) const { return getSection(symb->st_shndx); } -template -const typename ELFObjectFile::Elf_Ehdr * -ELFObjectFile::getElfHeader() const { - return Header; -} - -template -const typename ELFObjectFile::Elf_Shdr * -ELFObjectFile::getElfSection(section_iterator &It) const { - llvm::object::DataRefImpl ShdrRef = It->getRawDataRefImpl(); - return reinterpret_cast(ShdrRef.p); -} - -template -const typename ELFObjectFile::Elf_Sym * -ELFObjectFile::getElfSymbol(symbol_iterator &It) const { - return getSymbol(It->getRawDataRefImpl()); -} - -template -const typename ELFObjectFile::Elf_Sym * -ELFObjectFile::getElfSymbol(uint32_t index) const { - DataRefImpl SymbolData; - SymbolData.d.a = index; - SymbolData.d.b = SymbolTableIndex; - return getSymbol(SymbolData); -} - -template -error_code ELFObjectFile::getSymbolFileOffset(DataRefImpl Symb, - uint64_t &Result) const { - validateSymbol(Symb); - const Elf_Sym *symb = getSymbol(Symb); - const Elf_Shdr *Section; - switch (getSymbolTableIndex(symb)) { - case ELF::SHN_COMMON: - // Unintialized symbols have no offset in the object file - case ELF::SHN_UNDEF: - Result = UnknownAddressOrSize; - return object_error::success; - case ELF::SHN_ABS: - Result = symb->st_value; - return object_error::success; - default: Section = getSection(symb); - } - - switch (symb->getType()) { - case ELF::STT_SECTION: - Result = Section ? Section->sh_offset : UnknownAddressOrSize; - return object_error::success; - case ELF::STT_FUNC: - case ELF::STT_OBJECT: - case ELF::STT_NOTYPE: - Result = symb->st_value + - (Section ? Section->sh_offset : 0); - return object_error::success; - default: - Result = UnknownAddressOrSize; - return object_error::success; - } -} - -template -error_code ELFObjectFile::getSymbolAddress(DataRefImpl Symb, - uint64_t &Result) const { - validateSymbol(Symb); - const Elf_Sym *symb = getSymbol(Symb); - const Elf_Shdr *Section; - switch (getSymbolTableIndex(symb)) { - case ELF::SHN_COMMON: - case ELF::SHN_UNDEF: - Result = UnknownAddressOrSize; - return object_error::success; - case ELF::SHN_ABS: - Result = symb->st_value; - return object_error::success; - default: Section = getSection(symb); - } - - switch (symb->getType()) { - case ELF::STT_SECTION: - Result = Section ? Section->sh_addr : UnknownAddressOrSize; - return object_error::success; - case ELF::STT_FUNC: - case ELF::STT_OBJECT: - case ELF::STT_NOTYPE: - bool IsRelocatable; - switch(Header->e_type) { - case ELF::ET_EXEC: - case ELF::ET_DYN: - IsRelocatable = false; - break; - default: - IsRelocatable = true; - } - Result = symb->st_value; - - // Clear the ARM/Thumb indicator flag. - if (Header->e_machine == ELF::EM_ARM) - Result &= ~1; - - if (IsRelocatable && Section != 0) - Result += Section->sh_addr; - return object_error::success; - default: - Result = UnknownAddressOrSize; - return object_error::success; - } -} - -template -error_code ELFObjectFile::getSymbolAlignment(DataRefImpl Symb, - uint32_t &Res) const { - uint32_t flags; - getSymbolFlags(Symb, flags); - if (flags & SymbolRef::SF_Common) { - uint64_t Value; - getSymbolValue(Symb, Value); - Res = Value; - } else { - Res = 0; - } - return object_error::success; -} - -template -error_code ELFObjectFile::getSymbolSize(DataRefImpl Symb, - uint64_t &Result) const { - validateSymbol(Symb); - const Elf_Sym *symb = getSymbol(Symb); - if (symb->st_size == 0) - Result = UnknownAddressOrSize; - Result = symb->st_size; - return object_error::success; -} - -template -error_code ELFObjectFile::getSymbolNMTypeChar(DataRefImpl Symb, - char &Result) const { - validateSymbol(Symb); - const Elf_Sym *symb = getSymbol(Symb); - const Elf_Shdr *Section = getSection(symb); - - char ret = '?'; - - if (Section) { - switch (Section->sh_type) { - case ELF::SHT_PROGBITS: - case ELF::SHT_DYNAMIC: - switch (Section->sh_flags) { - case (ELF::SHF_ALLOC | ELF::SHF_EXECINSTR): - ret = 't'; break; - case (ELF::SHF_ALLOC | ELF::SHF_WRITE): - ret = 'd'; break; - case ELF::SHF_ALLOC: - case (ELF::SHF_ALLOC | ELF::SHF_MERGE): - case (ELF::SHF_ALLOC | ELF::SHF_MERGE | ELF::SHF_STRINGS): - ret = 'r'; break; - } - break; - case ELF::SHT_NOBITS: ret = 'b'; - } - } - - switch (getSymbolTableIndex(symb)) { - case ELF::SHN_UNDEF: - if (ret == '?') - ret = 'U'; - break; - case ELF::SHN_ABS: ret = 'a'; break; - case ELF::SHN_COMMON: ret = 'c'; break; - } - - switch (symb->getBinding()) { - case ELF::STB_GLOBAL: ret = ::toupper(ret); break; - case ELF::STB_WEAK: - if (getSymbolTableIndex(symb) == ELF::SHN_UNDEF) - ret = 'w'; - else - if (symb->getType() == ELF::STT_OBJECT) - ret = 'V'; - else - ret = 'W'; - } - - if (ret == '?' && symb->getType() == ELF::STT_SECTION) { - StringRef name; - if (error_code ec = getSymbolName(Symb, name)) - return ec; - Result = StringSwitch(name) - .StartsWith(".debug", 'N') - .StartsWith(".note", 'n') - .Default('?'); - return object_error::success; - } - - Result = ret; - return object_error::success; -} - -template -error_code ELFObjectFile::getSymbolType(DataRefImpl Symb, - SymbolRef::Type &Result) const { - validateSymbol(Symb); - const Elf_Sym *symb = getSymbol(Symb); - - switch (symb->getType()) { - case ELF::STT_NOTYPE: - Result = SymbolRef::ST_Unknown; - break; - case ELF::STT_SECTION: - Result = SymbolRef::ST_Debug; - break; - case ELF::STT_FILE: - Result = SymbolRef::ST_File; - break; - case ELF::STT_FUNC: - Result = SymbolRef::ST_Function; - break; - case ELF::STT_OBJECT: - case ELF::STT_COMMON: - case ELF::STT_TLS: - Result = SymbolRef::ST_Data; - break; - default: - Result = SymbolRef::ST_Other; - break; - } - return object_error::success; -} - -template -error_code ELFObjectFile::getSymbolFlags(DataRefImpl Symb, - uint32_t &Result) const { - validateSymbol(Symb); - const Elf_Sym *symb = getSymbol(Symb); - - Result = SymbolRef::SF_None; - - if (symb->getBinding() != ELF::STB_LOCAL) - Result |= SymbolRef::SF_Global; - - if (symb->getBinding() == ELF::STB_WEAK) - Result |= SymbolRef::SF_Weak; - - if (symb->st_shndx == ELF::SHN_ABS) - Result |= SymbolRef::SF_Absolute; - - if (symb->getType() == ELF::STT_FILE || - symb->getType() == ELF::STT_SECTION || - Symb == begin_symbols()->getRawDataRefImpl()) - Result |= SymbolRef::SF_FormatSpecific; - - if (getSymbolTableIndex(symb) == ELF::SHN_UNDEF) - Result |= SymbolRef::SF_Undefined; - - if (symb->getType() == ELF::STT_COMMON || - getSymbolTableIndex(symb) == ELF::SHN_COMMON) - Result |= SymbolRef::SF_Common; - - if (symb->getType() == ELF::STT_TLS) - Result |= SymbolRef::SF_ThreadLocal; - - return object_error::success; -} - -template -error_code ELFObjectFile::getSymbolSection(DataRefImpl Symb, - section_iterator &Res) const { - validateSymbol(Symb); - const Elf_Sym *symb = getSymbol(Symb); - const Elf_Shdr *sec = getSection(symb); - if (!sec) - Res = end_sections(); - else { - DataRefImpl Sec; - Sec.p = reinterpret_cast(sec); - Res = section_iterator(SectionRef(Sec, this)); - } - return object_error::success; -} - -template -error_code ELFObjectFile::getSymbolValue(DataRefImpl Symb, - uint64_t &Val) const { - validateSymbol(Symb); - const Elf_Sym *symb = getSymbol(Symb); - Val = symb->st_value; - return object_error::success; -} - -template -error_code ELFObjectFile::getSectionNext(DataRefImpl Sec, - SectionRef &Result) const { - const uint8_t *sec = reinterpret_cast(Sec.p); - sec += Header->e_shentsize; - Sec.p = reinterpret_cast(sec); - Result = SectionRef(Sec, this); - return object_error::success; -} - -template -error_code ELFObjectFile::getSectionName(DataRefImpl Sec, - StringRef &Result) const { - const Elf_Shdr *sec = reinterpret_cast(Sec.p); - Result = StringRef(getString(dot_shstrtab_sec, sec->sh_name)); - return object_error::success; -} - -template -error_code ELFObjectFile::getSectionAddress(DataRefImpl Sec, - uint64_t &Result) const { - const Elf_Shdr *sec = reinterpret_cast(Sec.p); - Result = sec->sh_addr; - return object_error::success; -} - -template -error_code ELFObjectFile::getSectionSize(DataRefImpl Sec, - uint64_t &Result) const { - const Elf_Shdr *sec = reinterpret_cast(Sec.p); - Result = sec->sh_size; - return object_error::success; -} - -template -error_code ELFObjectFile::getSectionContents(DataRefImpl Sec, - StringRef &Result) const { - const Elf_Shdr *sec = reinterpret_cast(Sec.p); - const char *start = (const char*)base() + sec->sh_offset; - Result = StringRef(start, sec->sh_size); - return object_error::success; -} - -template -error_code ELFObjectFile::getSectionContents(const Elf_Shdr *Sec, - StringRef &Result) const { - const char *start = (const char*)base() + Sec->sh_offset; - Result = StringRef(start, Sec->sh_size); - return object_error::success; -} - -template -error_code ELFObjectFile::getSectionAlignment(DataRefImpl Sec, - uint64_t &Result) const { - const Elf_Shdr *sec = reinterpret_cast(Sec.p); - Result = sec->sh_addralign; - return object_error::success; -} - -template -error_code ELFObjectFile::isSectionText(DataRefImpl Sec, - bool &Result) const { - const Elf_Shdr *sec = reinterpret_cast(Sec.p); - if (sec->sh_flags & ELF::SHF_EXECINSTR) - Result = true; - else - Result = false; - return object_error::success; -} - -template -error_code ELFObjectFile::isSectionData(DataRefImpl Sec, - bool &Result) const { - const Elf_Shdr *sec = reinterpret_cast(Sec.p); - if (sec->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) - && sec->sh_type == ELF::SHT_PROGBITS) - Result = true; - else - Result = false; - return object_error::success; -} - -template -error_code ELFObjectFile::isSectionBSS(DataRefImpl Sec, - bool &Result) const { - const Elf_Shdr *sec = reinterpret_cast(Sec.p); - if (sec->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) - && sec->sh_type == ELF::SHT_NOBITS) - Result = true; - else - Result = false; - return object_error::success; -} - -template -error_code ELFObjectFile::isSectionRequiredForExecution( - DataRefImpl Sec, bool &Result) const { - const Elf_Shdr *sec = reinterpret_cast(Sec.p); - if (sec->sh_flags & ELF::SHF_ALLOC) - Result = true; - else - Result = false; - return object_error::success; -} - -template -error_code ELFObjectFile::isSectionVirtual(DataRefImpl Sec, - bool &Result) const { - const Elf_Shdr *sec = reinterpret_cast(Sec.p); - if (sec->sh_type == ELF::SHT_NOBITS) - Result = true; - else - Result = false; - return object_error::success; -} - -template -error_code ELFObjectFile::isSectionZeroInit(DataRefImpl Sec, - bool &Result) const { - const Elf_Shdr *sec = reinterpret_cast(Sec.p); - // For ELF, all zero-init sections are virtual (that is, they occupy no space - // in the object image) and vice versa. - Result = sec->sh_type == ELF::SHT_NOBITS; - return object_error::success; -} - -template -error_code ELFObjectFile::isSectionReadOnlyData(DataRefImpl Sec, - bool &Result) const { - const Elf_Shdr *sec = reinterpret_cast(Sec.p); - if (sec->sh_flags & ELF::SHF_WRITE || sec->sh_flags & ELF::SHF_EXECINSTR) - Result = false; - else - Result = true; - return object_error::success; -} - -template -error_code ELFObjectFile::sectionContainsSymbol(DataRefImpl Sec, - DataRefImpl Symb, - bool &Result) const { - validateSymbol(Symb); - - const Elf_Shdr *sec = reinterpret_cast(Sec.p); - const Elf_Sym *symb = getSymbol(Symb); - - unsigned shndx = symb->st_shndx; - bool Reserved = shndx >= ELF::SHN_LORESERVE - && shndx <= ELF::SHN_HIRESERVE; - - Result = !Reserved && (sec == getSection(symb->st_shndx)); - return object_error::success; -} - -template -relocation_iterator -ELFObjectFile::getSectionRelBegin(DataRefImpl Sec) const { - DataRefImpl RelData; - uintptr_t SHT = reinterpret_cast(SectionHeaderTable); - RelData.d.a = (Sec.p - SHT) / Header->e_shentsize; - RelData.d.b = 0; - return relocation_iterator(RelocationRef(RelData, this)); -} - -template -relocation_iterator -ELFObjectFile::getSectionRelEnd(DataRefImpl Sec) const { - DataRefImpl RelData; - uintptr_t SHT = reinterpret_cast(SectionHeaderTable); - const Elf_Shdr *S = reinterpret_cast(Sec.p); - RelData.d.a = (Sec.p - SHT) / Header->e_shentsize; - if (S->sh_type != ELF::SHT_RELA && S->sh_type != ELF::SHT_REL) - RelData.d.b = 0; - else - RelData.d.b = S->sh_size / S->sh_entsize; - - return relocation_iterator(RelocationRef(RelData, this)); -} - template -section_iterator -ELFObjectFile::getRelocatedSection(DataRefImpl Sec) const { - if (Header->e_type != ELF::ET_REL) - return end_sections(); - - const Elf_Shdr *S = reinterpret_cast(Sec.p); - unsigned sh_type = S->sh_type; - if (sh_type != ELF::SHT_RELA && sh_type != ELF::SHT_REL) - return end_sections(); - - assert(S->sh_info != 0); - const Elf_Shdr *R = getSection(S->sh_info); - DataRefImpl D; - D.p = reinterpret_cast(R); - return section_iterator(SectionRef(D, this)); -} - -// Relocations -template -error_code ELFObjectFile::getRelocationNext(DataRefImpl Rel, - RelocationRef &Result) const { - ++Rel.d.b; - Result = RelocationRef(Rel, this); - return object_error::success; +const typename ELFFile::Elf_Sym * +ELFFile::getSymbol(uint32_t Index) const { + return &*(begin_symbols() + Index); } template -symbol_iterator -ELFObjectFile::getRelocationSymbol(DataRefImpl Rel) const { - uint32_t symbolIdx; - const Elf_Shdr *sec = getRelSection(Rel); - switch (sec->sh_type) { - default : - report_fatal_error("Invalid section type in Rel!"); - case ELF::SHT_REL : { - symbolIdx = getRel(Rel)->getSymbol(isMips64EL()); - break; - } - case ELF::SHT_RELA : { - symbolIdx = getRela(Rel)->getSymbol(isMips64EL()); - break; - } - } - if (!symbolIdx) - return end_symbols(); - - DataRefImpl SymbolData; - SymbolData.d.a = symbolIdx; - SymbolData.d.b = sec->sh_link; - return symbol_iterator(SymbolRef(SymbolData, this)); -} - -template -error_code ELFObjectFile::getRelocationAddress(DataRefImpl Rel, - uint64_t &Result) const { - assert((Header->e_type == ELF::ET_EXEC || Header->e_type == ELF::ET_DYN) && - "Only executable and shared objects files have addresses"); - Result = getROffset(Rel); - return object_error::success; +ErrorOr > +ELFFile::getSectionContents(const Elf_Shdr *Sec) const { + if (Sec->sh_offset + Sec->sh_size > Buf->getBufferSize()) + return object_error::parse_failed; + const uint8_t *Start = base() + Sec->sh_offset; + return ArrayRef(Start, Sec->sh_size); } -template -error_code ELFObjectFile::getRelocationOffset(DataRefImpl Rel, - uint64_t &Result) const { - assert(Header->e_type == ELF::ET_REL && - "Only relocatable object files have relocation offsets"); - Result = getROffset(Rel); - return object_error::success; -} - -template -uint64_t ELFObjectFile::getROffset(DataRefImpl Rel) const { - const Elf_Shdr *sec = getRelSection(Rel); - switch (sec->sh_type) { - default: - report_fatal_error("Invalid section type in Rel!"); - case ELF::SHT_REL: - return getRel(Rel)->r_offset; - case ELF::SHT_RELA: - return getRela(Rel)->r_offset; - } -} - -template -error_code ELFObjectFile::getRelocationType(DataRefImpl Rel, - uint64_t &Result) const { - const Elf_Shdr *sec = getRelSection(Rel); - switch (sec->sh_type) { - default : - report_fatal_error("Invalid section type in Rel!"); - case ELF::SHT_REL : { - Result = getRel(Rel)->getType(isMips64EL()); - break; - } - case ELF::SHT_RELA : { - Result = getRela(Rel)->getType(isMips64EL()); - break; - } - } - return object_error::success; -} - -#define LLVM_ELF_SWITCH_RELOC_TYPE_NAME(enum) \ - case ELF::enum: Res = #enum; break; - -template -StringRef ELFObjectFile::getRelocationTypeName(uint32_t Type) const { - StringRef Res = "Unknown"; - switch (Header->e_machine) { - case ELF::EM_X86_64: - switch (Type) { - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_NONE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_PC32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOT32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_PLT32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_COPY); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GLOB_DAT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_JUMP_SLOT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_RELATIVE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTPCREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_32S); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_PC16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_8); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_PC8); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_DTPMOD64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_DTPOFF64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TPOFF64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TLSGD); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TLSLD); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_DTPOFF32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTTPOFF); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TPOFF32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_PC64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTOFF64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTPC32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOT64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTPCREL64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTPC64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTPLT64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_PLTOFF64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_SIZE32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_SIZE64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_GOTPC32_TLSDESC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TLSDESC_CALL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_TLSDESC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_X86_64_IRELATIVE); - default: break; - } - break; - case ELF::EM_386: - switch (Type) { - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_NONE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_PC32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_GOT32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_PLT32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_COPY); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_GLOB_DAT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_JUMP_SLOT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_RELATIVE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_GOTOFF); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_GOTPC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_32PLT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_TPOFF); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_IE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GOTIE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GD); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDM); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_PC16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_8); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_PC8); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GD_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GD_PUSH); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GD_CALL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GD_POP); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDM_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDM_PUSH); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDM_CALL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDM_POP); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LDO_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_IE_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_LE_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_DTPMOD32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_DTPOFF32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_TPOFF32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_GOTDESC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_DESC_CALL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_TLS_DESC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_386_IRELATIVE); - default: break; - } - break; - case ELF::EM_MIPS: - switch (Type) { - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_NONE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_REL32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_26); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_HI16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_LO16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_GPREL16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_LITERAL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_GOT16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_PC16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_CALL16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_GPREL32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_UNUSED1); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_UNUSED2); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_SHIFT5); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_SHIFT6); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_GOT_DISP); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_GOT_PAGE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_GOT_OFST); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_GOT_HI16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_GOT_LO16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_SUB); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_INSERT_A); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_INSERT_B); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_DELETE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_HIGHER); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_HIGHEST); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_CALL_HI16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_CALL_LO16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_SCN_DISP); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_REL16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_ADD_IMMEDIATE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_PJUMP); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_RELGOT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_JALR); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_TLS_DTPMOD32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_TLS_DTPREL32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_TLS_DTPMOD64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_TLS_DTPREL64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_TLS_GD); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_TLS_LDM); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_TLS_DTPREL_HI16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_TLS_DTPREL_LO16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_TLS_GOTTPREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_TLS_TPREL32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_TLS_TPREL64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_TLS_TPREL_HI16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_TLS_TPREL_LO16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_GLOB_DAT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_COPY); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_JUMP_SLOT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_MIPS_NUM); - default: break; - } - break; - case ELF::EM_AARCH64: - switch (Type) { - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_NONE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_ABS64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_ABS32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_ABS16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_PREL64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_PREL32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_PREL16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_MOVW_UABS_G0); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_MOVW_UABS_G0_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_MOVW_UABS_G1); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_MOVW_UABS_G1_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_MOVW_UABS_G2); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_MOVW_UABS_G2_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_MOVW_UABS_G3); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_MOVW_SABS_G0); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_MOVW_SABS_G1); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_MOVW_SABS_G2); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_LD_PREL_LO19); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_ADR_PREL_LO21); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_ADR_PREL_PG_HI21); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_ADD_ABS_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_LDST8_ABS_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TSTBR14); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_CONDBR19); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_JUMP26); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_CALL26); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_LDST16_ABS_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_LDST32_ABS_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_LDST64_ABS_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_LDST128_ABS_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_ADR_GOT_PAGE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_LD64_GOT_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLD_MOVW_DTPREL_G2); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLD_MOVW_DTPREL_G1); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLD_MOVW_DTPREL_G0); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLD_ADD_DTPREL_HI12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLD_ADD_DTPREL_LO12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLD_LDST8_DTPREL_LO12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLD_LDST16_DTPREL_LO12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLD_LDST32_DTPREL_LO12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLD_LDST64_DTPREL_LO12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSIE_MOVW_GOTTPREL_G1); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSIE_LD_GOTTPREL_PREL19); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLE_MOVW_TPREL_G2); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLE_MOVW_TPREL_G1); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLE_MOVW_TPREL_G1_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLE_MOVW_TPREL_G0); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLE_MOVW_TPREL_G0_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLE_ADD_TPREL_HI12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLE_ADD_TPREL_LO12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLE_ADD_TPREL_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLE_LDST8_TPREL_LO12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLE_LDST16_TPREL_LO12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLE_LDST32_TPREL_LO12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLE_LDST64_TPREL_LO12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSDESC_ADR_PAGE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSDESC_LD64_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSDESC_ADD_LO12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_AARCH64_TLSDESC_CALL); - default: break; - } - break; - case ELF::EM_ARM: - switch (Type) { - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_NONE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PC24); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ABS32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_REL32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDR_PC_G0); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ABS16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ABS12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_ABS5); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ABS8); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_SBREL32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_CALL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_PC8); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_BREL_ADJ); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_TLS_DESC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_SWI8); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_XPC25); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_XPC22); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_TLS_DTPMOD32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_TLS_DTPOFF32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_TLS_TPOFF32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_COPY); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_GLOB_DAT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_JUMP_SLOT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_RELATIVE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_GOTOFF32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_BASE_PREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_GOT_BREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PLT32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_CALL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_JUMP24); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_JUMP24); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_BASE_ABS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ALU_PCREL_7_0); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ALU_PCREL_15_8); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ALU_PCREL_23_15); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDR_SBREL_11_0_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ALU_SBREL_19_12_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ALU_SBREL_27_20_CK); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_TARGET1); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_SBREL31); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_V4BX); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_TARGET2); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PREL31); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_MOVW_ABS_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_MOVT_ABS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_MOVW_PREL_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_MOVT_PREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_MOVW_ABS_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_MOVT_ABS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_MOVW_PREL_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_MOVT_PREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_JUMP19); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_JUMP6); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_ALU_PREL_11_0); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_PC12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ABS32_NOI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_REL32_NOI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ALU_PC_G0_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ALU_PC_G0); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ALU_PC_G1_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ALU_PC_G1); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ALU_PC_G2); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDR_PC_G1); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDR_PC_G2); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDRS_PC_G0); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDRS_PC_G1); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDRS_PC_G2); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDC_PC_G0); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDC_PC_G1); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDC_PC_G2); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ALU_SB_G0_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ALU_SB_G0); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ALU_SB_G1_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ALU_SB_G1); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ALU_SB_G2); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDR_SB_G0); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDR_SB_G1); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDR_SB_G2); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDRS_SB_G0); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDRS_SB_G1); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDRS_SB_G2); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDC_SB_G0); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDC_SB_G1); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_LDC_SB_G2); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_MOVW_BREL_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_MOVT_BREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_MOVW_BREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_MOVW_BREL_NC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_MOVT_BREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_MOVW_BREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_TLS_GOTDESC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_TLS_CALL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_TLS_DESCSEQ); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_TLS_CALL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PLT32_ABS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_GOT_ABS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_GOT_PREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_GOT_BREL12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_GOTOFF12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_GOTRELAX); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_GNU_VTENTRY); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_GNU_VTINHERIT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_JUMP11); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_JUMP8); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_TLS_GD32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_TLS_LDM32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_TLS_LDO32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_TLS_IE32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_TLS_LE32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_TLS_LDO12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_TLS_LE12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_TLS_IE12GP); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PRIVATE_0); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PRIVATE_1); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PRIVATE_2); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PRIVATE_3); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PRIVATE_4); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PRIVATE_5); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PRIVATE_6); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PRIVATE_7); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PRIVATE_8); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PRIVATE_9); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PRIVATE_10); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PRIVATE_11); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PRIVATE_12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PRIVATE_13); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PRIVATE_14); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_PRIVATE_15); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_ME_TOO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_TLS_DESCSEQ16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_ARM_THM_TLS_DESCSEQ32); - default: break; - } - break; - case ELF::EM_HEXAGON: - switch (Type) { - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_NONE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_B22_PCREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_B15_PCREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_B7_PCREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_LO16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_HI16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_8); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GPREL16_0); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GPREL16_1); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GPREL16_2); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GPREL16_3); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_HL16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_B13_PCREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_B9_PCREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_B32_PCREL_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_32_6_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_B22_PCREL_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_B15_PCREL_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_B13_PCREL_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_B9_PCREL_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_B7_PCREL_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_16_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_12_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_11_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_10_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_9_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_8_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_7_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_6_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_32_PCREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_COPY); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GLOB_DAT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_JMP_SLOT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_RELATIVE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_PLT_B22_PCREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GOTREL_LO16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GOTREL_HI16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GOTREL_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GOT_LO16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GOT_HI16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GOT_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GOT_16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_DTPMOD_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_DTPREL_LO16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_DTPREL_HI16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_DTPREL_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_DTPREL_16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GD_PLT_B22_PCREL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GD_GOT_LO16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GD_GOT_HI16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GD_GOT_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GD_GOT_16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_IE_LO16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_IE_HI16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_IE_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_IE_GOT_LO16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_IE_GOT_HI16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_IE_GOT_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_IE_GOT_16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_TPREL_LO16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_TPREL_HI16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_TPREL_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_TPREL_16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_6_PCREL_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GOTREL_32_6_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GOTREL_16_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GOTREL_11_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GOT_32_6_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GOT_16_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GOT_11_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_DTPREL_32_6_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_DTPREL_16_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_DTPREL_11_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GD_GOT_32_6_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GD_GOT_16_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_GD_GOT_11_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_IE_32_6_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_IE_16_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_IE_GOT_32_6_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_IE_GOT_16_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_IE_GOT_11_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_TPREL_32_6_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_TPREL_16_X); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_HEX_TPREL_11_X); - default: break; - } - break; - case ELF::EM_PPC: - switch (Type) { - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_NONE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_ADDR32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_ADDR24); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_ADDR16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_ADDR16_LO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_ADDR16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_ADDR16_HA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_ADDR14); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_ADDR14_BRTAKEN); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_ADDR14_BRNTAKEN); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_REL24); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_REL14); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_REL14_BRTAKEN); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_REL14_BRNTAKEN); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT16_LO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT16_HA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_REL32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_TLS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_DTPMOD32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_TPREL16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_TPREL16_LO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_TPREL16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_TPREL16_HA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_TPREL32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_DTPREL16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_DTPREL16_LO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_DTPREL16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_DTPREL16_HA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_DTPREL32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_TLSGD16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_TLSGD16_LO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_TLSGD16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_TLSGD16_HA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_TLSLD16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_TLSLD16_LO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_TLSLD16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_TLSLD16_HA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_TPREL16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_TPREL16_LO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_TPREL16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_TPREL16_HA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_DTPREL16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_DTPREL16_LO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_DTPREL16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_GOT_DTPREL16_HA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_TLSGD); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_TLSLD); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_REL16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_REL16_LO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_REL16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC_REL16_HA); - default: break; - } - break; - case ELF::EM_PPC64: - switch (Type) { - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_NONE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR24); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_LO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_HA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR14); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR14_BRTAKEN); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR14_BRNTAKEN); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL24); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL14); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL14_BRTAKEN); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL14_BRNTAKEN); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT16_LO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT16_HA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_HIGHER); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_HIGHERA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_HIGHEST); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_HIGHESTA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TOC16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TOC16_LO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TOC16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TOC16_HA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TOC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_DS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_LO_DS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT16_DS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT16_LO_DS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TOC16_DS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TOC16_LO_DS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TLS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPMOD64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TPREL16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TPREL16_LO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TPREL16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TPREL16_HA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TPREL64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPREL16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPREL16_LO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPREL16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPREL16_HA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPREL64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_TLSGD16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_TLSGD16_LO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_TLSGD16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_TLSGD16_HA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_TLSLD16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_TLSLD16_LO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_TLSLD16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_TLSLD16_HA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_TPREL16_DS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_TPREL16_LO_DS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_TPREL16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_TPREL16_HA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_DTPREL16_DS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_DTPREL16_LO_DS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_DTPREL16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_GOT_DTPREL16_HA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TPREL16_DS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TPREL16_LO_DS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TPREL16_HIGHER); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TPREL16_HIGHERA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TPREL16_HIGHEST); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TPREL16_HIGHESTA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPREL16_DS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPREL16_LO_DS); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPREL16_HIGHER); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPREL16_HIGHERA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPREL16_HIGHEST); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_DTPREL16_HIGHESTA); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TLSGD); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TLSLD); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL16_LO); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL16_HI); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL16_HA); - default: break; - } - break; - case ELF::EM_S390: - switch (Type) { - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_NONE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_8); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_PC32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GOT12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GOT32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_PLT32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_COPY); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GLOB_DAT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_JMP_SLOT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_RELATIVE); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GOTOFF); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GOTPC); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GOT16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_PC16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_PC16DBL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_PLT16DBL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_PC32DBL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_PLT32DBL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GOTPCDBL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_PC64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GOT64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_PLT64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GOTENT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GOTOFF16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GOTOFF64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GOTPLT12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GOTPLT16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GOTPLT32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GOTPLT64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GOTPLTENT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_PLTOFF16); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_PLTOFF32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_PLTOFF64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_LOAD); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_GDCALL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_LDCALL); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_GD32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_GD64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_GOTIE12); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_GOTIE32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_GOTIE64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_LDM32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_LDM64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_IE32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_IE64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_IEENT); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_LE32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_LE64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_LDO32); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_LDO64); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_DTPMOD); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_DTPOFF); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_TPOFF); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_20); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GOT20); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_GOTPLT20); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_TLS_GOTIE20); - LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_390_IRELATIVE); - default: break; - } - break; - default: break; - } - return Res; +template +StringRef ELFFile::getRelocationTypeName(uint32_t Type) const { + return getELFRelocationTypeName(Header->e_machine, Type); } -#undef LLVM_ELF_SWITCH_RELOC_TYPE_NAME - -template -error_code ELFObjectFile::getRelocationTypeName( - DataRefImpl Rel, SmallVectorImpl &Result) const { - const Elf_Shdr *sec = getRelSection(Rel); - uint32_t type; - switch (sec->sh_type) { - default : - return object_error::parse_failed; - case ELF::SHT_REL : { - type = getRel(Rel)->getType(isMips64EL()); - break; - } - case ELF::SHT_RELA : { - type = getRela(Rel)->getType(isMips64EL()); - break; - } - } - +template +void ELFFile::getRelocationTypeName(uint32_t Type, + SmallVectorImpl &Result) const { if (!isMips64EL()) { - StringRef Name = getRelocationTypeName(type); + StringRef Name = getRelocationTypeName(Type); Result.append(Name.begin(), Name.end()); } else { - uint8_t Type1 = (type >> 0) & 0xFF; - uint8_t Type2 = (type >> 8) & 0xFF; - uint8_t Type3 = (type >> 16) & 0xFF; + uint8_t Type1 = (Type >> 0) & 0xFF; + uint8_t Type2 = (Type >> 8) & 0xFF; + uint8_t Type3 = (Type >> 16) & 0xFF; // Concat all three relocation type names. StringRef Name = getRelocationTypeName(Type1); @@ -2272,135 +557,63 @@ error_code ELFObjectFile::getRelocationTypeName( Result.append(1, '/'); Result.append(Name.begin(), Name.end()); } - - return object_error::success; } -template -error_code ELFObjectFile::getRelocationAddend( - DataRefImpl Rel, int64_t &Result) const { - const Elf_Shdr *sec = getRelSection(Rel); - switch (sec->sh_type) { - default : - report_fatal_error("Invalid section type in Rel!"); - case ELF::SHT_REL : { - Result = 0; - return object_error::success; - } - case ELF::SHT_RELA : { - Result = getRela(Rel)->r_addend; - return object_error::success; - } - } -} - -template -error_code ELFObjectFile::getRelocationValueString( - DataRefImpl Rel, SmallVectorImpl &Result) const { - const Elf_Shdr *sec = getRelSection(Rel); - uint8_t type; - StringRef res; - int64_t addend = 0; - uint16_t symbol_index = 0; - switch (sec->sh_type) { - default: - return object_error::parse_failed; - case ELF::SHT_REL: { - type = getRel(Rel)->getType(isMips64EL()); - symbol_index = getRel(Rel)->getSymbol(isMips64EL()); - // TODO: Read implicit addend from section data. - break; - } - case ELF::SHT_RELA: { - type = getRela(Rel)->getType(isMips64EL()); - symbol_index = getRela(Rel)->getSymbol(isMips64EL()); - addend = getRela(Rel)->r_addend; - break; - } - } - const Elf_Sym *symb = getEntry(sec->sh_link, symbol_index); - StringRef symname; - if (error_code ec = getSymbolName(getSection(sec->sh_link), symb, symname)) - return ec; - switch (Header->e_machine) { - case ELF::EM_X86_64: - switch (type) { - case ELF::R_X86_64_PC8: - case ELF::R_X86_64_PC16: - case ELF::R_X86_64_PC32: { - std::string fmtbuf; - raw_string_ostream fmt(fmtbuf); - fmt << symname << (addend < 0 ? "" : "+") << addend << "-P"; - fmt.flush(); - Result.append(fmtbuf.begin(), fmtbuf.end()); - } - break; - case ELF::R_X86_64_8: - case ELF::R_X86_64_16: - case ELF::R_X86_64_32: - case ELF::R_X86_64_32S: - case ELF::R_X86_64_64: { - std::string fmtbuf; - raw_string_ostream fmt(fmtbuf); - fmt << symname << (addend < 0 ? "" : "+") << addend; - fmt.flush(); - Result.append(fmtbuf.begin(), fmtbuf.end()); - } - break; - default: - res = "Unknown"; - } - break; - case ELF::EM_AARCH64: { - std::string fmtbuf; - raw_string_ostream fmt(fmtbuf); - fmt << symname; - if (addend != 0) - fmt << (addend < 0 ? "" : "+") << addend; - fmt.flush(); - Result.append(fmtbuf.begin(), fmtbuf.end()); - break; - } - case ELF::EM_ARM: - case ELF::EM_HEXAGON: - res = symname; - break; - default: - res = "Unknown"; - } - if (Result.empty()) - Result.append(res.begin(), res.end()); - return object_error::success; +template +template +std::pair::Elf_Shdr *, + const typename ELFFile::Elf_Sym *> +ELFFile::getRelocationSymbol(const Elf_Shdr *Sec, const RelT *Rel) const { + if (!Sec->sh_link) + return std::pair(0, 0); + const Elf_Shdr *SymTable = getSection(Sec->sh_link); + return std::make_pair( + SymTable, getEntry(SymTable, Rel->getSymbol(isMips64EL()))); } // Verify that the last byte in the string table in a null. -template -void ELFObjectFile::VerifyStrTab(const Elf_Shdr *sh) const { - const char *strtab = (const char*)base() + sh->sh_offset; +template +void ELFFile::VerifyStrTab(const Elf_Shdr *sh) const { + const char *strtab = (const char *)base() + sh->sh_offset; if (strtab[sh->sh_size - 1] != 0) // FIXME: Proper error handling. report_fatal_error("String table must end with a null terminator!"); } -template -ELFObjectFile::ELFObjectFile(MemoryBuffer *Object, error_code &ec) - : ObjectFile(getELFType( - static_cast(ELFT::TargetEndianness) == support::little, - ELFT::Is64Bits), - Object) - , isDyldELFObject(false) - , SectionHeaderTable(0) - , dot_shstrtab_sec(0) - , dot_strtab_sec(0) - , dot_dynstr_sec(0) - , dot_dynamic_sec(0) - , dot_gnu_version_sec(0) - , dot_gnu_version_r_sec(0) - , dot_gnu_version_d_sec(0) - , dt_soname(0) - { - - const uint64_t FileSize = Data->getBufferSize(); +template +uint64_t ELFFile::getNumSections() const { + assert(Header && "Header not initialized!"); + if (Header->e_shnum == ELF::SHN_UNDEF) { + assert(SectionHeaderTable && "SectionHeaderTable not initialized!"); + return SectionHeaderTable->sh_size; + } + return Header->e_shnum; +} + +template +typename ELFFile::uintX_t ELFFile::getStringTableIndex() const { + if (Header->e_shnum == ELF::SHN_UNDEF) { + if (Header->e_shstrndx == ELF::SHN_HIRESERVE) + return SectionHeaderTable->sh_link; + if (Header->e_shstrndx >= getNumSections()) + return 0; + } + return Header->e_shstrndx; +} + +template +ELFFile::ELFFile(MemoryBuffer *Object, error_code &ec) + : Buf(Object), + SectionHeaderTable(0), + dot_shstrtab_sec(0), + dot_strtab_sec(0), + dot_symtab_sec(0), + SymbolTableSectionHeaderIndex(0), + dot_gnu_version_sec(0), + dot_gnu_version_r_sec(0), + dot_gnu_version_d_sec(0), + dt_soname(0) { + const uint64_t FileSize = Buf->getBufferSize(); if (sizeof(Elf_Ehdr) > FileSize) // FIXME: Proper error handling. @@ -2426,68 +639,64 @@ ELFObjectFile::ELFObjectFile(MemoryBuffer *Object, error_code &ec) // FIXME: Proper error handling. report_fatal_error("Section table goes past end of file!"); - // To find the symbol tables we walk the section table to find SHT_SYMTAB. - const Elf_Shdr* SymbolTableSectionHeaderIndex = 0; - const Elf_Shdr* sh = SectionHeaderTable; + // Scan sections for special sections. - SymbolTableIndex = -1; - DynamicSymbolTableIndex = -1; - - for (uint64_t i = 0, e = getNumSections(); i != e; ++i) { - switch (sh->sh_type) { - case ELF::SHT_SYMTAB_SHNDX: { + for (Elf_Shdr_Iter SecI = begin_sections(), SecE = end_sections(); + SecI != SecE; ++SecI) { + switch (SecI->sh_type) { + case ELF::SHT_SYMTAB_SHNDX: if (SymbolTableSectionHeaderIndex) // FIXME: Proper error handling. report_fatal_error("More than one .symtab_shndx!"); - SymbolTableSectionHeaderIndex = sh; + SymbolTableSectionHeaderIndex = &*SecI; break; - } - case ELF::SHT_SYMTAB: { - if (SymbolTableIndex != -1) - report_fatal_error("More than one SHT_SYMTAB!"); - SymbolTableIndex = i; + case ELF::SHT_SYMTAB: + if (dot_symtab_sec) + // FIXME: Proper error handling. + report_fatal_error("More than one .symtab!"); + dot_symtab_sec = &*SecI; + dot_strtab_sec = getSection(SecI->sh_link); break; - } case ELF::SHT_DYNSYM: { - if (DynamicSymbolTableIndex != -1) + if (DynSymRegion.Addr) // FIXME: Proper error handling. - report_fatal_error("More than one SHT_DYNSYM!"); - DynamicSymbolTableIndex = i; + report_fatal_error("More than one .dynsym!"); + DynSymRegion.Addr = base() + SecI->sh_offset; + DynSymRegion.Size = SecI->sh_size; + DynSymRegion.EntSize = SecI->sh_entsize; + const Elf_Shdr *DynStr = getSection(SecI->sh_link); + DynStrRegion.Addr = base() + DynStr->sh_offset; + DynStrRegion.Size = DynStr->sh_size; + DynStrRegion.EntSize = DynStr->sh_entsize; break; } - case ELF::SHT_REL: - case ELF::SHT_RELA: - break; - case ELF::SHT_DYNAMIC: { - if (dot_dynamic_sec != NULL) + case ELF::SHT_DYNAMIC: + if (DynamicRegion.Addr) // FIXME: Proper error handling. report_fatal_error("More than one .dynamic!"); - dot_dynamic_sec = sh; + DynamicRegion.Addr = base() + SecI->sh_offset; + DynamicRegion.Size = SecI->sh_size; + DynamicRegion.EntSize = SecI->sh_entsize; break; - } - case ELF::SHT_GNU_versym: { + case ELF::SHT_GNU_versym: if (dot_gnu_version_sec != NULL) // FIXME: Proper error handling. report_fatal_error("More than one .gnu.version section!"); - dot_gnu_version_sec = sh; + dot_gnu_version_sec = &*SecI; break; - } - case ELF::SHT_GNU_verdef: { + case ELF::SHT_GNU_verdef: if (dot_gnu_version_d_sec != NULL) // FIXME: Proper error handling. report_fatal_error("More than one .gnu.version_d section!"); - dot_gnu_version_d_sec = sh; + dot_gnu_version_d_sec = &*SecI; break; - } - case ELF::SHT_GNU_verneed: { + case ELF::SHT_GNU_verneed: if (dot_gnu_version_r_sec != NULL) // FIXME: Proper error handling. report_fatal_error("More than one .gnu.version_r section!"); - dot_gnu_version_r_sec = sh; + dot_gnu_version_r_sec = &*SecI; break; } - } - ++sh; } // Get string table sections. @@ -2497,173 +706,117 @@ ELFObjectFile::ELFObjectFile(MemoryBuffer *Object, error_code &ec) VerifyStrTab(dot_shstrtab_sec); } - // Merge this into the above loop. - for (const char *i = reinterpret_cast(SectionHeaderTable), - *e = i + getNumSections() * Header->e_shentsize; - i != e; i += Header->e_shentsize) { - const Elf_Shdr *sh = reinterpret_cast(i); - if (sh->sh_type == ELF::SHT_STRTAB) { - StringRef SectionName(getString(dot_shstrtab_sec, sh->sh_name)); - if (SectionName == ".strtab") { - if (dot_strtab_sec != 0) - // FIXME: Proper error handling. - report_fatal_error("Already found section named .strtab!"); - dot_strtab_sec = sh; - VerifyStrTab(dot_strtab_sec); - } else if (SectionName == ".dynstr") { - if (dot_dynstr_sec != 0) - // FIXME: Proper error handling. - report_fatal_error("Already found section named .dynstr!"); - dot_dynstr_sec = sh; - VerifyStrTab(dot_dynstr_sec); - } - } - } - // Build symbol name side-mapping if there is one. if (SymbolTableSectionHeaderIndex) { const Elf_Word *ShndxTable = reinterpret_cast(base() + SymbolTableSectionHeaderIndex->sh_offset); - error_code ec; - for (symbol_iterator si = begin_symbols(), - se = end_symbols(); si != se; si.increment(ec)) { - if (ec) - report_fatal_error("Fewer extended symbol table entries than symbols!"); + for (Elf_Sym_Iter SI = begin_symbols(), SE = end_symbols(); SI != SE; + ++SI) { if (*ShndxTable != ELF::SHN_UNDEF) - ExtendedSymbolTable[getSymbol(si->getRawDataRefImpl())] = *ShndxTable; + ExtendedSymbolTable[&*SI] = *ShndxTable; ++ShndxTable; } } + + // Scan program headers. + for (Elf_Phdr_Iter PhdrI = begin_program_headers(), + PhdrE = end_program_headers(); + PhdrI != PhdrE; ++PhdrI) { + if (PhdrI->p_type == ELF::PT_DYNAMIC) { + DynamicRegion.Addr = base() + PhdrI->p_offset; + DynamicRegion.Size = PhdrI->p_filesz; + DynamicRegion.EntSize = sizeof(Elf_Dyn); + break; + } + } + + ec = error_code::success(); } // Get the symbol table index in the symtab section given a symbol -template -uint64_t ELFObjectFile::getSymbolIndex(const Elf_Sym *Sym) const { - const Elf_Shdr *SymTab = getSection(SymbolTableIndex); +template +uint64_t ELFFile::getSymbolIndex(const Elf_Sym *Sym) const { uintptr_t SymLoc = uintptr_t(Sym); - uintptr_t SymTabLoc = uintptr_t(base() + SymTab->sh_offset); + uintptr_t SymTabLoc = uintptr_t(base() + dot_symtab_sec->sh_offset); assert(SymLoc > SymTabLoc && "Symbol not in symbol table!"); uint64_t SymOffset = SymLoc - SymTabLoc; - assert(SymOffset % SymTab->sh_entsize == 0 && + assert(SymOffset % dot_symtab_sec->sh_entsize == 0 && "Symbol not multiple of symbol size!"); - return SymOffset / SymTab->sh_entsize; + return SymOffset / dot_symtab_sec->sh_entsize; } -template -symbol_iterator ELFObjectFile::begin_symbols() const { - DataRefImpl SymbolData; - if (SymbolTableIndex == -1) { - SymbolData.d.a = 0; - SymbolData.d.b = 0; - } else { - SymbolData.d.a = 0; - SymbolData.d.b = SymbolTableIndex; - } - return symbol_iterator(SymbolRef(SymbolData, this)); +template +typename ELFFile::Elf_Shdr_Iter ELFFile::begin_sections() const { + return Elf_Shdr_Iter(Header->e_shentsize, + (const char *)base() + Header->e_shoff); } -template -symbol_iterator ELFObjectFile::end_symbols() const { - DataRefImpl SymbolData; - if (SymbolTableIndex == -1) { - SymbolData.d.a = 0; - SymbolData.d.b = 0; - } else { - const Elf_Shdr *SymbolTableSection = getSection(SymbolTableIndex); - SymbolData.d.a = SymbolTableSection->getEntityCount(); - SymbolData.d.b = SymbolTableIndex; - } - return symbol_iterator(SymbolRef(SymbolData, this)); +template +typename ELFFile::Elf_Shdr_Iter ELFFile::end_sections() const { + return Elf_Shdr_Iter(Header->e_shentsize, + (const char *)base() + Header->e_shoff + + (getNumSections() * Header->e_shentsize)); } -template -symbol_iterator ELFObjectFile::begin_dynamic_symbols() const { - DataRefImpl SymbolData; - if (DynamicSymbolTableIndex == -1) { - SymbolData.d.a = 0; - SymbolData.d.b = 0; - } else { - SymbolData.d.a = 0; - SymbolData.d.b = DynamicSymbolTableIndex; - } - return symbol_iterator(SymbolRef(SymbolData, this)); +template +typename ELFFile::Elf_Sym_Iter ELFFile::begin_symbols() const { + if (!dot_symtab_sec) + return Elf_Sym_Iter(0, 0, false); + return Elf_Sym_Iter(dot_symtab_sec->sh_entsize, + (const char *)base() + dot_symtab_sec->sh_offset, false); } -template -symbol_iterator ELFObjectFile::end_dynamic_symbols() const { - DataRefImpl SymbolData; - if (DynamicSymbolTableIndex == -1) { - SymbolData.d.a = 0; - SymbolData.d.b = 0; - } else { - const Elf_Shdr *SymbolTableSection = getSection(DynamicSymbolTableIndex); - SymbolData.d.a = SymbolTableSection->getEntityCount(); - SymbolData.d.b = DynamicSymbolTableIndex; - } - return symbol_iterator(SymbolRef(SymbolData, this)); +template +typename ELFFile::Elf_Sym_Iter ELFFile::end_symbols() const { + if (!dot_symtab_sec) + return Elf_Sym_Iter(0, 0, false); + return Elf_Sym_Iter(dot_symtab_sec->sh_entsize, + (const char *)base() + dot_symtab_sec->sh_offset + + dot_symtab_sec->sh_size, + false); } -template -section_iterator ELFObjectFile::begin_sections() const { - DataRefImpl ret; - ret.p = reinterpret_cast(base() + Header->e_shoff); - return section_iterator(SectionRef(ret, this)); +template +typename ELFFile::Elf_Dyn_Iter +ELFFile::begin_dynamic_table() const { + if (DynamicRegion.Addr) + return Elf_Dyn_Iter(DynamicRegion.EntSize, + (const char *)DynamicRegion.Addr); + return Elf_Dyn_Iter(0, 0); } -template -section_iterator ELFObjectFile::end_sections() const { - DataRefImpl ret; - ret.p = reinterpret_cast(base() - + Header->e_shoff - + (Header->e_shentsize*getNumSections())); - return section_iterator(SectionRef(ret, this)); -} +template +typename ELFFile::Elf_Dyn_Iter +ELFFile::end_dynamic_table(bool NULLEnd) const { + if (!DynamicRegion.Addr) + return Elf_Dyn_Iter(0, 0); + Elf_Dyn_Iter Ret(DynamicRegion.EntSize, + (const char *)DynamicRegion.Addr + DynamicRegion.Size); -template -typename ELFObjectFile::Elf_Dyn_iterator -ELFObjectFile::begin_dynamic_table() const { - if (dot_dynamic_sec) - return Elf_Dyn_iterator(dot_dynamic_sec->sh_entsize, - (const char *)base() + dot_dynamic_sec->sh_offset); - return Elf_Dyn_iterator(0, 0); -} + if (NULLEnd) { + Elf_Dyn_Iter Start = begin_dynamic_table(); + while (Start != Ret && Start->getTag() != ELF::DT_NULL) + ++Start; -template -typename ELFObjectFile::Elf_Dyn_iterator -ELFObjectFile::end_dynamic_table(bool NULLEnd) const { - if (dot_dynamic_sec) { - Elf_Dyn_iterator Ret(dot_dynamic_sec->sh_entsize, - (const char *)base() + dot_dynamic_sec->sh_offset + - dot_dynamic_sec->sh_size); - - if (NULLEnd) { - Elf_Dyn_iterator Start = begin_dynamic_table(); - while (Start != Ret && Start->getTag() != ELF::DT_NULL) - ++Start; - - // Include the DT_NULL. - if (Start != Ret) - ++Start; - Ret = Start; - } - return Ret; + // Include the DT_NULL. + if (Start != Ret) + ++Start; + Ret = Start; } - return Elf_Dyn_iterator(0, 0); + return Ret; } -template -StringRef ELFObjectFile::getLoadName() const { +template +StringRef ELFFile::getLoadName() const { if (!dt_soname) { // Find the DT_SONAME entry - Elf_Dyn_iterator it = begin_dynamic_table(); - Elf_Dyn_iterator ie = end_dynamic_table(); + Elf_Dyn_Iter it = begin_dynamic_table(); + Elf_Dyn_Iter ie = end_dynamic_table(); while (it != ie && it->getTag() != ELF::DT_SONAME) ++it; if (it != ie) { - if (dot_dynstr_sec == NULL) - report_fatal_error("Dynamic string table is missing"); - dt_soname = getString(dot_dynstr_sec, it->getVal()); + dt_soname = getDynamicString(it->getVal()); } else { dt_soname = ""; } @@ -2671,210 +824,23 @@ StringRef ELFObjectFile::getLoadName() const { return dt_soname; } -template -library_iterator ELFObjectFile::begin_libraries_needed() const { - // Find the first DT_NEEDED entry - Elf_Dyn_iterator i = begin_dynamic_table(); - Elf_Dyn_iterator e = end_dynamic_table(); - while (i != e && i->getTag() != ELF::DT_NEEDED) - ++i; - - DataRefImpl DRI; - DRI.p = reinterpret_cast(i.get()); - return library_iterator(LibraryRef(DRI, this)); -} - -template -error_code ELFObjectFile::getLibraryNext(DataRefImpl Data, - LibraryRef &Result) const { - // Use the same DataRefImpl format as DynRef. - Elf_Dyn_iterator i = Elf_Dyn_iterator(dot_dynamic_sec->sh_entsize, - reinterpret_cast(Data.p)); - Elf_Dyn_iterator e = end_dynamic_table(); - - // Skip the current dynamic table entry and find the next DT_NEEDED entry. - do - ++i; - while (i != e && i->getTag() != ELF::DT_NEEDED); - - DataRefImpl DRI; - DRI.p = reinterpret_cast(i.get()); - Result = LibraryRef(DRI, this); - return object_error::success; -} - -template -error_code ELFObjectFile::getLibraryPath(DataRefImpl Data, - StringRef &Res) const { - Elf_Dyn_iterator i = Elf_Dyn_iterator(dot_dynamic_sec->sh_entsize, - reinterpret_cast(Data.p)); - if (i == end_dynamic_table()) - report_fatal_error("getLibraryPath() called on iterator end"); - - if (i->getTag() != ELF::DT_NEEDED) - report_fatal_error("Invalid library_iterator"); - - // This uses .dynstr to lookup the name of the DT_NEEDED entry. - // THis works as long as DT_STRTAB == .dynstr. This is true most of - // the time, but the specification allows exceptions. - // TODO: This should really use DT_STRTAB instead. Doing this requires - // reading the program headers. - if (dot_dynstr_sec == NULL) - report_fatal_error("Dynamic string table is missing"); - Res = getString(dot_dynstr_sec, i->getVal()); - return object_error::success; -} - -template -library_iterator ELFObjectFile::end_libraries_needed() const { - Elf_Dyn_iterator e = end_dynamic_table(); - DataRefImpl DRI; - DRI.p = reinterpret_cast(e.get()); - return library_iterator(LibraryRef(DRI, this)); -} - -template -uint8_t ELFObjectFile::getBytesInAddress() const { - return ELFT::Is64Bits ? 8 : 4; -} - -template -StringRef ELFObjectFile::getFileFormatName() const { - switch(Header->e_ident[ELF::EI_CLASS]) { - case ELF::ELFCLASS32: - switch(Header->e_machine) { - case ELF::EM_386: - return "ELF32-i386"; - case ELF::EM_X86_64: - return "ELF32-x86-64"; - case ELF::EM_ARM: - return "ELF32-arm"; - case ELF::EM_HEXAGON: - return "ELF32-hexagon"; - case ELF::EM_MIPS: - return "ELF32-mips"; - case ELF::EM_PPC: - return "ELF32-ppc"; - default: - return "ELF32-unknown"; - } - case ELF::ELFCLASS64: - switch(Header->e_machine) { - case ELF::EM_386: - return "ELF64-i386"; - case ELF::EM_X86_64: - return "ELF64-x86-64"; - case ELF::EM_AARCH64: - return "ELF64-aarch64"; - case ELF::EM_PPC64: - return "ELF64-ppc64"; - case ELF::EM_S390: - return "ELF64-s390"; - default: - return "ELF64-unknown"; - } - default: - // FIXME: Proper error handling. - report_fatal_error("Invalid ELFCLASS!"); - } -} - -template -unsigned ELFObjectFile::getArch() const { - switch(Header->e_machine) { - case ELF::EM_386: - return Triple::x86; - case ELF::EM_X86_64: - return Triple::x86_64; - case ELF::EM_AARCH64: - return Triple::aarch64; - case ELF::EM_ARM: - return Triple::arm; - case ELF::EM_HEXAGON: - return Triple::hexagon; - case ELF::EM_MIPS: - return (ELFT::TargetEndianness == support::little) ? - Triple::mipsel : Triple::mips; - case ELF::EM_PPC64: - return (ELFT::TargetEndianness == support::little) ? - Triple::ppc64le : Triple::ppc64; - case ELF::EM_S390: - return Triple::systemz; - default: - return Triple::UnknownArch; - } -} - -template -uint64_t ELFObjectFile::getNumSections() const { - assert(Header && "Header not initialized!"); - if (Header->e_shnum == ELF::SHN_UNDEF) { - assert(SectionHeaderTable && "SectionHeaderTable not initialized!"); - return SectionHeaderTable->sh_size; - } - return Header->e_shnum; -} - -template -uint64_t -ELFObjectFile::getStringTableIndex() const { - if (Header->e_shnum == ELF::SHN_UNDEF) { - if (Header->e_shstrndx == ELF::SHN_HIRESERVE) - return SectionHeaderTable->sh_link; - if (Header->e_shstrndx >= getNumSections()) - return 0; - } - return Header->e_shstrndx; -} - -template -template -inline const T * -ELFObjectFile::getEntry(uint32_t Section, uint32_t Entry) const { +template +template +const T *ELFFile::getEntry(uint32_t Section, uint32_t Entry) const { return getEntry(getSection(Section), Entry); } -template -template -inline const T * -ELFObjectFile::getEntry(const Elf_Shdr * Section, uint32_t Entry) const { - return reinterpret_cast( - base() - + Section->sh_offset - + (Entry * Section->sh_entsize)); -} - -template -const typename ELFObjectFile::Elf_Sym * -ELFObjectFile::getSymbol(DataRefImpl Symb) const { - return getEntry(Symb.d.b, Symb.d.a); -} - -template -const typename ELFObjectFile::Elf_Rel * -ELFObjectFile::getRel(DataRefImpl Rel) const { - return getEntry(Rel.d.a, Rel.d.b); -} - -template -const typename ELFObjectFile::Elf_Rela * -ELFObjectFile::getRela(DataRefImpl Rela) const { - return getEntry(Rela.d.a, Rela.d.b); -} - -template -const typename ELFObjectFile::Elf_Shdr * -ELFObjectFile::getSection(DataRefImpl Symb) const { - const Elf_Shdr *sec = getSection(Symb.d.b); - if (sec->sh_type != ELF::SHT_SYMTAB || sec->sh_type != ELF::SHT_DYNSYM) - // FIXME: Proper error handling. - report_fatal_error("Invalid symbol table section!"); - return sec; +template +template +const T *ELFFile::getEntry(const Elf_Shdr *Section, + uint32_t Entry) const { + return reinterpret_cast(base() + Section->sh_offset + + (Entry * Section->sh_entsize)); } -template -const typename ELFObjectFile::Elf_Shdr * -ELFObjectFile::getSection(uint32_t index) const { +template +const typename ELFFile::Elf_Shdr * +ELFFile::getSection(uint32_t index) const { if (index == 0) return 0; if (!SectionHeaderTable || index >= getNumSections()) @@ -2886,15 +852,15 @@ ELFObjectFile::getSection(uint32_t index) const { + (index * Header->e_shentsize)); } -template -const char *ELFObjectFile::getString(uint32_t section, - ELF::Elf32_Word offset) const { +template +const char *ELFFile::getString(uint32_t section, + ELF::Elf32_Word offset) const { return getString(getSection(section), offset); } -template -const char *ELFObjectFile::getString(const Elf_Shdr *section, - ELF::Elf32_Word offset) const { +template +const char *ELFFile::getString(const Elf_Shdr *section, + ELF::Elf32_Word offset) const { assert(section && section->sh_type == ELF::SHT_STRTAB && "Invalid section!"); if (offset >= section->sh_size) // FIXME: Proper error handling. @@ -2902,56 +868,63 @@ const char *ELFObjectFile::getString(const Elf_Shdr *section, return (const char *)base() + section->sh_offset + offset; } -template -error_code ELFObjectFile::getSymbolName(const Elf_Shdr *section, - const Elf_Sym *symb, - StringRef &Result) const { - if (symb->st_name == 0) { - const Elf_Shdr *section = getSection(symb); - if (!section) - Result = ""; - else - Result = getString(dot_shstrtab_sec, section->sh_name); - return object_error::success; - } +template +const char *ELFFile::getDynamicString(uintX_t Offset) const { + if (!DynStrRegion.Addr || Offset >= DynStrRegion.Size) + return 0; + return (const char *)DynStrRegion.Addr + Offset; +} - if (DynamicSymbolTableIndex != -1 && - section == getSection(DynamicSymbolTableIndex)) { - // Symbol is in .dynsym, use .dynstr string table - Result = getString(dot_dynstr_sec, symb->st_name); - } else { - // Use the default symbol table name section. - Result = getString(dot_strtab_sec, symb->st_name); +template +ErrorOr ELFFile::getSymbolName(Elf_Sym_Iter Sym) const { + if (!Sym.isDynamic()) + return getSymbolName(dot_symtab_sec, &*Sym); + + if (!DynStrRegion.Addr || Sym->st_name >= DynStrRegion.Size) + return object_error::parse_failed; + return StringRef(getDynamicString(Sym->st_name)); +} + +template +ErrorOr ELFFile::getSymbolName(const Elf_Shdr *Section, + const Elf_Sym *Symb) const { + if (Symb->st_name == 0) { + const Elf_Shdr *ContainingSec = getSection(Symb); + if (ContainingSec) + return getSectionName(ContainingSec); } - return object_error::success; + + const Elf_Shdr *StrTab = getSection(Section->sh_link); + if (Symb->st_name >= StrTab->sh_size) + return object_error::parse_failed; + return StringRef(getString(StrTab, Symb->st_name)); } -template -error_code ELFObjectFile::getSectionName(const Elf_Shdr *section, - StringRef &Result) const { - Result = StringRef(getString(dot_shstrtab_sec, section->sh_name)); - return object_error::success; +template +ErrorOr +ELFFile::getSectionName(const Elf_Shdr *Section) const { + if (Section->sh_name >= dot_shstrtab_sec->sh_size) + return object_error::parse_failed; + return StringRef(getString(dot_shstrtab_sec, Section->sh_name)); } -template -error_code ELFObjectFile::getSymbolVersion(const Elf_Shdr *section, - const Elf_Sym *symb, - StringRef &Version, - bool &IsDefault) const { +template +ErrorOr ELFFile::getSymbolVersion(const Elf_Shdr *section, + const Elf_Sym *symb, + bool &IsDefault) const { // Handle non-dynamic symbols. - if (section != getSection(DynamicSymbolTableIndex)) { + if (section != DynSymRegion.Addr && section != 0) { // Non-dynamic symbols can have versions in their names // A name of the form 'foo@V1' indicates version 'V1', non-default. // A name of the form 'foo@@V2' indicates version 'V2', default version. - StringRef Name; - error_code ec = getSymbolName(section, symb, Name); - if (ec != object_error::success) - return ec; + ErrorOr SymName = getSymbolName(section, symb); + if (!SymName) + return SymName; + StringRef Name = *SymName; size_t atpos = Name.find('@'); if (atpos == StringRef::npos) { - Version = ""; IsDefault = false; - return object_error::success; + return StringRef(""); } ++atpos; if (atpos < Name.size() && Name[atpos] == '@') { @@ -2960,21 +933,19 @@ error_code ELFObjectFile::getSymbolVersion(const Elf_Shdr *section, } else { IsDefault = false; } - Version = Name.substr(atpos); - return object_error::success; + return Name.substr(atpos); } // This is a dynamic symbol. Look in the GNU symbol version table. if (dot_gnu_version_sec == NULL) { // No version table. - Version = ""; IsDefault = false; - return object_error::success; + return StringRef(""); } // Determine the position in the symbol table of this entry. - const char *sec_start = (const char*)base() + section->sh_offset; - size_t entry_index = ((const char*)symb - sec_start)/section->sh_entsize; + size_t entry_index = ((const char *)symb - (const char *)DynSymRegion.Addr) / + DynSymRegion.EntSize; // Get the corresponding version index entry const Elf_Versym *vs = getEntry(dot_gnu_version_sec, entry_index); @@ -2983,16 +954,14 @@ error_code ELFObjectFile::getSymbolVersion(const Elf_Shdr *section, // Special markers for unversioned symbols. if (version_index == ELF::VER_NDX_LOCAL || version_index == ELF::VER_NDX_GLOBAL) { - Version = ""; IsDefault = false; - return object_error::success; + return StringRef(""); } // Lookup this symbol in the version table LoadVersionMap(); if (version_index >= VersionMap.size() || VersionMap[version_index].isNull()) - report_fatal_error("Symbol has version index without corresponding " - "define or reference entry"); + return object_error::parse_failed; const VersionMapEntry &entry = VersionMap[version_index]; // Get the version name string @@ -3003,7 +972,6 @@ error_code ELFObjectFile::getSymbolVersion(const Elf_Shdr *section, } else { name_offset = entry.getVernaux()->vna_name; } - Version = getString(dot_dynstr_sec, name_offset); // Set IsDefault if (entry.isVerdef()) { @@ -3012,57 +980,9 @@ error_code ELFObjectFile::getSymbolVersion(const Elf_Shdr *section, IsDefault = false; } - return object_error::success; -} - -/// FIXME: Maybe we should have a base ElfObjectFile that is not a template -/// and make these member functions? -static inline error_code getELFRelocationAddend(const RelocationRef R, - int64_t &Addend) { - const ObjectFile *Obj = R.getObjectFile(); - DataRefImpl DRI = R.getRawDataRefImpl(); - // Little-endian 32-bit - if (const ELF32LEObjectFile *ELFObj = dyn_cast(Obj)) - return ELFObj->getRelocationAddend(DRI, Addend); - - // Big-endian 32-bit - if (const ELF32BEObjectFile *ELFObj = dyn_cast(Obj)) - return ELFObj->getRelocationAddend(DRI, Addend); - - // Little-endian 64-bit - if (const ELF64LEObjectFile *ELFObj = dyn_cast(Obj)) - return ELFObj->getRelocationAddend(DRI, Addend); - - // Big-endian 64-bit - if (const ELF64BEObjectFile *ELFObj = dyn_cast(Obj)) - return ELFObj->getRelocationAddend(DRI, Addend); - - llvm_unreachable("Object passed to getELFRelocationAddend() is not ELF"); -} - -/// This is a generic interface for retrieving GNU symbol version -/// information from an ELFObjectFile. -static inline error_code GetELFSymbolVersion(const ObjectFile *Obj, - const SymbolRef &Sym, - StringRef &Version, - bool &IsDefault) { - // Little-endian 32-bit - if (const ELF32LEObjectFile *ELFObj = dyn_cast(Obj)) - return ELFObj->getSymbolVersion(Sym, Version, IsDefault); - - // Big-endian 32-bit - if (const ELF32BEObjectFile *ELFObj = dyn_cast(Obj)) - return ELFObj->getSymbolVersion(Sym, Version, IsDefault); - - // Little-endian 64-bit - if (const ELF64LEObjectFile *ELFObj = dyn_cast(Obj)) - return ELFObj->getSymbolVersion(Sym, Version, IsDefault); - - // Big-endian 64-bit - if (const ELF64BEObjectFile *ELFObj = dyn_cast(Obj)) - return ELFObj->getSymbolVersion(Sym, Version, IsDefault); - - llvm_unreachable("Object passed to GetELFSymbolVersion() is not ELF"); + if (name_offset >= DynStrRegion.Size) + return object_error::parse_failed; + return StringRef(getDynamicString(name_offset)); } /// This function returns the hash value for a symbol in the .dynsym section @@ -3079,8 +999,7 @@ static inline unsigned elf_hash(StringRef &symbolName) { } return h; } - -} -} +} // end namespace object +} // end namespace llvm #endif diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h new file mode 100644 index 0000000..f0be8ab --- /dev/null +++ b/include/llvm/Object/ELFObjectFile.h @@ -0,0 +1,1098 @@ +//===- ELFObjectFile.h - ELF object file implementation ---------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the ELFObjectFile template class. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_OBJECT_ELF_OBJECT_FILE_H +#define LLVM_OBJECT_ELF_OBJECT_FILE_H + +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/PointerIntPair.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/StringSwitch.h" +#include "llvm/ADT/Triple.h" +#include "llvm/Object/ELF.h" +#include "llvm/Object/ObjectFile.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/ELF.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/raw_ostream.h" +#include +#include +#include + +namespace llvm { +namespace object { + +template +class ELFObjectFile : public ObjectFile { +public: + LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) + + typedef typename ELFFile::uintX_t uintX_t; + + typedef typename ELFFile::Elf_Sym Elf_Sym; + typedef typename ELFFile::Elf_Shdr Elf_Shdr; + typedef typename ELFFile::Elf_Rel Elf_Rel; + typedef typename ELFFile::Elf_Rela Elf_Rela; + typedef typename ELFFile::Elf_Dyn Elf_Dyn; + + typedef typename ELFFile::Elf_Sym_Iter Elf_Sym_Iter; + typedef typename ELFFile::Elf_Shdr_Iter Elf_Shdr_Iter; + typedef typename ELFFile::Elf_Dyn_Iter Elf_Dyn_Iter; + +protected: + ELFFile EF; + + virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const; + virtual error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const; + virtual error_code getSymbolFileOffset(DataRefImpl Symb, uint64_t &Res) const; + virtual error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res) const; + virtual error_code getSymbolAlignment(DataRefImpl Symb, uint32_t &Res) const; + virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const; + virtual error_code getSymbolNMTypeChar(DataRefImpl Symb, char &Res) const; + virtual error_code getSymbolFlags(DataRefImpl Symb, uint32_t &Res) const; + virtual error_code getSymbolType(DataRefImpl Symb, + SymbolRef::Type &Res) const; + virtual error_code getSymbolSection(DataRefImpl Symb, + section_iterator &Res) const; + virtual error_code getSymbolValue(DataRefImpl Symb, uint64_t &Val) const; + + virtual error_code getLibraryNext(DataRefImpl Data, LibraryRef &Result) const; + virtual error_code getLibraryPath(DataRefImpl Data, StringRef &Res) const; + + virtual error_code getSectionNext(DataRefImpl Sec, SectionRef &Res) const; + virtual error_code getSectionName(DataRefImpl Sec, StringRef &Res) const; + virtual error_code getSectionAddress(DataRefImpl Sec, uint64_t &Res) const; + virtual error_code getSectionSize(DataRefImpl Sec, uint64_t &Res) const; + virtual error_code getSectionContents(DataRefImpl Sec, StringRef &Res) const; + virtual error_code getSectionAlignment(DataRefImpl Sec, uint64_t &Res) const; + virtual error_code isSectionText(DataRefImpl Sec, bool &Res) const; + virtual error_code isSectionData(DataRefImpl Sec, bool &Res) const; + virtual error_code isSectionBSS(DataRefImpl Sec, bool &Res) const; + virtual error_code isSectionRequiredForExecution(DataRefImpl Sec, + bool &Res) const; + virtual error_code isSectionVirtual(DataRefImpl Sec, bool &Res) const; + virtual error_code isSectionZeroInit(DataRefImpl Sec, bool &Res) const; + virtual error_code isSectionReadOnlyData(DataRefImpl Sec, bool &Res) const; + virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, + bool &Result) const; + virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const; + virtual relocation_iterator getSectionRelEnd(DataRefImpl Sec) const; + virtual section_iterator getRelocatedSection(DataRefImpl Sec) const; + + virtual error_code getRelocationNext(DataRefImpl Rel, + RelocationRef &Res) const; + virtual error_code getRelocationAddress(DataRefImpl Rel, uint64_t &Res) const; + virtual error_code getRelocationOffset(DataRefImpl Rel, uint64_t &Res) const; + virtual symbol_iterator getRelocationSymbol(DataRefImpl Rel) const; + virtual error_code getRelocationType(DataRefImpl Rel, uint64_t &Res) const; + virtual error_code getRelocationTypeName(DataRefImpl Rel, + SmallVectorImpl &Result) const; + virtual error_code + getRelocationValueString(DataRefImpl Rel, + SmallVectorImpl &Result) const; + +protected: // ELF specific protected members. + const Elf_Sym *getSymbol(DataRefImpl Symb) const; + uint64_t getROffset(DataRefImpl Rel) const; + StringRef getRelocationTypeName(uint32_t Type) const; + + /// \brief Get the relocation section that contains \a Rel. + const Elf_Shdr *getRelSection(DataRefImpl Rel) const { + return EF.getSection(Rel.d.a); + } + + const Elf_Rel *getRel(DataRefImpl Rel) const; + const Elf_Rela *getRela(DataRefImpl Rela) const; + + Elf_Sym_Iter toELFSymIter(DataRefImpl Symb) const { + bool IsDynamic = Symb.p & 1; + if (IsDynamic) + return Elf_Sym_Iter( + EF.begin_dynamic_symbols().getEntSize(), + reinterpret_cast(Symb.p & ~uintptr_t(1)), IsDynamic); + return Elf_Sym_Iter(EF.begin_symbols().getEntSize(), + reinterpret_cast(Symb.p), IsDynamic); + } + + DataRefImpl toDRI(Elf_Sym_Iter Symb) const { + DataRefImpl DRI; + DRI.p = reinterpret_cast(Symb.get()) | Symb.isDynamic(); + return DRI; + } + + Elf_Shdr_Iter toELFShdrIter(DataRefImpl Sec) const { + return Elf_Shdr_Iter(EF.getHeader()->e_shentsize, + reinterpret_cast(Sec.p)); + } + + DataRefImpl toDRI(Elf_Shdr_Iter Sec) const { + DataRefImpl DRI; + DRI.p = reinterpret_cast(Sec.get()); + return DRI; + } + + DataRefImpl toDRI(const Elf_Shdr *Sec) const { + DataRefImpl DRI; + DRI.p = reinterpret_cast(Sec); + return DRI; + } + + Elf_Dyn_Iter toELFDynIter(DataRefImpl Dyn) const { + return Elf_Dyn_Iter(EF.begin_dynamic_table().getEntSize(), + reinterpret_cast(Dyn.p)); + } + + DataRefImpl toDRI(Elf_Dyn_Iter Dyn) const { + DataRefImpl DRI; + DRI.p = reinterpret_cast(Dyn.get()); + return DRI; + } + + // This flag is used for classof, to distinguish ELFObjectFile from + // its subclass. If more subclasses will be created, this flag will + // have to become an enum. + bool isDyldELFObject; + +public: + ELFObjectFile(MemoryBuffer *Object, error_code &ec); + + virtual symbol_iterator begin_symbols() const; + virtual symbol_iterator end_symbols() const; + + virtual symbol_iterator begin_dynamic_symbols() const; + virtual symbol_iterator end_dynamic_symbols() const; + + virtual section_iterator begin_sections() const; + virtual section_iterator end_sections() const; + + virtual library_iterator begin_libraries_needed() const; + virtual library_iterator end_libraries_needed() const; + + error_code getRelocationAddend(DataRefImpl Rel, int64_t &Res) const; + error_code getSymbolVersion(SymbolRef Symb, StringRef &Version, + bool &IsDefault) const; + + virtual uint8_t getBytesInAddress() const; + virtual StringRef getFileFormatName() const; + virtual StringRef getObjectType() const { return "ELF"; } + virtual unsigned getArch() const; + virtual StringRef getLoadName() const; + + const ELFFile *getELFFile() const { return &EF; } + + bool isDyldType() const { return isDyldELFObject; } + static inline bool classof(const Binary *v) { + return v->getType() == getELFType(ELFT::TargetEndianness == support::little, + ELFT::Is64Bits); + } +}; + +// Use an alignment of 2 for the typedefs since that is the worst case for +// ELF files in archives. +typedef ELFObjectFile > ELF32LEObjectFile; +typedef ELFObjectFile > ELF64LEObjectFile; +typedef ELFObjectFile > ELF32BEObjectFile; +typedef ELFObjectFile > ELF64BEObjectFile; + +template +error_code ELFObjectFile::getSymbolNext(DataRefImpl Symb, + SymbolRef &Result) const { + Result = SymbolRef(toDRI(++toELFSymIter(Symb)), this); + return object_error::success; +} + +template +error_code ELFObjectFile::getSymbolName(DataRefImpl Symb, + StringRef &Result) const { + ErrorOr Name = EF.getSymbolName(toELFSymIter(Symb)); + if (!Name) + return Name; + Result = *Name; + return object_error::success; +} + +template +error_code ELFObjectFile::getSymbolVersion(SymbolRef SymRef, + StringRef &Version, + bool &IsDefault) const { + DataRefImpl Symb = SymRef.getRawDataRefImpl(); + const Elf_Sym *symb = getSymbol(Symb); + ErrorOr Ver = + EF.getSymbolVersion(EF.getSection(Symb.d.b), symb, IsDefault); + if (!Ver) + return Ver; + Version = *Ver; + return object_error::success; +} + +template +error_code ELFObjectFile::getSymbolFileOffset(DataRefImpl Symb, + uint64_t &Result) const { + const Elf_Sym *ESym = getSymbol(Symb); + const Elf_Shdr *ESec; + switch (EF.getSymbolTableIndex(ESym)) { + case ELF::SHN_COMMON: + // Unintialized symbols have no offset in the object file + case ELF::SHN_UNDEF: + Result = UnknownAddressOrSize; + return object_error::success; + case ELF::SHN_ABS: + Result = ESym->st_value; + return object_error::success; + default: + ESec = EF.getSection(ESym); + } + + switch (ESym->getType()) { + case ELF::STT_SECTION: + Result = ESec ? ESec->sh_offset : UnknownAddressOrSize; + return object_error::success; + case ELF::STT_FUNC: + case ELF::STT_OBJECT: + case ELF::STT_NOTYPE: + Result = ESym->st_value + (ESec ? ESec->sh_offset : 0); + return object_error::success; + default: + Result = UnknownAddressOrSize; + return object_error::success; + } +} + +template +error_code ELFObjectFile::getSymbolAddress(DataRefImpl Symb, + uint64_t &Result) const { + const Elf_Sym *ESym = getSymbol(Symb); + const Elf_Shdr *ESec; + switch (EF.getSymbolTableIndex(ESym)) { + case ELF::SHN_COMMON: + case ELF::SHN_UNDEF: + Result = UnknownAddressOrSize; + return object_error::success; + case ELF::SHN_ABS: + Result = ESym->st_value; + return object_error::success; + default: + ESec = EF.getSection(ESym); + } + + switch (ESym->getType()) { + case ELF::STT_SECTION: + Result = ESec ? ESec->sh_addr : UnknownAddressOrSize; + return object_error::success; + case ELF::STT_FUNC: + case ELF::STT_OBJECT: + case ELF::STT_NOTYPE: + bool IsRelocatable; + switch (EF.getHeader()->e_type) { + case ELF::ET_EXEC: + case ELF::ET_DYN: + IsRelocatable = false; + break; + default: + IsRelocatable = true; + } + Result = ESym->st_value; + + // Clear the ARM/Thumb indicator flag. + if (EF.getHeader()->e_machine == ELF::EM_ARM) + Result &= ~1; + + if (IsRelocatable && ESec != 0) + Result += ESec->sh_addr; + return object_error::success; + default: + Result = UnknownAddressOrSize; + return object_error::success; + } +} + +template +error_code ELFObjectFile::getSymbolAlignment(DataRefImpl Symb, + uint32_t &Res) const { + Elf_Sym_Iter Sym = toELFSymIter(Symb); + if (Sym->st_shndx == ELF::SHN_COMMON) + Res = Sym->st_value; + else + Res = 0; + return object_error::success; +} + +template +error_code ELFObjectFile::getSymbolSize(DataRefImpl Symb, + uint64_t &Result) const { + Result = toELFSymIter(Symb)->st_size; + return object_error::success; +} + +template +error_code ELFObjectFile::getSymbolNMTypeChar(DataRefImpl Symb, + char &Result) const { + const Elf_Sym *ESym = getSymbol(Symb); + const Elf_Shdr *ESec = EF.getSection(ESym); + + char ret = '?'; + + if (ESec) { + switch (ESec->sh_type) { + case ELF::SHT_PROGBITS: + case ELF::SHT_DYNAMIC: + switch (ESec->sh_flags) { + case (ELF::SHF_ALLOC | ELF::SHF_EXECINSTR): + ret = 't'; + break; + case (ELF::SHF_ALLOC | ELF::SHF_WRITE): + ret = 'd'; + break; + case ELF::SHF_ALLOC: + case (ELF::SHF_ALLOC | ELF::SHF_MERGE): + case (ELF::SHF_ALLOC | ELF::SHF_MERGE | ELF::SHF_STRINGS): + ret = 'r'; + break; + } + break; + case ELF::SHT_NOBITS: + ret = 'b'; + } + } + + switch (EF.getSymbolTableIndex(ESym)) { + case ELF::SHN_UNDEF: + if (ret == '?') + ret = 'U'; + break; + case ELF::SHN_ABS: + ret = 'a'; + break; + case ELF::SHN_COMMON: + ret = 'c'; + break; + } + + switch (ESym->getBinding()) { + case ELF::STB_GLOBAL: + ret = ::toupper(ret); + break; + case ELF::STB_WEAK: + if (EF.getSymbolTableIndex(ESym) == ELF::SHN_UNDEF) + ret = 'w'; + else if (ESym->getType() == ELF::STT_OBJECT) + ret = 'V'; + else + ret = 'W'; + } + + if (ret == '?' && ESym->getType() == ELF::STT_SECTION) { + ErrorOr Name = EF.getSymbolName(toELFSymIter(Symb)); + if (!Name) + return Name; + Result = StringSwitch(*Name) + .StartsWith(".debug", 'N') + .StartsWith(".note", 'n') + .Default('?'); + return object_error::success; + } + + Result = ret; + return object_error::success; +} + +template +error_code ELFObjectFile::getSymbolType(DataRefImpl Symb, + SymbolRef::Type &Result) const { + const Elf_Sym *ESym = getSymbol(Symb); + + switch (ESym->getType()) { + case ELF::STT_NOTYPE: + Result = SymbolRef::ST_Unknown; + break; + case ELF::STT_SECTION: + Result = SymbolRef::ST_Debug; + break; + case ELF::STT_FILE: + Result = SymbolRef::ST_File; + break; + case ELF::STT_FUNC: + Result = SymbolRef::ST_Function; + break; + case ELF::STT_OBJECT: + case ELF::STT_COMMON: + case ELF::STT_TLS: + Result = SymbolRef::ST_Data; + break; + default: + Result = SymbolRef::ST_Other; + break; + } + return object_error::success; +} + +template +error_code ELFObjectFile::getSymbolFlags(DataRefImpl Symb, + uint32_t &Result) const { + const Elf_Sym *ESym = getSymbol(Symb); + + Result = SymbolRef::SF_None; + + if (ESym->getBinding() != ELF::STB_LOCAL) + Result |= SymbolRef::SF_Global; + + if (ESym->getBinding() == ELF::STB_WEAK) + Result |= SymbolRef::SF_Weak; + + if (ESym->st_shndx == ELF::SHN_ABS) + Result |= SymbolRef::SF_Absolute; + + if (ESym->getType() == ELF::STT_FILE || ESym->getType() == ELF::STT_SECTION || + ESym == &*EF.begin_symbols()) + Result |= SymbolRef::SF_FormatSpecific; + + if (EF.getSymbolTableIndex(ESym) == ELF::SHN_UNDEF) + Result |= SymbolRef::SF_Undefined; + + if (ESym->getType() == ELF::STT_COMMON || + EF.getSymbolTableIndex(ESym) == ELF::SHN_COMMON) + Result |= SymbolRef::SF_Common; + + if (ESym->getType() == ELF::STT_TLS) + Result |= SymbolRef::SF_ThreadLocal; + + return object_error::success; +} + +template +error_code ELFObjectFile::getSymbolSection(DataRefImpl Symb, + section_iterator &Res) const { + const Elf_Sym *ESym = getSymbol(Symb); + const Elf_Shdr *ESec = EF.getSection(ESym); + if (!ESec) + Res = end_sections(); + else { + DataRefImpl Sec; + Sec.p = reinterpret_cast(ESec); + Res = section_iterator(SectionRef(Sec, this)); + } + return object_error::success; +} + +template +error_code ELFObjectFile::getSymbolValue(DataRefImpl Symb, + uint64_t &Val) const { + const Elf_Sym *ESym = getSymbol(Symb); + Val = ESym->st_value; + return object_error::success; +} + +template +error_code ELFObjectFile::getSectionNext(DataRefImpl Sec, + SectionRef &Result) const { + Result = SectionRef(toDRI(++toELFShdrIter(Sec)), this); + return object_error::success; +} + +template +error_code ELFObjectFile::getSectionName(DataRefImpl Sec, + StringRef &Result) const { + ErrorOr Name = EF.getSectionName(&*toELFShdrIter(Sec)); + if (!Name) + return Name; + Result = *Name; + return object_error::success; +} + +template +error_code ELFObjectFile::getSectionAddress(DataRefImpl Sec, + uint64_t &Result) const { + Result = toELFShdrIter(Sec)->sh_addr; + return object_error::success; +} + +template +error_code ELFObjectFile::getSectionSize(DataRefImpl Sec, + uint64_t &Result) const { + Result = toELFShdrIter(Sec)->sh_size; + return object_error::success; +} + +template +error_code ELFObjectFile::getSectionContents(DataRefImpl Sec, + StringRef &Result) const { + Elf_Shdr_Iter EShdr = toELFShdrIter(Sec); + Result = StringRef((const char *)base() + EShdr->sh_offset, EShdr->sh_size); + return object_error::success; +} + +template +error_code ELFObjectFile::getSectionAlignment(DataRefImpl Sec, + uint64_t &Result) const { + Result = toELFShdrIter(Sec)->sh_addralign; + return object_error::success; +} + +template +error_code ELFObjectFile::isSectionText(DataRefImpl Sec, + bool &Result) const { + Result = toELFShdrIter(Sec)->sh_flags & ELF::SHF_EXECINSTR; + return object_error::success; +} + +template +error_code ELFObjectFile::isSectionData(DataRefImpl Sec, + bool &Result) const { + Elf_Shdr_Iter EShdr = toELFShdrIter(Sec); + Result = EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) && + EShdr->sh_type == ELF::SHT_PROGBITS; + return object_error::success; +} + +template +error_code ELFObjectFile::isSectionBSS(DataRefImpl Sec, + bool &Result) const { + Elf_Shdr_Iter EShdr = toELFShdrIter(Sec); + Result = EShdr->sh_flags & (ELF::SHF_ALLOC | ELF::SHF_WRITE) && + EShdr->sh_type == ELF::SHT_NOBITS; + return object_error::success; +} + +template +error_code +ELFObjectFile::isSectionRequiredForExecution(DataRefImpl Sec, + bool &Result) const { + Result = toELFShdrIter(Sec)->sh_flags & ELF::SHF_ALLOC; + return object_error::success; +} + +template +error_code ELFObjectFile::isSectionVirtual(DataRefImpl Sec, + bool &Result) const { + Result = toELFShdrIter(Sec)->sh_type & ELF::SHT_NOBITS; + return object_error::success; +} + +template +error_code ELFObjectFile::isSectionZeroInit(DataRefImpl Sec, + bool &Result) const { + Result = toELFShdrIter(Sec)->sh_type & ELF::SHT_NOBITS; + return object_error::success; +} + +template +error_code ELFObjectFile::isSectionReadOnlyData(DataRefImpl Sec, + bool &Result) const { + Elf_Shdr_Iter EShdr = toELFShdrIter(Sec); + Result = !(EShdr->sh_flags & (ELF::SHF_WRITE | ELF::SHF_EXECINSTR)); + return object_error::success; +} + +template +error_code ELFObjectFile::sectionContainsSymbol(DataRefImpl Sec, + DataRefImpl Symb, + bool &Result) const { + Elf_Sym_Iter ESym = toELFSymIter(Symb); + + uintX_t Index = ESym->st_shndx; + bool Reserved = Index >= ELF::SHN_LORESERVE && Index <= ELF::SHN_HIRESERVE; + + Result = !Reserved && (&*toELFShdrIter(Sec) == EF.getSection(ESym->st_shndx)); + return object_error::success; +} + +template +relocation_iterator +ELFObjectFile::getSectionRelBegin(DataRefImpl Sec) const { + DataRefImpl RelData; + uintptr_t SHT = reinterpret_cast(EF.begin_sections().get()); + RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize; + RelData.d.b = 0; + return relocation_iterator(RelocationRef(RelData, this)); +} + +template +relocation_iterator +ELFObjectFile::getSectionRelEnd(DataRefImpl Sec) const { + DataRefImpl RelData; + uintptr_t SHT = reinterpret_cast(EF.begin_sections().get()); + const Elf_Shdr *S = reinterpret_cast(Sec.p); + RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize; + if (S->sh_type != ELF::SHT_RELA && S->sh_type != ELF::SHT_REL) + RelData.d.b = 0; + else + RelData.d.b = S->sh_size / S->sh_entsize; + + return relocation_iterator(RelocationRef(RelData, this)); +} + +template +section_iterator +ELFObjectFile::getRelocatedSection(DataRefImpl Sec) const { + if (EF.getHeader()->e_type != ELF::ET_REL) + return end_sections(); + + Elf_Shdr_Iter EShdr = toELFShdrIter(Sec); + uintX_t Type = EShdr->sh_type; + if (Type != ELF::SHT_REL && Type != ELF::SHT_RELA) + return end_sections(); + + const Elf_Shdr *R = EF.getSection(EShdr->sh_info); + return section_iterator(SectionRef(toDRI(R), this)); +} + +// Relocations +template +error_code ELFObjectFile::getRelocationNext(DataRefImpl Rel, + RelocationRef &Result) const { + ++Rel.d.b; + Result = RelocationRef(Rel, this); + return object_error::success; +} + +template +symbol_iterator +ELFObjectFile::getRelocationSymbol(DataRefImpl Rel) const { + uint32_t symbolIdx; + const Elf_Shdr *sec = getRelSection(Rel); + switch (sec->sh_type) { + default: + report_fatal_error("Invalid section type in Rel!"); + case ELF::SHT_REL: { + symbolIdx = getRel(Rel)->getSymbol(EF.isMips64EL()); + break; + } + case ELF::SHT_RELA: { + symbolIdx = getRela(Rel)->getSymbol(EF.isMips64EL()); + break; + } + } + if (!symbolIdx) + return end_symbols(); + + const Elf_Shdr *SymSec = EF.getSection(sec->sh_link); + + DataRefImpl SymbolData; + switch (SymSec->sh_type) { + default: + report_fatal_error("Invalid symbol table section type!"); + case ELF::SHT_SYMTAB: + SymbolData = toDRI(EF.begin_symbols() + symbolIdx); + break; + case ELF::SHT_DYNSYM: + SymbolData = toDRI(EF.begin_dynamic_symbols() + symbolIdx); + break; + } + + return symbol_iterator(SymbolRef(SymbolData, this)); +} + +template +error_code ELFObjectFile::getRelocationAddress(DataRefImpl Rel, + uint64_t &Result) const { + Result = getROffset(Rel); + return object_error::success; +} + +template +error_code ELFObjectFile::getRelocationOffset(DataRefImpl Rel, + uint64_t &Result) const { + Result = getROffset(Rel); + return object_error::success; +} + +template +uint64_t ELFObjectFile::getROffset(DataRefImpl Rel) const { + const Elf_Shdr *sec = getRelSection(Rel); + switch (sec->sh_type) { + default: + report_fatal_error("Invalid section type in Rel!"); + case ELF::SHT_REL: + return getRel(Rel)->r_offset; + case ELF::SHT_RELA: + return getRela(Rel)->r_offset; + } +} + +template +error_code ELFObjectFile::getRelocationType(DataRefImpl Rel, + uint64_t &Result) const { + const Elf_Shdr *sec = getRelSection(Rel); + switch (sec->sh_type) { + default: + report_fatal_error("Invalid section type in Rel!"); + case ELF::SHT_REL: { + Result = getRel(Rel)->getType(EF.isMips64EL()); + break; + } + case ELF::SHT_RELA: { + Result = getRela(Rel)->getType(EF.isMips64EL()); + break; + } + } + return object_error::success; +} + +template +StringRef ELFObjectFile::getRelocationTypeName(uint32_t Type) const { + return getELFRelocationTypeName(EF.getHeader()->e_machine, Type); +} + +template +error_code ELFObjectFile::getRelocationTypeName( + DataRefImpl Rel, SmallVectorImpl &Result) const { + const Elf_Shdr *sec = getRelSection(Rel); + uint32_t type; + switch (sec->sh_type) { + default: + return object_error::parse_failed; + case ELF::SHT_REL: { + type = getRel(Rel)->getType(EF.isMips64EL()); + break; + } + case ELF::SHT_RELA: { + type = getRela(Rel)->getType(EF.isMips64EL()); + break; + } + } + + EF.getRelocationTypeName(type, Result); + return object_error::success; +} + +template +error_code ELFObjectFile::getRelocationAddend(DataRefImpl Rel, + int64_t &Result) const { + const Elf_Shdr *sec = getRelSection(Rel); + switch (sec->sh_type) { + default: + report_fatal_error("Invalid section type in Rel!"); + case ELF::SHT_REL: { + Result = 0; + return object_error::success; + } + case ELF::SHT_RELA: { + Result = getRela(Rel)->r_addend; + return object_error::success; + } + } +} + +template +error_code ELFObjectFile::getRelocationValueString( + DataRefImpl Rel, SmallVectorImpl &Result) const { + const Elf_Shdr *sec = getRelSection(Rel); + uint8_t type; + StringRef res; + int64_t addend = 0; + uint16_t symbol_index = 0; + switch (sec->sh_type) { + default: + return object_error::parse_failed; + case ELF::SHT_REL: { + type = getRel(Rel)->getType(EF.isMips64EL()); + symbol_index = getRel(Rel)->getSymbol(EF.isMips64EL()); + // TODO: Read implicit addend from section data. + break; + } + case ELF::SHT_RELA: { + type = getRela(Rel)->getType(EF.isMips64EL()); + symbol_index = getRela(Rel)->getSymbol(EF.isMips64EL()); + addend = getRela(Rel)->r_addend; + break; + } + } + const Elf_Sym *symb = + EF.template getEntry(sec->sh_link, symbol_index); + ErrorOr SymName = + EF.getSymbolName(EF.getSection(sec->sh_link), symb); + if (!SymName) + return SymName; + switch (EF.getHeader()->e_machine) { + case ELF::EM_X86_64: + switch (type) { + case ELF::R_X86_64_PC8: + case ELF::R_X86_64_PC16: + case ELF::R_X86_64_PC32: { + std::string fmtbuf; + raw_string_ostream fmt(fmtbuf); + fmt << *SymName << (addend < 0 ? "" : "+") << addend << "-P"; + fmt.flush(); + Result.append(fmtbuf.begin(), fmtbuf.end()); + } break; + case ELF::R_X86_64_8: + case ELF::R_X86_64_16: + case ELF::R_X86_64_32: + case ELF::R_X86_64_32S: + case ELF::R_X86_64_64: { + std::string fmtbuf; + raw_string_ostream fmt(fmtbuf); + fmt << *SymName << (addend < 0 ? "" : "+") << addend; + fmt.flush(); + Result.append(fmtbuf.begin(), fmtbuf.end()); + } break; + default: + res = "Unknown"; + } + break; + case ELF::EM_AARCH64: { + std::string fmtbuf; + raw_string_ostream fmt(fmtbuf); + fmt << *SymName; + if (addend != 0) + fmt << (addend < 0 ? "" : "+") << addend; + fmt.flush(); + Result.append(fmtbuf.begin(), fmtbuf.end()); + break; + } + case ELF::EM_ARM: + case ELF::EM_HEXAGON: + res = *SymName; + break; + default: + res = "Unknown"; + } + if (Result.empty()) + Result.append(res.begin(), res.end()); + return object_error::success; +} + +template +const typename ELFFile::Elf_Sym * +ELFObjectFile::getSymbol(DataRefImpl Symb) const { + return &*toELFSymIter(Symb); +} + +template +const typename ELFObjectFile::Elf_Rel * +ELFObjectFile::getRel(DataRefImpl Rel) const { + return EF.template getEntry(Rel.d.a, Rel.d.b); +} + +template +const typename ELFObjectFile::Elf_Rela * +ELFObjectFile::getRela(DataRefImpl Rela) const { + return EF.template getEntry(Rela.d.a, Rela.d.b); +} + +template +ELFObjectFile::ELFObjectFile(MemoryBuffer *Object, error_code &ec) + : ObjectFile(getELFType(static_cast(ELFT::TargetEndianness) == + support::little, + ELFT::Is64Bits), + Object), + EF(Object, ec) {} + +template +symbol_iterator ELFObjectFile::begin_symbols() const { + return symbol_iterator(SymbolRef(toDRI(EF.begin_symbols()), this)); +} + +template +symbol_iterator ELFObjectFile::end_symbols() const { + return symbol_iterator(SymbolRef(toDRI(EF.end_symbols()), this)); +} + +template +symbol_iterator ELFObjectFile::begin_dynamic_symbols() const { + return symbol_iterator(SymbolRef(toDRI(EF.begin_dynamic_symbols()), this)); +} + +template +symbol_iterator ELFObjectFile::end_dynamic_symbols() const { + return symbol_iterator(SymbolRef(toDRI(EF.end_dynamic_symbols()), this)); +} + +template +section_iterator ELFObjectFile::begin_sections() const { + return section_iterator(SectionRef(toDRI(EF.begin_sections()), this)); +} + +template +section_iterator ELFObjectFile::end_sections() const { + return section_iterator(SectionRef(toDRI(EF.end_sections()), this)); +} + +template +StringRef ELFObjectFile::getLoadName() const { + Elf_Dyn_Iter DI = EF.begin_dynamic_table(); + Elf_Dyn_Iter DE = EF.end_dynamic_table(); + + while (DI != DE && DI->getTag() != ELF::DT_SONAME) + ++DI; + + if (DI != DE) + return EF.getDynamicString(DI->getVal()); + return ""; +} + +template +library_iterator ELFObjectFile::begin_libraries_needed() const { + Elf_Dyn_Iter DI = EF.begin_dynamic_table(); + Elf_Dyn_Iter DE = EF.end_dynamic_table(); + + while (DI != DE && DI->getTag() != ELF::DT_SONAME) + ++DI; + + return library_iterator(LibraryRef(toDRI(DI), this)); +} + +template +error_code ELFObjectFile::getLibraryNext(DataRefImpl Data, + LibraryRef &Result) const { + Elf_Dyn_Iter DI = toELFDynIter(Data); + Elf_Dyn_Iter DE = EF.end_dynamic_table(); + + // Skip to the next DT_NEEDED entry. + do + ++DI; + while (DI != DE && DI->getTag() != ELF::DT_NEEDED); + + Result = LibraryRef(toDRI(DI), this); + return object_error::success; +} + +template +error_code ELFObjectFile::getLibraryPath(DataRefImpl Data, + StringRef &Res) const { + Res = EF.getDynamicString(toELFDynIter(Data)->getVal()); + return object_error::success; +} + +template +library_iterator ELFObjectFile::end_libraries_needed() const { + return library_iterator(LibraryRef(toDRI(EF.end_dynamic_table()), this)); +} + +template +uint8_t ELFObjectFile::getBytesInAddress() const { + return ELFT::Is64Bits ? 8 : 4; +} + +template +StringRef ELFObjectFile::getFileFormatName() const { + switch (EF.getHeader()->e_ident[ELF::EI_CLASS]) { + case ELF::ELFCLASS32: + switch (EF.getHeader()->e_machine) { + case ELF::EM_386: + return "ELF32-i386"; + case ELF::EM_X86_64: + return "ELF32-x86-64"; + case ELF::EM_ARM: + return "ELF32-arm"; + case ELF::EM_HEXAGON: + return "ELF32-hexagon"; + case ELF::EM_MIPS: + return "ELF32-mips"; + case ELF::EM_PPC: + return "ELF32-ppc"; + default: + return "ELF32-unknown"; + } + case ELF::ELFCLASS64: + switch (EF.getHeader()->e_machine) { + case ELF::EM_386: + return "ELF64-i386"; + case ELF::EM_X86_64: + return "ELF64-x86-64"; + case ELF::EM_AARCH64: + return "ELF64-aarch64"; + case ELF::EM_PPC64: + return "ELF64-ppc64"; + case ELF::EM_S390: + return "ELF64-s390"; + default: + return "ELF64-unknown"; + } + default: + // FIXME: Proper error handling. + report_fatal_error("Invalid ELFCLASS!"); + } +} + +template +unsigned ELFObjectFile::getArch() const { + switch (EF.getHeader()->e_machine) { + case ELF::EM_386: + return Triple::x86; + case ELF::EM_X86_64: + return Triple::x86_64; + case ELF::EM_AARCH64: + return Triple::aarch64; + case ELF::EM_ARM: + return Triple::arm; + case ELF::EM_HEXAGON: + return Triple::hexagon; + case ELF::EM_MIPS: + return (ELFT::TargetEndianness == support::little) ? Triple::mipsel + : Triple::mips; + case ELF::EM_PPC64: + return (ELFT::TargetEndianness == support::little) ? Triple::ppc64le + : Triple::ppc64; + case ELF::EM_S390: + return Triple::systemz; + default: + return Triple::UnknownArch; + } +} + +/// FIXME: Maybe we should have a base ElfObjectFile that is not a template +/// and make these member functions? +static inline error_code getELFRelocationAddend(const RelocationRef R, + int64_t &Addend) { + const ObjectFile *Obj = R.getObjectFile(); + DataRefImpl DRI = R.getRawDataRefImpl(); + // Little-endian 32-bit + if (const ELF32LEObjectFile *ELFObj = dyn_cast(Obj)) + return ELFObj->getRelocationAddend(DRI, Addend); + + // Big-endian 32-bit + if (const ELF32BEObjectFile *ELFObj = dyn_cast(Obj)) + return ELFObj->getRelocationAddend(DRI, Addend); + + // Little-endian 64-bit + if (const ELF64LEObjectFile *ELFObj = dyn_cast(Obj)) + return ELFObj->getRelocationAddend(DRI, Addend); + + // Big-endian 64-bit + if (const ELF64BEObjectFile *ELFObj = dyn_cast(Obj)) + return ELFObj->getRelocationAddend(DRI, Addend); + + llvm_unreachable("Object passed to getELFRelocationAddend() is not ELF"); +} + +/// This is a generic interface for retrieving GNU symbol version +/// information from an ELFObjectFile. +static inline error_code GetELFSymbolVersion(const ObjectFile *Obj, + const SymbolRef &Sym, + StringRef &Version, + bool &IsDefault) { + // Little-endian 32-bit + if (const ELF32LEObjectFile *ELFObj = dyn_cast(Obj)) + return ELFObj->getSymbolVersion(Sym, Version, IsDefault); + + // Big-endian 32-bit + if (const ELF32BEObjectFile *ELFObj = dyn_cast(Obj)) + return ELFObj->getSymbolVersion(Sym, Version, IsDefault); + + // Little-endian 64-bit + if (const ELF64LEObjectFile *ELFObj = dyn_cast(Obj)) + return ELFObj->getSymbolVersion(Sym, Version, IsDefault); + + // Big-endian 64-bit + if (const ELF64BEObjectFile *ELFObj = dyn_cast(Obj)) + return ELFObj->getSymbolVersion(Sym, Version, IsDefault); + + llvm_unreachable("Object passed to GetELFSymbolVersion() is not ELF"); +} +} +} + +#endif diff --git a/include/llvm/Object/ELFTypes.h b/include/llvm/Object/ELFTypes.h new file mode 100644 index 0000000..84b6031 --- /dev/null +++ b/include/llvm/Object/ELFTypes.h @@ -0,0 +1,463 @@ +//===- ELFTypes.h - Endian specific types for ELF ---------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_OBJECT_ELF_TYPES_H +#define LLVM_OBJECT_ELF_TYPES_H + +#include "llvm/Support/AlignOf.h" +#include "llvm/Support/DataTypes.h" +#include "llvm/Support/ELF.h" +#include "llvm/Support/Endian.h" + +namespace llvm { +namespace object { + +using support::endianness; + +template +struct ELFType { + static const endianness TargetEndianness = target_endianness; + static const std::size_t MaxAlignment = max_alignment; + static const bool Is64Bits = is64Bits; +}; + +template struct MaximumAlignment { + enum { value = AlignOf::Alignment > max_align ? max_align + : AlignOf::Alignment + }; +}; + +// Templates to choose Elf_Addr and Elf_Off depending on is64Bits. +template +struct ELFDataTypeTypedefHelperCommon { + typedef support::detail::packed_endian_specific_integral< + uint16_t, target_endianness, + MaximumAlignment::value> Elf_Half; + typedef support::detail::packed_endian_specific_integral< + uint32_t, target_endianness, + MaximumAlignment::value> Elf_Word; + typedef support::detail::packed_endian_specific_integral< + int32_t, target_endianness, + MaximumAlignment::value> Elf_Sword; + typedef support::detail::packed_endian_specific_integral< + uint64_t, target_endianness, + MaximumAlignment::value> Elf_Xword; + typedef support::detail::packed_endian_specific_integral< + int64_t, target_endianness, + MaximumAlignment::value> Elf_Sxword; +}; + +template struct ELFDataTypeTypedefHelper; + +/// ELF 32bit types. +template +struct ELFDataTypeTypedefHelper > + : ELFDataTypeTypedefHelperCommon { + typedef uint32_t value_type; + typedef support::detail::packed_endian_specific_integral< + value_type, TargetEndianness, + MaximumAlignment::value> Elf_Addr; + typedef support::detail::packed_endian_specific_integral< + value_type, TargetEndianness, + MaximumAlignment::value> Elf_Off; +}; + +/// ELF 64bit types. +template +struct ELFDataTypeTypedefHelper > + : ELFDataTypeTypedefHelperCommon { + typedef uint64_t value_type; + typedef support::detail::packed_endian_specific_integral< + value_type, TargetEndianness, + MaximumAlignment::value> Elf_Addr; + typedef support::detail::packed_endian_specific_integral< + value_type, TargetEndianness, + MaximumAlignment::value> Elf_Off; +}; + +// I really don't like doing this, but the alternative is copypasta. +#define LLVM_ELF_IMPORT_TYPES(E, M, W) \ +typedef typename ELFDataTypeTypedefHelper >::Elf_Addr \ + Elf_Addr; \ +typedef typename ELFDataTypeTypedefHelper >::Elf_Off \ + Elf_Off; \ +typedef typename ELFDataTypeTypedefHelper >::Elf_Half \ + Elf_Half; \ +typedef typename ELFDataTypeTypedefHelper >::Elf_Word \ + Elf_Word; \ +typedef typename ELFDataTypeTypedefHelper >::Elf_Sword \ + Elf_Sword; \ +typedef typename ELFDataTypeTypedefHelper >::Elf_Xword \ + Elf_Xword; \ +typedef typename ELFDataTypeTypedefHelper >::Elf_Sxword \ + Elf_Sxword; + +#define LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) \ + LLVM_ELF_IMPORT_TYPES(ELFT::TargetEndianness, ELFT::MaxAlignment, \ + ELFT::Is64Bits) + +// Section header. +template struct Elf_Shdr_Base; + +template +struct Elf_Shdr_Base > { + LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, false) + Elf_Word sh_name; // Section name (index into string table) + Elf_Word sh_type; // Section type (SHT_*) + Elf_Word sh_flags; // Section flags (SHF_*) + Elf_Addr sh_addr; // Address where section is to be loaded + Elf_Off sh_offset; // File offset of section data, in bytes + Elf_Word sh_size; // Size of section, in bytes + Elf_Word sh_link; // Section type-specific header table index link + Elf_Word sh_info; // Section type-specific extra information + Elf_Word sh_addralign; // Section address alignment + Elf_Word sh_entsize; // Size of records contained within the section +}; + +template +struct Elf_Shdr_Base > { + LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, true) + Elf_Word sh_name; // Section name (index into string table) + Elf_Word sh_type; // Section type (SHT_*) + Elf_Xword sh_flags; // Section flags (SHF_*) + Elf_Addr sh_addr; // Address where section is to be loaded + Elf_Off sh_offset; // File offset of section data, in bytes + Elf_Xword sh_size; // Size of section, in bytes + Elf_Word sh_link; // Section type-specific header table index link + Elf_Word sh_info; // Section type-specific extra information + Elf_Xword sh_addralign; // Section address alignment + Elf_Xword sh_entsize; // Size of records contained within the section +}; + +template +struct Elf_Shdr_Impl : Elf_Shdr_Base { + using Elf_Shdr_Base::sh_entsize; + using Elf_Shdr_Base::sh_size; + + /// @brief Get the number of entities this section contains if it has any. + unsigned getEntityCount() const { + if (sh_entsize == 0) + return 0; + return sh_size / sh_entsize; + } +}; + +template struct Elf_Sym_Base; + +template +struct Elf_Sym_Base > { + LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, false) + Elf_Word st_name; // Symbol name (index into string table) + Elf_Addr st_value; // Value or address associated with the symbol + Elf_Word st_size; // Size of the symbol + unsigned char st_info; // Symbol's type and binding attributes + unsigned char st_other; // Must be zero; reserved + Elf_Half st_shndx; // Which section (header table index) it's defined in +}; + +template +struct Elf_Sym_Base > { + LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, true) + Elf_Word st_name; // Symbol name (index into string table) + unsigned char st_info; // Symbol's type and binding attributes + unsigned char st_other; // Must be zero; reserved + Elf_Half st_shndx; // Which section (header table index) it's defined in + Elf_Addr st_value; // Value or address associated with the symbol + Elf_Xword st_size; // Size of the symbol +}; + +template +struct Elf_Sym_Impl : Elf_Sym_Base { + using Elf_Sym_Base::st_info; + + // These accessors and mutators correspond to the ELF32_ST_BIND, + // ELF32_ST_TYPE, and ELF32_ST_INFO macros defined in the ELF specification: + unsigned char getBinding() const { return st_info >> 4; } + unsigned char getType() const { return st_info & 0x0f; } + void setBinding(unsigned char b) { setBindingAndType(b, getType()); } + void setType(unsigned char t) { setBindingAndType(getBinding(), t); } + void setBindingAndType(unsigned char b, unsigned char t) { + st_info = (b << 4) + (t & 0x0f); + } +}; + +/// Elf_Versym: This is the structure of entries in the SHT_GNU_versym section +/// (.gnu.version). This structure is identical for ELF32 and ELF64. +template +struct Elf_Versym_Impl { + LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) + Elf_Half vs_index; // Version index with flags (e.g. VERSYM_HIDDEN) +}; + +template struct Elf_Verdaux_Impl; + +/// Elf_Verdef: This is the structure of entries in the SHT_GNU_verdef section +/// (.gnu.version_d). This structure is identical for ELF32 and ELF64. +template +struct Elf_Verdef_Impl { + LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) + typedef Elf_Verdaux_Impl Elf_Verdaux; + Elf_Half vd_version; // Version of this structure (e.g. VER_DEF_CURRENT) + Elf_Half vd_flags; // Bitwise flags (VER_DEF_*) + Elf_Half vd_ndx; // Version index, used in .gnu.version entries + Elf_Half vd_cnt; // Number of Verdaux entries + Elf_Word vd_hash; // Hash of name + Elf_Word vd_aux; // Offset to the first Verdaux entry (in bytes) + Elf_Word vd_next; // Offset to the next Verdef entry (in bytes) + + /// Get the first Verdaux entry for this Verdef. + const Elf_Verdaux *getAux() const { + return reinterpret_cast((const char *)this + vd_aux); + } +}; + +/// Elf_Verdaux: This is the structure of auxiliary data in the SHT_GNU_verdef +/// section (.gnu.version_d). This structure is identical for ELF32 and ELF64. +template +struct Elf_Verdaux_Impl { + LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) + Elf_Word vda_name; // Version name (offset in string table) + Elf_Word vda_next; // Offset to next Verdaux entry (in bytes) +}; + +/// Elf_Verneed: This is the structure of entries in the SHT_GNU_verneed +/// section (.gnu.version_r). This structure is identical for ELF32 and ELF64. +template +struct Elf_Verneed_Impl { + LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) + Elf_Half vn_version; // Version of this structure (e.g. VER_NEED_CURRENT) + Elf_Half vn_cnt; // Number of associated Vernaux entries + Elf_Word vn_file; // Library name (string table offset) + Elf_Word vn_aux; // Offset to first Vernaux entry (in bytes) + Elf_Word vn_next; // Offset to next Verneed entry (in bytes) +}; + +/// Elf_Vernaux: This is the structure of auxiliary data in SHT_GNU_verneed +/// section (.gnu.version_r). This structure is identical for ELF32 and ELF64. +template +struct Elf_Vernaux_Impl { + LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) + Elf_Word vna_hash; // Hash of dependency name + Elf_Half vna_flags; // Bitwise Flags (VER_FLAG_*) + Elf_Half vna_other; // Version index, used in .gnu.version entries + Elf_Word vna_name; // Dependency name + Elf_Word vna_next; // Offset to next Vernaux entry (in bytes) +}; + +/// Elf_Dyn_Base: This structure matches the form of entries in the dynamic +/// table section (.dynamic) look like. +template struct Elf_Dyn_Base; + +template +struct Elf_Dyn_Base > { + LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, false) + Elf_Sword d_tag; + union { + Elf_Word d_val; + Elf_Addr d_ptr; + } d_un; +}; + +template +struct Elf_Dyn_Base > { + LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, true) + Elf_Sxword d_tag; + union { + Elf_Xword d_val; + Elf_Addr d_ptr; + } d_un; +}; + +/// Elf_Dyn_Impl: This inherits from Elf_Dyn_Base, adding getters and setters. +template +struct Elf_Dyn_Impl : Elf_Dyn_Base { + using Elf_Dyn_Base::d_tag; + using Elf_Dyn_Base::d_un; + int64_t getTag() const { return d_tag; } + uint64_t getVal() const { return d_un.d_val; } + uint64_t getPtr() const { return d_un.ptr; } +}; + +// Elf_Rel: Elf Relocation +template struct Elf_Rel_Base; + +template +struct Elf_Rel_Base, false> { + LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, false) + Elf_Addr r_offset; // Location (file byte offset, or program virtual addr) + Elf_Word r_info; // Symbol table index and type of relocation to apply + + uint32_t getRInfo(bool isMips64EL) const { + assert(!isMips64EL); + return r_info; + } + void setRInfo(uint32_t R) { r_info = R; } +}; + +template +struct Elf_Rel_Base, false> { + LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, true) + Elf_Addr r_offset; // Location (file byte offset, or program virtual addr) + Elf_Xword r_info; // Symbol table index and type of relocation to apply + + uint64_t getRInfo(bool isMips64EL) const { + uint64_t t = r_info; + if (!isMips64EL) + return t; + // Mips64 little endian has a "special" encoding of r_info. Instead of one + // 64 bit little endian number, it is a little endian 32 bit number followed + // by a 32 bit big endian number. + return (t << 32) | ((t >> 8) & 0xff000000) | ((t >> 24) & 0x00ff0000) | + ((t >> 40) & 0x0000ff00) | ((t >> 56) & 0x000000ff); + } + void setRInfo(uint64_t R) { + // FIXME: Add mips64el support. + r_info = R; + } +}; + +template +struct Elf_Rel_Base, true> { + LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, false) + Elf_Addr r_offset; // Location (file byte offset, or program virtual addr) + Elf_Word r_info; // Symbol table index and type of relocation to apply + Elf_Sword r_addend; // Compute value for relocatable field by adding this + + uint32_t getRInfo(bool isMips64EL) const { + assert(!isMips64EL); + return r_info; + } + void setRInfo(uint32_t R) { r_info = R; } +}; + +template +struct Elf_Rel_Base, true> { + LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, true) + Elf_Addr r_offset; // Location (file byte offset, or program virtual addr) + Elf_Xword r_info; // Symbol table index and type of relocation to apply + Elf_Sxword r_addend; // Compute value for relocatable field by adding this. + + uint64_t getRInfo(bool isMips64EL) const { + // Mips64 little endian has a "special" encoding of r_info. Instead of one + // 64 bit little endian number, it is a little endian 32 bit number followed + // by a 32 bit big endian number. + uint64_t t = r_info; + if (!isMips64EL) + return t; + return (t << 32) | ((t >> 8) & 0xff000000) | ((t >> 24) & 0x00ff0000) | + ((t >> 40) & 0x0000ff00) | ((t >> 56) & 0x000000ff); + } + void setRInfo(uint64_t R) { + // FIXME: Add mips64el support. + r_info = R; + } +}; + +template struct Elf_Rel_Impl; + +template +struct Elf_Rel_Impl, + isRela> : Elf_Rel_Base< + ELFType, isRela> { + LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, true) + + // These accessors and mutators correspond to the ELF64_R_SYM, ELF64_R_TYPE, + // and ELF64_R_INFO macros defined in the ELF specification: + uint32_t getSymbol(bool isMips64EL) const { + return (uint32_t)(this->getRInfo(isMips64EL) >> 32); + } + uint32_t getType(bool isMips64EL) const { + return (uint32_t)(this->getRInfo(isMips64EL) & 0xffffffffL); + } + void setSymbol(uint32_t s) { setSymbolAndType(s, getType()); } + void setType(uint32_t t) { setSymbolAndType(getSymbol(), t); } + void setSymbolAndType(uint32_t s, uint32_t t) { + this->setRInfo(((uint64_t)s << 32) + (t & 0xffffffffL)); + } +}; + +template +struct Elf_Rel_Impl, + isRela> : Elf_Rel_Base< + ELFType, isRela> { + LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, false) + + // These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE, + // and ELF32_R_INFO macros defined in the ELF specification: + uint32_t getSymbol(bool isMips64EL) const { + return this->getRInfo(isMips64EL) >> 8; + } + unsigned char getType(bool isMips64EL) const { + return (unsigned char)(this->getRInfo(isMips64EL) & 0x0ff); + } + void setSymbol(uint32_t s) { setSymbolAndType(s, getType()); } + void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); } + void setSymbolAndType(uint32_t s, unsigned char t) { + this->setRInfo((s << 8) + t); + } +}; + +template +struct Elf_Ehdr_Impl { + LLVM_ELF_IMPORT_TYPES_ELFT(ELFT) + unsigned char e_ident[ELF::EI_NIDENT]; // ELF Identification bytes + Elf_Half e_type; // Type of file (see ET_*) + Elf_Half e_machine; // Required architecture for this file (see EM_*) + Elf_Word e_version; // Must be equal to 1 + Elf_Addr e_entry; // Address to jump to in order to start program + Elf_Off e_phoff; // Program header table's file offset, in bytes + Elf_Off e_shoff; // Section header table's file offset, in bytes + Elf_Word e_flags; // Processor-specific flags + Elf_Half e_ehsize; // Size of ELF header, in bytes + Elf_Half e_phentsize; // Size of an entry in the program header table + Elf_Half e_phnum; // Number of entries in the program header table + Elf_Half e_shentsize; // Size of an entry in the section header table + Elf_Half e_shnum; // Number of entries in the section header table + Elf_Half e_shstrndx; // Section header table index of section name + // string table + bool checkMagic() const { + return (memcmp(e_ident, ELF::ElfMagic, strlen(ELF::ElfMagic))) == 0; + } + unsigned char getFileClass() const { return e_ident[ELF::EI_CLASS]; } + unsigned char getDataEncoding() const { return e_ident[ELF::EI_DATA]; } +}; + +template struct Elf_Phdr_Impl; + +template +struct Elf_Phdr_Impl > { + LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, false) + Elf_Word p_type; // Type of segment + Elf_Off p_offset; // FileOffset where segment is located, in bytes + Elf_Addr p_vaddr; // Virtual Address of beginning of segment + Elf_Addr p_paddr; // Physical address of beginning of segment (OS-specific) + Elf_Word p_filesz; // Num. of bytes in file image of segment (may be zero) + Elf_Word p_memsz; // Num. of bytes in mem image of segment (may be zero) + Elf_Word p_flags; // Segment flags + Elf_Word p_align; // Segment alignment constraint +}; + +template +struct Elf_Phdr_Impl > { + LLVM_ELF_IMPORT_TYPES(TargetEndianness, MaxAlign, true) + Elf_Word p_type; // Type of segment + Elf_Word p_flags; // Segment flags + Elf_Off p_offset; // FileOffset where segment is located, in bytes + Elf_Addr p_vaddr; // Virtual Address of beginning of segment + Elf_Addr p_paddr; // Physical address of beginning of segment (OS-specific) + Elf_Xword p_filesz; // Num. of bytes in file image of segment (may be zero) + Elf_Xword p_memsz; // Num. of bytes in mem image of segment (may be zero) + Elf_Xword p_align; // Segment alignment constraint +}; + +} // end namespace object. +} // end namespace llvm. + +#endif diff --git a/include/llvm/Object/RelocVisitor.h b/include/llvm/Object/RelocVisitor.h index b1eb4e6..97912fe 100644 --- a/include/llvm/Object/RelocVisitor.h +++ b/include/llvm/Object/RelocVisitor.h @@ -18,7 +18,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Object/ObjectFile.h" -#include "llvm/Object/ELF.h" +#include "llvm/Object/ELFObjectFile.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ELF.h" #include "llvm/Support/raw_ostream.h" -- cgit v1.1 From 68554401fca3770583d21b8505553e914f9ee307 Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Thu, 8 Aug 2013 22:50:40 +0000 Subject: llvm isn't C++11 yet :( git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188023 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELF.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 8afbd45..39a8c98 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -249,7 +249,7 @@ private: /// \brief Represents a region described by entries in the .dynamic table. struct DynRegionInfo { - DynRegionInfo() : Addr(nullptr), Size(0), EntSize(0) {} + DynRegionInfo() : Addr(0), Size(0), EntSize(0) {} /// \brief Address in current address space. const void *Addr; /// \brief Size in bytes of the region. -- cgit v1.1 From 1c9cd021c8999d9c2c0786dff074d1e75bbd0eb2 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Fri, 9 Aug 2013 01:52:03 +0000 Subject: [CodeGen] prevent abnormal on invalid attributes Currently, when an invalid attribute is encountered on processing a .s file, clang will abort due to llvm_unreachable. Invalid user input should not cause an abnormal termination of the compiler. Change the interface to return a boolean to indicate the failure as a first step towards improving hanlding of malformed user input to clang. Signed-off-by: Saleem Abdulrasool git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188047 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCELFStreamer.h | 2 +- include/llvm/MC/MCStreamer.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCELFStreamer.h b/include/llvm/MC/MCELFStreamer.h index 7565c15..bff0cba 100644 --- a/include/llvm/MC/MCELFStreamer.h +++ b/include/llvm/MC/MCELFStreamer.h @@ -57,7 +57,7 @@ public: virtual void EmitAssemblerFlag(MCAssemblerFlag Flag); virtual void EmitThumbFunc(MCSymbol *Func); virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol); - virtual void EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute); + virtual bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute); virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue); virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, unsigned ByteAlignment); diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 970c4ed..96b32cd 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -323,7 +323,7 @@ namespace llvm { virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) = 0; /// EmitSymbolAttribute - Add the given @p Attribute to @p Symbol. - virtual void EmitSymbolAttribute(MCSymbol *Symbol, + virtual bool EmitSymbolAttribute(MCSymbol *Symbol, MCSymbolAttr Attribute) = 0; /// EmitSymbolDesc - Set the @p DescValue for the @p Symbol. -- cgit v1.1 From 1b8ac539825d10b38d12759a862f43f7b40ddd9a Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Fri, 9 Aug 2013 07:34:06 +0000 Subject: Try to unbreak Windows build after r188022 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188057 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELF.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 39a8c98..a6774c1 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -565,7 +565,7 @@ std::pair::Elf_Shdr *, const typename ELFFile::Elf_Sym *> ELFFile::getRelocationSymbol(const Elf_Shdr *Sec, const RelT *Rel) const { if (!Sec->sh_link) - return std::pair(0, 0); + return std::make_pair((const Elf_Shdr *)0, (const Elf_Sym *)0); const Elf_Shdr *SymTable = getSection(Sec->sh_link); return std::make_pair( SymTable, getEntry(SymTable, Rel->getSymbol(isMips64EL()))); -- cgit v1.1 From 6c2dc9e66eeec5d39b2e6e53d18a023a5fa0af54 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Fri, 9 Aug 2013 16:48:21 +0000 Subject: ELFObjectFile.h: Silence warning on Windows The compiler was warning about using | on a uintptr_t and bool: Object/ELFObjectFile.h(131) : warning C4805: '|' : unsafe mix of type 'uintptr_t' and type 'bool' in operation I think the warning might be useful in other cases, so I added a cast instead of disabling it altogether. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188079 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELFObjectFile.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index f0be8ab..08cac04 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -128,7 +128,8 @@ protected: // ELF specific protected members. DataRefImpl toDRI(Elf_Sym_Iter Symb) const { DataRefImpl DRI; - DRI.p = reinterpret_cast(Symb.get()) | Symb.isDynamic(); + DRI.p = reinterpret_cast(Symb.get()) | + static_cast(Symb.isDynamic()); return DRI; } -- cgit v1.1 From 5752b08aef30386cc6720b59f1103e770ae4eb9c Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 9 Aug 2013 17:03:39 +0000 Subject: Make directory iterator sentinels free. This trades some complexity in operator== for not introducing static objects into any functions using recursive directory iterators. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188081 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/FileSystem.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/FileSystem.h b/include/llvm/Support/FileSystem.h index c130b47..fb0eaeb 100644 --- a/include/llvm/Support/FileSystem.h +++ b/include/llvm/Support/FileSystem.h @@ -869,7 +869,7 @@ public: } /// Construct end iterator. - directory_iterator() : State(new detail::DirIterState) {} + directory_iterator() : State(0) {} // No operator++ because we need error_code. directory_iterator &increment(error_code &ec) { @@ -881,6 +881,12 @@ public: const directory_entry *operator->() const { return &State->CurrentEntry; } bool operator==(const directory_iterator &RHS) const { + if (State == RHS.State) + return true; + if (RHS.State == 0) + return State->CurrentEntry == directory_entry(); + if (State == 0) + return RHS.State->CurrentEntry == directory_entry(); return State->CurrentEntry == RHS.State->CurrentEntry; } @@ -920,7 +926,7 @@ public: } // No operator++ because we need error_code. recursive_directory_iterator &increment(error_code &ec) { - static const directory_iterator end_itr; + const directory_iterator end_itr; if (State->HasNoPushRequest) State->HasNoPushRequest = false; @@ -967,7 +973,7 @@ public: assert(State && "Cannot pop and end itertor!"); assert(State->Level > 0 && "Cannot pop an iterator with level < 1"); - static const directory_iterator end_itr; + const directory_iterator end_itr; error_code ec; do { if (ec) -- cgit v1.1 From 8328b6932ffeb41af7fc1260a48d36cf2a427f6f Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 9 Aug 2013 17:17:12 +0000 Subject: DebugInfo: provide the ability to add members to a class after it has been constructed This is necessary to allow Clang to only emit implicit members when there is code generated for them, rather than whenever they are ODR used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188082 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 74416db..b02446a 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -323,6 +323,7 @@ namespace llvm { DIArray getTypeArray() const { return getFieldAs(10); } void setTypeArray(DIArray Elements, DIArray TParams = DIArray()); + void addMember(DISubprogram S); unsigned getRunTimeLang() const { return getUnsignedField(11); } DICompositeType getContainingType() const { return getFieldAs(12); -- cgit v1.1 From fc6434a73d053c3e1d9c79034a267ae1434483ad Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 9 Aug 2013 19:33:32 +0000 Subject: Add a overload to CostTable which allows it to infer the size of the table. Use it to avoid repeating ourselves too often. Also store MVT::SimpleValueType in the TTI tables so they can be statically initialized, MVT's constructors create bloated initialization code otherwise. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188095 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/CostTable.h | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/llvm/Target/CostTable.h b/include/llvm/Target/CostTable.h index a974b56..34f6041 100644 --- a/include/llvm/Target/CostTable.h +++ b/include/llvm/Target/CostTable.h @@ -25,18 +25,25 @@ struct CostTblEntry { unsigned Cost; }; -/// Find in cost table, TypeTy must be comparable by == -template -int CostTableLookup(const CostTblEntry *Tbl, - unsigned len, int ISD, TypeTy Ty) { +/// Find in cost table, TypeTy must be comparable to CompareTy by == +template +int CostTableLookup(const CostTblEntry *Tbl, unsigned len, int ISD, + CompareTy Ty) { for (unsigned int i = 0; i < len; ++i) - if (Tbl[i].ISD == ISD && Tbl[i].Type == Ty) + if (ISD == Tbl[i].ISD && Ty == Tbl[i].Type) return i; // Could not find an entry. return -1; } +/// Find in cost table, TypeTy must be comparable to CompareTy by == +template +int CostTableLookup(const CostTblEntry(&Tbl)[N], int ISD, + CompareTy Ty) { + return CostTableLookup(Tbl, N, ISD, Ty); +} + /// Type Conversion Cost Table template struct TypeConversionCostTblEntry { @@ -46,18 +53,28 @@ struct TypeConversionCostTblEntry { unsigned Cost; }; -/// Find in type conversion cost table, TypeTy must be comparable by == -template +/// Find in type conversion cost table, TypeTy must be comparable to CompareTy +/// by == +template int ConvertCostTableLookup(const TypeConversionCostTblEntry *Tbl, - unsigned len, int ISD, TypeTy Dst, TypeTy Src) { + unsigned len, int ISD, CompareTy Dst, + CompareTy Src) { for (unsigned int i = 0; i < len; ++i) - if (Tbl[i].ISD == ISD && Tbl[i].Src == Src && Tbl[i].Dst == Dst) + if (ISD == Tbl[i].ISD && Src == Tbl[i].Src && Dst == Tbl[i].Dst) return i; // Could not find an entry. return -1; } +/// Find in type conversion cost table, TypeTy must be comparable to CompareTy +/// by == +template +int ConvertCostTableLookup(const TypeConversionCostTblEntry(&Tbl)[N], + int ISD, CompareTy Dst, CompareTy Src) { + return ConvertCostTableLookup(Tbl, N, ISD, Dst, Src); +} + } // namespace llvm -- cgit v1.1 From d976d43f23d67e18f097d72fd90923627f334c79 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Mon, 12 Aug 2013 07:49:36 +0000 Subject: Introduce factory methods for SpecialCaseList Summary: Doing work in constructors is bad: this change suggests to call SpecialCaseList::create(Path, Error) instead of "new SpecialCaseList(Path)". Currently the latter may crash with report_fatal_error, which is undesirable - sometimes we want to report the error to user gracefully - for example, if he provides an incorrect file as an argument of Clang's -fsanitize-blacklist flag. Reviewers: pcc Reviewed By: pcc CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1327 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188156 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/Utils/SpecialCaseList.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Transforms/Utils/SpecialCaseList.h b/include/llvm/Transforms/Utils/SpecialCaseList.h index 787ddb0..36ee604 100644 --- a/include/llvm/Transforms/Utils/SpecialCaseList.h +++ b/include/llvm/Transforms/Utils/SpecialCaseList.h @@ -57,8 +57,18 @@ class StringRef; class SpecialCaseList { public: + // FIXME: Switch all users to factories and remove these constructors. SpecialCaseList(const StringRef Path); SpecialCaseList(const MemoryBuffer *MB); + + /// 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); + /// 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); + ~SpecialCaseList(); /// Returns whether either this function or its source file are listed in the @@ -89,10 +99,16 @@ class SpecialCaseList { bool findCategory(const Module &M, StringRef &Category) const; private: + SpecialCaseList(SpecialCaseList const &) LLVM_DELETED_FUNCTION; + SpecialCaseList &operator=(SpecialCaseList const &) LLVM_DELETED_FUNCTION; + struct Entry; StringMap > Entries; - void init(const MemoryBuffer *MB); + SpecialCaseList(); + /// Parses just-constructed SpecialCaseList entries from a memory buffer. + bool parse(const MemoryBuffer *MB, std::string &Error); + bool findCategory(const StringRef Section, const StringRef Query, StringRef &Category) const; bool inSectionCategory(const StringRef Section, const StringRef Query, -- cgit v1.1 From 8d8bdff6d7eccb05bf16e18141263ee72ea8296b Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 12 Aug 2013 09:49:17 +0000 Subject: Target a minimal terminfo library rather than necessarily a full curses library for color support detection. This still will use a curses library if that is all we have available on the system. This change tries to use a smaller subset of the curses library, specifically the subset that is on some systems split off into a separate library. For example, if you install ncurses configured --with-tinfo, a 'libtinfo' is install that provides just the terminfo querying functionality. That library is now used instead of curses when it is available. This happens to fix a build error on systems with that library because when we tried to link ncurses into the binary, we didn't pull tinfo in as well. =] It should also provide an easy path for supporting the NetBSD libterminfo library, but as I don't have access to a NetBSD system I'm leaving adding that support to those folks. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188160 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Config/config.h.cmake | 9 ++++++--- include/llvm/Config/config.h.in | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake index 4b0aa4b..5090a65 100644 --- a/include/llvm/Config/config.h.cmake +++ b/include/llvm/Config/config.h.cmake @@ -48,9 +48,6 @@ /* Define to 1 if you have the `closedir' function. */ #cmakedefine HAVE_CLOSEDIR ${HAVE_CLOSEDIR} -/* Define if curses provides the has_color() function on this platform. */ -#cmakedefine HAVE_CURSES - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_CURSES_H @@ -420,9 +417,15 @@ /* Define to 1 if you have that is POSIX.1 compatible. */ #cmakedefine HAVE_SYS_WAIT_H ${HAVE_SYS_WAIT_H} +/* Define if the setupterm() function is supported this platform. */ +#cmakedefine HAVE_TERMINFO ${HAVE_TERMINFO} + /* Define to 1 if you have the header file. */ #cmakedefine HAVE_TERMIOS_H ${HAVE_TERMIOS_H} +/* Define to 1 if you have the header file. */ +#cmakedefine HAVE_TERM_H + /* Define if the neat program is available */ #cmakedefine HAVE_TWOPI ${HAVE_TWOPI} diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in index 7bb1caa..55c66cc 100644 --- a/include/llvm/Config/config.h.in +++ b/include/llvm/Config/config.h.in @@ -69,9 +69,6 @@ /* can use __crashreporter_info__ */ #undef HAVE_CRASHREPORTER_INFO -/* Define if curses provides the has_color() function on this platform. */ -#undef HAVE_CURSES - /* Define to 1 if you have the header file. */ #undef HAVE_CURSES_H @@ -455,9 +452,15 @@ /* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H +/* Define if the setupterm() function is supported this platform. */ +#undef HAVE_TERMINFO + /* Define to 1 if you have the header file. */ #undef HAVE_TERMIOS_H +/* Define to 1 if you have the header file. */ +#undef HAVE_TERM_H + /* Define if the neat program is available */ #undef HAVE_TWOPI -- cgit v1.1 From ac168b8bc8773a083a10902f64e4ae57a925aee4 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Mon, 12 Aug 2013 10:28:10 +0000 Subject: [SystemZ] Use CLC and IPM to implement memcmp For now this is restricted to fixed-length comparisons with a length in the range [1, 256], as for memcpy() and MVC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188163 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetSelectionDAGInfo.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/llvm/Target/TargetSelectionDAGInfo.h b/include/llvm/Target/TargetSelectionDAGInfo.h index fe2fba4..35da1d7 100644 --- a/include/llvm/Target/TargetSelectionDAGInfo.h +++ b/include/llvm/Target/TargetSelectionDAGInfo.h @@ -94,6 +94,20 @@ public: MachinePointerInfo DstPtrInfo) const { return SDValue(); } + + /// EmitTargetCodeForMemcmp - Emit target-specific code that performs a + /// memcmp, in cases where that is faster than a libcall. The first + /// returned SDValue is the result of the memcmp and the second is + /// the chain. Both SDValues can be null if a normal libcall should + /// be used. + virtual std::pair + EmitTargetCodeForMemcmp(SelectionDAG &DAG, SDLoc dl, + SDValue Chain, + SDValue Op1, SDValue Op2, + SDValue Op3, MachinePointerInfo Op1PtrInfo, + MachinePointerInfo Op2PtrInfo) const { + return std::make_pair(SDValue(), SDValue()); + } }; } // end llvm namespace -- cgit v1.1 From 3729d7d62b9973baa60d253fe0463d6d607dd815 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 12 Aug 2013 10:40:11 +0000 Subject: Remove all checking for the various terminfo headers (term.h and curses.h). Finding these headers is next to impossible. For example, on Debian systems libtinfo-dev provides the terminfo reading library we want, but *not* term.h. For the header, you have to use libncurses-dev. And libncursesw-dev provides a *different* term.h in a different location! These headers aren't worth it. We want two functions the signatures of which are clearly spec'ed in sys-v and other documentation. Just declare them ourselves and call them. This should fix some debian builders and provide better support for "minimal" debian systems that do want color autodetection. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188165 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Config/config.h.cmake | 18 ------------------ include/llvm/Config/config.h.in | 18 ------------------ 2 files changed, 36 deletions(-) (limited to 'include') diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake index 5090a65..572fb6f 100644 --- a/include/llvm/Config/config.h.cmake +++ b/include/llvm/Config/config.h.cmake @@ -48,9 +48,6 @@ /* Define to 1 if you have the `closedir' function. */ #cmakedefine HAVE_CLOSEDIR ${HAVE_CLOSEDIR} -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_CURSES_H - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_CXXABI_H ${HAVE_CXXABI_H} @@ -259,18 +256,6 @@ /* Define if mmap() can map files into memory */ #undef HAVE_MMAP_FILE -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NCURSESW_CURSES_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NCURSESW_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NCURSES_CURSES_H - -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_NCURSES_H - /* Define to 1 if you have the header file, and it defines `DIR'. */ #cmakedefine HAVE_NDIR_H ${HAVE_NDIR_H} @@ -423,9 +408,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_TERMIOS_H ${HAVE_TERMIOS_H} -/* Define to 1 if you have the header file. */ -#cmakedefine HAVE_TERM_H - /* Define if the neat program is available */ #cmakedefine HAVE_TWOPI ${HAVE_TWOPI} diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in index 55c66cc..6dc8c6e 100644 --- a/include/llvm/Config/config.h.in +++ b/include/llvm/Config/config.h.in @@ -69,9 +69,6 @@ /* can use __crashreporter_info__ */ #undef HAVE_CRASHREPORTER_INFO -/* Define to 1 if you have the header file. */ -#undef HAVE_CURSES_H - /* Define to 1 if you have the header file. */ #undef HAVE_CXXABI_H @@ -285,18 +282,6 @@ /* Define if mmap() can map files into memory */ #undef HAVE_MMAP_FILE -/* Define to 1 if you have the header file. */ -#undef HAVE_NCURSESW_CURSES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_NCURSESW_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_NCURSES_CURSES_H - -/* Define to 1 if you have the header file. */ -#undef HAVE_NCURSES_H - /* Define to 1 if you have the header file, and it defines `DIR'. */ #undef HAVE_NDIR_H @@ -458,9 +443,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_TERMIOS_H -/* Define to 1 if you have the header file. */ -#undef HAVE_TERM_H - /* Define if the neat program is available */ #undef HAVE_TWOPI -- cgit v1.1 From e39e1316f034e9932cb8da535541a3e35a0e490a Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Mon, 12 Aug 2013 11:46:09 +0000 Subject: Add SpecialCaseList::createOrDie() factory and use it in sanitizer passes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188169 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/Utils/SpecialCaseList.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm/Transforms/Utils/SpecialCaseList.h b/include/llvm/Transforms/Utils/SpecialCaseList.h index 36ee604..34396fd 100644 --- a/include/llvm/Transforms/Utils/SpecialCaseList.h +++ b/include/llvm/Transforms/Utils/SpecialCaseList.h @@ -68,6 +68,9 @@ class SpecialCaseList { /// 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); + /// Parses the special case list from a file. On failure, reports a fatal + /// error. + static SpecialCaseList *createOrDie(const StringRef Path); ~SpecialCaseList(); -- cgit v1.1 From 655abf57edcc9954428ac405905005f82091add5 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Mon, 12 Aug 2013 11:50:44 +0000 Subject: Remove unused SpecialCaseList constructors git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188171 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/Utils/SpecialCaseList.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/llvm/Transforms/Utils/SpecialCaseList.h b/include/llvm/Transforms/Utils/SpecialCaseList.h index 34396fd..bf95ec0 100644 --- a/include/llvm/Transforms/Utils/SpecialCaseList.h +++ b/include/llvm/Transforms/Utils/SpecialCaseList.h @@ -57,10 +57,6 @@ class StringRef; class SpecialCaseList { public: - // FIXME: Switch all users to factories and remove these constructors. - SpecialCaseList(const StringRef Path); - SpecialCaseList(const MemoryBuffer *MB); - /// 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. -- cgit v1.1 From 67d135ae40b121a138e334a175d0e02dbb54eeca Mon Sep 17 00:00:00 2001 From: Shuxin Yang Date: Mon, 12 Aug 2013 18:29:43 +0000 Subject: Misc enhancements to LTO: 1. Add some helper classes for partitions. They are designed in a way such that the top-level LTO driver will not see much difference with or without partitioning. 2. Introduce work-dir. Now all intermediate files generated during LTO phases will be saved under work-dir. User can specify the workdir via -lto-workdir=/path/to/dir. By default the work-dir will be erased before linker exit. To keep the workdir, do -lto-keep, or -lto-keep=1. TODO: Erase the workdir, if the linker exit prematurely. We are currently not able to remove directory on signal. The support routines simply ignore directory. 3. Add one new API lto_codegen_get_files_need_remove(). Linker and LTO plugin will communicate via this API about which files (including directories) need to removed before linker exit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188188 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/lto.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/llvm-c/lto.h b/include/llvm-c/lto.h index 40110fd..a7a942d 100644 --- a/include/llvm-c/lto.h +++ b/include/llvm-c/lto.h @@ -284,6 +284,18 @@ lto_codegen_compile(lto_code_gen_t cg, size_t* length); extern bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char** name); +/** + * Get intermediate files that need to be removed before linker exit. Upon + * return, the paths of the files need to be removed is written to "paths". The + * paths are separated by a single '\0', and the last path is ended by double + * '\0's. A file could be a directory; in this case, the entire directory needs + * to be removed recursively. + * + * It is only necessary to call this function after \p lto_codegen_compile was + * successfully called. + */ +extern void +lto_codegen_get_files_need_remove(lto_code_gen_t cg, const char **paths); /** * Sets options to help debug codegen bugs. -- cgit v1.1 From 2a64a639e5f2870a2a898a593fc37a800f977d5e Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Mon, 12 Aug 2013 18:35:32 +0000 Subject: [stackprotector] Added intrinsic llvm.stackprotectorcheck. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188191 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Intrinsics.td | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/Intrinsics.td b/include/llvm/IR/Intrinsics.td index ffa121d..18f56d2 100644 --- a/include/llvm/IR/Intrinsics.td +++ b/include/llvm/IR/Intrinsics.td @@ -258,6 +258,8 @@ def int_readcyclecounter : Intrinsic<[llvm_i64_ty]>; // Stack Protector Intrinsic - The stackprotector intrinsic writes the stack // guard to the correct place on the stack frame. def int_stackprotector : Intrinsic<[], [llvm_ptr_ty, llvm_ptrptr_ty], []>; +def int_stackprotectorcheck : Intrinsic<[], [llvm_ptrptr_ty], + [IntrReadWriteArgMem]>; //===------------------- Standard C Library Intrinsics --------------------===// // -- cgit v1.1 From 15b2782ccf141930cc98507a1cb1d501fbfd4000 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Mon, 12 Aug 2013 18:45:38 +0000 Subject: [stackprotector] Add in the stackprotector libcall. We support this libcall on all platforms except for OpenBSD (See lib/Codegen/StackProtector.cpp). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188193 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/RuntimeLibcalls.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/RuntimeLibcalls.h b/include/llvm/CodeGen/RuntimeLibcalls.h index e578b50..14769ec 100644 --- a/include/llvm/CodeGen/RuntimeLibcalls.h +++ b/include/llvm/CodeGen/RuntimeLibcalls.h @@ -354,6 +354,9 @@ namespace RTLIB { SYNC_FETCH_AND_NAND_4, SYNC_FETCH_AND_NAND_8, + // Stack Protector Fail. + STACKPROTECTOR_CHECK_FAIL, + UNKNOWN_LIBCALL }; -- cgit v1.1 From cfaa636a1d31f2db71df627e4882e9d5c066c419 Mon Sep 17 00:00:00 2001 From: Shuxin Yang Date: Mon, 12 Aug 2013 21:07:31 +0000 Subject: Revert r188188 and r188200. In order to appease people (in Apple) who accuse me for committing "huge change" (?) without proper review. Thank Eric for fixing a compile-warning. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188204 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/lto.h | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'include') diff --git a/include/llvm-c/lto.h b/include/llvm-c/lto.h index a7a942d..40110fd 100644 --- a/include/llvm-c/lto.h +++ b/include/llvm-c/lto.h @@ -284,18 +284,6 @@ lto_codegen_compile(lto_code_gen_t cg, size_t* length); extern bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char** name); -/** - * Get intermediate files that need to be removed before linker exit. Upon - * return, the paths of the files need to be removed is written to "paths". The - * paths are separated by a single '\0', and the last path is ended by double - * '\0's. A file could be a directory; in this case, the entire directory needs - * to be removed recursively. - * - * It is only necessary to call this function after \p lto_codegen_compile was - * successfully called. - */ -extern void -lto_codegen_get_files_need_remove(lto_code_gen_t cg, const char **paths); /** * Sets options to help debug codegen bugs. -- cgit v1.1 From 93a013c760631e696e6ae3042551c16d4636ade6 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Mon, 12 Aug 2013 21:10:23 +0000 Subject: Add editor C++ filetype declaration no functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188205 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineBranchProbabilityInfo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineBranchProbabilityInfo.h b/include/llvm/CodeGen/MachineBranchProbabilityInfo.h index 98dd03b..c59948f 100644 --- a/include/llvm/CodeGen/MachineBranchProbabilityInfo.h +++ b/include/llvm/CodeGen/MachineBranchProbabilityInfo.h @@ -1,4 +1,4 @@ -//==- MachineBranchProbabilityInfo.h - Machine Branch Probability Analysis -==// +//=- MachineBranchProbabilityInfo.h - Branch Probability Analysis -*- C++ -*-=// // // The LLVM Compiler Infrastructure // -- cgit v1.1 From d3d5e6d8eb8f4bbb26decb582f0730600ed8a53d Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Mon, 12 Aug 2013 22:59:14 +0000 Subject: [Object/ELF] sh_type is not a bitfield. Fixes RuntimeDyld test failure on ARM. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188220 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELFObjectFile.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index 08cac04..f799f7e 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -577,14 +577,14 @@ ELFObjectFile::isSectionRequiredForExecution(DataRefImpl Sec, template error_code ELFObjectFile::isSectionVirtual(DataRefImpl Sec, bool &Result) const { - Result = toELFShdrIter(Sec)->sh_type & ELF::SHT_NOBITS; + Result = toELFShdrIter(Sec)->sh_type == ELF::SHT_NOBITS; return object_error::success; } template error_code ELFObjectFile::isSectionZeroInit(DataRefImpl Sec, bool &Result) const { - Result = toELFShdrIter(Sec)->sh_type & ELF::SHT_NOBITS; + Result = toELFShdrIter(Sec)->sh_type == ELF::SHT_NOBITS; return object_error::success; } -- cgit v1.1 From 72dba254ae65b06062106910a70d46f21e19d55a Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 13 Aug 2013 00:03:47 +0000 Subject: Fix an oversight in isPotentiallyReachable where we wouldn't do any CFG-walking to find loops if the From and To instructions were in the same block. Refactor the code a little now that we need to fill to start the CFG-walking algorithm with more than one starting basic block sometimes. Special thanks to Andrew Trick for catching an error in my understanding of natural loops in code review. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188236 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/CFG.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/llvm/Analysis/CFG.h b/include/llvm/Analysis/CFG.h index 08fdc26..979926b 100644 --- a/include/llvm/Analysis/CFG.h +++ b/include/llvm/Analysis/CFG.h @@ -49,6 +49,9 @@ unsigned GetSuccessorNumber(BasicBlock *BB, BasicBlock *Succ); bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum, bool AllowIdenticalEdges = false); +/// \brief Determine whether instruction 'To' is reachable from 'From', +/// returning true if uncertain. +/// /// Determine whether there is a path from From to To within a single function. /// Returns false only if we can prove that once 'From' has been executed then /// 'To' can not be executed. Conservatively returns true. @@ -64,6 +67,15 @@ bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum, bool isPotentiallyReachable(const Instruction *From, const Instruction *To, DominatorTree *DT = 0, LoopInfo *LI = 0); +/// \brief Determine whether block 'To' is reachable from 'From', returning +/// true if uncertain. +/// +/// Determine whether there is a path from From to To within a single function. +/// Returns false only if we can prove that once 'From' has been reached then +/// 'To' can not be executed. Conservatively returns true. +bool isPotentiallyReachable(const BasicBlock *From, const BasicBlock *To, + DominatorTree *DT = 0, LoopInfo *LI = 0); + } // End llvm namespace #endif -- cgit v1.1 From e05a304e5af754e4f8b1f1a35e22ebf35f072995 Mon Sep 17 00:00:00 2001 From: Carlo Kok Date: Tue, 13 Aug 2013 17:45:53 +0000 Subject: For COFF only: dwarf debug info output a label reference as a section relative item only when it's one of dw_from strp, sec_offset, ref_addr or op_call_ref instead of going by size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188296 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/AsmPrinter.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h index 677331b..59d14cc 100644 --- a/include/llvm/CodeGen/AsmPrinter.h +++ b/include/llvm/CodeGen/AsmPrinter.h @@ -359,13 +359,15 @@ namespace llvm { /// where the size in bytes of the directive is specified by Size and Label /// specifies the label. This implicitly uses .set if it is available. void EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset, - unsigned Size) const; + unsigned Size, + bool IsSectionRelative = false) const; /// EmitLabelReference - Emit something like ".long Label" /// where the size in bytes of the directive is specified by Size and Label /// specifies the label. - void EmitLabelReference(const MCSymbol *Label, unsigned Size) const { - EmitLabelPlusOffset(Label, 0, Size); + void EmitLabelReference(const MCSymbol *Label, unsigned Size, + bool IsSectionRelative = false) const { + EmitLabelPlusOffset(Label, 0, Size, IsSectionRelative); } //===------------------------------------------------------------------===// -- cgit v1.1 From 3add0679d24a00c4a585809c6ce54486f6a458f5 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Tue, 13 Aug 2013 17:54:56 +0000 Subject: Update makeLibCall to return both the call and the chain associated with the libcall instead of just the call. This allows us to specify libcalls that return void. LowerCallTo returns a pair with the return value of the call as the first element and the chain associated with the return value as the second element. If we lower a call that has a void return value, LowerCallTo returns an SDValue with a NULL SDNode and the chain for the call. Thus makeLibCall by just returning the first value makes it impossible for you to set up the chain so that the call is not eliminated as dead code. I also updated all references to makeLibCall to reflect the new return type. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188300 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLowering.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index c3fa3cc..580a358 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -1702,9 +1702,12 @@ public: SDValue &NewLHS, SDValue &NewRHS, ISD::CondCode &CCCode, SDLoc DL) const; - SDValue makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, EVT RetVT, - const SDValue *Ops, unsigned NumOps, - bool isSigned, SDLoc dl) const; + /// Returns a pair of (return value, chain). + std::pair makeLibCall(SelectionDAG &DAG, RTLIB::Libcall LC, + EVT RetVT, const SDValue *Ops, + unsigned NumOps, bool isSigned, + SDLoc dl, bool doesNotReturn = false, + bool isReturnValueUsed = true) const; //===--------------------------------------------------------------------===// // TargetLowering Optimization Methods -- cgit v1.1 From af9e3557552c341615052a05d4eeb36d7fd5c33f Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Tue, 13 Aug 2013 21:09:50 +0000 Subject: Options: Add new option kind that consumes remaining arguments This adds KIND_REMAINING_ARGS, a class of options that consume all remaining arguments on the command line. This will be used to support /link in clang-cl, which is used to forward all remaining arguments to the linker. It also allows us to remove the hard-coded handling of "--", allowing clients (clang and lld) to implement that functionality themselves with this new option class. Differential Revision: http://llvm-reviews.chandlerc.com/D1387 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188314 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Option/OptParser.td | 2 ++ include/llvm/Option/Option.h | 2 ++ 2 files changed, 4 insertions(+) (limited to 'include') diff --git a/include/llvm/Option/OptParser.td b/include/llvm/Option/OptParser.td index 32cc2c0..963389f 100644 --- a/include/llvm/Option/OptParser.td +++ b/include/llvm/Option/OptParser.td @@ -44,6 +44,8 @@ def KIND_JOINED_OR_SEPARATE : OptionKind<"JoinedOrSeparate">; // An option which is both joined to its (first) value, and followed by its // (second) value. def KIND_JOINED_AND_SEPARATE : OptionKind<"JoinedAndSeparate">; +// An option which consumes all remaining arguments if there are any. +def KIND_REMAINING_ARGS : OptionKind<"RemainingArgs">; // Define the option flags. diff --git a/include/llvm/Option/Option.h b/include/llvm/Option/Option.h index 47fd817..03d4774 100644 --- a/include/llvm/Option/Option.h +++ b/include/llvm/Option/Option.h @@ -50,6 +50,7 @@ public: FlagClass, JoinedClass, SeparateClass, + RemainingArgsClass, CommaJoinedClass, MultiArgClass, JoinedOrSeparateClass, @@ -149,6 +150,7 @@ public: case SeparateClass: case MultiArgClass: case JoinedOrSeparateClass: + case RemainingArgsClass: return RenderSeparateStyle; } llvm_unreachable("Unexpected kind!"); -- cgit v1.1 From 0fe3792a2fd6ed9c20d8bf8eb3689672cb30c1c7 Mon Sep 17 00:00:00 2001 From: Jack Carter Date: Tue, 13 Aug 2013 22:34:26 +0000 Subject: [Mips][msa] Value types for MSA support. Added v8f16 to ValueTypes.h, ValueTypes.cpp, ValueTypes.td, and CodeGenTarget.cpp Patch by Daniel Sanders git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188326 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/ValueTypes.h | 31 ++++++++++++++++++------------- include/llvm/CodeGen/ValueTypes.td | 23 ++++++++++++----------- 2 files changed, 30 insertions(+), 24 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h index b7b3d73..f605c80 100644 --- a/include/llvm/CodeGen/ValueTypes.h +++ b/include/llvm/CodeGen/ValueTypes.h @@ -94,13 +94,14 @@ namespace llvm { LAST_INTEGER_VECTOR_VALUETYPE = v16i64, v2f16 = 41, // 2 x f16 - v2f32 = 42, // 2 x f32 - v4f32 = 43, // 4 x f32 - v8f32 = 44, // 8 x f32 - v16f32 = 45, // 16 x f32 - v2f64 = 46, // 2 x f64 - v4f64 = 47, // 4 x f64 - v8f64 = 48, // 8 x f64 + v8f16 = 42, // 8 x f16 + v2f32 = 43, // 2 x f32 + v4f32 = 44, // 4 x f32 + v8f32 = 45, // 8 x f32 + v16f32 = 46, // 16 x f32 + v2f64 = 47, // 2 x f64 + v4f64 = 48, // 4 x f64 + v8f64 = 49, // 8 x f64 FIRST_FP_VECTOR_VALUETYPE = v2f16, LAST_FP_VECTOR_VALUETYPE = v8f64, @@ -108,17 +109,17 @@ namespace llvm { FIRST_VECTOR_VALUETYPE = v2i1, LAST_VECTOR_VALUETYPE = v8f64, - x86mmx = 49, // This is an X86 MMX value + x86mmx = 50, // This is an X86 MMX value - Glue = 50, // This glues nodes together during pre-RA sched + Glue = 51, // This glues nodes together during pre-RA sched - isVoid = 51, // This has no value + isVoid = 52, // This has no value - Untyped = 52, // This value takes a register, but has + Untyped = 53, // This value takes a register, but has // unspecified type. The register class // will be determined by the opcode. - LAST_VALUETYPE = 53, // This always remains at the end of the list. + LAST_VALUETYPE = 54, // This always remains at the end of the list. // This is the current maximum for LAST_VALUETYPE. // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors @@ -287,7 +288,8 @@ namespace llvm { case v4i64: case v8i64: case v16i64: return i64; - case v2f16: return f16; + case v2f16: + case v8f16: return f16; case v2f32: case v4f32: case v8f32: @@ -318,6 +320,7 @@ namespace llvm { case v8i16: case v8i32: case v8i64: + case v8f16: case v8f32: case v8f64: return 8; case v4i1: @@ -390,6 +393,7 @@ namespace llvm { case v8i16: case v4i32: case v2i64: + case v8f16: case v4f32: case v2f64: return 128; case v32i8: @@ -521,6 +525,7 @@ namespace llvm { break; case MVT::f16: if (NumElements == 2) return MVT::v2f16; + if (NumElements == 8) return MVT::v8f16; break; case MVT::f32: if (NumElements == 2) return MVT::v2f32; diff --git a/include/llvm/CodeGen/ValueTypes.td b/include/llvm/CodeGen/ValueTypes.td index da26985..28ad936 100644 --- a/include/llvm/CodeGen/ValueTypes.td +++ b/include/llvm/CodeGen/ValueTypes.td @@ -63,19 +63,20 @@ def v8i64 : ValueType<512, 39>; // 8 x i64 vector value def v16i64 : ValueType<1024,40>; // 16 x i64 vector value def v2f16 : ValueType<32 , 41>; // 2 x f16 vector value -def v2f32 : ValueType<64 , 42>; // 2 x f32 vector value -def v4f32 : ValueType<128, 43>; // 4 x f32 vector value -def v8f32 : ValueType<256, 44>; // 8 x f32 vector value -def v16f32 : ValueType<512, 45>; // 16 x f32 vector value -def v2f64 : ValueType<128, 46>; // 2 x f64 vector value -def v4f64 : ValueType<256, 47>; // 4 x f64 vector value -def v8f64 : ValueType<512, 48>; // 8 x f64 vector value +def v8f16 : ValueType<128, 42>; // 8 x f16 vector value +def v2f32 : ValueType<64 , 43>; // 2 x f32 vector value +def v4f32 : ValueType<128, 44>; // 4 x f32 vector value +def v8f32 : ValueType<256, 45>; // 8 x f32 vector value +def v16f32 : ValueType<512, 46>; // 16 x f32 vector value +def v2f64 : ValueType<128, 47>; // 2 x f64 vector value +def v4f64 : ValueType<256, 48>; // 4 x f64 vector value +def v8f64 : ValueType<512, 49>; // 8 x f64 vector value -def x86mmx : ValueType<64 , 49>; // X86 MMX value -def FlagVT : ValueType<0 , 50>; // Pre-RA sched glue -def isVoid : ValueType<0 , 51>; // Produces no value -def untyped: ValueType<8 , 52>; // Produces an untyped value +def x86mmx : ValueType<64 , 50>; // X86 MMX value +def FlagVT : ValueType<0 , 51>; // Pre-RA sched glue +def isVoid : ValueType<0 , 52>; // Produces no value +def untyped: ValueType<8 , 53>; // Produces an untyped value def MetadataVT: ValueType<0, 250>; // Metadata // Pseudo valuetype mapped to the current pointer size to any address space. -- cgit v1.1 From 6c1fa7caaefc88a5a867add402d90115823bd0eb Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Tue, 13 Aug 2013 22:51:58 +0000 Subject: Revert r187191, which broke opt -mem2reg on the testcases included in PR16867. However, opt -O2 doesn't run mem2reg directly so nobody noticed until r188146 when SROA started sending more things directly down the PromoteMemToReg path. In order to revert r187191, I also revert dependent revisions r187296, r187322 and r188146. Fixes PR16867. Does not add the testcases from that PR, but both of them should get added for both mem2reg and sroa when this revert gets unreverted. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188327 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/Utils/PromoteMemToReg.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/Transforms/Utils/PromoteMemToReg.h b/include/llvm/Transforms/Utils/PromoteMemToReg.h index 2f28f33..22f46e5 100644 --- a/include/llvm/Transforms/Utils/PromoteMemToReg.h +++ b/include/llvm/Transforms/Utils/PromoteMemToReg.h @@ -20,7 +20,6 @@ namespace llvm { class AllocaInst; -class DataLayout; class DominatorTree; class AliasSetTracker; @@ -30,7 +29,7 @@ class AliasSetTracker; /// (transitively) using this alloca. This also enforces that there is only /// ever one layer of bitcasts or GEPs between the alloca and the lifetime /// markers. -bool isAllocaPromotable(const AllocaInst *AI, const DataLayout *DL); +bool isAllocaPromotable(const AllocaInst *AI); /// \brief Promote the specified list of alloca instructions into scalar /// registers, inserting PHI nodes as appropriate. @@ -42,7 +41,7 @@ bool isAllocaPromotable(const AllocaInst *AI, const DataLayout *DL); /// If AST is specified, the specified tracker is updated to reflect changes /// made to the IR. void PromoteMemToReg(ArrayRef Allocas, DominatorTree &DT, - const DataLayout *DL, AliasSetTracker *AST = 0); + AliasSetTracker *AST = 0); } // End llvm namespace -- cgit v1.1 From 337439d12d2e2a9e820e0aeee261bbdb935fc0a5 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Wed, 14 Aug 2013 14:23:31 +0000 Subject: Support C99 hexadecimal floating-point literals in assembly It's useful to be able to write down floating-point numbers without having to worry about what they'll be rounded to (as C99 discovered), this extends that ability to the MC assembly parsers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188370 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCParser/AsmLexer.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/MC/MCParser/AsmLexer.h b/include/llvm/MC/MCParser/AsmLexer.h index 0dab314..1b3ab57 100644 --- a/include/llvm/MC/MCParser/AsmLexer.h +++ b/include/llvm/MC/MCParser/AsmLexer.h @@ -63,6 +63,7 @@ private: AsmToken LexSingleQuote(); AsmToken LexQuote(); AsmToken LexFloatLiteral(); + AsmToken LexHexFloatLiteral(bool NoIntDigits); }; } // end namespace llvm -- cgit v1.1 From ef7aefc53bf24214f489bf9e4100bcff45f7b12a Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Wed, 14 Aug 2013 16:03:29 +0000 Subject: Expose CRC-32 implementation from zlib git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188380 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Compression.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm/Support/Compression.h b/include/llvm/Support/Compression.h index 9b1142d..bef9146 100644 --- a/include/llvm/Support/Compression.h +++ b/include/llvm/Support/Compression.h @@ -50,6 +50,8 @@ Status uncompress(StringRef InputBuffer, OwningPtr &UncompressedBuffer, size_t UncompressedSize); +uint32_t crc32(StringRef Buffer); + } // End of namespace zlib } // End of namespace llvm -- cgit v1.1 From 292e417c1b3452c43d224e1a928c89bde6469515 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Wed, 14 Aug 2013 17:28:39 +0000 Subject: Remove unused struct/enum Patch by Matthias Braun! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188388 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveInterval.h | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index efad0c6..251ef50 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -144,17 +144,6 @@ namespace llvm { Ranges ranges; // the ranges in which this register is live VNInfoList valnos; // value#'s - struct InstrSlots { - enum { - LOAD = 0, - USE = 1, - DEF = 2, - STORE = 3, - NUM = 4 - }; - - }; - LiveInterval(unsigned Reg, float Weight) : reg(Reg), weight(Weight) {} -- cgit v1.1 From 906968c53336490c021b624c94642b10d9541d2c Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Wed, 14 Aug 2013 17:28:49 +0000 Subject: Remove unused function. Patch by Matthias Braun! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188392 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveInterval.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index 251ef50..f42bf8c 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -381,13 +381,6 @@ namespace llvm { SmallVectorImpl &NewVNInfo, MachineRegisterInfo *MRI); - /// isInOneLiveRange - Return true if the range specified is entirely in the - /// a single LiveRange of the live interval. - bool isInOneLiveRange(SlotIndex Start, SlotIndex End) const { - const_iterator r = find(Start); - return r != end() && r->containsRange(Start, End); - } - /// True iff this live range is a single segment that lies between the /// specified boundaries, exclusively. Vregs live across a backedge are not /// considered local. The boundaries are expected to lie within an extended -- cgit v1.1 From 1c6d387dc90fba589f8effb17c72a39f966f87df Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Wed, 14 Aug 2013 17:28:52 +0000 Subject: Remove unnecessary parameter to RenumberValues. Patch by Matthias Braun! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188393 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveInterval.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index f42bf8c..6361c35 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -240,7 +240,7 @@ namespace llvm { /// RenumberValues - Renumber all values in order of appearance and remove /// unused values. - void RenumberValues(LiveIntervals &lis); + void RenumberValues(); /// MergeValueNumberInto - This method is called when two value nubmers /// are found to be equivalent. This eliminates V1, replacing all -- cgit v1.1 From fdb1a6c341c0e289f3f900cdab87f831262c0e93 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 14 Aug 2013 18:54:12 +0000 Subject: DataFlowSanitizer: greylist is now ABI list. This replaces the old incomplete greylist functionality with an ABI list, which can provide more detailed information about the ABI and semantics of specific functions. The pass treats every function in the "uninstrumented" category in the ABI list file as conforming to the "native" (i.e. unsanitized) ABI. Unless the ABI list contains additional categories for those functions, a call to one of those functions will produce a warning message, as the labelling behaviour of the function is unknown. The other supported categories are "functional", "discard" and "custom". - "discard" -- This function does not write to (user-accessible) memory, and its return value is unlabelled. - "functional" -- This function does not write to (user-accessible) memory, and the label of its return value is the union of the label of its arguments. - "custom" -- Instead of calling the function, a custom wrapper __dfsw_F is called, where F is the name of the function. This function may wrap the original function or provide its own implementation. Differential Revision: http://llvm-reviews.chandlerc.com/D1345 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188402 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/Instrumentation.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/Transforms/Instrumentation.h b/include/llvm/Transforms/Instrumentation.h index ecc470b..a5cac00 100644 --- a/include/llvm/Transforms/Instrumentation.h +++ b/include/llvm/Transforms/Instrumentation.h @@ -89,12 +89,14 @@ FunctionPass *createMemorySanitizerPass(bool TrackOrigins = false, FunctionPass *createThreadSanitizerPass(StringRef BlacklistFile = StringRef()); // Insert DataFlowSanitizer (dynamic data flow analysis) instrumentation -ModulePass *createDataFlowSanitizerPass(void *(*getArgTLS)() = 0, +ModulePass *createDataFlowSanitizerPass(StringRef ABIListFile = StringRef(), + void *(*getArgTLS)() = 0, void *(*getRetValTLS)() = 0); #if defined(__GNUC__) && defined(__linux__) -inline ModulePass *createDataFlowSanitizerPassForJIT() { - return createDataFlowSanitizerPass(getDFSanArgTLSPtrForJIT, +inline ModulePass *createDataFlowSanitizerPassForJIT(StringRef ABIListFile = + StringRef()) { + return createDataFlowSanitizerPass(ABIListFile, getDFSanArgTLSPtrForJIT, getDFSanRetValTLSPtrForJIT); } #endif -- cgit v1.1 From 1feb5854aeeda897e9318c8193d187673c8576b8 Mon Sep 17 00:00:00 2001 From: Mark Lacey Date: Wed, 14 Aug 2013 23:50:04 +0000 Subject: Track new virtual registers by register number. Track new virtual registers by register number, rather than by the live interval created for them. This is the first step in separating the creation of new virtual registers and new live intervals. Eventually live intervals will be created and populated on demand after the virtual registers have been created and used in instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188434 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveRangeEdit.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveRangeEdit.h b/include/llvm/CodeGen/LiveRangeEdit.h index a8749da..30ec10f 100644 --- a/include/llvm/CodeGen/LiveRangeEdit.h +++ b/include/llvm/CodeGen/LiveRangeEdit.h @@ -30,7 +30,6 @@ class AliasAnalysis; class LiveIntervals; class MachineBlockFrequencyInfo; class MachineLoopInfo; -class MachineRegisterInfo; class VirtRegMap; class LiveRangeEdit { @@ -58,7 +57,7 @@ public: private: LiveInterval *Parent; - SmallVectorImpl &NewRegs; + SmallVectorImpl &NewRegs; MachineRegisterInfo &MRI; LiveIntervals &LIS; VirtRegMap *VRM; @@ -108,7 +107,7 @@ public: /// function. If NULL, no virtual register map updates will /// be done. This could be the case if called before Regalloc. LiveRangeEdit(LiveInterval *parent, - SmallVectorImpl &newRegs, + SmallVectorImpl &newRegs, MachineFunction &MF, LiveIntervals &lis, VirtRegMap *vrm, @@ -127,14 +126,14 @@ public: unsigned getReg() const { return getParent().reg; } /// Iterator for accessing the new registers added by this edit. - typedef SmallVectorImpl::const_iterator iterator; + typedef SmallVectorImpl::const_iterator iterator; iterator begin() const { return NewRegs.begin()+FirstNew; } iterator end() const { return NewRegs.end(); } unsigned size() const { return NewRegs.size()-FirstNew; } bool empty() const { return size() == 0; } - LiveInterval *get(unsigned idx) const { return NewRegs[idx+FirstNew]; } + unsigned get(unsigned idx) const { return NewRegs[idx+FirstNew]; } - ArrayRef regs() const { + ArrayRef regs() const { return makeArrayRef(NewRegs).slice(FirstNew); } -- cgit v1.1 From 03fe68e0a9c0fdd196f62899cb44b6f9a56dd7c8 Mon Sep 17 00:00:00 2001 From: Mark Lacey Date: Wed, 14 Aug 2013 23:50:09 +0000 Subject: Notify LiveRangeEdit of new virtual registers. Add a delegate class to MachineRegisterInfo with a single virtual function, MRI_NoteNewVirtualRegister(). Update LiveRangeEdit to inherit from this delegate class and override the definition of the callback with an implementation that tracks the newly created virtual registers. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188435 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveRangeEdit.h | 11 +++++++++-- include/llvm/CodeGen/MachineRegisterInfo.h | 27 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveRangeEdit.h b/include/llvm/CodeGen/LiveRangeEdit.h index 30ec10f..43a9566 100644 --- a/include/llvm/CodeGen/LiveRangeEdit.h +++ b/include/llvm/CodeGen/LiveRangeEdit.h @@ -22,6 +22,7 @@ #include "llvm/ADT/SetVector.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/CodeGen/LiveInterval.h" +#include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/Target/TargetMachine.h" namespace llvm { @@ -32,7 +33,7 @@ class MachineBlockFrequencyInfo; class MachineLoopInfo; class VirtRegMap; -class LiveRangeEdit { +class LiveRangeEdit : private MachineRegisterInfo::Delegate { public: /// Callback methods for LiveRangeEdit owners. class Delegate { @@ -96,6 +97,10 @@ private: /// Helper for eliminateDeadDefs. void eliminateDeadDef(MachineInstr *MI, ToShrinkSet &ToShrink); + /// MachineRegisterInfo callback to notify when new virtual + /// registers are created. + void MRI_NoteNewVirtualRegister(unsigned VReg); + public: /// Create a LiveRangeEdit for breaking down parent into smaller pieces. /// @param parent The register being spilled or split. @@ -117,7 +122,9 @@ public: TII(*MF.getTarget().getInstrInfo()), TheDelegate(delegate), FirstNew(newRegs.size()), - ScannedRemattable(false) {} + ScannedRemattable(false) { MRI.setDelegate(this); } + + ~LiveRangeEdit() { MRI.resetDelegate(this); } LiveInterval &getParent() const { assert(Parent && "No parent LiveInterval"); diff --git a/include/llvm/CodeGen/MachineRegisterInfo.h b/include/llvm/CodeGen/MachineRegisterInfo.h index 7a6dcd0..4fb1ac9 100644 --- a/include/llvm/CodeGen/MachineRegisterInfo.h +++ b/include/llvm/CodeGen/MachineRegisterInfo.h @@ -27,7 +27,17 @@ namespace llvm { /// registers, including vreg register classes, use/def chains for registers, /// etc. class MachineRegisterInfo { +public: + class Delegate { + public: + virtual void MRI_NoteNewVirtualRegister(unsigned Reg) {} + + virtual ~Delegate() {} + }; + +private: const TargetMachine &TM; + Delegate *TheDelegate; /// IsSSA - True when the machine function is in SSA form and virtual /// registers have a single def. @@ -116,6 +126,23 @@ public: return TM.getRegisterInfo(); } + void resetDelegate(Delegate *delegate) { + // Ensure another delegate does not take over unless the current + // delegate first unattaches itself. If we ever need to multicast + // notifications, we will need to change to using a list. + assert(TheDelegate == delegate && + "Only the current delegate can perform reset!"); + TheDelegate = 0; + } + + void setDelegate(Delegate *delegate) { + assert(delegate && !TheDelegate && + "Attempted to set delegate to null, or to change it without " + "first resetting it!"); + + TheDelegate = delegate; + } + //===--------------------------------------------------------------------===// // Function State //===--------------------------------------------------------------------===// -- cgit v1.1 From 3bbd96e90be56c39a0b527fc6d5ccd8af4426a03 Mon Sep 17 00:00:00 2001 From: Mark Lacey Date: Wed, 14 Aug 2013 23:50:11 +0000 Subject: Add the MachineInstrSpan class. MachineInstrSpan is initialized with a MachineBasicBlock::iterator, and is intended to track which instructions are inserted before/after that instruction from the time the MachineInstrSpan is created. It provides a begin()/end() interface to walk the range of instructions inserted around the initial instruction (including that initial instruction). It also provides a getInitial() interface to return the initial iterator. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188436 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineBasicBlock.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index d6f5883..e126f86 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -733,6 +733,31 @@ template <> struct GraphTraits > { } }; + + +/// MachineInstrSpan provides an interface to get an iteration range +/// containing the instruction it was initialized with, along with all +/// those instructions inserted prior to or following that instruction +/// at some point after the MachineInstrSpan is constructed. +class MachineInstrSpan { + MachineBasicBlock &MBB; + MachineBasicBlock::iterator I, B, E; +public: + MachineInstrSpan(MachineBasicBlock::iterator I) + : MBB(*I->getParent()), + I(I), + B(I == MBB.begin() ? MBB.end() : llvm::prior(I)), + E(llvm::next(I)) {} + + MachineBasicBlock::iterator begin() { + return B == MBB.end() ? MBB.begin() : llvm::next(B); + } + MachineBasicBlock::iterator end() { return E; } + bool empty() { return begin() == end(); } + + MachineBasicBlock::iterator getInitial() { return I; } +}; + } // End llvm namespace #endif -- cgit v1.1 From e742d687369f79702894b6cf302e1f222c5d7432 Mon Sep 17 00:00:00 2001 From: Mark Lacey Date: Wed, 14 Aug 2013 23:50:16 +0000 Subject: Auto-compute live intervals on demand. When new virtual registers are created during splitting/spilling, defer creation of the live interval until we need to use the live interval. Along with the recent commits to notify LiveRangeEdit when new virtual registers are created, this makes it possible for functions like TargetInstrInfo::loadRegFromStackSlot() and TargetInstrInfo::storeRegToStackSlot() to create multiple virtual registers as part of the process of generating loads/stores for different register classes, and then have the live intervals for those new registers computed when they are needed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188437 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveIntervalAnalysis.h | 30 ++++++++++++++++++++--------- include/llvm/CodeGen/LiveRangeEdit.h | 11 +++++++++-- 2 files changed, 30 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h index ffb07a5..d134781 100644 --- a/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -103,9 +103,10 @@ namespace llvm { static float getSpillWeight(bool isDef, bool isUse, BlockFrequency freq); LiveInterval &getInterval(unsigned Reg) { - LiveInterval *LI = VirtRegIntervals[Reg]; - assert(LI && "Interval does not exist for virtual register"); - return *LI; + if (hasInterval(Reg)) + return *VirtRegIntervals[Reg]; + else + return createAndComputeVirtRegInterval(Reg); } const LiveInterval &getInterval(unsigned Reg) const { @@ -117,12 +118,17 @@ namespace llvm { } // Interval creation. - LiveInterval &getOrCreateInterval(unsigned Reg) { - if (!hasInterval(Reg)) { - VirtRegIntervals.grow(Reg); - VirtRegIntervals[Reg] = createInterval(Reg); - } - return getInterval(Reg); + LiveInterval &createEmptyInterval(unsigned Reg) { + assert(!hasInterval(Reg) && "Interval already exists!"); + VirtRegIntervals.grow(Reg); + VirtRegIntervals[Reg] = createInterval(Reg); + return *VirtRegIntervals[Reg]; + } + + LiveInterval &createAndComputeVirtRegInterval(unsigned Reg) { + LiveInterval &LI = createEmptyInterval(Reg); + computeVirtRegInterval(&LI); + return LI; } // Interval removal. @@ -225,6 +231,12 @@ namespace llvm { return Indexes->insertMachineInstrInMaps(MI); } + void InsertMachineInstrRangeInMaps(MachineBasicBlock::iterator B, + MachineBasicBlock::iterator E) { + for (MachineBasicBlock::iterator I = B; I != E; ++I) + Indexes->insertMachineInstrInMaps(I); + } + void RemoveMachineInstrFromMaps(MachineInstr *MI) { Indexes->removeMachineInstrFromMaps(MI); } diff --git a/include/llvm/CodeGen/LiveRangeEdit.h b/include/llvm/CodeGen/LiveRangeEdit.h index 43a9566..7edf67c 100644 --- a/include/llvm/CodeGen/LiveRangeEdit.h +++ b/include/llvm/CodeGen/LiveRangeEdit.h @@ -144,12 +144,19 @@ public: return makeArrayRef(NewRegs).slice(FirstNew); } + /// createEmptyIntervalFrom - Create a new empty interval based on OldReg. + LiveInterval &createEmptyIntervalFrom(unsigned OldReg); + /// createFrom - Create a new virtual register based on OldReg. - LiveInterval &createFrom(unsigned OldReg); + unsigned createFrom(unsigned OldReg); /// create - Create a new register with the same class and original slot as /// parent. - LiveInterval &create() { + LiveInterval &createEmptyInterval() { + return createEmptyIntervalFrom(getReg()); + } + + unsigned create() { return createFrom(getReg()); } -- cgit v1.1 From e2a9376b1bd2204ea6f56a35b762e28e0ef4e35a Mon Sep 17 00:00:00 2001 From: Jack Carter Date: Thu, 15 Aug 2013 12:24:57 +0000 Subject: [Mips][msa] Added the simple builtins (add_a to dpsub[su], ilvev to ldi) Includes: add_a, adds_[asu], addv, addvi, andi.b, asub_[su].[bhwd], aver?_[su]_[bhwd], bclr, bclri, bins[lr], bins[lr]i, bmnzi, bmzi, bneg, bnegi, bseli, bset, bseti, c(eq|ne), c(eq|ne)i, cl[et]_[su], cl[et]i_[su], copy_[su].[bhw], div_[su], dotp_[su], dpadd_[su], dpsub_[su], ilvev, ilvl, ilvod, ilvr, insv, insve, ldi Patch by Daniel Sanders git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188457 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 443 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 443 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index a0987c8..f497c73 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -386,4 +386,447 @@ def int_mips_subuh_qb: GCCBuiltin<"__builtin_mips_subuh_qb">, Intrinsic<[llvm_v4i8_ty], [llvm_v4i8_ty, llvm_v4i8_ty], [IntrNoMem]>; def int_mips_subuh_r_qb: GCCBuiltin<"__builtin_mips_subuh_r_qb">, Intrinsic<[llvm_v4i8_ty], [llvm_v4i8_ty, llvm_v4i8_ty], [IntrNoMem]>; + +//===----------------------------------------------------------------------===// +// MIPS MSA + +//===----------------------------------------------------------------------===// +// Addition/subtraction + +def int_mips_add_a_b : GCCBuiltin<"__builtin_msa_add_a_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; +def int_mips_add_a_h : GCCBuiltin<"__builtin_msa_add_a_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; +def int_mips_add_a_w : GCCBuiltin<"__builtin_msa_add_a_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; +def int_mips_add_a_d : GCCBuiltin<"__builtin_msa_add_a_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + +def int_mips_adds_a_b : GCCBuiltin<"__builtin_msa_adds_a_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; +def int_mips_adds_a_h : GCCBuiltin<"__builtin_msa_adds_a_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; +def int_mips_adds_a_w : GCCBuiltin<"__builtin_msa_adds_a_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; +def int_mips_adds_a_d : GCCBuiltin<"__builtin_msa_adds_a_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + +def int_mips_adds_s_b : GCCBuiltin<"__builtin_msa_adds_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; +def int_mips_adds_s_h : GCCBuiltin<"__builtin_msa_adds_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; +def int_mips_adds_s_w : GCCBuiltin<"__builtin_msa_adds_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; +def int_mips_adds_s_d : GCCBuiltin<"__builtin_msa_adds_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + +def int_mips_adds_u_b : GCCBuiltin<"__builtin_msa_adds_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; +def int_mips_adds_u_h : GCCBuiltin<"__builtin_msa_adds_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; +def int_mips_adds_u_w : GCCBuiltin<"__builtin_msa_adds_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; +def int_mips_adds_u_d : GCCBuiltin<"__builtin_msa_adds_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + +def int_mips_addv_b : GCCBuiltin<"__builtin_msa_addv_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; +def int_mips_addv_h : GCCBuiltin<"__builtin_msa_addv_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; +def int_mips_addv_w : GCCBuiltin<"__builtin_msa_addv_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; +def int_mips_addv_d : GCCBuiltin<"__builtin_msa_addv_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + +def int_mips_addvi_b : GCCBuiltin<"__builtin_msa_addvi_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [Commutative]>; +def int_mips_addvi_h : GCCBuiltin<"__builtin_msa_addvi_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [Commutative]>; +def int_mips_addvi_w : GCCBuiltin<"__builtin_msa_addvi_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [Commutative]>; +def int_mips_addvi_d : GCCBuiltin<"__builtin_msa_addvi_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [Commutative]>; + +def int_mips_andi_b : GCCBuiltin<"__builtin_msa_andi_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + +def int_mips_asub_s_b : GCCBuiltin<"__builtin_msa_asub_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_asub_s_h : GCCBuiltin<"__builtin_msa_asub_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_asub_s_w : GCCBuiltin<"__builtin_msa_asub_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_asub_s_d : GCCBuiltin<"__builtin_msa_asub_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_asub_u_b : GCCBuiltin<"__builtin_msa_asub_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_asub_u_h : GCCBuiltin<"__builtin_msa_asub_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_asub_u_w : GCCBuiltin<"__builtin_msa_asub_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_asub_u_d : GCCBuiltin<"__builtin_msa_asub_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_ave_s_b : GCCBuiltin<"__builtin_msa_ave_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; +def int_mips_ave_s_h : GCCBuiltin<"__builtin_msa_ave_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; +def int_mips_ave_s_w : GCCBuiltin<"__builtin_msa_ave_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; +def int_mips_ave_s_d : GCCBuiltin<"__builtin_msa_ave_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + +def int_mips_ave_u_b : GCCBuiltin<"__builtin_msa_ave_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; +def int_mips_ave_u_h : GCCBuiltin<"__builtin_msa_ave_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; +def int_mips_ave_u_w : GCCBuiltin<"__builtin_msa_ave_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; +def int_mips_ave_u_d : GCCBuiltin<"__builtin_msa_ave_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + +def int_mips_aver_s_b : GCCBuiltin<"__builtin_msa_aver_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; +def int_mips_aver_s_h : GCCBuiltin<"__builtin_msa_aver_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; +def int_mips_aver_s_w : GCCBuiltin<"__builtin_msa_aver_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; +def int_mips_aver_s_d : GCCBuiltin<"__builtin_msa_aver_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + +def int_mips_aver_u_b : GCCBuiltin<"__builtin_msa_aver_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; +def int_mips_aver_u_h : GCCBuiltin<"__builtin_msa_aver_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; +def int_mips_aver_u_w : GCCBuiltin<"__builtin_msa_aver_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; +def int_mips_aver_u_d : GCCBuiltin<"__builtin_msa_aver_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + +def int_mips_bclr_b : GCCBuiltin<"__builtin_msa_bclr_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_bclr_h : GCCBuiltin<"__builtin_msa_bclr_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_bclr_w : GCCBuiltin<"__builtin_msa_bclr_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_bclr_d : GCCBuiltin<"__builtin_msa_bclr_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_bclri_b : GCCBuiltin<"__builtin_msa_bclri_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_bclri_h : GCCBuiltin<"__builtin_msa_bclri_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_bclri_w : GCCBuiltin<"__builtin_msa_bclri_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_bclri_d : GCCBuiltin<"__builtin_msa_bclri_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_binsl_b : GCCBuiltin<"__builtin_msa_binsl_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_binsl_h : GCCBuiltin<"__builtin_msa_binsl_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_binsl_w : GCCBuiltin<"__builtin_msa_binsl_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_binsl_d : GCCBuiltin<"__builtin_msa_binsl_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_binsli_b : GCCBuiltin<"__builtin_msa_binsli_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_binsli_h : GCCBuiltin<"__builtin_msa_binsli_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_binsli_w : GCCBuiltin<"__builtin_msa_binsli_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_binsli_d : GCCBuiltin<"__builtin_msa_binsli_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_binsr_b : GCCBuiltin<"__builtin_msa_binsr_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_binsr_h : GCCBuiltin<"__builtin_msa_binsr_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_binsr_w : GCCBuiltin<"__builtin_msa_binsr_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_binsr_d : GCCBuiltin<"__builtin_msa_binsr_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_binsri_b : GCCBuiltin<"__builtin_msa_binsri_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_binsri_h : GCCBuiltin<"__builtin_msa_binsri_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_binsri_w : GCCBuiltin<"__builtin_msa_binsri_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_binsri_d : GCCBuiltin<"__builtin_msa_binsri_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_bmnzi_b : GCCBuiltin<"__builtin_msa_bmnzi_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + +def int_mips_bmzi_b : GCCBuiltin<"__builtin_msa_bmzi_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + +def int_mips_bneg_b : GCCBuiltin<"__builtin_msa_bneg_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_bneg_h : GCCBuiltin<"__builtin_msa_bneg_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_bneg_w : GCCBuiltin<"__builtin_msa_bneg_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_bneg_d : GCCBuiltin<"__builtin_msa_bneg_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_bnegi_b : GCCBuiltin<"__builtin_msa_bnegi_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_bnegi_h : GCCBuiltin<"__builtin_msa_bnegi_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_bnegi_w : GCCBuiltin<"__builtin_msa_bnegi_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_bnegi_d : GCCBuiltin<"__builtin_msa_bnegi_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_bseli_b : GCCBuiltin<"__builtin_msa_bseli_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_bseli_h : GCCBuiltin<"__builtin_msa_bseli_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_bseli_w : GCCBuiltin<"__builtin_msa_bseli_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_bseli_d : GCCBuiltin<"__builtin_msa_bseli_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_bset_b : GCCBuiltin<"__builtin_msa_bset_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_bset_h : GCCBuiltin<"__builtin_msa_bset_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_bset_w : GCCBuiltin<"__builtin_msa_bset_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_bset_d : GCCBuiltin<"__builtin_msa_bset_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_bseti_b : GCCBuiltin<"__builtin_msa_bseti_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_bseti_h : GCCBuiltin<"__builtin_msa_bseti_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_bseti_w : GCCBuiltin<"__builtin_msa_bseti_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_bseti_d : GCCBuiltin<"__builtin_msa_bseti_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_ceq_b : GCCBuiltin<"__builtin_msa_ceq_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_ceq_h : GCCBuiltin<"__builtin_msa_ceq_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_ceq_w : GCCBuiltin<"__builtin_msa_ceq_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_ceq_d : GCCBuiltin<"__builtin_msa_ceq_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_ceqi_b : GCCBuiltin<"__builtin_msa_ceqi_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_ceqi_h : GCCBuiltin<"__builtin_msa_ceqi_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_ceqi_w : GCCBuiltin<"__builtin_msa_ceqi_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_ceqi_d : GCCBuiltin<"__builtin_msa_ceqi_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_cle_s_b : GCCBuiltin<"__builtin_msa_cle_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_cle_s_h : GCCBuiltin<"__builtin_msa_cle_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_cle_s_w : GCCBuiltin<"__builtin_msa_cle_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_cle_s_d : GCCBuiltin<"__builtin_msa_cle_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_cle_u_b : GCCBuiltin<"__builtin_msa_cle_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_cle_u_h : GCCBuiltin<"__builtin_msa_cle_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_cle_u_w : GCCBuiltin<"__builtin_msa_cle_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_cle_u_d : GCCBuiltin<"__builtin_msa_cle_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_clei_s_b : GCCBuiltin<"__builtin_msa_clei_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_clei_s_h : GCCBuiltin<"__builtin_msa_clei_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_clei_s_w : GCCBuiltin<"__builtin_msa_clei_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_clei_s_d : GCCBuiltin<"__builtin_msa_clei_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_clei_u_b : GCCBuiltin<"__builtin_msa_clei_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_clei_u_h : GCCBuiltin<"__builtin_msa_clei_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_clei_u_w : GCCBuiltin<"__builtin_msa_clei_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_clei_u_d : GCCBuiltin<"__builtin_msa_clei_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_clt_s_b : GCCBuiltin<"__builtin_msa_clt_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_clt_s_h : GCCBuiltin<"__builtin_msa_clt_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_clt_s_w : GCCBuiltin<"__builtin_msa_clt_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_clt_s_d : GCCBuiltin<"__builtin_msa_clt_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_clt_u_b : GCCBuiltin<"__builtin_msa_clt_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_clt_u_h : GCCBuiltin<"__builtin_msa_clt_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_clt_u_w : GCCBuiltin<"__builtin_msa_clt_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_clt_u_d : GCCBuiltin<"__builtin_msa_clt_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_clti_s_b : GCCBuiltin<"__builtin_msa_clti_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_clti_s_h : GCCBuiltin<"__builtin_msa_clti_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_clti_s_w : GCCBuiltin<"__builtin_msa_clti_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_clti_s_d : GCCBuiltin<"__builtin_msa_clti_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_clti_u_b : GCCBuiltin<"__builtin_msa_clti_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_clti_u_h : GCCBuiltin<"__builtin_msa_clti_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_clti_u_w : GCCBuiltin<"__builtin_msa_clti_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_clti_u_d : GCCBuiltin<"__builtin_msa_clti_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_copy_s_b : GCCBuiltin<"__builtin_msa_copy_s_b">, + Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_copy_s_h : GCCBuiltin<"__builtin_msa_copy_s_h">, + Intrinsic<[llvm_i32_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_copy_s_w : GCCBuiltin<"__builtin_msa_copy_s_w">, + Intrinsic<[llvm_i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + +def int_mips_copy_u_b : GCCBuiltin<"__builtin_msa_copy_u_b">, + Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_copy_u_h : GCCBuiltin<"__builtin_msa_copy_u_h">, + Intrinsic<[llvm_i32_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_copy_u_w : GCCBuiltin<"__builtin_msa_copy_u_w">, + Intrinsic<[llvm_i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + +def int_mips_div_s_b : GCCBuiltin<"__builtin_msa_div_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_div_s_h : GCCBuiltin<"__builtin_msa_div_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_div_s_w : GCCBuiltin<"__builtin_msa_div_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_div_s_d : GCCBuiltin<"__builtin_msa_div_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_div_u_b : GCCBuiltin<"__builtin_msa_div_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_div_u_h : GCCBuiltin<"__builtin_msa_div_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_div_u_w : GCCBuiltin<"__builtin_msa_div_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_div_u_d : GCCBuiltin<"__builtin_msa_div_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_dotp_s_b : GCCBuiltin<"__builtin_msa_dotp_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_dotp_s_h : GCCBuiltin<"__builtin_msa_dotp_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_dotp_s_w : GCCBuiltin<"__builtin_msa_dotp_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_dotp_s_d : GCCBuiltin<"__builtin_msa_dotp_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_dotp_u_b : GCCBuiltin<"__builtin_msa_dotp_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_dotp_u_h : GCCBuiltin<"__builtin_msa_dotp_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_dotp_u_w : GCCBuiltin<"__builtin_msa_dotp_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_dotp_u_d : GCCBuiltin<"__builtin_msa_dotp_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_dpadd_s_h : GCCBuiltin<"__builtin_msa_dpadd_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_dpadd_s_w : GCCBuiltin<"__builtin_msa_dpadd_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_dpadd_s_d : GCCBuiltin<"__builtin_msa_dpadd_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + +def int_mips_dpadd_u_h : GCCBuiltin<"__builtin_msa_dpadd_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_dpadd_u_w : GCCBuiltin<"__builtin_msa_dpadd_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_dpadd_u_d : GCCBuiltin<"__builtin_msa_dpadd_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + +def int_mips_dpsub_s_h : GCCBuiltin<"__builtin_msa_dpsub_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_dpsub_s_w : GCCBuiltin<"__builtin_msa_dpsub_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_dpsub_s_d : GCCBuiltin<"__builtin_msa_dpsub_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + +def int_mips_dpsub_u_h : GCCBuiltin<"__builtin_msa_dpsub_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_dpsub_u_w : GCCBuiltin<"__builtin_msa_dpsub_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_dpsub_u_d : GCCBuiltin<"__builtin_msa_dpsub_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + +def int_mips_ilvev_b : GCCBuiltin<"__builtin_msa_ilvev_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_ilvev_h : GCCBuiltin<"__builtin_msa_ilvev_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_ilvev_w : GCCBuiltin<"__builtin_msa_ilvev_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_ilvev_d : GCCBuiltin<"__builtin_msa_ilvev_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_ilvl_b : GCCBuiltin<"__builtin_msa_ilvl_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_ilvl_h : GCCBuiltin<"__builtin_msa_ilvl_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_ilvl_w : GCCBuiltin<"__builtin_msa_ilvl_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_ilvl_d : GCCBuiltin<"__builtin_msa_ilvl_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_ilvod_b : GCCBuiltin<"__builtin_msa_ilvod_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_ilvod_h : GCCBuiltin<"__builtin_msa_ilvod_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_ilvod_w : GCCBuiltin<"__builtin_msa_ilvod_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_ilvod_d : GCCBuiltin<"__builtin_msa_ilvod_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_ilvr_b : GCCBuiltin<"__builtin_msa_ilvr_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_ilvr_h : GCCBuiltin<"__builtin_msa_ilvr_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_ilvr_w : GCCBuiltin<"__builtin_msa_ilvr_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_ilvr_d : GCCBuiltin<"__builtin_msa_ilvr_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_insert_b : GCCBuiltin<"__builtin_msa_insert_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty, llvm_i32_ty], []>; +def int_mips_insert_h : GCCBuiltin<"__builtin_msa_insert_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty, llvm_i32_ty], []>; +def int_mips_insert_w : GCCBuiltin<"__builtin_msa_insert_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty, llvm_i32_ty], []>; + +def int_mips_ldi_b : GCCBuiltin<"__builtin_msa_ldi_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_i32_ty], []>; +def int_mips_ldi_h : GCCBuiltin<"__builtin_msa_ldi_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_i32_ty], []>; +def int_mips_ldi_w : GCCBuiltin<"__builtin_msa_ldi_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_i32_ty], []>; +def int_mips_ldi_d : GCCBuiltin<"__builtin_msa_ldi_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_i32_ty], []>; + } -- cgit v1.1 From d0f99639c16ddad697db30e75643ae4cc52c3e80 Mon Sep 17 00:00:00 2001 From: Jack Carter Date: Thu, 15 Aug 2013 13:45:36 +0000 Subject: [Mips][msa] Added the simple builtins (fadd to ftq) Includes: fadd, fceq, fcg[et], fclass, fcl[et], fcne, fcun, fdiv, fexdo, fexp2, fexup[lr], ffint_[su], ffql, ffqr, fill, flog2, fmadd, fmax, fmax_a, fmin, fmin_a, fmsub, fmul, frint, frcp, frsqrt, fseq, fsge, fsgt, fsle, fslt, fsne, fsqr, fsub, ftint_s, ftq Patch by Daniel Sanders git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188458 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Intrinsics.td | 1 + include/llvm/IR/IntrinsicsMips.td | 207 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 208 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/Intrinsics.td b/include/llvm/IR/Intrinsics.td index 18f56d2..856e0a5 100644 --- a/include/llvm/IR/Intrinsics.td +++ b/include/llvm/IR/Intrinsics.td @@ -165,6 +165,7 @@ def llvm_v4i64_ty : LLVMType; // 4 x i64 def llvm_v8i64_ty : LLVMType; // 8 x i64 def llvm_v16i64_ty : LLVMType; // 16 x i64 +def llvm_v8f16_ty : LLVMType; // 8 x half (__fp16) def llvm_v2f32_ty : LLVMType; // 2 x float def llvm_v4f32_ty : LLVMType; // 4 x float def llvm_v8f32_ty : LLVMType; // 8 x float diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index f497c73..f49995e 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -777,6 +777,213 @@ def int_mips_dpsub_u_w : GCCBuiltin<"__builtin_msa_dpsub_u_w">, def int_mips_dpsub_u_d : GCCBuiltin<"__builtin_msa_dpsub_u_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_fadd_w : GCCBuiltin<"__builtin_msa_fadd_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fadd_d : GCCBuiltin<"__builtin_msa_fadd_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fceq_w : GCCBuiltin<"__builtin_msa_fceq_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fceq_d : GCCBuiltin<"__builtin_msa_fceq_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fcle_w : GCCBuiltin<"__builtin_msa_fcle_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fcle_d : GCCBuiltin<"__builtin_msa_fcle_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fclt_w : GCCBuiltin<"__builtin_msa_fclt_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fclt_d : GCCBuiltin<"__builtin_msa_fclt_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fclass_w : GCCBuiltin<"__builtin_msa_fclass_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], []>; +def int_mips_fclass_d : GCCBuiltin<"__builtin_msa_fclass_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty], []>; + +def int_mips_fcge_w : GCCBuiltin<"__builtin_msa_fcge_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fcge_d : GCCBuiltin<"__builtin_msa_fcge_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fcgt_w : GCCBuiltin<"__builtin_msa_fcgt_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fcgt_d : GCCBuiltin<"__builtin_msa_fcgt_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fcne_w : GCCBuiltin<"__builtin_msa_fcne_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fcne_d : GCCBuiltin<"__builtin_msa_fcne_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fcun_w : GCCBuiltin<"__builtin_msa_fcun_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fcun_d : GCCBuiltin<"__builtin_msa_fcun_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fdiv_w : GCCBuiltin<"__builtin_msa_fdiv_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fdiv_d : GCCBuiltin<"__builtin_msa_fdiv_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fexdo_h : GCCBuiltin<"__builtin_msa_fexdo_h">, + Intrinsic<[llvm_v8f16_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fexdo_w : GCCBuiltin<"__builtin_msa_fexdo_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fexp2_w : GCCBuiltin<"__builtin_msa_fexp2_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4i32_ty], []>; +def int_mips_fexp2_d : GCCBuiltin<"__builtin_msa_fexp2_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2i64_ty], []>; + +def int_mips_fexupl_w : GCCBuiltin<"__builtin_msa_fexupl_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v8f16_ty], []>; +def int_mips_fexupl_d : GCCBuiltin<"__builtin_msa_fexupl_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v4f32_ty], []>; + +def int_mips_fexupr_w : GCCBuiltin<"__builtin_msa_fexupr_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v8f16_ty], []>; +def int_mips_fexupr_d : GCCBuiltin<"__builtin_msa_fexupr_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v4f32_ty], []>; + +def int_mips_ffint_s_w : GCCBuiltin<"__builtin_msa_ffint_s_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4i32_ty], []>; +def int_mips_ffint_s_d : GCCBuiltin<"__builtin_msa_ffint_s_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2i64_ty], []>; + +def int_mips_ffint_u_w : GCCBuiltin<"__builtin_msa_ffint_u_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4i32_ty], []>; +def int_mips_ffint_u_d : GCCBuiltin<"__builtin_msa_ffint_u_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2i64_ty], []>; + +def int_mips_ffql_w : GCCBuiltin<"__builtin_msa_ffql_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v8i16_ty], []>; +def int_mips_ffql_d : GCCBuiltin<"__builtin_msa_ffql_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v4i32_ty], []>; + +def int_mips_ffqr_w : GCCBuiltin<"__builtin_msa_ffqr_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v8i16_ty], []>; +def int_mips_ffqr_d : GCCBuiltin<"__builtin_msa_ffqr_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v4i32_ty], []>; + +def int_mips_fill_b : GCCBuiltin<"__builtin_msa_fill_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_i32_ty], []>; +def int_mips_fill_h : GCCBuiltin<"__builtin_msa_fill_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_i32_ty], []>; +def int_mips_fill_w : GCCBuiltin<"__builtin_msa_fill_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_i32_ty], []>; + +def int_mips_flog2_w : GCCBuiltin<"__builtin_msa_flog2_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], []>; +def int_mips_flog2_d : GCCBuiltin<"__builtin_msa_flog2_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], []>; + +def int_mips_fmadd_w : GCCBuiltin<"__builtin_msa_fmadd_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fmadd_d : GCCBuiltin<"__builtin_msa_fmadd_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fmax_w : GCCBuiltin<"__builtin_msa_fmax_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fmax_d : GCCBuiltin<"__builtin_msa_fmax_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fmax_a_w : GCCBuiltin<"__builtin_msa_fmax_a_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fmax_a_d : GCCBuiltin<"__builtin_msa_fmax_a_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fmin_w : GCCBuiltin<"__builtin_msa_fmin_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fmin_d : GCCBuiltin<"__builtin_msa_fmin_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fmin_a_w : GCCBuiltin<"__builtin_msa_fmin_a_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fmin_a_d : GCCBuiltin<"__builtin_msa_fmin_a_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fmsub_w : GCCBuiltin<"__builtin_msa_fmsub_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fmsub_d : GCCBuiltin<"__builtin_msa_fmsub_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fmul_w : GCCBuiltin<"__builtin_msa_fmul_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fmul_d : GCCBuiltin<"__builtin_msa_fmul_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_frint_w : GCCBuiltin<"__builtin_msa_frint_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], []>; +def int_mips_frint_d : GCCBuiltin<"__builtin_msa_frint_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], []>; + +def int_mips_frcp_w : GCCBuiltin<"__builtin_msa_frcp_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], []>; +def int_mips_frcp_d : GCCBuiltin<"__builtin_msa_frcp_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], []>; + +def int_mips_frsqrt_w : GCCBuiltin<"__builtin_msa_frsqrt_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], []>; +def int_mips_frsqrt_d : GCCBuiltin<"__builtin_msa_frsqrt_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], []>; + +def int_mips_fseq_w : GCCBuiltin<"__builtin_msa_fseq_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fseq_d : GCCBuiltin<"__builtin_msa_fseq_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fsle_w : GCCBuiltin<"__builtin_msa_fsle_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fsle_d : GCCBuiltin<"__builtin_msa_fsle_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fslt_w : GCCBuiltin<"__builtin_msa_fslt_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fslt_d : GCCBuiltin<"__builtin_msa_fslt_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fsge_w : GCCBuiltin<"__builtin_msa_fsge_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fsge_d : GCCBuiltin<"__builtin_msa_fsge_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fsgt_w : GCCBuiltin<"__builtin_msa_fsgt_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fsgt_d : GCCBuiltin<"__builtin_msa_fsgt_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fsne_w : GCCBuiltin<"__builtin_msa_fsne_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fsne_d : GCCBuiltin<"__builtin_msa_fsne_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fsqrt_w : GCCBuiltin<"__builtin_msa_fsqrt_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], []>; +def int_mips_fsqrt_d : GCCBuiltin<"__builtin_msa_fsqrt_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], []>; + +def int_mips_fsub_w : GCCBuiltin<"__builtin_msa_fsub_w">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fsub_d : GCCBuiltin<"__builtin_msa_fsub_d">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_ftint_s_w : GCCBuiltin<"__builtin_msa_ftint_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], []>; +def int_mips_ftint_s_d : GCCBuiltin<"__builtin_msa_ftint_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty], []>; + +def int_mips_ftint_u_w : GCCBuiltin<"__builtin_msa_ftint_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], []>; +def int_mips_ftint_u_d : GCCBuiltin<"__builtin_msa_ftint_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty], []>; + +def int_mips_ftq_h : GCCBuiltin<"__builtin_msa_ftq_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_ftq_w : GCCBuiltin<"__builtin_msa_ftq_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + def int_mips_ilvev_b : GCCBuiltin<"__builtin_msa_ilvev_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; def int_mips_ilvev_h : GCCBuiltin<"__builtin_msa_ilvev_h">, -- cgit v1.1 From bd71eea899d579deb1fcee02944f955a4708091a Mon Sep 17 00:00:00 2001 From: Jack Carter Date: Thu, 15 Aug 2013 14:22:07 +0000 Subject: [Mips][msa] Added the simple builtins (madd_q to xori) Includes: madd_q, maddr_q, maddv, max_[asu], maxi_[su], min_[asu], mini_[su], mod_[su], msub_q, msubr_q, msubv, mul_q, mulr_q, mulv, nloc, nlzc, nori, ori, pckev, pckod, pcnt, sat_[su], shf, sld, sldi, sll, slli, splat, splati, sr[al], sr[al]i, subs_[su], subss_u, subus_s, subv, subvi, vshf, xori Patch by Daniel Sanders git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188460 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 396 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 396 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index f49995e..0c413dc 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -1036,4 +1036,400 @@ def int_mips_ldi_w : GCCBuiltin<"__builtin_msa_ldi_w">, def int_mips_ldi_d : GCCBuiltin<"__builtin_msa_ldi_d">, Intrinsic<[llvm_v2i64_ty], [llvm_i32_ty], []>; +def int_mips_madd_q_h : GCCBuiltin<"__builtin_msa_madd_q_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_madd_q_w : GCCBuiltin<"__builtin_msa_madd_q_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + +def int_mips_maddr_q_h : GCCBuiltin<"__builtin_msa_maddr_q_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_maddr_q_w : GCCBuiltin<"__builtin_msa_maddr_q_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + +def int_mips_maddv_b : GCCBuiltin<"__builtin_msa_maddv_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_maddv_h : GCCBuiltin<"__builtin_msa_maddv_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_maddv_w : GCCBuiltin<"__builtin_msa_maddv_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_maddv_d : GCCBuiltin<"__builtin_msa_maddv_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_max_a_b : GCCBuiltin<"__builtin_msa_max_a_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_max_a_h : GCCBuiltin<"__builtin_msa_max_a_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_max_a_w : GCCBuiltin<"__builtin_msa_max_a_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_max_a_d : GCCBuiltin<"__builtin_msa_max_a_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_max_s_b : GCCBuiltin<"__builtin_msa_max_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_max_s_h : GCCBuiltin<"__builtin_msa_max_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_max_s_w : GCCBuiltin<"__builtin_msa_max_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_max_s_d : GCCBuiltin<"__builtin_msa_max_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_max_u_b : GCCBuiltin<"__builtin_msa_max_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_max_u_h : GCCBuiltin<"__builtin_msa_max_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_max_u_w : GCCBuiltin<"__builtin_msa_max_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_max_u_d : GCCBuiltin<"__builtin_msa_max_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_maxi_s_b : GCCBuiltin<"__builtin_msa_maxi_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_maxi_s_h : GCCBuiltin<"__builtin_msa_maxi_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_maxi_s_w : GCCBuiltin<"__builtin_msa_maxi_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_maxi_s_d : GCCBuiltin<"__builtin_msa_maxi_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_maxi_u_b : GCCBuiltin<"__builtin_msa_maxi_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_maxi_u_h : GCCBuiltin<"__builtin_msa_maxi_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_maxi_u_w : GCCBuiltin<"__builtin_msa_maxi_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_maxi_u_d : GCCBuiltin<"__builtin_msa_maxi_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_min_a_b : GCCBuiltin<"__builtin_msa_min_a_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_min_a_h : GCCBuiltin<"__builtin_msa_min_a_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_min_a_w : GCCBuiltin<"__builtin_msa_min_a_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_min_a_d : GCCBuiltin<"__builtin_msa_min_a_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_min_s_b : GCCBuiltin<"__builtin_msa_min_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_min_s_h : GCCBuiltin<"__builtin_msa_min_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_min_s_w : GCCBuiltin<"__builtin_msa_min_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_min_s_d : GCCBuiltin<"__builtin_msa_min_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_min_u_b : GCCBuiltin<"__builtin_msa_min_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_min_u_h : GCCBuiltin<"__builtin_msa_min_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_min_u_w : GCCBuiltin<"__builtin_msa_min_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_min_u_d : GCCBuiltin<"__builtin_msa_min_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_mini_s_b : GCCBuiltin<"__builtin_msa_mini_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_mini_s_h : GCCBuiltin<"__builtin_msa_mini_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_mini_s_w : GCCBuiltin<"__builtin_msa_mini_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_mini_s_d : GCCBuiltin<"__builtin_msa_mini_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_mini_u_b : GCCBuiltin<"__builtin_msa_mini_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_mini_u_h : GCCBuiltin<"__builtin_msa_mini_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_mini_u_w : GCCBuiltin<"__builtin_msa_mini_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_mini_u_d : GCCBuiltin<"__builtin_msa_mini_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_mod_s_b : GCCBuiltin<"__builtin_msa_mod_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_mod_s_h : GCCBuiltin<"__builtin_msa_mod_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_mod_s_w : GCCBuiltin<"__builtin_msa_mod_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_mod_s_d : GCCBuiltin<"__builtin_msa_mod_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_mod_u_b : GCCBuiltin<"__builtin_msa_mod_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_mod_u_h : GCCBuiltin<"__builtin_msa_mod_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_mod_u_w : GCCBuiltin<"__builtin_msa_mod_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_mod_u_d : GCCBuiltin<"__builtin_msa_mod_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_msub_q_h : GCCBuiltin<"__builtin_msa_msub_q_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_msub_q_w : GCCBuiltin<"__builtin_msa_msub_q_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + +def int_mips_msubr_q_h : GCCBuiltin<"__builtin_msa_msubr_q_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_msubr_q_w : GCCBuiltin<"__builtin_msa_msubr_q_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + +def int_mips_msubv_b : GCCBuiltin<"__builtin_msa_msubv_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_msubv_h : GCCBuiltin<"__builtin_msa_msubv_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_msubv_w : GCCBuiltin<"__builtin_msa_msubv_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_msubv_d : GCCBuiltin<"__builtin_msa_msubv_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_mul_q_h : GCCBuiltin<"__builtin_msa_mul_q_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_mul_q_w : GCCBuiltin<"__builtin_msa_mul_q_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + +def int_mips_mulr_q_h : GCCBuiltin<"__builtin_msa_mulr_q_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_mulr_q_w : GCCBuiltin<"__builtin_msa_mulr_q_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + +def int_mips_mulv_b : GCCBuiltin<"__builtin_msa_mulv_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_mulv_h : GCCBuiltin<"__builtin_msa_mulv_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_mulv_w : GCCBuiltin<"__builtin_msa_mulv_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_mulv_d : GCCBuiltin<"__builtin_msa_mulv_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_nloc_b : GCCBuiltin<"__builtin_msa_nloc_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], []>; +def int_mips_nloc_h : GCCBuiltin<"__builtin_msa_nloc_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty], []>; +def int_mips_nloc_w : GCCBuiltin<"__builtin_msa_nloc_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty], []>; +def int_mips_nloc_d : GCCBuiltin<"__builtin_msa_nloc_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty], []>; + +def int_mips_nlzc_b : GCCBuiltin<"__builtin_msa_nlzc_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], []>; +def int_mips_nlzc_h : GCCBuiltin<"__builtin_msa_nlzc_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty], []>; +def int_mips_nlzc_w : GCCBuiltin<"__builtin_msa_nlzc_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty], []>; +def int_mips_nlzc_d : GCCBuiltin<"__builtin_msa_nlzc_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty], []>; + +def int_mips_nori_b : GCCBuiltin<"__builtin_msa_nori_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + +def int_mips_ori_b : GCCBuiltin<"__builtin_msa_ori_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + +def int_mips_pckev_b : GCCBuiltin<"__builtin_msa_pckev_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_pckev_h : GCCBuiltin<"__builtin_msa_pckev_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_pckev_w : GCCBuiltin<"__builtin_msa_pckev_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_pckev_d : GCCBuiltin<"__builtin_msa_pckev_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_pckod_b : GCCBuiltin<"__builtin_msa_pckod_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_pckod_h : GCCBuiltin<"__builtin_msa_pckod_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_pckod_w : GCCBuiltin<"__builtin_msa_pckod_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_pckod_d : GCCBuiltin<"__builtin_msa_pckod_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_pcnt_b : GCCBuiltin<"__builtin_msa_pcnt_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], []>; +def int_mips_pcnt_h : GCCBuiltin<"__builtin_msa_pcnt_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty], []>; +def int_mips_pcnt_w : GCCBuiltin<"__builtin_msa_pcnt_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty], []>; +def int_mips_pcnt_d : GCCBuiltin<"__builtin_msa_pcnt_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty], []>; + +def int_mips_sat_s_b : GCCBuiltin<"__builtin_msa_sat_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_sat_s_h : GCCBuiltin<"__builtin_msa_sat_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_sat_s_w : GCCBuiltin<"__builtin_msa_sat_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_sat_s_d : GCCBuiltin<"__builtin_msa_sat_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_sat_u_b : GCCBuiltin<"__builtin_msa_sat_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_sat_u_h : GCCBuiltin<"__builtin_msa_sat_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_sat_u_w : GCCBuiltin<"__builtin_msa_sat_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_sat_u_d : GCCBuiltin<"__builtin_msa_sat_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_shf_b : GCCBuiltin<"__builtin_msa_shf_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_shf_h : GCCBuiltin<"__builtin_msa_shf_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_shf_w : GCCBuiltin<"__builtin_msa_shf_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + +def int_mips_sld_b : GCCBuiltin<"__builtin_msa_sld_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_sld_h : GCCBuiltin<"__builtin_msa_sld_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_sld_w : GCCBuiltin<"__builtin_msa_sld_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_sld_d : GCCBuiltin<"__builtin_msa_sld_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_sldi_b : GCCBuiltin<"__builtin_msa_sldi_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_sldi_h : GCCBuiltin<"__builtin_msa_sldi_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_sldi_w : GCCBuiltin<"__builtin_msa_sldi_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_sldi_d : GCCBuiltin<"__builtin_msa_sldi_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_sll_b : GCCBuiltin<"__builtin_msa_sll_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_sll_h : GCCBuiltin<"__builtin_msa_sll_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_sll_w : GCCBuiltin<"__builtin_msa_sll_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_sll_d : GCCBuiltin<"__builtin_msa_sll_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_slli_b : GCCBuiltin<"__builtin_msa_slli_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_slli_h : GCCBuiltin<"__builtin_msa_slli_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_slli_w : GCCBuiltin<"__builtin_msa_slli_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_slli_d : GCCBuiltin<"__builtin_msa_slli_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_splat_b : GCCBuiltin<"__builtin_msa_splat_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_splat_h : GCCBuiltin<"__builtin_msa_splat_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_splat_w : GCCBuiltin<"__builtin_msa_splat_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_splat_d : GCCBuiltin<"__builtin_msa_splat_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_splati_b : GCCBuiltin<"__builtin_msa_splati_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_splati_h : GCCBuiltin<"__builtin_msa_splati_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_splati_w : GCCBuiltin<"__builtin_msa_splati_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_splati_d : GCCBuiltin<"__builtin_msa_splati_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_sra_b : GCCBuiltin<"__builtin_msa_sra_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_sra_h : GCCBuiltin<"__builtin_msa_sra_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_sra_w : GCCBuiltin<"__builtin_msa_sra_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_sra_d : GCCBuiltin<"__builtin_msa_sra_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_srai_b : GCCBuiltin<"__builtin_msa_srai_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_srai_h : GCCBuiltin<"__builtin_msa_srai_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_srai_w : GCCBuiltin<"__builtin_msa_srai_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_srai_d : GCCBuiltin<"__builtin_msa_srai_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_srl_b : GCCBuiltin<"__builtin_msa_srl_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; +def int_mips_srl_h : GCCBuiltin<"__builtin_msa_srl_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; +def int_mips_srl_w : GCCBuiltin<"__builtin_msa_srl_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; +def int_mips_srl_d : GCCBuiltin<"__builtin_msa_srl_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + +def int_mips_srli_b : GCCBuiltin<"__builtin_msa_srli_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_srli_h : GCCBuiltin<"__builtin_msa_srli_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; +def int_mips_srli_w : GCCBuiltin<"__builtin_msa_srli_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_srli_d : GCCBuiltin<"__builtin_msa_srli_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + +def int_mips_subs_s_b : GCCBuiltin<"__builtin_msa_subs_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; +def int_mips_subs_s_h : GCCBuiltin<"__builtin_msa_subs_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; +def int_mips_subs_s_w : GCCBuiltin<"__builtin_msa_subs_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; +def int_mips_subs_s_d : GCCBuiltin<"__builtin_msa_subs_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + +def int_mips_subs_u_b : GCCBuiltin<"__builtin_msa_subs_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; +def int_mips_subs_u_h : GCCBuiltin<"__builtin_msa_subs_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; +def int_mips_subs_u_w : GCCBuiltin<"__builtin_msa_subs_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; +def int_mips_subs_u_d : GCCBuiltin<"__builtin_msa_subs_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + +def int_mips_subsus_u_b : GCCBuiltin<"__builtin_msa_subsus_u_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; +def int_mips_subsus_u_h : GCCBuiltin<"__builtin_msa_subsus_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; +def int_mips_subsus_u_w : GCCBuiltin<"__builtin_msa_subsus_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; +def int_mips_subsus_u_d : GCCBuiltin<"__builtin_msa_subsus_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + +def int_mips_subsuu_s_b : GCCBuiltin<"__builtin_msa_subsuu_s_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; +def int_mips_subsuu_s_h : GCCBuiltin<"__builtin_msa_subsuu_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; +def int_mips_subsuu_s_w : GCCBuiltin<"__builtin_msa_subsuu_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; +def int_mips_subsuu_s_d : GCCBuiltin<"__builtin_msa_subsuu_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + +def int_mips_subv_b : GCCBuiltin<"__builtin_msa_subv_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; +def int_mips_subv_h : GCCBuiltin<"__builtin_msa_subv_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; +def int_mips_subv_w : GCCBuiltin<"__builtin_msa_subv_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; +def int_mips_subv_d : GCCBuiltin<"__builtin_msa_subv_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + +def int_mips_subvi_b : GCCBuiltin<"__builtin_msa_subvi_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [Commutative]>; +def int_mips_subvi_h : GCCBuiltin<"__builtin_msa_subvi_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [Commutative]>; +def int_mips_subvi_w : GCCBuiltin<"__builtin_msa_subvi_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [Commutative]>; +def int_mips_subvi_d : GCCBuiltin<"__builtin_msa_subvi_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [Commutative]>; + +def int_mips_vshf_b : GCCBuiltin<"__builtin_msa_vshf_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; +def int_mips_vshf_h : GCCBuiltin<"__builtin_msa_vshf_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; +def int_mips_vshf_w : GCCBuiltin<"__builtin_msa_vshf_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; +def int_mips_vshf_d : GCCBuiltin<"__builtin_msa_vshf_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + +def int_mips_xori_b : GCCBuiltin<"__builtin_msa_xori_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; } -- cgit v1.1 From a370bdb42eaefdb103f971ad2e84c75573d77c68 Mon Sep 17 00:00:00 2001 From: Joey Gouly Date: Thu, 15 Aug 2013 16:02:44 +0000 Subject: Drive-by fix for a doxygen comment in MachineInstr.h. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188467 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineInstr.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index cf5e7e2..e54c5c5 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -397,8 +397,8 @@ public: return isBranch(Type) & isBarrier(Type) & !isIndirectBranch(Type); } - // isPredicable - Return true if this instruction has a predicate operand that - // controls execution. It may be set to 'always', or may be set to other + /// Return true if this instruction has a predicate operand that + /// controls execution. It may be set to 'always', or may be set to other /// values. There are various methods in TargetInstrInfo that can be used to /// control and modify the predicate in this instruction. bool isPredicable(QueryType Type = AllInBundle) const { -- cgit v1.1 From 873e392ffd6701f6724e4c2a7accd0a4e1f1e0a1 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 15 Aug 2013 20:25:44 +0000 Subject: Make a few more things const. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188484 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineModuleInfo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineModuleInfo.h b/include/llvm/CodeGen/MachineModuleInfo.h index 186017c..460c08c 100644 --- a/include/llvm/CodeGen/MachineModuleInfo.h +++ b/include/llvm/CodeGen/MachineModuleInfo.h @@ -234,7 +234,7 @@ public: /// \brief Returns a reference to a list of cfi instructions in the current /// function's prologue. Used to construct frame maps for debug and exception /// handling comsumers. - const std::vector &getFrameInstructions() { + const std::vector &getFrameInstructions() const { return FrameInstructions; } -- cgit v1.1 From d5f33aa33fbf865e15a3dced11b847e88f6a8239 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Thu, 15 Aug 2013 23:17:53 +0000 Subject: Tighten up the yamilizer so it stops eliding empty sequences if the embedded empty sequence is the first key/value in a map which is itself in a sequence. Patch with help from Nick Kledzik. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188508 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/YAMLTraits.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h index 0f57f44..98964fc 100644 --- a/include/llvm/Support/YAMLTraits.h +++ b/include/llvm/Support/YAMLTraits.h @@ -323,6 +323,7 @@ public: virtual bool preflightElement(unsigned, void *&) = 0; virtual void postflightElement(void*) = 0; virtual void endSequence() = 0; + virtual bool canElideEmptySequence() = 0; virtual unsigned beginFlowSequence() = 0; virtual bool preflightFlowElement(unsigned, void *&) = 0; @@ -388,7 +389,7 @@ public: typename llvm::enable_if_c::value,void>::type mapOptional(const char* Key, T& Val) { // omit key/value instead of outputting empty sequence - if ( this->outputting() && !(Val.begin() != Val.end()) ) + if ( this->canElideEmptySequence() && !(Val.begin() != Val.end()) ) return; this->processKey(Key, Val, false); } @@ -715,6 +716,7 @@ private: virtual void endBitSetScalar(); virtual void scalarString(StringRef &); virtual void setError(const Twine &message); + virtual bool canElideEmptySequence(); class HNode { public: @@ -837,7 +839,7 @@ public: virtual void endBitSetScalar(); virtual void scalarString(StringRef &); virtual void setError(const Twine &message); - + virtual bool canElideEmptySequence(); public: // These are only used by operator<<. They could be private // if that templated operator could be made a friend. -- cgit v1.1 From 4e31acb558a7f157244a11ae382c0138ee12d60b Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 16 Aug 2013 02:56:43 +0000 Subject: Calling the base class constructor from the derived class' initializer list. This matches DenseMap's behavior, and silences some warnings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188528 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/DenseMap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/ADT/DenseMap.h b/include/llvm/ADT/DenseMap.h index d5aa864..0b30161 100644 --- a/include/llvm/ADT/DenseMap.h +++ b/include/llvm/ADT/DenseMap.h @@ -713,13 +713,13 @@ public: init(NumInitBuckets); } - SmallDenseMap(const SmallDenseMap &other) { + SmallDenseMap(const SmallDenseMap &other) : BaseT() { init(0); copyFrom(other); } #if LLVM_HAS_RVALUE_REFERENCES - SmallDenseMap(SmallDenseMap &&other) { + SmallDenseMap(SmallDenseMap &&other) : BaseT() { init(0); swap(other); } -- cgit v1.1 From e1b2af731e2a45344a7c502232f66c55cd746da0 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Fri, 16 Aug 2013 11:21:54 +0000 Subject: [SystemZ] Use CLST to implement strcmp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188544 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLibraryInfo.h | 2 +- include/llvm/Target/TargetSelectionDAGInfo.h | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Target/TargetLibraryInfo.h b/include/llvm/Target/TargetLibraryInfo.h index d0245ba..a033d07 100644 --- a/include/llvm/Target/TargetLibraryInfo.h +++ b/include/llvm/Target/TargetLibraryInfo.h @@ -699,7 +699,7 @@ public: case LibFunc::trunc: case LibFunc::truncf: case LibFunc::truncl: case LibFunc::log2: case LibFunc::log2f: case LibFunc::log2l: case LibFunc::exp2: case LibFunc::exp2f: case LibFunc::exp2l: - case LibFunc::memcmp: + case LibFunc::memcmp: case LibFunc::strcmp: return true; } return false; diff --git a/include/llvm/Target/TargetSelectionDAGInfo.h b/include/llvm/Target/TargetSelectionDAGInfo.h index 35da1d7..2d0989c 100644 --- a/include/llvm/Target/TargetSelectionDAGInfo.h +++ b/include/llvm/Target/TargetSelectionDAGInfo.h @@ -108,6 +108,20 @@ public: MachinePointerInfo Op2PtrInfo) const { return std::make_pair(SDValue(), SDValue()); } + + /// EmitTargetCodeForStrcmp - Emit target-specific code that performs a + /// strcmp, in cases where that is faster than a libcall. The first + /// returned SDValue is the result of the strcmp and the second is + /// the chain. Both SDValues can be null if a normal libcall should + /// be used. + virtual std::pair + EmitTargetCodeForStrcmp(SelectionDAG &DAG, SDLoc dl, + SDValue Chain, + SDValue Op1, SDValue Op2, + MachinePointerInfo Op1PtrInfo, + MachinePointerInfo Op2PtrInfo) const { + return std::make_pair(SDValue(), SDValue()); + } }; } // end llvm namespace -- cgit v1.1 From 4fc7355a21e1fa838406e15459aaf54a58fcf909 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Fri, 16 Aug 2013 11:29:37 +0000 Subject: [SystemZ] Use MVST to implement strcpy and stpcpy git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188546 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLibraryInfo.h | 3 ++- include/llvm/Target/TargetSelectionDAGInfo.h | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Target/TargetLibraryInfo.h b/include/llvm/Target/TargetLibraryInfo.h index a033d07..7a06415 100644 --- a/include/llvm/Target/TargetLibraryInfo.h +++ b/include/llvm/Target/TargetLibraryInfo.h @@ -699,7 +699,8 @@ public: case LibFunc::trunc: case LibFunc::truncf: case LibFunc::truncl: case LibFunc::log2: case LibFunc::log2f: case LibFunc::log2l: case LibFunc::exp2: case LibFunc::exp2f: case LibFunc::exp2l: - case LibFunc::memcmp: case LibFunc::strcmp: + case LibFunc::memcmp: case LibFunc::strcmp: case LibFunc::strcpy: + case LibFunc::stpcpy: return true; } return false; diff --git a/include/llvm/Target/TargetSelectionDAGInfo.h b/include/llvm/Target/TargetSelectionDAGInfo.h index 2d0989c..5e65c30 100644 --- a/include/llvm/Target/TargetSelectionDAGInfo.h +++ b/include/llvm/Target/TargetSelectionDAGInfo.h @@ -109,6 +109,21 @@ public: return std::make_pair(SDValue(), SDValue()); } + /// EmitTargetCodeForStrcpy - Emit target-specific code that performs a + /// strcpy or stpcpy, in cases where that is faster than a libcall. + /// The first returned SDValue is the result of the copy (the start + /// of the destination string for strcpy, a pointer to the null terminator + /// for stpcpy) and the second is the chain. Both SDValues can be null + /// if a normal libcall should be used. + virtual std::pair + EmitTargetCodeForStrcpy(SelectionDAG &DAG, SDLoc DL, SDValue Chain, + SDValue Dest, SDValue Src, + MachinePointerInfo DestPtrInfo, + MachinePointerInfo SrcPtrInfo, + bool isStpcpy) const { + return std::make_pair(SDValue(), SDValue()); + } + /// EmitTargetCodeForStrcmp - Emit target-specific code that performs a /// strcmp, in cases where that is faster than a libcall. The first /// returned SDValue is the result of the strcmp and the second is -- cgit v1.1 From 19262ee0725a09b7c621a3d2eb66ba1513ae932a Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Fri, 16 Aug 2013 11:41:43 +0000 Subject: [SystemZ] Use SRST to implement strlen and strnlen It would also make sense to use it for memchr; I'm working on that now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188547 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLibraryInfo.h | 2 +- include/llvm/Target/TargetSelectionDAGInfo.h | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Target/TargetLibraryInfo.h b/include/llvm/Target/TargetLibraryInfo.h index 7a06415..50b16a3 100644 --- a/include/llvm/Target/TargetLibraryInfo.h +++ b/include/llvm/Target/TargetLibraryInfo.h @@ -700,7 +700,7 @@ public: case LibFunc::log2: case LibFunc::log2f: case LibFunc::log2l: case LibFunc::exp2: case LibFunc::exp2f: case LibFunc::exp2l: case LibFunc::memcmp: case LibFunc::strcmp: case LibFunc::strcpy: - case LibFunc::stpcpy: + case LibFunc::stpcpy: case LibFunc::strlen: case LibFunc::strnlen: return true; } return false; diff --git a/include/llvm/Target/TargetSelectionDAGInfo.h b/include/llvm/Target/TargetSelectionDAGInfo.h index 5e65c30..138ff48 100644 --- a/include/llvm/Target/TargetSelectionDAGInfo.h +++ b/include/llvm/Target/TargetSelectionDAGInfo.h @@ -137,6 +137,19 @@ public: MachinePointerInfo Op2PtrInfo) const { return std::make_pair(SDValue(), SDValue()); } + + virtual std::pair + EmitTargetCodeForStrlen(SelectionDAG &DAG, SDLoc DL, SDValue Chain, + SDValue Src, MachinePointerInfo SrcPtrInfo) const { + return std::make_pair(SDValue(), SDValue()); + } + + virtual std::pair + EmitTargetCodeForStrnlen(SelectionDAG &DAG, SDLoc DL, SDValue Chain, + SDValue Src, SDValue MaxLength, + MachinePointerInfo SrcPtrInfo) const { + return std::make_pair(SDValue(), SDValue()); + } }; } // end llvm namespace -- cgit v1.1 From 0009850524f72183c49b506f3eb4c3bdc5f3a0d4 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Fri, 16 Aug 2013 17:33:57 +0000 Subject: Removing unused functionality. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188565 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Process.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/Process.h b/include/llvm/Support/Process.h index 0baf7b9..a23c4ad 100644 --- a/include/llvm/Support/Process.h +++ b/include/llvm/Support/Process.h @@ -155,16 +155,6 @@ public: static void GetTimeUsage(TimeValue &elapsed, TimeValue &user_time, TimeValue &sys_time); - /// This static function will return the process' current user id number. - /// Not all operating systems support this feature. Where it is not - /// supported, the function should return 65536 as the value. - static int GetCurrentUserId(); - - /// This static function will return the process' current group id number. - /// Not all operating systems support this feature. Where it is not - /// supported, the function should return 65536 as the value. - static int GetCurrentGroupId(); - /// This function makes the necessary calls to the operating system to /// prevent core files or any other kind of large memory dumps that can /// occur when a program fails. -- cgit v1.1 From 692062f18023979c0f8d5a155c14cf1f1616a2b0 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 16 Aug 2013 20:42:14 +0000 Subject: DebugInfo: Allow the addition of other (such as static data) members to a record type after construction Plus a type cleanup & minor fix to enumerate members of declarations. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188577 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DIBuilder.h | 8 +++++--- include/llvm/DebugInfo.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm/DIBuilder.h b/include/llvm/DIBuilder.h index a15d619..941ed04 100644 --- a/include/llvm/DIBuilder.h +++ b/include/llvm/DIBuilder.h @@ -419,9 +419,11 @@ namespace llvm { DIType createObjectPointerType(DIType Ty); /// createForwardDecl - Create a temporary forward-declared type. - DIType createForwardDecl(unsigned Tag, StringRef Name, DIDescriptor Scope, - DIFile F, unsigned Line, unsigned RuntimeLang = 0, - uint64_t SizeInBits = 0, uint64_t AlignInBits = 0); + DICompositeType createForwardDecl(unsigned Tag, StringRef Name, + DIDescriptor Scope, DIFile F, + unsigned Line, unsigned RuntimeLang = 0, + uint64_t SizeInBits = 0, + uint64_t AlignInBits = 0); /// retainType - Retain DIType in a module even if it is not referenced /// through debug info anchors. diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index b02446a..2efc730 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -323,7 +323,7 @@ namespace llvm { DIArray getTypeArray() const { return getFieldAs(10); } void setTypeArray(DIArray Elements, DIArray TParams = DIArray()); - void addMember(DISubprogram S); + void addMember(DIDescriptor D); unsigned getRunTimeLang() const { return getUnsignedField(11); } DICompositeType getContainingType() const { return getFieldAs(12); -- cgit v1.1 From d861b90fe264ec42b941162ca920fadd0a80a1c1 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 16 Aug 2013 21:55:56 +0000 Subject: Add difference_type to ImmutableMap/Set iterators so they have a complete set of typedefs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188579 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/ImmutableMap.h | 1 + include/llvm/ADT/ImmutableSet.h | 1 + 2 files changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm/ADT/ImmutableMap.h b/include/llvm/ADT/ImmutableMap.h index a667479..8f8fb98 100644 --- a/include/llvm/ADT/ImmutableMap.h +++ b/include/llvm/ADT/ImmutableMap.h @@ -211,6 +211,7 @@ public: friend class ImmutableMap; public: + typedef ptrdiff_t difference_type; typedef typename ImmutableMap::value_type value_type; typedef typename ImmutableMap::value_type_ref reference; typedef typename iterator::value_type *pointer; diff --git a/include/llvm/ADT/ImmutableSet.h b/include/llvm/ADT/ImmutableSet.h index fbdf066..2a0579e 100644 --- a/include/llvm/ADT/ImmutableSet.h +++ b/include/llvm/ADT/ImmutableSet.h @@ -1060,6 +1060,7 @@ public: friend class ImmutableSet; public: + typedef ptrdiff_t difference_type; typedef typename ImmutableSet::value_type value_type; typedef typename ImmutableSet::value_type_ref reference; typedef typename iterator::value_type *pointer; -- cgit v1.1 From b2820859240b8b8ad03384207ce896da60702f98 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 16 Aug 2013 22:09:02 +0000 Subject: allow != to compare PointerUnion, we already support ==. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188582 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/PointerUnion.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/ADT/PointerUnion.h b/include/llvm/ADT/PointerUnion.h index c1a6d74..045cf2b 100644 --- a/include/llvm/ADT/PointerUnion.h +++ b/include/llvm/ADT/PointerUnion.h @@ -177,10 +177,17 @@ namespace llvm { }; template - bool operator==(PointerUnion lhs, PointerUnion rhs) { + static bool operator==(PointerUnion lhs, + PointerUnion rhs) { return lhs.getOpaqueValue() == rhs.getOpaqueValue(); } - + + template + static bool operator!=(PointerUnion lhs, + PointerUnion rhs) { + return lhs.getOpaqueValue() == rhs.getOpaqueValue(); + } + // Teach SmallPtrSet that PointerUnion is "basically a pointer", that has // # low bits available = min(PT1bits,PT2bits)-1. template -- cgit v1.1 From 586ea17be9fbf2fa1f2341900ebf1675a0924edc Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 16 Aug 2013 22:29:44 +0000 Subject: I'm told that != is not == git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188583 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/PointerUnion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/ADT/PointerUnion.h b/include/llvm/ADT/PointerUnion.h index 045cf2b..4eed121 100644 --- a/include/llvm/ADT/PointerUnion.h +++ b/include/llvm/ADT/PointerUnion.h @@ -185,7 +185,7 @@ namespace llvm { template static bool operator!=(PointerUnion lhs, PointerUnion rhs) { - return lhs.getOpaqueValue() == rhs.getOpaqueValue(); + return lhs.getOpaqueValue() != rhs.getOpaqueValue(); } // Teach SmallPtrSet that PointerUnion is "basically a pointer", that has -- cgit v1.1 From 13230064236e0cb916cefddcd75bd55d9ce15c41 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 16 Aug 2013 23:30:19 +0000 Subject: [typo] An LLVM. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188589 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 22 +++++++++++----------- include/llvm/CodeGen/MachineRelocation.h | 2 +- include/llvm/CodeGen/PseudoSourceValue.h | 2 +- include/llvm/TableGen/TableGenBackend.h | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 409c0f1..a7d17b7 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -460,7 +460,7 @@ unsigned LLVMGetMDKindID(const char* Name, unsigned SLen); /** * @defgroup LLVMCCoreModule Modules * - * Modules represent the top-level structure in a LLVM program. An LLVM + * Modules represent the top-level structure in an LLVM program. An LLVM * module is effectively a translation unit or a collection of * translation units merged together. * @@ -1041,7 +1041,7 @@ LLVMTypeRef LLVMX86MMXType(void); * hierarchy of classes within this type. Depending on the instance * obtained, not all APIs are available. * - * Callers can determine the type of a LLVMValueRef by calling the + * Callers can determine the type of an LLVMValueRef by calling the * LLVMIsA* family of functions (e.g. LLVMIsAArgument()). These * functions are defined by a macro, so it isn't obvious which are * available by looking at the Doxygen source code. Instead, look at the @@ -1181,7 +1181,7 @@ LLVMBool LLVMIsUndef(LLVMValueRef Val); /** * Convert value instances between types. * - * Internally, a LLVMValueRef is "pinned" to a specific type. This + * Internally, an LLVMValueRef is "pinned" to a specific type. This * series of functions allows you to cast an instance to a specific * type. * @@ -1203,7 +1203,7 @@ LLVM_FOR_EACH_VALUE_SUBCLASS(LLVM_DECLARE_VALUE_CAST) * This module defines functions that allow you to inspect the uses of a * LLVMValueRef. * - * It is possible to obtain a LLVMUseRef for any LLVMValueRef instance. + * It is possible to obtain an LLVMUseRef for any LLVMValueRef instance. * Each LLVMUseRef (which corresponds to a llvm::Use instance) holds a * llvm::User and llvm::Value. * @@ -1806,7 +1806,7 @@ LLVMValueRef LLVMGetParam(LLVMValueRef Fn, unsigned Index); /** * Obtain the function to which this argument belongs. * - * Unlike other functions in this group, this one takes a LLVMValueRef + * Unlike other functions in this group, this one takes an LLVMValueRef * that corresponds to a llvm::Attribute. * * The returned LLVMValueRef is the llvm::Function to which this @@ -1831,7 +1831,7 @@ LLVMValueRef LLVMGetLastParam(LLVMValueRef Fn); /** * Obtain the next parameter to a function. * - * This takes a LLVMValueRef obtained from LLVMGetFirstParam() (which is + * This takes an LLVMValueRef obtained from LLVMGetFirstParam() (which is * actually a wrapped iterator) and obtains the next parameter from the * underlying iterator. */ @@ -1980,12 +1980,12 @@ void LLVMGetMDNodeOperands(LLVMValueRef V, LLVMValueRef *Dest); LLVMValueRef LLVMBasicBlockAsValue(LLVMBasicBlockRef BB); /** - * Determine whether a LLVMValueRef is itself a basic block. + * Determine whether an LLVMValueRef is itself a basic block. */ LLVMBool LLVMValueIsBasicBlock(LLVMValueRef Val); /** - * Convert a LLVMValueRef to a LLVMBasicBlockRef instance. + * Convert an LLVMValueRef to an LLVMBasicBlockRef instance. */ LLVMBasicBlockRef LLVMValueAsBasicBlock(LLVMValueRef Val); @@ -2142,7 +2142,7 @@ LLVMValueRef LLVMGetFirstInstruction(LLVMBasicBlockRef BB); /** * Obtain the last instruction in a basic block. * - * The returned LLVMValueRef corresponds to a LLVM:Instruction. + * The returned LLVMValueRef corresponds to an LLVM:Instruction. */ LLVMValueRef LLVMGetLastInstruction(LLVMBasicBlockRef BB); @@ -2324,12 +2324,12 @@ void LLVMAddIncoming(LLVMValueRef PhiNode, LLVMValueRef *IncomingValues, unsigned LLVMCountIncoming(LLVMValueRef PhiNode); /** - * Obtain an incoming value to a PHI node as a LLVMValueRef. + * Obtain an incoming value to a PHI node as an LLVMValueRef. */ LLVMValueRef LLVMGetIncomingValue(LLVMValueRef PhiNode, unsigned Index); /** - * Obtain an incoming value to a PHI node as a LLVMBasicBlockRef. + * Obtain an incoming value to a PHI node as an LLVMBasicBlockRef. */ LLVMBasicBlockRef LLVMGetIncomingBlock(LLVMValueRef PhiNode, unsigned Index); diff --git a/include/llvm/CodeGen/MachineRelocation.h b/include/llvm/CodeGen/MachineRelocation.h index 244b466..e778457 100644 --- a/include/llvm/CodeGen/MachineRelocation.h +++ b/include/llvm/CodeGen/MachineRelocation.h @@ -57,7 +57,7 @@ class MachineRelocation { union { void *Result; // If this has been resolved to a resolved pointer GlobalValue *GV; // If this is a pointer to a GV or an indirect ref. - MachineBasicBlock *MBB; // If this is a pointer to a LLVM BB + MachineBasicBlock *MBB; // If this is a pointer to an LLVM BB const char *ExtSym; // If this is a pointer to a named symbol unsigned Index; // Constant pool / jump table index unsigned GOTIndex; // Index in the GOT of this symbol/global diff --git a/include/llvm/CodeGen/PseudoSourceValue.h b/include/llvm/CodeGen/PseudoSourceValue.h index df74d088..705086c 100644 --- a/include/llvm/CodeGen/PseudoSourceValue.h +++ b/include/llvm/CodeGen/PseudoSourceValue.h @@ -44,7 +44,7 @@ namespace llvm { virtual bool isAliased(const MachineFrameInfo *) const; /// mayAlias - Return true if the memory pointed to by this - /// PseudoSourceValue can ever alias a LLVM IR Value. + /// PseudoSourceValue can ever alias an LLVM IR Value. virtual bool mayAlias(const MachineFrameInfo *) const; /// classof - Methods for support type inquiry through isa, cast, and diff --git a/include/llvm/TableGen/TableGenBackend.h b/include/llvm/TableGen/TableGenBackend.h index bedf7fb..3e4f3cc 100644 --- a/include/llvm/TableGen/TableGenBackend.h +++ b/include/llvm/TableGen/TableGenBackend.h @@ -20,7 +20,7 @@ namespace llvm { class raw_ostream; -/// emitSourceFileHeader - Output a LLVM style file header to the specified +/// emitSourceFileHeader - Output an LLVM style file header to the specified /// raw_ostream. void emitSourceFileHeader(StringRef Desc, raw_ostream &OS); -- cgit v1.1 From 68af19cbb1faec31dad274601d8937c2da9794c2 Mon Sep 17 00:00:00 2001 From: Juergen Ributzka Date: Sat, 17 Aug 2013 16:38:37 +0000 Subject: The vbroadcastsi256 intrinsic does not exactly resemble the GCC builtin. The GCC builtin expects the arguments to be passed by val, whereas the LLVM intrinsic expects a pointer instead. This is related to PR 16581 and rdar:14747994. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188608 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index c7675c2..f1728b7 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -1635,7 +1635,6 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". GCCBuiltin<"__builtin_ia32_vbroadcastss_ps256">, Intrinsic<[llvm_v8f32_ty], [llvm_v4f32_ty], [IntrNoMem]>; def int_x86_avx2_vbroadcasti128 : - GCCBuiltin<"__builtin_ia32_vbroadcastsi256">, Intrinsic<[llvm_v4i64_ty], [llvm_ptr_ty], [IntrReadArgMem]>; def int_x86_avx2_pbroadcastb_128 : GCCBuiltin<"__builtin_ia32_pbroadcastb128">, -- cgit v1.1 From 353149ea2f8d4d3bf1ec82e90f80154c6959d56e Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 19 Aug 2013 00:24:20 +0000 Subject: Remove SpecialCaseList::findCategory. It turned out that I didn't need this for DFSan. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188646 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/Utils/SpecialCaseList.h | 16 ---------------- 1 file changed, 16 deletions(-) (limited to 'include') diff --git a/include/llvm/Transforms/Utils/SpecialCaseList.h b/include/llvm/Transforms/Utils/SpecialCaseList.h index bf95ec0..90eace1 100644 --- a/include/llvm/Transforms/Utils/SpecialCaseList.h +++ b/include/llvm/Transforms/Utils/SpecialCaseList.h @@ -83,20 +83,6 @@ class SpecialCaseList { /// omitted to search the empty category. bool isIn(const Module &M, const StringRef Category = StringRef()) const; - /// Returns whether either this function or its source file are listed in any - /// category. Category will contain the name of an arbitrary category in - /// which this function is listed. - bool findCategory(const Function &F, StringRef &Category) const; - - /// Returns whether this global, its type or its source file are listed in any - /// category. Category will contain the name of an arbitrary category in - /// which this global is listed. - bool findCategory(const GlobalVariable &G, StringRef &Category) const; - - /// Returns whether this module is listed in any category. Category will - /// contain the name of an arbitrary category in which this module is listed. - bool findCategory(const Module &M, StringRef &Category) const; - private: SpecialCaseList(SpecialCaseList const &) LLVM_DELETED_FUNCTION; SpecialCaseList &operator=(SpecialCaseList const &) LLVM_DELETED_FUNCTION; @@ -108,8 +94,6 @@ class SpecialCaseList { /// Parses just-constructed SpecialCaseList entries from a memory buffer. bool parse(const MemoryBuffer *MB, std::string &Error); - bool findCategory(const StringRef Section, const StringRef Query, - StringRef &Category) const; bool inSectionCategory(const StringRef Section, const StringRef Query, const StringRef Category) const; }; -- cgit v1.1 From c892bd6a74ba92b5631c89cfac8961a8005b644a Mon Sep 17 00:00:00 2001 From: Elena Demikhovsky Date: Mon, 19 Aug 2013 06:55:01 +0000 Subject: AVX-512: compiler intrinsics git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188654 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 263 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 263 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index f1728b7..c7a68da 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -1199,6 +1199,10 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". Intrinsic<[llvm_v4i32_ty], [llvm_v4f64_ty], [IntrNoMem]>; def int_x86_avx_cvtt_ps2dq_256 : GCCBuiltin<"__builtin_ia32_cvttps2dq256">, Intrinsic<[llvm_v8i32_ty], [llvm_v8f32_ty], [IntrNoMem]>; + def int_x86_avx512_cvt_ps2dq_512 : GCCBuiltin<"__builtin_ia32_cvtps2dq512">, + Intrinsic<[llvm_v16i32_ty], [llvm_v16f32_ty], [IntrNoMem]>; + def int_x86_avx512_cvtdq2_ps_512 : GCCBuiltin<"__builtin_ia32_cvtdq2ps512">, + Intrinsic<[llvm_v16f32_ty], [llvm_v16i32_ty], [IntrNoMem]>; } // Vector bit test @@ -1283,6 +1287,12 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx_vbroadcastf128_ps_256 : GCCBuiltin<"__builtin_ia32_vbroadcastf128_ps256">, Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty], [IntrReadArgMem]>; + def int_x86_avx512_vbroadcast_sd_512 : + GCCBuiltin<"__builtin_ia32_vbroadcastsd512">, + Intrinsic<[llvm_v8f64_ty], [llvm_ptr_ty], [IntrReadArgMem]>; + def int_x86_avx512_vbroadcast_ss_512 : + GCCBuiltin<"__builtin_ia32_vbroadcastss512">, + Intrinsic<[llvm_v16f32_ty], [llvm_ptr_ty], [IntrReadArgMem]>; } // SIMD load ops @@ -1494,6 +1504,19 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx2_psrl_dq_bs : GCCBuiltin<"__builtin_ia32_psrldqi256_byteshift">, Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_i32_ty], [IntrNoMem]>; + + def int_x86_avx512_psll_dq : GCCBuiltin<"__builtin_ia32_pslldqi512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_avx512_psrl_dq : GCCBuiltin<"__builtin_ia32_psrldqi512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_avx512_psll_dq_bs : GCCBuiltin<"__builtin_ia32_pslldqi512_byteshift">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_avx512_psrl_dq_bs : GCCBuiltin<"__builtin_ia32_psrldqi512_byteshift">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, + llvm_i32_ty], [IntrNoMem]>; } // Pack ops. @@ -1605,6 +1628,22 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx2_pmovzxwq : GCCBuiltin<"__builtin_ia32_pmovzxwq256">, Intrinsic<[llvm_v4i64_ty], [llvm_v8i16_ty], [IntrNoMem]>; + // AVX-512 + def int_x86_avx512_pmovzxbq : GCCBuiltin<"__builtin_ia32_pmovzxbq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v16i8_ty], + [IntrNoMem]>; + def int_x86_avx512_pmovzxwd : GCCBuiltin<"__builtin_ia32_pmovzxwd512">, + Intrinsic<[llvm_v16i32_ty], [llvm_v16i16_ty], + [IntrNoMem]>; + def int_x86_avx512_pmovzxbd : GCCBuiltin<"__builtin_ia32_pmovzxbd512">, + Intrinsic<[llvm_v16i32_ty], [llvm_v16i8_ty], + [IntrNoMem]>; + def int_x86_avx512_pmovzxwq : GCCBuiltin<"__builtin_ia32_pmovzxwq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i16_ty], + [IntrNoMem]>; + def int_x86_avx512_pmovzxdq : GCCBuiltin<"__builtin_ia32_pmovzxdq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i32_ty], + [IntrNoMem]>; } // Vector blend @@ -1631,9 +1670,15 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx2_vbroadcast_sd_pd_256 : GCCBuiltin<"__builtin_ia32_vbroadcastsd_pd256">, Intrinsic<[llvm_v4f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; + def int_x86_avx512_vbroadcast_sd_pd_512 : + GCCBuiltin<"__builtin_ia32_vbroadcastsd_pd512">, + Intrinsic<[llvm_v8f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; def int_x86_avx2_vbroadcast_ss_ps_256 : GCCBuiltin<"__builtin_ia32_vbroadcastss_ps256">, Intrinsic<[llvm_v8f32_ty], [llvm_v4f32_ty], [IntrNoMem]>; + def int_x86_avx512_vbroadcast_ss_ps_512 : + GCCBuiltin<"__builtin_ia32_vbroadcastss_ps512">, + Intrinsic<[llvm_v16f32_ty], [llvm_v4f32_ty], [IntrNoMem]>; def int_x86_avx2_vbroadcasti128 : Intrinsic<[llvm_v4i64_ty], [llvm_ptr_ty], [IntrReadArgMem]>; def int_x86_avx2_pbroadcastb_128 : @@ -2616,3 +2661,221 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". Intrinsic<[llvm_i32_ty], [llvm_i16_ty, llvm_i16_ty], [IntrNoMem]>; } + +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx512_min_ps_512 : GCCBuiltin<"__builtin_ia32_minps512">, + Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, + llvm_v16f32_ty], [IntrNoMem]>; + def int_x86_avx512_min_pd_512 : GCCBuiltin<"__builtin_ia32_minpd512">, + Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, + llvm_v8f64_ty], [IntrNoMem]>; + def int_x86_avx512_max_ps_512 : GCCBuiltin<"__builtin_ia32_maxps512">, + Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, + llvm_v16f32_ty], [IntrNoMem]>; + def int_x86_avx512_max_pd_512 : GCCBuiltin<"__builtin_ia32_maxpd512">, + Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, + llvm_v8f64_ty], [IntrNoMem]>; +} + +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx512_rndscale_ss : GCCBuiltin<"__builtin_ia32_rndscaless">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_avx512_rndscale_sd : GCCBuiltin<"__builtin_ia32_rndscalesd">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_avx512_sqrt_ss : GCCBuiltin<"__builtin_ia32_sqrtrndss">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], + [IntrNoMem]>; + def int_x86_avx512_sqrt_sd : GCCBuiltin<"__builtin_ia32_sqrtrndsd">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], + [IntrNoMem]>; + + def int_x86_avx512_rndscale_ps_512 : GCCBuiltin<"__builtin_ia32_rndscaleps512">, + Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_avx512_rndscale_pd_512 : GCCBuiltin<"__builtin_ia32_rndscalepd512">, + Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, + llvm_i32_ty], [IntrNoMem]>; + + def int_x86_avx512_sqrt_pd_512 : GCCBuiltin<"__builtin_ia32_sqrtpd512">, + Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty], [IntrNoMem]>; + def int_x86_avx512_sqrt_ps_512 : GCCBuiltin<"__builtin_ia32_sqrtps512">, + Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty], [IntrNoMem]>; + + def int_x86_avx512_rcp14_ps_512 : GCCBuiltin<"__builtin_ia32_avx512_rcp14ps512">, + Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty], + [IntrNoMem]>; + def int_x86_avx512_rcp14_pd_512 : GCCBuiltin<"__builtin_ia32_avx512_rcp14pd512">, + Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty], + [IntrNoMem]>; + def int_x86_avx512_rcp14_ss : GCCBuiltin<"__builtin_ia32_avx512_rcp14ss">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], + [IntrNoMem]>; + def int_x86_avx512_rcp14_sd : GCCBuiltin<"__builtin_ia32_avx512_rcp14sd">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], + [IntrNoMem]>; + def int_x86_avx512_rsqrt14_ps_512 : GCCBuiltin<"__builtin_ia32_avx512_rsqrt14ps512">, + Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty], + [IntrNoMem]>; + def int_x86_avx512_rsqrt14_pd_512 : GCCBuiltin<"__builtin_ia32_avx512_rsqrt14pd512">, + Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty], + [IntrNoMem]>; + def int_x86_avx512_rsqrt14_ss : GCCBuiltin<"__builtin_ia32_avx512_rsqrt14ss">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], + [IntrNoMem]>; + def int_x86_avx512_rsqrt14_sd : GCCBuiltin<"__builtin_ia32_avx512_rsqrt14sd">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], + [IntrNoMem]>; +} + +let TargetPrefix = "x86" in { + def int_x86_avx512_gather_dpd_mask_512 : GCCBuiltin<"__builtin_ia32_mask_gatherdpd512">, + Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_i8_ty, + llvm_v8i32_ty, llvm_ptr_ty, llvm_i32_ty], + [IntrReadMem]>; + def int_x86_avx512_gather_dps_mask_512 : GCCBuiltin<"__builtin_ia32_mask_gatherdps512">, + Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, llvm_i16_ty, + llvm_v16i32_ty, llvm_ptr_ty, llvm_i32_ty], + [IntrReadMem]>; + def int_x86_avx512_gather_qpd_mask_512 : GCCBuiltin<"__builtin_ia32_mask_gatherqpd512">, + Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_i8_ty, + llvm_v8i64_ty, llvm_ptr_ty, llvm_i32_ty], + [IntrReadMem]>; + def int_x86_avx512_gather_qps_mask_512 : GCCBuiltin<"__builtin_ia32_mask_gatherqps512">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_i8_ty, + llvm_v8i64_ty, llvm_ptr_ty, llvm_i32_ty], + [IntrReadMem]>; + + def int_x86_avx512_gather_dpd_512 : GCCBuiltin<"__builtin_ia32_gatherdpd512">, + Intrinsic<[llvm_v8f64_ty], [llvm_v8i32_ty, llvm_ptr_ty, + llvm_i32_ty], + [IntrReadMem]>; + def int_x86_avx512_gather_dps_512 : GCCBuiltin<"__builtin_ia32_gatherdps512">, + Intrinsic<[llvm_v16f32_ty], [llvm_v16i32_ty, llvm_ptr_ty, + llvm_i32_ty], + [IntrReadMem]>; + def int_x86_avx512_gather_qpd_512 : GCCBuiltin<"__builtin_ia32_gatherqpd512">, + Intrinsic<[llvm_v8f64_ty], [llvm_v8i64_ty, llvm_ptr_ty, + llvm_i32_ty], + [IntrReadArgMem]>; + def int_x86_avx512_gather_qps_512 : GCCBuiltin<"__builtin_ia32_gatherqps512">, + Intrinsic<[llvm_v8f32_ty], [llvm_v8i64_ty, llvm_ptr_ty, + llvm_i32_ty], + [IntrReadMem]>; + + def int_x86_avx512_gather_dpq_mask_512 : GCCBuiltin<"__builtin_ia32_mask_gatherdpq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_i8_ty, + llvm_v8i32_ty, llvm_ptr_ty, llvm_i32_ty], + [IntrReadMem]>; + def int_x86_avx512_gather_dpi_mask_512 : GCCBuiltin<"__builtin_ia32_mask_gatherdpi512">, + Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_i16_ty, + llvm_v16i32_ty, llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; + def int_x86_avx512_gather_qpq_mask_512 : GCCBuiltin<"__builtin_ia32_mask_gatherqpq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_i8_ty, + llvm_v8i64_ty, llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; + def int_x86_avx512_gather_qpi_mask_512 : GCCBuiltin<"__builtin_ia32_mask_gatherqpi512">, + Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_i8_ty, + llvm_v8i64_ty, llvm_ptr_ty, llvm_i32_ty], + [IntrReadMem]>; + + def int_x86_avx512_gather_dpq_512 : GCCBuiltin<"__builtin_ia32_gatherdpq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i32_ty, llvm_ptr_ty, + llvm_i32_ty], + [IntrReadArgMem]>; + def int_x86_avx512_gather_dpi_512 : GCCBuiltin<"__builtin_ia32_gatherdpi512">, + Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_ptr_ty, + llvm_i32_ty], + [IntrReadArgMem]>; + def int_x86_avx512_gather_qpq_512 : GCCBuiltin<"__builtin_ia32_gatherqpq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_ptr_ty, + llvm_i32_ty], + [IntrReadArgMem]>; + def int_x86_avx512_gather_qpi_512 : GCCBuiltin<"__builtin_ia32_gatherqpi512">, + Intrinsic<[llvm_v8i32_ty], [llvm_v8i64_ty, llvm_ptr_ty, + llvm_i32_ty], + [IntrReadArgMem]>; +// scatter + def int_x86_avx512_scatter_dpd_mask_512 : GCCBuiltin<"__builtin_ia32_mask_scatterdpd512">, + Intrinsic<[], [llvm_ptr_ty, llvm_i8_ty, + llvm_v8i32_ty, llvm_v8f64_ty, llvm_i32_ty], + [IntrReadWriteArgMem]>; + def int_x86_avx512_scatter_dps_mask_512 : GCCBuiltin<"__builtin_ia32_mask_scatterdps512">, + Intrinsic<[], [llvm_ptr_ty, llvm_i16_ty, + llvm_v16i32_ty, llvm_v16f32_ty, llvm_i32_ty], + [IntrReadWriteArgMem]>; + def int_x86_avx512_scatter_qpd_mask_512 : GCCBuiltin<"__builtin_ia32_mask_scatterqpd512">, + Intrinsic<[], [llvm_ptr_ty, llvm_i8_ty, + llvm_v8i64_ty, llvm_v8f64_ty, llvm_i32_ty], + [IntrReadWriteArgMem]>; + def int_x86_avx512_scatter_qps_mask_512 : GCCBuiltin<"__builtin_ia32_mask_scatterqps512">, + Intrinsic<[], [llvm_ptr_ty, llvm_i8_ty, + llvm_v8i64_ty, llvm_v8f32_ty, llvm_i32_ty], + [IntrReadWriteArgMem]>; + + def int_x86_avx512_scatter_dpd_512 : GCCBuiltin<"__builtin_ia32_scatterdpd512">, + Intrinsic<[], [llvm_ptr_ty, llvm_v8i32_ty, llvm_v8f64_ty, + llvm_i32_ty], + [IntrReadWriteArgMem]>; + def int_x86_avx512_scatter_dps_512 : GCCBuiltin<"__builtin_ia32_scatterdps512">, + Intrinsic<[], [llvm_ptr_ty, llvm_v16i32_ty, llvm_v16f32_ty, + llvm_i32_ty], + [IntrReadWriteArgMem]>; + def int_x86_avx512_scatter_qpd_512 : GCCBuiltin<"__builtin_ia32_scatterqpd512">, + Intrinsic<[], [llvm_ptr_ty, llvm_v8i64_ty, llvm_v8f64_ty, + llvm_i32_ty], + [IntrReadWriteArgMem]>; + def int_x86_avx512_scatter_qps_512 : GCCBuiltin<"__builtin_ia32_scatterqps512">, + Intrinsic<[], [llvm_ptr_ty, llvm_v8i64_ty, llvm_v8f32_ty, + llvm_i32_ty], + [IntrReadWriteArgMem]>; + + def int_x86_avx512_scatter_dpq_mask_512 : GCCBuiltin<"__builtin_ia32_mask_scatterdpq512">, + Intrinsic<[], [llvm_ptr_ty, llvm_i8_ty, llvm_v8i32_ty, + llvm_v8i64_ty, llvm_i32_ty], + [IntrReadWriteArgMem]>; + def int_x86_avx512_scatter_dpi_mask_512 : GCCBuiltin<"__builtin_ia32_mask_scatterdpi512">, + Intrinsic<[], [llvm_ptr_ty, llvm_i16_ty, + llvm_v16i32_ty, llvm_v16i32_ty, llvm_i32_ty], + [IntrReadWriteArgMem]>; + def int_x86_avx512_scatter_qpq_mask_512 : GCCBuiltin<"__builtin_ia32_mask_scatterqpq512">, + Intrinsic<[], [llvm_ptr_ty, llvm_i8_ty, + llvm_v8i64_ty, llvm_v8i64_ty, llvm_i32_ty], + [IntrReadWriteArgMem]>; + def int_x86_avx512_scatter_qpi_mask_512 : GCCBuiltin<"__builtin_ia32_mask_scatterqpi512">, + Intrinsic<[], [llvm_ptr_ty, llvm_i8_ty, + llvm_v8i64_ty, llvm_v8i32_ty, llvm_i32_ty], + [IntrReadWriteArgMem]>; + + def int_x86_avx512_scatter_dpq_512 : GCCBuiltin<"__builtin_ia32_scatterdpq512">, + Intrinsic<[], [llvm_ptr_ty, + llvm_v8i32_ty, llvm_v8i64_ty, llvm_i32_ty], + []>; + def int_x86_avx512_scatter_dpi_512 : GCCBuiltin<"__builtin_ia32_scatterdpi512">, + Intrinsic<[], [llvm_ptr_ty, + llvm_v16i32_ty, llvm_v16i32_ty, llvm_i32_ty], + []>; + def int_x86_avx512_scatter_qpq_512 : GCCBuiltin<"__builtin_ia32_scatterqpq512">, + Intrinsic<[], [llvm_ptr_ty, llvm_v8i64_ty, llvm_v8i64_ty, + llvm_i32_ty], + []>; + def int_x86_avx512_scatter_qpi_512 : GCCBuiltin<"__builtin_ia32_scatterqpi512">, + Intrinsic<[], [llvm_ptr_ty, llvm_v8i64_ty, llvm_v8i32_ty, + llvm_i32_ty], + []>; +} + +let TargetPrefix = "x86" in { + def int_x86_avx512_mskblend_ps_512 : GCCBuiltin<"__builtin_ia32_avx512_mskblendps512">, + Intrinsic<[llvm_v16f32_ty], + [llvm_i16_ty, llvm_v16f32_ty, llvm_v16f32_ty], + [IntrNoMem]>; + def int_x86_avx512_cmpeq_pi_512 : GCCBuiltin<"__builtin_ia32_avx512_cmpeqpi512">, + Intrinsic<[llvm_i16_ty], [llvm_v16i32_ty, llvm_v16i32_ty], + [IntrNoMem]>; + def int_x86_avx512_and_pi : GCCBuiltin<"__builtin_ia32_avx512_andpi512">, + Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty], + [IntrNoMem]>; +} -- cgit v1.1 From 2b762cc75df2cbab21b5a1945fdf913a66de0f81 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 19 Aug 2013 19:00:35 +0000 Subject: Introduce SpecialCaseList::isIn overload for GlobalAliases. Differential Revision: http://llvm-reviews.chandlerc.com/D1437 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188688 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/Utils/SpecialCaseList.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/llvm/Transforms/Utils/SpecialCaseList.h b/include/llvm/Transforms/Utils/SpecialCaseList.h index 90eace1..34c28fc 100644 --- a/include/llvm/Transforms/Utils/SpecialCaseList.h +++ b/include/llvm/Transforms/Utils/SpecialCaseList.h @@ -49,6 +49,7 @@ namespace llvm { class Function; +class GlobalAlias; class GlobalVariable; class MemoryBuffer; class Module; @@ -79,6 +80,14 @@ class SpecialCaseList { bool isIn(const GlobalVariable &G, const StringRef Category = StringRef()) const; + /// Returns whether this global alias is listed in the given category, which + /// may be omitted to search the empty category. + /// + /// If GA aliases a function, the alias's name is matched as a function name + /// would be. Similarly, aliases of globals are matched like globals. + bool isIn(const GlobalAlias &GA, + const StringRef Category = StringRef()) const; + /// Returns whether this module is listed in the given category, which may be /// omitted to search the empty category. bool isIn(const Module &M, const StringRef Category = StringRef()) const; -- cgit v1.1 From 630d17566793c7f25a05cd407ab9b79a1756966a Mon Sep 17 00:00:00 2001 From: Jakub Staszak Date: Mon, 19 Aug 2013 19:02:33 +0000 Subject: Add definition of __warn_unused_result__ attribute. It will be used in the futher commits. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188689 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Compiler.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index feac934..c32a485 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -179,6 +179,12 @@ #define LLVM_ATTRIBUTE_USED #endif +#if __has_attribute(warn_unused_result) || __GNUC_PREREQ(3, 4) +#define LLVM_ATTRIBUTE_UNUSED_RESULT __attribute__((__warn_unused_result__)) +#else +#define LLVM_ATTRIBUTE_UNUSED_RESULT +#endif + // Some compilers warn about unused functions. When a function is sometimes // used or not depending on build settings (e.g. a function only called from // within "assert"), this attribute can be used to suppress such warnings. -- cgit v1.1 From c4d070ad07c606f77af15604dbbe817edd11ca9c Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Mon, 19 Aug 2013 21:43:16 +0000 Subject: Fix assert with GEP ptr vector indexing structs Also fix it calculating the wrong value. The struct index is not a ConstantInt, so it was being interpreted as an array index. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188713 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/Utils/Local.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/Transforms/Utils/Local.h b/include/llvm/Transforms/Utils/Local.h index 65755d0..5586c15 100644 --- a/include/llvm/Transforms/Utils/Local.h +++ b/include/llvm/Transforms/Utils/Local.h @@ -203,12 +203,17 @@ Value *EmitGEPOffset(IRBuilderTy *Builder, const DataLayout &TD, User *GEP, ++i, ++GTI) { Value *Op = *i; uint64_t Size = TD.getTypeAllocSize(GTI.getIndexedType()) & PtrSizeMask; - if (ConstantInt *OpC = dyn_cast(Op)) { - if (OpC->isZero()) continue; + if (Constant *OpC = dyn_cast(Op)) { + if (OpC->isZeroValue()) + continue; // Handle a struct index, which adds its field offset to the pointer. if (StructType *STy = dyn_cast(*GTI)) { - Size = TD.getStructLayout(STy)->getElementOffset(OpC->getZExtValue()); + if (OpC->getType()->isVectorTy()) + OpC = OpC->getSplatValue(); + + uint64_t OpValue = cast(OpC)->getZExtValue(); + Size = TD.getStructLayout(STy)->getElementOffset(OpValue); if (Size) Result = Builder->CreateAdd(Result, ConstantInt::get(IntPtrTy, Size), -- cgit v1.1 From b937c55e93e9d52fa618b3488da04ff73182f3f9 Mon Sep 17 00:00:00 2001 From: Jakub Staszak Date: Mon, 19 Aug 2013 22:12:00 +0000 Subject: Make sure that pop_back_val() result is used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188717 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/SetVector.h | 2 +- include/llvm/ADT/SmallVector.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/ADT/SetVector.h b/include/llvm/ADT/SetVector.h index d2f7286..5eda37c 100644 --- a/include/llvm/ADT/SetVector.h +++ b/include/llvm/ADT/SetVector.h @@ -170,7 +170,7 @@ public: vector_.pop_back(); } - T pop_back_val() { + T LLVM_ATTRIBUTE_UNUSED_RESULT pop_back_val() { T Ret = back(); pop_back(); return Ret; diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h index 7ba0a71..0dc8904 100644 --- a/include/llvm/ADT/SmallVector.h +++ b/include/llvm/ADT/SmallVector.h @@ -427,7 +427,7 @@ public: this->grow(N); } - T pop_back_val() { + T LLVM_ATTRIBUTE_UNUSED_RESULT pop_back_val() { #if LLVM_HAS_RVALUE_REFERENCES T Result = ::std::move(this->back()); #else -- cgit v1.1 From abd37961d55680e5e946b9e336ce14b4ac56f830 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 19 Aug 2013 23:13:33 +0000 Subject: Introduce non-const overloads for GlobalAlias::{get,resolve}AliasedGlobal. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188725 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/GlobalAlias.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/GlobalAlias.h b/include/llvm/IR/GlobalAlias.h index 883814a..e09fb6a 100644 --- a/include/llvm/IR/GlobalAlias.h +++ b/include/llvm/IR/GlobalAlias.h @@ -66,14 +66,20 @@ public: } /// getAliasedGlobal() - Aliasee can be either global or bitcast of /// global. This method retrives the global for both aliasee flavours. - const GlobalValue *getAliasedGlobal() const; + GlobalValue *getAliasedGlobal(); + const GlobalValue *getAliasedGlobal() const { + return const_cast(this)->getAliasedGlobal(); + } /// resolveAliasedGlobal() - This method tries to ultimately resolve the alias /// by going through the aliasing chain and trying to find the very last /// global. Returns NULL if a cycle was found. If stopOnWeak is false, then /// the whole chain aliasing chain is traversed, otherwise - only strong /// aliases. - const GlobalValue *resolveAliasedGlobal(bool stopOnWeak = true) const; + GlobalValue *resolveAliasedGlobal(bool stopOnWeak = true); + const GlobalValue *resolveAliasedGlobal(bool stopOnWeak = true) const { + return const_cast(this)->resolveAliasedGlobal(stopOnWeak); + } // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const Value *V) { -- cgit v1.1 From 66d1fa6f4b443ac9f8bcea5d1f71a73ada733a42 Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Mon, 19 Aug 2013 23:35:46 +0000 Subject: Add a llvm.copysign intrinsic This adds a llvm.copysign intrinsic; We already have Libfunc recognition for copysign (which is turned into the FCOPYSIGN SDAG node). In order to autovectorize calls to copysign in the loop vectorizer, we need a corresponding intrinsic as well. In addition to the expected changes to the language reference, the loop vectorizer, BasicTTI, and the SDAG builder (the intrinsic is transformed into an FCOPYSIGN node, just like the function call), this also adds FCOPYSIGN to a few lists in LegalizeVector{Ops,Types} so that vector copysigns can be expanded. In TargetLoweringBase::initActions, I've made the default action for FCOPYSIGN be Expand for vector types. This seems correct for all in-tree targets, and I think is the right thing to do because, previously, there was no way to generate vector-values FCOPYSIGN nodes (and most targets don't specify an action for vector-typed FCOPYSIGN). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188728 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Intrinsics.td | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/Intrinsics.td b/include/llvm/IR/Intrinsics.td index 856e0a5..c7414e0 100644 --- a/include/llvm/IR/Intrinsics.td +++ b/include/llvm/IR/Intrinsics.td @@ -296,6 +296,8 @@ let Properties = [IntrReadMem] in { def int_exp : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; def int_exp2 : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; def int_fabs : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; + def int_copysign : Intrinsic<[llvm_anyfloat_ty], + [LLVMMatchType<0>, LLVMMatchType<0>]>; def int_floor : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; def int_ceil : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; def int_trunc : Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>]>; -- cgit v1.1 From 9d6852cf98dd1e6a939b3469ea49ff7cbc15ad73 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Tue, 20 Aug 2013 08:36:50 +0000 Subject: [stackprotector] Refactor out the end of isInTailCallPosition into the function returnTypeIsEligibleForTailCall. This allows me to use returnTypeIsEligibleForTailCall in the stack protector pass. rdar://13935163 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188765 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/Analysis.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/Analysis.h b/include/llvm/CodeGen/Analysis.h index ce9ca0a..b2cc704 100644 --- a/include/llvm/CodeGen/Analysis.h +++ b/include/llvm/CodeGen/Analysis.h @@ -26,6 +26,7 @@ namespace llvm { class GlobalVariable; class TargetLowering; +class TargetLoweringBase; class SDNode; class SDValue; class SelectionDAG; @@ -88,6 +89,14 @@ ISD::CondCode getICmpCondCode(ICmpInst::Predicate Pred); /// This function only tests target-independent requirements. bool isInTailCallPosition(ImmutableCallSite CS, const TargetLowering &TLI); +/// Test if given that the input instruction is in the tail call position if the +/// return type or any attributes of the function will inhibit tail call +/// optimization. +bool returnTypeIsEligibleForTailCall(const Function *F, + const Instruction *I, + const ReturnInst *Ret, + const TargetLoweringBase &TLI); + } // End llvm namespace #endif -- cgit v1.1 From c149fbbe279ef623e6067304fd08dc1a62d74f7d Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Tue, 20 Aug 2013 08:38:21 +0000 Subject: [mips][msa] Added and.v, bmnz.v, bmz.v, bsel.v, nor.v, or.v, xor.v git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188767 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 0c413dc..9e6d202 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -447,6 +447,9 @@ def int_mips_addvi_w : GCCBuiltin<"__builtin_msa_addvi_w">, def int_mips_addvi_d : GCCBuiltin<"__builtin_msa_addvi_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [Commutative]>; +def int_mips_and_v : GCCBuiltin<"__builtin_msa_and_v">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + def int_mips_andi_b : GCCBuiltin<"__builtin_msa_andi_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; @@ -558,9 +561,15 @@ def int_mips_binsri_w : GCCBuiltin<"__builtin_msa_binsri_w">, def int_mips_binsri_d : GCCBuiltin<"__builtin_msa_binsri_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; +def int_mips_bmnz_v : GCCBuiltin<"__builtin_msa_bmnz_v">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + def int_mips_bmnzi_b : GCCBuiltin<"__builtin_msa_bmnzi_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_bmz_v : GCCBuiltin<"__builtin_msa_bmz_v">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + def int_mips_bmzi_b : GCCBuiltin<"__builtin_msa_bmzi_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; @@ -582,6 +591,9 @@ def int_mips_bnegi_w : GCCBuiltin<"__builtin_msa_bnegi_w">, def int_mips_bnegi_d : GCCBuiltin<"__builtin_msa_bnegi_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; +def int_mips_bsel_v : GCCBuiltin<"__builtin_msa_bsel_v">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + def int_mips_bseli_b : GCCBuiltin<"__builtin_msa_bseli_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; def int_mips_bseli_h : GCCBuiltin<"__builtin_msa_bseli_h">, @@ -1219,9 +1231,15 @@ def int_mips_nlzc_w : GCCBuiltin<"__builtin_msa_nlzc_w">, def int_mips_nlzc_d : GCCBuiltin<"__builtin_msa_nlzc_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty], []>; +def int_mips_nor_v : GCCBuiltin<"__builtin_msa_nor_v">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + def int_mips_nori_b : GCCBuiltin<"__builtin_msa_nori_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; +def int_mips_or_v : GCCBuiltin<"__builtin_msa_or_v">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + def int_mips_ori_b : GCCBuiltin<"__builtin_msa_ori_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; @@ -1430,6 +1448,9 @@ def int_mips_vshf_w : GCCBuiltin<"__builtin_msa_vshf_w">, def int_mips_vshf_d : GCCBuiltin<"__builtin_msa_vshf_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; +def int_mips_xor_v : GCCBuiltin<"__builtin_msa_xor_v">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + def int_mips_xori_b : GCCBuiltin<"__builtin_msa_xori_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; } -- cgit v1.1 From 6ef333501eb917cbd79a51c84294051a1a257a0b Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Tue, 20 Aug 2013 09:22:54 +0000 Subject: [mips][msa] Added insve git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188777 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 9e6d202..eb86388 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -1039,6 +1039,23 @@ def int_mips_insert_h : GCCBuiltin<"__builtin_msa_insert_h">, def int_mips_insert_w : GCCBuiltin<"__builtin_msa_insert_w">, Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty, llvm_i32_ty], []>; +def int_mips_insve_b : GCCBuiltin<"__builtin_msa_insve_b">, + Intrinsic<[llvm_v16i8_ty], + [llvm_v16i8_ty, llvm_i32_ty, llvm_v16i8_ty], + [IntrNoMem]>; +def int_mips_insve_h : GCCBuiltin<"__builtin_msa_insve_h">, + Intrinsic<[llvm_v8i16_ty], + [llvm_v8i16_ty, llvm_i32_ty, llvm_v8i16_ty], + [IntrNoMem]>; +def int_mips_insve_w : GCCBuiltin<"__builtin_msa_insve_w">, + Intrinsic<[llvm_v4i32_ty], + [llvm_v4i32_ty, llvm_i32_ty, llvm_v4i32_ty], + [IntrNoMem]>; +def int_mips_insve_d : GCCBuiltin<"__builtin_msa_insve_d">, + Intrinsic<[llvm_v2i64_ty], + [llvm_v2i64_ty, llvm_i32_ty, llvm_v2i64_ty], + [IntrNoMem]>; + def int_mips_ldi_b : GCCBuiltin<"__builtin_msa_ldi_b">, Intrinsic<[llvm_v16i8_ty], [llvm_i32_ty], []>; def int_mips_ldi_h : GCCBuiltin<"__builtin_msa_ldi_h">, -- cgit v1.1 From 8c20158fb0e1e5d747077f065eb0170c5af1fbfa Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Tue, 20 Aug 2013 09:38:48 +0000 Subject: [SystemZ] Use SRST to optimize memchr SystemZTargetLowering::emitStringWrapper() previously loaded the character into R0 before the loop and made R0 live on entry. I'd forgotten that allocatable registers weren't allowed to be live across blocks at this stage, and it confused LiveVariables enough to cause a miscompilation of f3 in memchr-02.ll. This patch instead loads R0 in the loop and leaves LICM to hoist it after RA. This is actually what I'd tried originally, but I went for the manual optimisation after noticing that R0 often wasn't being hoisted. This bug forced me to go back and look at why, now fixed as r188774. We should also try to optimize null checks so that they test the CC result of the SRST directly. The select between null and the SRST GPR result could then usually be deleted as dead. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188779 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLibraryInfo.h | 1 + include/llvm/Target/TargetSelectionDAGInfo.h | 12 ++++++++++++ 2 files changed, 13 insertions(+) (limited to 'include') diff --git a/include/llvm/Target/TargetLibraryInfo.h b/include/llvm/Target/TargetLibraryInfo.h index 50b16a3..9111cb1 100644 --- a/include/llvm/Target/TargetLibraryInfo.h +++ b/include/llvm/Target/TargetLibraryInfo.h @@ -701,6 +701,7 @@ public: case LibFunc::exp2: case LibFunc::exp2f: case LibFunc::exp2l: case LibFunc::memcmp: case LibFunc::strcmp: case LibFunc::strcpy: case LibFunc::stpcpy: case LibFunc::strlen: case LibFunc::strnlen: + case LibFunc::memchr: return true; } return false; diff --git a/include/llvm/Target/TargetSelectionDAGInfo.h b/include/llvm/Target/TargetSelectionDAGInfo.h index 138ff48..3474ee4 100644 --- a/include/llvm/Target/TargetSelectionDAGInfo.h +++ b/include/llvm/Target/TargetSelectionDAGInfo.h @@ -109,6 +109,18 @@ public: return std::make_pair(SDValue(), SDValue()); } + /// EmitTargetCodeForMemchr - Emit target-specific code that performs a + /// memchr, in cases where that is faster than a libcall. The first + /// returned SDValue is the result of the memchr and the second is + /// the chain. Both SDValues can be null if a normal libcall should + /// be used. + virtual std::pair + EmitTargetCodeForMemchr(SelectionDAG &DAG, SDLoc dl, SDValue Chain, + SDValue Src, SDValue Char, SDValue Length, + MachinePointerInfo SrcPtrInfo) const { + return std::make_pair(SDValue(), SDValue()); + } + /// EmitTargetCodeForStrcpy - Emit target-specific code that performs a /// strcpy or stpcpy, in cases where that is faster than a libcall. /// The first returned SDValue is the result of the copy (the start -- cgit v1.1 From c5158b869bbde7b08c486c6f326bd1c701367c98 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Tue, 20 Aug 2013 09:41:47 +0000 Subject: [mips][msa] Removed fcge, fcgt, fsge, fsgt These instructions were present in a draft spec but were removed before publication. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188782 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index eb86388..ed3f70d 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -814,16 +814,6 @@ def int_mips_fclass_w : GCCBuiltin<"__builtin_msa_fclass_w">, def int_mips_fclass_d : GCCBuiltin<"__builtin_msa_fclass_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty], []>; -def int_mips_fcge_w : GCCBuiltin<"__builtin_msa_fcge_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; -def int_mips_fcge_d : GCCBuiltin<"__builtin_msa_fcge_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; - -def int_mips_fcgt_w : GCCBuiltin<"__builtin_msa_fcgt_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; -def int_mips_fcgt_d : GCCBuiltin<"__builtin_msa_fcgt_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; - def int_mips_fcne_w : GCCBuiltin<"__builtin_msa_fcne_w">, Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; def int_mips_fcne_d : GCCBuiltin<"__builtin_msa_fcne_d">, @@ -956,16 +946,6 @@ def int_mips_fslt_w : GCCBuiltin<"__builtin_msa_fslt_w">, def int_mips_fslt_d : GCCBuiltin<"__builtin_msa_fslt_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; -def int_mips_fsge_w : GCCBuiltin<"__builtin_msa_fsge_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; -def int_mips_fsge_d : GCCBuiltin<"__builtin_msa_fsge_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; - -def int_mips_fsgt_w : GCCBuiltin<"__builtin_msa_fsgt_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; -def int_mips_fsgt_d : GCCBuiltin<"__builtin_msa_fsgt_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; - def int_mips_fsne_w : GCCBuiltin<"__builtin_msa_fsne_w">, Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; def int_mips_fsne_d : GCCBuiltin<"__builtin_msa_fsne_d">, -- cgit v1.1 From 5f560af5411fe4e9f62d4563a74f836b1dae3eae Mon Sep 17 00:00:00 2001 From: Jakub Staszak Date: Tue, 20 Aug 2013 22:52:02 +0000 Subject: Fix include guards. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188841 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ExecutionEngine/ObjectCache.h | 4 ++-- include/llvm/Support/Valgrind.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm/ExecutionEngine/ObjectCache.h b/include/llvm/ExecutionEngine/ObjectCache.h index aa200fb..6f55e43 100644 --- a/include/llvm/ExecutionEngine/ObjectCache.h +++ b/include/llvm/ExecutionEngine/ObjectCache.h @@ -7,8 +7,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_LIB_EXECUTIONENGINE_OBJECTCACHE_H -#define LLVM_LIB_EXECUTIONENGINE_OBJECTCACHE_H +#ifndef LLVM_EXECUTIONENGINE_OBJECTCACHE_H +#define LLVM_EXECUTIONENGINE_OBJECTCACHE_H #include "llvm/Support/MemoryBuffer.h" diff --git a/include/llvm/Support/Valgrind.h b/include/llvm/Support/Valgrind.h index a1397db..7ae40af 100644 --- a/include/llvm/Support/Valgrind.h +++ b/include/llvm/Support/Valgrind.h @@ -13,8 +13,8 @@ // //===----------------------------------------------------------------------===// -#ifndef LLVM_SYSTEM_VALGRIND_H -#define LLVM_SYSTEM_VALGRIND_H +#ifndef LLVM_SUPPORT_VALGRIND_H +#define LLVM_SUPPORT_VALGRIND_H #include "llvm/Config/llvm-config.h" #include "llvm/Support/Compiler.h" -- cgit v1.1 From 328a4fbfbb778de44d9a738c3efdfd42a58925d9 Mon Sep 17 00:00:00 2001 From: Jakub Staszak Date: Tue, 20 Aug 2013 23:04:15 +0000 Subject: Add some constantness. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188844 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/BlockFrequencyImpl.h | 2 +- include/llvm/Analysis/CFG.h | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/Analysis/BlockFrequencyImpl.h b/include/llvm/Analysis/BlockFrequencyImpl.h index 5e14d6f..817a441 100644 --- a/include/llvm/Analysis/BlockFrequencyImpl.h +++ b/include/llvm/Analysis/BlockFrequencyImpl.h @@ -118,7 +118,7 @@ class BlockFrequencyImpl { /// isBackedge - Return if edge Src -> Dst is a reachable backedge. /// - bool isBackedge(BlockT *Src, BlockT *Dst) { + bool isBackedge(BlockT *Src, BlockT *Dst) const { unsigned a = RPO.lookup(Src); if (!a) return false; diff --git a/include/llvm/Analysis/CFG.h b/include/llvm/Analysis/CFG.h index 979926b..e5683c8 100644 --- a/include/llvm/Analysis/CFG.h +++ b/include/llvm/Analysis/CFG.h @@ -65,7 +65,8 @@ bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum, /// on branchy code but not loops, and LI is most useful on code with loops but /// does not help on branchy code outside loops. bool isPotentiallyReachable(const Instruction *From, const Instruction *To, - DominatorTree *DT = 0, LoopInfo *LI = 0); + const DominatorTree *DT = 0, + const LoopInfo *LI = 0); /// \brief Determine whether block 'To' is reachable from 'From', returning /// true if uncertain. @@ -74,7 +75,8 @@ bool isPotentiallyReachable(const Instruction *From, const Instruction *To, /// Returns false only if we can prove that once 'From' has been reached then /// 'To' can not be executed. Conservatively returns true. bool isPotentiallyReachable(const BasicBlock *From, const BasicBlock *To, - DominatorTree *DT = 0, LoopInfo *LI = 0); + const DominatorTree *DT = 0, + const LoopInfo *LI = 0); } // End llvm namespace -- cgit v1.1 From 0856d3d9712c9fc515f014102e9f03f389555e75 Mon Sep 17 00:00:00 2001 From: Jakub Staszak Date: Wed, 21 Aug 2013 01:20:11 +0000 Subject: Move #includes from .h to .cpp file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188852 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/MachO.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Object/MachO.h b/include/llvm/Object/MachO.h index 50435d6..caa642a 100644 --- a/include/llvm/Object/MachO.h +++ b/include/llvm/Object/MachO.h @@ -20,8 +20,6 @@ #include "llvm/ADT/Triple.h" #include "llvm/Object/MachOFormat.h" #include "llvm/Object/ObjectFile.h" -#include "llvm/Support/MachO.h" -#include "llvm/Support/raw_ostream.h" namespace llvm { namespace object { -- cgit v1.1 From d7d43dc435f24e611d9d8090f6ca80a4998efd31 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 21 Aug 2013 06:13:34 +0000 Subject: DebugInfo: Do not use the DWARF Version for the .debug_pubnames or .debug_pubtypes version field Summary: LLVM would generate DWARF with version 3 in the .debug_pubname and .debug_pubtypes version fields. This would lead SGI dwarfdump to fail parsing the DWARF with (in the instance of .debug_pubnames) would exit with: dwarfdump ERROR: dwarf_get_globals: DW_DLE_PUBNAMES_VERSION_ERROR (123) This fixes PR16950. Reviewers: echristo, dblaikie Reviewed By: echristo CC: cfe-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1454 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188869 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index d0e2322..d857341 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -56,7 +56,9 @@ enum llvm_dwarf_constants { DW_TAG_user_base = 0x1000, // Recommended base for user tags. - DW_CIE_VERSION = 1 // Common frame information version. + DW_CIE_VERSION = 1, // Common frame information version. + DW_PUBTYPES_VERSION = 2, // Section version number for .debug_pubtypes. + DW_PUBNAMES_VERSION = 2 // Section version number for .debug_pubnames. }; -- cgit v1.1 From 73260db46b9daf8d0b60298d9d50fb0a3af8f8af Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:27:40 +0000 Subject: MC CFG: Add a getter for MCDataAtom's data array. While there, switch to new-style documentation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188871 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAtom.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/MC/MCAtom.h b/include/llvm/MC/MCAtom.h index 6a93798..ad8291f 100644 --- a/include/llvm/MC/MCAtom.h +++ b/include/llvm/MC/MCAtom.h @@ -16,6 +16,7 @@ #ifndef LLVM_MC_MCATOM_H #define LLVM_MC_MCATOM_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/MC/MCInst.h" #include "llvm/Support/DataTypes.h" #include @@ -28,7 +29,7 @@ class MCAtom; class MCTextAtom; class MCDataAtom; -/// MCAtom - Represents a contiguous range of either instructions (a TextAtom) +/// \brief Represents a contiguous range of either instructions (a TextAtom) /// or data (a DataAtom). Address ranges are expressed as _closed_ intervals. class MCAtom { public: @@ -172,6 +173,9 @@ public: /// Append a data entry, expanding the atom if necessary. void addData(const MCData &D); + /// Get a reference to the data in this atom. + ArrayRef getData() const { return Data; } + /// \name Atom type specific split/truncate logic. /// @{ MCDataAtom *split(uint64_t SplitPt) LLVM_OVERRIDE; -- cgit v1.1 From e0511ded947bc9a63608b94909da888e97a0b4e4 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:27:44 +0000 Subject: MC CFG: uint64_t -> size_t for vector size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188872 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAtom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/MC/MCAtom.h b/include/llvm/MC/MCAtom.h index ad8291f..686f8e1 100644 --- a/include/llvm/MC/MCAtom.h +++ b/include/llvm/MC/MCAtom.h @@ -139,7 +139,7 @@ public: const MCDecodedInst &back() const { return Insts.back(); } const MCDecodedInst &at(size_t n) const { return Insts.at(n); } - uint64_t size() const { return Insts.size(); } + size_t size() const { return Insts.size(); } /// @} /// \name Atom type specific split/truncate logic. -- cgit v1.1 From 7dac32d07d54231ba203f7c32f3a9f8e6730810f Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:27:55 +0000 Subject: MC CFG: Keep pointer to parent MCModule in created MCFunctions. Also, drive-by cleaning around createFunction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188875 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCFunction.h | 7 ++++--- include/llvm/MC/MCModule.h | 5 +++-- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCFunction.h b/include/llvm/MC/MCFunction.h index b85011e..4c75cd4 100644 --- a/include/llvm/MC/MCFunction.h +++ b/include/llvm/MC/MCFunction.h @@ -74,21 +74,22 @@ public: }; /// \brief Represents a function in machine code, containing MCBasicBlocks. -/// MCFunctions are created using MCModule::createFunction. +/// MCFunctions are created by MCModule. class MCFunction { MCFunction (const MCFunction&) LLVM_DELETED_FUNCTION; MCFunction& operator=(const MCFunction&) LLVM_DELETED_FUNCTION; std::string Name; + MCModule *ParentModule; typedef std::vector BasicBlockListTy; BasicBlockListTy Blocks; // MCModule owns the function. friend class MCModule; - MCFunction(StringRef Name); -public: + MCFunction(StringRef Name, MCModule *Parent); ~MCFunction(); +public: /// \brief Create an MCBasicBlock backed by Insts and add it to this function. /// \param Insts Sequence of straight-line code backing the basic block. /// \returns The newly created basic block. diff --git a/include/llvm/MC/MCModule.h b/include/llvm/MC/MCModule.h index 02f8ca0..6d49362 100644 --- a/include/llvm/MC/MCModule.h +++ b/include/llvm/MC/MCModule.h @@ -23,6 +23,7 @@ namespace llvm { class MCAtom; +class MCBasicBlock; class MCDataAtom; class MCFunction; class MCObjectDisassembler; @@ -88,8 +89,8 @@ public: atom_iterator atom_end() { return Atoms.end(); } /// @} - /// \name Create a new MCFunction. - MCFunction *createFunction(const StringRef &Name); + /// \brief Create a new MCFunction. + MCFunction *createFunction(StringRef Name); /// \name Access to the owned function list. /// @{ -- cgit v1.1 From f9e2348e948451d30e4e0593e0beb3bcc31da8da Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:27:59 +0000 Subject: MC CFG: Add more MCFunction container methods (find, empty). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188876 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCFunction.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCFunction.h b/include/llvm/MC/MCFunction.h index 4c75cd4..a87b948 100644 --- a/include/llvm/MC/MCFunction.h +++ b/include/llvm/MC/MCFunction.h @@ -97,13 +97,15 @@ public: StringRef getName() const { return Name; } - /// \name Access to the function's basic blocks. No ordering is enforced. + /// \name Access to the function's basic blocks. No ordering is enforced, + /// except that the first block is the entry block. /// @{ /// \brief Get the entry point basic block. const MCBasicBlock *getEntryBlock() const { return front(); } MCBasicBlock *getEntryBlock() { return front(); } - // NOTE: Dereferencing iterators gives pointers, so maybe a list is best here. + bool empty() const { return Blocks.empty(); } + typedef BasicBlockListTy::const_iterator const_iterator; typedef BasicBlockListTy:: iterator iterator; const_iterator begin() const { return Blocks.begin(); } @@ -115,6 +117,10 @@ public: MCBasicBlock* front() { return Blocks.front(); } const MCBasicBlock* back() const { return Blocks.back(); } MCBasicBlock* back() { return Blocks.back(); } + + /// \brief Find the basic block, if any, that starts at \p StartAddr. + const MCBasicBlock *find(uint64_t StartAddr) const; + MCBasicBlock *find(uint64_t StartAddr); /// @} }; -- cgit v1.1 From 07e8f8f64308239ba9f707c869e0f0e53071a992 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:28:02 +0000 Subject: MC CFG: Add entrypoint address to MCModule. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188877 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCModule.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/MC/MCModule.h b/include/llvm/MC/MCModule.h index 6d49362..a145653 100644 --- a/include/llvm/MC/MCModule.h +++ b/include/llvm/MC/MCModule.h @@ -60,14 +60,17 @@ class MCModule { FunctionListTy Functions; /// @} + /// The address of the entrypoint function. + uint64_t Entrypoint; + MCModule (const MCModule &) LLVM_DELETED_FUNCTION; MCModule& operator=(const MCModule &) LLVM_DELETED_FUNCTION; // MCObjectDisassembler creates MCModules. friend class MCObjectDisassembler; - MCModule() : Atoms() { } public: + MCModule() : Entrypoint(0) { } ~MCModule(); /// \name Create a new MCAtom covering the specified offset range. @@ -101,6 +104,9 @@ public: const_func_iterator func_end() const { return Functions.end(); } func_iterator func_end() { return Functions.end(); } /// @} + + /// \brief Get the address of the entrypoint function, or 0 if there is none. + uint64_t getEntrypoint() const { return Entrypoint; } }; } -- cgit v1.1 From cdef37a9d8d559042fe43d8ae91d4b65f281df69 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:28:07 +0000 Subject: MC: Refactor ObjectSymbolizer to make relocation/section info generation lazy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188878 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCObjectSymbolizer.h | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCObjectSymbolizer.h b/include/llvm/MC/MCObjectSymbolizer.h index 555cf51..7d70dfd 100644 --- a/include/llvm/MC/MCObjectSymbolizer.h +++ b/include/llvm/MC/MCObjectSymbolizer.h @@ -32,22 +32,14 @@ class MCObjectSymbolizer : public MCSymbolizer { protected: const object::ObjectFile *Obj; - typedef DenseMap AddrToRelocMap; - typedef std::vector SortedSectionList; - SortedSectionList SortedSections; - // Map a load address to the first relocation that applies there. As far as I // know, if there are several relocations at the exact same address, they are // related and the others can be determined from the first that was found in // the relocation table. For instance, on x86-64 mach-o, a SUBTRACTOR // relocation (referencing the minuend symbol) is followed by an UNSIGNED // relocation (referencing the subtrahend symbol). - AddrToRelocMap AddrToReloc; - - // Helpers around SortedSections. - SortedSectionList::const_iterator findSectionContaining(uint64_t Addr) const; - void insertSection(object::SectionRef Section); - + const object::RelocationRef *findRelocationAt(uint64_t Addr); + const object::SectionRef *findSectionContaining(uint64_t Addr); MCObjectSymbolizer(MCContext &Ctx, OwningPtr &RelInfo, const object::ObjectFile *Obj); @@ -56,9 +48,9 @@ public: /// \name Overridden MCSymbolizer methods: /// @{ bool tryAddingSymbolicOperand(MCInst &MI, raw_ostream &cStream, - int64_t Value, - uint64_t Address, bool IsBranch, - uint64_t Offset, uint64_t InstSize); + int64_t Value, uint64_t Address, + bool IsBranch, uint64_t Offset, + uint64_t InstSize); void tryAddingPcLoadReferenceComment(raw_ostream &cStream, int64_t Value, uint64_t Address); @@ -68,6 +60,15 @@ public: static MCObjectSymbolizer * createObjectSymbolizer(MCContext &Ctx, OwningPtr &RelInfo, const object::ObjectFile *Obj); + +private: + typedef DenseMap AddrToRelocMap; + typedef std::vector SortedSectionList; + SortedSectionList SortedSections; + AddrToRelocMap AddrToReloc; + + void buildSectionList(); + void buildRelocationByAddrMap(); }; } -- cgit v1.1 From 9bfc0626c02e449dd321a71a09f005ac8239e921 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:28:13 +0000 Subject: MC: ObjectSymbolizer can now recognize external function stubs. Only implemented in the Mach-O ObjectSymbolizer. The testcase sadly introduces a new binary. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188879 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCObjectSymbolizer.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCObjectSymbolizer.h b/include/llvm/MC/MCObjectSymbolizer.h index 7d70dfd..64b932e 100644 --- a/include/llvm/MC/MCObjectSymbolizer.h +++ b/include/llvm/MC/MCObjectSymbolizer.h @@ -56,6 +56,11 @@ public: int64_t Value, uint64_t Address); /// @} + /// \brief Look for an external function symbol at \p Addr. + /// (References through the ELF PLT, Mach-O stubs, and similar). + /// \returns An MCExpr representing the external symbol, or 0 if not found. + virtual StringRef findExternalFunctionAt(uint64_t Addr); + /// \brief Create an object symbolizer for \p Obj. static MCObjectSymbolizer * createObjectSymbolizer(MCContext &Ctx, OwningPtr &RelInfo, -- cgit v1.1 From 46d353f8e8a2bbe02e8aa6a2292eae930dd3b7e6 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:28:17 +0000 Subject: MC CFG: Add a few needed methods, mainly MCModule::findFirstAtomAfter. While there, do some minor cleanup. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188880 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCFunction.h | 6 ++++++ include/llvm/MC/MCModule.h | 4 ++++ 2 files changed, 10 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCFunction.h b/include/llvm/MC/MCFunction.h index a87b948..697b500 100644 --- a/include/llvm/MC/MCFunction.h +++ b/include/llvm/MC/MCFunction.h @@ -97,6 +97,12 @@ public: StringRef getName() const { return Name; } + /// \name Get the owning MC Module. + /// @{ + const MCModule *getParent() const { return ParentModule; } + MCModule *getParent() { return ParentModule; } + /// @} + /// \name Access to the function's basic blocks. No ordering is enforced, /// except that the first block is the entry block. /// @{ diff --git a/include/llvm/MC/MCModule.h b/include/llvm/MC/MCModule.h index a145653..c0c242c 100644 --- a/include/llvm/MC/MCModule.h +++ b/include/llvm/MC/MCModule.h @@ -43,7 +43,9 @@ class MCModule { typedef std::vector AtomListTy; AtomListTy Atoms; + // For access to map/remap. friend class MCAtom; + /// \brief Remap \p Atom to the given range, and update its Begin/End fields. /// \param Atom An atom belonging to this module. /// An atom should always use this method to update its bounds, because this @@ -83,6 +85,8 @@ public: /// @{ const MCAtom *findAtomContaining(uint64_t Addr) const; MCAtom *findAtomContaining(uint64_t Addr); + const MCAtom *findFirstAtomAfter(uint64_t Addr) const; + MCAtom *findFirstAtomAfter(uint64_t Addr); typedef AtomListTy::const_iterator const_atom_iterator; typedef AtomListTy:: iterator atom_iterator; -- cgit v1.1 From aeb2bbcb6d4f13d0032d57fd1cb1a92da2acd01e Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:28:24 +0000 Subject: MC CFG: Split MCBasicBlocks to mirror atom splitting. When an MCTextAtom is split, all MCBasicBlocks backed by it are automatically split, with a fallthrough between both blocks, and the successors moved to the second block. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188881 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCFunction.h | 8 ++++++++ include/llvm/MC/MCModule.h | 15 +++++++++++++++ 2 files changed, 23 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCFunction.h b/include/llvm/MC/MCFunction.h index 697b500..3fccaac 100644 --- a/include/llvm/MC/MCFunction.h +++ b/include/llvm/MC/MCFunction.h @@ -70,6 +70,14 @@ public: void addPredecessor(const MCBasicBlock *MCBB); bool isPredecessor(const MCBasicBlock *MCBB) const; + + /// \brief Split block, mirrorring NewAtom = Insts->split(..). + /// This moves all successors to \p SplitBB, and + /// adds a fallthrough to it. + /// \p SplitBB The result of splitting Insts, a basic block directly following + /// this basic block. + /// \returns A new basic block, backed by \p SplitBB. + void splitBasicBlock(MCBasicBlock *SplitBB); /// @} }; diff --git a/include/llvm/MC/MCModule.h b/include/llvm/MC/MCModule.h index c0c242c..63635c7 100644 --- a/include/llvm/MC/MCModule.h +++ b/include/llvm/MC/MCModule.h @@ -56,6 +56,21 @@ class MCModule { void map(MCAtom *NewAtom); /// @} + /// \name Basic block tracking + /// @{ + typedef std::vector BBsByAtomTy; + BBsByAtomTy BBsByAtom; + + // For access to basic block > atom tracking. + friend class MCBasicBlock; + friend class MCTextAtom; + + /// \brief Keep track of \p BBBackedByAtom as being backed by \p Atom. + /// This is used to update succs/preds when \p Atom is split. + void trackBBForAtom(const MCTextAtom *Atom, MCBasicBlock *BBBackedByAtom); + void splitBasicBlocksForAtom(const MCTextAtom *TA, const MCTextAtom *NewTA); + /// @} + /// \name Function tracking /// @{ typedef std::vector FunctionListTy; -- cgit v1.1 From 0a30cccd493e3bc82a5771ca15326f7cc8b6cb8c Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:28:29 +0000 Subject: MC CFG: Add MCObjectDisassembler support for entrypoint + static ctors. For now, this isn't implemented for any format. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188882 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCObjectDisassembler.h | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCObjectDisassembler.h b/include/llvm/MC/MCObjectDisassembler.h index 749a54e..de2aae7 100644 --- a/include/llvm/MC/MCObjectDisassembler.h +++ b/include/llvm/MC/MCObjectDisassembler.h @@ -15,6 +15,10 @@ #ifndef LLVM_MC_MCOBJECTDISASSEMBLER_H #define LLVM_MC_MCOBJECTDISASSEMBLER_H +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/Support/DataTypes.h" + namespace llvm { namespace object { @@ -33,14 +37,11 @@ class MCModule; /// It can also be used to create a control flow graph consisting of MCFunctions /// and MCBasicBlocks. class MCObjectDisassembler { - const object::ObjectFile &Obj; - const MCDisassembler &Dis; - const MCInstrAnalysis &MIA; - public: MCObjectDisassembler(const object::ObjectFile &Obj, const MCDisassembler &Dis, const MCInstrAnalysis &MIA); + virtual ~MCObjectDisassembler() {} /// \brief Build an MCModule, creating atoms and optionally functions. /// \param withCFG Also build a CFG by adding MCFunctions to the Module. @@ -50,6 +51,25 @@ public: /// block atoms, which then each back an MCBasicBlock. MCModule *buildModule(bool withCFG = false); + MCModule *buildEmptyModule(); + + /// \brief Get the effective address of the entrypoint, or 0 if there is none. + virtual uint64_t getEntrypoint(); + + /// \name Get the addresses of static constructors/destructors in the object. + /// The caller is expected to know how to interpret the addresses; + /// for example, Mach-O init functions expect 5 arguments, not for ELF. + /// The addresses are original object file load addresses, not effective. + /// @{ + virtual ArrayRef getStaticInitFunctions(); + virtual ArrayRef getStaticExitFunctions(); + /// @} + +protected: + const object::ObjectFile &Obj; + const MCDisassembler &Dis; + const MCInstrAnalysis &MIA; + private: /// \brief Fill \p Module by creating an atom for each section. /// This could be made much smarter, using information like symbols, but also -- cgit v1.1 From 484a6eb9cc22db9c78bb93969bc0341c19e7739e Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:28:37 +0000 Subject: MC CFG: Add "dynamic disassembly" support to MCObjectDisassembler. It can now disassemble code in situations where the effective load address is different than the load address declared in the object file. This happens for PIC, hence "dynamic". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188884 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCObjectDisassembler.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCObjectDisassembler.h b/include/llvm/MC/MCObjectDisassembler.h index de2aae7..edaf7dc 100644 --- a/include/llvm/MC/MCObjectDisassembler.h +++ b/include/llvm/MC/MCObjectDisassembler.h @@ -65,6 +65,22 @@ public: virtual ArrayRef getStaticExitFunctions(); /// @} + /// \name Translation between effective and objectfile load address. + /// @{ + /// \brief Compute the effective load address, from an objectfile virtual + /// address. This is implemented in a format-specific way, to take into + /// account things like PIE/ASLR when doing dynamic disassembly. + /// For example, on Mach-O this would be done by adding the VM addr slide, + /// on glibc ELF by keeping a map between segment load addresses, filled + /// using dl_iterate_phdr, etc.. + /// In most static situations and in the default impl., this returns \p Addr. + virtual uint64_t getEffectiveLoadAddr(uint64_t Addr); + + /// \brief Compute the original load address, as specified in the objectfile. + /// This is the inverse of getEffectiveLoadAddr. + virtual uint64_t getOriginalLoadAddr(uint64_t EffectiveAddr); + /// @} + protected: const object::ObjectFile &Obj; const MCDisassembler &Dis; -- cgit v1.1 From fe018c414542141010ef0706820ebfde0a4b3e41 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:28:40 +0000 Subject: Add Mach-O entry_point_command declaration. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188885 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/MachO.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/llvm/Support/MachO.h b/include/llvm/Support/MachO.h index 7f28c3f..5d2a8a8 100644 --- a/include/llvm/Support/MachO.h +++ b/include/llvm/Support/MachO.h @@ -621,6 +621,13 @@ namespace llvm { uint32_t header_addr; }; + struct entry_point_command { + uint32_t cmd; + uint32_t cmdsize; + uint64_t entryoff; + uint64_t stacksize; + }; + // Structs from struct fat_header { -- cgit v1.1 From 0e83b902834530da4670ad8416cf44afba9b4111 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:28:44 +0000 Subject: MC CFG: Add MCObjectDisassembler Mach-O implementation. Supports: - entrypoint, using LC_MAIN. - static ctors/dtors, using __mod_{init,exit}_func - translation between effective and object load address, using dyld's VM address slide. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188886 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCObjectDisassembler.h | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCObjectDisassembler.h b/include/llvm/MC/MCObjectDisassembler.h index edaf7dc..4ac3456 100644 --- a/include/llvm/MC/MCObjectDisassembler.h +++ b/include/llvm/MC/MCObjectDisassembler.h @@ -23,6 +23,7 @@ namespace llvm { namespace object { class ObjectFile; + class MachOObjectFile; } class MCBasicBlock; @@ -100,6 +101,36 @@ private: void buildCFG(MCModule *Module); }; +class MCMachOObjectDisassembler : public MCObjectDisassembler { + const object::MachOObjectFile &MOOF; + + uint64_t VMAddrSlide; + uint64_t HeaderLoadAddress; + + // __DATA;__mod_init_func support. + llvm::StringRef ModInitContents; + // __DATA;__mod_exit_func support. + llvm::StringRef ModExitContents; + +public: + /// \brief Construct a Mach-O specific object disassembler. + /// \param VMAddrSlide The virtual address slide applied by dyld. + /// \param HeaderLoadAddress The load address of the mach_header for this + /// object. + MCMachOObjectDisassembler(const object::MachOObjectFile &MOOF, + const MCDisassembler &Dis, + const MCInstrAnalysis &MIA, uint64_t VMAddrSlide, + uint64_t HeaderLoadAddress); + +protected: + uint64_t getEffectiveLoadAddr(uint64_t Addr) LLVM_OVERRIDE; + uint64_t getOriginalLoadAddr(uint64_t EffectiveAddr) LLVM_OVERRIDE; + uint64_t getEntrypoint() LLVM_OVERRIDE; + + ArrayRef getStaticInitFunctions() LLVM_OVERRIDE; + ArrayRef getStaticExitFunctions() LLVM_OVERRIDE; +}; + } #endif -- cgit v1.1 From 0f4a5ba24e680f5193792822c9dd066bfccdfc2d Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:28:48 +0000 Subject: MC CFG: Add an MCObjectSymbolizer in the MCObjectDisassembler. Used to detect calls to function symbol stubs (future commit). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188887 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCObjectDisassembler.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCObjectDisassembler.h b/include/llvm/MC/MCObjectDisassembler.h index 4ac3456..ab317e3 100644 --- a/include/llvm/MC/MCObjectDisassembler.h +++ b/include/llvm/MC/MCObjectDisassembler.h @@ -31,6 +31,7 @@ class MCDisassembler; class MCFunction; class MCInstrAnalysis; class MCModule; +class MCObjectSymbolizer; /// \brief Disassemble an ObjectFile to an MCModule and MCFunctions. /// This class builds on MCDisassembler to disassemble whole sections, creating @@ -54,6 +55,13 @@ public: MCModule *buildEmptyModule(); + /// \brief Set the symbolizer to use to get information on external functions. + /// Note that this isn't used to do instruction-level symbolization (that is, + /// plugged into MCDisassembler), but to symbolize function call targets. + void setSymbolizer(MCObjectSymbolizer *ObjectSymbolizer) { + MOS = ObjectSymbolizer; + } + /// \brief Get the effective address of the entrypoint, or 0 if there is none. virtual uint64_t getEntrypoint(); @@ -86,6 +94,7 @@ protected: const object::ObjectFile &Obj; const MCDisassembler &Dis; const MCInstrAnalysis &MIA; + MCObjectSymbolizer *MOS; private: /// \brief Fill \p Module by creating an atom for each section. -- cgit v1.1 From f176482752fbea3139394e280adfb10270dd3aac Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:28:55 +0000 Subject: MC CFG: Support disassembly at arbitrary addresses in MCObjectDisassembler. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188889 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCObjectDisassembler.h | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCObjectDisassembler.h b/include/llvm/MC/MCObjectDisassembler.h index ab317e3..0d87d33 100644 --- a/include/llvm/MC/MCObjectDisassembler.h +++ b/include/llvm/MC/MCObjectDisassembler.h @@ -16,8 +16,11 @@ #define LLVM_MC_MCOBJECTDISASSEMBLER_H #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/MemoryObject.h" +#include namespace llvm { @@ -55,6 +58,19 @@ public: MCModule *buildEmptyModule(); + typedef std::vector AddressSetTy; + /// \name Create a new MCFunction. + MCFunction *createFunction(MCModule *Module, uint64_t BeginAddr, + AddressSetTy &CallTargets, + AddressSetTy &TailCallTargets); + + /// \brief Set the region on which to fallback if disassembly was requested + /// somewhere not accessible in the object file. + /// This is used for dynamic disassembly (see RawMemoryObject). + void setFallbackRegion(OwningPtr &Region) { + FallbackRegion.reset(Region.take()); + } + /// \brief Set the symbolizer to use to get information on external functions. /// Note that this isn't used to do instruction-level symbolization (that is, /// plugged into MCDisassembler), but to symbolize function call targets. @@ -96,6 +112,16 @@ protected: const MCInstrAnalysis &MIA; MCObjectSymbolizer *MOS; + /// \brief The fallback memory region, outside the object file. + OwningPtr FallbackRegion; + + /// \brief Return a memory region suitable for reading starting at \p Addr. + /// In most cases, this returns a StringRefMemoryObject backed by the + /// containing section. When no section was found, this returns the + /// FallbackRegion, if it is suitable. + /// If it is not, or if there is no fallback region, this returns 0. + MemoryObject *getRegionFor(uint64_t Addr); + private: /// \brief Fill \p Module by creating an atom for each section. /// This could be made much smarter, using information like symbols, but also @@ -108,6 +134,10 @@ private: /// When the CFG is built, contiguous instructions that were previously in a /// single MCTextAtom will be split in multiple basic block atoms. void buildCFG(MCModule *Module); + + MCBasicBlock *getBBAt(MCModule *Module, MCFunction *MCFN, uint64_t BeginAddr, + AddressSetTy &CallTargets, + AddressSetTy &TailCallTargets); }; class MCMachOObjectDisassembler : public MCObjectDisassembler { -- cgit v1.1 From 171ac8ca175bec5bc0bff8b3006850f70e0569c9 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Wed, 21 Aug 2013 07:29:02 +0000 Subject: MC CFG: Add YAML MCModule representation to enable MC CFG testing. Like yaml ObjectFiles, this will be very useful for testing the MC CFG implementation (mostly MCObjectDisassembler), by matching the output with YAML, and for potential users of the MC CFG, by using it as an input. There isn't much to the actual format, it is just a serialization of the MCModule class. Of note: - Basic block references (pred/succ, ..) are represented by the BB's start address. - Just as in the MC CFG, instructions are MCInsts with a size. - Operands have a prefix representing the type (only register and immediate supported here). - Instruction opcodes are represented by their names; enum values aren't stable, enum names mostly are: usually, a change to a name would need lots of changes in the backend anyway. Same with registers. All in all, an example is better than 1000 words, here goes: A simple binary: Disassembly of section __TEXT,__text: _main: 100000f9c: 48 8b 46 08 movq 8(%rsi), %rax 100000fa0: 0f be 00 movsbl (%rax), %eax 100000fa3: 3b 04 25 48 00 00 00 cmpl 72, %eax 100000faa: 0f 8c 07 00 00 00 jl 7 <.Lend> 100000fb0: 2b 04 25 48 00 00 00 subl 72, %eax .Lend: 100000fb7: c3 ret And the (pretty verbose) generated YAML: --- Atoms: - StartAddress: 0x0000000100000F9C Size: 20 Type: Text Content: - Inst: MOV64rm Size: 4 Ops: [ RRAX, RRSI, I1, R, I8, R ] - Inst: MOVSX32rm8 Size: 3 Ops: [ REAX, RRAX, I1, R, I0, R ] - Inst: CMP32rm Size: 7 Ops: [ REAX, R, I1, R, I72, R ] - Inst: JL_4 Size: 6 Ops: [ I7 ] - StartAddress: 0x0000000100000FB0 Size: 7 Type: Text Content: - Inst: SUB32rm Size: 7 Ops: [ REAX, REAX, R, I1, R, I72, R ] - StartAddress: 0x0000000100000FB7 Size: 1 Type: Text Content: - Inst: RET Size: 1 Ops: [ ] Functions: - Name: __text BasicBlocks: - Address: 0x0000000100000F9C Preds: [ ] Succs: [ 0x0000000100000FB7, 0x0000000100000FB0 ] ... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188890 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCModuleYAML.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 include/llvm/MC/MCModuleYAML.h (limited to 'include') diff --git a/include/llvm/MC/MCModuleYAML.h b/include/llvm/MC/MCModuleYAML.h new file mode 100644 index 0000000..0ea29da --- /dev/null +++ b/include/llvm/MC/MCModuleYAML.h @@ -0,0 +1,41 @@ +//===- MCModuleYAML.h - MCModule YAMLIO implementation ----------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +/// +/// \file +/// \brief This file declares classes for handling the YAML representation +/// of MCModule. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_OBJECT_MCMODULEYAML_H +#define LLVM_OBJECT_MCMODULEYAML_H + +#include "llvm/ADT/OwningPtr.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/MC/MCModule.h" +#include "llvm/Support/raw_ostream.h" + +namespace llvm { + +class MCInstrInfo; +class MCRegisterInfo; + +/// \brief Dump a YAML representation of the MCModule \p MCM to \p OS. +/// \returns The empty string on success, an error message on failure. +StringRef mcmodule2yaml(raw_ostream &OS, const MCModule &MCM, + const MCInstrInfo &MII, const MCRegisterInfo &MRI); + +/// \brief Creates a new module and returns it in \p MCM. +/// \returns The empty string on success, an error message on failure. +StringRef yaml2mcmodule(OwningPtr &MCM, StringRef YamlContent, + const MCInstrInfo &MII, const MCRegisterInfo &MRI); + +} // end namespace llvm + +#endif -- cgit v1.1 From f44026bf2639561364747fb6c419eeb5f531e5b9 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 21 Aug 2013 09:34:22 +0000 Subject: MCFunction.h: Prune \returns to fix a warning in r188881. [-Wdocumentation] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188897 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCFunction.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/llvm/MC/MCFunction.h b/include/llvm/MC/MCFunction.h index 3fccaac..22c9192 100644 --- a/include/llvm/MC/MCFunction.h +++ b/include/llvm/MC/MCFunction.h @@ -76,7 +76,6 @@ public: /// adds a fallthrough to it. /// \p SplitBB The result of splitting Insts, a basic block directly following /// this basic block. - /// \returns A new basic block, backed by \p SplitBB. void splitBasicBlock(MCBasicBlock *SplitBB); /// @} }; -- cgit v1.1 From 296ca41b2d305f4aaf1d0562c7da90dc20cd9e14 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Wed, 21 Aug 2013 21:30:23 +0000 Subject: Basic unit tests for PointerUnion git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188933 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/PointerUnion.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/ADT/PointerUnion.h b/include/llvm/ADT/PointerUnion.h index 4eed121..05d362f 100644 --- a/include/llvm/ADT/PointerUnion.h +++ b/include/llvm/ADT/PointerUnion.h @@ -72,7 +72,7 @@ namespace llvm { /// printf("%d %d", P.is(), P.is()); // prints "1 0" /// X = P.get(); // ok. /// Y = P.get(); // runtime assertion failure. - /// Z = P.get(); // runtime assertion failure (regardless of tag) + /// Z = P.get(); // compile time failure. /// P = (float*)0; /// Y = P.get(); // ok. /// X = P.get(); // runtime assertion failure. -- cgit v1.1 From 79ef34d1802eeea48aa4e9346abecbf8ceb2e8eb Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 21 Aug 2013 21:53:33 +0000 Subject: ADT/Triple: Helper to determine if we are targeting the Windows CRT Summary: This support will be utilized in things like clang to help check printf format specifiers that are only valid when using the VSCRT. Reviewers: rnk, asl, chandlerc Reviewed By: chandlerc CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1455 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188935 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/Triple.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index 8d968e8..4b53ad2 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -318,6 +318,11 @@ public: return getOS() == Triple::Cygwin || getOS() == Triple::MinGW32; } + /// \brief Is this a "Windows" OS targeting a "MSVCRT.dll" environment. + bool isOSMSVCRT() const { + return getOS() == Triple::Win32 || getOS() == Triple::MinGW32; + } + /// isOSWindows - Is this a "Windows" OS. bool isOSWindows() const { return getOS() == Triple::Win32 || isOSCygMing(); -- cgit v1.1 From f7ab3a84b3e1b5a647ae9456a5edb99d86b35329 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Thu, 22 Aug 2013 09:57:11 +0000 Subject: ARM: use TableGen patterns to select CMOV operations. Back in the mists of time (2008), it seems TableGen couldn't handle the patterns necessary to match ARM's CMOV node that we convert select operations to, so we wrote a lot of fairly hairy C++ to do it for us. TableGen can deal with it now: there were a few minor differences to CodeGen (see tests), but nothing obviously worse that I could see, so we should probably address anything that *does* come up in a localised manner. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188995 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/Target.td | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Target/Target.td b/include/llvm/Target/Target.td index 89ca529..b7f3693 100644 --- a/include/llvm/Target/Target.td +++ b/include/llvm/Target/Target.td @@ -632,6 +632,11 @@ def f64imm : Operand; /// def zero_reg; +/// All operands which the MC layer classifies as predicates should inherit from +/// this class in some manner. This is already handled for the most commonly +/// used PredicateOperand, but may be useful in other circumstances. +class PredicateOp; + /// OperandWithDefaultOps - This Operand class can be used as the parent class /// for an Operand that needs to be initialized with a default value if /// no value is supplied in a pattern. This class can be used to simplify the @@ -647,7 +652,7 @@ class OperandWithDefaultOps /// AlwaysVal specifies the value of this predicate when set to "always /// execute". class PredicateOperand - : OperandWithDefaultOps { + : OperandWithDefaultOps, PredicateOp { let MIOperandInfo = OpTypes; } -- cgit v1.1 From f6db9425648e9d9b965dc0aae9f63afbb3e7a5b8 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Thu, 22 Aug 2013 10:12:18 +0000 Subject: Clean up the doxygen formatting of the comments on the strip* methods on Value. These methods probably don't belong here, and I'm discussing moving the lot of them to a better home, but for now I'm about to extend their functionality and wanted to tidy them up first. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188997 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Value.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/Value.h b/include/llvm/IR/Value.h index 5fba3d5..e667b87 100644 --- a/include/llvm/IR/Value.h +++ b/include/llvm/IR/Value.h @@ -260,37 +260,37 @@ public: /// this value. bool hasValueHandle() const { return HasValueHandle; } - /// \brief This method strips off any unneeded pointer casts, - /// all-zero GEPs and aliases from the specified value, returning the original - /// uncasted value. If this is called on a non-pointer value, it returns - /// 'this'. + /// \brief Strips off any unneeded pointer casts, all-zero GEPs and aliases + /// from the specified value, returning the original uncasted value. + /// + /// If this is called on a non-pointer value, it returns 'this'. Value *stripPointerCasts(); const Value *stripPointerCasts() const { return const_cast(this)->stripPointerCasts(); } - /// \brief This method strips off any unneeded pointer casts and - /// all-zero GEPs from the specified value, returning the original - /// uncasted value. If this is called on a non-pointer value, it returns - /// 'this'. + /// \brief Strips off any unneeded pointer casts and all-zero GEPs from the + /// specified value, returning the original uncasted value. + /// + /// If this is called on a non-pointer value, it returns 'this'. Value *stripPointerCastsNoFollowAliases(); const Value *stripPointerCastsNoFollowAliases() const { return const_cast(this)->stripPointerCastsNoFollowAliases(); } - /// stripInBoundsConstantOffsets - This method strips off unneeded pointer casts and - /// all-constant GEPs from the specified value, returning the original - /// pointer value. If this is called on a non-pointer value, it returns - /// 'this'. + /// \brief Strips off unneeded pointer casts and all-constant GEPs from the + /// specified value, returning the original pointer value. + /// + /// If this is called on a non-pointer value, it returns 'this'. Value *stripInBoundsConstantOffsets(); const Value *stripInBoundsConstantOffsets() const { return const_cast(this)->stripInBoundsConstantOffsets(); } - /// stripInBoundsOffsets - This method strips off unneeded pointer casts and - /// any in-bounds Offsets from the specified value, returning the original - /// pointer value. If this is called on a non-pointer value, it returns - /// 'this'. + /// \brief Strips off unneeded pointer casts and any in-bounds offsets from + /// the specified value, returning the original pointer value. + /// + /// If this is called on a non-pointer value, it returns 'this'. Value *stripInBoundsOffsets(); const Value *stripInBoundsOffsets() const { return const_cast(this)->stripInBoundsOffsets(); -- cgit v1.1 From f73826bef09fcc38d2db7b69baf0b8a45c9788f8 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Thu, 22 Aug 2013 11:25:11 +0000 Subject: Add a new helper method to Value to strip in-bounds constant offsets of pointers, but accumulate the offset into an APInt in the process of stripping it. This is a pretty handy thing to have, such as when trying to determine if two pointers are at some constant relative offset. I'll be committing a patch shortly to use it for exactly that purpose. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189000 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Value.h | 43 +++++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/Value.h b/include/llvm/IR/Value.h index e667b87..e1361fe 100644 --- a/include/llvm/IR/Value.h +++ b/include/llvm/IR/Value.h @@ -22,26 +22,29 @@ namespace llvm { -class Constant; +class APInt; class Argument; -class Instruction; +class AssemblyAnnotationWriter; class BasicBlock; -class GlobalValue; +class Constant; +class DataLayout; class Function; -class GlobalVariable; class GlobalAlias; +class GlobalValue; +class GlobalVariable; class InlineAsm; -class ValueSymbolTable; -template class StringMapEntry; -typedef StringMapEntry ValueName; -class raw_ostream; -class AssemblyAnnotationWriter; -class ValueHandleBase; +class Instruction; class LLVMContext; -class Twine; class MDNode; -class Type; class StringRef; +class Twine; +class Type; +class ValueHandleBase; +class ValueSymbolTable; +class raw_ostream; + +template class StringMapEntry; +typedef StringMapEntry ValueName; //===----------------------------------------------------------------------===// // Value Class @@ -287,6 +290,22 @@ public: return const_cast(this)->stripInBoundsConstantOffsets(); } + /// \brief Strips like \c stripInBoundsConstantOffsets but also accumulates + /// the constant offset stripped. + /// + /// Stores the resulting constant offset stripped into the APInt provided. + /// The provided APInt will be extended or truncated as needed to be the + /// correct bitwidth for an offset of this pointer type. + /// + /// If this is called on a non-pointer value, it returns 'this'. + Value *stripAndAccumulateInBoundsConstantOffsets(const DataLayout &DL, + APInt &Offset); + const Value *stripAndAccumulateInBoundsConstantOffsets(const DataLayout &DL, + APInt &Offset) const { + return const_cast(this) + ->stripAndAccumulateInBoundsConstantOffsets(DL, Offset); + } + /// \brief Strips off unneeded pointer casts and any in-bounds offsets from /// the specified value, returning the original pointer value. /// -- cgit v1.1 From d93969c32a6bbae3326a1f485c4c85be1cb39406 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Fri, 23 Aug 2013 02:25:47 +0000 Subject: Add an OtherPreserved field to the CalleeSaved TableGen class. This field specifies registers that are preserved across function calls, but that should not be included in the generates SaveList array. This can be used ot generate regmasks for architectures that save registers through other means, like SPARC's register windows. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189084 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetCallingConv.td | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/llvm/Target/TargetCallingConv.td b/include/llvm/Target/TargetCallingConv.td index a53ed29..c1bef28 100644 --- a/include/llvm/Target/TargetCallingConv.td +++ b/include/llvm/Target/TargetCallingConv.td @@ -143,4 +143,10 @@ class CallingConv actions> { /// returning from getCallPreservedMask(). class CalleeSavedRegs { dag SaveList = saves; + + // Registers that are also preserved across function calls, but should not be + // included in the generated FOO_SaveList array. These registers will be + // included in the FOO_RegMask bit mask. This can be used for registers that + // are saved automatically, like the SPARC register windows. + dag OtherPreserved; } -- cgit v1.1 From a8a7099c1849fcbb4a68642a292fd0250aa46505 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Fri, 23 Aug 2013 10:27:02 +0000 Subject: Turn MipsOptimizeMathLibCalls into a target-independent scalar transform ...so that it can be used for z too. Most of the code is the same. The only real change is to use TargetTransformInfo to test when a sqrt instruction is available. The pass is opt-in because at the moment it only handles sqrt. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189097 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Transforms/Scalar.h | 3 +++ include/llvm/Analysis/TargetTransformInfo.h | 4 ++++ include/llvm/InitializePasses.h | 1 + include/llvm/LinkAllPasses.h | 1 + include/llvm/Transforms/Scalar.h | 7 +++++++ 5 files changed, 16 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Transforms/Scalar.h b/include/llvm-c/Transforms/Scalar.h index a2c4d61..2456c6c 100644 --- a/include/llvm-c/Transforms/Scalar.h +++ b/include/llvm-c/Transforms/Scalar.h @@ -74,6 +74,9 @@ void LLVMAddLoopUnswitchPass(LLVMPassManagerRef PM); /** See llvm::createMemCpyOptPass function. */ void LLVMAddMemCpyOptPass(LLVMPassManagerRef PM); +/** See llvm::createPartiallyInlineLibCallsPass function. */ +void LLVMAddPartiallyInlineLibCallsPass(LLVMPassManagerRef PM); + /** See llvm::createPromoteMemoryToRegisterPass function. */ void LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM); diff --git a/include/llvm/Analysis/TargetTransformInfo.h b/include/llvm/Analysis/TargetTransformInfo.h index 21a3a12..06810a7 100644 --- a/include/llvm/Analysis/TargetTransformInfo.h +++ b/include/llvm/Analysis/TargetTransformInfo.h @@ -262,6 +262,10 @@ public: /// getPopcntSupport - Return hardware support for population count. virtual PopcntSupportKind getPopcntSupport(unsigned IntTyWidthInBit) const; + /// haveFastSqrt -- Return true if the hardware has a fast square-root + /// instruction. + virtual bool haveFastSqrt(Type *Ty) const; + /// getIntImmCost - Return the expected cost of materializing the given /// integer immediate of the specified type. virtual unsigned getIntImmCost(const APInt &Imm, Type *Ty) const; diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h index 08f0c7a..aa06eca 100644 --- a/include/llvm/InitializePasses.h +++ b/include/llvm/InitializePasses.h @@ -205,6 +205,7 @@ void initializeObjCARCContractPass(PassRegistry&); void initializeObjCARCOptPass(PassRegistry&); void initializeOptimalEdgeProfilerPass(PassRegistry&); void initializeOptimizePHIsPass(PassRegistry&); +void initializePartiallyInlineLibCallsPass(PassRegistry&); void initializePEIPass(PassRegistry&); void initializePHIEliminationPass(PassRegistry&); void initializePartialInlinerPass(PassRegistry&); diff --git a/include/llvm/LinkAllPasses.h b/include/llvm/LinkAllPasses.h index ec39829..ec1ca49 100644 --- a/include/llvm/LinkAllPasses.h +++ b/include/llvm/LinkAllPasses.h @@ -163,6 +163,7 @@ namespace { (void) llvm::createLoopVectorizePass(); (void) llvm::createSLPVectorizerPass(); (void) llvm::createBBVectorizePass(); + (void) llvm::createPartiallyInlineLibCallsPass(); (void)new llvm::IntervalPartition(); (void)new llvm::FindUsedTypes(); diff --git a/include/llvm/Transforms/Scalar.h b/include/llvm/Transforms/Scalar.h index 037ab6b..eec9e59 100644 --- a/include/llvm/Transforms/Scalar.h +++ b/include/llvm/Transforms/Scalar.h @@ -354,6 +354,13 @@ extern char &InstructionSimplifierID; FunctionPass *createLowerExpectIntrinsicPass(); +//===----------------------------------------------------------------------===// +// +// PartiallyInlineLibCalls - Tries to inline the fast path of library +// calls such as sqrt. +// +FunctionPass *createPartiallyInlineLibCallsPass(); + } // End llvm namespace #endif -- cgit v1.1 From 5768bb8d77892926dff0d078b1fb08c14ea791f3 Mon Sep 17 00:00:00 2001 From: Andrea Di Biagio Date: Fri, 23 Aug 2013 11:53:55 +0000 Subject: Add function attribute 'optnone'. This function attribute indicates that the function is not optimized by any optimization or code generator passes with the exception of interprocedural optimization passes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189101 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 5 +++-- include/llvm/Bitcode/LLVMBitCodes.h | 3 ++- include/llvm/IR/Attributes.h | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index a7d17b7..57834c5 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -165,8 +165,9 @@ typedef enum { a temporary measure until the API/ABI impact to the C API is understood and the path forward agreed upon. LLVMAddressSafety = 1ULL << 32, - LLVMStackProtectStrongAttribute = 1ULL<<33 - LLVMCold = 1ULL << 34 + LLVMStackProtectStrongAttribute = 1ULL<<33, + LLVMCold = 1ULL << 34, + LLVMOptimizeNone = 1ULL << 35 */ } LLVMAttribute; diff --git a/include/llvm/Bitcode/LLVMBitCodes.h b/include/llvm/Bitcode/LLVMBitCodes.h index 463e3b9..90e9063 100644 --- a/include/llvm/Bitcode/LLVMBitCodes.h +++ b/include/llvm/Bitcode/LLVMBitCodes.h @@ -368,7 +368,8 @@ namespace bitc { ATTR_KIND_UW_TABLE = 33, ATTR_KIND_Z_EXT = 34, ATTR_KIND_BUILTIN = 35, - ATTR_KIND_COLD = 36 + ATTR_KIND_COLD = 36, + ATTR_KIND_OPTIMIZE_NONE = 37 }; } // End bitc namespace diff --git a/include/llvm/IR/Attributes.h b/include/llvm/IR/Attributes.h index 2183758..ebee637 100644 --- a/include/llvm/IR/Attributes.h +++ b/include/llvm/IR/Attributes.h @@ -88,6 +88,7 @@ public: NoReturn, ///< Mark the function as not returning NoUnwind, ///< Function doesn't unwind stack OptimizeForSize, ///< opt_size + OptimizeNone, ///< Function must not be optimized. ReadNone, ///< Function does not access memory ReadOnly, ///< Function only reads from memory Returned, ///< Return value is always equal to this argument -- cgit v1.1 From e307a9c58ce91dfde160c9a4acf28bfcdedfb498 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Fri, 23 Aug 2013 12:21:25 +0000 Subject: [mips][msa] Few MSA Builtins have side-effects. Added IntrNoMem to those that don't. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189106 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 767 +++++++++++++++++++++----------------- 1 file changed, 419 insertions(+), 348 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index ed3f70d..6f56af7 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -394,322 +394,362 @@ def int_mips_subuh_r_qb: GCCBuiltin<"__builtin_mips_subuh_r_qb">, // Addition/subtraction def int_mips_add_a_b : GCCBuiltin<"__builtin_msa_add_a_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], + [Commutative, IntrNoMem]>; def int_mips_add_a_h : GCCBuiltin<"__builtin_msa_add_a_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], + [Commutative, IntrNoMem]>; def int_mips_add_a_w : GCCBuiltin<"__builtin_msa_add_a_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], + [Commutative, IntrNoMem]>; def int_mips_add_a_d : GCCBuiltin<"__builtin_msa_add_a_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], + [Commutative, IntrNoMem]>; def int_mips_adds_a_b : GCCBuiltin<"__builtin_msa_adds_a_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], + [Commutative, IntrNoMem]>; def int_mips_adds_a_h : GCCBuiltin<"__builtin_msa_adds_a_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], + [Commutative, IntrNoMem]>; def int_mips_adds_a_w : GCCBuiltin<"__builtin_msa_adds_a_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], + [Commutative, IntrNoMem]>; def int_mips_adds_a_d : GCCBuiltin<"__builtin_msa_adds_a_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], + [Commutative, IntrNoMem]>; def int_mips_adds_s_b : GCCBuiltin<"__builtin_msa_adds_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], + [Commutative, IntrNoMem]>; def int_mips_adds_s_h : GCCBuiltin<"__builtin_msa_adds_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], + [Commutative, IntrNoMem]>; def int_mips_adds_s_w : GCCBuiltin<"__builtin_msa_adds_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], + [Commutative, IntrNoMem]>; def int_mips_adds_s_d : GCCBuiltin<"__builtin_msa_adds_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], + [Commutative, IntrNoMem]>; def int_mips_adds_u_b : GCCBuiltin<"__builtin_msa_adds_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], + [Commutative, IntrNoMem]>; def int_mips_adds_u_h : GCCBuiltin<"__builtin_msa_adds_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], + [Commutative, IntrNoMem]>; def int_mips_adds_u_w : GCCBuiltin<"__builtin_msa_adds_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], + [Commutative, IntrNoMem]>; def int_mips_adds_u_d : GCCBuiltin<"__builtin_msa_adds_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], + [Commutative, IntrNoMem]>; def int_mips_addv_b : GCCBuiltin<"__builtin_msa_addv_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], + [Commutative, IntrNoMem]>; def int_mips_addv_h : GCCBuiltin<"__builtin_msa_addv_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], + [Commutative, IntrNoMem]>; def int_mips_addv_w : GCCBuiltin<"__builtin_msa_addv_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], + [Commutative, IntrNoMem]>; def int_mips_addv_d : GCCBuiltin<"__builtin_msa_addv_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], + [Commutative, IntrNoMem]>; def int_mips_addvi_b : GCCBuiltin<"__builtin_msa_addvi_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [Commutative]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], + [Commutative, IntrNoMem]>; def int_mips_addvi_h : GCCBuiltin<"__builtin_msa_addvi_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [Commutative]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], + [Commutative, IntrNoMem]>; def int_mips_addvi_w : GCCBuiltin<"__builtin_msa_addvi_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [Commutative]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], + [Commutative, IntrNoMem]>; def int_mips_addvi_d : GCCBuiltin<"__builtin_msa_addvi_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [Commutative]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], + [Commutative, IntrNoMem]>; def int_mips_and_v : GCCBuiltin<"__builtin_msa_and_v">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_andi_b : GCCBuiltin<"__builtin_msa_andi_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_asub_s_b : GCCBuiltin<"__builtin_msa_asub_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_asub_s_h : GCCBuiltin<"__builtin_msa_asub_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_asub_s_w : GCCBuiltin<"__builtin_msa_asub_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_asub_s_d : GCCBuiltin<"__builtin_msa_asub_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_asub_u_b : GCCBuiltin<"__builtin_msa_asub_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_asub_u_h : GCCBuiltin<"__builtin_msa_asub_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_asub_u_w : GCCBuiltin<"__builtin_msa_asub_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_asub_u_d : GCCBuiltin<"__builtin_msa_asub_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_ave_s_b : GCCBuiltin<"__builtin_msa_ave_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], + [Commutative, IntrNoMem]>; def int_mips_ave_s_h : GCCBuiltin<"__builtin_msa_ave_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], + [Commutative, IntrNoMem]>; def int_mips_ave_s_w : GCCBuiltin<"__builtin_msa_ave_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], + [Commutative, IntrNoMem]>; def int_mips_ave_s_d : GCCBuiltin<"__builtin_msa_ave_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], + [Commutative, IntrNoMem]>; def int_mips_ave_u_b : GCCBuiltin<"__builtin_msa_ave_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], + [Commutative, IntrNoMem]>; def int_mips_ave_u_h : GCCBuiltin<"__builtin_msa_ave_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], + [Commutative, IntrNoMem]>; def int_mips_ave_u_w : GCCBuiltin<"__builtin_msa_ave_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], + [Commutative, IntrNoMem]>; def int_mips_ave_u_d : GCCBuiltin<"__builtin_msa_ave_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], + [Commutative, IntrNoMem]>; def int_mips_aver_s_b : GCCBuiltin<"__builtin_msa_aver_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], + [Commutative, IntrNoMem]>; def int_mips_aver_s_h : GCCBuiltin<"__builtin_msa_aver_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], + [Commutative, IntrNoMem]>; def int_mips_aver_s_w : GCCBuiltin<"__builtin_msa_aver_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], + [Commutative, IntrNoMem]>; def int_mips_aver_s_d : GCCBuiltin<"__builtin_msa_aver_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], + [Commutative, IntrNoMem]>; def int_mips_aver_u_b : GCCBuiltin<"__builtin_msa_aver_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], + [Commutative, IntrNoMem]>; def int_mips_aver_u_h : GCCBuiltin<"__builtin_msa_aver_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], + [Commutative, IntrNoMem]>; def int_mips_aver_u_w : GCCBuiltin<"__builtin_msa_aver_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], + [Commutative, IntrNoMem]>; def int_mips_aver_u_d : GCCBuiltin<"__builtin_msa_aver_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], + [Commutative, IntrNoMem]>; def int_mips_bclr_b : GCCBuiltin<"__builtin_msa_bclr_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_bclr_h : GCCBuiltin<"__builtin_msa_bclr_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_bclr_w : GCCBuiltin<"__builtin_msa_bclr_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_bclr_d : GCCBuiltin<"__builtin_msa_bclr_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_bclri_b : GCCBuiltin<"__builtin_msa_bclri_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_bclri_h : GCCBuiltin<"__builtin_msa_bclri_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_bclri_w : GCCBuiltin<"__builtin_msa_bclri_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_bclri_d : GCCBuiltin<"__builtin_msa_bclri_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_binsl_b : GCCBuiltin<"__builtin_msa_binsl_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_binsl_h : GCCBuiltin<"__builtin_msa_binsl_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_binsl_w : GCCBuiltin<"__builtin_msa_binsl_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_binsl_d : GCCBuiltin<"__builtin_msa_binsl_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_binsli_b : GCCBuiltin<"__builtin_msa_binsli_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_binsli_h : GCCBuiltin<"__builtin_msa_binsli_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_binsli_w : GCCBuiltin<"__builtin_msa_binsli_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_binsli_d : GCCBuiltin<"__builtin_msa_binsli_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_binsr_b : GCCBuiltin<"__builtin_msa_binsr_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_binsr_h : GCCBuiltin<"__builtin_msa_binsr_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_binsr_w : GCCBuiltin<"__builtin_msa_binsr_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_binsr_d : GCCBuiltin<"__builtin_msa_binsr_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_binsri_b : GCCBuiltin<"__builtin_msa_binsri_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_binsri_h : GCCBuiltin<"__builtin_msa_binsri_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_binsri_w : GCCBuiltin<"__builtin_msa_binsri_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_binsri_d : GCCBuiltin<"__builtin_msa_binsri_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_bmnz_v : GCCBuiltin<"__builtin_msa_bmnz_v">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_bmnzi_b : GCCBuiltin<"__builtin_msa_bmnzi_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_bmz_v : GCCBuiltin<"__builtin_msa_bmz_v">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_bmzi_b : GCCBuiltin<"__builtin_msa_bmzi_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_bneg_b : GCCBuiltin<"__builtin_msa_bneg_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_bneg_h : GCCBuiltin<"__builtin_msa_bneg_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_bneg_w : GCCBuiltin<"__builtin_msa_bneg_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_bneg_d : GCCBuiltin<"__builtin_msa_bneg_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_bnegi_b : GCCBuiltin<"__builtin_msa_bnegi_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_bnegi_h : GCCBuiltin<"__builtin_msa_bnegi_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_bnegi_w : GCCBuiltin<"__builtin_msa_bnegi_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_bnegi_d : GCCBuiltin<"__builtin_msa_bnegi_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_bsel_v : GCCBuiltin<"__builtin_msa_bsel_v">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_bseli_b : GCCBuiltin<"__builtin_msa_bseli_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_bseli_h : GCCBuiltin<"__builtin_msa_bseli_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_bseli_w : GCCBuiltin<"__builtin_msa_bseli_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_bseli_d : GCCBuiltin<"__builtin_msa_bseli_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_bset_b : GCCBuiltin<"__builtin_msa_bset_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_bset_h : GCCBuiltin<"__builtin_msa_bset_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_bset_w : GCCBuiltin<"__builtin_msa_bset_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_bset_d : GCCBuiltin<"__builtin_msa_bset_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_bseti_b : GCCBuiltin<"__builtin_msa_bseti_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_bseti_h : GCCBuiltin<"__builtin_msa_bseti_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_bseti_w : GCCBuiltin<"__builtin_msa_bseti_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_bseti_d : GCCBuiltin<"__builtin_msa_bseti_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_ceq_b : GCCBuiltin<"__builtin_msa_ceq_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_ceq_h : GCCBuiltin<"__builtin_msa_ceq_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_ceq_w : GCCBuiltin<"__builtin_msa_ceq_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_ceq_d : GCCBuiltin<"__builtin_msa_ceq_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_ceqi_b : GCCBuiltin<"__builtin_msa_ceqi_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_ceqi_h : GCCBuiltin<"__builtin_msa_ceqi_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_ceqi_w : GCCBuiltin<"__builtin_msa_ceqi_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_ceqi_d : GCCBuiltin<"__builtin_msa_ceqi_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_cle_s_b : GCCBuiltin<"__builtin_msa_cle_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_cle_s_h : GCCBuiltin<"__builtin_msa_cle_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_cle_s_w : GCCBuiltin<"__builtin_msa_cle_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_cle_s_d : GCCBuiltin<"__builtin_msa_cle_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_cle_u_b : GCCBuiltin<"__builtin_msa_cle_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_cle_u_h : GCCBuiltin<"__builtin_msa_cle_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_cle_u_w : GCCBuiltin<"__builtin_msa_cle_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_cle_u_d : GCCBuiltin<"__builtin_msa_cle_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_clei_s_b : GCCBuiltin<"__builtin_msa_clei_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_clei_s_h : GCCBuiltin<"__builtin_msa_clei_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_clei_s_w : GCCBuiltin<"__builtin_msa_clei_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_clei_s_d : GCCBuiltin<"__builtin_msa_clei_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_clei_u_b : GCCBuiltin<"__builtin_msa_clei_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_clei_u_h : GCCBuiltin<"__builtin_msa_clei_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_clei_u_w : GCCBuiltin<"__builtin_msa_clei_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_clei_u_d : GCCBuiltin<"__builtin_msa_clei_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_clt_s_b : GCCBuiltin<"__builtin_msa_clt_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_clt_s_h : GCCBuiltin<"__builtin_msa_clt_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_clt_s_w : GCCBuiltin<"__builtin_msa_clt_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_clt_s_d : GCCBuiltin<"__builtin_msa_clt_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_clt_u_b : GCCBuiltin<"__builtin_msa_clt_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_clt_u_h : GCCBuiltin<"__builtin_msa_clt_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_clt_u_w : GCCBuiltin<"__builtin_msa_clt_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_clt_u_d : GCCBuiltin<"__builtin_msa_clt_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_clti_s_b : GCCBuiltin<"__builtin_msa_clti_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_clti_s_h : GCCBuiltin<"__builtin_msa_clti_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_clti_s_w : GCCBuiltin<"__builtin_msa_clti_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_clti_s_d : GCCBuiltin<"__builtin_msa_clti_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_clti_u_b : GCCBuiltin<"__builtin_msa_clti_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_clti_u_h : GCCBuiltin<"__builtin_msa_clti_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_clti_u_w : GCCBuiltin<"__builtin_msa_clti_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_clti_u_d : GCCBuiltin<"__builtin_msa_clti_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_copy_s_b : GCCBuiltin<"__builtin_msa_copy_s_b">, Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; @@ -726,68 +766,80 @@ def int_mips_copy_u_w : GCCBuiltin<"__builtin_msa_copy_u_w">, Intrinsic<[llvm_i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; def int_mips_div_s_b : GCCBuiltin<"__builtin_msa_div_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_div_s_h : GCCBuiltin<"__builtin_msa_div_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_div_s_w : GCCBuiltin<"__builtin_msa_div_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_div_s_d : GCCBuiltin<"__builtin_msa_div_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_div_u_b : GCCBuiltin<"__builtin_msa_div_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_div_u_h : GCCBuiltin<"__builtin_msa_div_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_div_u_w : GCCBuiltin<"__builtin_msa_div_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_div_u_d : GCCBuiltin<"__builtin_msa_div_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_dotp_s_b : GCCBuiltin<"__builtin_msa_dotp_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_dotp_s_h : GCCBuiltin<"__builtin_msa_dotp_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_dotp_s_w : GCCBuiltin<"__builtin_msa_dotp_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_dotp_s_d : GCCBuiltin<"__builtin_msa_dotp_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_dotp_u_b : GCCBuiltin<"__builtin_msa_dotp_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_dotp_u_h : GCCBuiltin<"__builtin_msa_dotp_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_dotp_u_w : GCCBuiltin<"__builtin_msa_dotp_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_dotp_u_d : GCCBuiltin<"__builtin_msa_dotp_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_dpadd_s_h : GCCBuiltin<"__builtin_msa_dpadd_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v16i8_ty, llvm_v16i8_ty], + [IntrNoMem]>; def int_mips_dpadd_s_w : GCCBuiltin<"__builtin_msa_dpadd_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v8i16_ty, llvm_v8i16_ty], + [IntrNoMem]>; def int_mips_dpadd_s_d : GCCBuiltin<"__builtin_msa_dpadd_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v4i32_ty, llvm_v4i32_ty], + [IntrNoMem]>; def int_mips_dpadd_u_h : GCCBuiltin<"__builtin_msa_dpadd_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v16i8_ty, llvm_v16i8_ty], + [IntrNoMem]>; def int_mips_dpadd_u_w : GCCBuiltin<"__builtin_msa_dpadd_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v8i16_ty, llvm_v8i16_ty], + [IntrNoMem]>; def int_mips_dpadd_u_d : GCCBuiltin<"__builtin_msa_dpadd_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v4i32_ty, llvm_v4i32_ty], + [IntrNoMem]>; def int_mips_dpsub_s_h : GCCBuiltin<"__builtin_msa_dpsub_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v16i8_ty, llvm_v16i8_ty], + [IntrNoMem]>; def int_mips_dpsub_s_w : GCCBuiltin<"__builtin_msa_dpsub_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v8i16_ty, llvm_v8i16_ty], + [IntrNoMem]>; def int_mips_dpsub_s_d : GCCBuiltin<"__builtin_msa_dpsub_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v4i32_ty, llvm_v4i32_ty], + [IntrNoMem]>; def int_mips_dpsub_u_h : GCCBuiltin<"__builtin_msa_dpsub_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v16i8_ty, llvm_v16i8_ty], + [IntrNoMem]>; def int_mips_dpsub_u_w : GCCBuiltin<"__builtin_msa_dpsub_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v8i16_ty, llvm_v8i16_ty], + [IntrNoMem]>; def int_mips_dpsub_u_d : GCCBuiltin<"__builtin_msa_dpsub_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v4i32_ty, llvm_v4i32_ty], + [IntrNoMem]>; def int_mips_fadd_w : GCCBuiltin<"__builtin_msa_fadd_w">, Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; @@ -810,9 +862,9 @@ def int_mips_fclt_d : GCCBuiltin<"__builtin_msa_fclt_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; def int_mips_fclass_w : GCCBuiltin<"__builtin_msa_fclass_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fclass_d : GCCBuiltin<"__builtin_msa_fclass_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fcne_w : GCCBuiltin<"__builtin_msa_fcne_w">, Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; @@ -860,21 +912,21 @@ def int_mips_ffint_u_d : GCCBuiltin<"__builtin_msa_ffint_u_d">, Intrinsic<[llvm_v2f64_ty], [llvm_v2i64_ty], []>; def int_mips_ffql_w : GCCBuiltin<"__builtin_msa_ffql_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v8i16_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v8i16_ty], [IntrNoMem]>; def int_mips_ffql_d : GCCBuiltin<"__builtin_msa_ffql_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v4i32_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v4i32_ty], [IntrNoMem]>; def int_mips_ffqr_w : GCCBuiltin<"__builtin_msa_ffqr_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v8i16_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v8i16_ty], [IntrNoMem]>; def int_mips_ffqr_d : GCCBuiltin<"__builtin_msa_ffqr_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v4i32_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v4i32_ty], [IntrNoMem]>; def int_mips_fill_b : GCCBuiltin<"__builtin_msa_fill_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_i32_ty], [IntrNoMem]>; def int_mips_fill_h : GCCBuiltin<"__builtin_msa_fill_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_i32_ty], [IntrNoMem]>; def int_mips_fill_w : GCCBuiltin<"__builtin_msa_fill_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_i32_ty], [IntrNoMem]>; def int_mips_flog2_w : GCCBuiltin<"__builtin_msa_flog2_w">, Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], []>; @@ -977,47 +1029,50 @@ def int_mips_ftq_w : GCCBuiltin<"__builtin_msa_ftq_w">, Intrinsic<[llvm_v4i32_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; def int_mips_ilvev_b : GCCBuiltin<"__builtin_msa_ilvev_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_ilvev_h : GCCBuiltin<"__builtin_msa_ilvev_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_ilvev_w : GCCBuiltin<"__builtin_msa_ilvev_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_ilvev_d : GCCBuiltin<"__builtin_msa_ilvev_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_ilvl_b : GCCBuiltin<"__builtin_msa_ilvl_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_ilvl_h : GCCBuiltin<"__builtin_msa_ilvl_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_ilvl_w : GCCBuiltin<"__builtin_msa_ilvl_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_ilvl_d : GCCBuiltin<"__builtin_msa_ilvl_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_ilvod_b : GCCBuiltin<"__builtin_msa_ilvod_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_ilvod_h : GCCBuiltin<"__builtin_msa_ilvod_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_ilvod_w : GCCBuiltin<"__builtin_msa_ilvod_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_ilvod_d : GCCBuiltin<"__builtin_msa_ilvod_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_ilvr_b : GCCBuiltin<"__builtin_msa_ilvr_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_ilvr_h : GCCBuiltin<"__builtin_msa_ilvr_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_ilvr_w : GCCBuiltin<"__builtin_msa_ilvr_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_ilvr_d : GCCBuiltin<"__builtin_msa_ilvr_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_insert_b : GCCBuiltin<"__builtin_msa_insert_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty, llvm_i32_ty], + [IntrNoMem]>; def int_mips_insert_h : GCCBuiltin<"__builtin_msa_insert_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty, llvm_i32_ty], + [IntrNoMem]>; def int_mips_insert_w : GCCBuiltin<"__builtin_msa_insert_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty, llvm_i32_ty], + [IntrNoMem]>; def int_mips_insve_b : GCCBuiltin<"__builtin_msa_insve_b">, Intrinsic<[llvm_v16i8_ty], @@ -1037,350 +1092,366 @@ def int_mips_insve_d : GCCBuiltin<"__builtin_msa_insve_d">, [IntrNoMem]>; def int_mips_ldi_b : GCCBuiltin<"__builtin_msa_ldi_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_i32_ty], [IntrNoMem]>; def int_mips_ldi_h : GCCBuiltin<"__builtin_msa_ldi_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_i32_ty], [IntrNoMem]>; def int_mips_ldi_w : GCCBuiltin<"__builtin_msa_ldi_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_i32_ty], [IntrNoMem]>; def int_mips_ldi_d : GCCBuiltin<"__builtin_msa_ldi_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_i32_ty], [IntrNoMem]>; def int_mips_madd_q_h : GCCBuiltin<"__builtin_msa_madd_q_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], + [IntrNoMem]>; def int_mips_madd_q_w : GCCBuiltin<"__builtin_msa_madd_q_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], + [IntrNoMem]>; def int_mips_maddr_q_h : GCCBuiltin<"__builtin_msa_maddr_q_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], + [IntrNoMem]>; def int_mips_maddr_q_w : GCCBuiltin<"__builtin_msa_maddr_q_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], + [IntrNoMem]>; def int_mips_maddv_b : GCCBuiltin<"__builtin_msa_maddv_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty], + [IntrNoMem]>; def int_mips_maddv_h : GCCBuiltin<"__builtin_msa_maddv_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], + [IntrNoMem]>; def int_mips_maddv_w : GCCBuiltin<"__builtin_msa_maddv_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], + [IntrNoMem]>; def int_mips_maddv_d : GCCBuiltin<"__builtin_msa_maddv_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty], + [IntrNoMem]>; def int_mips_max_a_b : GCCBuiltin<"__builtin_msa_max_a_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_max_a_h : GCCBuiltin<"__builtin_msa_max_a_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_max_a_w : GCCBuiltin<"__builtin_msa_max_a_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_max_a_d : GCCBuiltin<"__builtin_msa_max_a_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_max_s_b : GCCBuiltin<"__builtin_msa_max_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_max_s_h : GCCBuiltin<"__builtin_msa_max_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_max_s_w : GCCBuiltin<"__builtin_msa_max_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_max_s_d : GCCBuiltin<"__builtin_msa_max_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_max_u_b : GCCBuiltin<"__builtin_msa_max_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_max_u_h : GCCBuiltin<"__builtin_msa_max_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_max_u_w : GCCBuiltin<"__builtin_msa_max_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_max_u_d : GCCBuiltin<"__builtin_msa_max_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_maxi_s_b : GCCBuiltin<"__builtin_msa_maxi_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_maxi_s_h : GCCBuiltin<"__builtin_msa_maxi_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_maxi_s_w : GCCBuiltin<"__builtin_msa_maxi_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_maxi_s_d : GCCBuiltin<"__builtin_msa_maxi_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_maxi_u_b : GCCBuiltin<"__builtin_msa_maxi_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_maxi_u_h : GCCBuiltin<"__builtin_msa_maxi_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_maxi_u_w : GCCBuiltin<"__builtin_msa_maxi_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_maxi_u_d : GCCBuiltin<"__builtin_msa_maxi_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_min_a_b : GCCBuiltin<"__builtin_msa_min_a_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_min_a_h : GCCBuiltin<"__builtin_msa_min_a_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_min_a_w : GCCBuiltin<"__builtin_msa_min_a_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_min_a_d : GCCBuiltin<"__builtin_msa_min_a_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_min_s_b : GCCBuiltin<"__builtin_msa_min_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_min_s_h : GCCBuiltin<"__builtin_msa_min_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_min_s_w : GCCBuiltin<"__builtin_msa_min_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_min_s_d : GCCBuiltin<"__builtin_msa_min_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_min_u_b : GCCBuiltin<"__builtin_msa_min_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_min_u_h : GCCBuiltin<"__builtin_msa_min_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_min_u_w : GCCBuiltin<"__builtin_msa_min_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_min_u_d : GCCBuiltin<"__builtin_msa_min_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_mini_s_b : GCCBuiltin<"__builtin_msa_mini_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_mini_s_h : GCCBuiltin<"__builtin_msa_mini_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_mini_s_w : GCCBuiltin<"__builtin_msa_mini_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_mini_s_d : GCCBuiltin<"__builtin_msa_mini_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_mini_u_b : GCCBuiltin<"__builtin_msa_mini_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_mini_u_h : GCCBuiltin<"__builtin_msa_mini_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_mini_u_w : GCCBuiltin<"__builtin_msa_mini_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_mini_u_d : GCCBuiltin<"__builtin_msa_mini_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_mod_s_b : GCCBuiltin<"__builtin_msa_mod_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_mod_s_h : GCCBuiltin<"__builtin_msa_mod_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_mod_s_w : GCCBuiltin<"__builtin_msa_mod_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_mod_s_d : GCCBuiltin<"__builtin_msa_mod_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_mod_u_b : GCCBuiltin<"__builtin_msa_mod_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_mod_u_h : GCCBuiltin<"__builtin_msa_mod_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_mod_u_w : GCCBuiltin<"__builtin_msa_mod_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_mod_u_d : GCCBuiltin<"__builtin_msa_mod_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_msub_q_h : GCCBuiltin<"__builtin_msa_msub_q_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], + [IntrNoMem]>; def int_mips_msub_q_w : GCCBuiltin<"__builtin_msa_msub_q_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], + [IntrNoMem]>; def int_mips_msubr_q_h : GCCBuiltin<"__builtin_msa_msubr_q_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], + [IntrNoMem]>; def int_mips_msubr_q_w : GCCBuiltin<"__builtin_msa_msubr_q_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], + [IntrNoMem]>; def int_mips_msubv_b : GCCBuiltin<"__builtin_msa_msubv_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty], + [IntrNoMem]>; def int_mips_msubv_h : GCCBuiltin<"__builtin_msa_msubv_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], + [IntrNoMem]>; def int_mips_msubv_w : GCCBuiltin<"__builtin_msa_msubv_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], + [IntrNoMem]>; def int_mips_msubv_d : GCCBuiltin<"__builtin_msa_msubv_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty], + [IntrNoMem]>; def int_mips_mul_q_h : GCCBuiltin<"__builtin_msa_mul_q_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_mul_q_w : GCCBuiltin<"__builtin_msa_mul_q_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_mulr_q_h : GCCBuiltin<"__builtin_msa_mulr_q_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_mulr_q_w : GCCBuiltin<"__builtin_msa_mulr_q_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_mulv_b : GCCBuiltin<"__builtin_msa_mulv_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_mulv_h : GCCBuiltin<"__builtin_msa_mulv_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_mulv_w : GCCBuiltin<"__builtin_msa_mulv_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_mulv_d : GCCBuiltin<"__builtin_msa_mulv_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_nloc_b : GCCBuiltin<"__builtin_msa_nloc_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], [IntrNoMem]>; def int_mips_nloc_h : GCCBuiltin<"__builtin_msa_nloc_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty], [IntrNoMem]>; def int_mips_nloc_w : GCCBuiltin<"__builtin_msa_nloc_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty], [IntrNoMem]>; def int_mips_nloc_d : GCCBuiltin<"__builtin_msa_nloc_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty], [IntrNoMem]>; def int_mips_nlzc_b : GCCBuiltin<"__builtin_msa_nlzc_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], [IntrNoMem]>; def int_mips_nlzc_h : GCCBuiltin<"__builtin_msa_nlzc_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty], [IntrNoMem]>; def int_mips_nlzc_w : GCCBuiltin<"__builtin_msa_nlzc_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty], [IntrNoMem]>; def int_mips_nlzc_d : GCCBuiltin<"__builtin_msa_nlzc_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty], [IntrNoMem]>; def int_mips_nor_v : GCCBuiltin<"__builtin_msa_nor_v">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_nori_b : GCCBuiltin<"__builtin_msa_nori_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_or_v : GCCBuiltin<"__builtin_msa_or_v">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_ori_b : GCCBuiltin<"__builtin_msa_ori_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_pckev_b : GCCBuiltin<"__builtin_msa_pckev_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_pckev_h : GCCBuiltin<"__builtin_msa_pckev_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_pckev_w : GCCBuiltin<"__builtin_msa_pckev_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_pckev_d : GCCBuiltin<"__builtin_msa_pckev_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_pckod_b : GCCBuiltin<"__builtin_msa_pckod_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_pckod_h : GCCBuiltin<"__builtin_msa_pckod_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_pckod_w : GCCBuiltin<"__builtin_msa_pckod_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_pckod_d : GCCBuiltin<"__builtin_msa_pckod_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_pcnt_b : GCCBuiltin<"__builtin_msa_pcnt_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], [IntrNoMem]>; def int_mips_pcnt_h : GCCBuiltin<"__builtin_msa_pcnt_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty], [IntrNoMem]>; def int_mips_pcnt_w : GCCBuiltin<"__builtin_msa_pcnt_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty], [IntrNoMem]>; def int_mips_pcnt_d : GCCBuiltin<"__builtin_msa_pcnt_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty], [IntrNoMem]>; def int_mips_sat_s_b : GCCBuiltin<"__builtin_msa_sat_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sat_s_h : GCCBuiltin<"__builtin_msa_sat_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sat_s_w : GCCBuiltin<"__builtin_msa_sat_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sat_s_d : GCCBuiltin<"__builtin_msa_sat_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sat_u_b : GCCBuiltin<"__builtin_msa_sat_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sat_u_h : GCCBuiltin<"__builtin_msa_sat_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sat_u_w : GCCBuiltin<"__builtin_msa_sat_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sat_u_d : GCCBuiltin<"__builtin_msa_sat_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_shf_b : GCCBuiltin<"__builtin_msa_shf_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_shf_h : GCCBuiltin<"__builtin_msa_shf_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_shf_w : GCCBuiltin<"__builtin_msa_shf_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sld_b : GCCBuiltin<"__builtin_msa_sld_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_sld_h : GCCBuiltin<"__builtin_msa_sld_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_sld_w : GCCBuiltin<"__builtin_msa_sld_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_sld_d : GCCBuiltin<"__builtin_msa_sld_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_sldi_b : GCCBuiltin<"__builtin_msa_sldi_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sldi_h : GCCBuiltin<"__builtin_msa_sldi_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sldi_w : GCCBuiltin<"__builtin_msa_sldi_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sldi_d : GCCBuiltin<"__builtin_msa_sldi_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sll_b : GCCBuiltin<"__builtin_msa_sll_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_sll_h : GCCBuiltin<"__builtin_msa_sll_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_sll_w : GCCBuiltin<"__builtin_msa_sll_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_sll_d : GCCBuiltin<"__builtin_msa_sll_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_slli_b : GCCBuiltin<"__builtin_msa_slli_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_slli_h : GCCBuiltin<"__builtin_msa_slli_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_slli_w : GCCBuiltin<"__builtin_msa_slli_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_slli_d : GCCBuiltin<"__builtin_msa_slli_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_splat_b : GCCBuiltin<"__builtin_msa_splat_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_splat_h : GCCBuiltin<"__builtin_msa_splat_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_splat_w : GCCBuiltin<"__builtin_msa_splat_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_splat_d : GCCBuiltin<"__builtin_msa_splat_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_splati_b : GCCBuiltin<"__builtin_msa_splati_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_splati_h : GCCBuiltin<"__builtin_msa_splati_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_splati_w : GCCBuiltin<"__builtin_msa_splati_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_splati_d : GCCBuiltin<"__builtin_msa_splati_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sra_b : GCCBuiltin<"__builtin_msa_sra_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_sra_h : GCCBuiltin<"__builtin_msa_sra_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_sra_w : GCCBuiltin<"__builtin_msa_sra_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_sra_d : GCCBuiltin<"__builtin_msa_sra_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_srai_b : GCCBuiltin<"__builtin_msa_srai_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_srai_h : GCCBuiltin<"__builtin_msa_srai_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_srai_w : GCCBuiltin<"__builtin_msa_srai_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_srai_d : GCCBuiltin<"__builtin_msa_srai_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_srl_b : GCCBuiltin<"__builtin_msa_srl_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_srl_h : GCCBuiltin<"__builtin_msa_srl_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_srl_w : GCCBuiltin<"__builtin_msa_srl_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_srl_d : GCCBuiltin<"__builtin_msa_srl_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_srli_b : GCCBuiltin<"__builtin_msa_srli_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_srli_h : GCCBuiltin<"__builtin_msa_srli_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_srli_w : GCCBuiltin<"__builtin_msa_srli_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_srli_d : GCCBuiltin<"__builtin_msa_srli_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_subs_s_b : GCCBuiltin<"__builtin_msa_subs_s_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; @@ -1446,8 +1517,8 @@ def int_mips_vshf_d : GCCBuiltin<"__builtin_msa_vshf_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; def int_mips_xor_v : GCCBuiltin<"__builtin_msa_xor_v">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_xori_b : GCCBuiltin<"__builtin_msa_xori_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; } -- cgit v1.1 From d2763f6ce62eaa497e944331668414e35f3712f3 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Fri, 23 Aug 2013 17:48:33 +0000 Subject: mi-sched: Don't call MBB.size() in initSUnits. The driver already has instr count. This fixes a pathological compile time problem with very large blocks and lots of scheduling boundaries. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189116 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineScheduler.h | 3 +-- include/llvm/CodeGen/ScheduleDAGInstrs.h | 10 +++------- 2 files changed, 4 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineScheduler.h b/include/llvm/CodeGen/MachineScheduler.h index d110ea1..2749a19 100644 --- a/include/llvm/CodeGen/MachineScheduler.h +++ b/include/llvm/CodeGen/MachineScheduler.h @@ -293,8 +293,7 @@ public: void enterRegion(MachineBasicBlock *bb, MachineBasicBlock::iterator begin, MachineBasicBlock::iterator end, - unsigned endcount); - + unsigned regioninstrs) LLVM_OVERRIDE; /// Implement ScheduleDAGInstrs interface for scheduling a sequence of /// reorderable instructions. diff --git a/include/llvm/CodeGen/ScheduleDAGInstrs.h b/include/llvm/CodeGen/ScheduleDAGInstrs.h index 9ab1013..358793d 100644 --- a/include/llvm/CodeGen/ScheduleDAGInstrs.h +++ b/include/llvm/CodeGen/ScheduleDAGInstrs.h @@ -104,12 +104,8 @@ namespace llvm { /// The end of the range to be scheduled. MachineBasicBlock::iterator RegionEnd; - /// The index in BB of RegionEnd. - /// - /// This is the instruction number from the top of the current block, not - /// the SlotIndex. It is only used by the AntiDepBreaker and should be - /// removed once that client is obsolete. - unsigned EndIndex; + /// Instructions in this region (distance(RegionBegin, RegionEnd)). + unsigned NumRegionInstrs; /// After calling BuildSchedGraph, each machine instruction in the current /// scheduling region is mapped to an SUnit. @@ -185,7 +181,7 @@ namespace llvm { virtual void enterRegion(MachineBasicBlock *bb, MachineBasicBlock::iterator begin, MachineBasicBlock::iterator end, - unsigned endcount); + unsigned regioninstrs); /// Notify that the scheduler has finished scheduling the current region. virtual void exitRegion(); -- cgit v1.1 From c7a8d3e31d3f2fd9be02cad832131b425930fa09 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Fri, 23 Aug 2013 17:48:36 +0000 Subject: Remove unused field. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189117 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/ScheduleDAGInstrs.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/ScheduleDAGInstrs.h b/include/llvm/CodeGen/ScheduleDAGInstrs.h index 358793d..e22ac25 100644 --- a/include/llvm/CodeGen/ScheduleDAGInstrs.h +++ b/include/llvm/CodeGen/ScheduleDAGInstrs.h @@ -81,10 +81,6 @@ namespace llvm { /// isPostRA flag indicates vregs cannot be present. bool IsPostRA; - /// UnitLatencies (misnamed) flag avoids computing def-use latencies, using - /// the def-side latency only. - bool UnitLatencies; - /// The standard DAG builder does not normally include terminators as DAG /// nodes because it does not create the necessary dependencies to prevent /// reordering. A specialized scheduler can overide -- cgit v1.1 From 99093638a024fc23609a323677e67bb1dc63ebe7 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Fri, 23 Aug 2013 17:48:39 +0000 Subject: MI Sched: record local vreg uses. This will be used to compute the cyclic critical path and to update precomputed per-node pressure differences. In the longer term, it could also be used to speed up LiveInterval update by avoiding visiting all global vreg users. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189118 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/ScheduleDAGInstrs.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/ScheduleDAGInstrs.h b/include/llvm/CodeGen/ScheduleDAGInstrs.h index e22ac25..4a447e2 100644 --- a/include/llvm/CodeGen/ScheduleDAGInstrs.h +++ b/include/llvm/CodeGen/ScheduleDAGInstrs.h @@ -56,7 +56,8 @@ namespace llvm { /// Use a SparseMultiSet to track physical registers. Storage is only /// allocated once for the pass. It can be cleared in constant time and reused /// without any frees. - typedef SparseMultiSet, uint16_t> Reg2SUnitsMap; + typedef SparseMultiSet, uint16_t> + Reg2SUnitsMap; /// Use SparseSet as a SparseMap by relying on the fact that it never /// compares ValueT's, only unsigned keys. This allows the set to be cleared @@ -64,6 +65,11 @@ namespace llvm { /// require a destructor. typedef SparseSet VReg2SUnitMap; + /// Track local uses of virtual registers. These uses are gathered by the DAG + /// builder and may be consulted by the scheduler to avoid iterating an entire + /// vreg use list. + typedef SparseMultiSet VReg2UseMap; + /// ScheduleDAGInstrs - A ScheduleDAG subclass for scheduling lists of /// MachineInstrs. class ScheduleDAGInstrs : public ScheduleDAG { @@ -107,6 +113,11 @@ namespace llvm { /// scheduling region is mapped to an SUnit. DenseMap MISUnitMap; + /// After calling BuildSchedGraph, each vreg used in the scheduling region + /// is mapped to a set of SUnits. These include all local vreg uses, not + /// just the uses for a singly defined vreg. + VReg2UseMap VRegUses; + /// State internal to DAG building. /// ------------------------------- -- cgit v1.1 From ea57433cee8bd59acaa99d148b45df92347cea68 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Fri, 23 Aug 2013 17:48:43 +0000 Subject: Adds cyclic critical path computation and heuristics, temporarily disabled. Estimate the cyclic critical path within a single block loop. If the acyclic critical path is longer, then the loop will exhaust OOO resources after some number of iterations. If lag between the acyclic critical path and cyclic critical path is longer the the time it takes to issue those loop iterations, then aggressively schedule for latency. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189120 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/ScheduleDAGInstrs.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/ScheduleDAGInstrs.h b/include/llvm/CodeGen/ScheduleDAGInstrs.h index 4a447e2..1b81314 100644 --- a/include/llvm/CodeGen/ScheduleDAGInstrs.h +++ b/include/llvm/CodeGen/ScheduleDAGInstrs.h @@ -197,6 +197,9 @@ namespace llvm { /// input. void buildSchedGraph(AliasAnalysis *AA, RegPressureTracker *RPTracker = 0); + /// Compute the cyclic critical path through the DAG. + unsigned computeCyclicCriticalPath(); + /// addSchedBarrierDeps - Add dependencies from instructions in the current /// list of instructions being scheduled to scheduling barrier. We want to /// make sure instructions which define registers that are either used by -- cgit v1.1 From 238bf5ada19ee411c1decff68e140966f7baf479 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Fri, 23 Aug 2013 17:48:46 +0000 Subject: Add a convenient PSetIterator for visiting pressure sets affected by a register. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189121 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineRegisterInfo.h | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineRegisterInfo.h b/include/llvm/CodeGen/MachineRegisterInfo.h index 4fb1ac9..736a0a2 100644 --- a/include/llvm/CodeGen/MachineRegisterInfo.h +++ b/include/llvm/CodeGen/MachineRegisterInfo.h @@ -22,6 +22,7 @@ #include namespace llvm { +class PSetIterator; /// MachineRegisterInfo - Keep track of information for virtual and physical /// registers, including vreg register classes, use/def chains for registers, @@ -326,6 +327,11 @@ public: /// a physreg. bool isConstantPhysReg(unsigned PhysReg, const MachineFunction &MF) const; + /// Get an iterator over the pressure sets affected by the given physical or + /// virtual register. If RegUnit is physical, it must be a register unit (from + /// MCRegUnitIterator). + PSetIterator getPressureSets(unsigned RegUnit) const; + //===--------------------------------------------------------------------===// // Virtual Register Info //===--------------------------------------------------------------------===// @@ -647,9 +653,49 @@ public: return Op->getParent(); } }; +}; +/// Iterate over the pressure sets affected by the given physical or virtual +/// register. If Reg is physical, it must be a register unit (from +/// MCRegUnitIterator). +class PSetIterator { + const int *PSet; + unsigned Weight; +public: + PSetIterator(): PSet(0), Weight(0) {} + PSetIterator(unsigned RegUnit, const MachineRegisterInfo *MRI) { + const TargetRegisterInfo *TRI = MRI->getTargetRegisterInfo(); + if (TargetRegisterInfo::isVirtualRegister(RegUnit)) { + const TargetRegisterClass *RC = MRI->getRegClass(RegUnit); + PSet = TRI->getRegClassPressureSets(RC); + Weight = TRI->getRegClassWeight(RC).RegWeight; + } + else { + PSet = TRI->getRegUnitPressureSets(RegUnit); + Weight = TRI->getRegUnitWeight(RegUnit); + } + if (*PSet == -1) + PSet = 0; + } + bool isValid() const { return PSet; } + + unsigned getWeight() const { return Weight; } + + unsigned operator*() const { return *PSet; } + + void operator++() { + assert(isValid() && "Invalid PSetIterator."); + ++PSet; + if (*PSet == -1) + PSet = 0; + } }; +inline PSetIterator MachineRegisterInfo:: +getPressureSets(unsigned RegUnit) const { + return PSetIterator(RegUnit, this); +} + } // End llvm namespace #endif -- cgit v1.1 From 12d3dc73dc44acd8b11cca783b826ccbd66f44da Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Fri, 23 Aug 2013 17:48:53 +0000 Subject: PrintVRegOrUnit git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189124 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetRegisterInfo.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include') diff --git a/include/llvm/Target/TargetRegisterInfo.h b/include/llvm/Target/TargetRegisterInfo.h index 82fccde..958bea6 100644 --- a/include/llvm/Target/TargetRegisterInfo.h +++ b/include/llvm/Target/TargetRegisterInfo.h @@ -901,6 +901,7 @@ static inline raw_ostream &operator<<(raw_ostream &OS, const PrintReg &PR) { /// Usage: OS << PrintRegUnit(Unit, TRI) << '\n'; /// class PrintRegUnit { +protected: const TargetRegisterInfo *TRI; unsigned Unit; public: @@ -914,6 +915,21 @@ static inline raw_ostream &operator<<(raw_ostream &OS, const PrintRegUnit &PR) { return OS; } +/// PrintVRegOrUnit - It is often convenient to track virtual registers and +/// physical register units in the same list. +class PrintVRegOrUnit : protected PrintRegUnit { +public: + PrintVRegOrUnit(unsigned VRegOrUnit, const TargetRegisterInfo *tri) + : PrintRegUnit(VRegOrUnit, tri) {} + void print(raw_ostream&) const; +}; + +static inline raw_ostream &operator<<(raw_ostream &OS, + const PrintVRegOrUnit &PR) { + PR.print(OS); + return OS; +} + } // End llvm namespace #endif -- cgit v1.1 From 4a48389b27cafe30a38592b50e0f4b9e97b9d65e Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Sat, 24 Aug 2013 01:50:41 +0000 Subject: Added const qualifier to StringRef::edit_distance member function Patch by Ismail Pazarbasi. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189162 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/StringRef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index 3e1e24c..fd5b28e 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -175,7 +175,7 @@ namespace llvm { /// transform one of the given strings into the other. If zero, /// the strings are identical. unsigned edit_distance(StringRef Other, bool AllowReplacements = true, - unsigned MaxEditDistance = 0); + unsigned MaxEditDistance = 0) const; /// str - Get the contents as an std::string. std::string str() const { -- cgit v1.1 From 0b6962f4be35aca7054ff68ef9bbbb2e03617d31 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 24 Aug 2013 12:54:27 +0000 Subject: Add a function object to compare the first or second component of a std::pair. Replace instances of this scattered around the code base. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189169 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/STLExtras.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include') diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h index dacda36..bfe1392 100644 --- a/include/llvm/ADT/STLExtras.h +++ b/include/llvm/ADT/STLExtras.h @@ -217,6 +217,22 @@ inline tier tie(T1& f, T2& s) { return tier(f, s); } +/// \brief Function object to check whether the first component of a std::pair +/// compares less than the first component of another std::pair. +struct less_first { + template bool operator()(const T &lhs, const T &rhs) const { + return lhs.first < rhs.first; + } +}; + +/// \brief Function object to check whether the second component of a std::pair +/// compares less than the second component of another std::pair. +struct less_second { + template bool operator()(const T &lhs, const T &rhs) const { + return lhs.second < rhs.second; + } +}; + //===----------------------------------------------------------------------===// // Extra additions for arrays //===----------------------------------------------------------------------===// -- cgit v1.1 From a6d055847068f8fe195603b96f07327c5abbfaeb Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sat, 24 Aug 2013 20:14:40 +0000 Subject: [Support] add missing enumeration values This adds additional missing Windows subsystem identifiers to the IMAGE_SUBSYSTEM enumeration. Signed-off-by: Saleem Abdulrasool git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189180 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/COFF.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/COFF.h b/include/llvm/Support/COFF.h index a39a3f9..74ae62b 100644 --- a/include/llvm/Support/COFF.h +++ b/include/llvm/Support/COFF.h @@ -511,7 +511,9 @@ namespace COFF { IMAGE_SUBSYSTEM_NATIVE = 1, ///< Device drivers and native Windows processes IMAGE_SUBSYSTEM_WINDOWS_GUI = 2, ///< The Windows GUI subsystem. IMAGE_SUBSYSTEM_WINDOWS_CUI = 3, ///< The Windows character subsystem. + IMAGE_SUBSYSTEM_OS2_CUI = 5, ///< The OS/2 character subsytem. IMAGE_SUBSYSTEM_POSIX_CUI = 7, ///< The POSIX character subsystem. + IMAGE_SUBSYSTEM_NATIVE_WINDOWS = 8, ///< Native Windows 9x driver. IMAGE_SUBSYSTEM_WINDOWS_CE_GUI = 9, ///< Windows CE. IMAGE_SUBSYSTEM_EFI_APPLICATION = 10, ///< An EFI application. IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER = 11, ///< An EFI driver with boot @@ -519,7 +521,8 @@ namespace COFF { IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER = 12, ///< An EFI driver with run-time /// services. IMAGE_SUBSYSTEM_EFI_ROM = 13, ///< An EFI ROM image. - IMAGE_SUBSYSTEM_XBOX = 14 ///< XBOX. + IMAGE_SUBSYSTEM_XBOX = 14, ///< XBOX. + IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16, ///< A BCD application. }; enum DLLCharacteristics { -- cgit v1.1 From 676537aaaaaefe982207da058af27bb09ad1949d Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Sat, 24 Aug 2013 20:35:16 +0000 Subject: [Support] fix compile with -Werror error: commas at the end of enumerator lists are a C++11 extension [-Werror,-Wc++11-extensions] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189183 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/COFF.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/COFF.h b/include/llvm/Support/COFF.h index 74ae62b..541d563c 100644 --- a/include/llvm/Support/COFF.h +++ b/include/llvm/Support/COFF.h @@ -522,7 +522,7 @@ namespace COFF { /// services. IMAGE_SUBSYSTEM_EFI_ROM = 13, ///< An EFI ROM image. IMAGE_SUBSYSTEM_XBOX = 14, ///< XBOX. - IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16, ///< A BCD application. + IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16 ///< A BCD application. }; enum DLLCharacteristics { -- cgit v1.1 From f27c35347aa9fdd36c4ed6268380e2574ccfc87f Mon Sep 17 00:00:00 2001 From: Jakub Staszak Date: Sun, 25 Aug 2013 19:48:46 +0000 Subject: Fix #include guard. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189199 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCModuleYAML.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCModuleYAML.h b/include/llvm/MC/MCModuleYAML.h index 0ea29da..281e3d8 100644 --- a/include/llvm/MC/MCModuleYAML.h +++ b/include/llvm/MC/MCModuleYAML.h @@ -13,8 +13,8 @@ /// //===----------------------------------------------------------------------===// -#ifndef LLVM_OBJECT_MCMODULEYAML_H -#define LLVM_OBJECT_MCMODULEYAML_H +#ifndef LLVM_MC_MCMODULEYAML_H +#define LLVM_MC_MCMODULEYAML_H #include "llvm/ADT/OwningPtr.h" #include "llvm/ADT/StringRef.h" -- cgit v1.1 From da25cd3e6de8f21005590c2de49868f883cf2410 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Mon, 26 Aug 2013 15:05:36 +0000 Subject: SelectionDAG: Use correct pointer size when lowering function arguments v2 This adds minimal support to the SelectionDAG for handling address spaces with different pointer sizes. The SelectionDAG should now correctly lower pointer function arguments to the correct size as well as generate the correct code when lowering getelementptr. This patch also updates the R600 DataLayout to use 32-bit pointers for the local address space. v2: - Add more helper functions to TargetLoweringBase - Use CHECK-LABEL for tests git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189221 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLowering.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 580a358..cd95a73 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -151,7 +151,9 @@ public: // Return the pointer type for the given address space, defaults to // the pointer type from the data layout. // FIXME: The default needs to be removed once all the code is updated. - virtual MVT getPointerTy(uint32_t /*AS*/ = 0) const { return PointerTy; } + virtual MVT getPointerTy(uint32_t /*AS*/ = 0) const; + unsigned getPointerSizeInBits(uint32_t AS = 0) const; + unsigned getPointerTypeSizeInBits(Type *Ty) const; virtual MVT getScalarShiftAmountTy(EVT LHSTy) const; EVT getShiftAmountTy(EVT LHSTy) const; @@ -568,7 +570,7 @@ public: /// otherwise it will assert. EVT getValueType(Type *Ty, bool AllowUnknown = false) const { // Lower scalar pointers to native pointer types. - if (Ty->isPointerTy()) return PointerTy; + if (Ty->isPointerTy()) return getPointerTy(Ty->getPointerAddressSpace()); if (Ty->isVectorTy()) { VectorType *VTy = cast(Ty); -- cgit v1.1 From 19a54725044b8c7338aa86d0edf75dec1bae93a8 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Mon, 26 Aug 2013 18:11:25 +0000 Subject: [cmake] Check for realpath availability in CMake git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189249 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Config/config.h.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake index 572fb6f..825349c 100644 --- a/include/llvm/Config/config.h.cmake +++ b/include/llvm/Config/config.h.cmake @@ -302,7 +302,7 @@ #cmakedefine HAVE_READDIR ${HAVE_READDIR} /* Define to 1 if you have the `realpath' function. */ -#undef HAVE_REALPATH +#cmakedefine HAVE_REALPATH ${HAVE_REALPATH} /* Define to 1 if you have the `rintf' function. */ #undef HAVE_RINTF -- cgit v1.1 From 6e3cd0ebe22a7cc959ed301de7f2f09d7a9307c8 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Mon, 26 Aug 2013 22:39:55 +0000 Subject: Debug Info: add an identifier field to DICompositeType. DICompositeType will have an identifier field at position 14. For now, the field is set to null in DIBuilder. For DICompositeTypes where the template argument field (the 13th field) was optional, modify DIBuilder to make sure the template argument field is set. Now DICompositeType has 15 fields. Update DIBuilder to use NULL instead of "i32 0" for null value of a MDNode. Update verifier to check that DICompositeType has 15 fields and the last field is null or a MDString. Update testing cases to include an extra field for DICompositeType. The identifier field will be used by type uniquing so a front end can genearte a DICompositeType with a unique identifer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189282 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 2efc730..87ccac1 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -34,6 +34,7 @@ namespace llvm { class DbgValueInst; class Instruction; class MDNode; + class MDString; class NamedMDNode; class LLVMContext; class raw_ostream; @@ -330,6 +331,7 @@ namespace llvm { } void setContainingType(DICompositeType ContainingType); DIArray getTemplateParams() const { return getFieldAs(13); } + MDString *getIdentifier() const; /// Verify - Verify that a composite type descriptor is well formed. bool Verify() const; -- cgit v1.1 From e3427a5815ca3993584af6db28524f0c424b749e Mon Sep 17 00:00:00 2001 From: Shuxin Yang Date: Tue, 27 Aug 2013 00:03:23 +0000 Subject: Add new API lto_codegen_compile_parallel(). This API is proposed by Nick Kledzik. The semantic is: -------------------------------------------------------------------------- Generate code for merged module into an array of native object files. On success returns a pointer to an array of NativeObjectFile. The count parameter returns the number of elements in the array. Each element is a pointer/length for a generated mach-o/ELF buffer. The buffer is owned by the lto_code_gen_t and will be freed when lto_codegen_dispose() is called, or lto_codegen_compile() is called again. On failure, returns NULL (check lto_get_error_message() for details). extern const struct NativeObjectFile* lto_codegen_compile_parallel(lto_code_gen_t cg, size_t *count); --------------------------------------------------------------------------- This API is currently only called on OSX platform. Linux or other Unixes using GNU gold are not supposed to call this function, because on these systems, object files are fed back to linker via disk file instead of memory buffer. In this commit, lto_codegen_compile_parallel() simply calls lto_codegen_compile() to return a single object file. In the near future, this function is the entry point for compilation with partition. Linker can blindly call this function even if partition is turned off; in this case, compiler will return only one object file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189297 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/lto.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm-c/lto.h b/include/llvm-c/lto.h index 40110fd..907007c 100644 --- a/include/llvm-c/lto.h +++ b/include/llvm-c/lto.h @@ -27,7 +27,7 @@ * @{ */ -#define LTO_API_VERSION 4 +#define LTO_API_VERSION 5 typedef enum { LTO_SYMBOL_ALIGNMENT_MASK = 0x0000001F, /* log2 of alignment */ @@ -284,6 +284,22 @@ lto_codegen_compile(lto_code_gen_t cg, size_t* length); extern bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char** name); +struct NativeObjectFile { + const void *content; + size_t length; +}; + +/** + * Generates code for merged module into an array of native object files. + * On success returns a pointer to an array of NativeObjectFile. The + * count parameter returns the number of elements in the array. Each + * element is a pointer/length for a generated mach-o/ELF buffer. The + * buffer is owned by the lto_code_gen_t and will be freed when + * lto_codegen_dispose() is called, or lto_codegen_compile() is called again. + * On failure, returns NULL (check lto_get_error_message() for details). + */ +extern const struct NativeObjectFile* +lto_codegen_compile_parallel(lto_code_gen_t cg, size_t *count); /** * Sets options to help debug codegen bugs. -- cgit v1.1 From bf778d0546a4d8814339d946ca5c7e52291cc00c Mon Sep 17 00:00:00 2001 From: Charles Davis Date: Tue, 27 Aug 2013 05:00:13 +0000 Subject: Support/MachO: Add a bunch of defines. Right now we have two headers for the Mach-O format. I'd like to get rid of one. Since the other object formats are all in Support, I chose to keep the Mach-O header in Support, and discard the other one. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189314 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/MachO.h | 789 +++++++++++++++++++++++++++++-------------- 1 file changed, 533 insertions(+), 256 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/MachO.h b/include/llvm/Support/MachO.h index 5d2a8a8..cc9651b 100644 --- a/include/llvm/Support/MachO.h +++ b/include/llvm/Support/MachO.h @@ -15,270 +15,406 @@ #define LLVM_SUPPORT_MACHO_H #include "llvm/Support/DataTypes.h" +#include "llvm/Support/Host.h" -// NOTE: The enums in this file are intentially named to be different than those -// in the headers in /usr/include/mach (on darwin systems) to avoid conflicts -// with those macros. namespace llvm { namespace MachO { // Enums from enum { // Constants for the "magic" field in llvm::MachO::mach_header and // llvm::MachO::mach_header_64 - HeaderMagic32 = 0xFEEDFACEu, // MH_MAGIC - HeaderMagic32Swapped = 0xCEFAEDFEu, // MH_CIGAM - HeaderMagic64 = 0xFEEDFACFu, // MH_MAGIC_64 - HeaderMagic64Swapped = 0xCFFAEDFEu, // MH_CIGAM_64 - UniversalMagic = 0xCAFEBABEu, // FAT_MAGIC - UniversalMagicSwapped = 0xBEBAFECAu, // FAT_CIGAM + MH_MAGIC = 0xFEEDFACEu, + MH_CIGAM = 0xCEFAEDFEu, + MH_MAGIC_64 = 0xFEEDFACFu, + MH_CIGAM_64 = 0xCFFAEDFEu, + FAT_MAGIC = 0xCAFEBABEu, + FAT_CIGAM = 0xBEBAFECAu + }; + enum HeaderFileType { // Constants for the "filetype" field in llvm::MachO::mach_header and // llvm::MachO::mach_header_64 - HeaderFileTypeObject = 0x1u, // MH_OBJECT - HeaderFileTypeExecutable = 0x2u, // MH_EXECUTE - HeaderFileTypeFixedVMShlib = 0x3u, // MH_FVMLIB - HeaderFileTypeCore = 0x4u, // MH_CORE - HeaderFileTypePreloadedExecutable = 0x5u, // MH_PRELOAD - HeaderFileTypeDynamicShlib = 0x6u, // MH_DYLIB - HeaderFileTypeDynamicLinkEditor = 0x7u, // MH_DYLINKER - HeaderFileTypeBundle = 0x8u, // MH_BUNDLE - HeaderFileTypeDynamicShlibStub = 0x9u, // MH_DYLIB_STUB - HeaderFileTypeDSYM = 0xAu, // MH_DSYM - HeaderFileTypeKextBundle = 0xBu, // MH_KEXT_BUNDLE + MH_OBJECT = 0x1u, + MH_EXECUTE = 0x2u, + MH_FVMLIB = 0x3u, + MH_CORE = 0x4u, + MH_PRELOAD = 0x5u, + MH_DYLIB = 0x6u, + MH_DYLINKER = 0x7u, + MH_BUNDLE = 0x8u, + MH_DYLIB_STUB = 0x9u, + MH_DSYM = 0xAu, + MH_KEXT_BUNDLE = 0xBu + }; + enum { // Constant bits for the "flags" field in llvm::MachO::mach_header and // llvm::MachO::mach_header_64 - HeaderFlagBitNoUndefinedSymbols = 0x00000001u, // MH_NOUNDEFS - HeaderFlagBitIsIncrementalLinkObject= 0x00000002u, // MH_INCRLINK - HeaderFlagBitIsDynamicLinkObject = 0x00000004u, // MH_DYLDLINK - HeaderFlagBitBindAtLoad = 0x00000008u, // MH_BINDATLOAD - HeaderFlagBitPrebound = 0x00000010u, // MH_PREBOUND - HeaderFlagBitSplitSegments = 0x00000020u, // MH_SPLIT_SEGS - HeaderFlagBitLazyInit = 0x00000040u, // MH_LAZY_INIT - HeaderFlagBitTwoLevelNamespace = 0x00000080u, // MH_TWOLEVEL - HeaderFlagBitForceFlatNamespace = 0x00000100u, // MH_FORCE_FLAT - HeaderFlagBitNoMultipleDefintions = 0x00000200u, // MH_NOMULTIDEFS - HeaderFlagBitNoFixPrebinding = 0x00000400u, // MH_NOFIXPREBINDING - HeaderFlagBitPrebindable = 0x00000800u, // MH_PREBINDABLE - HeaderFlagBitAllModulesBound = 0x00001000u, // MH_ALLMODSBOUND - HeaderFlagBitSubsectionsViaSymbols = 0x00002000u, // MH_SUBSECTIONS_VIA_SYMBOLS - HeaderFlagBitCanonical = 0x00004000u, // MH_CANONICAL - HeaderFlagBitWeakDefines = 0x00008000u, // MH_WEAK_DEFINES - HeaderFlagBitBindsToWeak = 0x00010000u, // MH_BINDS_TO_WEAK - HeaderFlagBitAllowStackExecution = 0x00020000u, // MH_ALLOW_STACK_EXECUTION - HeaderFlagBitRootSafe = 0x00040000u, // MH_ROOT_SAFE - HeaderFlagBitSetUIDSafe = 0x00080000u, // MH_SETUID_SAFE - HeaderFlagBitNoReexportedDylibs = 0x00100000u, // MH_NO_REEXPORTED_DYLIBS - HeaderFlagBitPIE = 0x00200000u, // MH_PIE - HeaderFlagBitDeadStrippableDylib = 0x00400000u, // MH_DEAD_STRIPPABLE_DYLIB + MH_NOUNDEFS = 0x00000001u, + MH_INCRLINK = 0x00000002u, + MH_DYLDLINK = 0x00000004u, + MH_BINDATLOAD = 0x00000008u, + MH_PREBOUND = 0x00000010u, + MH_SPLIT_SEGS = 0x00000020u, + MH_LAZY_INIT = 0x00000040u, + MH_TWOLEVEL = 0x00000080u, + MH_FORCE_FLAT = 0x00000100u, + MH_NOMULTIDEFS = 0x00000200u, + MH_NOFIXPREBINDING = 0x00000400u, + MH_PREBINDABLE = 0x00000800u, + MH_ALLMODSBOUND = 0x00001000u, + MH_SUBSECTIONS_VIA_SYMBOLS = 0x00002000u, + MH_CANONICAL = 0x00004000u, + MH_WEAK_DEFINES = 0x00008000u, + MH_BINDS_TO_WEAK = 0x00010000u, + MH_ALLOW_STACK_EXECUTION = 0x00020000u, + MH_ROOT_SAFE = 0x00040000u, + MH_SETUID_SAFE = 0x00080000u, + MH_NO_REEXPORTED_DYLIBS = 0x00100000u, + MH_PIE = 0x00200000u, + MH_DEAD_STRIPPABLE_DYLIB = 0x00400000u + }; + enum { + // Flags for the "cmd" field in llvm::MachO::load_command + LC_REQ_DYLD = 0x80000000u + }; + + enum LoadCommandType { // Constants for the "cmd" field in llvm::MachO::load_command - LoadCommandDynamicLinkerRequired = 0x80000000u, // LC_REQ_DYLD - LoadCommandSegment32 = 0x00000001u, // LC_SEGMENT - LoadCommandSymtab = 0x00000002u, // LC_SYMTAB - LoadCommandSymSeg = 0x00000003u, // LC_SYMSEG - LoadCommandThread = 0x00000004u, // LC_THREAD - LoadCommandUnixThread = 0x00000005u, // LC_UNIXTHREAD - LoadCommandFixedVMShlibLoad = 0x00000006u, // LC_LOADFVMLIB - LoadCommandFixedVMShlibIdent = 0x00000007u, // LC_IDFVMLIB - LoadCommandIdent = 0x00000008u, // LC_IDENT - LoadCommandFixedVMFileInclusion = 0x00000009u, // LC_FVMFILE - LoadCommandPrePage = 0x0000000Au, // LC_PREPAGE - LoadCommandDynamicSymtabInfo = 0x0000000Bu, // LC_DYSYMTAB - LoadCommandDylibLoad = 0x0000000Cu, // LC_LOAD_DYLIB - LoadCommandDylibIdent = 0x0000000Du, // LC_ID_DYLIB - LoadCommandDynamicLinkerLoad = 0x0000000Eu, // LC_LOAD_DYLINKER - LoadCommandDynamicLinkerIdent = 0x0000000Fu, // LC_ID_DYLINKER - LoadCommandDylibPrebound = 0x00000010u, // LC_PREBOUND_DYLIB - LoadCommandRoutines32 = 0x00000011u, // LC_ROUTINES - LoadCommandSubFramework = 0x00000012u, // LC_SUB_FRAMEWORK - LoadCommandSubUmbrella = 0x00000013u, // LC_SUB_UMBRELLA - LoadCommandSubClient = 0x00000014u, // LC_SUB_CLIENT - LoadCommandSubLibrary = 0x00000015u, // LC_SUB_LIBRARY - LoadCommandTwoLevelHints = 0x00000016u, // LC_TWOLEVEL_HINTS - LoadCommandPreBindChecksum = 0x00000017u, // LC_PREBIND_CKSUM - LoadCommandDylibLoadWeak = 0x80000018u, // LC_LOAD_WEAK_DYLIB - LoadCommandSegment64 = 0x00000019u, // LC_SEGMENT_64 - LoadCommandRoutines64 = 0x0000001Au, // LC_ROUTINES_64 - LoadCommandUUID = 0x0000001Bu, // LC_UUID - LoadCommandRunpath = 0x8000001Cu, // LC_RPATH - LoadCommandCodeSignature = 0x0000001Du, // LC_CODE_SIGNATURE - LoadCommandSegmentSplitInfo = 0x0000001Eu, // LC_SEGMENT_SPLIT_INFO - LoadCommandDylibReexport = 0x8000001Fu, // LC_REEXPORT_DYLIB - LoadCommandDylibLazyLoad = 0x00000020u, // LC_LAZY_LOAD_DYLIB - LoadCommandEncryptionInfo = 0x00000021u, // LC_ENCRYPTION_INFO - LoadCommandDynamicLinkerInfo = 0x00000022u, // LC_DYLD_INFO - LoadCommandDynamicLinkerInfoOnly = 0x80000022u, // LC_DYLD_INFO_ONLY - LoadCommandDylibLoadUpward = 0x80000023u, // LC_LOAD_UPWARD_DYLIB - LoadCommandVersionMinMacOSX = 0x00000024u, // LC_VERSION_MIN_MACOSX - LoadCommandVersionMinIPhoneOS = 0x00000025u, // LC_VERSION_MIN_IPHONEOS - LoadCommandFunctionStarts = 0x00000026u, // LC_FUNCTION_STARTS - LoadCommandDyldEnvironment = 0x00000027u, // LC_DYLD_ENVIRONMENT - LoadCommandMain = 0x80000028u, // LC_MAIN - LoadCommandDataInCode = 0x00000029u, // LC_DATA_IN_CODE - LoadCommandSourceVersion = 0x0000002Au, // LC_SOURCE_VERSION - LoadCommandCodeSignDRs = 0x0000002Bu, // LC_DYLIB_CODE_SIGN_DRS + LC_SEGMENT = 0x00000001u, + LC_SYMTAB = 0x00000002u, + LC_SYMSEG = 0x00000003u, + LC_THREAD = 0x00000004u, + LC_UNIXTHREAD = 0x00000005u, + LC_LOADFVMLIB = 0x00000006u, + LC_IDFVMLIB = 0x00000007u, + LC_IDENT = 0x00000008u, + LC_FVMFILE = 0x00000009u, + LC_PREPAGE = 0x0000000Au, + LC_DYSYMTAB = 0x0000000Bu, + LC_LOAD_DYLIB = 0x0000000Cu, + LC_ID_DYLIB = 0x0000000Du, + LC_LOAD_DYLINKER = 0x0000000Eu, + LC_ID_DYLINKER = 0x0000000Fu, + LC_PREBOUND_DYLIB = 0x00000010u, + LC_ROUTINES = 0x00000011u, + LC_SUB_FRAMEWORK = 0x00000012u, + LC_SUB_UMBRELLA = 0x00000013u, + LC_SUB_CLIENT = 0x00000014u, + LC_SUB_LIBRARY = 0x00000015u, + LC_TWOLEVEL_HINTS = 0x00000016u, + LC_PREBIND_CKSUM = 0x00000017u, + LC_LOAD_WEAK_DYLIB = 0x80000018u, + LC_SEGMENT_64 = 0x00000019u, + LC_ROUTINES_64 = 0x0000001Au, + LC_UUID = 0x0000001Bu, + LC_RPATH = 0x8000001Cu, + LC_CODE_SIGNATURE = 0x0000001Du, + LC_SEGMENT_SPLIT_INFO = 0x0000001Eu, + LC_REEXPORT_DYLIB = 0x8000001Fu, + LC_LAZY_LOAD_DYLIB = 0x00000020u, + LC_ENCRYPTION_INFO = 0x00000021u, + LC_DYLD_INFO = 0x00000022u, + LC_DYLD_INFO_ONLY = 0x80000022u, + LC_LOAD_UPWARD_DYLIB = 0x80000023u, + LC_VERSION_MIN_MACOSX = 0x00000024u, + LC_VERSION_MIN_IPHONEOS = 0x00000025u, + LC_FUNCTION_STARTS = 0x00000026u, + LC_DYLD_ENVIRONMENT = 0x00000027u, + LC_MAIN = 0x80000028u, + LC_DATA_IN_CODE = 0x00000029u, + LC_SOURCE_VERSION = 0x0000002Au, + LC_DYLIB_CODE_SIGN_DRS = 0x0000002Bu, + // 0x0000002Cu, + LC_LINKER_OPTIONS = 0x0000002Du + }; + enum { // Constant bits for the "flags" field in llvm::MachO::segment_command - SegmentCommandFlagBitHighVM = 0x1u, // SG_HIGHVM - SegmentCommandFlagBitFixedVMLibrary = 0x2u, // SG_FVMLIB - SegmentCommandFlagBitNoRelocations = 0x4u, // SG_NORELOC - SegmentCommandFlagBitProtectedVersion1 = 0x8u, // SG_PROTECTED_VERSION_1 + SG_HIGHVM = 0x1u, + SG_FVMLIB = 0x2u, + SG_NORELOC = 0x4u, + SG_PROTECTED_VERSION_1 = 0x8u, // Constant masks for the "flags" field in llvm::MachO::section and // llvm::MachO::section_64 - SectionFlagMaskSectionType = 0x000000ffu, // SECTION_TYPE - SectionFlagMaskAllAttributes = 0xffffff00u, // SECTION_ATTRIBUTES - SectionFlagMaskUserAttributes = 0xff000000u, // SECTION_ATTRIBUTES_USR - SectionFlagMaskSystemAttributes = 0x00ffff00u, // SECTION_ATTRIBUTES_SYS + SECTION_TYPE = 0x000000ffu, // SECTION_TYPE + SECTION_ATTRIBUTES = 0xffffff00u, // SECTION_ATTRIBUTES + SECTION_ATTRIBUTES_USR = 0xff000000u, // SECTION_ATTRIBUTES_USR + SECTION_ATTRIBUTES_SYS = 0x00ffff00u // SECTION_ATTRIBUTES_SYS + }; + enum SectionType { // Constant masks for the "flags[7:0]" field in llvm::MachO::section and // llvm::MachO::section_64 (mask "flags" with SECTION_TYPE) - SectionTypeRegular = 0x00u, // S_REGULAR - SectionTypeZeroFill = 0x01u, // S_ZEROFILL - SectionTypeCStringLiterals = 0x02u, // S_CSTRING_LITERALS - SectionType4ByteLiterals = 0x03u, // S_4BYTE_LITERALS - SectionType8ByteLiterals = 0x04u, // S_8BYTE_LITERALS - SectionTypeLiteralPointers = 0x05u, // S_LITERAL_POINTERS - SectionTypeNonLazySymbolPointers = 0x06u, // S_NON_LAZY_SYMBOL_POINTERS - SectionTypeLazySymbolPointers = 0x07u, // S_LAZY_SYMBOL_POINTERS - SectionTypeSymbolStubs = 0x08u, // S_SYMBOL_STUBS - SectionTypeModuleInitFunctionPointers = 0x09u, // S_MOD_INIT_FUNC_POINTERS - SectionTypeModuleTermFunctionPointers = 0x0au, // S_MOD_TERM_FUNC_POINTERS - SectionTypeCoalesced = 0x0bu, // S_COALESCED - SectionTypeZeroFillLarge = 0x0cu, // S_GB_ZEROFILL - SectionTypeInterposing = 0x0du, // S_INTERPOSING - SectionType16ByteLiterals = 0x0eu, // S_16BYTE_LITERALS - SectionTypeDTraceObjectFormat = 0x0fu, // S_DTRACE_DOF - SectionTypeLazyDylibSymbolPointers = 0x10u, // S_LAZY_DYLIB_SYMBOL_POINTERS + S_REGULAR = 0x00u, + S_ZEROFILL = 0x01u, + S_CSTRING_LITERALS = 0x02u, + S_4BYTE_LITERALS = 0x03u, + S_8BYTE_LITERALS = 0x04u, + S_LITERAL_POINTERS = 0x05u, + S_NON_LAZY_SYMBOL_POINTERS = 0x06u, + S_LAZY_SYMBOL_POINTERS = 0x07u, + S_SYMBOL_STUBS = 0x08u, + S_MOD_INIT_FUNC_POINTERS = 0x09u, + S_MOD_TERM_FUNC_POINTERS = 0x0au, + S_COALESCED = 0x0bu, + S_GB_ZEROFILL = 0x0cu, + S_INTERPOSING = 0x0du, + S_16BYTE_LITERALS = 0x0eu, + S_DTRACE_DOF = 0x0fu, + S_LAZY_DYLIB_SYMBOL_POINTERS = 0x10u, + S_THREAD_LOCAL_REGULAR = 0x11u, + S_THREAD_LOCAL_ZEROFILL = 0x12u, + S_THREAD_LOCAL_VARIABLES = 0x13u, + S_THREAD_LOCA_VARIABLE_POINTERS = 0x14u, + S_THREAD_LOCAL_INIT_FUNCTION_POINTERS = 0x15u + }; + enum { // Constant masks for the "flags[31:24]" field in llvm::MachO::section and // llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_USR) - SectionAttrUserPureInstructions = 0x80000000u, // S_ATTR_PURE_INSTRUCTIONS - SectionAttrUserNoTableOfContents = 0x40000000u, // S_ATTR_NO_TOC - SectionAttrUserCanStripStaticSymbols = 0x20000000u, // S_ATTR_STRIP_STATIC_SYMS - SectionAttrUserNoDeadStrip = 0x10000000u, // S_ATTR_NO_DEAD_STRIP - SectionAttrUserLiveSupport = 0x08000000u, // S_ATTR_LIVE_SUPPORT - SectionAttrUserSelfModifyingCode = 0x04000000u, // S_ATTR_SELF_MODIFYING_CODE - SectionAttrUserDebug = 0x02000000u, // S_ATTR_DEBUG + S_ATTR_PURE_INSTRUCTIONS = 0x80000000u, + S_ATTR_NO_TOC = 0x40000000u, + S_ATTR_STRIP_STATIC_SYMS = 0x20000000u, + S_ATTR_NO_DEAD_STRIP = 0x10000000u, + S_ATTR_LIVE_SUPPORT = 0x08000000u, + S_ATTR_SELF_MODIFYING_CODE = 0x04000000u, + S_ATTR_DEBUG = 0x02000000u, // Constant masks for the "flags[23:8]" field in llvm::MachO::section and // llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_SYS) - SectionAttrSytemSomeInstructions = 0x00000400u, // S_ATTR_SOME_INSTRUCTIONS - SectionAttrSytemHasExternalRelocations= 0x00000200u, // S_ATTR_EXT_RELOC - SectionAttrSytemHasLocalRelocations = 0x00000100u, // S_ATTR_LOC_RELOC - - IndirectSymbolLocal = 0x80000000u, // INDIRECT_SYMBOL_LOCAL - IndirectSymbolAbsolute = 0x40000000u, // INDIRECT_SYMBOL_ABS - - RebaseTypePointer = 1u, // REBASE_TYPE_POINTER - RebaseTypeTextAbsolute32 = 2u, // REBASE_TYPE_TEXT_ABSOLUTE32 - RebaseTypeTextPCRelative32 = 3u, // REBASE_TYPE_TEXT_PCREL32 - - RebaseOpcodeMask = 0xF0u, // REBASE_OPCODE_MASK - RebaseImmediateMask = 0x0Fu, // REBASE_IMMEDIATE_MASK - RebaseOpcodeDone = 0x00u, // REBASE_OPCODE_DONE - RebaseOpcodeSetTypeImmediate = 0x10u, // REBASE_OPCODE_SET_TYPE_IMM - RebaseOpcodeSetSegmentAndOffsetULEB = 0x20u, // REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB - RebaseOpcodeAddAddressULEB = 0x30u, // REBASE_OPCODE_ADD_ADDR_ULEB - RebaseOpcodeAddAddressImmediateScaled = 0x40u, // REBASE_OPCODE_ADD_ADDR_IMM_SCALED - RebaseOpcodeDoRebaseImmediateTimes = 0x50u, // REBASE_OPCODE_DO_REBASE_IMM_TIMES - RebaseOpcodeDoRebaseULEBTimes = 0x60u, // REBASE_OPCODE_DO_REBASE_ULEB_TIMES - RebaseOpcodeDoRebaseAddAddressULEB = 0x70u, // REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB - RebaseOpcodeDoRebaseULEBTimesSkippingULEB = 0x80u, // REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB - - - BindTypePointer = 1u, // BIND_TYPE_POINTER - BindTypeTextAbsolute32 = 2u, // BIND_TYPE_TEXT_ABSOLUTE32 - BindTypeTextPCRelative32 = 3u, // BIND_TYPE_TEXT_PCREL32 - - BindSpecialDylibSelf = 0u, // BIND_SPECIAL_DYLIB_SELF - BindSpecialDylibMainExecutable = -1u, // BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE - BindSpecialDylibFlatLookup = -2u, // BIND_SPECIAL_DYLIB_FLAT_LOOKUP - - BindSymbolFlagsWeakImport = 0x1u, // BIND_SYMBOL_FLAGS_WEAK_IMPORT - BindSymbolFlagsNonWeakDefinition = 0x8u, // BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION - - BindOpcodeMask = 0xF0u, // BIND_OPCODE_MASK - BindImmediateMask = 0x0Fu, // BIND_IMMEDIATE_MASK - BindOpcodeDone = 0x00u, // BIND_OPCODE_DONE - BindOpcodeSetDylibOrdinalImmediate = 0x10u, // BIND_OPCODE_SET_DYLIB_ORDINAL_IMM - BindOpcodeSetDylibOrdinalULEB = 0x20u, // BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB - BindOpcodeSetDylibSpecialImmediate = 0x30u, // BIND_OPCODE_SET_DYLIB_SPECIAL_IMM - BindOpcodeSetSymbolTrailingFlagsImmediate = 0x40u, // BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM - BindOpcodeSetTypeImmediate = 0x50u, // BIND_OPCODE_SET_TYPE_IMM - BindOpcodeSetAppendSLEB = 0x60u, // BIND_OPCODE_SET_ADDEND_SLEB - BindOpcodeSetSegmentAndOffsetULEB = 0x70u, // BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB - BindOpcodeAddAddressULEB = 0x80u, // BIND_OPCODE_ADD_ADDR_ULEB - BindOpcodeDoBind = 0x90u, // BIND_OPCODE_DO_BIND - BindOpcodeDoBindAddAddressULEB = 0xA0u, // BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB - BindOpcodeDoBindAddAddressImmediateScaled = 0xB0u, // BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED - BindOpcodeDoBindULEBTimesSkippingULEB = 0xC0u, // BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB - - ExportSymbolFlagsKindMask = 0x03u, // EXPORT_SYMBOL_FLAGS_KIND_MASK - ExportSymbolFlagsKindRegular = 0x00u, // EXPORT_SYMBOL_FLAGS_KIND_REGULAR - ExportSymbolFlagsKindThreadLocal = 0x01u, // EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL - ExportSymbolFlagsWeakDefinition = 0x04u, // EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION - ExportSymbolFlagsIndirectDefinition = 0x08u, // EXPORT_SYMBOL_FLAGS_INDIRECT_DEFINITION - ExportSymbolFlagsHasSpecializations = 0x10u, // EXPORT_SYMBOL_FLAGS_HAS_SPECIALIZATIONS + S_ATTR_SOME_INSTRUCTIONS = 0x00000400u, + S_ATTR_EXT_RELOC = 0x00000200u, + S_ATTR_LOC_RELOC = 0x00000100u, + + // Constant masks for the value of an indirect symbol in an indirect + // symbol table + INDIRECT_SYMBOL_LOCAL = 0x80000000u, + INDIRECT_SYMBOL_ABS = 0x40000000u + }; + + enum DataRegionType { + // Constants for the "kind" field in a data_in_code_entry structure + DICE_KIND_DATA = 1u, + DICE_KIND_JUMP_TABLE8 = 2u, + DICE_KIND_JUMP_TABLE16 = 3u, + DICE_KIND_JUMP_TABLE32 = 4u, + DICE_KIND_ABS_JUMP_TABLE32 = 5u + }; + + enum RebaseType { + REBASE_TYPE_POINTER = 1u, + REBASE_TYPE_TEXT_ABSOLUTE32 = 2u, + REBASE_TYPE_TEXT_PCREL32 = 3u + }; + + enum { + REBASE_OPCODE_MASK = 0xF0u, + REBASE_IMMEDIATE_MASK = 0x0Fu + }; + enum RebaseOpcode { + REBASE_OPCODE_DONE = 0x00u, + REBASE_OPCODE_SET_TYPE_IMM = 0x10u, + REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB = 0x20u, + REBASE_OPCODE_ADD_ADDR_ULEB = 0x30u, + REBASE_OPCODE_ADD_ADDR_IMM_SCALED = 0x40u, + REBASE_OPCODE_DO_REBASE_IMM_TIMES = 0x50u, + REBASE_OPCODE_DO_REBASE_ULEB_TIMES = 0x60u, + REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB = 0x70u, + REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB = 0x80u + }; + + enum BindType { + BIND_TYPE_POINTER = 1u, + BIND_TYPE_TEXT_ABSOLUTE32 = 2u, + BIND_TYPE_TEXT_PCREL32 = 3u + }; + + enum BindSpecialDylib { + BIND_SPECIAL_DYLIB_SELF = 0u, + BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE = -1u, + BIND_SPECIAL_DYLIB_FLAT_LOOKUP = -2u + }; + + enum { + BIND_SYMBOL_FLAGS_WEAK_IMPORT = 0x1u, + BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION = 0x8u, + + BIND_OPCODE_MASK = 0xF0u, + BIND_IMMEDIATE_MASK = 0x0Fu + }; + + enum BindOpcode { + BIND_OPCODE_DONE = 0x00u, + BIND_OPCODE_SET_DYLIB_ORDINAL_IMM = 0x10u, + BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB = 0x20u, + BIND_OPCODE_SET_DYLIB_SPECIAL_IMM = 0x30u, + BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM = 0x40u, + BIND_OPCODE_SET_TYPE_IMM = 0x50u, + BIND_OPCODE_SET_ADDEND_SLEB = 0x60u, + BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB = 0x70u, + BIND_OPCODE_ADD_ADDR_ULEB = 0x80u, + BIND_OPCODE_DO_BIND = 0x90u, + BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB = 0xA0u, + BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED = 0xB0u, + BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB = 0xC0u + }; + enum { + EXPORT_SYMBOL_FLAGS_KIND_MASK = 0x03u, + EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION = 0x04u, + EXPORT_SYMBOL_FLAGS_INDIRECT_DEFINITION = 0x08u, + EXPORT_SYMBOL_FLAGS_HAS_SPECIALIZATIONS = 0x10u + }; + + enum ExportSymbolKind { + EXPORT_SYMBOL_FLAGS_KIND_REGULAR = 0x00u, + EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL = 0x01u + }; + + + enum { // Constant masks for the "n_type" field in llvm::MachO::nlist and // llvm::MachO::nlist_64 - NlistMaskStab = 0xe0, // N_STAB - NlistMaskPrivateExternal = 0x10, // N_PEXT - NlistMaskType = 0x0e, // N_TYPE - NlistMaskExternal = 0x01, // N_EXT + N_STAB = 0xe0, + N_PEXT = 0x10, + N_TYPE = 0x0e, + N_EXT = 0x01 + }; + enum NListType { // Constants for the "n_type & N_TYPE" llvm::MachO::nlist and // llvm::MachO::nlist_64 - NListTypeUndefined = 0x0u, // N_UNDF - NListTypeAbsolute = 0x2u, // N_ABS - NListTypeSection = 0xeu, // N_SECT - NListTypePreboundUndefined = 0xcu, // N_PBUD - NListTypeIndirect = 0xau, // N_INDR + N_UNDF = 0x0u, + N_ABS = 0x2u, + N_SECT = 0xeu, + N_PBUD = 0xcu, + N_INDR = 0xau + }; - // Constant masks for the "n_sect" field in llvm::MachO::nlist and + enum SectionOrdinal { + // Constants for the "n_sect" field in llvm::MachO::nlist and // llvm::MachO::nlist_64 - NListSectionNoSection = 0u, // NO_SECT - NListSectionMaxSection = 0xffu, // MAX_SECT + NO_SECT = 0u, + MAX_SECT = 0xffu + }; - NListDescWeakRef = 0x40u, - NListDescWeakDef = 0x80u, + enum { + // Constant masks for the "n_desc" field in llvm::MachO::nlist and + // llvm::MachO::nlist_64 + N_ARM_THUMB_DEF = 0x0008u, + N_NO_DEAD_STRIP = 0x0020u, + N_WEAK_REF = 0x0040u, + N_WEAK_DEF = 0x0080u, + N_SYMBOL_RESOLVER = 0x0100u + }; + enum StabType { // Constant values for the "n_type" field in llvm::MachO::nlist and // llvm::MachO::nlist_64 when "(n_type & NlistMaskStab) != 0" - StabGlobalSymbol = 0x20u, // N_GSYM - StabFunctionName = 0x22u, // N_FNAME - StabFunction = 0x24u, // N_FUN - StabStaticSymbol = 0x26u, // N_STSYM - StabLocalCommon = 0x28u, // N_LCSYM - StabBeginSymbol = 0x2Eu, // N_BNSYM - StabSourceFileOptions = 0x3Cu, // N_OPT - StabRegisterSymbol = 0x40u, // N_RSYM - StabSourceLine = 0x44u, // N_SLINE - StabEndSymbol = 0x4Eu, // N_ENSYM - StabStructureType = 0x60u, // N_SSYM - StabSourceFileName = 0x64u, // N_SO - StabObjectFileName = 0x66u, // N_OSO - StabLocalSymbol = 0x80u, // N_LSYM - StabBeginIncludeFileName = 0x82u, // N_BINCL - StabIncludeFileName = 0x84u, // N_SOL - StabCompilerParameters = 0x86u, // N_PARAMS - StabCompilerVersion = 0x88u, // N_VERSION - StabCompilerOptLevel = 0x8Au, // N_OLEVEL - StabParameter = 0xA0u, // N_PSYM - StabEndIncludeFile = 0xA2u, // N_EINCL - StabAlternateEntry = 0xA4u, // N_ENTRY - StabLeftBracket = 0xC0u, // N_LBRAC - StabDeletedIncludeFile = 0xC2u, // N_EXCL - StabRightBracket = 0xE0u, // N_RBRAC - StabBeginCommon = 0xE2u, // N_BCOMM - StabEndCommon = 0xE4u, // N_ECOMM - StabEndCommonLocal = 0xE8u, // N_ECOML - StabLength = 0xFEu // N_LENG + N_GSYM = 0x20u, + N_FNAME = 0x22u, + N_FUN = 0x24u, + N_STSYM = 0x26u, + N_LCSYM = 0x28u, + N_BNSYM = 0x2Eu, + N_OPT = 0x3Cu, + N_RSYM = 0x40u, + N_SLINE = 0x44u, + N_ENSYM = 0x4Eu, + N_SSYM = 0x60u, + N_SO = 0x64u, + N_OSO = 0x66u, + N_LSYM = 0x80u, + N_BINCL = 0x82u, + N_SOL = 0x84u, + N_PARAMS = 0x86u, + N_VERSION = 0x88u, + N_OLEVEL = 0x8Au, + N_PSYM = 0xA0u, + N_EINCL = 0xA2u, + N_ENTRY = 0xA4u, + N_LBRAC = 0xC0u, + N_EXCL = 0xC2u, + N_RBRAC = 0xE0u, + N_BCOMM = 0xE2u, + N_ECOMM = 0xE4u, + N_ECOML = 0xE8u, + N_LENG = 0xFEu + }; + enum { + // Constant values for the r_symbolnum field in an + // llvm::MachO::relocation_info structure when r_extern is 0. + R_ABS = 0, + + // Constant bits for the r_address field in an + // llvm::MachO::relocation_info structure. + R_SCATTERED = 0x80000000 + }; + + enum RelocationInfoType { + // Constant values for the r_type field in an + // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info + // structure. + GENERIC_RELOC_VANILLA = 0, + GENERIC_RELOC_PAIR = 1, + GENERIC_RELOC_SECTDIFF = 2, + GENERIC_RELOC_PB_LA_PTR = 3, + GENERIC_RELOC_LOCAL_SECTDIFF = 4, + GENERIC_RELOC_TLV = 5, + + // Constant values for the r_type field in a PowerPC architecture + // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info + // structure. + PPC_RELOC_VANILLA = GENERIC_RELOC_VANILLA, + PPC_RELOC_PAIR = GENERIC_RELOC_PAIR, + PPC_RELOC_BR14 = 2, + PPC_RELOC_BR24 = 3, + PPC_RELOC_HI16 = 4, + PPC_RELOC_LO16 = 5, + PPC_RELOC_HA16 = 6, + PPC_RELOC_LO14 = 7, + PPC_RELOC_SECTDIFF = 8, + PPC_RELOC_PB_LA_PTR = 9, + PPC_RELOC_HI16_SECTDIFF = 10, + PPC_RELOC_LO16_SECTDIFF = 11, + PPC_RELOC_HA16_SECTDIFF = 12, + PPC_RELOC_JBSR = 13, + PPC_RELOC_LO14_SECTDIFF = 14, + PPC_RELOC_LOCAL_SECTDIFF = 15, + + // Constant values for the r_type field in an ARM architecture + // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info + // structure. + ARM_RELOC_VANILLA = GENERIC_RELOC_VANILLA, + ARM_RELOC_PAIR = GENERIC_RELOC_PAIR, + ARM_RELOC_SECTDIFF = GENERIC_RELOC_SECTDIFF, + ARM_RELOC_LOCAL_SECTDIFF = 3, + ARM_RELOC_PB_LA_PTR = 4, + ARM_RELOC_BR24 = 5, + ARM_THUMB_RELOC_BR22 = 6, + ARM_THUMB_32BIT_BRANCH = 7, // obsolete + ARM_RELOC_HALF = 8, + ARM_RELOC_HALF_SECTDIFF = 9, + + // Constant values for the r_type field in an x86_64 architecture + // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info + // structure + X86_64_RELOC_UNSIGNED = 0, + X86_64_RELOC_SIGNED = 1, + X86_64_RELOC_BRANCH = 2, + X86_64_RELOC_GOT_LOAD = 3, + X86_64_RELOC_GOT = 4, + X86_64_RELOC_SUBTRACTOR = 5, + X86_64_RELOC_SIGNED_1 = 6, + X86_64_RELOC_SIGNED_2 = 7, + X86_64_RELOC_SIGNED_4 = 8, + X86_64_RELOC_TLV = 9 }; // Structs from @@ -572,6 +708,18 @@ namespace llvm { uint32_t datasize; }; + struct data_in_code_entry { + uint32_t offset; + uint16_t length; + uint16_t kind; + }; + + struct source_version_command { + uint32_t cmd; + uint32_t cmdsize; + uint64_t version; + }; + struct encryption_info_command { uint32_t cmd; uint32_t cmdsize; @@ -602,6 +750,12 @@ namespace llvm { uint32_t export_size; }; + struct linker_options_command { + uint32_t cmd; + uint32_t cmdsize; + uint32_t count; + }; + struct symseg_command { uint32_t cmd; uint32_t cmdsize; @@ -621,6 +775,24 @@ namespace llvm { uint32_t header_addr; }; + struct tlv_descriptor_32 { + uint32_t thunk; + uint32_t key; + uint32_t offset; + }; + + struct tlv_descriptor_64 { + uint64_t thunk; + uint64_t key; + uint64_t offset; + }; + + struct tlv_descriptor { + uintptr_t thunk; + uintptr_t key; + uintptr_t offset; + }; + struct entry_point_command { uint32_t cmd; uint32_t cmdsize; @@ -643,7 +815,39 @@ namespace llvm { uint32_t align; }; - // Structs from + // Structs from + struct relocation_info { + int32_t r_address; + uint32_t r_symbolnum:24, + r_pcrel:1, + r_length:2, + r_extern:1, + r_type:4; + }; + + struct scattered_relocation_info { +#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN) + uint32_t r_scattered:1, + r_pcrel:1, + r_length:2, + r_type:4, + r_address:24; +#else + uint32_t r_address:24, + r_type:4, + r_length:2, + r_pcrel:1, + r_scattered:1; +#endif + int32_t r_value; + }; + + // Structs NOT from , but that make LLVM's life easier + struct any_relocation_info { + uint32_t r_word0, r_word1; + }; + + // Structs from struct nlist { uint32_t n_strx; uint8_t n_type; @@ -662,58 +866,131 @@ namespace llvm { // Get/Set functions from - static inline uint16_t GET_LIBRARY_ORDINAL(uint16_t n_desc) - { + static inline uint16_t GET_LIBRARY_ORDINAL(uint16_t n_desc) { return (((n_desc) >> 8u) & 0xffu); } - static inline void SET_LIBRARY_ORDINAL(uint16_t &n_desc, uint8_t ordinal) - { + static inline void SET_LIBRARY_ORDINAL(uint16_t &n_desc, uint8_t ordinal) { n_desc = (((n_desc) & 0x00ff) | (((ordinal) & 0xff) << 8)); } - static inline uint8_t GET_COMM_ALIGN (uint16_t n_desc) - { + static inline uint8_t GET_COMM_ALIGN (uint16_t n_desc) { return (n_desc >> 8u) & 0x0fu; } - static inline void SET_COMM_ALIGN (uint16_t &n_desc, uint8_t align) - { + static inline void SET_COMM_ALIGN (uint16_t &n_desc, uint8_t align) { n_desc = ((n_desc & 0xf0ffu) | ((align & 0x0fu) << 8u)); } // Enums from enum { // Capability bits used in the definition of cpu_type. - CPUArchMask = 0xff000000, // Mask for architecture bits - CPUArchABI64 = 0x01000000, // 64 bit ABI - - // Constants for the cputype field. - CPUTypeI386 = 7, - CPUTypeX86_64 = CPUTypeI386 | CPUArchABI64, - CPUTypeARM = 12, - CPUTypeSPARC = 14, - CPUTypePowerPC = 18, - CPUTypePowerPC64 = CPUTypePowerPC | CPUArchABI64, - - - // Constants for the cpusubtype field. - - // X86 - CPUSubType_I386_ALL = 3, - CPUSubType_X86_64_ALL = 3, - - // ARM - CPUSubType_ARM_ALL = 0, - CPUSubType_ARM_V4T = 5, - CPUSubType_ARM_V5 = 7, - CPUSubType_ARM_V6 = 6, - CPUSubType_ARM_V7 = 9, + CPU_ARCH_MASK = 0xff000000, // Mask for architecture bits + CPU_ARCH_ABI64 = 0x01000000 // 64 bit ABI + }; - // PowerPC - CPUSubType_POWERPC_ALL = 0, + // Constants for the cputype field. + enum CPUType { + CPU_TYPE_ANY = -1, + CPU_TYPE_X86 = 7, + CPU_TYPE_I386 = CPU_TYPE_X86, + CPU_TYPE_X86_64 = CPU_TYPE_X86 | CPU_ARCH_ABI64, + /* CPU_TYPE_MIPS = 8, */ + CPU_TYPE_MC98000 = 10, // Old Motorola PowerPC + CPU_TYPE_ARM = 12, + CPU_TYPE_SPARC = 14, + CPU_TYPE_POWERPC = 18, + CPU_TYPE_POWERPC64 = CPU_TYPE_POWERPC | CPU_ARCH_ABI64 + }; - CPUSubType_SPARC_ALL = 0 + enum { + // Capability bits used in the definition of cpusubtype. + CPU_SUB_TYPE_MASK = 0xff000000, // Mask for architecture bits + CPU_SUB_TYPE_LIB64 = 0x80000000, // 64 bit libraries + + // Special CPU subtype constants. + CPU_SUBTYPE_MULTIPLE = -1 + }; + + // Constants for the cpusubtype field. + enum CPUSubTypeX86 { + CPU_SUBTYPE_I386_ALL = 3, + CPU_SUBTYPE_386 = 3, + CPU_SUBTYPE_486 = 4, + CPU_SUBTYPE_486SX = 0x84, + CPU_SUBTYPE_586 = 5, + CPU_SUBTYPE_PENT = CPU_SUBTYPE_586, + CPU_SUBTYPE_PENTPRO = 0x16, + CPU_SUBTYPE_PENTII_M3 = 0x36, + CPU_SUBTYPE_PENTII_M5 = 0x56, + CPU_SUBTYPE_CELERON = 0x67, + CPU_SUBTYPE_CELERON_MOBILE = 0x77, + CPU_SUBTYPE_PENTIUM_3 = 0x08, + CPU_SUBTYPE_PENTIUM_3_M = 0x18, + CPU_SUBTYPE_PENTIUM_3_XEON = 0x28, + CPU_SUBTYPE_PENTIUM_M = 0x09, + CPU_SUBTYPE_PENTIUM_4 = 0x0a, + CPU_SUBTYPE_PENTIUM_4_M = 0x1a, + CPU_SUBTYPE_ITANIUM = 0x0b, + CPU_SUBTYPE_ITANIUM_2 = 0x1b, + CPU_SUBTYPE_XEON = 0x0c, + CPU_SUBTYPE_XEON_MP = 0x1c, + + CPU_SUBTYPE_X86_ALL = 3, + CPU_SUBTYPE_X86_64_ALL = 3, + CPU_SUBTYPE_X86_ARCH1 = 4 + }; + static inline int CPU_SUBTYPE_INTEL(int Family, int Model) { + return Family | (Model << 4); + } + static inline int CPU_SUBTYPE_INTEL_FAMILY(CPUSubTypeX86 ST) { + return ((int)ST) & 0x0f; + } + static inline int CPU_SUBTYPE_INTEL_MODEL(CPUSubTypeX86 ST) { + return ((int)ST) >> 4; + } + enum { + CPU_SUBTYPE_INTEL_FAMILY_MAX = 15, + CPU_SUBTYPE_INTEL_MODEL_ALL = 0 + }; + + enum CPUSubTypeARM { + CPU_SUBTYPE_ARM_ALL = 0, + CPU_SUBTYPE_ARM_V4T = 5, + CPU_SUBTYPE_ARM_V6 = 6, + CPU_SUBTYPE_ARM_V5 = 7, + CPU_SUBTYPE_ARM_V5TEJ = 7, + CPU_SUBTYPE_ARM_XSCALE = 8, + CPU_SUBTYPE_ARM_V7 = 9, + CPU_SUBTYPE_ARM_V7F = 10, + CPU_SUBTYPE_ARM_V7S = 11, + CPU_SUBTYPE_ARM_V7K = 12, + CPU_SUBTYPE_ARM_V6M = 14, + CPU_SUBTYPE_ARM_V7M = 15, + CPU_SUBTYPE_ARM_V7EM = 16 + }; + + enum CPUSubTypeSPARC { + CPU_SUBTYPE_SPARC_ALL = 0 + }; + + enum CPUSubTypePowerPC { + CPU_SUBTYPE_POWERPC_ALL = 0, + CPU_SUBTYPE_POWERPC_601 = 1, + CPU_SUBTYPE_POWERPC_602 = 2, + CPU_SUBTYPE_POWERPC_603 = 3, + CPU_SUBTYPE_POWERPC_603e = 4, + CPU_SUBTYPE_POWERPC_603ev = 5, + CPU_SUBTYPE_POWERPC_604 = 6, + CPU_SUBTYPE_POWERPC_604e = 7, + CPU_SUBTYPE_POWERPC_620 = 8, + CPU_SUBTYPE_POWERPC_750 = 9, + CPU_SUBTYPE_POWERPC_7400 = 10, + CPU_SUBTYPE_POWERPC_7450 = 11, + CPU_SUBTYPE_POWERPC_970 = 100, + + CPU_SUBTYPE_MC980000_ALL = CPU_SUBTYPE_POWERPC_ALL, + CPU_SUBTYPE_MC98601 = CPU_SUBTYPE_POWERPC_601 }; } // end namespace MachO } // end namespace llvm -- cgit v1.1 From 9c3dd1b0d1e96ef408b68da3b06c6ebd6c943601 Mon Sep 17 00:00:00 2001 From: Charles Davis Date: Tue, 27 Aug 2013 05:00:43 +0000 Subject: Move everything depending on Object/MachOFormat.h over to Support/MachO.h. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189315 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCMachObjectWriter.h | 25 +- include/llvm/Object/MachO.h | 87 +++---- include/llvm/Object/MachOFormat.h | 452 ----------------------------------- include/llvm/Object/MachOUniversal.h | 6 +- 4 files changed, 67 insertions(+), 503 deletions(-) delete mode 100644 include/llvm/Object/MachOFormat.h (limited to 'include') diff --git a/include/llvm/MC/MCMachObjectWriter.h b/include/llvm/MC/MCMachObjectWriter.h index 3c9a588..ae3beb1 100644 --- a/include/llvm/MC/MCMachObjectWriter.h +++ b/include/llvm/MC/MCMachObjectWriter.h @@ -15,8 +15,8 @@ #include "llvm/ADT/SmallString.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCObjectWriter.h" -#include "llvm/Object/MachOFormat.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/MachO.h" #include namespace llvm { @@ -98,7 +98,7 @@ class MachObjectWriter : public MCObjectWriter { /// @{ llvm::DenseMap > Relocations; + std::vector > Relocations; llvm::DenseMap IndirectSymBase; /// @} @@ -155,9 +155,8 @@ public: bool is64Bit() const { return TargetObjectWriter->is64Bit(); } bool isARM() const { - uint32_t CPUType = TargetObjectWriter->getCPUType() & - ~object::mach::CTFM_ArchMask; - return CPUType == object::mach::CTM_ARM; + uint32_t CPUType = TargetObjectWriter->getCPUType() & ~MachO::CPU_ARCH_MASK; + return CPUType == MachO::CPU_TYPE_ARM; } /// @} @@ -213,7 +212,21 @@ public: // these through in many cases. void addRelocation(const MCSectionData *SD, - object::macho::RelocationEntry &MRE) { + MachO::relocation_info &MRE) { + MachO::any_relocation_info AMRE; + memcpy(&AMRE, &MRE, sizeof(MRE)); + Relocations[SD].push_back(AMRE); + } + + void addRelocation(const MCSectionData *SD, + MachO::scattered_relocation_info &SMRE) { + MachO::any_relocation_info MRE; + memcpy(&MRE, &SMRE, sizeof(MRE)); + Relocations[SD].push_back(MRE); + } + + void addRelocation(const MCSectionData *SD, + MachO::any_relocation_info &MRE) { Relocations[SD].push_back(MRE); } diff --git a/include/llvm/Object/MachO.h b/include/llvm/Object/MachO.h index caa642a..f3f391e 100644 --- a/include/llvm/Object/MachO.h +++ b/include/llvm/Object/MachO.h @@ -18,8 +18,8 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Triple.h" -#include "llvm/Object/MachOFormat.h" #include "llvm/Object/ObjectFile.h" +#include "llvm/Support/MachO.h" namespace llvm { namespace object { @@ -53,7 +53,7 @@ class MachOObjectFile : public ObjectFile { public: struct LoadCommandInfo { const char *Ptr; // Where in memory the load command is. - macho::LoadCommand C; // The command itself. + MachO::load_command C; // The command itself. }; MachOObjectFile(MemoryBuffer *Object, bool IsLittleEndian, bool Is64Bits, @@ -146,50 +146,53 @@ public: ArrayRef getSectionRawFinalSegmentName(DataRefImpl Sec) const; // MachO specific Info about relocations. - bool isRelocationScattered(const macho::RelocationEntry &RE) const; - unsigned getPlainRelocationSymbolNum(const macho::RelocationEntry &RE) const; - bool getPlainRelocationExternal(const macho::RelocationEntry &RE) const; - bool getScatteredRelocationScattered(const macho::RelocationEntry &RE) const; - uint32_t getScatteredRelocationValue(const macho::RelocationEntry &RE) const; - unsigned getAnyRelocationAddress(const macho::RelocationEntry &RE) const; - unsigned getAnyRelocationPCRel(const macho::RelocationEntry &RE) const; - unsigned getAnyRelocationLength(const macho::RelocationEntry &RE) const; - unsigned getAnyRelocationType(const macho::RelocationEntry &RE) const; - SectionRef getRelocationSection(const macho::RelocationEntry &RE) const; + bool isRelocationScattered(const MachO::any_relocation_info &RE) const; + unsigned getPlainRelocationSymbolNum( + const MachO::any_relocation_info &RE) const; + bool getPlainRelocationExternal(const MachO::any_relocation_info &RE) const; + bool getScatteredRelocationScattered( + const MachO::any_relocation_info &RE) const; + uint32_t getScatteredRelocationValue( + const MachO::any_relocation_info &RE) const; + unsigned getAnyRelocationAddress(const MachO::any_relocation_info &RE) const; + unsigned getAnyRelocationPCRel(const MachO::any_relocation_info &RE) const; + unsigned getAnyRelocationLength(const MachO::any_relocation_info &RE) const; + unsigned getAnyRelocationType(const MachO::any_relocation_info &RE) const; + SectionRef getRelocationSection(const MachO::any_relocation_info &RE) const; // Walk load commands. LoadCommandInfo getFirstLoadCommandInfo() const; LoadCommandInfo getNextLoadCommandInfo(const LoadCommandInfo &L) const; // MachO specific structures. - macho::Section getSection(DataRefImpl DRI) const; - macho::Section64 getSection64(DataRefImpl DRI) const; - macho::Section getSection(const LoadCommandInfo &L, unsigned Index) const; - macho::Section64 getSection64(const LoadCommandInfo &L, unsigned Index) const; - macho::SymbolTableEntry getSymbolTableEntry(DataRefImpl DRI) const; - macho::Symbol64TableEntry getSymbol64TableEntry(DataRefImpl DRI) const; - - macho::LinkeditDataLoadCommand + MachO::section getSection(DataRefImpl DRI) const; + MachO::section_64 getSection64(DataRefImpl DRI) const; + MachO::section getSection(const LoadCommandInfo &L, unsigned Index) const; + MachO::section_64 getSection64(const LoadCommandInfo &L,unsigned Index) const; + MachO::nlist getSymbolTableEntry(DataRefImpl DRI) const; + MachO::nlist_64 getSymbol64TableEntry(DataRefImpl DRI) const; + + MachO::linkedit_data_command getLinkeditDataLoadCommand(const LoadCommandInfo &L) const; - macho::SegmentLoadCommand + MachO::segment_command getSegmentLoadCommand(const LoadCommandInfo &L) const; - macho::Segment64LoadCommand + MachO::segment_command_64 getSegment64LoadCommand(const LoadCommandInfo &L) const; - macho::LinkerOptionsLoadCommand + MachO::linker_options_command getLinkerOptionsLoadCommand(const LoadCommandInfo &L) const; - macho::RelocationEntry getRelocation(DataRefImpl Rel) const; - macho::DataInCodeTableEntry getDice(DataRefImpl Rel) const; - macho::Header getHeader() const; - macho::Header64Ext getHeader64Ext() const; - macho::IndirectSymbolTableEntry - getIndirectSymbolTableEntry(const macho::DysymtabLoadCommand &DLC, + MachO::any_relocation_info getRelocation(DataRefImpl Rel) const; + MachO::data_in_code_entry getDice(DataRefImpl Rel) const; + MachO::mach_header getHeader() const; + MachO::mach_header_64 getHeader64() const; + uint32_t + getIndirectSymbolTableEntry(const MachO::dysymtab_command &DLC, unsigned Index) const; - macho::DataInCodeTableEntry getDataInCodeTableEntry(uint32_t DataOffset, - unsigned Index) const; - macho::SymtabLoadCommand getSymtabLoadCommand() const; - macho::DysymtabLoadCommand getDysymtabLoadCommand() const; - macho::LinkeditDataLoadCommand getDataInCodeLoadCommand() const; + MachO::data_in_code_entry getDataInCodeTableEntry(uint32_t DataOffset, + unsigned Index) const; + MachO::symtab_command getSymtabLoadCommand() const; + MachO::dysymtab_command getDysymtabLoadCommand() const; + MachO::linkedit_data_command getDataInCodeLoadCommand() const; StringRef getStringTableData() const; bool is64Bit() const; @@ -223,8 +226,8 @@ inline bool DiceRef::operator<(const DiceRef &Other) const { inline error_code DiceRef::getNext(DiceRef &Result) const { DataRefImpl Rel = DicePimpl; - const macho::DataInCodeTableEntry *P = - reinterpret_cast(Rel.p); + const MachO::data_in_code_entry *P = + reinterpret_cast(Rel.p); Rel.p = reinterpret_cast(P + 1); Result = DiceRef(Rel, OwningObject); return object_error::success; @@ -237,24 +240,24 @@ inline error_code DiceRef::getNext(DiceRef &Result) const { inline error_code DiceRef::getOffset(uint32_t &Result) const { const MachOObjectFile *MachOOF = static_cast(OwningObject); - macho::DataInCodeTableEntry Dice = MachOOF->getDice(DicePimpl); - Result = Dice.Offset; + MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl); + Result = Dice.offset; return object_error::success; } inline error_code DiceRef::getLength(uint16_t &Result) const { const MachOObjectFile *MachOOF = static_cast(OwningObject); - macho::DataInCodeTableEntry Dice = MachOOF->getDice(DicePimpl); - Result = Dice.Length; + MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl); + Result = Dice.length; return object_error::success; } inline error_code DiceRef::getKind(uint16_t &Result) const { const MachOObjectFile *MachOOF = static_cast(OwningObject); - macho::DataInCodeTableEntry Dice = MachOOF->getDice(DicePimpl); - Result = Dice.Kind; + MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl); + Result = Dice.kind; return object_error::success; } diff --git a/include/llvm/Object/MachOFormat.h b/include/llvm/Object/MachOFormat.h deleted file mode 100644 index 2bbad0a..0000000 --- a/include/llvm/Object/MachOFormat.h +++ /dev/null @@ -1,452 +0,0 @@ -//===- MachOFormat.h - Mach-O Format Structures And Constants ---*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares various structures and constants which are platform -// independent and can be shared by any client which wishes to interact with -// Mach object files. -// -// The definitions here are purposely chosen to match the LLVM style as opposed -// to following the platform specific definition of the format. -// -// On a Mach system, see the includes for more information, in -// particular . -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_OBJECT_MACHOFORMAT_H -#define LLVM_OBJECT_MACHOFORMAT_H - -#include "llvm/Support/DataTypes.h" - -namespace llvm { -namespace object { - -/// General Mach platform information. -namespace mach { - /// @name CPU Type and Subtype Information - /// { - - /// \brief Capability bits used in CPU type encoding. - enum CPUTypeFlagsMask { - CTFM_ArchMask = 0xFF000000, - CTFM_ArchABI64 = 0x01000000 - }; - - /// \brief Machine type IDs used in CPU type encoding. - enum CPUTypeMachine { - CTM_i386 = 7, - CTM_x86_64 = CTM_i386 | CTFM_ArchABI64, - CTM_ARM = 12, - CTM_SPARC = 14, - CTM_PowerPC = 18, - CTM_PowerPC64 = CTM_PowerPC | CTFM_ArchABI64 - }; - - /// \brief Capability bits used in CPU subtype encoding. - enum CPUSubtypeFlagsMask { - CSFM_SubtypeMask = 0xFF000000, - CSFM_SubtypeLib64 = 0x80000000 - }; - - /// \brief ARM Machine Subtypes. - enum CPUSubtypeARM { - CSARM_ALL = 0, - CSARM_V4T = 5, - CSARM_V6 = 6, - CSARM_V5TEJ = 7, - CSARM_XSCALE = 8, - CSARM_V7 = 9, - CSARM_V7F = 10, - CSARM_V7S = 11, - CSARM_V7K = 12, - CSARM_V6M = 14, - CSARM_V7M = 15, - CSARM_V7EM = 16 - }; - - /// \brief PowerPC Machine Subtypes. - enum CPUSubtypePowerPC { - CSPPC_ALL = 0 - }; - - /// \brief SPARC Machine Subtypes. - enum CPUSubtypeSPARC { - CSSPARC_ALL = 0 - }; - - /// \brief x86 Machine Subtypes. - enum CPUSubtypeX86 { - CSX86_ALL = 3 - }; - - /// @} - -} // end namespace mach - -/// Format information for Mach object files. -namespace macho { - /// \brief Constants for structure sizes. - enum StructureSizes { - Header32Size = 28, - Header64Size = 32, - FatHeaderSize = 8, - FatArchHeaderSize = 20, - SegmentLoadCommand32Size = 56, - SegmentLoadCommand64Size = 72, - Section32Size = 68, - Section64Size = 80, - SymtabLoadCommandSize = 24, - DysymtabLoadCommandSize = 80, - Nlist32Size = 12, - Nlist64Size = 16, - RelocationInfoSize = 8, - LinkeditLoadCommandSize = 16 - }; - - /// \brief Constants for header magic field. - enum HeaderMagic { - HM_Object32 = 0xFEEDFACE, ///< 32-bit mach object file - HM_Object64 = 0xFEEDFACF, ///< 64-bit mach object file - HM_Universal = 0xCAFEBABE ///< Universal object file - }; - - /// \brief Header common to all Mach object files. - struct Header { - uint32_t Magic; - uint32_t CPUType; - uint32_t CPUSubtype; - uint32_t FileType; - uint32_t NumLoadCommands; - uint32_t SizeOfLoadCommands; - uint32_t Flags; - }; - - /// \brief Extended header for 64-bit object files. - struct Header64Ext { - uint32_t Reserved; - }; - - /// \brief Header for universal object files. - struct FatHeader { - uint32_t Magic; - uint32_t NumFatArch; - }; - - /// \brief Header for a single-architecture object file in a - /// universal binary. - struct FatArchHeader { - uint32_t CPUType; - uint32_t CPUSubtype; - uint32_t Offset; - uint32_t Size; - uint32_t Align; - }; - - // See . - enum HeaderFileType { - HFT_Object = 0x1 - }; - - enum HeaderFlags { - HF_SubsectionsViaSymbols = 0x2000 - }; - - enum LoadCommandType { - LCT_Segment = 0x1, - LCT_Symtab = 0x2, - LCT_Dysymtab = 0xb, - LCT_Segment64 = 0x19, - LCT_UUID = 0x1b, - LCT_CodeSignature = 0x1d, - LCT_SegmentSplitInfo = 0x1e, - LCT_FunctionStarts = 0x26, - LCT_DataInCode = 0x29, - LCT_LinkerOptions = 0x2D - }; - - /// \brief Load command structure. - struct LoadCommand { - uint32_t Type; - uint32_t Size; - }; - - /// @name Load Command Structures - /// @{ - - struct SegmentLoadCommand { - uint32_t Type; - uint32_t Size; - char Name[16]; - uint32_t VMAddress; - uint32_t VMSize; - uint32_t FileOffset; - uint32_t FileSize; - uint32_t MaxVMProtection; - uint32_t InitialVMProtection; - uint32_t NumSections; - uint32_t Flags; - }; - - struct Segment64LoadCommand { - uint32_t Type; - uint32_t Size; - char Name[16]; - uint64_t VMAddress; - uint64_t VMSize; - uint64_t FileOffset; - uint64_t FileSize; - uint32_t MaxVMProtection; - uint32_t InitialVMProtection; - uint32_t NumSections; - uint32_t Flags; - }; - - struct SymtabLoadCommand { - uint32_t Type; - uint32_t Size; - uint32_t SymbolTableOffset; - uint32_t NumSymbolTableEntries; - uint32_t StringTableOffset; - uint32_t StringTableSize; - }; - - struct DysymtabLoadCommand { - uint32_t Type; - uint32_t Size; - - uint32_t LocalSymbolsIndex; - uint32_t NumLocalSymbols; - - uint32_t ExternalSymbolsIndex; - uint32_t NumExternalSymbols; - - uint32_t UndefinedSymbolsIndex; - uint32_t NumUndefinedSymbols; - - uint32_t TOCOffset; - uint32_t NumTOCEntries; - - uint32_t ModuleTableOffset; - uint32_t NumModuleTableEntries; - - uint32_t ReferenceSymbolTableOffset; - uint32_t NumReferencedSymbolTableEntries; - - uint32_t IndirectSymbolTableOffset; - uint32_t NumIndirectSymbolTableEntries; - - uint32_t ExternalRelocationTableOffset; - uint32_t NumExternalRelocationTableEntries; - - uint32_t LocalRelocationTableOffset; - uint32_t NumLocalRelocationTableEntries; - }; - - struct LinkeditDataLoadCommand { - uint32_t Type; - uint32_t Size; - uint32_t DataOffset; - uint32_t DataSize; - }; - - struct LinkerOptionsLoadCommand { - uint32_t Type; - uint32_t Size; - uint32_t Count; - // Load command is followed by Count number of zero-terminated UTF8 strings, - // and then zero-filled to be 4-byte aligned. - }; - - /// @} - /// @name Section Data - /// @{ - - enum SectionFlags { - SF_PureInstructions = 0x80000000 - }; - - struct Section { - char Name[16]; - char SegmentName[16]; - uint32_t Address; - uint32_t Size; - uint32_t Offset; - uint32_t Align; - uint32_t RelocationTableOffset; - uint32_t NumRelocationTableEntries; - uint32_t Flags; - uint32_t Reserved1; - uint32_t Reserved2; - }; - struct Section64 { - char Name[16]; - char SegmentName[16]; - uint64_t Address; - uint64_t Size; - uint32_t Offset; - uint32_t Align; - uint32_t RelocationTableOffset; - uint32_t NumRelocationTableEntries; - uint32_t Flags; - uint32_t Reserved1; - uint32_t Reserved2; - uint32_t Reserved3; - }; - - /// @} - /// @name Symbol Table Entries - /// @{ - - struct SymbolTableEntry { - uint32_t StringIndex; - uint8_t Type; - uint8_t SectionIndex; - uint16_t Flags; - uint32_t Value; - }; - // Despite containing a uint64_t, this structure is only 4-byte aligned within - // a MachO file. -#pragma pack(push) -#pragma pack(4) - struct Symbol64TableEntry { - uint32_t StringIndex; - uint8_t Type; - uint8_t SectionIndex; - uint16_t Flags; - uint64_t Value; - }; -#pragma pack(pop) - - /// @} - /// @name Data-in-code Table Entry - /// @{ - - // See . - enum DataRegionType { Data = 1, JumpTable8, JumpTable16, JumpTable32 }; - struct DataInCodeTableEntry { - uint32_t Offset; /* from mach_header to start of data region */ - uint16_t Length; /* number of bytes in data region */ - uint16_t Kind; /* a DataRegionType value */ - }; - - /// @} - /// @name Indirect Symbol Table - /// @{ - - struct IndirectSymbolTableEntry { - uint32_t Index; - }; - - /// @} - /// @name Relocation Data - /// @{ - - struct RelocationEntry { - uint32_t Word0; - uint32_t Word1; - }; - - /// @} - - // See . - enum SymbolTypeType { - STT_Undefined = 0x00, - STT_Absolute = 0x02, - STT_Section = 0x0e - }; - - enum SymbolTypeFlags { - // If any of these bits are set, then the entry is a stab entry number (see - // . Otherwise the other masks apply. - STF_StabsEntryMask = 0xe0, - - STF_TypeMask = 0x0e, - STF_External = 0x01, - STF_PrivateExtern = 0x10 - }; - - /// IndirectSymbolFlags - Flags for encoding special values in the indirect - /// symbol entry. - enum IndirectSymbolFlags { - ISF_Local = 0x80000000, - ISF_Absolute = 0x40000000 - }; - - /// RelocationFlags - Special flags for addresses. - enum RelocationFlags { - RF_Scattered = 0x80000000 - }; - - /// Common relocation info types. - enum RelocationInfoType { - RIT_Vanilla = 0, - RIT_Pair = 1, - RIT_Difference = 2 - }; - - /// Generic relocation info types, which are shared by some (but not all) - /// platforms. - enum RelocationInfoType_Generic { - RIT_Generic_PreboundLazyPointer = 3, - RIT_Generic_LocalDifference = 4, - RIT_Generic_TLV = 5 - }; - - /// X86_64 uses its own relocation types. - enum RelocationInfoTypeX86_64 { - // Note that x86_64 doesn't even share the common relocation types. - RIT_X86_64_Unsigned = 0, - RIT_X86_64_Signed = 1, - RIT_X86_64_Branch = 2, - RIT_X86_64_GOTLoad = 3, - RIT_X86_64_GOT = 4, - RIT_X86_64_Subtractor = 5, - RIT_X86_64_Signed1 = 6, - RIT_X86_64_Signed2 = 7, - RIT_X86_64_Signed4 = 8, - RIT_X86_64_TLV = 9 - }; - - /// ARM uses its own relocation types. - enum RelocationInfoTypeARM { - RIT_ARM_LocalDifference = 3, - RIT_ARM_PreboundLazyPointer = 4, - RIT_ARM_Branch24Bit = 5, - RIT_ARM_ThumbBranch22Bit = 6, - RIT_ARM_ThumbBranch32Bit = 7, - RIT_ARM_Half = 8, - RIT_ARM_HalfDifference = 9 - - }; - - /// PPC relocation types from - enum RelocationInfoTypePPC { - RIT_PPC_BR14 = RIT_Pair +1, - RIT_PPC_BR24, - RIT_PPC_HI16, - RIT_PPC_LO16, - RIT_PPC_HA16, - RIT_PPC_LO14, - RIT_PPC_SECTDIFF, - RIT_PPC_PB_LA_PTR, - RIT_PPC_HI16_SECTDIFF, - RIT_PPC_LO16_SECTDIFF, - RIT_PPC_HA16_SECTDIFF, - RIT_PPC_JBSR, - RIT_PPC_LO14_SECTDIFF, - RIT_PPC_LOCAL_SECTDIFF, - RIT_PPC_TLV - }; - -} // end namespace macho - -} // end namespace object -} // end namespace llvm - -#endif diff --git a/include/llvm/Object/MachOUniversal.h b/include/llvm/Object/MachOUniversal.h index 5743282..c5d1359 100644 --- a/include/llvm/Object/MachOUniversal.h +++ b/include/llvm/Object/MachOUniversal.h @@ -18,7 +18,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" #include "llvm/Object/Binary.h" -#include "llvm/Object/MachOFormat.h" +#include "llvm/Support/MachO.h" namespace llvm { namespace object { @@ -35,7 +35,7 @@ public: /// \brief Index of object in the universal binary. uint32_t Index; /// \brief Descriptor of the object. - macho::FatArchHeader Header; + MachO::fat_arch Header; public: ObjectForArch(const MachOUniversalBinary *Parent, uint32_t Index); @@ -50,7 +50,7 @@ public: } ObjectForArch getNext() const { return ObjectForArch(Parent, Index + 1); } - uint32_t getCPUType() const { return Header.CPUType; } + uint32_t getCPUType() const { return Header.cputype; } error_code getAsObjectFile(OwningPtr &Result) const; }; -- cgit v1.1 From f69a29b23a116a3520f185054290c445abf9aa62 Mon Sep 17 00:00:00 2001 From: Charles Davis Date: Tue, 27 Aug 2013 05:38:30 +0000 Subject: Revert "Fix the build broken by r189315." and "Move everything depending on Object/MachOFormat.h over to Support/MachO.h." This reverts commits r189319 and r189315. r189315 broke some tests on what I believe are big-endian platforms. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189321 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCMachObjectWriter.h | 25 +- include/llvm/Object/MachO.h | 87 ++++--- include/llvm/Object/MachOFormat.h | 452 +++++++++++++++++++++++++++++++++++ include/llvm/Object/MachOUniversal.h | 6 +- 4 files changed, 503 insertions(+), 67 deletions(-) create mode 100644 include/llvm/Object/MachOFormat.h (limited to 'include') diff --git a/include/llvm/MC/MCMachObjectWriter.h b/include/llvm/MC/MCMachObjectWriter.h index ae3beb1..3c9a588 100644 --- a/include/llvm/MC/MCMachObjectWriter.h +++ b/include/llvm/MC/MCMachObjectWriter.h @@ -15,8 +15,8 @@ #include "llvm/ADT/SmallString.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCObjectWriter.h" +#include "llvm/Object/MachOFormat.h" #include "llvm/Support/DataTypes.h" -#include "llvm/Support/MachO.h" #include namespace llvm { @@ -98,7 +98,7 @@ class MachObjectWriter : public MCObjectWriter { /// @{ llvm::DenseMap > Relocations; + std::vector > Relocations; llvm::DenseMap IndirectSymBase; /// @} @@ -155,8 +155,9 @@ public: bool is64Bit() const { return TargetObjectWriter->is64Bit(); } bool isARM() const { - uint32_t CPUType = TargetObjectWriter->getCPUType() & ~MachO::CPU_ARCH_MASK; - return CPUType == MachO::CPU_TYPE_ARM; + uint32_t CPUType = TargetObjectWriter->getCPUType() & + ~object::mach::CTFM_ArchMask; + return CPUType == object::mach::CTM_ARM; } /// @} @@ -212,21 +213,7 @@ public: // these through in many cases. void addRelocation(const MCSectionData *SD, - MachO::relocation_info &MRE) { - MachO::any_relocation_info AMRE; - memcpy(&AMRE, &MRE, sizeof(MRE)); - Relocations[SD].push_back(AMRE); - } - - void addRelocation(const MCSectionData *SD, - MachO::scattered_relocation_info &SMRE) { - MachO::any_relocation_info MRE; - memcpy(&MRE, &SMRE, sizeof(MRE)); - Relocations[SD].push_back(MRE); - } - - void addRelocation(const MCSectionData *SD, - MachO::any_relocation_info &MRE) { + object::macho::RelocationEntry &MRE) { Relocations[SD].push_back(MRE); } diff --git a/include/llvm/Object/MachO.h b/include/llvm/Object/MachO.h index f3f391e..caa642a 100644 --- a/include/llvm/Object/MachO.h +++ b/include/llvm/Object/MachO.h @@ -18,8 +18,8 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Triple.h" +#include "llvm/Object/MachOFormat.h" #include "llvm/Object/ObjectFile.h" -#include "llvm/Support/MachO.h" namespace llvm { namespace object { @@ -53,7 +53,7 @@ class MachOObjectFile : public ObjectFile { public: struct LoadCommandInfo { const char *Ptr; // Where in memory the load command is. - MachO::load_command C; // The command itself. + macho::LoadCommand C; // The command itself. }; MachOObjectFile(MemoryBuffer *Object, bool IsLittleEndian, bool Is64Bits, @@ -146,53 +146,50 @@ public: ArrayRef getSectionRawFinalSegmentName(DataRefImpl Sec) const; // MachO specific Info about relocations. - bool isRelocationScattered(const MachO::any_relocation_info &RE) const; - unsigned getPlainRelocationSymbolNum( - const MachO::any_relocation_info &RE) const; - bool getPlainRelocationExternal(const MachO::any_relocation_info &RE) const; - bool getScatteredRelocationScattered( - const MachO::any_relocation_info &RE) const; - uint32_t getScatteredRelocationValue( - const MachO::any_relocation_info &RE) const; - unsigned getAnyRelocationAddress(const MachO::any_relocation_info &RE) const; - unsigned getAnyRelocationPCRel(const MachO::any_relocation_info &RE) const; - unsigned getAnyRelocationLength(const MachO::any_relocation_info &RE) const; - unsigned getAnyRelocationType(const MachO::any_relocation_info &RE) const; - SectionRef getRelocationSection(const MachO::any_relocation_info &RE) const; + bool isRelocationScattered(const macho::RelocationEntry &RE) const; + unsigned getPlainRelocationSymbolNum(const macho::RelocationEntry &RE) const; + bool getPlainRelocationExternal(const macho::RelocationEntry &RE) const; + bool getScatteredRelocationScattered(const macho::RelocationEntry &RE) const; + uint32_t getScatteredRelocationValue(const macho::RelocationEntry &RE) const; + unsigned getAnyRelocationAddress(const macho::RelocationEntry &RE) const; + unsigned getAnyRelocationPCRel(const macho::RelocationEntry &RE) const; + unsigned getAnyRelocationLength(const macho::RelocationEntry &RE) const; + unsigned getAnyRelocationType(const macho::RelocationEntry &RE) const; + SectionRef getRelocationSection(const macho::RelocationEntry &RE) const; // Walk load commands. LoadCommandInfo getFirstLoadCommandInfo() const; LoadCommandInfo getNextLoadCommandInfo(const LoadCommandInfo &L) const; // MachO specific structures. - MachO::section getSection(DataRefImpl DRI) const; - MachO::section_64 getSection64(DataRefImpl DRI) const; - MachO::section getSection(const LoadCommandInfo &L, unsigned Index) const; - MachO::section_64 getSection64(const LoadCommandInfo &L,unsigned Index) const; - MachO::nlist getSymbolTableEntry(DataRefImpl DRI) const; - MachO::nlist_64 getSymbol64TableEntry(DataRefImpl DRI) const; - - MachO::linkedit_data_command + macho::Section getSection(DataRefImpl DRI) const; + macho::Section64 getSection64(DataRefImpl DRI) const; + macho::Section getSection(const LoadCommandInfo &L, unsigned Index) const; + macho::Section64 getSection64(const LoadCommandInfo &L, unsigned Index) const; + macho::SymbolTableEntry getSymbolTableEntry(DataRefImpl DRI) const; + macho::Symbol64TableEntry getSymbol64TableEntry(DataRefImpl DRI) const; + + macho::LinkeditDataLoadCommand getLinkeditDataLoadCommand(const LoadCommandInfo &L) const; - MachO::segment_command + macho::SegmentLoadCommand getSegmentLoadCommand(const LoadCommandInfo &L) const; - MachO::segment_command_64 + macho::Segment64LoadCommand getSegment64LoadCommand(const LoadCommandInfo &L) const; - MachO::linker_options_command + macho::LinkerOptionsLoadCommand getLinkerOptionsLoadCommand(const LoadCommandInfo &L) const; - MachO::any_relocation_info getRelocation(DataRefImpl Rel) const; - MachO::data_in_code_entry getDice(DataRefImpl Rel) const; - MachO::mach_header getHeader() const; - MachO::mach_header_64 getHeader64() const; - uint32_t - getIndirectSymbolTableEntry(const MachO::dysymtab_command &DLC, + macho::RelocationEntry getRelocation(DataRefImpl Rel) const; + macho::DataInCodeTableEntry getDice(DataRefImpl Rel) const; + macho::Header getHeader() const; + macho::Header64Ext getHeader64Ext() const; + macho::IndirectSymbolTableEntry + getIndirectSymbolTableEntry(const macho::DysymtabLoadCommand &DLC, unsigned Index) const; - MachO::data_in_code_entry getDataInCodeTableEntry(uint32_t DataOffset, - unsigned Index) const; - MachO::symtab_command getSymtabLoadCommand() const; - MachO::dysymtab_command getDysymtabLoadCommand() const; - MachO::linkedit_data_command getDataInCodeLoadCommand() const; + macho::DataInCodeTableEntry getDataInCodeTableEntry(uint32_t DataOffset, + unsigned Index) const; + macho::SymtabLoadCommand getSymtabLoadCommand() const; + macho::DysymtabLoadCommand getDysymtabLoadCommand() const; + macho::LinkeditDataLoadCommand getDataInCodeLoadCommand() const; StringRef getStringTableData() const; bool is64Bit() const; @@ -226,8 +223,8 @@ inline bool DiceRef::operator<(const DiceRef &Other) const { inline error_code DiceRef::getNext(DiceRef &Result) const { DataRefImpl Rel = DicePimpl; - const MachO::data_in_code_entry *P = - reinterpret_cast(Rel.p); + const macho::DataInCodeTableEntry *P = + reinterpret_cast(Rel.p); Rel.p = reinterpret_cast(P + 1); Result = DiceRef(Rel, OwningObject); return object_error::success; @@ -240,24 +237,24 @@ inline error_code DiceRef::getNext(DiceRef &Result) const { inline error_code DiceRef::getOffset(uint32_t &Result) const { const MachOObjectFile *MachOOF = static_cast(OwningObject); - MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl); - Result = Dice.offset; + macho::DataInCodeTableEntry Dice = MachOOF->getDice(DicePimpl); + Result = Dice.Offset; return object_error::success; } inline error_code DiceRef::getLength(uint16_t &Result) const { const MachOObjectFile *MachOOF = static_cast(OwningObject); - MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl); - Result = Dice.length; + macho::DataInCodeTableEntry Dice = MachOOF->getDice(DicePimpl); + Result = Dice.Length; return object_error::success; } inline error_code DiceRef::getKind(uint16_t &Result) const { const MachOObjectFile *MachOOF = static_cast(OwningObject); - MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl); - Result = Dice.kind; + macho::DataInCodeTableEntry Dice = MachOOF->getDice(DicePimpl); + Result = Dice.Kind; return object_error::success; } diff --git a/include/llvm/Object/MachOFormat.h b/include/llvm/Object/MachOFormat.h new file mode 100644 index 0000000..2bbad0a --- /dev/null +++ b/include/llvm/Object/MachOFormat.h @@ -0,0 +1,452 @@ +//===- MachOFormat.h - Mach-O Format Structures And Constants ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares various structures and constants which are platform +// independent and can be shared by any client which wishes to interact with +// Mach object files. +// +// The definitions here are purposely chosen to match the LLVM style as opposed +// to following the platform specific definition of the format. +// +// On a Mach system, see the includes for more information, in +// particular . +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_OBJECT_MACHOFORMAT_H +#define LLVM_OBJECT_MACHOFORMAT_H + +#include "llvm/Support/DataTypes.h" + +namespace llvm { +namespace object { + +/// General Mach platform information. +namespace mach { + /// @name CPU Type and Subtype Information + /// { + + /// \brief Capability bits used in CPU type encoding. + enum CPUTypeFlagsMask { + CTFM_ArchMask = 0xFF000000, + CTFM_ArchABI64 = 0x01000000 + }; + + /// \brief Machine type IDs used in CPU type encoding. + enum CPUTypeMachine { + CTM_i386 = 7, + CTM_x86_64 = CTM_i386 | CTFM_ArchABI64, + CTM_ARM = 12, + CTM_SPARC = 14, + CTM_PowerPC = 18, + CTM_PowerPC64 = CTM_PowerPC | CTFM_ArchABI64 + }; + + /// \brief Capability bits used in CPU subtype encoding. + enum CPUSubtypeFlagsMask { + CSFM_SubtypeMask = 0xFF000000, + CSFM_SubtypeLib64 = 0x80000000 + }; + + /// \brief ARM Machine Subtypes. + enum CPUSubtypeARM { + CSARM_ALL = 0, + CSARM_V4T = 5, + CSARM_V6 = 6, + CSARM_V5TEJ = 7, + CSARM_XSCALE = 8, + CSARM_V7 = 9, + CSARM_V7F = 10, + CSARM_V7S = 11, + CSARM_V7K = 12, + CSARM_V6M = 14, + CSARM_V7M = 15, + CSARM_V7EM = 16 + }; + + /// \brief PowerPC Machine Subtypes. + enum CPUSubtypePowerPC { + CSPPC_ALL = 0 + }; + + /// \brief SPARC Machine Subtypes. + enum CPUSubtypeSPARC { + CSSPARC_ALL = 0 + }; + + /// \brief x86 Machine Subtypes. + enum CPUSubtypeX86 { + CSX86_ALL = 3 + }; + + /// @} + +} // end namespace mach + +/// Format information for Mach object files. +namespace macho { + /// \brief Constants for structure sizes. + enum StructureSizes { + Header32Size = 28, + Header64Size = 32, + FatHeaderSize = 8, + FatArchHeaderSize = 20, + SegmentLoadCommand32Size = 56, + SegmentLoadCommand64Size = 72, + Section32Size = 68, + Section64Size = 80, + SymtabLoadCommandSize = 24, + DysymtabLoadCommandSize = 80, + Nlist32Size = 12, + Nlist64Size = 16, + RelocationInfoSize = 8, + LinkeditLoadCommandSize = 16 + }; + + /// \brief Constants for header magic field. + enum HeaderMagic { + HM_Object32 = 0xFEEDFACE, ///< 32-bit mach object file + HM_Object64 = 0xFEEDFACF, ///< 64-bit mach object file + HM_Universal = 0xCAFEBABE ///< Universal object file + }; + + /// \brief Header common to all Mach object files. + struct Header { + uint32_t Magic; + uint32_t CPUType; + uint32_t CPUSubtype; + uint32_t FileType; + uint32_t NumLoadCommands; + uint32_t SizeOfLoadCommands; + uint32_t Flags; + }; + + /// \brief Extended header for 64-bit object files. + struct Header64Ext { + uint32_t Reserved; + }; + + /// \brief Header for universal object files. + struct FatHeader { + uint32_t Magic; + uint32_t NumFatArch; + }; + + /// \brief Header for a single-architecture object file in a + /// universal binary. + struct FatArchHeader { + uint32_t CPUType; + uint32_t CPUSubtype; + uint32_t Offset; + uint32_t Size; + uint32_t Align; + }; + + // See . + enum HeaderFileType { + HFT_Object = 0x1 + }; + + enum HeaderFlags { + HF_SubsectionsViaSymbols = 0x2000 + }; + + enum LoadCommandType { + LCT_Segment = 0x1, + LCT_Symtab = 0x2, + LCT_Dysymtab = 0xb, + LCT_Segment64 = 0x19, + LCT_UUID = 0x1b, + LCT_CodeSignature = 0x1d, + LCT_SegmentSplitInfo = 0x1e, + LCT_FunctionStarts = 0x26, + LCT_DataInCode = 0x29, + LCT_LinkerOptions = 0x2D + }; + + /// \brief Load command structure. + struct LoadCommand { + uint32_t Type; + uint32_t Size; + }; + + /// @name Load Command Structures + /// @{ + + struct SegmentLoadCommand { + uint32_t Type; + uint32_t Size; + char Name[16]; + uint32_t VMAddress; + uint32_t VMSize; + uint32_t FileOffset; + uint32_t FileSize; + uint32_t MaxVMProtection; + uint32_t InitialVMProtection; + uint32_t NumSections; + uint32_t Flags; + }; + + struct Segment64LoadCommand { + uint32_t Type; + uint32_t Size; + char Name[16]; + uint64_t VMAddress; + uint64_t VMSize; + uint64_t FileOffset; + uint64_t FileSize; + uint32_t MaxVMProtection; + uint32_t InitialVMProtection; + uint32_t NumSections; + uint32_t Flags; + }; + + struct SymtabLoadCommand { + uint32_t Type; + uint32_t Size; + uint32_t SymbolTableOffset; + uint32_t NumSymbolTableEntries; + uint32_t StringTableOffset; + uint32_t StringTableSize; + }; + + struct DysymtabLoadCommand { + uint32_t Type; + uint32_t Size; + + uint32_t LocalSymbolsIndex; + uint32_t NumLocalSymbols; + + uint32_t ExternalSymbolsIndex; + uint32_t NumExternalSymbols; + + uint32_t UndefinedSymbolsIndex; + uint32_t NumUndefinedSymbols; + + uint32_t TOCOffset; + uint32_t NumTOCEntries; + + uint32_t ModuleTableOffset; + uint32_t NumModuleTableEntries; + + uint32_t ReferenceSymbolTableOffset; + uint32_t NumReferencedSymbolTableEntries; + + uint32_t IndirectSymbolTableOffset; + uint32_t NumIndirectSymbolTableEntries; + + uint32_t ExternalRelocationTableOffset; + uint32_t NumExternalRelocationTableEntries; + + uint32_t LocalRelocationTableOffset; + uint32_t NumLocalRelocationTableEntries; + }; + + struct LinkeditDataLoadCommand { + uint32_t Type; + uint32_t Size; + uint32_t DataOffset; + uint32_t DataSize; + }; + + struct LinkerOptionsLoadCommand { + uint32_t Type; + uint32_t Size; + uint32_t Count; + // Load command is followed by Count number of zero-terminated UTF8 strings, + // and then zero-filled to be 4-byte aligned. + }; + + /// @} + /// @name Section Data + /// @{ + + enum SectionFlags { + SF_PureInstructions = 0x80000000 + }; + + struct Section { + char Name[16]; + char SegmentName[16]; + uint32_t Address; + uint32_t Size; + uint32_t Offset; + uint32_t Align; + uint32_t RelocationTableOffset; + uint32_t NumRelocationTableEntries; + uint32_t Flags; + uint32_t Reserved1; + uint32_t Reserved2; + }; + struct Section64 { + char Name[16]; + char SegmentName[16]; + uint64_t Address; + uint64_t Size; + uint32_t Offset; + uint32_t Align; + uint32_t RelocationTableOffset; + uint32_t NumRelocationTableEntries; + uint32_t Flags; + uint32_t Reserved1; + uint32_t Reserved2; + uint32_t Reserved3; + }; + + /// @} + /// @name Symbol Table Entries + /// @{ + + struct SymbolTableEntry { + uint32_t StringIndex; + uint8_t Type; + uint8_t SectionIndex; + uint16_t Flags; + uint32_t Value; + }; + // Despite containing a uint64_t, this structure is only 4-byte aligned within + // a MachO file. +#pragma pack(push) +#pragma pack(4) + struct Symbol64TableEntry { + uint32_t StringIndex; + uint8_t Type; + uint8_t SectionIndex; + uint16_t Flags; + uint64_t Value; + }; +#pragma pack(pop) + + /// @} + /// @name Data-in-code Table Entry + /// @{ + + // See . + enum DataRegionType { Data = 1, JumpTable8, JumpTable16, JumpTable32 }; + struct DataInCodeTableEntry { + uint32_t Offset; /* from mach_header to start of data region */ + uint16_t Length; /* number of bytes in data region */ + uint16_t Kind; /* a DataRegionType value */ + }; + + /// @} + /// @name Indirect Symbol Table + /// @{ + + struct IndirectSymbolTableEntry { + uint32_t Index; + }; + + /// @} + /// @name Relocation Data + /// @{ + + struct RelocationEntry { + uint32_t Word0; + uint32_t Word1; + }; + + /// @} + + // See . + enum SymbolTypeType { + STT_Undefined = 0x00, + STT_Absolute = 0x02, + STT_Section = 0x0e + }; + + enum SymbolTypeFlags { + // If any of these bits are set, then the entry is a stab entry number (see + // . Otherwise the other masks apply. + STF_StabsEntryMask = 0xe0, + + STF_TypeMask = 0x0e, + STF_External = 0x01, + STF_PrivateExtern = 0x10 + }; + + /// IndirectSymbolFlags - Flags for encoding special values in the indirect + /// symbol entry. + enum IndirectSymbolFlags { + ISF_Local = 0x80000000, + ISF_Absolute = 0x40000000 + }; + + /// RelocationFlags - Special flags for addresses. + enum RelocationFlags { + RF_Scattered = 0x80000000 + }; + + /// Common relocation info types. + enum RelocationInfoType { + RIT_Vanilla = 0, + RIT_Pair = 1, + RIT_Difference = 2 + }; + + /// Generic relocation info types, which are shared by some (but not all) + /// platforms. + enum RelocationInfoType_Generic { + RIT_Generic_PreboundLazyPointer = 3, + RIT_Generic_LocalDifference = 4, + RIT_Generic_TLV = 5 + }; + + /// X86_64 uses its own relocation types. + enum RelocationInfoTypeX86_64 { + // Note that x86_64 doesn't even share the common relocation types. + RIT_X86_64_Unsigned = 0, + RIT_X86_64_Signed = 1, + RIT_X86_64_Branch = 2, + RIT_X86_64_GOTLoad = 3, + RIT_X86_64_GOT = 4, + RIT_X86_64_Subtractor = 5, + RIT_X86_64_Signed1 = 6, + RIT_X86_64_Signed2 = 7, + RIT_X86_64_Signed4 = 8, + RIT_X86_64_TLV = 9 + }; + + /// ARM uses its own relocation types. + enum RelocationInfoTypeARM { + RIT_ARM_LocalDifference = 3, + RIT_ARM_PreboundLazyPointer = 4, + RIT_ARM_Branch24Bit = 5, + RIT_ARM_ThumbBranch22Bit = 6, + RIT_ARM_ThumbBranch32Bit = 7, + RIT_ARM_Half = 8, + RIT_ARM_HalfDifference = 9 + + }; + + /// PPC relocation types from + enum RelocationInfoTypePPC { + RIT_PPC_BR14 = RIT_Pair +1, + RIT_PPC_BR24, + RIT_PPC_HI16, + RIT_PPC_LO16, + RIT_PPC_HA16, + RIT_PPC_LO14, + RIT_PPC_SECTDIFF, + RIT_PPC_PB_LA_PTR, + RIT_PPC_HI16_SECTDIFF, + RIT_PPC_LO16_SECTDIFF, + RIT_PPC_HA16_SECTDIFF, + RIT_PPC_JBSR, + RIT_PPC_LO14_SECTDIFF, + RIT_PPC_LOCAL_SECTDIFF, + RIT_PPC_TLV + }; + +} // end namespace macho + +} // end namespace object +} // end namespace llvm + +#endif diff --git a/include/llvm/Object/MachOUniversal.h b/include/llvm/Object/MachOUniversal.h index c5d1359..5743282 100644 --- a/include/llvm/Object/MachOUniversal.h +++ b/include/llvm/Object/MachOUniversal.h @@ -18,7 +18,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" #include "llvm/Object/Binary.h" -#include "llvm/Support/MachO.h" +#include "llvm/Object/MachOFormat.h" namespace llvm { namespace object { @@ -35,7 +35,7 @@ public: /// \brief Index of object in the universal binary. uint32_t Index; /// \brief Descriptor of the object. - MachO::fat_arch Header; + macho::FatArchHeader Header; public: ObjectForArch(const MachOUniversalBinary *Parent, uint32_t Index); @@ -50,7 +50,7 @@ public: } ObjectForArch getNext() const { return ObjectForArch(Parent, Index + 1); } - uint32_t getCPUType() const { return Header.cputype; } + uint32_t getCPUType() const { return Header.CPUType; } error_code getAsObjectFile(OwningPtr &Result) const; }; -- cgit v1.1 From 63fd2af3892a81026f40374d08b5124e72ccff4e Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Tue, 27 Aug 2013 09:20:22 +0000 Subject: Add support for DebugFission to DWARF parser Summary: 1) Make llvm-symbolizer properly symbolize files with split debug info (by using stanalone .dwo files). 2) Make DWARFCompileUnit parse and store corresponding .dwo file, if necessary. 3) Make bits of DWARF parsing more CompileUnit-oriented. Reviewers: echristo Reviewed By: echristo CC: bkramer, llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1164 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189329 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo/DWARFFormValue.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo/DWARFFormValue.h b/include/llvm/DebugInfo/DWARFFormValue.h index eaaccfb..ad6f71d 100644 --- a/include/llvm/DebugInfo/DWARFFormValue.h +++ b/include/llvm/DebugInfo/DWARFFormValue.h @@ -20,7 +20,7 @@ class raw_ostream; class DWARFFormValue { public: struct ValueType { - ValueType() : data(NULL) { + ValueType() : data(NULL), IsDWOIndex(false) { uval = 0; } @@ -30,6 +30,7 @@ public: const char* cstr; }; const uint8_t* data; + bool IsDWOIndex; }; enum { @@ -63,11 +64,8 @@ public: bool resolveCompileUnitReferences(const DWARFCompileUnit* cu); uint64_t getUnsigned() const { return Value.uval; } int64_t getSigned() const { return Value.sval; } - const char *getAsCString(const DataExtractor *debug_str_data_ptr) const; - const char *getIndirectCString(const DataExtractor *, - const DataExtractor *) const; - uint64_t getIndirectAddress(const DataExtractor *, - const DWARFCompileUnit *) const; + const char *getAsCString(const DWARFCompileUnit *CU) const; + uint64_t getAsAddress(const DWARFCompileUnit *CU) const; bool skipValue(DataExtractor debug_info_data, uint32_t *offset_ptr, const DWARFCompileUnit *cu) const; static bool skipValue(uint16_t form, DataExtractor debug_info_data, -- cgit v1.1 From 9dc1842b3f7bab8304f0dd23c077c6ef3788b6f1 Mon Sep 17 00:00:00 2001 From: Joey Gouly Date: Tue, 27 Aug 2013 11:20:13 +0000 Subject: Add an assertion to the fixed-size allocator to ensure that we don't request an allocation that is greater than what we will actually allocate. Patch by Artyom Skrobov! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189340 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/RecyclingAllocator.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/RecyclingAllocator.h b/include/llvm/Support/RecyclingAllocator.h index f67503f..001d1cf 100644 --- a/include/llvm/Support/RecyclingAllocator.h +++ b/include/llvm/Support/RecyclingAllocator.h @@ -60,9 +60,10 @@ public: } template -inline void *operator new(size_t, +inline void *operator new(size_t size, llvm::RecyclingAllocator &Allocator) { + assert(size <= Size && "allocation size exceeded"); return Allocator.Allocate(); } -- cgit v1.1 From 00c198042e22d781e46180a2aec2332945712552 Mon Sep 17 00:00:00 2001 From: Shuxin Yang Date: Tue, 27 Aug 2013 17:15:54 +0000 Subject: Revert 189297, the original commit message is following. ---- Add new API lto_codegen_compile_parallel(). This API is proposed by Nick Kledzik. The semantic is: -------------------------------------------------------------------------- Generate code for merged module into an array of native object files. On success returns a pointer to an array of NativeObjectFile. The count parameter returns the number of elements in the array. Each element is a pointer/length for a generated mach-o/ELF buffer. The buffer is owned by the lto_code_gen_t and will be freed when lto_codegen_dispose() is called, or lto_codegen_compile() is called again. On failure, returns NULL (check lto_get_error_message() for details). extern const struct NativeObjectFile* lto_codegen_compile_parallel(lto_code_gen_t cg, size_t *count); --------------------------------------------------------------------------- This API is currently only called on OSX platform. Linux or other Unixes using GNU gold are not supposed to call this function, because on these systems, object files are fed back to linker via disk file instead of memory buffer. In this commit, lto_codegen_compile_parallel() simply calls lto_codegen_compile() to return a single object file. In the near future, this function is the entry point for compilation with partition. Linker can blindly call this function even if partition is turned off; in this case, compiler will return only one object file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189386 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/lto.h | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'include') diff --git a/include/llvm-c/lto.h b/include/llvm-c/lto.h index 907007c..40110fd 100644 --- a/include/llvm-c/lto.h +++ b/include/llvm-c/lto.h @@ -27,7 +27,7 @@ * @{ */ -#define LTO_API_VERSION 5 +#define LTO_API_VERSION 4 typedef enum { LTO_SYMBOL_ALIGNMENT_MASK = 0x0000001F, /* log2 of alignment */ @@ -284,22 +284,6 @@ lto_codegen_compile(lto_code_gen_t cg, size_t* length); extern bool lto_codegen_compile_to_file(lto_code_gen_t cg, const char** name); -struct NativeObjectFile { - const void *content; - size_t length; -}; - -/** - * Generates code for merged module into an array of native object files. - * On success returns a pointer to an array of NativeObjectFile. The - * count parameter returns the number of elements in the array. Each - * element is a pointer/length for a generated mach-o/ELF buffer. The - * buffer is owned by the lto_code_gen_t and will be freed when - * lto_codegen_dispose() is called, or lto_codegen_compile() is called again. - * On failure, returns NULL (check lto_get_error_message() for details). - */ -extern const struct NativeObjectFile* -lto_codegen_compile_parallel(lto_code_gen_t cg, size_t *count); /** * Sets options to help debug codegen bugs. -- cgit v1.1 From 66b7139b1be1ddce410d97499d5831231c6be267 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Tue, 27 Aug 2013 20:23:19 +0000 Subject: Given target assembler parsers a chance to handle variant expressions first. Use this to turn the PPC modifiers into PPC specific expressions, allowing them to work on constants. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189400 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCTargetAsmParser.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCTargetAsmParser.h b/include/llvm/MC/MCTargetAsmParser.h index ebcbd5b..6e96e8b 100644 --- a/include/llvm/MC/MCTargetAsmParser.h +++ b/include/llvm/MC/MCTargetAsmParser.h @@ -11,6 +11,7 @@ #define LLVM_MC_TARGETPARSER_H #include "llvm/MC/MCParser/MCAsmParserExtension.h" +#include "llvm/MC/MCExpr.h" namespace llvm { class MCStreamer; @@ -174,6 +175,12 @@ public: virtual void convertToMapAndConstraints(unsigned Kind, const SmallVectorImpl &Operands) = 0; + + virtual const MCExpr *applyModifierToExpr(const MCExpr *E, + MCSymbolRefExpr::VariantKind, + MCContext &Ctx) { + return 0; + } }; } // End llvm namespace -- cgit v1.1 From 23f84cb1406b0f26f5bd808afa1828d427a40a2f Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Tue, 27 Aug 2013 23:06:40 +0000 Subject: DIBuilder: take an optional StringRef to pass in unique identifier. createClassType, createStructType, createUnionType, createEnumerationType, and createForwardDecl will take an optional StringRef to pass in the unique identifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189410 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DIBuilder.h | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/llvm/DIBuilder.h b/include/llvm/DIBuilder.h index 941ed04..a4c4347 100644 --- a/include/llvm/DIBuilder.h +++ b/include/llvm/DIBuilder.h @@ -279,13 +279,15 @@ namespace llvm { /// DW_AT_containing_type. See DWARF documentation /// for more info. /// @param TemplateParms Template type parameters. + /// @param UniqueIdentifier A unique identifier for the class. DICompositeType createClassType(DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, DIType DerivedFrom, DIArray Elements, MDNode *VTableHolder = 0, - MDNode *TemplateParms = 0); + MDNode *TemplateParms = 0, + StringRef UniqueIdentifier = StringRef()); /// createStructType - Create debugging information entry for a struct. /// @param Scope Scope in which this struct is defined. @@ -297,12 +299,14 @@ namespace llvm { /// @param Flags Flags to encode member attribute, e.g. private /// @param Elements Struct elements. /// @param RunTimeLang Optional parameter, Objective-C runtime version. + /// @param UniqueIdentifier A unique identifier for the struct. DICompositeType createStructType(DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, DIType DerivedFrom, DIArray Elements, unsigned RunTimeLang = 0, - MDNode *VTableHolder = 0); + MDNode *VTableHolder = 0, + StringRef UniqueIdentifier = StringRef()); /// createUnionType - Create debugging information entry for an union. /// @param Scope Scope in which this union is defined. @@ -314,10 +318,12 @@ namespace llvm { /// @param Flags Flags to encode member attribute, e.g. private /// @param Elements Union elements. /// @param RunTimeLang Optional parameter, Objective-C runtime version. + /// @param UniqueIdentifier A unique identifier for the union. DICompositeType createUnionType( DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNumber, uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, - DIArray Elements, unsigned RunTimeLang = 0); + DIArray Elements, unsigned RunTimeLang = 0, + StringRef UniqueIdentifier = StringRef()); /// createTemplateTypeParameter - Create debugging information for template /// type parameter. @@ -398,12 +404,11 @@ namespace llvm { /// @param AlignInBits Member alignment. /// @param Elements Enumeration elements. /// @param UnderlyingType Underlying type of a C++11/ObjC fixed enum. + /// @param UniqueIdentifier A unique identifier for the enum. DICompositeType createEnumerationType(DIDescriptor Scope, StringRef Name, - DIFile File, unsigned LineNumber, - uint64_t SizeInBits, - uint64_t AlignInBits, - DIArray Elements, - DIType UnderlyingType); + DIFile File, unsigned LineNumber, uint64_t SizeInBits, + uint64_t AlignInBits, DIArray Elements, DIType UnderlyingType, + StringRef UniqueIdentifier = StringRef()); /// createSubroutineType - Create subroutine type. /// @param File File in which this subroutine is defined. @@ -423,7 +428,8 @@ namespace llvm { DIDescriptor Scope, DIFile F, unsigned Line, unsigned RuntimeLang = 0, uint64_t SizeInBits = 0, - uint64_t AlignInBits = 0); + uint64_t AlignInBits = 0, + StringRef UniqueIdentifier = StringRef()); /// retainType - Retain DIType in a module even if it is not referenced /// through debug info anchors. -- cgit v1.1 From 055f4e99ffb32462db6fc62f9a306f2865acacb0 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 27 Aug 2013 23:47:01 +0000 Subject: Option parsing: support case-insensitive option matching. Link.exe's command line options are case-insensitive. This patch adds a new attribute to OptTable to let the option parser to compare options, ignoring case. Command lines are generally case-insensitive on Windows. CL.exe is an exception. So this new attribute should be useful for other commands running on Windows. Differential Revision: http://llvm-reviews.chandlerc.com/D1485 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189416 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Option/OptTable.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Option/OptTable.h b/include/llvm/Option/OptTable.h index a5b59ce..5035940 100644 --- a/include/llvm/Option/OptTable.h +++ b/include/llvm/Option/OptTable.h @@ -51,6 +51,7 @@ private: /// \brief The static option information table. const Info *OptionInfos; unsigned NumOptionInfos; + bool IgnoreCase; unsigned TheInputOptionID; unsigned TheUnknownOptionID; @@ -72,7 +73,8 @@ private: } protected: - OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos); + OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos, + bool _IgnoreCase = false); public: ~OptTable(); -- cgit v1.1 From 1997734e37775a68182b3fd508a52e0c28ff36f8 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 28 Aug 2013 00:02:06 +0000 Subject: Revert "Option parsing: support case-insensitive option matching." as it broke Windows buildbot. This reverts r189416. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189424 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Option/OptTable.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/Option/OptTable.h b/include/llvm/Option/OptTable.h index 5035940..a5b59ce 100644 --- a/include/llvm/Option/OptTable.h +++ b/include/llvm/Option/OptTable.h @@ -51,7 +51,6 @@ private: /// \brief The static option information table. const Info *OptionInfos; unsigned NumOptionInfos; - bool IgnoreCase; unsigned TheInputOptionID; unsigned TheUnknownOptionID; @@ -73,8 +72,7 @@ private: } protected: - OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos, - bool _IgnoreCase = false); + OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos); public: ~OptTable(); -- cgit v1.1 From 7f9a887d3f64d1227b911c9180767d95dbba4c10 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Wed, 28 Aug 2013 01:02:21 +0000 Subject: [BumpPtrAllocator] Move DefaultSlabAllocator to a member of BumpPtrAllocator, instead of a static variable. The problem with having DefaultSlabAllocator being a global static is that it is undefined if BumpPtrAllocator will be usable during global initialization because it is not guaranteed that DefaultSlabAllocator will be initialized before BumpPtrAllocator is created and used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189433 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Allocator.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/Allocator.h b/include/llvm/Support/Allocator.h index 3243fd9..397f50f 100644 --- a/include/llvm/Support/Allocator.h +++ b/include/llvm/Support/Allocator.h @@ -99,6 +99,9 @@ class BumpPtrAllocator { /// allocate a separate slab. size_t SizeThreshold; + /// \brief the default allocator used if one is not provided + MallocSlabAllocator DefaultSlabAllocator; + /// Allocator - The underlying allocator we use to get slabs of memory. This /// defaults to MallocSlabAllocator, which wraps malloc, but it could be /// changed to use a custom allocator. @@ -133,12 +136,10 @@ class BumpPtrAllocator { /// one. void DeallocateSlabs(MemSlab *Slab); - static MallocSlabAllocator DefaultSlabAllocator; - template friend class SpecificBumpPtrAllocator; public: - BumpPtrAllocator(size_t size = 4096, size_t threshold = 4096, - SlabAllocator &allocator = DefaultSlabAllocator); + BumpPtrAllocator(size_t size = 4096, size_t threshold = 4096); + BumpPtrAllocator(size_t size, size_t threshold, SlabAllocator &allocator); ~BumpPtrAllocator(); /// Reset - Deallocate all but the current slab and reset the current pointer @@ -189,8 +190,10 @@ template class SpecificBumpPtrAllocator { BumpPtrAllocator Allocator; public: - SpecificBumpPtrAllocator(size_t size = 4096, size_t threshold = 4096, - SlabAllocator &allocator = BumpPtrAllocator::DefaultSlabAllocator) + SpecificBumpPtrAllocator(size_t size = 4096, size_t threshold = 4096) + : Allocator(size, threshold) {} + SpecificBumpPtrAllocator(size_t size, size_t threshold, + SlabAllocator &allocator) : Allocator(size, threshold, allocator) {} ~SpecificBumpPtrAllocator() { -- cgit v1.1 From 6b6345f0167fb9ddf60bdc51d616d7a9ae590442 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Wed, 28 Aug 2013 04:04:28 +0000 Subject: Remove support for the .debug_inlined section. No known software in use supports it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189439 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAsmInfo.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h index e83b624..186a8f6 100644 --- a/include/llvm/MC/MCAsmInfo.h +++ b/include/llvm/MC/MCAsmInfo.h @@ -316,10 +316,6 @@ namespace llvm { /// SupportsExceptionHandling - True if target supports exception handling. ExceptionHandling::ExceptionsType ExceptionsType; // Defaults to None - /// DwarfUsesInlineInfoSection - True if DwarfDebugInlineSection is used to - /// encode inline subroutine information. - bool DwarfUsesInlineInfoSection; // Defaults to false. - /// DwarfUsesRelocationsAcrossSections - True if Dwarf2 output generally /// uses relocations for references to other .debug_* sections. bool DwarfUsesRelocationsAcrossSections; @@ -558,9 +554,6 @@ namespace llvm { ExceptionsType == ExceptionHandling::ARM || ExceptionsType == ExceptionHandling::Win64); } - bool doesDwarfUseInlineInfoSection() const { - return DwarfUsesInlineInfoSection; - } bool doesDwarfUseRelocationsAcrossSections() const { return DwarfUsesRelocationsAcrossSections; } -- cgit v1.1 From f00539cc5a5e66ce6b7ce3779b00fd381e2d2dee Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Wed, 28 Aug 2013 10:12:09 +0000 Subject: [mips][msa] Added f[cs]af, f[cs]or, f[cs]ueq, f[cs]ul[et], f[cs]une, fsun, ftrunc_[su], hadd_[su], hsub_[su], sr[al]r, sr[al]ri git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189467 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 139 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 139 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 6f56af7..55d4c4d 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -846,6 +846,11 @@ def int_mips_fadd_w : GCCBuiltin<"__builtin_msa_fadd_w">, def int_mips_fadd_d : GCCBuiltin<"__builtin_msa_fadd_d">, Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; +def int_mips_fcaf_w : GCCBuiltin<"__builtin_msa_fcaf_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fcaf_d : GCCBuiltin<"__builtin_msa_fcaf_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + def int_mips_fceq_w : GCCBuiltin<"__builtin_msa_fceq_w">, Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; def int_mips_fceq_d : GCCBuiltin<"__builtin_msa_fceq_d">, @@ -871,11 +876,36 @@ def int_mips_fcne_w : GCCBuiltin<"__builtin_msa_fcne_w">, def int_mips_fcne_d : GCCBuiltin<"__builtin_msa_fcne_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; +def int_mips_fcor_w : GCCBuiltin<"__builtin_msa_fcor_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fcor_d : GCCBuiltin<"__builtin_msa_fcor_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fcueq_w : GCCBuiltin<"__builtin_msa_fcueq_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fcueq_d : GCCBuiltin<"__builtin_msa_fcueq_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fcule_w : GCCBuiltin<"__builtin_msa_fcule_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fcule_d : GCCBuiltin<"__builtin_msa_fcule_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fcult_w : GCCBuiltin<"__builtin_msa_fcult_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fcult_d : GCCBuiltin<"__builtin_msa_fcult_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + def int_mips_fcun_w : GCCBuiltin<"__builtin_msa_fcun_w">, Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; def int_mips_fcun_d : GCCBuiltin<"__builtin_msa_fcun_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; +def int_mips_fcune_w : GCCBuiltin<"__builtin_msa_fcune_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fcune_d : GCCBuiltin<"__builtin_msa_fcune_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + def int_mips_fdiv_w : GCCBuiltin<"__builtin_msa_fdiv_w">, Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; def int_mips_fdiv_d : GCCBuiltin<"__builtin_msa_fdiv_d">, @@ -983,6 +1013,11 @@ def int_mips_frsqrt_w : GCCBuiltin<"__builtin_msa_frsqrt_w">, def int_mips_frsqrt_d : GCCBuiltin<"__builtin_msa_frsqrt_d">, Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], []>; +def int_mips_fsaf_w : GCCBuiltin<"__builtin_msa_fsaf_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fsaf_d : GCCBuiltin<"__builtin_msa_fsaf_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + def int_mips_fseq_w : GCCBuiltin<"__builtin_msa_fseq_w">, Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; def int_mips_fseq_d : GCCBuiltin<"__builtin_msa_fseq_d">, @@ -1003,6 +1038,11 @@ def int_mips_fsne_w : GCCBuiltin<"__builtin_msa_fsne_w">, def int_mips_fsne_d : GCCBuiltin<"__builtin_msa_fsne_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; +def int_mips_fsor_w : GCCBuiltin<"__builtin_msa_fsor_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fsor_d : GCCBuiltin<"__builtin_msa_fsor_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + def int_mips_fsqrt_w : GCCBuiltin<"__builtin_msa_fsqrt_w">, Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], []>; def int_mips_fsqrt_d : GCCBuiltin<"__builtin_msa_fsqrt_d">, @@ -1013,6 +1053,31 @@ def int_mips_fsub_w : GCCBuiltin<"__builtin_msa_fsub_w">, def int_mips_fsub_d : GCCBuiltin<"__builtin_msa_fsub_d">, Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; +def int_mips_fsueq_w : GCCBuiltin<"__builtin_msa_fsueq_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fsueq_d : GCCBuiltin<"__builtin_msa_fsueq_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fsule_w : GCCBuiltin<"__builtin_msa_fsule_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fsule_d : GCCBuiltin<"__builtin_msa_fsule_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fsult_w : GCCBuiltin<"__builtin_msa_fsult_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fsult_d : GCCBuiltin<"__builtin_msa_fsult_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fsun_w : GCCBuiltin<"__builtin_msa_fsun_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fsun_d : GCCBuiltin<"__builtin_msa_fsun_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + +def int_mips_fsune_w : GCCBuiltin<"__builtin_msa_fsune_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; +def int_mips_fsune_d : GCCBuiltin<"__builtin_msa_fsune_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + def int_mips_ftint_s_w : GCCBuiltin<"__builtin_msa_ftint_s_w">, Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], []>; def int_mips_ftint_s_d : GCCBuiltin<"__builtin_msa_ftint_s_d">, @@ -1028,6 +1093,44 @@ def int_mips_ftq_h : GCCBuiltin<"__builtin_msa_ftq_h">, def int_mips_ftq_w : GCCBuiltin<"__builtin_msa_ftq_w">, Intrinsic<[llvm_v4i32_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; +def int_mips_ftrunc_s_w : GCCBuiltin<"__builtin_msa_ftrunc_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], []>; +def int_mips_ftrunc_s_d : GCCBuiltin<"__builtin_msa_ftrunc_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty], []>; + +def int_mips_ftrunc_u_w : GCCBuiltin<"__builtin_msa_ftrunc_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], []>; +def int_mips_ftrunc_u_d : GCCBuiltin<"__builtin_msa_ftrunc_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty], []>; + +def int_mips_hadd_s_h : GCCBuiltin<"__builtin_msa_hadd_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; +def int_mips_hadd_s_w : GCCBuiltin<"__builtin_msa_hadd_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; +def int_mips_hadd_s_d : GCCBuiltin<"__builtin_msa_hadd_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; + +def int_mips_hadd_u_h : GCCBuiltin<"__builtin_msa_hadd_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; +def int_mips_hadd_u_w : GCCBuiltin<"__builtin_msa_hadd_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; +def int_mips_hadd_u_d : GCCBuiltin<"__builtin_msa_hadd_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; + +def int_mips_hsub_s_h : GCCBuiltin<"__builtin_msa_hsub_s_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; +def int_mips_hsub_s_w : GCCBuiltin<"__builtin_msa_hsub_s_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; +def int_mips_hsub_s_d : GCCBuiltin<"__builtin_msa_hsub_s_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; + +def int_mips_hsub_u_h : GCCBuiltin<"__builtin_msa_hsub_u_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; +def int_mips_hsub_u_w : GCCBuiltin<"__builtin_msa_hsub_u_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; +def int_mips_hsub_u_d : GCCBuiltin<"__builtin_msa_hsub_u_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; + def int_mips_ilvev_b : GCCBuiltin<"__builtin_msa_ilvev_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_ilvev_h : GCCBuiltin<"__builtin_msa_ilvev_h">, @@ -1435,6 +1538,24 @@ def int_mips_srai_w : GCCBuiltin<"__builtin_msa_srai_w">, def int_mips_srai_d : GCCBuiltin<"__builtin_msa_srai_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; +def int_mips_srar_b : GCCBuiltin<"__builtin_msa_srar_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; +def int_mips_srar_h : GCCBuiltin<"__builtin_msa_srar_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; +def int_mips_srar_w : GCCBuiltin<"__builtin_msa_srar_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; +def int_mips_srar_d : GCCBuiltin<"__builtin_msa_srar_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; + +def int_mips_srari_b : GCCBuiltin<"__builtin_msa_srari_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; +def int_mips_srari_h : GCCBuiltin<"__builtin_msa_srari_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; +def int_mips_srari_w : GCCBuiltin<"__builtin_msa_srari_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; +def int_mips_srari_d : GCCBuiltin<"__builtin_msa_srari_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; + def int_mips_srl_b : GCCBuiltin<"__builtin_msa_srl_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_srl_h : GCCBuiltin<"__builtin_msa_srl_h">, @@ -1453,6 +1574,24 @@ def int_mips_srli_w : GCCBuiltin<"__builtin_msa_srli_w">, def int_mips_srli_d : GCCBuiltin<"__builtin_msa_srli_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; +def int_mips_srlr_b : GCCBuiltin<"__builtin_msa_srlr_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; +def int_mips_srlr_h : GCCBuiltin<"__builtin_msa_srlr_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; +def int_mips_srlr_w : GCCBuiltin<"__builtin_msa_srlr_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; +def int_mips_srlr_d : GCCBuiltin<"__builtin_msa_srlr_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; + +def int_mips_srlri_b : GCCBuiltin<"__builtin_msa_srlri_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; +def int_mips_srlri_h : GCCBuiltin<"__builtin_msa_srlri_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; +def int_mips_srlri_w : GCCBuiltin<"__builtin_msa_srlri_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; +def int_mips_srlri_d : GCCBuiltin<"__builtin_msa_srlri_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; + def int_mips_subs_s_b : GCCBuiltin<"__builtin_msa_subs_s_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; def int_mips_subs_s_h : GCCBuiltin<"__builtin_msa_subs_s_h">, -- cgit v1.1 From a6c3a4ee76ef8464d3c83472e15af521ade7eeb4 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Wed, 28 Aug 2013 10:26:24 +0000 Subject: [mips][msa] Added cfcmsa, and ctcmsa The MSA control registers have been added as reserved registers, and are only used via ISD::Copy(To|From)Reg. The intrinsics are lowered into these nodes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189468 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 55d4c4d..0bcbbd8 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -679,6 +679,9 @@ def int_mips_ceqi_w : GCCBuiltin<"__builtin_msa_ceqi_w">, def int_mips_ceqi_d : GCCBuiltin<"__builtin_msa_ceqi_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; +def int_mips_cfcmsa : GCCBuiltin<"__builtin_msa_cfcmsa">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty], []>; + def int_mips_cle_s_b : GCCBuiltin<"__builtin_msa_cle_s_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_cle_s_h : GCCBuiltin<"__builtin_msa_cle_s_h">, @@ -765,6 +768,9 @@ def int_mips_copy_u_h : GCCBuiltin<"__builtin_msa_copy_u_h">, def int_mips_copy_u_w : GCCBuiltin<"__builtin_msa_copy_u_w">, Intrinsic<[llvm_i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; +def int_mips_ctcmsa : GCCBuiltin<"__builtin_msa_ctcmsa">, + Intrinsic<[], [llvm_i32_ty, llvm_i32_ty], []>; + def int_mips_div_s_b : GCCBuiltin<"__builtin_msa_div_s_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_div_s_h : GCCBuiltin<"__builtin_msa_div_s_h">, -- cgit v1.1 From abbcf3bd47ad8ffa70f48ebd924f99fff5c22131 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Wed, 28 Aug 2013 10:44:47 +0000 Subject: [mips][msa] Added move.v git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189471 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 0bcbbd8..6e03a19 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -1344,6 +1344,9 @@ def int_mips_mod_u_w : GCCBuiltin<"__builtin_msa_mod_u_w">, def int_mips_mod_u_d : GCCBuiltin<"__builtin_msa_mod_u_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; +def int_mips_move_v : GCCBuiltin<"__builtin_msa_move_v">, + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty], [IntrNoMem]>; + def int_mips_msub_q_h : GCCBuiltin<"__builtin_msa_msub_q_h">, Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; -- cgit v1.1 From 2fd3e67dc6438cee5e32e0d7d7d42891df7edd96 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Wed, 28 Aug 2013 12:04:29 +0000 Subject: [mips][msa] Added load/store intrinsics. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189476 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 6e03a19..c8178a9 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -1200,6 +1200,32 @@ def int_mips_insve_d : GCCBuiltin<"__builtin_msa_insve_d">, [llvm_v2i64_ty, llvm_i32_ty, llvm_v2i64_ty], [IntrNoMem]>; +def int_mips_ld_b : GCCBuiltin<"__builtin_msa_ld_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; +def int_mips_ld_h : GCCBuiltin<"__builtin_msa_ld_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; +def int_mips_ld_w : GCCBuiltin<"__builtin_msa_ld_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; +def int_mips_ld_d : GCCBuiltin<"__builtin_msa_ld_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; + +def int_mips_ldx_b : GCCBuiltin<"__builtin_msa_ldx_b">, + Intrinsic<[llvm_v16i8_ty], [llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; +def int_mips_ldx_h : GCCBuiltin<"__builtin_msa_ldx_h">, + Intrinsic<[llvm_v8i16_ty], [llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; +def int_mips_ldx_w : GCCBuiltin<"__builtin_msa_ldx_w">, + Intrinsic<[llvm_v4i32_ty], [llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; +def int_mips_ldx_d : GCCBuiltin<"__builtin_msa_ldx_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; + def int_mips_ldi_b : GCCBuiltin<"__builtin_msa_ldi_b">, Intrinsic<[llvm_v16i8_ty], [llvm_i32_ty], [IntrNoMem]>; def int_mips_ldi_h : GCCBuiltin<"__builtin_msa_ldi_h">, @@ -1601,6 +1627,32 @@ def int_mips_srlri_w : GCCBuiltin<"__builtin_msa_srlri_w">, def int_mips_srlri_d : GCCBuiltin<"__builtin_msa_srlri_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; +def int_mips_st_b : GCCBuiltin<"__builtin_msa_st_b">, + Intrinsic<[], [llvm_v16i8_ty, llvm_ptr_ty, llvm_i32_ty], + [IntrReadWriteArgMem]>; +def int_mips_st_h : GCCBuiltin<"__builtin_msa_st_h">, + Intrinsic<[], [llvm_v8i16_ty, llvm_ptr_ty, llvm_i32_ty], + [IntrReadWriteArgMem]>; +def int_mips_st_w : GCCBuiltin<"__builtin_msa_st_w">, + Intrinsic<[], [llvm_v4i32_ty, llvm_ptr_ty, llvm_i32_ty], + [IntrReadWriteArgMem]>; +def int_mips_st_d : GCCBuiltin<"__builtin_msa_st_d">, + Intrinsic<[], [llvm_v2i64_ty, llvm_ptr_ty, llvm_i32_ty], + [IntrReadWriteArgMem]>; + +def int_mips_stx_b : GCCBuiltin<"__builtin_msa_stx_b">, + Intrinsic<[], [llvm_v16i8_ty, llvm_ptr_ty, llvm_i32_ty], + [IntrReadWriteArgMem]>; +def int_mips_stx_h : GCCBuiltin<"__builtin_msa_stx_h">, + Intrinsic<[], [llvm_v8i16_ty, llvm_ptr_ty, llvm_i32_ty], + [IntrReadWriteArgMem]>; +def int_mips_stx_w : GCCBuiltin<"__builtin_msa_stx_w">, + Intrinsic<[], [llvm_v4i32_ty, llvm_ptr_ty, llvm_i32_ty], + [IntrReadWriteArgMem]>; +def int_mips_stx_d : GCCBuiltin<"__builtin_msa_stx_d">, + Intrinsic<[], [llvm_v2i64_ty, llvm_ptr_ty, llvm_i32_ty], + [IntrReadWriteArgMem]>; + def int_mips_subs_s_b : GCCBuiltin<"__builtin_msa_subs_s_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; def int_mips_subs_s_h : GCCBuiltin<"__builtin_msa_subs_s_h">, -- cgit v1.1 From 3c380d5e28f86984b147fcd424736c498773f37e Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Wed, 28 Aug 2013 12:14:50 +0000 Subject: [mips][msa] Added bnz.df, bnz.v, bz.df, and bz.v These intrinsics are legalized to V(ALL|ANY)_(NON)?ZERO nodes, are matched as SN?Z_[BHWDV]_PSEUDO pseudo's, and emitted as a branch/mov sequence to evaluate to 0 or 1. Note: The resulting code is sub-optimal since it doesnt seem to be possible to feed the result of an intrinsic directly into a brcond. At the moment it uses (SETCC (VALL_ZERO $ws), 0, SETEQ) and similar which unnecessarily evaluates the boolean twice. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189478 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index c8178a9..202bc37 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -631,6 +631,18 @@ def int_mips_bnegi_w : GCCBuiltin<"__builtin_msa_bnegi_w">, def int_mips_bnegi_d : GCCBuiltin<"__builtin_msa_bnegi_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; +def int_mips_bnz_b : GCCBuiltin<"__builtin_msa_bnz_b">, + Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty], [IntrNoMem]>; +def int_mips_bnz_h : GCCBuiltin<"__builtin_msa_bnz_h">, + Intrinsic<[llvm_i32_ty], [llvm_v8i16_ty], [IntrNoMem]>; +def int_mips_bnz_w : GCCBuiltin<"__builtin_msa_bnz_w">, + Intrinsic<[llvm_i32_ty], [llvm_v4i32_ty], [IntrNoMem]>; +def int_mips_bnz_d : GCCBuiltin<"__builtin_msa_bnz_d">, + Intrinsic<[llvm_i32_ty], [llvm_v2i64_ty], [IntrNoMem]>; + +def int_mips_bnz_v : GCCBuiltin<"__builtin_msa_bnz_v">, + Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty], [IntrNoMem]>; + def int_mips_bsel_v : GCCBuiltin<"__builtin_msa_bsel_v">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; @@ -661,6 +673,18 @@ def int_mips_bseti_w : GCCBuiltin<"__builtin_msa_bseti_w">, def int_mips_bseti_d : GCCBuiltin<"__builtin_msa_bseti_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; +def int_mips_bz_b : GCCBuiltin<"__builtin_msa_bz_b">, + Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty], [IntrNoMem]>; +def int_mips_bz_h : GCCBuiltin<"__builtin_msa_bz_h">, + Intrinsic<[llvm_i32_ty], [llvm_v8i16_ty], [IntrNoMem]>; +def int_mips_bz_w : GCCBuiltin<"__builtin_msa_bz_w">, + Intrinsic<[llvm_i32_ty], [llvm_v4i32_ty], [IntrNoMem]>; +def int_mips_bz_d : GCCBuiltin<"__builtin_msa_bz_d">, + Intrinsic<[llvm_i32_ty], [llvm_v2i64_ty], [IntrNoMem]>; + +def int_mips_bz_v : GCCBuiltin<"__builtin_msa_bz_v">, + Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty], [IntrNoMem]>; + def int_mips_ceq_b : GCCBuiltin<"__builtin_msa_ceq_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_ceq_h : GCCBuiltin<"__builtin_msa_ceq_h">, -- cgit v1.1 From d3128a4a5a8531a256a224422d7da178d18459eb Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Wed, 28 Aug 2013 14:33:33 +0000 Subject: ARM: remove unused v(add|sub)hn and vqdml[as]l intrinsics. Clang is now generating cleaner IR, so this removes the old variants which should be completely unused. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189481 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsARM.td | 6 ------ 1 file changed, 6 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsARM.td b/include/llvm/IR/IntrinsicsARM.td index 3c5d5ff..e29a01b 100644 --- a/include/llvm/IR/IntrinsicsARM.td +++ b/include/llvm/IR/IntrinsicsARM.td @@ -163,7 +163,6 @@ let Properties = [IntrNoMem, Commutative] in { def int_arm_neon_vrhaddu : Neon_2Arg_Intrinsic; def int_arm_neon_vqadds : Neon_2Arg_Intrinsic; def int_arm_neon_vqaddu : Neon_2Arg_Intrinsic; - def int_arm_neon_vaddhn : Neon_2Arg_Narrow_Intrinsic; def int_arm_neon_vraddhn : Neon_2Arg_Narrow_Intrinsic; // Vector Multiply. @@ -175,10 +174,6 @@ let Properties = [IntrNoMem, Commutative] in { def int_arm_neon_vmullp : Neon_2Arg_Long_Intrinsic; def int_arm_neon_vqdmull : Neon_2Arg_Long_Intrinsic; - // Vector Multiply and Accumulate/Subtract. - def int_arm_neon_vqdmlal : Neon_3Arg_Long_Intrinsic; - def int_arm_neon_vqdmlsl : Neon_3Arg_Long_Intrinsic; - // Vector Maximum. def int_arm_neon_vmaxs : Neon_2Arg_Intrinsic; def int_arm_neon_vmaxu : Neon_2Arg_Intrinsic; @@ -201,7 +196,6 @@ def int_arm_neon_vhsubs : Neon_2Arg_Intrinsic; def int_arm_neon_vhsubu : Neon_2Arg_Intrinsic; def int_arm_neon_vqsubs : Neon_2Arg_Intrinsic; def int_arm_neon_vqsubu : Neon_2Arg_Intrinsic; -def int_arm_neon_vsubhn : Neon_2Arg_Narrow_Intrinsic; def int_arm_neon_vrsubhn : Neon_2Arg_Narrow_Intrinsic; // Vector Absolute Compare. -- cgit v1.1 From 435798e96a64738b55a01055dde1bc9a88a15191 Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Wed, 28 Aug 2013 18:33:10 +0000 Subject: Disable unrolling in the loop vectorizer when disabled in the pass manager When unrolling is disabled in the pass manager, the loop vectorizer should also not unroll loops. This will allow the -fno-unroll-loops option in Clang to behave as expected (even for vectorizable loops). The loop vectorizer's -force-vector-unroll option will (continue to) override the pass-manager setting (including -force-vector-unroll=0 to force use of the internal auto-selection logic). In order to test this, I added a flag to opt (-disable-loop-unrolling) to force disable unrolling through opt (the analog of -fno-unroll-loops in Clang). Also, this fixes a small bug in opt where the loop vectorizer was enabled only after the pass manager populated the queue of passes (the global_alias.ll test needed a slight update to the RUN line as a result of this fix). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189499 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/Vectorize.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Transforms/Vectorize.h b/include/llvm/Transforms/Vectorize.h index 8d0db16..823c5fb 100644 --- a/include/llvm/Transforms/Vectorize.h +++ b/include/llvm/Transforms/Vectorize.h @@ -114,7 +114,7 @@ createBBVectorizePass(const VectorizeConfig &C = VectorizeConfig()); // // LoopVectorize - Create a loop vectorization pass. // -Pass *createLoopVectorizePass(); +Pass *createLoopVectorizePass(bool NoUnrolling = false); //===----------------------------------------------------------------------===// // -- cgit v1.1 From 2957273b888dabe8be8e2fa5ac691e39879685c4 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 28 Aug 2013 20:04:31 +0000 Subject: Option parsing: support case-insensitive option matching. Re-submitting r189416 with fix for Windows build on where strcasecmp is not defined. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189501 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Option/OptTable.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Option/OptTable.h b/include/llvm/Option/OptTable.h index a5b59ce..5035940 100644 --- a/include/llvm/Option/OptTable.h +++ b/include/llvm/Option/OptTable.h @@ -51,6 +51,7 @@ private: /// \brief The static option information table. const Info *OptionInfos; unsigned NumOptionInfos; + bool IgnoreCase; unsigned TheInputOptionID; unsigned TheUnknownOptionID; @@ -72,7 +73,8 @@ private: } protected: - OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos); + OptTable(const Info *_OptionInfos, unsigned _NumOptionInfos, + bool _IgnoreCase = false); public: ~OptTable(); -- cgit v1.1 From c08bd51181bd9df392065baa40586aabf94fa80f Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 28 Aug 2013 23:49:30 +0000 Subject: [Object/COFF] Add coff_aux_weak_external. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189541 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/COFF.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h index 2190067..cb464ab 100644 --- a/include/llvm/Object/COFF.h +++ b/include/llvm/Object/COFF.h @@ -184,6 +184,12 @@ struct coff_relocation { support::ulittle16_t Type; }; +struct coff_aux_weak_external { + support::ulittle32_t TagIndex; + support::ulittle32_t Characteristics; + char Unused[10]; +}; + struct coff_aux_section_definition { support::ulittle32_t Length; support::ulittle16_t NumberOfRelocations; -- cgit v1.1 From 738073c4aa474e27c9d3c991daf593bddce54718 Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Thu, 29 Aug 2013 03:25:05 +0000 Subject: Add useAA() to TargetSubtargetInfo There are several optional (off-by-default) features in CodeGen that can make use of alias analysis. These features are important for generating code for some kinds of cores (for example the (in-order) PPC A2 core). This adds a useAA() function to TargetSubtargetInfo to allow these features to be enabled by default on a per-subtarget basis. Here is the first use of this function: To control the default of the -enable-aa-sched-mi feature. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189563 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetSubtargetInfo.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/llvm/Target/TargetSubtargetInfo.h b/include/llvm/Target/TargetSubtargetInfo.h index b2d405d..2092aba 100644 --- a/include/llvm/Target/TargetSubtargetInfo.h +++ b/include/llvm/Target/TargetSubtargetInfo.h @@ -75,6 +75,10 @@ public: virtual void adjustSchedDependency(SUnit *def, SUnit *use, SDep& dep) const { } + /// \brief Enable use of alias analysis during code generation (during MI + /// scheduling, DAGCombine, etc.). + virtual bool useAA() const; + /// \brief Reset the features for the subtarget. virtual void resetSubtargetFeatures(const MachineFunction *MF) { } }; -- cgit v1.1 From 32f258b96a723b771eb44a2c0689b8bf4dd871ee Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Thu, 29 Aug 2013 03:29:57 +0000 Subject: Add getUnrollingPreferences to TTI Allow targets to customize the default behavior of the generic loop unrolling transformation. This will be used by the PowerPC backend when targeting the A2 core (which is in-order with a deep pipeline), and using more aggressive defaults is important. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189565 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/TargetTransformInfo.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include') diff --git a/include/llvm/Analysis/TargetTransformInfo.h b/include/llvm/Analysis/TargetTransformInfo.h index 06810a7..908612c 100644 --- a/include/llvm/Analysis/TargetTransformInfo.h +++ b/include/llvm/Analysis/TargetTransformInfo.h @@ -191,6 +191,20 @@ public: /// incurs significant execution cost. virtual bool isLoweredToCall(const Function *F) const; + /// Parameters that control the generic loop unrolling transformation. + struct UnrollingPreferences { + unsigned Threshold; ///< The cost threshold for the unrolled loop. + unsigned OptSizeThreshold; ///< The cost threshold for the unrolled loop + ///< when optimizing for size. + bool Partial; ///< Allow partial loop unrolling. + bool Runtime; ///< Perform runtime unrolling. + }; + + /// \brief Get target-customized preferences for the generic loop unrolling + /// transformation. Returns true if the UnrollingPreferences struct has been + /// initialized. + virtual bool getUnrollingPreferences(UnrollingPreferences &UP) const; + /// @} /// \name Scalar Target Information -- cgit v1.1 From f208398528efde82bc49f48d0fef0587c1f192bb Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Thu, 29 Aug 2013 03:33:15 +0000 Subject: Revert: r189565 - Add getUnrollingPreferences to TTI Revert unintentional commit (of an unreviewed change). Original commit message: Add getUnrollingPreferences to TTI Allow targets to customize the default behavior of the generic loop unrolling transformation. This will be used by the PowerPC backend when targeting the A2 core (which is in-order with a deep pipeline), and using more aggressive defaults is important. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189566 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/TargetTransformInfo.h | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'include') diff --git a/include/llvm/Analysis/TargetTransformInfo.h b/include/llvm/Analysis/TargetTransformInfo.h index 908612c..06810a7 100644 --- a/include/llvm/Analysis/TargetTransformInfo.h +++ b/include/llvm/Analysis/TargetTransformInfo.h @@ -191,20 +191,6 @@ public: /// incurs significant execution cost. virtual bool isLoweredToCall(const Function *F) const; - /// Parameters that control the generic loop unrolling transformation. - struct UnrollingPreferences { - unsigned Threshold; ///< The cost threshold for the unrolled loop. - unsigned OptSizeThreshold; ///< The cost threshold for the unrolled loop - ///< when optimizing for size. - bool Partial; ///< Allow partial loop unrolling. - bool Runtime; ///< Perform runtime unrolling. - }; - - /// \brief Get target-customized preferences for the generic loop unrolling - /// transformation. Returns true if the UnrollingPreferences struct has been - /// initialized. - virtual bool getUnrollingPreferences(UnrollingPreferences &UP) const; - /// @} /// \name Scalar Target Information -- cgit v1.1 From aae60d1dc417dffb1b2486c8e7ca546cf3777901 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 29 Aug 2013 05:09:55 +0000 Subject: Move StringToOffsetTable into the TableGen include directory so I can use it in clang. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189567 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/TableGen/StringToOffsetTable.h | 83 +++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 include/llvm/TableGen/StringToOffsetTable.h (limited to 'include') diff --git a/include/llvm/TableGen/StringToOffsetTable.h b/include/llvm/TableGen/StringToOffsetTable.h new file mode 100644 index 0000000..d94d3a2 --- /dev/null +++ b/include/llvm/TableGen/StringToOffsetTable.h @@ -0,0 +1,83 @@ +//===- StringToOffsetTable.h - Emit a big concatenated string ---*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef TBLGEN_STRING_TO_OFFSET_TABLE_H +#define TBLGEN_STRING_TO_OFFSET_TABLE_H + +#include "llvm/ADT/SmallString.h" +#include "llvm/ADT/StringExtras.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/Support/raw_ostream.h" +#include + +namespace llvm { + +/// StringToOffsetTable - This class uniques a bunch of nul-terminated strings +/// and keeps track of their offset in a massive contiguous string allocation. +/// It can then output this string blob and use indexes into the string to +/// reference each piece. +class StringToOffsetTable { + StringMap StringOffset; + std::string AggregateString; +public: + + unsigned GetOrAddStringOffset(StringRef Str, bool appendZero = true) { + StringMapEntry &Entry = StringOffset.GetOrCreateValue(Str, -1U); + if (Entry.getValue() == -1U) { + // Add the string to the aggregate if this is the first time found. + Entry.setValue(AggregateString.size()); + AggregateString.append(Str.begin(), Str.end()); + if (appendZero) + AggregateString += '\0'; + } + + return Entry.getValue(); + } + + void EmitString(raw_ostream &O) { + // Escape the string. + SmallString<256> Str; + raw_svector_ostream(Str).write_escaped(AggregateString); + AggregateString = Str.str(); + + O << " \""; + unsigned CharsPrinted = 0; + for (unsigned i = 0, e = AggregateString.size(); i != e; ++i) { + if (CharsPrinted > 70) { + O << "\"\n \""; + CharsPrinted = 0; + } + O << AggregateString[i]; + ++CharsPrinted; + + // Print escape sequences all together. + if (AggregateString[i] != '\\') + continue; + + assert(i+1 < AggregateString.size() && "Incomplete escape sequence!"); + if (isdigit(AggregateString[i+1])) { + assert(isdigit(AggregateString[i+2]) && + isdigit(AggregateString[i+3]) && + "Expected 3 digit octal escape!"); + O << AggregateString[++i]; + O << AggregateString[++i]; + O << AggregateString[++i]; + CharsPrinted += 3; + } else { + O << AggregateString[++i]; + ++CharsPrinted; + } + } + O << "\""; + } +}; + +} // end namespace llvm + +#endif -- cgit v1.1 From 2f02ded68a114410f11bc2f4e901d0d8e5850de1 Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Thu, 29 Aug 2013 12:12:13 +0000 Subject: isCharInSet refactoring. Summary: Made UnicodeCharSet a class, perform validity checking inside its constructor instead of each isCharInSet call, use std::binary_search instead of own implementation. This patch comes with a necessary change in clang (sent separately). Reviewers: jordan_rose, klimek Reviewed By: klimek CC: cfe-commits, rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D1534 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189582 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/ArrayRef.h | 2 +- include/llvm/Support/UnicodeCharRanges.h | 123 ++++++++++++++++--------------- 2 files changed, 63 insertions(+), 62 deletions(-) (limited to 'include') diff --git a/include/llvm/ADT/ArrayRef.h b/include/llvm/ADT/ArrayRef.h index d4152ec..a0b6eff 100644 --- a/include/llvm/ADT/ArrayRef.h +++ b/include/llvm/ADT/ArrayRef.h @@ -80,7 +80,7 @@ namespace llvm { /// Construct an ArrayRef from a C array. template - /*implicit*/ ArrayRef(const T (&Arr)[N]) + /*implicit*/ LLVM_CONSTEXPR ArrayRef(const T (&Arr)[N]) : Data(Arr), Length(N) {} /// @} diff --git a/include/llvm/Support/UnicodeCharRanges.h b/include/llvm/Support/UnicodeCharRanges.h index 4a4d988..c007571 100644 --- a/include/llvm/Support/UnicodeCharRanges.h +++ b/include/llvm/Support/UnicodeCharRanges.h @@ -17,82 +17,83 @@ #include "llvm/Support/MutexGuard.h" #include "llvm/Support/raw_ostream.h" -namespace { +#include +namespace llvm { +namespace sys { + +/// \brief Represents a closed range of Unicode code points [Lower, Upper]. struct UnicodeCharRange { uint32_t Lower; uint32_t Upper; }; -typedef llvm::ArrayRef UnicodeCharSet; -/// Returns true if each of the ranges in \p CharSet is a proper closed range -/// [min, max], and if the ranges themselves are ordered and non-overlapping. -static inline bool isValidCharSet(UnicodeCharSet CharSet) { -#ifndef NDEBUG - static llvm::SmallPtrSet Validated; - static llvm::sys::Mutex ValidationMutex; +inline bool operator<(uint32_t Value, UnicodeCharRange Range) { + return Value < Range.Lower; +} +inline bool operator<(UnicodeCharRange Range, uint32_t Value) { + return Range.Upper < Value; +} - // Check the validation cache. - { - llvm::MutexGuard Guard(ValidationMutex); - if (Validated.count(CharSet.data())) - return true; - } +/// \brief Holds a reference to an ordered array of UnicodeCharRange and allows +/// to quickly check if a code point is contained in the set represented by this +/// array. +class UnicodeCharSet { +public: + typedef llvm::ArrayRef CharRanges; - // Walk through the ranges. - uint32_t Prev = 0; - for (UnicodeCharSet::iterator I = CharSet.begin(), E = CharSet.end(); - I != E; ++I) { - if (I != CharSet.begin() && Prev >= I->Lower) { - DEBUG(llvm::dbgs() << "Upper bound 0x"); - DEBUG(llvm::dbgs().write_hex(Prev)); - DEBUG(llvm::dbgs() << " should be less than succeeding lower bound 0x"); - DEBUG(llvm::dbgs().write_hex(I->Lower) << "\n"); - return false; - } - if (I->Upper < I->Lower) { - DEBUG(llvm::dbgs() << "Upper bound 0x"); - DEBUG(llvm::dbgs().write_hex(I->Lower)); - DEBUG(llvm::dbgs() << " should not be less than lower bound 0x"); - DEBUG(llvm::dbgs().write_hex(I->Upper) << "\n"); - return false; - } - Prev = I->Upper; + /// \brief Constructs a UnicodeCharSet instance from an array of + /// UnicodeCharRanges. + /// + /// Array pointed by \p Ranges should have the lifetime at least as long as + /// the UnicodeCharSet instance, and should not change. Array is validated by + /// the constructor, so it makes sense to create as few UnicodeCharSet + /// instances per each array of ranges, as possible. +#ifdef NDEBUG + LLVM_CONSTEXPR +#endif + UnicodeCharSet(CharRanges Ranges) : Ranges(Ranges) { + assert(rangesAreValid()); } - // Update the validation cache. - { - llvm::MutexGuard Guard(ValidationMutex); - Validated.insert(CharSet.data()); + /// \brief Returns true if the character set contains the Unicode code point + /// \p C. + bool contains(uint32_t C) const { + return std::binary_search(Ranges.begin(), Ranges.end(), C); } -#endif - return true; -} - -} // namespace +private: + /// \brief Returns true if each of the ranges is a proper closed range + /// [min, max], and if the ranges themselves are ordered and non-overlapping. + bool rangesAreValid() const { + uint32_t Prev = 0; + for (CharRanges::const_iterator I = Ranges.begin(), E = Ranges.end(); + I != E; ++I) { + if (I != Ranges.begin() && Prev >= I->Lower) { + DEBUG(llvm::dbgs() << "Upper bound 0x"); + DEBUG(llvm::dbgs().write_hex(Prev)); + DEBUG(llvm::dbgs() << " should be less than succeeding lower bound 0x"); + DEBUG(llvm::dbgs().write_hex(I->Lower) << "\n"); + return false; + } + if (I->Upper < I->Lower) { + DEBUG(llvm::dbgs() << "Upper bound 0x"); + DEBUG(llvm::dbgs().write_hex(I->Lower)); + DEBUG(llvm::dbgs() << " should not be less than lower bound 0x"); + DEBUG(llvm::dbgs().write_hex(I->Upper) << "\n"); + return false; + } + Prev = I->Upper; + } -/// Returns true if the Unicode code point \p C is within the set of -/// characters specified by \p CharSet. -LLVM_READONLY static inline bool isCharInSet(uint32_t C, - UnicodeCharSet CharSet) { - assert(isValidCharSet(CharSet)); + return true; + } - size_t LowPoint = 0; - size_t HighPoint = CharSet.size(); + const CharRanges Ranges; +}; - // Binary search the set of char ranges. - while (HighPoint != LowPoint) { - size_t MidPoint = (HighPoint + LowPoint) / 2; - if (C < CharSet[MidPoint].Lower) - HighPoint = MidPoint; - else if (C > CharSet[MidPoint].Upper) - LowPoint = MidPoint + 1; - else - return true; - } +} // namespace sys +} // namespace llvm - return false; -} #endif // LLVM_SUPPORT_UNICODECHARRANGES_H -- cgit v1.1 From 851bb2c9cbbd3b1847def5ca7ea8dadf457298b5 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Thu, 29 Aug 2013 18:04:49 +0000 Subject: Comment and revise the cyclic critical path code. This should be much more clear now. It's still disabled pending testing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189597 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineScheduler.h | 3 +++ include/llvm/CodeGen/ScheduleDAGInstrs.h | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineScheduler.h b/include/llvm/CodeGen/MachineScheduler.h index 2749a19..3182440 100644 --- a/include/llvm/CodeGen/MachineScheduler.h +++ b/include/llvm/CodeGen/MachineScheduler.h @@ -331,6 +331,9 @@ public: BitVector &getScheduledTrees() { return ScheduledTrees; } + /// Compute the cyclic critical path through the DAG. + unsigned computeCyclicCriticalPath(); + void viewGraph(const Twine &Name, const Twine &Title) LLVM_OVERRIDE; void viewGraph() LLVM_OVERRIDE; diff --git a/include/llvm/CodeGen/ScheduleDAGInstrs.h b/include/llvm/CodeGen/ScheduleDAGInstrs.h index 1b81314..4a447e2 100644 --- a/include/llvm/CodeGen/ScheduleDAGInstrs.h +++ b/include/llvm/CodeGen/ScheduleDAGInstrs.h @@ -197,9 +197,6 @@ namespace llvm { /// input. void buildSchedGraph(AliasAnalysis *AA, RegPressureTracker *RPTracker = 0); - /// Compute the cyclic critical path through the DAG. - unsigned computeCyclicCriticalPath(); - /// addSchedBarrierDeps - Add dependencies from instructions in the current /// list of instructions being scheduled to scheduling barrier. We want to /// make sure instructions which define registers that are either used by -- cgit v1.1 From 9071f68fd2b18abaee614e07ae6da6d8bc34426e Mon Sep 17 00:00:00 2001 From: Kaelyn Uhrain Date: Thu, 29 Aug 2013 18:49:35 +0000 Subject: Fix the following error when NDEBUG is defined: include/llvm/Support/UnicodeCharRanges.h:56:5: error: use of this statement in a constexpr constructor is a C++1y extension [-Werror,-Wc++1y-extensions] assert(rangesAreValid()); ^ git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189599 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/UnicodeCharRanges.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/UnicodeCharRanges.h b/include/llvm/Support/UnicodeCharRanges.h index c007571..86faa38 100644 --- a/include/llvm/Support/UnicodeCharRanges.h +++ b/include/llvm/Support/UnicodeCharRanges.h @@ -49,9 +49,6 @@ public: /// the UnicodeCharSet instance, and should not change. Array is validated by /// the constructor, so it makes sense to create as few UnicodeCharSet /// instances per each array of ranges, as possible. -#ifdef NDEBUG - LLVM_CONSTEXPR -#endif UnicodeCharSet(CharRanges Ranges) : Ranges(Ranges) { assert(rangesAreValid()); } -- cgit v1.1 From 441c557708b5dbe91f1799baf790ad418c23ea70 Mon Sep 17 00:00:00 2001 From: Cameron Esfahani Date: Thu, 29 Aug 2013 20:23:14 +0000 Subject: Clean up some usage of Triple. The base class has methods for determining if the target is iOS and Linux. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189604 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/Triple.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index 4b53ad2..3fccf41 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -323,7 +323,7 @@ public: return getOS() == Triple::Win32 || getOS() == Triple::MinGW32; } - /// isOSWindows - Is this a "Windows" OS. + /// \brief Tests whether the OS is Windows. bool isOSWindows() const { return getOS() == Triple::Win32 || isOSCygMing(); } @@ -333,6 +333,11 @@ public: return getOS() == Triple::NaCl; } + /// \brief Tests whether the OS is Linux. + bool isOSLinux() const { + return getOS() == Triple::Linux; + } + /// \brief Tests whether the OS uses the ELF binary format. bool isOSBinFormatELF() const { return !isOSDarwin() && !isOSWindows(); -- cgit v1.1 From 3a0e9b50f3a9031217a8fe209398ec37c54774eb Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Thu, 29 Aug 2013 23:17:54 +0000 Subject: DIBuilder: retain a type when created with a unique identifier. createClassType, createStructType, createUnionType, createEnumerationType, and createForwardDecl will retain a type when created with a unique identifier, to make sure they are treated as used even when all uses are replaced with the identifiers. Use TrackingVH instead of MDNode in AllRetainTypes, since the created node can later be updated. The change will be tested when clients of DIBuilder start to pass in non-empty unique identifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189621 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DIBuilder.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/DIBuilder.h b/include/llvm/DIBuilder.h index a4c4347..d4dfadc 100644 --- a/include/llvm/DIBuilder.h +++ b/include/llvm/DIBuilder.h @@ -18,6 +18,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/ValueHandle.h" namespace llvm { class BasicBlock; @@ -65,7 +66,9 @@ namespace llvm { Function *ValueFn; // llvm.dbg.value SmallVector AllEnumTypes; - SmallVector AllRetainTypes; + /// Use TrackingVH to collect RetainTypes, since they can be updated + /// later on. + SmallVector, 4> AllRetainTypes; SmallVector AllSubprograms; SmallVector AllGVs; SmallVector AllImportedModules; -- cgit v1.1 From 4c60b8a78d811a5b16ae45f6957933fb479bab58 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Fri, 30 Aug 2013 03:49:48 +0000 Subject: mi-sched: Precompute a PressureDiff for each instruction, adjust for liveness later. Created SUPressureDiffs array to hold the per node PDiff computed during DAG building. Added a getUpwardPressureDelta API that will soon replace the old one. Compute PressureDelta here from the precomputed PressureDiffs. Updating for liveness will come next. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189640 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineScheduler.h | 13 +++- include/llvm/CodeGen/RegisterPressure.h | 123 +++++++++++++++++++++++++------ include/llvm/CodeGen/ScheduleDAGInstrs.h | 4 +- 3 files changed, 115 insertions(+), 25 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineScheduler.h b/include/llvm/CodeGen/MachineScheduler.h index 3182440..8f307f9 100644 --- a/include/llvm/CodeGen/MachineScheduler.h +++ b/include/llvm/CodeGen/MachineScheduler.h @@ -221,14 +221,17 @@ protected: MachineBasicBlock::iterator LiveRegionEnd; - /// Register pressure in this region computed by buildSchedGraph. + // Map each SU to its summary of pressure changes. + PressureDiffs SUPressureDiffs; + + /// Register pressure in this region computed by initRegPressure. IntervalPressure RegPressure; RegPressureTracker RPTracker; /// List of pressure sets that exceed the target's pressure limit before /// scheduling, listed in increasing set ID order. Each pressure set is paired /// with its max pressure in the currently scheduled regions. - std::vector RegionCriticalPSets; + std::vector RegionCriticalPSets; /// The top of the unscheduled zone. MachineBasicBlock::iterator CurrentTop; @@ -314,10 +317,14 @@ public: /// Get register pressure for the entire scheduling region before scheduling. const IntervalPressure &getRegPressure() const { return RegPressure; } - const std::vector &getRegionCriticalPSets() const { + const std::vector &getRegionCriticalPSets() const { return RegionCriticalPSets; } + PressureDiff &getPressureDiff(const SUnit *SU) { + return SUPressureDiffs[SU->NodeNum]; + } + const SUnit *getNextClusterPred() const { return NextClusterPred; } const SUnit *getNextClusterSucc() const { return NextClusterSucc; } diff --git a/include/llvm/CodeGen/RegisterPressure.h b/include/llvm/CodeGen/RegisterPressure.h index 8a0a8f3..b271f7f 100644 --- a/include/llvm/CodeGen/RegisterPressure.h +++ b/include/llvm/CodeGen/RegisterPressure.h @@ -89,20 +89,85 @@ struct RegionPressure : RegisterPressure { void openBottom(MachineBasicBlock::const_iterator PrevBottom); }; -/// An element of pressure difference that identifies the pressure set and -/// amount of increase or decrease in units of pressure. -struct PressureElement { - unsigned PSetID; - int UnitIncrease; +/// Capture a change in pressure for a single pressure set. UnitInc may be +/// expressed in terms of upward or downward pressure depending on the client +/// and will be dynamically adjusted for current liveness. +/// +/// Pressure increments are tiny, typically 1-2 units, and this is only for +/// heuristics, so we don't check UnitInc overflow. Instead, we may have a +/// higher level assert that pressure is consistent within a region. We also +/// effectively ignore dead defs which don't affect heuristics much. +class PressureChange { + uint16_t PSetID; // ID+1. 0=Invalid. + int16_t UnitInc; +public: + PressureChange(): PSetID(0), UnitInc(0) {} + PressureChange(unsigned id): PSetID(id+1), UnitInc(0) { + assert(id < UINT16_MAX && "PSetID overflow."); + } + + bool isValid() const { return PSetID > 0; } + + unsigned getPSet() const { + assert(isValid() && "invalid PressureChange"); + return PSetID - 1; + } + + int getUnitInc() const { return UnitInc; } + + void setUnitInc(int Inc) { UnitInc = Inc; } + + // If PSetID is invalid, convert to INT_MAX to give it lowest priority. + int getRank() const { return (PSetID - 1) & INT_MAX; } + + bool operator==(const PressureChange &RHS) const { + return PSetID == RHS.PSetID && UnitInc == RHS.UnitInc; + } +}; + +template <> struct isPodLike { + static const bool value = true; +}; + +/// List of PressureChanges in order of increasing, unique PSetID. +/// +/// Use a small fixed number, because we can fit more PressureChanges in an +/// empty SmallVector than ever need to be tracked per register class. If more +/// PSets are affected, then we only track the most constrained. +class PressureDiff { + // The initial design was for MaxPSets=4, but that requires PSet partitions, + // which are not yet implemented. (PSet partitions are equivalent PSets given + // the register classes actually in use within the scheduling region.) + enum { MaxPSets = 16 }; + + PressureChange PressureChanges[MaxPSets]; +public: + typedef PressureChange* iterator; + typedef const PressureChange* const_iterator; + iterator begin() { return &PressureChanges[0]; } + iterator end() { return &PressureChanges[MaxPSets]; } - PressureElement(): PSetID(~0U), UnitIncrease(0) {} - PressureElement(unsigned id, int inc): PSetID(id), UnitIncrease(inc) {} + void addPressureChange(unsigned RegUnit, bool IsDec, + const MachineRegisterInfo *MRI); +}; + +/// Array of PressureDiffs. +class PressureDiffs { + PressureDiff *PDiffArray; + unsigned Size; + unsigned Max; +public: + PressureDiffs(): PDiffArray(0), Size(0), Max(0) {} - bool isValid() const { return PSetID != ~0U; } + void init(unsigned N); - // If signed PSetID is negative, it is invalid; convert it to INT_MAX to give - // it lowest priority. - int PSetRank() const { return PSetID & INT_MAX; } + PressureDiff &operator[](unsigned Idx) { + assert(Idx < Size && "PressureDiff index out of bounds"); + return PDiffArray[Idx]; + } + const PressureDiff &operator[](unsigned Idx) const { + return const_cast(this)->operator[](Idx); + } }; /// Store the effects of a change in pressure on things that MI scheduler cares @@ -120,11 +185,19 @@ struct PressureElement { /// CurrentMax records the largest increase in the tracker's max pressure that /// exceeds the current limit for some pressure set determined by the client. struct RegPressureDelta { - PressureElement Excess; - PressureElement CriticalMax; - PressureElement CurrentMax; + PressureChange Excess; + PressureChange CriticalMax; + PressureChange CurrentMax; RegPressureDelta() {} + + bool operator==(const RegPressureDelta &RHS) const { + return Excess == RHS.Excess && CriticalMax == RHS.CriticalMax + && CurrentMax == RHS.CurrentMax; + } + bool operator!=(const RegPressureDelta &RHS) const { + return !operator==(RHS); + } }; /// \brief A set of live virtual registers and physical register units. @@ -135,7 +208,7 @@ struct LiveRegSet { SparseSet PhysRegs; SparseSet VirtRegs; - bool contains(unsigned Reg) { + bool contains(unsigned Reg) const { if (TargetRegisterInfo::isVirtualRegister(Reg)) return VirtRegs.count(Reg); return PhysRegs.count(Reg); @@ -239,7 +312,7 @@ public: SlotIndex getCurrSlot() const; /// Recede across the previous instruction. - bool recede(); + bool recede(PressureDiff *PDiff = 0); /// Advance across the current instruction. bool advance(); @@ -282,31 +355,39 @@ public: /// limit based on the tracker's current pressure, and record the number of /// excess register units of that pressure set introduced by this instruction. void getMaxUpwardPressureDelta(const MachineInstr *MI, + PressureDiff *PDiff, RegPressureDelta &Delta, - ArrayRef CriticalPSets, + ArrayRef CriticalPSets, ArrayRef MaxPressureLimit); + void getUpwardPressureDelta(const MachineInstr *MI, + /*const*/ PressureDiff &PDiff, + RegPressureDelta &Delta, + ArrayRef CriticalPSets, + ArrayRef MaxPressureLimit) const; + /// Consider the pressure increase caused by traversing this instruction /// top-down. Find the pressure set with the most change beyond its pressure /// limit based on the tracker's current pressure, and record the number of /// excess register units of that pressure set introduced by this instruction. void getMaxDownwardPressureDelta(const MachineInstr *MI, RegPressureDelta &Delta, - ArrayRef CriticalPSets, + ArrayRef CriticalPSets, ArrayRef MaxPressureLimit); /// Find the pressure set with the most change beyond its pressure limit after /// traversing this instruction either upward or downward depending on the /// closed end of the current region. - void getMaxPressureDelta(const MachineInstr *MI, RegPressureDelta &Delta, - ArrayRef CriticalPSets, + void getMaxPressureDelta(const MachineInstr *MI, + RegPressureDelta &Delta, + ArrayRef CriticalPSets, ArrayRef MaxPressureLimit) { if (isTopClosed()) return getMaxDownwardPressureDelta(MI, Delta, CriticalPSets, MaxPressureLimit); assert(isBottomClosed() && "Uninitialized pressure tracker"); - return getMaxUpwardPressureDelta(MI, Delta, CriticalPSets, + return getMaxUpwardPressureDelta(MI, 0, Delta, CriticalPSets, MaxPressureLimit); } diff --git a/include/llvm/CodeGen/ScheduleDAGInstrs.h b/include/llvm/CodeGen/ScheduleDAGInstrs.h index 4a447e2..999f2d3 100644 --- a/include/llvm/CodeGen/ScheduleDAGInstrs.h +++ b/include/llvm/CodeGen/ScheduleDAGInstrs.h @@ -28,6 +28,7 @@ namespace llvm { class MachineDominatorTree; class LiveIntervals; class RegPressureTracker; + class PressureDiffs; /// An individual mapping from virtual register number to SUnit. struct VReg2SUnit { @@ -195,7 +196,8 @@ namespace llvm { /// buildSchedGraph - Build SUnits from the MachineBasicBlock that we are /// input. - void buildSchedGraph(AliasAnalysis *AA, RegPressureTracker *RPTracker = 0); + void buildSchedGraph(AliasAnalysis *AA, RegPressureTracker *RPTracker = 0, + PressureDiffs *PDiffs = 0); /// addSchedBarrierDeps - Add dependencies from instructions in the current /// list of instructions being scheduled to scheduling barrier. We want to -- cgit v1.1 From da6fc15f0fb26ebbe42ab96e0d066bbd5bdbb72e Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Fri, 30 Aug 2013 04:27:29 +0000 Subject: mi-sched: improve the generic register pressure comparison. Only compare pressure within the same set. When multiple sets are affected, we prioritize the most constrained set. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189641 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/RegisterPressure.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/RegisterPressure.h b/include/llvm/CodeGen/RegisterPressure.h index b271f7f..68f2ac2 100644 --- a/include/llvm/CodeGen/RegisterPressure.h +++ b/include/llvm/CodeGen/RegisterPressure.h @@ -112,14 +112,13 @@ public: assert(isValid() && "invalid PressureChange"); return PSetID - 1; } + // If PSetID is invalid, return UINT16_MAX to give it lowest priority. + unsigned getPSetOrMax() const { return (PSetID - 1) & UINT16_MAX; } int getUnitInc() const { return UnitInc; } void setUnitInc(int Inc) { UnitInc = Inc; } - // If PSetID is invalid, convert to INT_MAX to give it lowest priority. - int getRank() const { return (PSetID - 1) & INT_MAX; } - bool operator==(const PressureChange &RHS) const { return PSetID == RHS.PSetID && UnitInc == RHS.UnitInc; } -- cgit v1.1 From 1362dcb5899bc88f0e567dd10e2e9003a79ace21 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Fri, 30 Aug 2013 04:31:01 +0000 Subject: Replace LiveInterval::killedAt with isKilledAtInstr. Return true for LRGs that end at EarlyClobber or Register slots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189642 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveInterval.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index 6361c35..058f95e 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -287,12 +287,13 @@ namespace llvm { return r != end() && r->start <= index; } - /// killedAt - Return true if a live range ends at index. Note that the kill - /// point is not contained in the half-open live range. It is usually the - /// getDefIndex() slot following its last use. - bool killedAt(SlotIndex index) const { - const_iterator r = find(index.getRegSlot(true)); - return r != end() && r->end == index; + /// Return true if a live range ends at the instruction at this index. Note + /// that the kill point is not contained in the half-open live range. It is + /// usually the EarlyClobber or Register slot following its last use. + bool isKilledAtInstr(SlotIndex index) const { + SlotIndex BaseIdx = index.getBaseIndex(); + const_iterator r = find(BaseIdx); + return r != end() && r->end.getBaseIndex() == BaseIdx; } /// getLiveRangeContaining - Return the live range that contains the -- cgit v1.1 From 663bd9922776e5f7bc17dfc574efe3fe05ceb12c Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Fri, 30 Aug 2013 04:36:57 +0000 Subject: mi-sched: update PressureDiffs on-the-fly for liveness. This removes all expensive pressure tracking logic from the scheduling critical path of node comparison. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189643 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveInterval.h | 6 ++++++ include/llvm/CodeGen/MachineScheduler.h | 6 +++++- include/llvm/CodeGen/RegisterPressure.h | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index 058f95e..38d07e4 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -296,6 +296,12 @@ namespace llvm { return r != end() && r->end.getBaseIndex() == BaseIdx; } + /// Return true if a live range starts at the instruction at this index. + bool isDefinedByInstr(SlotIndex index) const { + const_iterator r = find(index.getDeadSlot()); + return r != end() && r->end.getBaseIndex() == index.getBaseIndex(); + } + /// getLiveRangeContaining - Return the live range that contains the /// specified index, or null if there is none. const LiveRange *getLiveRangeContaining(SlotIndex Idx) const { diff --git a/include/llvm/CodeGen/MachineScheduler.h b/include/llvm/CodeGen/MachineScheduler.h index 8f307f9..69c648c 100644 --- a/include/llvm/CodeGen/MachineScheduler.h +++ b/include/llvm/CodeGen/MachineScheduler.h @@ -221,7 +221,9 @@ protected: MachineBasicBlock::iterator LiveRegionEnd; - // Map each SU to its summary of pressure changes. + // Map each SU to its summary of pressure changes. This array is updated for + // liveness during bottom-up scheduling. Top-down scheduling may proceed but + // has no affect on the pressure diffs. PressureDiffs SUPressureDiffs; /// Register pressure in this region computed by initRegPressure. @@ -376,6 +378,8 @@ protected: void initRegPressure(); + void updatePressureDiffs(ArrayRef LiveUses); + void updateScheduledPressure(const std::vector &NewMaxPressure); bool checkSchedLimit(); diff --git a/include/llvm/CodeGen/RegisterPressure.h b/include/llvm/CodeGen/RegisterPressure.h index 68f2ac2..e01e4ec 100644 --- a/include/llvm/CodeGen/RegisterPressure.h +++ b/include/llvm/CodeGen/RegisterPressure.h @@ -311,7 +311,7 @@ public: SlotIndex getCurrSlot() const; /// Recede across the previous instruction. - bool recede(PressureDiff *PDiff = 0); + bool recede(SmallVectorImpl *LiveUses = 0, PressureDiff *PDiff = 0); /// Advance across the current instruction. bool advance(); -- cgit v1.1 From 846b31d74aa673a178f57f9d47f366d8ddb756d3 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Fri, 30 Aug 2013 17:58:49 +0000 Subject: Use LiveRangeQuery for instruction-level liveness queries. Remove redundant or bug-prone LiveInterval APIs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189685 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveInterval.h | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index 38d07e4..84323de 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -287,21 +287,6 @@ namespace llvm { return r != end() && r->start <= index; } - /// Return true if a live range ends at the instruction at this index. Note - /// that the kill point is not contained in the half-open live range. It is - /// usually the EarlyClobber or Register slot following its last use. - bool isKilledAtInstr(SlotIndex index) const { - SlotIndex BaseIdx = index.getBaseIndex(); - const_iterator r = find(BaseIdx); - return r != end() && r->end.getBaseIndex() == BaseIdx; - } - - /// Return true if a live range starts at the instruction at this index. - bool isDefinedByInstr(SlotIndex index) const { - const_iterator r = find(index.getDeadSlot()); - return r != end() && r->end.getBaseIndex() == index.getBaseIndex(); - } - /// getLiveRangeContaining - Return the live range that contains the /// specified index, or null if there is none. const LiveRange *getLiveRangeContaining(SlotIndex Idx) const { -- cgit v1.1 From e179b31bfcb6a49de5fe7df7586a2aade9191e08 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Fri, 30 Aug 2013 20:39:21 +0000 Subject: [conf] Add config variable to disable crash related overrides. - We do some nasty things w.r.t. installing or overriding signal handlers in order to improve our crash recovery support or interaction with crash reporting software, and those things are not necessarily appropriate when LLVM is being linked into a client application that has its own ideas about how to do things. This gives those clients a way to disable that handling at build time. - Currently, the code this guards is all Apple specific, but other platforms might have the same concerns so I went for a more generic configure name. Someone who is more familiar with library embedding on Windows can handle choosing which of the Windows/Signals.inc behaviors might make sense to go under this flag. - This also fixes the proper autoconf'ing of ENABLE_BACKTRACES. The code expects it to be undefined when disabled, but the autoconf check was just defining it to 0. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189694 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Config/config.h.cmake | 3 +++ include/llvm/Config/config.h.in | 3 +++ 2 files changed, 6 insertions(+) (limited to 'include') diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake index 825349c..77de967 100644 --- a/include/llvm/Config/config.h.cmake +++ b/include/llvm/Config/config.h.cmake @@ -21,6 +21,9 @@ /* Define if you want backtraces on crash */ #cmakedefine ENABLE_BACKTRACES +/* Define to enable crash overrides */ +#cmakedefine ENABLE_CRASH_OVERRIDES + /* Define if position independent code is enabled */ #cmakedefine ENABLE_PIC diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in index 6dc8c6e..860bccb 100644 --- a/include/llvm/Config/config.h.in +++ b/include/llvm/Config/config.h.in @@ -21,6 +21,9 @@ /* Define if you want backtraces on crash */ #undef ENABLE_BACKTRACES +/* Define to enable crash handling overrides */ +#undef ENABLE_CRASH_OVERRIDES + /* Define if position independent code is enabled */ #undef ENABLE_PIC -- cgit v1.1 From 4af4cbbcedfa811b2d84a0614a2b47a3a685b386 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 31 Aug 2013 20:10:01 +0000 Subject: Free PressureDiffs instead of leaking. Found by valgrind. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189725 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/RegisterPressure.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/CodeGen/RegisterPressure.h b/include/llvm/CodeGen/RegisterPressure.h index e01e4ec..694d287 100644 --- a/include/llvm/CodeGen/RegisterPressure.h +++ b/include/llvm/CodeGen/RegisterPressure.h @@ -157,6 +157,7 @@ class PressureDiffs { unsigned Max; public: PressureDiffs(): PDiffArray(0), Size(0), Max(0) {} + ~PressureDiffs() { free(PDiffArray); } void init(unsigned N); -- cgit v1.1 From 5510728d28bb1ee04abc32da3d21b7df12948053 Mon Sep 17 00:00:00 2001 From: Charles Davis Date: Sun, 1 Sep 2013 04:28:48 +0000 Subject: Move everything depending on Object/MachOFormat.h over to Support/MachO.h. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189728 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCMachObjectWriter.h | 11 +- include/llvm/Object/MachO.h | 87 +++---- include/llvm/Object/MachOFormat.h | 452 ----------------------------------- include/llvm/Object/MachOUniversal.h | 6 +- 4 files changed, 53 insertions(+), 503 deletions(-) delete mode 100644 include/llvm/Object/MachOFormat.h (limited to 'include') diff --git a/include/llvm/MC/MCMachObjectWriter.h b/include/llvm/MC/MCMachObjectWriter.h index 3c9a588..3ba6e65 100644 --- a/include/llvm/MC/MCMachObjectWriter.h +++ b/include/llvm/MC/MCMachObjectWriter.h @@ -15,8 +15,8 @@ #include "llvm/ADT/SmallString.h" #include "llvm/MC/MCExpr.h" #include "llvm/MC/MCObjectWriter.h" -#include "llvm/Object/MachOFormat.h" #include "llvm/Support/DataTypes.h" +#include "llvm/Support/MachO.h" #include namespace llvm { @@ -98,7 +98,7 @@ class MachObjectWriter : public MCObjectWriter { /// @{ llvm::DenseMap > Relocations; + std::vector > Relocations; llvm::DenseMap IndirectSymBase; /// @} @@ -155,9 +155,8 @@ public: bool is64Bit() const { return TargetObjectWriter->is64Bit(); } bool isARM() const { - uint32_t CPUType = TargetObjectWriter->getCPUType() & - ~object::mach::CTFM_ArchMask; - return CPUType == object::mach::CTM_ARM; + uint32_t CPUType = TargetObjectWriter->getCPUType() & ~MachO::CPU_ARCH_MASK; + return CPUType == MachO::CPU_TYPE_ARM; } /// @} @@ -213,7 +212,7 @@ public: // these through in many cases. void addRelocation(const MCSectionData *SD, - object::macho::RelocationEntry &MRE) { + MachO::any_relocation_info &MRE) { Relocations[SD].push_back(MRE); } diff --git a/include/llvm/Object/MachO.h b/include/llvm/Object/MachO.h index caa642a..f3f391e 100644 --- a/include/llvm/Object/MachO.h +++ b/include/llvm/Object/MachO.h @@ -18,8 +18,8 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Triple.h" -#include "llvm/Object/MachOFormat.h" #include "llvm/Object/ObjectFile.h" +#include "llvm/Support/MachO.h" namespace llvm { namespace object { @@ -53,7 +53,7 @@ class MachOObjectFile : public ObjectFile { public: struct LoadCommandInfo { const char *Ptr; // Where in memory the load command is. - macho::LoadCommand C; // The command itself. + MachO::load_command C; // The command itself. }; MachOObjectFile(MemoryBuffer *Object, bool IsLittleEndian, bool Is64Bits, @@ -146,50 +146,53 @@ public: ArrayRef getSectionRawFinalSegmentName(DataRefImpl Sec) const; // MachO specific Info about relocations. - bool isRelocationScattered(const macho::RelocationEntry &RE) const; - unsigned getPlainRelocationSymbolNum(const macho::RelocationEntry &RE) const; - bool getPlainRelocationExternal(const macho::RelocationEntry &RE) const; - bool getScatteredRelocationScattered(const macho::RelocationEntry &RE) const; - uint32_t getScatteredRelocationValue(const macho::RelocationEntry &RE) const; - unsigned getAnyRelocationAddress(const macho::RelocationEntry &RE) const; - unsigned getAnyRelocationPCRel(const macho::RelocationEntry &RE) const; - unsigned getAnyRelocationLength(const macho::RelocationEntry &RE) const; - unsigned getAnyRelocationType(const macho::RelocationEntry &RE) const; - SectionRef getRelocationSection(const macho::RelocationEntry &RE) const; + bool isRelocationScattered(const MachO::any_relocation_info &RE) const; + unsigned getPlainRelocationSymbolNum( + const MachO::any_relocation_info &RE) const; + bool getPlainRelocationExternal(const MachO::any_relocation_info &RE) const; + bool getScatteredRelocationScattered( + const MachO::any_relocation_info &RE) const; + uint32_t getScatteredRelocationValue( + const MachO::any_relocation_info &RE) const; + unsigned getAnyRelocationAddress(const MachO::any_relocation_info &RE) const; + unsigned getAnyRelocationPCRel(const MachO::any_relocation_info &RE) const; + unsigned getAnyRelocationLength(const MachO::any_relocation_info &RE) const; + unsigned getAnyRelocationType(const MachO::any_relocation_info &RE) const; + SectionRef getRelocationSection(const MachO::any_relocation_info &RE) const; // Walk load commands. LoadCommandInfo getFirstLoadCommandInfo() const; LoadCommandInfo getNextLoadCommandInfo(const LoadCommandInfo &L) const; // MachO specific structures. - macho::Section getSection(DataRefImpl DRI) const; - macho::Section64 getSection64(DataRefImpl DRI) const; - macho::Section getSection(const LoadCommandInfo &L, unsigned Index) const; - macho::Section64 getSection64(const LoadCommandInfo &L, unsigned Index) const; - macho::SymbolTableEntry getSymbolTableEntry(DataRefImpl DRI) const; - macho::Symbol64TableEntry getSymbol64TableEntry(DataRefImpl DRI) const; - - macho::LinkeditDataLoadCommand + MachO::section getSection(DataRefImpl DRI) const; + MachO::section_64 getSection64(DataRefImpl DRI) const; + MachO::section getSection(const LoadCommandInfo &L, unsigned Index) const; + MachO::section_64 getSection64(const LoadCommandInfo &L,unsigned Index) const; + MachO::nlist getSymbolTableEntry(DataRefImpl DRI) const; + MachO::nlist_64 getSymbol64TableEntry(DataRefImpl DRI) const; + + MachO::linkedit_data_command getLinkeditDataLoadCommand(const LoadCommandInfo &L) const; - macho::SegmentLoadCommand + MachO::segment_command getSegmentLoadCommand(const LoadCommandInfo &L) const; - macho::Segment64LoadCommand + MachO::segment_command_64 getSegment64LoadCommand(const LoadCommandInfo &L) const; - macho::LinkerOptionsLoadCommand + MachO::linker_options_command getLinkerOptionsLoadCommand(const LoadCommandInfo &L) const; - macho::RelocationEntry getRelocation(DataRefImpl Rel) const; - macho::DataInCodeTableEntry getDice(DataRefImpl Rel) const; - macho::Header getHeader() const; - macho::Header64Ext getHeader64Ext() const; - macho::IndirectSymbolTableEntry - getIndirectSymbolTableEntry(const macho::DysymtabLoadCommand &DLC, + MachO::any_relocation_info getRelocation(DataRefImpl Rel) const; + MachO::data_in_code_entry getDice(DataRefImpl Rel) const; + MachO::mach_header getHeader() const; + MachO::mach_header_64 getHeader64() const; + uint32_t + getIndirectSymbolTableEntry(const MachO::dysymtab_command &DLC, unsigned Index) const; - macho::DataInCodeTableEntry getDataInCodeTableEntry(uint32_t DataOffset, - unsigned Index) const; - macho::SymtabLoadCommand getSymtabLoadCommand() const; - macho::DysymtabLoadCommand getDysymtabLoadCommand() const; - macho::LinkeditDataLoadCommand getDataInCodeLoadCommand() const; + MachO::data_in_code_entry getDataInCodeTableEntry(uint32_t DataOffset, + unsigned Index) const; + MachO::symtab_command getSymtabLoadCommand() const; + MachO::dysymtab_command getDysymtabLoadCommand() const; + MachO::linkedit_data_command getDataInCodeLoadCommand() const; StringRef getStringTableData() const; bool is64Bit() const; @@ -223,8 +226,8 @@ inline bool DiceRef::operator<(const DiceRef &Other) const { inline error_code DiceRef::getNext(DiceRef &Result) const { DataRefImpl Rel = DicePimpl; - const macho::DataInCodeTableEntry *P = - reinterpret_cast(Rel.p); + const MachO::data_in_code_entry *P = + reinterpret_cast(Rel.p); Rel.p = reinterpret_cast(P + 1); Result = DiceRef(Rel, OwningObject); return object_error::success; @@ -237,24 +240,24 @@ inline error_code DiceRef::getNext(DiceRef &Result) const { inline error_code DiceRef::getOffset(uint32_t &Result) const { const MachOObjectFile *MachOOF = static_cast(OwningObject); - macho::DataInCodeTableEntry Dice = MachOOF->getDice(DicePimpl); - Result = Dice.Offset; + MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl); + Result = Dice.offset; return object_error::success; } inline error_code DiceRef::getLength(uint16_t &Result) const { const MachOObjectFile *MachOOF = static_cast(OwningObject); - macho::DataInCodeTableEntry Dice = MachOOF->getDice(DicePimpl); - Result = Dice.Length; + MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl); + Result = Dice.length; return object_error::success; } inline error_code DiceRef::getKind(uint16_t &Result) const { const MachOObjectFile *MachOOF = static_cast(OwningObject); - macho::DataInCodeTableEntry Dice = MachOOF->getDice(DicePimpl); - Result = Dice.Kind; + MachO::data_in_code_entry Dice = MachOOF->getDice(DicePimpl); + Result = Dice.kind; return object_error::success; } diff --git a/include/llvm/Object/MachOFormat.h b/include/llvm/Object/MachOFormat.h deleted file mode 100644 index 2bbad0a..0000000 --- a/include/llvm/Object/MachOFormat.h +++ /dev/null @@ -1,452 +0,0 @@ -//===- MachOFormat.h - Mach-O Format Structures And Constants ---*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares various structures and constants which are platform -// independent and can be shared by any client which wishes to interact with -// Mach object files. -// -// The definitions here are purposely chosen to match the LLVM style as opposed -// to following the platform specific definition of the format. -// -// On a Mach system, see the includes for more information, in -// particular . -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_OBJECT_MACHOFORMAT_H -#define LLVM_OBJECT_MACHOFORMAT_H - -#include "llvm/Support/DataTypes.h" - -namespace llvm { -namespace object { - -/// General Mach platform information. -namespace mach { - /// @name CPU Type and Subtype Information - /// { - - /// \brief Capability bits used in CPU type encoding. - enum CPUTypeFlagsMask { - CTFM_ArchMask = 0xFF000000, - CTFM_ArchABI64 = 0x01000000 - }; - - /// \brief Machine type IDs used in CPU type encoding. - enum CPUTypeMachine { - CTM_i386 = 7, - CTM_x86_64 = CTM_i386 | CTFM_ArchABI64, - CTM_ARM = 12, - CTM_SPARC = 14, - CTM_PowerPC = 18, - CTM_PowerPC64 = CTM_PowerPC | CTFM_ArchABI64 - }; - - /// \brief Capability bits used in CPU subtype encoding. - enum CPUSubtypeFlagsMask { - CSFM_SubtypeMask = 0xFF000000, - CSFM_SubtypeLib64 = 0x80000000 - }; - - /// \brief ARM Machine Subtypes. - enum CPUSubtypeARM { - CSARM_ALL = 0, - CSARM_V4T = 5, - CSARM_V6 = 6, - CSARM_V5TEJ = 7, - CSARM_XSCALE = 8, - CSARM_V7 = 9, - CSARM_V7F = 10, - CSARM_V7S = 11, - CSARM_V7K = 12, - CSARM_V6M = 14, - CSARM_V7M = 15, - CSARM_V7EM = 16 - }; - - /// \brief PowerPC Machine Subtypes. - enum CPUSubtypePowerPC { - CSPPC_ALL = 0 - }; - - /// \brief SPARC Machine Subtypes. - enum CPUSubtypeSPARC { - CSSPARC_ALL = 0 - }; - - /// \brief x86 Machine Subtypes. - enum CPUSubtypeX86 { - CSX86_ALL = 3 - }; - - /// @} - -} // end namespace mach - -/// Format information for Mach object files. -namespace macho { - /// \brief Constants for structure sizes. - enum StructureSizes { - Header32Size = 28, - Header64Size = 32, - FatHeaderSize = 8, - FatArchHeaderSize = 20, - SegmentLoadCommand32Size = 56, - SegmentLoadCommand64Size = 72, - Section32Size = 68, - Section64Size = 80, - SymtabLoadCommandSize = 24, - DysymtabLoadCommandSize = 80, - Nlist32Size = 12, - Nlist64Size = 16, - RelocationInfoSize = 8, - LinkeditLoadCommandSize = 16 - }; - - /// \brief Constants for header magic field. - enum HeaderMagic { - HM_Object32 = 0xFEEDFACE, ///< 32-bit mach object file - HM_Object64 = 0xFEEDFACF, ///< 64-bit mach object file - HM_Universal = 0xCAFEBABE ///< Universal object file - }; - - /// \brief Header common to all Mach object files. - struct Header { - uint32_t Magic; - uint32_t CPUType; - uint32_t CPUSubtype; - uint32_t FileType; - uint32_t NumLoadCommands; - uint32_t SizeOfLoadCommands; - uint32_t Flags; - }; - - /// \brief Extended header for 64-bit object files. - struct Header64Ext { - uint32_t Reserved; - }; - - /// \brief Header for universal object files. - struct FatHeader { - uint32_t Magic; - uint32_t NumFatArch; - }; - - /// \brief Header for a single-architecture object file in a - /// universal binary. - struct FatArchHeader { - uint32_t CPUType; - uint32_t CPUSubtype; - uint32_t Offset; - uint32_t Size; - uint32_t Align; - }; - - // See . - enum HeaderFileType { - HFT_Object = 0x1 - }; - - enum HeaderFlags { - HF_SubsectionsViaSymbols = 0x2000 - }; - - enum LoadCommandType { - LCT_Segment = 0x1, - LCT_Symtab = 0x2, - LCT_Dysymtab = 0xb, - LCT_Segment64 = 0x19, - LCT_UUID = 0x1b, - LCT_CodeSignature = 0x1d, - LCT_SegmentSplitInfo = 0x1e, - LCT_FunctionStarts = 0x26, - LCT_DataInCode = 0x29, - LCT_LinkerOptions = 0x2D - }; - - /// \brief Load command structure. - struct LoadCommand { - uint32_t Type; - uint32_t Size; - }; - - /// @name Load Command Structures - /// @{ - - struct SegmentLoadCommand { - uint32_t Type; - uint32_t Size; - char Name[16]; - uint32_t VMAddress; - uint32_t VMSize; - uint32_t FileOffset; - uint32_t FileSize; - uint32_t MaxVMProtection; - uint32_t InitialVMProtection; - uint32_t NumSections; - uint32_t Flags; - }; - - struct Segment64LoadCommand { - uint32_t Type; - uint32_t Size; - char Name[16]; - uint64_t VMAddress; - uint64_t VMSize; - uint64_t FileOffset; - uint64_t FileSize; - uint32_t MaxVMProtection; - uint32_t InitialVMProtection; - uint32_t NumSections; - uint32_t Flags; - }; - - struct SymtabLoadCommand { - uint32_t Type; - uint32_t Size; - uint32_t SymbolTableOffset; - uint32_t NumSymbolTableEntries; - uint32_t StringTableOffset; - uint32_t StringTableSize; - }; - - struct DysymtabLoadCommand { - uint32_t Type; - uint32_t Size; - - uint32_t LocalSymbolsIndex; - uint32_t NumLocalSymbols; - - uint32_t ExternalSymbolsIndex; - uint32_t NumExternalSymbols; - - uint32_t UndefinedSymbolsIndex; - uint32_t NumUndefinedSymbols; - - uint32_t TOCOffset; - uint32_t NumTOCEntries; - - uint32_t ModuleTableOffset; - uint32_t NumModuleTableEntries; - - uint32_t ReferenceSymbolTableOffset; - uint32_t NumReferencedSymbolTableEntries; - - uint32_t IndirectSymbolTableOffset; - uint32_t NumIndirectSymbolTableEntries; - - uint32_t ExternalRelocationTableOffset; - uint32_t NumExternalRelocationTableEntries; - - uint32_t LocalRelocationTableOffset; - uint32_t NumLocalRelocationTableEntries; - }; - - struct LinkeditDataLoadCommand { - uint32_t Type; - uint32_t Size; - uint32_t DataOffset; - uint32_t DataSize; - }; - - struct LinkerOptionsLoadCommand { - uint32_t Type; - uint32_t Size; - uint32_t Count; - // Load command is followed by Count number of zero-terminated UTF8 strings, - // and then zero-filled to be 4-byte aligned. - }; - - /// @} - /// @name Section Data - /// @{ - - enum SectionFlags { - SF_PureInstructions = 0x80000000 - }; - - struct Section { - char Name[16]; - char SegmentName[16]; - uint32_t Address; - uint32_t Size; - uint32_t Offset; - uint32_t Align; - uint32_t RelocationTableOffset; - uint32_t NumRelocationTableEntries; - uint32_t Flags; - uint32_t Reserved1; - uint32_t Reserved2; - }; - struct Section64 { - char Name[16]; - char SegmentName[16]; - uint64_t Address; - uint64_t Size; - uint32_t Offset; - uint32_t Align; - uint32_t RelocationTableOffset; - uint32_t NumRelocationTableEntries; - uint32_t Flags; - uint32_t Reserved1; - uint32_t Reserved2; - uint32_t Reserved3; - }; - - /// @} - /// @name Symbol Table Entries - /// @{ - - struct SymbolTableEntry { - uint32_t StringIndex; - uint8_t Type; - uint8_t SectionIndex; - uint16_t Flags; - uint32_t Value; - }; - // Despite containing a uint64_t, this structure is only 4-byte aligned within - // a MachO file. -#pragma pack(push) -#pragma pack(4) - struct Symbol64TableEntry { - uint32_t StringIndex; - uint8_t Type; - uint8_t SectionIndex; - uint16_t Flags; - uint64_t Value; - }; -#pragma pack(pop) - - /// @} - /// @name Data-in-code Table Entry - /// @{ - - // See . - enum DataRegionType { Data = 1, JumpTable8, JumpTable16, JumpTable32 }; - struct DataInCodeTableEntry { - uint32_t Offset; /* from mach_header to start of data region */ - uint16_t Length; /* number of bytes in data region */ - uint16_t Kind; /* a DataRegionType value */ - }; - - /// @} - /// @name Indirect Symbol Table - /// @{ - - struct IndirectSymbolTableEntry { - uint32_t Index; - }; - - /// @} - /// @name Relocation Data - /// @{ - - struct RelocationEntry { - uint32_t Word0; - uint32_t Word1; - }; - - /// @} - - // See . - enum SymbolTypeType { - STT_Undefined = 0x00, - STT_Absolute = 0x02, - STT_Section = 0x0e - }; - - enum SymbolTypeFlags { - // If any of these bits are set, then the entry is a stab entry number (see - // . Otherwise the other masks apply. - STF_StabsEntryMask = 0xe0, - - STF_TypeMask = 0x0e, - STF_External = 0x01, - STF_PrivateExtern = 0x10 - }; - - /// IndirectSymbolFlags - Flags for encoding special values in the indirect - /// symbol entry. - enum IndirectSymbolFlags { - ISF_Local = 0x80000000, - ISF_Absolute = 0x40000000 - }; - - /// RelocationFlags - Special flags for addresses. - enum RelocationFlags { - RF_Scattered = 0x80000000 - }; - - /// Common relocation info types. - enum RelocationInfoType { - RIT_Vanilla = 0, - RIT_Pair = 1, - RIT_Difference = 2 - }; - - /// Generic relocation info types, which are shared by some (but not all) - /// platforms. - enum RelocationInfoType_Generic { - RIT_Generic_PreboundLazyPointer = 3, - RIT_Generic_LocalDifference = 4, - RIT_Generic_TLV = 5 - }; - - /// X86_64 uses its own relocation types. - enum RelocationInfoTypeX86_64 { - // Note that x86_64 doesn't even share the common relocation types. - RIT_X86_64_Unsigned = 0, - RIT_X86_64_Signed = 1, - RIT_X86_64_Branch = 2, - RIT_X86_64_GOTLoad = 3, - RIT_X86_64_GOT = 4, - RIT_X86_64_Subtractor = 5, - RIT_X86_64_Signed1 = 6, - RIT_X86_64_Signed2 = 7, - RIT_X86_64_Signed4 = 8, - RIT_X86_64_TLV = 9 - }; - - /// ARM uses its own relocation types. - enum RelocationInfoTypeARM { - RIT_ARM_LocalDifference = 3, - RIT_ARM_PreboundLazyPointer = 4, - RIT_ARM_Branch24Bit = 5, - RIT_ARM_ThumbBranch22Bit = 6, - RIT_ARM_ThumbBranch32Bit = 7, - RIT_ARM_Half = 8, - RIT_ARM_HalfDifference = 9 - - }; - - /// PPC relocation types from - enum RelocationInfoTypePPC { - RIT_PPC_BR14 = RIT_Pair +1, - RIT_PPC_BR24, - RIT_PPC_HI16, - RIT_PPC_LO16, - RIT_PPC_HA16, - RIT_PPC_LO14, - RIT_PPC_SECTDIFF, - RIT_PPC_PB_LA_PTR, - RIT_PPC_HI16_SECTDIFF, - RIT_PPC_LO16_SECTDIFF, - RIT_PPC_HA16_SECTDIFF, - RIT_PPC_JBSR, - RIT_PPC_LO14_SECTDIFF, - RIT_PPC_LOCAL_SECTDIFF, - RIT_PPC_TLV - }; - -} // end namespace macho - -} // end namespace object -} // end namespace llvm - -#endif diff --git a/include/llvm/Object/MachOUniversal.h b/include/llvm/Object/MachOUniversal.h index 5743282..c5d1359 100644 --- a/include/llvm/Object/MachOUniversal.h +++ b/include/llvm/Object/MachOUniversal.h @@ -18,7 +18,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Triple.h" #include "llvm/Object/Binary.h" -#include "llvm/Object/MachOFormat.h" +#include "llvm/Support/MachO.h" namespace llvm { namespace object { @@ -35,7 +35,7 @@ public: /// \brief Index of object in the universal binary. uint32_t Index; /// \brief Descriptor of the object. - macho::FatArchHeader Header; + MachO::fat_arch Header; public: ObjectForArch(const MachOUniversalBinary *Parent, uint32_t Index); @@ -50,7 +50,7 @@ public: } ObjectForArch getNext() const { return ObjectForArch(Parent, Index + 1); } - uint32_t getCPUType() const { return Header.CPUType; } + uint32_t getCPUType() const { return Header.cputype; } error_code getAsObjectFile(OwningPtr &Result) const; }; -- cgit v1.1 From 8092b710016873ebf569f66e598911fa94b4ea85 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Tue, 3 Sep 2013 09:35:20 +0000 Subject: [mips][msa] Added IntrNoMem to the floating-point intrinsics. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This changes the SelectionDAG nodes from ISD::INTRINSIC_W_CHAIN to ISD::INTRINSIC_WO_CHAIN which enables easy lowering to equivalent SelectionDAG nodes (e.g. __builtin_msa_fadd_w -> ISD::FADD) in future patches since nodes such as ISD::FADD do not have a chain. As per a similar change in r189106 (http://llvm.org/viewvc/llvm-project?rev=189106&view=rev) there isn’t a new testcase in this patch since the existing tests should test the intrinsics to the same standard and the best I can do for a testcase would be a fragile pass/maybe test of whether memory operations can (and do) cross the intrinsic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189782 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 196 +++++++++++++++++++------------------- 1 file changed, 100 insertions(+), 96 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 202bc37..7bbf003 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -872,29 +872,29 @@ def int_mips_dpsub_u_d : GCCBuiltin<"__builtin_msa_dpsub_u_d">, [IntrNoMem]>; def int_mips_fadd_w : GCCBuiltin<"__builtin_msa_fadd_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fadd_d : GCCBuiltin<"__builtin_msa_fadd_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fcaf_w : GCCBuiltin<"__builtin_msa_fcaf_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fcaf_d : GCCBuiltin<"__builtin_msa_fcaf_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fceq_w : GCCBuiltin<"__builtin_msa_fceq_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fceq_d : GCCBuiltin<"__builtin_msa_fceq_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fcle_w : GCCBuiltin<"__builtin_msa_fcle_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fcle_d : GCCBuiltin<"__builtin_msa_fcle_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fclt_w : GCCBuiltin<"__builtin_msa_fclt_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fclt_d : GCCBuiltin<"__builtin_msa_fclt_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fclass_w : GCCBuiltin<"__builtin_msa_fclass_w">, Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], [IntrNoMem]>; @@ -902,74 +902,74 @@ def int_mips_fclass_d : GCCBuiltin<"__builtin_msa_fclass_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fcne_w : GCCBuiltin<"__builtin_msa_fcne_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fcne_d : GCCBuiltin<"__builtin_msa_fcne_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fcor_w : GCCBuiltin<"__builtin_msa_fcor_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fcor_d : GCCBuiltin<"__builtin_msa_fcor_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fcueq_w : GCCBuiltin<"__builtin_msa_fcueq_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fcueq_d : GCCBuiltin<"__builtin_msa_fcueq_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fcule_w : GCCBuiltin<"__builtin_msa_fcule_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fcule_d : GCCBuiltin<"__builtin_msa_fcule_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fcult_w : GCCBuiltin<"__builtin_msa_fcult_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fcult_d : GCCBuiltin<"__builtin_msa_fcult_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fcun_w : GCCBuiltin<"__builtin_msa_fcun_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fcun_d : GCCBuiltin<"__builtin_msa_fcun_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fcune_w : GCCBuiltin<"__builtin_msa_fcune_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fcune_d : GCCBuiltin<"__builtin_msa_fcune_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fdiv_w : GCCBuiltin<"__builtin_msa_fdiv_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fdiv_d : GCCBuiltin<"__builtin_msa_fdiv_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fexdo_h : GCCBuiltin<"__builtin_msa_fexdo_h">, - Intrinsic<[llvm_v8f16_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v8f16_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fexdo_w : GCCBuiltin<"__builtin_msa_fexdo_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fexp2_w : GCCBuiltin<"__builtin_msa_fexp2_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_fexp2_d : GCCBuiltin<"__builtin_msa_fexp2_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_fexupl_w : GCCBuiltin<"__builtin_msa_fexupl_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v8f16_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v8f16_ty], [IntrNoMem]>; def int_mips_fexupl_d : GCCBuiltin<"__builtin_msa_fexupl_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v4f32_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fexupr_w : GCCBuiltin<"__builtin_msa_fexupr_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v8f16_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v8f16_ty], [IntrNoMem]>; def int_mips_fexupr_d : GCCBuiltin<"__builtin_msa_fexupr_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v4f32_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v4f32_ty], [IntrNoMem]>; def int_mips_ffint_s_w : GCCBuiltin<"__builtin_msa_ffint_s_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4i32_ty], [IntrNoMem]>; def int_mips_ffint_s_d : GCCBuiltin<"__builtin_msa_ffint_s_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2i64_ty], [IntrNoMem]>; def int_mips_ffint_u_w : GCCBuiltin<"__builtin_msa_ffint_u_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4i32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4i32_ty], [IntrNoMem]>; def int_mips_ffint_u_d : GCCBuiltin<"__builtin_msa_ffint_u_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2i64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2i64_ty], [IntrNoMem]>; def int_mips_ffql_w : GCCBuiltin<"__builtin_msa_ffql_w">, Intrinsic<[llvm_v4f32_ty], [llvm_v8i16_ty], [IntrNoMem]>; @@ -989,149 +989,153 @@ def int_mips_fill_w : GCCBuiltin<"__builtin_msa_fill_w">, Intrinsic<[llvm_v4i32_ty], [llvm_i32_ty], [IntrNoMem]>; def int_mips_flog2_w : GCCBuiltin<"__builtin_msa_flog2_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], [IntrNoMem]>; def int_mips_flog2_d : GCCBuiltin<"__builtin_msa_flog2_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fmadd_w : GCCBuiltin<"__builtin_msa_fmadd_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty], + [IntrNoMem]>; def int_mips_fmadd_d : GCCBuiltin<"__builtin_msa_fmadd_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty], + [IntrNoMem]>; def int_mips_fmax_w : GCCBuiltin<"__builtin_msa_fmax_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fmax_d : GCCBuiltin<"__builtin_msa_fmax_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fmax_a_w : GCCBuiltin<"__builtin_msa_fmax_a_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fmax_a_d : GCCBuiltin<"__builtin_msa_fmax_a_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fmin_w : GCCBuiltin<"__builtin_msa_fmin_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fmin_d : GCCBuiltin<"__builtin_msa_fmin_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fmin_a_w : GCCBuiltin<"__builtin_msa_fmin_a_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fmin_a_d : GCCBuiltin<"__builtin_msa_fmin_a_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fmsub_w : GCCBuiltin<"__builtin_msa_fmsub_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty], + [IntrNoMem]>; def int_mips_fmsub_d : GCCBuiltin<"__builtin_msa_fmsub_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty, llvm_v2f64_ty], + [IntrNoMem]>; def int_mips_fmul_w : GCCBuiltin<"__builtin_msa_fmul_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fmul_d : GCCBuiltin<"__builtin_msa_fmul_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_frint_w : GCCBuiltin<"__builtin_msa_frint_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], [IntrNoMem]>; def int_mips_frint_d : GCCBuiltin<"__builtin_msa_frint_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; def int_mips_frcp_w : GCCBuiltin<"__builtin_msa_frcp_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], [IntrNoMem]>; def int_mips_frcp_d : GCCBuiltin<"__builtin_msa_frcp_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; def int_mips_frsqrt_w : GCCBuiltin<"__builtin_msa_frsqrt_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], [IntrNoMem]>; def int_mips_frsqrt_d : GCCBuiltin<"__builtin_msa_frsqrt_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fsaf_w : GCCBuiltin<"__builtin_msa_fsaf_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fsaf_d : GCCBuiltin<"__builtin_msa_fsaf_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fseq_w : GCCBuiltin<"__builtin_msa_fseq_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fseq_d : GCCBuiltin<"__builtin_msa_fseq_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fsle_w : GCCBuiltin<"__builtin_msa_fsle_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fsle_d : GCCBuiltin<"__builtin_msa_fsle_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fslt_w : GCCBuiltin<"__builtin_msa_fslt_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fslt_d : GCCBuiltin<"__builtin_msa_fslt_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fsne_w : GCCBuiltin<"__builtin_msa_fsne_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fsne_d : GCCBuiltin<"__builtin_msa_fsne_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fsor_w : GCCBuiltin<"__builtin_msa_fsor_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fsor_d : GCCBuiltin<"__builtin_msa_fsor_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fsqrt_w : GCCBuiltin<"__builtin_msa_fsqrt_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fsqrt_d : GCCBuiltin<"__builtin_msa_fsqrt_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fsub_w : GCCBuiltin<"__builtin_msa_fsub_w">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fsub_d : GCCBuiltin<"__builtin_msa_fsub_d">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fsueq_w : GCCBuiltin<"__builtin_msa_fsueq_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fsueq_d : GCCBuiltin<"__builtin_msa_fsueq_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fsule_w : GCCBuiltin<"__builtin_msa_fsule_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fsule_d : GCCBuiltin<"__builtin_msa_fsule_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fsult_w : GCCBuiltin<"__builtin_msa_fsult_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fsult_d : GCCBuiltin<"__builtin_msa_fsult_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fsun_w : GCCBuiltin<"__builtin_msa_fsun_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fsun_d : GCCBuiltin<"__builtin_msa_fsun_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_fsune_w : GCCBuiltin<"__builtin_msa_fsune_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_fsune_d : GCCBuiltin<"__builtin_msa_fsune_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_ftint_s_w : GCCBuiltin<"__builtin_msa_ftint_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], [IntrNoMem]>; def int_mips_ftint_s_d : GCCBuiltin<"__builtin_msa_ftint_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty], [IntrNoMem]>; def int_mips_ftint_u_w : GCCBuiltin<"__builtin_msa_ftint_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], [IntrNoMem]>; def int_mips_ftint_u_d : GCCBuiltin<"__builtin_msa_ftint_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty], [IntrNoMem]>; def int_mips_ftq_h : GCCBuiltin<"__builtin_msa_ftq_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v4f32_ty, llvm_v4f32_ty], []>; + Intrinsic<[llvm_v8i16_ty], [llvm_v4f32_ty, llvm_v4f32_ty], [IntrNoMem]>; def int_mips_ftq_w : GCCBuiltin<"__builtin_msa_ftq_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v2f64_ty, llvm_v2f64_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; def int_mips_ftrunc_s_w : GCCBuiltin<"__builtin_msa_ftrunc_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], [IntrNoMem]>; def int_mips_ftrunc_s_d : GCCBuiltin<"__builtin_msa_ftrunc_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty], [IntrNoMem]>; def int_mips_ftrunc_u_w : GCCBuiltin<"__builtin_msa_ftrunc_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], []>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4f32_ty], [IntrNoMem]>; def int_mips_ftrunc_u_d : GCCBuiltin<"__builtin_msa_ftrunc_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty], []>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty], [IntrNoMem]>; def int_mips_hadd_s_h : GCCBuiltin<"__builtin_msa_hadd_s_h">, Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; -- cgit v1.1 From fdb6a38913cc54e9523b1ee1aab2cc3be27ea4f7 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Tue, 3 Sep 2013 09:45:20 +0000 Subject: [mips][msa] Added IntrNoMem and removed Commutative from sub intrinsics. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This changes the SelectionDAG nodes from ISD::INTRINSIC_W_CHAIN to ISD::INTRINSIC_WO_CHAIN which enables easy lowering to equivalent SelectionDAG nodes (e.g. __builtin_msa_sub_w -> ISD::SUB) in future patches since nodes such as ISD::SUB do not have a chain. It also corrects an obvious mistake, namely that the subtract intrinsics were marked as being commutative. As per a similar change in r189106 (http://llvm.org/viewvc/llvm-project?rev=189106&view=rev) there isn’t a new testcase in this patch since the existing tests should test the intrinsics to the same standard and the best I can do for a testcase would be a fragile pass/maybe test of whether memory operations can (and do) cross the intrinsic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189784 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 56 +++++++++++++++++++-------------------- 1 file changed, 28 insertions(+), 28 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 7bbf003..af01bf9 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -1682,67 +1682,67 @@ def int_mips_stx_d : GCCBuiltin<"__builtin_msa_stx_d">, [IntrReadWriteArgMem]>; def int_mips_subs_s_b : GCCBuiltin<"__builtin_msa_subs_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_subs_s_h : GCCBuiltin<"__builtin_msa_subs_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_subs_s_w : GCCBuiltin<"__builtin_msa_subs_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_subs_s_d : GCCBuiltin<"__builtin_msa_subs_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_subs_u_b : GCCBuiltin<"__builtin_msa_subs_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_subs_u_h : GCCBuiltin<"__builtin_msa_subs_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_subs_u_w : GCCBuiltin<"__builtin_msa_subs_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_subs_u_d : GCCBuiltin<"__builtin_msa_subs_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_subsus_u_b : GCCBuiltin<"__builtin_msa_subsus_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_subsus_u_h : GCCBuiltin<"__builtin_msa_subsus_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_subsus_u_w : GCCBuiltin<"__builtin_msa_subsus_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_subsus_u_d : GCCBuiltin<"__builtin_msa_subsus_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_subsuu_s_b : GCCBuiltin<"__builtin_msa_subsuu_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_subsuu_s_h : GCCBuiltin<"__builtin_msa_subsuu_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_subsuu_s_w : GCCBuiltin<"__builtin_msa_subsuu_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_subsuu_s_d : GCCBuiltin<"__builtin_msa_subsuu_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_subv_b : GCCBuiltin<"__builtin_msa_subv_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_subv_h : GCCBuiltin<"__builtin_msa_subv_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_subv_w : GCCBuiltin<"__builtin_msa_subv_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_subv_d : GCCBuiltin<"__builtin_msa_subv_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_subvi_b : GCCBuiltin<"__builtin_msa_subvi_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [Commutative]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_subvi_h : GCCBuiltin<"__builtin_msa_subvi_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [Commutative]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_subvi_w : GCCBuiltin<"__builtin_msa_subvi_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [Commutative]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_subvi_d : GCCBuiltin<"__builtin_msa_subvi_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [Commutative]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_vshf_b : GCCBuiltin<"__builtin_msa_vshf_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [Commutative]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_vshf_h : GCCBuiltin<"__builtin_msa_vshf_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [Commutative]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_vshf_w : GCCBuiltin<"__builtin_msa_vshf_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [Commutative]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_vshf_d : GCCBuiltin<"__builtin_msa_vshf_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [Commutative]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_xor_v : GCCBuiltin<"__builtin_msa_xor_v">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; -- cgit v1.1 From f21c18db9fa8bf185a44287f5700fec3d4a98e14 Mon Sep 17 00:00:00 2001 From: Joey Gouly Date: Tue, 3 Sep 2013 15:03:36 +0000 Subject: [MC] AvailableFeatures needs to be a uint64_t to match FeatureBits in MCSubtargetInfo. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189815 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCInstPrinter.h | 6 +++--- include/llvm/MC/MCTargetAsmParser.h | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCInstPrinter.h b/include/llvm/MC/MCInstPrinter.h index cb7225f..b4258be 100644 --- a/include/llvm/MC/MCInstPrinter.h +++ b/include/llvm/MC/MCInstPrinter.h @@ -41,7 +41,7 @@ protected: const MCRegisterInfo &MRI; /// The current set of available features. - unsigned AvailableFeatures; + uint64_t AvailableFeatures; /// True if we are printing marked up assembly. bool UseMarkup; @@ -77,8 +77,8 @@ public: /// printRegName - Print the assembler register name. virtual void printRegName(raw_ostream &OS, unsigned RegNo) const; - unsigned getAvailableFeatures() const { return AvailableFeatures; } - void setAvailableFeatures(unsigned Value) { AvailableFeatures = Value; } + uint64_t getAvailableFeatures() const { return AvailableFeatures; } + void setAvailableFeatures(uint64_t Value) { AvailableFeatures = Value; } bool getUseMarkup() const { return UseMarkup; } void setUseMarkup(bool Value) { UseMarkup = Value; } diff --git a/include/llvm/MC/MCTargetAsmParser.h b/include/llvm/MC/MCTargetAsmParser.h index 6e96e8b..a48c5d1 100644 --- a/include/llvm/MC/MCTargetAsmParser.h +++ b/include/llvm/MC/MCTargetAsmParser.h @@ -88,7 +88,7 @@ protected: // Can only create subclasses. MCTargetAsmParser(); /// AvailableFeatures - The current set of available features. - unsigned AvailableFeatures; + uint64_t AvailableFeatures; /// ParsingInlineAsm - Are we parsing ms-style inline assembly? bool ParsingInlineAsm; @@ -100,8 +100,8 @@ protected: // Can only create subclasses. public: virtual ~MCTargetAsmParser(); - unsigned getAvailableFeatures() const { return AvailableFeatures; } - void setAvailableFeatures(unsigned Value) { AvailableFeatures = Value; } + uint64_t getAvailableFeatures() const { return AvailableFeatures; } + void setAvailableFeatures(uint64_t Value) { AvailableFeatures = Value; } bool isParsingInlineAsm () { return ParsingInlineAsm; } void setParsingInlineAsm (bool Value) { ParsingInlineAsm = Value; } -- cgit v1.1 From 27ed5716ef97210879c1e2163210608679c5129e Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Tue, 3 Sep 2013 16:11:13 +0000 Subject: Migrate the DWARF_VERSION constant to 4. It largely needs to go away. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189824 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index d857341..ab4b449 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -69,7 +69,7 @@ const uint64_t DW64_CIE_ID = UINT64_MAX; enum dwarf_constants { - DWARF_VERSION = 2, + DWARF_VERSION = 4, // Tags DW_TAG_array_type = 0x01, -- cgit v1.1 From 06ef1ed260195e35fd1ea4a3dd8b3c00d7c434f2 Mon Sep 17 00:00:00 2001 From: Joey Gouly Date: Tue, 3 Sep 2013 16:18:19 +0000 Subject: [MC] Revert part of my previous change, I was a bit overzealous. A change to test the previous commit will be coming soon. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189825 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCTargetAsmParser.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCTargetAsmParser.h b/include/llvm/MC/MCTargetAsmParser.h index a48c5d1..6e96e8b 100644 --- a/include/llvm/MC/MCTargetAsmParser.h +++ b/include/llvm/MC/MCTargetAsmParser.h @@ -88,7 +88,7 @@ protected: // Can only create subclasses. MCTargetAsmParser(); /// AvailableFeatures - The current set of available features. - uint64_t AvailableFeatures; + unsigned AvailableFeatures; /// ParsingInlineAsm - Are we parsing ms-style inline assembly? bool ParsingInlineAsm; @@ -100,8 +100,8 @@ protected: // Can only create subclasses. public: virtual ~MCTargetAsmParser(); - uint64_t getAvailableFeatures() const { return AvailableFeatures; } - void setAvailableFeatures(uint64_t Value) { AvailableFeatures = Value; } + unsigned getAvailableFeatures() const { return AvailableFeatures; } + void setAvailableFeatures(unsigned Value) { AvailableFeatures = Value; } bool isParsingInlineAsm () { return ParsingInlineAsm; } void setParsingInlineAsm (bool Value) { ParsingInlineAsm = Value; } -- cgit v1.1 From f57a80f4942dafdb56e854d42af83abaf949ff9d Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Tue, 3 Sep 2013 20:43:54 +0000 Subject: Add a Python-like join function to merge a list of strings with a separator between each two elements. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189846 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/StringExtras.h | 43 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'include') diff --git a/include/llvm/ADT/StringExtras.h b/include/llvm/ADT/StringExtras.h index d2887c5..56dbb5b 100644 --- a/include/llvm/ADT/StringExtras.h +++ b/include/llvm/ADT/StringExtras.h @@ -14,6 +14,7 @@ #ifndef LLVM_ADT_STRINGEXTRAS_H #define LLVM_ADT_STRINGEXTRAS_H +#include #include "llvm/ADT/StringRef.h" #include "llvm/Support/DataTypes.h" @@ -159,6 +160,48 @@ static inline StringRef getOrdinalSuffix(unsigned Val) { } } +template +inline std::string join_impl(IteratorT Begin, IteratorT End, + StringRef Separator, std::input_iterator_tag) { + std::string S; + if (Begin == End) + return S; + + S += (*Begin); + while (++Begin != End) { + S += Separator; + S += (*Begin); + } + return S; +} + +template +inline std::string join_impl(IteratorT Begin, IteratorT End, + StringRef Separator, std::forward_iterator_tag) { + std::string S; + if (Begin == End) + return S; + + size_t Len = (std::distance(Begin, End) - 1) * Separator.size(); + for (IteratorT I = Begin; I != End; ++I) + Len += (*Begin).size(); + S.reserve(Len); + S += (*Begin); + while (++Begin != End) { + S += Separator; + S += (*Begin); + } + return S; +} + +/// Joins the strings in the range [Begin, End), adding Separator between +/// the elements. +template +inline std::string join(IteratorT Begin, IteratorT End, StringRef Separator) { + typedef typename std::iterator_traits::iterator_category tag; + return join_impl(Begin, End, Separator, tag()); +} + } // End llvm namespace #endif -- cgit v1.1 From e547c57dbfdd5adb031f297ade26d8b6ed3e9b00 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Tue, 3 Sep 2013 21:05:51 +0000 Subject: Fix grammar git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189855 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/ValueTypes.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h index f605c80..82b8d8a 100644 --- a/include/llvm/CodeGen/ValueTypes.h +++ b/include/llvm/CodeGen/ValueTypes.h @@ -27,9 +27,9 @@ namespace llvm { class LLVMContext; struct EVT; - /// MVT - Machine Value Type. Every type that is supported natively by some - /// processor targeted by LLVM occurs here. This means that any legal value - /// type can be represented by a MVT. + /// MVT - Machine Value Type. Every type that is supported natively by some + /// processor targeted by LLVM occurs here. This means that any legal value + /// type can be represented by an MVT. class MVT { public: enum SimpleValueType { -- cgit v1.1 From 17554f3ffb157b122bc715f7701836f30adaf1e5 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 3 Sep 2013 22:16:52 +0000 Subject: Add comments to the CFI instructions and reformat with clang-format. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189864 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCDwarf.h | 758 ++++++++++++++++++++++++---------------------- 1 file changed, 398 insertions(+), 360 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCDwarf.h b/include/llvm/MC/MCDwarf.h index 3ece262..5ca1be6 100644 --- a/include/llvm/MC/MCDwarf.h +++ b/include/llvm/MC/MCDwarf.h @@ -23,400 +23,438 @@ #include namespace llvm { - class MCContext; - class MCSection; - class MCStreamer; - class MCSymbol; - class SourceMgr; - class SMLoc; - - /// MCDwarfFile - Instances of this class represent the name of the dwarf - /// .file directive and its associated dwarf file number in the MC file, - /// and MCDwarfFile's are created and unique'd by the MCContext class where - /// the file number for each is its index into the vector of DwarfFiles (note - /// index 0 is not used and not a valid dwarf file number). - class MCDwarfFile { - // Name - the base name of the file without its directory path. - // The StringRef references memory allocated in the MCContext. - StringRef Name; - - // DirIndex - the index into the list of directory names for this file name. - unsigned DirIndex; - - private: // MCContext creates and uniques these. - friend class MCContext; - MCDwarfFile(StringRef name, unsigned dirIndex) +class MCContext; +class MCSection; +class MCStreamer; +class MCSymbol; +class SourceMgr; +class SMLoc; + +/// MCDwarfFile - Instances of this class represent the name of the dwarf +/// .file directive and its associated dwarf file number in the MC file, +/// and MCDwarfFile's are created and unique'd by the MCContext class where +/// the file number for each is its index into the vector of DwarfFiles (note +/// index 0 is not used and not a valid dwarf file number). +class MCDwarfFile { + // Name - the base name of the file without its directory path. + // The StringRef references memory allocated in the MCContext. + StringRef Name; + + // DirIndex - the index into the list of directory names for this file name. + unsigned DirIndex; + +private: // MCContext creates and uniques these. + friend class MCContext; + MCDwarfFile(StringRef name, unsigned dirIndex) : Name(name), DirIndex(dirIndex) {} - MCDwarfFile(const MCDwarfFile&) LLVM_DELETED_FUNCTION; - void operator=(const MCDwarfFile&) LLVM_DELETED_FUNCTION; - public: - /// getName - Get the base name of this MCDwarfFile. - StringRef getName() const { return Name; } - - /// getDirIndex - Get the dirIndex of this MCDwarfFile. - unsigned getDirIndex() const { return DirIndex; } - - - /// print - Print the value to the stream \p OS. - void print(raw_ostream &OS) const; - - /// dump - Print the value to stderr. - void dump() const; - }; - - inline raw_ostream &operator<<(raw_ostream &OS, const MCDwarfFile &DwarfFile){ - DwarfFile.print(OS); - return OS; - } - - /// MCDwarfLoc - Instances of this class represent the information from a - /// dwarf .loc directive. - class MCDwarfLoc { - // FileNum - the file number. - unsigned FileNum; - // Line - the line number. - unsigned Line; - // Column - the column position. - unsigned Column; - // Flags (see #define's below) - unsigned Flags; - // Isa - unsigned Isa; - // Discriminator - unsigned Discriminator; + MCDwarfFile(const MCDwarfFile &) LLVM_DELETED_FUNCTION; + void operator=(const MCDwarfFile &) LLVM_DELETED_FUNCTION; + +public: + /// getName - Get the base name of this MCDwarfFile. + StringRef getName() const { return Name; } + + /// getDirIndex - Get the dirIndex of this MCDwarfFile. + unsigned getDirIndex() const { return DirIndex; } + + /// print - Print the value to the stream \p OS. + void print(raw_ostream &OS) const; + + /// dump - Print the value to stderr. + void dump() const; +}; + +inline raw_ostream &operator<<(raw_ostream &OS, const MCDwarfFile &DwarfFile) { + DwarfFile.print(OS); + return OS; +} + +/// MCDwarfLoc - Instances of this class represent the information from a +/// dwarf .loc directive. +class MCDwarfLoc { + // FileNum - the file number. + unsigned FileNum; + // Line - the line number. + unsigned Line; + // Column - the column position. + unsigned Column; + // Flags (see #define's below) + unsigned Flags; + // Isa + unsigned Isa; + // Discriminator + unsigned Discriminator; // Flag that indicates the initial value of the is_stmt_start flag. -#define DWARF2_LINE_DEFAULT_IS_STMT 1 +#define DWARF2_LINE_DEFAULT_IS_STMT 1 -#define DWARF2_FLAG_IS_STMT (1 << 0) -#define DWARF2_FLAG_BASIC_BLOCK (1 << 1) -#define DWARF2_FLAG_PROLOGUE_END (1 << 2) +#define DWARF2_FLAG_IS_STMT (1 << 0) +#define DWARF2_FLAG_BASIC_BLOCK (1 << 1) +#define DWARF2_FLAG_PROLOGUE_END (1 << 2) #define DWARF2_FLAG_EPILOGUE_BEGIN (1 << 3) - private: // MCContext manages these - friend class MCContext; - friend class MCLineEntry; - MCDwarfLoc(unsigned fileNum, unsigned line, unsigned column, unsigned flags, - unsigned isa, unsigned discriminator) +private: // MCContext manages these + friend class MCContext; + friend class MCLineEntry; + MCDwarfLoc(unsigned fileNum, unsigned line, unsigned column, unsigned flags, + unsigned isa, unsigned discriminator) : FileNum(fileNum), Line(line), Column(column), Flags(flags), Isa(isa), Discriminator(discriminator) {} - // Allow the default copy constructor and assignment operator to be used - // for an MCDwarfLoc object. + // Allow the default copy constructor and assignment operator to be used + // for an MCDwarfLoc object. - public: - /// getFileNum - Get the FileNum of this MCDwarfLoc. - unsigned getFileNum() const { return FileNum; } +public: + /// getFileNum - Get the FileNum of this MCDwarfLoc. + unsigned getFileNum() const { return FileNum; } - /// getLine - Get the Line of this MCDwarfLoc. - unsigned getLine() const { return Line; } + /// getLine - Get the Line of this MCDwarfLoc. + unsigned getLine() const { return Line; } - /// getColumn - Get the Column of this MCDwarfLoc. - unsigned getColumn() const { return Column; } + /// getColumn - Get the Column of this MCDwarfLoc. + unsigned getColumn() const { return Column; } - /// getFlags - Get the Flags of this MCDwarfLoc. - unsigned getFlags() const { return Flags; } + /// getFlags - Get the Flags of this MCDwarfLoc. + unsigned getFlags() const { return Flags; } - /// getIsa - Get the Isa of this MCDwarfLoc. - unsigned getIsa() const { return Isa; } + /// getIsa - Get the Isa of this MCDwarfLoc. + unsigned getIsa() const { return Isa; } - /// getDiscriminator - Get the Discriminator of this MCDwarfLoc. - unsigned getDiscriminator() const { return Discriminator; } + /// getDiscriminator - Get the Discriminator of this MCDwarfLoc. + unsigned getDiscriminator() const { return Discriminator; } - /// setFileNum - Set the FileNum of this MCDwarfLoc. - void setFileNum(unsigned fileNum) { FileNum = fileNum; } + /// setFileNum - Set the FileNum of this MCDwarfLoc. + void setFileNum(unsigned fileNum) { FileNum = fileNum; } - /// setLine - Set the Line of this MCDwarfLoc. - void setLine(unsigned line) { Line = line; } + /// setLine - Set the Line of this MCDwarfLoc. + void setLine(unsigned line) { Line = line; } - /// setColumn - Set the Column of this MCDwarfLoc. - void setColumn(unsigned column) { Column = column; } + /// setColumn - Set the Column of this MCDwarfLoc. + void setColumn(unsigned column) { Column = column; } - /// setFlags - Set the Flags of this MCDwarfLoc. - void setFlags(unsigned flags) { Flags = flags; } + /// setFlags - Set the Flags of this MCDwarfLoc. + void setFlags(unsigned flags) { Flags = flags; } - /// setIsa - Set the Isa of this MCDwarfLoc. - void setIsa(unsigned isa) { Isa = isa; } + /// setIsa - Set the Isa of this MCDwarfLoc. + void setIsa(unsigned isa) { Isa = isa; } - /// setDiscriminator - Set the Discriminator of this MCDwarfLoc. - void setDiscriminator(unsigned discriminator) { - Discriminator = discriminator; - } - }; + /// setDiscriminator - Set the Discriminator of this MCDwarfLoc. + void setDiscriminator(unsigned discriminator) { + Discriminator = discriminator; + } +}; + +/// MCLineEntry - Instances of this class represent the line information for +/// the dwarf line table entries. Which is created after a machine +/// instruction is assembled and uses an address from a temporary label +/// created at the current address in the current section and the info from +/// the last .loc directive seen as stored in the context. +class MCLineEntry : public MCDwarfLoc { + MCSymbol *Label; + +private: + // Allow the default copy constructor and assignment operator to be used + // for an MCLineEntry object. + +public: + // Constructor to create an MCLineEntry given a symbol and the dwarf loc. + MCLineEntry(MCSymbol *label, const MCDwarfLoc loc) + : MCDwarfLoc(loc), Label(label) {} + + MCSymbol *getLabel() const { return Label; } + + // This is called when an instruction is assembled into the specified + // section and if there is information from the last .loc directive that + // has yet to have a line entry made for it is made. + static void Make(MCStreamer *MCOS, const MCSection *Section); +}; + +/// MCLineSection - Instances of this class represent the line information +/// for a section where machine instructions have been assembled after seeing +/// .loc directives. This is the information used to build the dwarf line +/// table for a section. +class MCLineSection { + +private: + MCLineSection(const MCLineSection &) LLVM_DELETED_FUNCTION; + void operator=(const MCLineSection &) LLVM_DELETED_FUNCTION; + +public: + // Constructor to create an MCLineSection with an empty MCLineEntries + // vector. + MCLineSection() {} + + // addLineEntry - adds an entry to this MCLineSection's line entries + void addLineEntry(const MCLineEntry &LineEntry, unsigned CUID) { + MCLineDivisions[CUID].push_back(LineEntry); + } - /// MCLineEntry - Instances of this class represent the line information for - /// the dwarf line table entries. Which is created after a machine - /// instruction is assembled and uses an address from a temporary label - /// created at the current address in the current section and the info from - /// the last .loc directive seen as stored in the context. - class MCLineEntry : public MCDwarfLoc { - MCSymbol *Label; - - private: - // Allow the default copy constructor and assignment operator to be used - // for an MCLineEntry object. - - public: - // Constructor to create an MCLineEntry given a symbol and the dwarf loc. - MCLineEntry(MCSymbol *label, const MCDwarfLoc loc) : MCDwarfLoc(loc), - Label(label) {} - - MCSymbol *getLabel() const { return Label; } - - // This is called when an instruction is assembled into the specified - // section and if there is information from the last .loc directive that - // has yet to have a line entry made for it is made. - static void Make(MCStreamer *MCOS, const MCSection *Section); - }; + typedef std::vector MCLineEntryCollection; + typedef MCLineEntryCollection::iterator iterator; + typedef MCLineEntryCollection::const_iterator const_iterator; + typedef std::map MCLineDivisionMap; + +private: + // A collection of MCLineEntry for each Compile Unit ID. + MCLineDivisionMap MCLineDivisions; - /// MCLineSection - Instances of this class represent the line information - /// for a section where machine instructions have been assembled after seeing - /// .loc directives. This is the information used to build the dwarf line - /// table for a section. - class MCLineSection { - - private: - MCLineSection(const MCLineSection&) LLVM_DELETED_FUNCTION; - void operator=(const MCLineSection&) LLVM_DELETED_FUNCTION; - - public: - // Constructor to create an MCLineSection with an empty MCLineEntries - // vector. - MCLineSection() {} - - // addLineEntry - adds an entry to this MCLineSection's line entries - void addLineEntry(const MCLineEntry &LineEntry, unsigned CUID) { - MCLineDivisions[CUID].push_back(LineEntry); - } - - typedef std::vector MCLineEntryCollection; - typedef MCLineEntryCollection::iterator iterator; - typedef MCLineEntryCollection::const_iterator const_iterator; - typedef std::map MCLineDivisionMap; - - private: - // A collection of MCLineEntry for each Compile Unit ID. - MCLineDivisionMap MCLineDivisions; - - public: - // Returns whether MCLineSection contains entries for a given Compile - // Unit ID. - bool containEntriesForID(unsigned CUID) const { - return MCLineDivisions.count(CUID); - } - // Returns the collection of MCLineEntry for a given Compile Unit ID. - const MCLineEntryCollection &getMCLineEntries(unsigned CUID) const { - MCLineDivisionMap::const_iterator CIter = MCLineDivisions.find(CUID); - assert(CIter != MCLineDivisions.end()); - return CIter->second; - } +public: + // Returns whether MCLineSection contains entries for a given Compile + // Unit ID. + bool containEntriesForID(unsigned CUID) const { + return MCLineDivisions.count(CUID); + } + // Returns the collection of MCLineEntry for a given Compile Unit ID. + const MCLineEntryCollection &getMCLineEntries(unsigned CUID) const { + MCLineDivisionMap::const_iterator CIter = MCLineDivisions.find(CUID); + assert(CIter != MCLineDivisions.end()); + return CIter->second; + } +}; + +class MCDwarfFileTable { +public: + // + // This emits the Dwarf file and the line tables for all Compile Units. + // + static const MCSymbol *Emit(MCStreamer *MCOS); + // + // This emits the Dwarf file and the line tables for a given Compile Unit. + // + static const MCSymbol *EmitCU(MCStreamer *MCOS, unsigned ID); +}; + +class MCDwarfLineAddr { +public: + /// Utility function to encode a Dwarf pair of LineDelta and AddrDeltas. + static void Encode(MCContext &Context, int64_t LineDelta, uint64_t AddrDelta, + raw_ostream &OS); + + /// Utility function to emit the encoding to a streamer. + static void Emit(MCStreamer *MCOS, int64_t LineDelta, uint64_t AddrDelta); +}; + +class MCGenDwarfInfo { +public: + // + // When generating dwarf for assembly source files this emits the Dwarf + // sections. + // + static void Emit(MCStreamer *MCOS, const MCSymbol *LineSectionSymbol); +}; + +// When generating dwarf for assembly source files this is the info that is +// needed to be gathered for each symbol that will have a dwarf label. +class MCGenDwarfLabelEntry { +private: + // Name of the symbol without a leading underbar, if any. + StringRef Name; + // The dwarf file number this symbol is in. + unsigned FileNumber; + // The line number this symbol is at. + unsigned LineNumber; + // The low_pc for the dwarf label is taken from this symbol. + MCSymbol *Label; + +public: + MCGenDwarfLabelEntry(StringRef name, unsigned fileNumber, unsigned lineNumber, + MCSymbol *label) + : Name(name), FileNumber(fileNumber), LineNumber(lineNumber), + Label(label) {} + + StringRef getName() const { return Name; } + unsigned getFileNumber() const { return FileNumber; } + unsigned getLineNumber() const { return LineNumber; } + MCSymbol *getLabel() const { return Label; } + + // This is called when label is created when we are generating dwarf for + // assembly source files. + static void Make(MCSymbol *Symbol, MCStreamer *MCOS, SourceMgr &SrcMgr, + SMLoc &Loc); +}; + +class MCCFIInstruction { +public: + enum OpType { + OpSameValue, + OpRememberState, + OpRestoreState, + OpOffset, + OpDefCfaRegister, + OpDefCfaOffset, + OpDefCfa, + OpRelOffset, + OpAdjustCfaOffset, + OpEscape, + OpRestore, + OpUndefined, + OpRegister }; - class MCDwarfFileTable { - public: - // - // This emits the Dwarf file and the line tables for all Compile Units. - // - static const MCSymbol *Emit(MCStreamer *MCOS); - // - // This emits the Dwarf file and the line tables for a given Compile Unit. - // - static const MCSymbol *EmitCU(MCStreamer *MCOS, unsigned ID); +private: + OpType Operation; + MCSymbol *Label; + unsigned Register; + union { + int Offset; + unsigned Register2; }; + std::vector Values; - class MCDwarfLineAddr { - public: - /// Utility function to encode a Dwarf pair of LineDelta and AddrDeltas. - static void Encode(MCContext &Context, int64_t LineDelta, - uint64_t AddrDelta, raw_ostream &OS); + MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int O, StringRef V) + : Operation(Op), Label(L), Register(R), Offset(O), + Values(V.begin(), V.end()) { + assert(Op != OpRegister); + } - /// Utility function to emit the encoding to a streamer. - static void Emit(MCStreamer *MCOS, - int64_t LineDelta,uint64_t AddrDelta); - }; + MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R1, unsigned R2) + : Operation(Op), Label(L), Register(R1), Register2(R2) { + assert(Op == OpRegister); + } - class MCGenDwarfInfo { - public: - // - // When generating dwarf for assembly source files this emits the Dwarf - // sections. - // - static void Emit(MCStreamer *MCOS, const MCSymbol *LineSectionSymbol); - }; +public: + /// \brief .cfi_def_cfa defines a rule for computing CFA as: take address from + /// \param Register and add \param Offset to it. + static MCCFIInstruction createDefCfa(MCSymbol *L, unsigned Register, + int Offset) { + return MCCFIInstruction(OpDefCfa, L, Register, -Offset, ""); + } - // When generating dwarf for assembly source files this is the info that is - // needed to be gathered for each symbol that will have a dwarf label. - class MCGenDwarfLabelEntry { - private: - // Name of the symbol without a leading underbar, if any. - StringRef Name; - // The dwarf file number this symbol is in. - unsigned FileNumber; - // The line number this symbol is at. - unsigned LineNumber; - // The low_pc for the dwarf label is taken from this symbol. - MCSymbol *Label; - - public: - MCGenDwarfLabelEntry(StringRef name, unsigned fileNumber, - unsigned lineNumber, MCSymbol *label) : - Name(name), FileNumber(fileNumber), LineNumber(lineNumber), Label(label){} - - StringRef getName() const { return Name; } - unsigned getFileNumber() const { return FileNumber; } - unsigned getLineNumber() const { return LineNumber; } - MCSymbol *getLabel() const { return Label; } - - // This is called when label is created when we are generating dwarf for - // assembly source files. - static void Make(MCSymbol *Symbol, MCStreamer *MCOS, SourceMgr &SrcMgr, - SMLoc &Loc); - }; + /// \brief .cfi_def_cfa_register modifies a rule for computing CFA. From now + /// on \param Register will be used instead of the old one. Offset remains the + /// same. + static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register) { + return MCCFIInstruction(OpDefCfaRegister, L, Register, 0, ""); + } - class MCCFIInstruction { - public: - enum OpType { OpSameValue, OpRememberState, OpRestoreState, OpOffset, - OpDefCfaRegister, OpDefCfaOffset, OpDefCfa, OpRelOffset, - OpAdjustCfaOffset, OpEscape, OpRestore, OpUndefined, - OpRegister }; - private: - OpType Operation; - MCSymbol *Label; - unsigned Register; - union { - int Offset; - unsigned Register2; - }; - std::vector Values; - - MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R, int O, StringRef V) : - Operation(Op), Label(L), Register(R), Offset(O), - Values(V.begin(), V.end()) { - assert(Op != OpRegister); - } - - MCCFIInstruction(OpType Op, MCSymbol *L, unsigned R1, unsigned R2) : - Operation(Op), Label(L), Register(R1), Register2(R2) { - assert(Op == OpRegister); - } - - public: - static MCCFIInstruction - createOffset(MCSymbol *L, unsigned Register, int Offset) { - return MCCFIInstruction(OpOffset, L, Register, Offset, ""); - } - - static MCCFIInstruction - createDefCfaRegister(MCSymbol *L, unsigned Register) { - return MCCFIInstruction(OpDefCfaRegister, L, Register, 0, ""); - } - - static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset) { - return MCCFIInstruction(OpDefCfaOffset, L, 0, -Offset, ""); - } - - static MCCFIInstruction - createDefCfa(MCSymbol *L, unsigned Register, int Offset) { - return MCCFIInstruction(OpDefCfa, L, Register, -Offset, ""); - } - - static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register) { - return MCCFIInstruction(OpUndefined, L, Register, 0, ""); - } - - static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register) { - return MCCFIInstruction(OpRestore, L, Register, 0, ""); - } - - static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register) { - return MCCFIInstruction(OpSameValue, L, Register, 0, ""); - } - - static MCCFIInstruction createRestoreState(MCSymbol *L) { - return MCCFIInstruction(OpRestoreState, L, 0, 0, ""); - } - - static MCCFIInstruction createRememberState(MCSymbol *L) { - return MCCFIInstruction(OpRememberState, L, 0, 0, ""); - } - - static MCCFIInstruction - createRelOffset(MCSymbol *L, unsigned Register, int Offset) { - return MCCFIInstruction(OpRelOffset, L, Register, Offset, ""); - } - - static MCCFIInstruction - createAdjustCfaOffset(MCSymbol *L, int Adjustment) { - return MCCFIInstruction(OpAdjustCfaOffset, L, 0, Adjustment, ""); - } - - static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals) { - return MCCFIInstruction(OpEscape, L, 0, 0, Vals); - } - - static MCCFIInstruction - createRegister(MCSymbol *L, unsigned Register1, unsigned Register2) { - return MCCFIInstruction(OpRegister, L, Register1, Register2); - } - - OpType getOperation() const { return Operation; } - MCSymbol *getLabel() const { return Label; } - - unsigned getRegister() const { - assert(Operation == OpDefCfa || Operation == OpOffset || - Operation == OpRestore || Operation == OpUndefined || - Operation == OpSameValue || Operation == OpDefCfaRegister || - Operation == OpRelOffset || Operation == OpRegister); - return Register; - } - - unsigned getRegister2() const { - assert(Operation == OpRegister); - return Register2; - } - - int getOffset() const { - assert(Operation == OpDefCfa || Operation == OpOffset || - Operation == OpRelOffset || Operation == OpDefCfaOffset || - Operation == OpAdjustCfaOffset); - return Offset; - } - - const StringRef getValues() const { - assert(Operation == OpEscape); - return StringRef(&Values[0], Values.size()); - } - }; + /// \brief .cfi_def_cfa_offset modifies a rule for computing CFA. Register + /// remains the same, but offset is new. Note that it is the absolute offset + /// that will be added to a defined register to the compute CFA address. + static MCCFIInstruction createDefCfaOffset(MCSymbol *L, int Offset) { + return MCCFIInstruction(OpDefCfaOffset, L, 0, -Offset, ""); + } - struct MCDwarfFrameInfo { - MCDwarfFrameInfo() : Begin(0), End(0), Personality(0), Lsda(0), - Function(0), Instructions(), PersonalityEncoding(), - LsdaEncoding(0), CompactUnwindEncoding(0), - IsSignalFrame(false) {} - MCSymbol *Begin; - MCSymbol *End; - const MCSymbol *Personality; - const MCSymbol *Lsda; - const MCSymbol *Function; - std::vector Instructions; - unsigned PersonalityEncoding; - unsigned LsdaEncoding; - uint32_t CompactUnwindEncoding; - bool IsSignalFrame; - }; + /// \brief .cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but \param + /// Offset is a relative value that is added/subtracted from the previous + /// offset. + static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int Adjustment) { + return MCCFIInstruction(OpAdjustCfaOffset, L, 0, Adjustment, ""); + } - class MCDwarfFrameEmitter { - public: - // - // This emits the frame info section. - // - static void Emit(MCStreamer &streamer, bool usingCFI, - bool isEH); - static void EmitAdvanceLoc(MCStreamer &Streamer, uint64_t AddrDelta); - static void EncodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta, - raw_ostream &OS); - }; + /// \brief .cfi_offset Previous value of \param Register is saved at offset + /// \param Offset from CFA. + static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, + int Offset) { + return MCCFIInstruction(OpOffset, L, Register, Offset, ""); + } + + /// \brief .cfi_rel_offset Previous value of \param Register is saved at + /// offset \param Offset from the current CFA register. This is transformed to + /// .cfi_offset using the known displacement of the CFA register from the CFA. + static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register, + int Offset) { + return MCCFIInstruction(OpRelOffset, L, Register, Offset, ""); + } + + /// \brief .cfi_register Previous value of \param Register1 is saved in + /// register \param Register2. + static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, + unsigned Register2) { + return MCCFIInstruction(OpRegister, L, Register1, Register2); + } + + /// \brief .cfi_restore says that the rule for \param Register is now the same + /// as it was at the beginning of the function, after all initial instructions + /// added by .cfi_startproc were executed. + static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register) { + return MCCFIInstruction(OpRestore, L, Register, 0, ""); + } + + /// \brief .cfi_undefined From now on the previous value of \param Register + /// can't be restored anymore. + static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register) { + return MCCFIInstruction(OpUndefined, L, Register, 0, ""); + } + + /// \brief .cfi_same_value Current value of \param Register is the same as + /// in the previous frame. I.e., no restoration is needed. + static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register) { + return MCCFIInstruction(OpSameValue, L, Register, 0, ""); + } + + /// \brief .cfi_remember_state Save all current rules for all registers. + static MCCFIInstruction createRememberState(MCSymbol *L) { + return MCCFIInstruction(OpRememberState, L, 0, 0, ""); + } + + /// \brief .cfi_restore_state Restore the previously saved state. + static MCCFIInstruction createRestoreState(MCSymbol *L) { + return MCCFIInstruction(OpRestoreState, L, 0, 0, ""); + } + + /// \brief .cfi_escape Allows the user to add arbitrary bytes to the unwind + /// info. + static MCCFIInstruction createEscape(MCSymbol *L, StringRef Vals) { + return MCCFIInstruction(OpEscape, L, 0, 0, Vals); + } + + OpType getOperation() const { return Operation; } + MCSymbol *getLabel() const { return Label; } + + unsigned getRegister() const { + assert(Operation == OpDefCfa || Operation == OpOffset || + Operation == OpRestore || Operation == OpUndefined || + Operation == OpSameValue || Operation == OpDefCfaRegister || + Operation == OpRelOffset || Operation == OpRegister); + return Register; + } + + unsigned getRegister2() const { + assert(Operation == OpRegister); + return Register2; + } + + int getOffset() const { + assert(Operation == OpDefCfa || Operation == OpOffset || + Operation == OpRelOffset || Operation == OpDefCfaOffset || + Operation == OpAdjustCfaOffset); + return Offset; + } + + const StringRef getValues() const { + assert(Operation == OpEscape); + return StringRef(&Values[0], Values.size()); + } +}; + +struct MCDwarfFrameInfo { + MCDwarfFrameInfo() + : Begin(0), End(0), Personality(0), Lsda(0), Function(0), Instructions(), + PersonalityEncoding(), LsdaEncoding(0), CompactUnwindEncoding(0), + IsSignalFrame(false) {} + MCSymbol *Begin; + MCSymbol *End; + const MCSymbol *Personality; + const MCSymbol *Lsda; + const MCSymbol *Function; + std::vector Instructions; + unsigned PersonalityEncoding; + unsigned LsdaEncoding; + uint32_t CompactUnwindEncoding; + bool IsSignalFrame; +}; + +class MCDwarfFrameEmitter { +public: + // + // This emits the frame info section. + // + static void Emit(MCStreamer &streamer, bool usingCFI, bool isEH); + static void EmitAdvanceLoc(MCStreamer &Streamer, uint64_t AddrDelta); + static void EncodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta, + raw_ostream &OS); +}; } // end namespace llvm #endif -- cgit v1.1 From 79869ee59abc3aeebda6e15540273a7e5936adb4 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 3 Sep 2013 23:34:36 +0000 Subject: Add r159136 back now that pr13124 has been fixed. Original message: If a constant or a function has linkonce_odr linkage and unnamed_addr, mark hidden. Being linkonce_odr guarantees that it is available in every dso that needs it. Being a constant/function with unnamed_addr guarantees that the copies don't have to be merged. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189886 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/GlobalValue.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/GlobalValue.h b/include/llvm/IR/GlobalValue.h index 1dc99cf..a5049e4 100644 --- a/include/llvm/IR/GlobalValue.h +++ b/include/llvm/IR/GlobalValue.h @@ -122,6 +122,9 @@ public: static bool isAvailableExternallyLinkage(LinkageTypes Linkage) { return Linkage == AvailableExternallyLinkage; } + static bool isLinkOnceODRLinkage(LinkageTypes Linkage) { + return Linkage == LinkOnceODRLinkage; + } static bool isLinkOnceLinkage(LinkageTypes Linkage) { return Linkage == LinkOnceAnyLinkage || Linkage == LinkOnceODRLinkage || @@ -202,6 +205,9 @@ public: bool hasAvailableExternallyLinkage() const { return isAvailableExternallyLinkage(Linkage); } + bool hasLinkOnceODRLinkage() const { + return isLinkOnceODRLinkage(Linkage); + } bool hasLinkOnceLinkage() const { return isLinkOnceLinkage(Linkage); } -- cgit v1.1 From 06351cd0ff4146fa40ba9eb76bc10c5c6cb08616 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 4 Sep 2013 02:10:32 +0000 Subject: MCDwarf.h: Prune a few stray \param(s). [-Wdocumentation] \param should be used to describe individual parameters. Use a command like \a or \c for visual enhancements. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189905 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCDwarf.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCDwarf.h b/include/llvm/MC/MCDwarf.h index 5ca1be6..3366fc9 100644 --- a/include/llvm/MC/MCDwarf.h +++ b/include/llvm/MC/MCDwarf.h @@ -335,7 +335,7 @@ public: return MCCFIInstruction(OpDefCfaOffset, L, 0, -Offset, ""); } - /// \brief .cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but \param + /// \brief .cfi_adjust_cfa_offset Same as .cfi_def_cfa_offset, but /// Offset is a relative value that is added/subtracted from the previous /// offset. static MCCFIInstruction createAdjustCfaOffset(MCSymbol *L, int Adjustment) { @@ -357,8 +357,8 @@ public: return MCCFIInstruction(OpRelOffset, L, Register, Offset, ""); } - /// \brief .cfi_register Previous value of \param Register1 is saved in - /// register \param Register2. + /// \brief .cfi_register Previous value of Register1 is saved in + /// register Register2. static MCCFIInstruction createRegister(MCSymbol *L, unsigned Register1, unsigned Register2) { return MCCFIInstruction(OpRegister, L, Register1, Register2); -- cgit v1.1 From 886631cc2790cc0143966069e613d933914724b4 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Wed, 4 Sep 2013 05:08:32 +0000 Subject: Use Intrinsic::ID for the pattern match templates, fixing a signed/unsigned comparison warning. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189921 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/PatternMatch.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/PatternMatch.h b/include/llvm/Support/PatternMatch.h index b1732b2..240bb81 100644 --- a/include/llvm/Support/PatternMatch.h +++ b/include/llvm/Support/PatternMatch.h @@ -1041,7 +1041,7 @@ inline Argument_match m_Argument(const Opnd_t &Op) { /// Intrinsic matchers. struct IntrinsicID_match { unsigned ID; - IntrinsicID_match(unsigned IntrID) : ID(IntrID) { } + IntrinsicID_match(Intrinsic::ID IntrID) : ID(IntrID) { } template bool match(OpTy *V) { @@ -1080,29 +1080,29 @@ struct m_Intrinsic_Ty { /// Match intrinsic calls like this: /// m_Intrinsic(m_Value(X)) -template +template inline IntrinsicID_match m_Intrinsic() { return IntrinsicID_match(IntrID); } -template +template inline typename m_Intrinsic_Ty::Ty m_Intrinsic(const T0 &Op0) { return m_CombineAnd(m_Intrinsic(), m_Argument<0>(Op0)); } -template +template inline typename m_Intrinsic_Ty::Ty m_Intrinsic(const T0 &Op0, const T1 &Op1) { return m_CombineAnd(m_Intrinsic(Op0), m_Argument<1>(Op1)); } -template +template inline typename m_Intrinsic_Ty::Ty m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2) { return m_CombineAnd(m_Intrinsic(Op0, Op1), m_Argument<2>(Op2)); } -template +template inline typename m_Intrinsic_Ty::Ty m_Intrinsic(const T0 &Op0, const T1 &Op1, const T2 &Op2, const T3 &Op3) { return m_CombineAnd(m_Intrinsic(Op0, Op1, Op2), m_Argument<3>(Op3)); -- cgit v1.1 From 19fdc268c316b3b0bdcb2b558449819f4f402d6a Mon Sep 17 00:00:00 2001 From: Hao Liu Date: Wed, 4 Sep 2013 09:28:24 +0000 Subject: Inplement aarch64 neon instructions in AdvSIMD(shift). About 24 shift instructions: sshr,ushr,ssra,usra,srshr,urshr,srsra,ursra,sri,shl,sli,sqshlu,sqshl,uqshl,shrn,sqrshrun,sqshrn,uqshr,sqrshrn,uqrshrn,sshll,ushll and 4 convert instructions: scvtf,ucvtf,fcvtzs,fcvtzu git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189925 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 28 ++++++++++++++++++++++++++++ include/llvm/Target/TargetSelectionDAG.td | 2 ++ 2 files changed, 30 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index d7b1947..0a71ea4 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -38,4 +38,32 @@ def int_aarch64_neon_vpminnm : Neon_2Arg_Intrinsic; // Vector Multiply Extended (Floating Point) def int_aarch64_neon_vmulx : Neon_2Arg_Intrinsic; + +class Neon_N2V_Intrinsic + : Intrinsic<[llvm_anyvector_ty], [LLVMMatchType<0>, llvm_i32_ty], + [IntrNoMem]>; +class Neon_N3V_Intrinsic + : Intrinsic<[llvm_anyvector_ty], + [LLVMMatchType<0>, LLVMMatchType<0>, llvm_i32_ty], + [IntrNoMem]>; +class Neon_N2V_Narrow_Intrinsic + : Intrinsic<[llvm_anyvector_ty], + [LLVMExtendedElementVectorType<0>, llvm_i32_ty], + [IntrNoMem]>; + +// Vector rounding shift right by immediate (Signed) +def int_aarch64_neon_vsrshr : Neon_N2V_Intrinsic; +def int_aarch64_neon_vurshr : Neon_N2V_Intrinsic; +def int_aarch64_neon_vsqshlu : Neon_N2V_Intrinsic; + +def int_aarch64_neon_vsri : Neon_N3V_Intrinsic; +def int_aarch64_neon_vsli : Neon_N3V_Intrinsic; + +def int_aarch64_neon_vsqshrun : Neon_N2V_Narrow_Intrinsic; +def int_aarch64_neon_vrshrn : Neon_N2V_Narrow_Intrinsic; +def int_aarch64_neon_vsqrshrun : Neon_N2V_Narrow_Intrinsic; +def int_aarch64_neon_vsqshrn : Neon_N2V_Narrow_Intrinsic; +def int_aarch64_neon_vuqshrn : Neon_N2V_Narrow_Intrinsic; +def int_aarch64_neon_vsqrshrn : Neon_N2V_Narrow_Intrinsic; +def int_aarch64_neon_vuqrshrn : Neon_N2V_Narrow_Intrinsic; } diff --git a/include/llvm/Target/TargetSelectionDAG.td b/include/llvm/Target/TargetSelectionDAG.td index 72963da..d94bdc6 100644 --- a/include/llvm/Target/TargetSelectionDAG.td +++ b/include/llvm/Target/TargetSelectionDAG.td @@ -465,6 +465,8 @@ def vector_extract : SDNode<"ISD::EXTRACT_VECTOR_ELT", SDTypeProfile<1, 2, [SDTCisPtrTy<2>]>, []>; def vector_insert : SDNode<"ISD::INSERT_VECTOR_ELT", SDTypeProfile<1, 3, [SDTCisSameAs<0, 1>, SDTCisPtrTy<3>]>, []>; +def concat_vectors : SDNode<"ISD::CONCAT_VECTORS", + SDTypeProfile<1, 2, [SDTCisVec<0>, SDTCisVec<1>, SDTCisSameAs<1, 2>]>,[]>; // This operator does not do subvector type checking. The ARM // backend, at least, needs it. -- cgit v1.1 From 280e5eef43ecf2279ab78f132922920ed7ce7952 Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Wed, 4 Sep 2013 16:00:12 +0000 Subject: Move generic isPrint and columnWidth implementations to a separate header/source to allow using both generic and system-dependent versions on win32. Summary: This is needed so we can use generic columnWidthUTF8 in clang-format on win32 simultaneously with a separate system-dependent implementations of isPrint/columnWidth in TextDiagnostic.cpp to avoid attempts to print Unicode characters using narrow-character interfaces (which is not supported on Windows, and we'll have to figure out how to handle this). Reviewers: jordan_rose Reviewed By: jordan_rose CC: llvm-commits, klimek Differential Revision: http://llvm-reviews.chandlerc.com/D1559 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189952 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Unicode.h | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 include/llvm/Support/Unicode.h (limited to 'include') diff --git a/include/llvm/Support/Unicode.h b/include/llvm/Support/Unicode.h new file mode 100644 index 0000000..e6a52c4 --- /dev/null +++ b/include/llvm/Support/Unicode.h @@ -0,0 +1,62 @@ +//===- llvm/Support/Unicode.h - Unicode character properties -*- 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 functions that allow querying certain properties of Unicode +// characters. +// +//===----------------------------------------------------------------------===// + +#include "llvm/ADT/StringRef.h" + +namespace llvm { +namespace sys { +namespace unicode { + +enum ColumnWidthErrors { + ErrorInvalidUTF8 = -2, + ErrorNonPrintableCharacter = -1 +}; + +/// Determines if a character is likely to be displayed correctly on the +/// terminal. Exact implementation would have to depend on the specific +/// terminal, so we define the semantic that should be suitable for generic case +/// of a terminal capable to output Unicode characters. +/// +/// All characters from the Unicode code point range are considered printable +/// except for: +/// * C0 and C1 control character ranges; +/// * default ignorable code points as per 5.21 of +/// http://www.unicode.org/versions/Unicode6.2.0/UnicodeStandard-6.2.pdf +/// except for U+00AD SOFT HYPHEN, as it's actually displayed on most +/// terminals; +/// * format characters (category = Cf); +/// * surrogates (category = Cs); +/// * unassigned characters (category = Cn). +/// \return true if the character is considered printable. +bool isPrintable(int UCS); + +/// Gets the number of positions the UTF8-encoded \p Text is likely to occupy +/// when output on a terminal ("character width"). This depends on the +/// implementation of the terminal, and there's no standard definition of +/// character width. +/// +/// The implementation defines it in a way that is expected to be compatible +/// with a generic Unicode-capable terminal. +/// +/// \return Character width: +/// * ErrorNonPrintableCharacter (-1) if \p Text contains non-printable +/// characters (as identified by isPrintable); +/// * 0 for each non-spacing and enclosing combining mark; +/// * 2 for each CJK character excluding halfwidth forms; +/// * 1 for each of the remaining characters. +int columnWidthUTF8(StringRef Text); + +} // namespace unicode +} // namespace sys +} // namespace llvm -- cgit v1.1 From 9718158222ad9c52b2fb14609a341d4e24def8bb Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 4 Sep 2013 16:09:01 +0000 Subject: Revert "Add r159136 back now that pr13124 has been fixed." This reverts commit r189886. I found a corner case where this optimization is not valid: Say we have a "linkonce_odr unnamed_addr" in two translation units: * In TU 1 this optimization kicks in and makes it hidden. * In TU 2 it gets const merged with a constant that is *not* unnamed_addr, resulting in a non unnamed_addr constant with default visibility. * The static linker rules for combining visibility them produce a hidden symbol, which is incorrect from the point of view of the non unnamed_addr constant. The one place we can do this is when we know that the symbol is not used from another TU in the same shared object, i.e., during LTO. I will move it there. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189954 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/GlobalValue.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/GlobalValue.h b/include/llvm/IR/GlobalValue.h index a5049e4..1dc99cf 100644 --- a/include/llvm/IR/GlobalValue.h +++ b/include/llvm/IR/GlobalValue.h @@ -122,9 +122,6 @@ public: static bool isAvailableExternallyLinkage(LinkageTypes Linkage) { return Linkage == AvailableExternallyLinkage; } - static bool isLinkOnceODRLinkage(LinkageTypes Linkage) { - return Linkage == LinkOnceODRLinkage; - } static bool isLinkOnceLinkage(LinkageTypes Linkage) { return Linkage == LinkOnceAnyLinkage || Linkage == LinkOnceODRLinkage || @@ -205,9 +202,6 @@ public: bool hasAvailableExternallyLinkage() const { return isAvailableExternallyLinkage(Linkage); } - bool hasLinkOnceODRLinkage() const { - return isLinkOnceODRLinkage(Linkage); - } bool hasLinkOnceLinkage() const { return isLinkOnceLinkage(Linkage); } -- cgit v1.1 From ca7b43d01d963deafcc704389935f0f77dcfab0a Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 4 Sep 2013 18:48:12 +0000 Subject: Remove 'param' label from comments. They aren't used properly here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189970 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCDwarf.h | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCDwarf.h b/include/llvm/MC/MCDwarf.h index 3366fc9..c671dd9 100644 --- a/include/llvm/MC/MCDwarf.h +++ b/include/llvm/MC/MCDwarf.h @@ -315,15 +315,14 @@ private: public: /// \brief .cfi_def_cfa defines a rule for computing CFA as: take address from - /// \param Register and add \param Offset to it. + /// Register and add Offset to it. static MCCFIInstruction createDefCfa(MCSymbol *L, unsigned Register, int Offset) { return MCCFIInstruction(OpDefCfa, L, Register, -Offset, ""); } /// \brief .cfi_def_cfa_register modifies a rule for computing CFA. From now - /// on \param Register will be used instead of the old one. Offset remains the - /// same. + /// on Register will be used instead of the old one. Offset remains the same. static MCCFIInstruction createDefCfaRegister(MCSymbol *L, unsigned Register) { return MCCFIInstruction(OpDefCfaRegister, L, Register, 0, ""); } @@ -342,16 +341,16 @@ public: return MCCFIInstruction(OpAdjustCfaOffset, L, 0, Adjustment, ""); } - /// \brief .cfi_offset Previous value of \param Register is saved at offset - /// \param Offset from CFA. + /// \brief .cfi_offset Previous value of Register is saved at offset Offset + /// from CFA. static MCCFIInstruction createOffset(MCSymbol *L, unsigned Register, int Offset) { return MCCFIInstruction(OpOffset, L, Register, Offset, ""); } - /// \brief .cfi_rel_offset Previous value of \param Register is saved at - /// offset \param Offset from the current CFA register. This is transformed to - /// .cfi_offset using the known displacement of the CFA register from the CFA. + /// \brief .cfi_rel_offset Previous value of Register is saved at offset + /// Offset from the current CFA register. This is transformed to .cfi_offset + /// using the known displacement of the CFA register from the CFA. static MCCFIInstruction createRelOffset(MCSymbol *L, unsigned Register, int Offset) { return MCCFIInstruction(OpRelOffset, L, Register, Offset, ""); @@ -364,21 +363,21 @@ public: return MCCFIInstruction(OpRegister, L, Register1, Register2); } - /// \brief .cfi_restore says that the rule for \param Register is now the same - /// as it was at the beginning of the function, after all initial instructions - /// added by .cfi_startproc were executed. + /// \brief .cfi_restore says that the rule for Register is now the same as it + /// was at the beginning of the function, after all initial instructions added + /// by .cfi_startproc were executed. static MCCFIInstruction createRestore(MCSymbol *L, unsigned Register) { return MCCFIInstruction(OpRestore, L, Register, 0, ""); } - /// \brief .cfi_undefined From now on the previous value of \param Register - /// can't be restored anymore. + /// \brief .cfi_undefined From now on the previous value of Register can't be + /// restored anymore. static MCCFIInstruction createUndefined(MCSymbol *L, unsigned Register) { return MCCFIInstruction(OpUndefined, L, Register, 0, ""); } - /// \brief .cfi_same_value Current value of \param Register is the same as - /// in the previous frame. I.e., no restoration is needed. + /// \brief .cfi_same_value Current value of Register is the same as in the + /// previous frame. I.e., no restoration is needed. static MCCFIInstruction createSameValue(MCSymbol *L, unsigned Register) { return MCCFIInstruction(OpSameValue, L, Register, 0, ""); } -- cgit v1.1 From 775079c227083be3fe22f6ae071d5b74a7ade745 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 4 Sep 2013 20:08:46 +0000 Subject: Rename some variables to match the style guide. I am about to patch this code, and this makes the diff far more readable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189982 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/IPO.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Transforms/IPO.h b/include/llvm/Transforms/IPO.h index e6eb8d3..6ebb6c4 100644 --- a/include/llvm/Transforms/IPO.h +++ b/include/llvm/Transforms/IPO.h @@ -109,7 +109,7 @@ Pass *createPruneEHPass(); /// /// Note that commandline options that are used with the above function are not /// used now! -ModulePass *createInternalizePass(ArrayRef exportList); +ModulePass *createInternalizePass(ArrayRef ExportList); /// createInternalizePass - Same as above, but with an empty exportList. ModulePass *createInternalizePass(); -- cgit v1.1 From 42ebb3ad41813af292cfa681c1fe2aadd1008721 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Wed, 4 Sep 2013 20:59:59 +0000 Subject: Added -misched-regpressure option. Register pressure tracking is half the complexity of the scheduler. It's useful to be able to turn it off for compile time and performance comparisons. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189987 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineScheduler.h | 6 ++++-- include/llvm/CodeGen/RegisterPressure.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineScheduler.h b/include/llvm/CodeGen/MachineScheduler.h index 69c648c..e36ffdd 100644 --- a/include/llvm/CodeGen/MachineScheduler.h +++ b/include/llvm/CodeGen/MachineScheduler.h @@ -227,6 +227,7 @@ protected: PressureDiffs SUPressureDiffs; /// Register pressure in this region computed by initRegPressure. + bool ShouldTrackPressure; IntervalPressure RegPressure; RegPressureTracker RPTracker; @@ -259,8 +260,9 @@ public: ScheduleDAGMI(MachineSchedContext *C, MachineSchedStrategy *S): ScheduleDAGInstrs(*C->MF, *C->MLI, *C->MDT, /*IsPostRA=*/false, C->LIS), AA(C->AA), RegClassInfo(C->RegClassInfo), SchedImpl(S), DFSResult(0), - Topo(SUnits, &ExitSU), RPTracker(RegPressure), CurrentTop(), - TopRPTracker(TopPressure), CurrentBottom(), BotRPTracker(BotPressure), + Topo(SUnits, &ExitSU), ShouldTrackPressure(false), + RPTracker(RegPressure), CurrentTop(), TopRPTracker(TopPressure), + CurrentBottom(), BotRPTracker(BotPressure), NextClusterPred(NULL), NextClusterSucc(NULL) { #ifndef NDEBUG NumInstrsScheduled = 0; diff --git a/include/llvm/CodeGen/RegisterPressure.h b/include/llvm/CodeGen/RegisterPressure.h index 694d287..a890bb0 100644 --- a/include/llvm/CodeGen/RegisterPressure.h +++ b/include/llvm/CodeGen/RegisterPressure.h @@ -288,6 +288,8 @@ public: MF(0), TRI(0), RCI(0), LIS(0), MBB(0), P(rp), RequireIntervals(false), TrackUntiedDefs(false) {} + void reset(); + void init(const MachineFunction *mf, const RegisterClassInfo *rci, const LiveIntervals *lis, const MachineBasicBlock *mbb, MachineBasicBlock::const_iterator pos, -- cgit v1.1 From 40b52bb8f2b4f63f6d99e347af0c48945f9cb4d2 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Wed, 4 Sep 2013 21:00:02 +0000 Subject: mi-sched: bypass heuristic checks when regpressure tracking is disabled. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189988 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineScheduler.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineScheduler.h b/include/llvm/CodeGen/MachineScheduler.h index e36ffdd..4bee217 100644 --- a/include/llvm/CodeGen/MachineScheduler.h +++ b/include/llvm/CodeGen/MachineScheduler.h @@ -271,6 +271,9 @@ public: virtual ~ScheduleDAGMI(); + /// Return true if register pressure tracking is enabled. + bool shouldTrackPressure() const { return ShouldTrackPressure; } + /// Add a postprocessing step to the DAG builder. /// Mutations are applied in the order that they are added after normal DAG /// building and before MachineSchedStrategy initialization. -- cgit v1.1 From d1d0d37a198df718b0fd1f838b7d9593b1636299 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Wed, 4 Sep 2013 21:00:08 +0000 Subject: mi-sched: Load clustering is a bit to expensive to enable unconditionally. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189990 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetInstrInfo.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm/Target/TargetInstrInfo.h b/include/llvm/Target/TargetInstrInfo.h index f746daf..d92ad42 100644 --- a/include/llvm/Target/TargetInstrInfo.h +++ b/include/llvm/Target/TargetInstrInfo.h @@ -615,6 +615,8 @@ public: return false; } + virtual bool enableClusterLoads() const { return false; } + virtual bool shouldClusterLoads(MachineInstr *FirstLdSt, MachineInstr *SecondLdSt, unsigned NumLoads) const { -- cgit v1.1 From 16bb45c5c8e918efa732fd7d0b31c0f31dc2a979 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Wed, 4 Sep 2013 21:00:11 +0000 Subject: mi-sched: Suppress register pressure tracking when the scheduling window is too small. If the instruction window is < NumRegs/2, pressure tracking is not likely to be effective. The scheduler has to process a very large number of tiny blocks. We want this to be fast. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189991 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineScheduler.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineScheduler.h b/include/llvm/CodeGen/MachineScheduler.h index 4bee217..e3768bc 100644 --- a/include/llvm/CodeGen/MachineScheduler.h +++ b/include/llvm/CodeGen/MachineScheduler.h @@ -107,6 +107,10 @@ class MachineSchedStrategy { public: virtual ~MachineSchedStrategy() {} + /// Check if pressure tracking is needed before building the DAG and + /// initializing this strategy. + virtual bool shouldTrackPressure(unsigned NumRegionInstrs) { return true; } + /// Initialize the strategy after building the DAG for a new region. virtual void initialize(ScheduleDAGMI *DAG) = 0; @@ -271,8 +275,8 @@ public: virtual ~ScheduleDAGMI(); - /// Return true if register pressure tracking is enabled. - bool shouldTrackPressure() const { return ShouldTrackPressure; } + /// \brief Return true if register pressure tracking is enabled. + bool isTrackingPressure() const { return ShouldTrackPressure; } /// Add a postprocessing step to the DAG builder. /// Mutations are applied in the order that they are added after normal DAG -- cgit v1.1 From 5b34493843fee70dd0aba300466da2b020676d65 Mon Sep 17 00:00:00 2001 From: Nick Kledzik Date: Wed, 4 Sep 2013 23:27:21 +0000 Subject: fix typo in enum name git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190009 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/MachO.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/MachO.h b/include/llvm/Support/MachO.h index cc9651b..9d401c8 100644 --- a/include/llvm/Support/MachO.h +++ b/include/llvm/Support/MachO.h @@ -169,7 +169,7 @@ namespace llvm { S_THREAD_LOCAL_REGULAR = 0x11u, S_THREAD_LOCAL_ZEROFILL = 0x12u, S_THREAD_LOCAL_VARIABLES = 0x13u, - S_THREAD_LOCA_VARIABLE_POINTERS = 0x14u, + S_THREAD_LOCAL_VARIABLE_POINTERS = 0x14u, S_THREAD_LOCAL_INIT_FUNCTION_POINTERS = 0x15u }; -- cgit v1.1 From 5afaf5d1c1879d5cfbb3230dcb56297bd886bda4 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Wed, 4 Sep 2013 23:38:29 +0000 Subject: Move default dwarf version enum into the llvm dwarf constants rather than the spec dwarf constants. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190011 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index ab4b449..13bca8e 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -41,7 +41,7 @@ namespace dwarf { //===----------------------------------------------------------------------===// // Dwarf constants as gleaned from the DWARF Debugging Information Format V.4 -// reference manual http://dwarf.freestandards.org . +// reference manual http://dwarf.freestandards.org. // // Do not mix the following two enumerations sets. DW_TAG_invalid changes the @@ -56,6 +56,7 @@ enum llvm_dwarf_constants { DW_TAG_user_base = 0x1000, // Recommended base for user tags. + DWARF_VERSION = 4, // Default dwarf version we output. DW_CIE_VERSION = 1, // Common frame information version. DW_PUBTYPES_VERSION = 2, // Section version number for .debug_pubtypes. DW_PUBNAMES_VERSION = 2 // Section version number for .debug_pubnames. @@ -69,8 +70,6 @@ const uint64_t DW64_CIE_ID = UINT64_MAX; enum dwarf_constants { - DWARF_VERSION = 4, - // Tags DW_TAG_array_type = 0x01, DW_TAG_class_type = 0x02, -- cgit v1.1 From a38c27be0ff5dd35fcd20cfce827f9dbdb24d1ea Mon Sep 17 00:00:00 2001 From: Nick Kledzik Date: Wed, 4 Sep 2013 23:53:44 +0000 Subject: Add names for mach-o permissions bits and use the symbol names in place of magic numbers git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190013 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/MachO.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/llvm/Support/MachO.h b/include/llvm/Support/MachO.h index 9d401c8..59998ad 100644 --- a/include/llvm/Support/MachO.h +++ b/include/llvm/Support/MachO.h @@ -417,6 +417,15 @@ namespace llvm { X86_64_RELOC_TLV = 9 }; + // Values for segment_command.initprot. + // From + enum { + VM_PROT_READ = 0x1, + VM_PROT_WRITE = 0x2, + VM_PROT_EXECUTE = 0x4 + }; + + // Structs from struct mach_header { -- cgit v1.1 From 1aaf8843dc1c29f9dd9fa59cb507f7de924674dd Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 5 Sep 2013 00:01:17 +0000 Subject: Clean up some whitespace and comment formatting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190015 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index 13bca8e..7a8bad6 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -18,23 +18,22 @@ #include "llvm/Support/DataTypes.h" - namespace llvm { //===----------------------------------------------------------------------===// // Debug info constants. enum { - 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. + 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 { @@ -49,26 +48,24 @@ namespace dwarf { enum llvm_dwarf_constants { // llvm mock tags - DW_TAG_invalid = ~0U, // Tag for invalid results. + DW_TAG_invalid = ~0U, // Tag for invalid results. - DW_TAG_auto_variable = 0x100, // Tag for local (auto) variables. - DW_TAG_arg_variable = 0x101, // Tag for argument variables. + DW_TAG_auto_variable = 0x100, // Tag for local (auto) variables. + DW_TAG_arg_variable = 0x101, // Tag for argument variables. - DW_TAG_user_base = 0x1000, // Recommended base for user tags. + DW_TAG_user_base = 0x1000, // Recommended base for user tags. - DWARF_VERSION = 4, // Default dwarf version we output. - DW_CIE_VERSION = 1, // Common frame information version. - DW_PUBTYPES_VERSION = 2, // Section version number for .debug_pubtypes. - DW_PUBNAMES_VERSION = 2 // Section version number for .debug_pubnames. + DWARF_VERSION = 4, // Default dwarf version we output. + DW_CIE_VERSION = 1, // Common frame information version. + DW_PUBTYPES_VERSION = 2, // Section version number for .debug_pubtypes. + DW_PUBNAMES_VERSION = 2 // Section version number for .debug_pubnames. }; - // Special ID values that distinguish a CIE from a FDE in DWARF CFI. // Not inside an enum because a 64-bit value is needed. const uint32_t DW_CIE_ID = UINT32_MAX; const uint64_t DW64_CIE_ID = UINT64_MAX; - enum dwarf_constants { // Tags DW_TAG_array_type = 0x01, -- cgit v1.1 From c7c07f6e5595edd205f35acb452fbc4133ce2830 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Thu, 5 Sep 2013 06:53:59 +0000 Subject: Fix typos in assert message. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190034 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/FileSystem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/FileSystem.h b/include/llvm/Support/FileSystem.h index fb0eaeb..9d72a66 100644 --- a/include/llvm/Support/FileSystem.h +++ b/include/llvm/Support/FileSystem.h @@ -970,7 +970,7 @@ public: // modifiers /// Goes up one level if Level > 0. void pop() { - assert(State && "Cannot pop and end itertor!"); + assert(State && "Cannot pop an end iterator!"); assert(State->Level > 0 && "Cannot pop an iterator with level < 1"); const directory_iterator end_itr; -- cgit v1.1 From 4897151df698197f0eb5c4085545312dbb20c94d Mon Sep 17 00:00:00 2001 From: Joey Gouly Date: Thu, 5 Sep 2013 15:35:24 +0000 Subject: [ARMv8] Implement the new DMB/DSB operands. This removes the custom ISD Node: MEMBARRIER and replaces it with an intrinsic. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190055 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsARM.td | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsARM.td b/include/llvm/IR/IntrinsicsARM.td index e29a01b..80affe6 100644 --- a/include/llvm/IR/IntrinsicsARM.td +++ b/include/llvm/IR/IntrinsicsARM.td @@ -45,6 +45,11 @@ def int_arm_strexd : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, def int_arm_ldrexd : Intrinsic<[llvm_i32_ty, llvm_i32_ty], [llvm_ptr_ty]>; //===----------------------------------------------------------------------===// +// Data barrier instructions +def int_arm_dmb : Intrinsic<[], [llvm_i32_ty]>; +def int_arm_dsb : Intrinsic<[], [llvm_i32_ty]>; + +//===----------------------------------------------------------------------===// // VFP def int_arm_get_fpscr : GCCBuiltin<"__builtin_arm_get_fpscr">, -- cgit v1.1 From c65d2010084fe471e1e8b86d0cec1d051e5a524f Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 5 Sep 2013 16:55:35 +0000 Subject: Rename enums to match convention and remove superfluous "dwarf" in names. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190067 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index 7a8bad6..5a86dee 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -46,7 +46,7 @@ namespace dwarf { // Do not mix the following two enumerations sets. DW_TAG_invalid changes the // enumeration base type. -enum llvm_dwarf_constants { +enum LLVMConstants { // llvm mock tags DW_TAG_invalid = ~0U, // Tag for invalid results. @@ -66,7 +66,7 @@ enum llvm_dwarf_constants { const uint32_t DW_CIE_ID = UINT32_MAX; const uint64_t DW64_CIE_ID = UINT64_MAX; -enum dwarf_constants { +enum Constants { // Tags DW_TAG_array_type = 0x01, DW_TAG_class_type = 0x02, -- cgit v1.1 From 577056f89c840537b059ea4cef8d2ae18513cda0 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 5 Sep 2013 18:20:16 +0000 Subject: Move accelerator table defines and constants to Dwarf.h since we're proposing it for DWARF5. No functional change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190074 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index 5a86dee..91aef13 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -763,6 +763,32 @@ 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. + DW_ATOM_null = 0u, // Marker as the end of a list of atoms. + DW_ATOM_die_offset = 1u, // DIE offset in the debug_info section. + DW_ATOM_cu_offset = 2u, // Offset of the compile unit header that contains the + // item in question. + DW_ATOM_die_tag = 3u, // A tag entry. + DW_ATOM_type_flags = 4u, // Set of flags for a type. + + // DW_ATOM_type_flags values. + + // Always set for C++, only set for ObjC if this is the @implementation for a + // class. + DW_FLAG_type_implementation = 2u, + + // Hash functions. + + // Daniel J. Bernstein hash. + DW_hash_function_djb = 0u +}; + +/// AtomTypeString - Return the string for the specified Atom type. +const char *AtomTypeString(unsigned Atom); + } // End of namespace dwarf } // End of namespace llvm -- cgit v1.1 From bc66071baa3153ba95d673b8084383835221eef6 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Thu, 5 Sep 2013 18:48:31 +0000 Subject: Debug Info: Use identifier to reference DIType in base type field of ptr_to_member. We introduce a new class DITypeRef that represents a reference to a DIType. It wraps around a Value*, which can be either an identifier in MDString or an actual MDNode. The class has a helper function "resolve" that finds the actual MDNode for a given DITypeRef. We specialize getFieldAs to return a field that is a reference to a DIType. To correctly access the base type field of ptr_to_member, getClassType now calls getFieldAs to return a DITypeRef. Also add a typedef for DITypeIdentifierMap and a helper generateDITypeIdentifierMap in DebugInfo.h. In DwarfDebug.cpp, we keep a DITypeIdentifierMap and call generateDITypeIdentifierMap to actually populate the map. Verifier is updated accordingly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190081 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 87ccac1..997d01e 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -17,6 +17,7 @@ #ifndef LLVM_DEBUGINFO_H #define LLVM_DEBUGINFO_H +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" @@ -45,12 +46,19 @@ namespace llvm { class DILexicalBlockFile; class DIVariable; class DIType; + class DITypeRef; class DIObjCProperty; + /// Maps from type identifier to the actual MDNode. + typedef DenseMap DITypeIdentifierMap; + /// DIDescriptor - A thin wraper around MDNode to access encoded debug info. /// This should not be stored in a container, because the underlying MDNode /// may change in certain situations. class DIDescriptor { + // Befriends DITypeRef so DITypeRef can befriend the protected member + // function: getFieldAs. + friend class DITypeRef; public: enum { FlagPrivate = 1 << 0, @@ -143,6 +151,23 @@ namespace llvm { void dump() const; }; + /// Specialize getFieldAs to handle fields that are references to DITypes. + template <> + DITypeRef DIDescriptor::getFieldAs(unsigned Elt) const; + + /// Represents reference to a DIType, abstracts over direct and + /// identifier-based metadata type references. + class DITypeRef { + friend DITypeRef DIDescriptor::getFieldAs(unsigned Elt) const; + + /// TypeVal can be either a MDNode or a MDString, in the latter, + /// MDString specifies the type identifier. + const Value *TypeVal; + explicit DITypeRef(const Value *V); + public: + DIType resolve(const DITypeIdentifierMap &Map) const; + }; + /// DISubrange - This is used to represent ranges, for array bounds. class DISubrange : public DIDescriptor { friend class DIDescriptor; @@ -296,9 +321,9 @@ namespace llvm { /// associated with one. MDNode *getObjCProperty() const; - DIType getClassType() const { + DITypeRef getClassType() const { assert(getTag() == dwarf::DW_TAG_ptr_to_member_type); - return getFieldAs(10); + return getFieldAs(10); } Constant *getConstant() const { @@ -720,6 +745,9 @@ namespace llvm { /// cleanseInlinedVariable - Remove inlined scope from the variable. DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext); + /// Construct DITypeIdentifierMap by going through retained types of each CU. + DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes); + /// DebugInfoFinder tries to list all debug info MDNodes used in a module. To /// list debug info MDNodes used by an instruction, DebugInfoFinder uses /// processDeclare, processValue and processLocation to handle DbgDeclareInst, -- cgit v1.1 From 66bd6729e986ff3ebae8360503b0528e9f8b44e2 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Thu, 5 Sep 2013 19:44:52 +0000 Subject: Trying to un-break the bots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190092 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 997d01e..bbb2743 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -158,7 +158,8 @@ namespace llvm { /// Represents reference to a DIType, abstracts over direct and /// identifier-based metadata type references. class DITypeRef { - friend DITypeRef DIDescriptor::getFieldAs(unsigned Elt) const; + template + friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const; /// TypeVal can be either a MDNode or a MDString, in the latter, /// MDString specifies the type identifier. -- cgit v1.1 From 4598bd53ab89c3d120ad8249abbfdc7e2d64d291 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 6 Sep 2013 00:37:24 +0000 Subject: Use type helper functions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190113 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/DataLayout.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/DataLayout.h b/include/llvm/IR/DataLayout.h index 269edeb..25f7569 100644 --- a/include/llvm/IR/DataLayout.h +++ b/include/llvm/IR/DataLayout.h @@ -451,7 +451,7 @@ inline uint64_t DataLayout::getTypeSizeInBits(Type *Ty) const { case Type::LabelTyID: return getPointerSizeInBits(0); case Type::PointerTyID: - return getPointerSizeInBits(cast(Ty)->getAddressSpace()); + return getPointerSizeInBits(Ty->getPointerAddressSpace()); case Type::ArrayTyID: { ArrayType *ATy = cast(Ty); return ATy->getNumElements() * @@ -461,7 +461,7 @@ inline uint64_t DataLayout::getTypeSizeInBits(Type *Ty) const { // Get the layout annotation... which is lazily created on demand. return getStructLayout(cast(Ty))->getSizeInBits(); case Type::IntegerTyID: - return cast(Ty)->getBitWidth(); + return Ty->getIntegerBitWidth(); case Type::HalfTyID: return 16; case Type::FloatTyID: -- cgit v1.1 From 256cb9eaafef2aef81121be7542e04c40d9017cb Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Fri, 6 Sep 2013 16:19:22 +0000 Subject: fix typo in comment git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190165 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveInterval.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index 84323de..345f0dd 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -242,7 +242,7 @@ namespace llvm { /// unused values. void RenumberValues(); - /// MergeValueNumberInto - This method is called when two value nubmers + /// MergeValueNumberInto - This method is called when two value numbers /// are found to be equivalent. This eliminates V1, replacing all /// LiveRanges with the V1 value number with the V2 value number. This can /// cause merging of V1/V2 values numbers and compaction of the value space. -- cgit v1.1 From 1920156982643a1c5c28af6f4684580b516eb597 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Fri, 6 Sep 2013 16:44:29 +0000 Subject: remove unused argument from LiveRanges::join() git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190169 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveInterval.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index 345f0dd..24aad4f 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -370,8 +370,7 @@ namespace llvm { void join(LiveInterval &Other, const int *ValNoAssignments, const int *RHSValNoAssignments, - SmallVectorImpl &NewVNInfo, - MachineRegisterInfo *MRI); + SmallVectorImpl &NewVNInfo); /// True iff this live range is a single segment that lies between the /// specified boundaries, exclusively. Vregs live across a backedge are not -- cgit v1.1 From b63db853500b3dcb46a96af3f2d5aec003e41d77 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Fri, 6 Sep 2013 16:44:32 +0000 Subject: avoid unnecessary direct access to LiveInterval::ranges git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190170 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveInterval.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index 24aad4f..eb2030f 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -194,6 +194,10 @@ namespace llvm { ranges.clear(); } + size_t size() const { + return ranges.size(); + } + bool hasAtLeastOneValue() const { return !valnos.empty(); } bool containsOneValue() const { return valnos.size() == 1; } @@ -439,9 +443,9 @@ namespace llvm { private: - Ranges::iterator addRangeFrom(LiveRange LR, Ranges::iterator From); - void extendIntervalEndTo(Ranges::iterator I, SlotIndex NewEnd); - Ranges::iterator extendIntervalStartTo(Ranges::iterator I, SlotIndex NewStr); + iterator addRangeFrom(LiveRange LR, iterator From); + void extendIntervalEndTo(iterator I, SlotIndex NewEnd); + iterator extendIntervalStartTo(iterator I, SlotIndex NewStr); void markValNoForDeletion(VNInfo *V); LiveInterval& operator=(const LiveInterval& rhs) LLVM_DELETED_FUNCTION; -- cgit v1.1 From 38e61122f27a8ca4ef0578eaf6dc5242880d2918 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Fri, 6 Sep 2013 17:32:34 +0000 Subject: Added MachineSchedPolicy. Allow subtargets to customize the generic scheduling strategy. This is convenient for targets that don't need to add new heuristics by specializing the strategy. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190176 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineScheduler.h | 28 ++++++++++++++++++++++++++-- include/llvm/Target/TargetSubtargetInfo.h | 11 +++++++++++ 2 files changed, 37 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineScheduler.h b/include/llvm/CodeGen/MachineScheduler.h index e3768bc..18744e7 100644 --- a/include/llvm/CodeGen/MachineScheduler.h +++ b/include/llvm/CodeGen/MachineScheduler.h @@ -101,15 +101,39 @@ public: class ScheduleDAGMI; +/// Define a generic scheduling policy for targets that don't provide their own +/// MachineSchedStrategy. This can be overriden for each scheduling region +/// before building the DAG. +struct MachineSchedPolicy { + // Allow the scheduler to disable register pressure tracking. + bool ShouldTrackPressure; + + // Allow the scheduler to force top-down or bottom-up scheduling. If neither + // is true, the scheduler runs in both directions and converges. + bool OnlyTopDown; + bool OnlyBottomUp; + + MachineSchedPolicy(): + ShouldTrackPressure(false), OnlyTopDown(false), OnlyBottomUp(false) {} +}; + /// MachineSchedStrategy - Interface to the scheduling algorithm used by /// ScheduleDAGMI. +/// +/// Initialization sequence: +/// initPolicy -> shouldTrackPressure -> initialize(DAG) -> registerRoots class MachineSchedStrategy { public: virtual ~MachineSchedStrategy() {} + /// Optionally override the per-region scheduling policy. + virtual void initPolicy(MachineBasicBlock::iterator Begin, + MachineBasicBlock::iterator End, + unsigned NumRegionInstrs) {} + /// Check if pressure tracking is needed before building the DAG and - /// initializing this strategy. - virtual bool shouldTrackPressure(unsigned NumRegionInstrs) { return true; } + /// initializing this strategy. Called after initPolicy. + virtual bool shouldTrackPressure() const { return true; } /// Initialize the strategy after building the DAG for a new region. virtual void initialize(ScheduleDAGMI *DAG) = 0; diff --git a/include/llvm/Target/TargetSubtargetInfo.h b/include/llvm/Target/TargetSubtargetInfo.h index 2092aba..37365b2 100644 --- a/include/llvm/Target/TargetSubtargetInfo.h +++ b/include/llvm/Target/TargetSubtargetInfo.h @@ -25,6 +25,7 @@ class SDep; class SUnit; class TargetRegisterClass; class TargetSchedModel; +struct MachineSchedPolicy; template class SmallVectorImpl; //===----------------------------------------------------------------------===// @@ -62,6 +63,16 @@ public: /// scheduler. It does not yet disable the postRA scheduler. virtual bool enableMachineScheduler() const; + /// \brief Override generic scheduling policy within a region. + /// + /// This is a convenient way for targets that don't provide any custom + /// scheduling heuristics (no custom MachineSchedStrategy) to make + /// changes to the generic scheduling policy. + virtual void overrideSchedPolicy(MachineSchedPolicy &Policy, + MachineInstr *begin, + MachineInstr *end, + unsigned NumRegionInstrs) const {} + // enablePostRAScheduler - If the target can benefit from post-regalloc // scheduling and the specified optimization level meets the requirement // return true to enable post-register-allocation scheduling. In -- cgit v1.1 From fb386db636d134b0b72cf0a37075906cf8f7248c Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Fri, 6 Sep 2013 17:32:47 +0000 Subject: mi-sched: cleanup register pressure update, remove a FIXME. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190181 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineScheduler.h | 3 ++- include/llvm/CodeGen/RegisterPressure.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineScheduler.h b/include/llvm/CodeGen/MachineScheduler.h index 18744e7..2003297 100644 --- a/include/llvm/CodeGen/MachineScheduler.h +++ b/include/llvm/CodeGen/MachineScheduler.h @@ -413,7 +413,8 @@ protected: void updatePressureDiffs(ArrayRef LiveUses); - void updateScheduledPressure(const std::vector &NewMaxPressure); + void updateScheduledPressure(const SUnit *SU, + const std::vector &NewMaxPressure); bool checkSchedLimit(); diff --git a/include/llvm/CodeGen/RegisterPressure.h b/include/llvm/CodeGen/RegisterPressure.h index a890bb0..1db0b9f 100644 --- a/include/llvm/CodeGen/RegisterPressure.h +++ b/include/llvm/CodeGen/RegisterPressure.h @@ -145,6 +145,8 @@ public: typedef const PressureChange* const_iterator; iterator begin() { return &PressureChanges[0]; } iterator end() { return &PressureChanges[MaxPSets]; } + const_iterator begin() const { return &PressureChanges[0]; } + const_iterator end() const { return &PressureChanges[MaxPSets]; } void addPressureChange(unsigned RegUnit, bool IsDec, const MachineRegisterInfo *MRI); @@ -159,6 +161,8 @@ public: PressureDiffs(): PDiffArray(0), Size(0), Max(0) {} ~PressureDiffs() { free(PDiffArray); } + void clear() { Size = 0; } + void init(unsigned N); PressureDiff &operator[](unsigned Idx) { -- cgit v1.1 From 5930eabe0fdc48c02c5af500aa5b1c5b732848b1 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Fri, 6 Sep 2013 18:27:00 +0000 Subject: Debug Info: Move a helper function getTypeIdentifier from DIBuilder to be part of DIType. Implement DIType::generateRef to return a type reference. This function will be used in setContaintingType and in DIBuilder to generete the type reference. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190188 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index bbb2743..4d08ce9 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -155,20 +155,6 @@ namespace llvm { template <> DITypeRef DIDescriptor::getFieldAs(unsigned Elt) const; - /// Represents reference to a DIType, abstracts over direct and - /// identifier-based metadata type references. - class DITypeRef { - template - friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const; - - /// TypeVal can be either a MDNode or a MDString, in the latter, - /// MDString specifies the type identifier. - const Value *TypeVal; - explicit DITypeRef(const Value *V); - public: - DIType resolve(const DITypeIdentifierMap &Map) const; - }; - /// DISubrange - This is used to represent ranges, for array bounds. class DISubrange : public DIDescriptor { friend class DIDescriptor; @@ -285,12 +271,32 @@ namespace llvm { /// isUnsignedDIType - Return true if type encoding is unsigned. bool isUnsignedDIType(); + /// Generate a reference to this DIType. Uses the type identifier instead + /// of the actual MDNode if possible, to help type uniquing. + DITypeRef generateRef(); + /// replaceAllUsesWith - Replace all uses of debug info referenced by /// this descriptor. void replaceAllUsesWith(DIDescriptor &D); void replaceAllUsesWith(MDNode *D); }; + /// Represents reference to a DIType, abstracts over direct and + /// identifier-based metadata type references. + class DITypeRef { + template + friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const; + friend DITypeRef DIType::generateRef(); + + /// TypeVal can be either a MDNode or a MDString, in the latter, + /// MDString specifies the type identifier. + const Value *TypeVal; + explicit DITypeRef(const Value *V); + public: + DIType resolve(const DITypeIdentifierMap &Map) const; + operator Value *() const { return const_cast(TypeVal); } + }; + /// DIBasicType - A basic type, like 'int' or 'float'. class DIBasicType : public DIType { public: -- cgit v1.1 From e42279cda481b48138d2119f4a4bbce7077f0a72 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Fri, 6 Sep 2013 18:46:00 +0000 Subject: Debug Info: Use identifier to reference DIType in containing type field of a DICompositeType. Verifier is updated accordingly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190190 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 4d08ce9..42ec188 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -358,8 +358,8 @@ namespace llvm { void setTypeArray(DIArray Elements, DIArray TParams = DIArray()); void addMember(DIDescriptor D); unsigned getRunTimeLang() const { return getUnsignedField(11); } - DICompositeType getContainingType() const { - return getFieldAs(12); + DITypeRef getContainingType() const { + return getFieldAs(12); } void setContainingType(DICompositeType ContainingType); DIArray getTemplateParams() const { return getFieldAs(13); } -- cgit v1.1 From 0b3d39235aaed8bc66ccffb3942bf7b5f185329c Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Fri, 6 Sep 2013 22:47:05 +0000 Subject: TBAA: add isTBAAVtableAccess to MDNode so clients can call the function instead of having its own implementation. The implementation of isTBAAVtableAccess is in TypeBasedAliasAnalysis.cpp since it is related to the format of TBAA metadata. The path for struct-path tbaa will be exercised by test/Instrumentation/ThreadSanitizer/read_from_global.ll, vptr_read.ll, and vptr_update.ll when struct-path tbaa is on by default. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190216 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Metadata.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/Metadata.h b/include/llvm/IR/Metadata.h index acd84d7..49eb895 100644 --- a/include/llvm/IR/Metadata.h +++ b/include/llvm/IR/Metadata.h @@ -161,6 +161,9 @@ public: return V->getValueID() == MDNodeVal; } + /// Check whether MDNode is a vtable access. + bool isTBAAVtableAccess() const; + /// Methods for metadata merging. static MDNode *getMostGenericTBAA(MDNode *A, MDNode *B); static MDNode *getMostGenericFPMath(MDNode *A, MDNode *B); -- cgit v1.1 From 8b56ca61e1f174d08d78f5aab3c83633c48af3a5 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Fri, 6 Sep 2013 23:54:23 +0000 Subject: Debug Info: pass in VTableHolder as DIType instead of MDNode *. Remove one cast and improve readability. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190225 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DIBuilder.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/DIBuilder.h b/include/llvm/DIBuilder.h index d4dfadc..39ff317 100644 --- a/include/llvm/DIBuilder.h +++ b/include/llvm/DIBuilder.h @@ -17,6 +17,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" +#include "llvm/DebugInfo.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/ValueHandle.h" @@ -288,7 +289,7 @@ namespace llvm { uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, DIType DerivedFrom, DIArray Elements, - MDNode *VTableHolder = 0, + DIType VTableHolder = NULL, MDNode *TemplateParms = 0, StringRef UniqueIdentifier = StringRef()); @@ -308,7 +309,7 @@ namespace llvm { uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, DIType DerivedFrom, DIArray Elements, unsigned RunTimeLang = 0, - MDNode *VTableHolder = 0, + DIType VTableHolder = NULL, StringRef UniqueIdentifier = StringRef()); /// createUnionType - Create debugging information entry for an union. @@ -586,7 +587,7 @@ namespace llvm { DICompositeType Ty, bool isLocalToUnit, bool isDefinition, unsigned Virtuality = 0, unsigned VTableIndex = 0, - MDNode *VTableHolder = 0, + DIType VTableHolder = NULL, unsigned Flags = 0, bool isOptimized = false, Function *Fn = 0, -- cgit v1.1 From 0e85f6e391990cc20be98263640b843edfa32bef Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Sat, 7 Sep 2013 00:04:05 +0000 Subject: Debug Info: Use identifier to reference DIType in containing type field of a DISubprogram. Verifier is updated accordingly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190229 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 42ec188..a3a231b 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -426,8 +426,8 @@ namespace llvm { unsigned getVirtuality() const { return getUnsignedField(10); } unsigned getVirtualIndex() const { return getUnsignedField(11); } - DICompositeType getContainingType() const { - return getFieldAs(12); + DITypeRef getContainingType() const { + return getFieldAs(12); } unsigned getFlags() const { -- cgit v1.1 From baaefaf828beb3527a3554af99505822fd4dfabf Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sat, 7 Sep 2013 11:55:36 +0000 Subject: Run clang-format on these header files. Part of a WIP. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190250 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAsmBackend.h | 12 +- include/llvm/MC/MCStreamer.h | 1279 ++++++++++++++++++++-------------------- 2 files changed, 638 insertions(+), 653 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCAsmBackend.h b/include/llvm/MC/MCAsmBackend.h index 9a6b703..8027250 100644 --- a/include/llvm/MC/MCAsmBackend.h +++ b/include/llvm/MC/MCAsmBackend.h @@ -32,6 +32,7 @@ class raw_ostream; class MCAsmBackend { MCAsmBackend(const MCAsmBackend &) LLVM_DELETED_FUNCTION; void operator=(const MCAsmBackend &) LLVM_DELETED_FUNCTION; + protected: // Can only create subclasses. MCAsmBackend(); @@ -42,7 +43,7 @@ public: virtual ~MCAsmBackend(); /// lifetime management - virtual void reset() { } + virtual void reset() {} /// createObjectWriter - Create a new MCObjectWriter instance for use by the /// assembler backend to emit the final object file. @@ -50,7 +51,7 @@ public: /// createELFObjectTargetWriter - Create a new ELFObjectTargetWriter to enable /// non-standard ELFObjectWriters. - virtual MCELFObjectTargetWriter *createELFObjectTargetWriter() const { + virtual MCELFObjectTargetWriter *createELFObjectTargetWriter() const { llvm_unreachable("createELFObjectTargetWriter is not supported by asm " "backend"); } @@ -71,9 +72,7 @@ public: /// hasDataInCodeSupport - Check whether this target implements data-in-code /// markers. If not, data region directives will be ignored. - bool hasDataInCodeSupport() const { - return HasDataInCodeSupport; - } + bool hasDataInCodeSupport() const { return HasDataInCodeSupport; } /// doesSectionRequireSymbols - Check whether the given section requires that /// all symbols (even temporaries) have symbol table entries. @@ -128,8 +127,7 @@ public: /// fixupNeedsRelaxation - Target specific predicate for whether a given /// fixup requires the associated instruction to be relaxed. - virtual bool fixupNeedsRelaxation(const MCFixup &Fixup, - uint64_t Value, + virtual bool fixupNeedsRelaxation(const MCFixup &Fixup, uint64_t Value, const MCRelaxableFragment *DF, const MCAsmLayout &Layout) const = 0; diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 96b32cd..4aaaa35 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -24,675 +24,662 @@ #include namespace llvm { - class MCAsmBackend; - class MCCodeEmitter; - class MCContext; - class MCExpr; - class MCInst; - class MCInstPrinter; - class MCSection; - class MCSymbol; - class StringRef; - class Twine; - class raw_ostream; - class formatted_raw_ostream; - - typedef std::pair MCSectionSubPair; - - /// MCStreamer - Streaming machine code generation interface. This interface - /// is intended to provide a programatic interface that is very similar to the - /// level that an assembler .s file provides. It has callbacks to emit bytes, - /// handle directives, etc. The implementation of this interface retains - /// state to know what the current section is etc. - /// - /// There are multiple implementations of this interface: one for writing out - /// a .s file, and implementations that write out .o files of various formats. - /// - class MCStreamer { - public: - enum StreamerKind { - SK_AsmStreamer, - SK_NullStreamer, - SK_RecordStreamer, - - // MCObjectStreamer subclasses. - SK_ELFStreamer, - SK_ARMELFStreamer, - SK_MachOStreamer, - SK_PureStreamer, - SK_MipsELFStreamer, - SK_WinCOFFStreamer - }; - - private: - const StreamerKind Kind; - MCContext &Context; - - MCStreamer(const MCStreamer&) LLVM_DELETED_FUNCTION; - MCStreamer &operator=(const MCStreamer&) LLVM_DELETED_FUNCTION; - - bool EmitEHFrame; - bool EmitDebugFrame; - - std::vector FrameInfos; - MCDwarfFrameInfo *getCurrentFrameInfo(); - MCSymbol *EmitCFICommon(); - void EnsureValidFrame(); - - std::vector W64UnwindInfos; - MCWin64EHUnwindInfo *CurrentW64UnwindInfo; - void setCurrentW64UnwindInfo(MCWin64EHUnwindInfo *Frame); - void EnsureValidW64UnwindInfo(); - - MCSymbol* LastSymbol; - - /// SectionStack - This is stack of current and previous section - /// values saved by PushSection. - SmallVector, 4> SectionStack; - - bool AutoInitSections; - - protected: - MCStreamer(StreamerKind Kind, MCContext &Ctx); - - const MCExpr *BuildSymbolDiff(MCContext &Context, const MCSymbol *A, - const MCSymbol *B); - - const MCExpr *ForceExpAbs(const MCExpr* Expr); - - void RecordProcStart(MCDwarfFrameInfo &Frame); - virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame); - void RecordProcEnd(MCDwarfFrameInfo &Frame); - virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame); - void EmitFrames(bool usingCFI); - - MCWin64EHUnwindInfo *getCurrentW64UnwindInfo(){return CurrentW64UnwindInfo;} - void EmitW64Tables(); - - public: - virtual ~MCStreamer(); - - StreamerKind getKind() const { return Kind; } - - /// State management - /// - virtual void reset(); - - MCContext &getContext() const { return Context; } - - unsigned getNumFrameInfos() { - return FrameInfos.size(); - } +class MCAsmBackend; +class MCCodeEmitter; +class MCContext; +class MCExpr; +class MCInst; +class MCInstPrinter; +class MCSection; +class MCSymbol; +class StringRef; +class Twine; +class raw_ostream; +class formatted_raw_ostream; + +typedef std::pair MCSectionSubPair; + +/// MCStreamer - Streaming machine code generation interface. This interface +/// is intended to provide a programatic interface that is very similar to the +/// level that an assembler .s file provides. It has callbacks to emit bytes, +/// handle directives, etc. The implementation of this interface retains +/// state to know what the current section is etc. +/// +/// There are multiple implementations of this interface: one for writing out +/// a .s file, and implementations that write out .o files of various formats. +/// +class MCStreamer { +public: + enum StreamerKind { + SK_AsmStreamer, + SK_NullStreamer, + SK_RecordStreamer, + + // MCObjectStreamer subclasses. + SK_ELFStreamer, + SK_ARMELFStreamer, + SK_MachOStreamer, + SK_PureStreamer, + SK_MipsELFStreamer, + SK_WinCOFFStreamer + }; - const MCDwarfFrameInfo &getFrameInfo(unsigned i) { - return FrameInfos[i]; - } +private: + const StreamerKind Kind; + MCContext &Context; - ArrayRef getFrameInfos() { - return FrameInfos; - } + MCStreamer(const MCStreamer &) LLVM_DELETED_FUNCTION; + MCStreamer &operator=(const MCStreamer &) LLVM_DELETED_FUNCTION; - unsigned getNumW64UnwindInfos() { - return W64UnwindInfos.size(); - } + bool EmitEHFrame; + bool EmitDebugFrame; - MCWin64EHUnwindInfo &getW64UnwindInfo(unsigned i) { - return *W64UnwindInfos[i]; - } + std::vector FrameInfos; + MCDwarfFrameInfo *getCurrentFrameInfo(); + MCSymbol *EmitCFICommon(); + void EnsureValidFrame(); - /// @name Assembly File Formatting. - /// @{ - - /// isVerboseAsm - Return true if this streamer supports verbose assembly - /// and if it is enabled. - virtual bool isVerboseAsm() const { return false; } - - /// hasRawTextSupport - Return true if this asm streamer supports emitting - /// unformatted text to the .s file with EmitRawText. - virtual bool hasRawTextSupport() const { return false; } - - /// AddComment - Add a comment that can be emitted to the generated .s - /// file if applicable as a QoI issue to make the output of the compiler - /// more readable. This only affects the MCAsmStreamer, and only when - /// verbose assembly output is enabled. - /// - /// If the comment includes embedded \n's, they will each get the comment - /// prefix as appropriate. The added comment should not end with a \n. - virtual void AddComment(const Twine &T) {} - - /// GetCommentOS - Return a raw_ostream that comments can be written to. - /// Unlike AddComment, you are required to terminate comments with \n if you - /// use this method. - virtual raw_ostream &GetCommentOS(); - - /// AddBlankLine - Emit a blank line to a .s file to pretty it up. - virtual void AddBlankLine() {} - - /// @} - - /// @name Symbol & Section Management - /// @{ - - /// getCurrentSection - Return the current section that the streamer is - /// emitting code to. - MCSectionSubPair getCurrentSection() const { - if (!SectionStack.empty()) - return SectionStack.back().first; - return MCSectionSubPair(); - } + std::vector W64UnwindInfos; + MCWin64EHUnwindInfo *CurrentW64UnwindInfo; + void setCurrentW64UnwindInfo(MCWin64EHUnwindInfo *Frame); + void EnsureValidW64UnwindInfo(); - /// getPreviousSection - Return the previous section that the streamer is - /// emitting code to. - MCSectionSubPair getPreviousSection() const { - if (!SectionStack.empty()) - return SectionStack.back().second; - return MCSectionSubPair(); - } + MCSymbol *LastSymbol; - /// ChangeSection - Update streamer for a new active section. - /// - /// This is called by PopSection and SwitchSection, if the current - /// section changes. - virtual void ChangeSection(const MCSection *, const MCExpr *) = 0; - - /// pushSection - Save the current and previous section on the - /// section stack. - void PushSection() { - SectionStack.push_back(std::make_pair(getCurrentSection(), - getPreviousSection())); - } + /// SectionStack - This is stack of current and previous section + /// values saved by PushSection. + SmallVector, 4> SectionStack; - /// popSection - Restore the current and previous section from - /// the section stack. Calls ChangeSection as needed. - /// - /// Returns false if the stack was empty. - bool PopSection() { - if (SectionStack.size() <= 1) - return false; - MCSectionSubPair oldSection = SectionStack.pop_back_val().first; - MCSectionSubPair curSection = SectionStack.back().first; - - if (oldSection != curSection) - ChangeSection(curSection.first, curSection.second); - return true; - } + bool AutoInitSections; - bool SubSection(const MCExpr *Subsection) { - if (SectionStack.empty()) - return false; +protected: + MCStreamer(StreamerKind Kind, MCContext &Ctx); - SwitchSection(SectionStack.back().first.first, Subsection); - return true; - } + const MCExpr *BuildSymbolDiff(MCContext &Context, const MCSymbol *A, + const MCSymbol *B); - /// SwitchSection - Set the current section where code is being emitted to - /// @p Section. This is required to update CurSection. - /// - /// This corresponds to assembler directives like .section, .text, etc. - void SwitchSection(const MCSection *Section, const MCExpr *Subsection = 0) { - assert(Section && "Cannot switch to a null section!"); - MCSectionSubPair curSection = SectionStack.back().first; - SectionStack.back().second = curSection; - if (MCSectionSubPair(Section, Subsection) != curSection) { - SectionStack.back().first = MCSectionSubPair(Section, Subsection); - ChangeSection(Section, Subsection); - } - } + const MCExpr *ForceExpAbs(const MCExpr *Expr); - /// SwitchSectionNoChange - Set the current section where code is being - /// emitted to @p Section. This is required to update CurSection. This - /// version does not call ChangeSection. - void SwitchSectionNoChange(const MCSection *Section, - const MCExpr *Subsection = 0) { - assert(Section && "Cannot switch to a null section!"); - MCSectionSubPair curSection = SectionStack.back().first; - SectionStack.back().second = curSection; - if (MCSectionSubPair(Section, Subsection) != curSection) - SectionStack.back().first = MCSectionSubPair(Section, Subsection); - } + void RecordProcStart(MCDwarfFrameInfo &Frame); + virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame); + void RecordProcEnd(MCDwarfFrameInfo &Frame); + virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame); + void EmitFrames(bool usingCFI); - /// Initialize the streamer. - void InitStreamer() { - if (AutoInitSections) - InitSections(); - } + MCWin64EHUnwindInfo *getCurrentW64UnwindInfo() { + return CurrentW64UnwindInfo; + } + void EmitW64Tables(); - /// Tell this MCStreamer to call InitSections upon initialization. - void setAutoInitSections(bool AutoInitSections) { - this->AutoInitSections = AutoInitSections; - } +public: + virtual ~MCStreamer(); + + StreamerKind getKind() const { return Kind; } + + /// State management + /// + virtual void reset(); + + MCContext &getContext() const { return Context; } + + unsigned getNumFrameInfos() { return FrameInfos.size(); } + + const MCDwarfFrameInfo &getFrameInfo(unsigned i) { return FrameInfos[i]; } + + ArrayRef getFrameInfos() const { return FrameInfos; } + + unsigned getNumW64UnwindInfos() { return W64UnwindInfos.size(); } + + MCWin64EHUnwindInfo &getW64UnwindInfo(unsigned i) { + return *W64UnwindInfos[i]; + } - /// InitSections - Create the default sections and set the initial one. - virtual void InitSections() = 0; - - /// InitToTextSection - Create a text section and switch the streamer to it. - virtual void InitToTextSection() = 0; - - /// EmitLabel - Emit a label for @p Symbol into the current section. - /// - /// This corresponds to an assembler statement such as: - /// foo: - /// - /// @param Symbol - The symbol to emit. A given symbol should only be - /// emitted as a label once, and symbols emitted as a label should never be - /// used in an assignment. - virtual void EmitLabel(MCSymbol *Symbol); - - virtual void EmitDebugLabel(MCSymbol *Symbol); - - virtual void EmitEHSymAttributes(const MCSymbol *Symbol, - MCSymbol *EHSymbol); - - /// EmitAssemblerFlag - Note in the output the specified @p Flag. - virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) = 0; - - /// EmitLinkerOptions - Emit the given list @p Options of strings as linker - /// options into the output. - virtual void EmitLinkerOptions(ArrayRef Kind) {} - - /// EmitDataRegion - Note in the output the specified region @p Kind. - virtual void EmitDataRegion(MCDataRegionType Kind) {} - - /// EmitThumbFunc - Note in the output that the specified @p Func is - /// a Thumb mode function (ARM target only). - virtual void EmitThumbFunc(MCSymbol *Func) = 0; - - /// getOrCreateSymbolData - Get symbol data for given symbol. - virtual MCSymbolData &getOrCreateSymbolData(MCSymbol *Symbol); - - /// EmitAssignment - Emit an assignment of @p Value to @p Symbol. - /// - /// This corresponds to an assembler statement such as: - /// symbol = value - /// - /// The assignment generates no code, but has the side effect of binding the - /// value in the current context. For the assembly streamer, this prints the - /// binding into the .s file. - /// - /// @param Symbol - The symbol being assigned to. - /// @param Value - The value for the symbol. - virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) = 0; - - /// EmitWeakReference - Emit an weak reference from @p Alias to @p Symbol. - /// - /// This corresponds to an assembler statement such as: - /// .weakref alias, symbol - /// - /// @param Alias - The alias that is being created. - /// @param Symbol - The symbol being aliased. - virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) = 0; - - /// EmitSymbolAttribute - Add the given @p Attribute to @p Symbol. - virtual bool EmitSymbolAttribute(MCSymbol *Symbol, - MCSymbolAttr Attribute) = 0; - - /// EmitSymbolDesc - Set the @p DescValue for the @p Symbol. - /// - /// @param Symbol - The symbol to have its n_desc field set. - /// @param DescValue - The value to set into the n_desc field. - virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) = 0; - - /// BeginCOFFSymbolDef - Start emitting COFF symbol definition - /// - /// @param Symbol - The symbol to have its External & Type fields set. - virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) = 0; - - /// EmitCOFFSymbolStorageClass - Emit the storage class of the symbol. - /// - /// @param StorageClass - The storage class the symbol should have. - virtual void EmitCOFFSymbolStorageClass(int StorageClass) = 0; - - /// EmitCOFFSymbolType - Emit the type of the symbol. - /// - /// @param Type - A COFF type identifier (see COFF::SymbolType in X86COFF.h) - virtual void EmitCOFFSymbolType(int Type) = 0; - - /// EndCOFFSymbolDef - Marks the end of the symbol definition. - virtual void EndCOFFSymbolDef() = 0; - - /// EmitCOFFSecRel32 - Emits a COFF section relative relocation. - /// - /// @param Symbol - Symbol the section relative realocation should point to. - virtual void EmitCOFFSecRel32(MCSymbol const *Symbol); - - /// EmitELFSize - Emit an ELF .size directive. - /// - /// This corresponds to an assembler statement such as: - /// .size symbol, expression - /// - virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) = 0; - - /// EmitCommonSymbol - Emit a common symbol. - /// - /// @param Symbol - The common symbol to emit. - /// @param Size - The size of the common symbol. - /// @param ByteAlignment - The alignment of the symbol if - /// non-zero. This must be a power of 2. - virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) = 0; - - /// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol. - /// - /// @param Symbol - The common symbol to emit. - /// @param Size - The size of the common symbol. - /// @param ByteAlignment - The alignment of the common symbol in bytes. - virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, - unsigned ByteAlignment) = 0; - - /// EmitZerofill - Emit the zerofill section and an optional symbol. - /// - /// @param Section - The zerofill section to create and or to put the symbol - /// @param Symbol - The zerofill symbol to emit, if non-NULL. - /// @param Size - The size of the zerofill symbol. - /// @param ByteAlignment - The alignment of the zerofill symbol if - /// non-zero. This must be a power of 2 on some targets. - virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0, - uint64_t Size = 0,unsigned ByteAlignment = 0) = 0; - - /// EmitTBSSSymbol - Emit a thread local bss (.tbss) symbol. - /// - /// @param Section - The thread local common section. - /// @param Symbol - The thread local common symbol to emit. - /// @param Size - The size of the symbol. - /// @param ByteAlignment - The alignment of the thread local common symbol - /// if non-zero. This must be a power of 2 on some targets. - virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, - uint64_t Size, unsigned ByteAlignment = 0) = 0; - - /// @} - /// @name Generating Data - /// @{ - - /// EmitBytes - Emit the bytes in \p Data into the output. - /// - /// This is used to implement assembler directives such as .byte, .ascii, - /// etc. - virtual void EmitBytes(StringRef Data) = 0; - - /// EmitValue - Emit the expression @p Value into the output as a native - /// integer of the given @p Size bytes. - /// - /// This is used to implement assembler directives such as .word, .quad, - /// etc. - /// - /// @param Value - The value to emit. - /// @param Size - The size of the integer (in bytes) to emit. This must - /// match a native machine width. - virtual void EmitValueImpl(const MCExpr *Value, unsigned Size) = 0; - - void EmitValue(const MCExpr *Value, unsigned Size); - - /// EmitIntValue - Special case of EmitValue that avoids the client having - /// to pass in a MCExpr for constant integers. - virtual void EmitIntValue(uint64_t Value, unsigned Size); - - /// EmitAbsValue - Emit the Value, but try to avoid relocations. On MachO - /// this is done by producing - /// foo = value - /// .long foo - void EmitAbsValue(const MCExpr *Value, unsigned Size); - - virtual void EmitULEB128Value(const MCExpr *Value) = 0; - - virtual void EmitSLEB128Value(const MCExpr *Value) = 0; - - /// EmitULEB128Value - Special case of EmitULEB128Value that avoids the - /// client having to pass in a MCExpr for constant integers. - void EmitULEB128IntValue(uint64_t Value, unsigned Padding = 0); - - /// EmitSLEB128Value - Special case of EmitSLEB128Value that avoids the - /// client having to pass in a MCExpr for constant integers. - void EmitSLEB128IntValue(int64_t Value); - - /// EmitSymbolValue - Special case of EmitValue that avoids the client - /// having to pass in a MCExpr for MCSymbols. - void EmitSymbolValue(const MCSymbol *Sym, unsigned Size); - - /// EmitGPRel64Value - Emit the expression @p Value into the output as a - /// gprel64 (64-bit GP relative) value. - /// - /// This is used to implement assembler directives such as .gpdword on - /// targets that support them. - virtual void EmitGPRel64Value(const MCExpr *Value); - - /// EmitGPRel32Value - Emit the expression @p Value into the output as a - /// gprel32 (32-bit GP relative) value. - /// - /// This is used to implement assembler directives such as .gprel32 on - /// targets that support them. - virtual void EmitGPRel32Value(const MCExpr *Value); - - /// EmitFill - Emit NumBytes bytes worth of the value specified by - /// FillValue. This implements directives such as '.space'. - virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue); - - /// \brief Emit NumBytes worth of zeros. - /// This function properly handles data in virtual sections. - virtual void EmitZeros(uint64_t NumBytes); - - /// EmitValueToAlignment - Emit some number of copies of @p Value until - /// the byte alignment @p ByteAlignment is reached. - /// - /// If the number of bytes need to emit for the alignment is not a multiple - /// of @p ValueSize, then the contents of the emitted fill bytes is - /// undefined. - /// - /// This used to implement the .align assembler directive. - /// - /// @param ByteAlignment - The alignment to reach. This must be a power of - /// two on some targets. - /// @param Value - The value to use when filling bytes. - /// @param ValueSize - The size of the integer (in bytes) to emit for - /// @p Value. This must match a native machine width. - /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If - /// the alignment cannot be reached in this many bytes, no bytes are - /// emitted. - virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0, - unsigned ValueSize = 1, - unsigned MaxBytesToEmit = 0) = 0; - - /// EmitCodeAlignment - Emit nops until the byte alignment @p ByteAlignment - /// is reached. - /// - /// This used to align code where the alignment bytes may be executed. This - /// can emit different bytes for different sizes to optimize execution. - /// - /// @param ByteAlignment - The alignment to reach. This must be a power of - /// two on some targets. - /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If - /// the alignment cannot be reached in this many bytes, no bytes are - /// emitted. - virtual void EmitCodeAlignment(unsigned ByteAlignment, - unsigned MaxBytesToEmit = 0) = 0; - - /// EmitValueToOffset - Emit some number of copies of @p Value until the - /// byte offset @p Offset is reached. - /// - /// This is used to implement assembler directives such as .org. - /// - /// @param Offset - The offset to reach. This may be an expression, but the - /// expression must be associated with the current section. - /// @param Value - The value to use when filling bytes. - /// @return false on success, true if the offset was invalid. - virtual bool EmitValueToOffset(const MCExpr *Offset, - unsigned char Value = 0) = 0; - - /// @} - - /// EmitFileDirective - Switch to a new logical file. This is used to - /// implement the '.file "foo.c"' assembler directive. - virtual void EmitFileDirective(StringRef Filename) = 0; - - /// EmitDwarfFileDirective - Associate a filename with a specified logical - /// file number. This implements the DWARF2 '.file 4 "foo.c"' assembler - /// directive. - virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Directory, - StringRef Filename, unsigned CUID = 0); - - /// EmitDwarfLocDirective - This implements the DWARF2 - // '.loc fileno lineno ...' assembler directive. - virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line, - unsigned Column, unsigned Flags, - unsigned Isa, - unsigned Discriminator, - StringRef FileName); - - virtual void EmitDwarfAdvanceLineAddr(int64_t LineDelta, - const MCSymbol *LastLabel, - const MCSymbol *Label, - unsigned PointerSize) = 0; - - virtual void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel, - const MCSymbol *Label) { + /// @name Assembly File Formatting. + /// @{ + + /// isVerboseAsm - Return true if this streamer supports verbose assembly + /// and if it is enabled. + virtual bool isVerboseAsm() const { return false; } + + /// hasRawTextSupport - Return true if this asm streamer supports emitting + /// unformatted text to the .s file with EmitRawText. + virtual bool hasRawTextSupport() const { return false; } + + /// AddComment - Add a comment that can be emitted to the generated .s + /// file if applicable as a QoI issue to make the output of the compiler + /// more readable. This only affects the MCAsmStreamer, and only when + /// verbose assembly output is enabled. + /// + /// If the comment includes embedded \n's, they will each get the comment + /// prefix as appropriate. The added comment should not end with a \n. + virtual void AddComment(const Twine &T) {} + + /// GetCommentOS - Return a raw_ostream that comments can be written to. + /// Unlike AddComment, you are required to terminate comments with \n if you + /// use this method. + virtual raw_ostream &GetCommentOS(); + + /// AddBlankLine - Emit a blank line to a .s file to pretty it up. + virtual void AddBlankLine() {} + + /// @} + + /// @name Symbol & Section Management + /// @{ + + /// getCurrentSection - Return the current section that the streamer is + /// emitting code to. + MCSectionSubPair getCurrentSection() const { + if (!SectionStack.empty()) + return SectionStack.back().first; + return MCSectionSubPair(); + } + + /// getPreviousSection - Return the previous section that the streamer is + /// emitting code to. + MCSectionSubPair getPreviousSection() const { + if (!SectionStack.empty()) + return SectionStack.back().second; + return MCSectionSubPair(); + } + + /// ChangeSection - Update streamer for a new active section. + /// + /// This is called by PopSection and SwitchSection, if the current + /// section changes. + virtual void ChangeSection(const MCSection *, const MCExpr *) = 0; + + /// pushSection - Save the current and previous section on the + /// section stack. + void PushSection() { + SectionStack.push_back( + std::make_pair(getCurrentSection(), getPreviousSection())); + } + + /// popSection - Restore the current and previous section from + /// the section stack. Calls ChangeSection as needed. + /// + /// Returns false if the stack was empty. + bool PopSection() { + if (SectionStack.size() <= 1) + return false; + MCSectionSubPair oldSection = SectionStack.pop_back_val().first; + MCSectionSubPair curSection = SectionStack.back().first; + + if (oldSection != curSection) + ChangeSection(curSection.first, curSection.second); + return true; + } + + bool SubSection(const MCExpr *Subsection) { + if (SectionStack.empty()) + return false; + + SwitchSection(SectionStack.back().first.first, Subsection); + return true; + } + + /// SwitchSection - Set the current section where code is being emitted to + /// @p Section. This is required to update CurSection. + /// + /// This corresponds to assembler directives like .section, .text, etc. + void SwitchSection(const MCSection *Section, const MCExpr *Subsection = 0) { + assert(Section && "Cannot switch to a null section!"); + MCSectionSubPair curSection = SectionStack.back().first; + SectionStack.back().second = curSection; + if (MCSectionSubPair(Section, Subsection) != curSection) { + SectionStack.back().first = MCSectionSubPair(Section, Subsection); + ChangeSection(Section, Subsection); } + } + + /// SwitchSectionNoChange - Set the current section where code is being + /// emitted to @p Section. This is required to update CurSection. This + /// version does not call ChangeSection. + void SwitchSectionNoChange(const MCSection *Section, + const MCExpr *Subsection = 0) { + assert(Section && "Cannot switch to a null section!"); + MCSectionSubPair curSection = SectionStack.back().first; + SectionStack.back().second = curSection; + if (MCSectionSubPair(Section, Subsection) != curSection) + SectionStack.back().first = MCSectionSubPair(Section, Subsection); + } + + /// Initialize the streamer. + void InitStreamer() { + if (AutoInitSections) + InitSections(); + } + + /// Tell this MCStreamer to call InitSections upon initialization. + void setAutoInitSections(bool AutoInitSections) { + this->AutoInitSections = AutoInitSections; + } + + /// InitSections - Create the default sections and set the initial one. + virtual void InitSections() = 0; + + /// InitToTextSection - Create a text section and switch the streamer to it. + virtual void InitToTextSection() = 0; + + /// EmitLabel - Emit a label for @p Symbol into the current section. + /// + /// This corresponds to an assembler statement such as: + /// foo: + /// + /// @param Symbol - The symbol to emit. A given symbol should only be + /// emitted as a label once, and symbols emitted as a label should never be + /// used in an assignment. + virtual void EmitLabel(MCSymbol *Symbol); - void EmitDwarfSetLineAddr(int64_t LineDelta, const MCSymbol *Label, - int PointerSize); - - virtual void EmitCompactUnwindEncoding(uint32_t CompactUnwindEncoding); - virtual void EmitCFISections(bool EH, bool Debug); - void EmitCFIStartProc(); - void EmitCFIEndProc(); - virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset); - virtual void EmitCFIDefCfaOffset(int64_t Offset); - virtual void EmitCFIDefCfaRegister(int64_t Register); - virtual void EmitCFIOffset(int64_t Register, int64_t Offset); - virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding); - virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding); - virtual void EmitCFIRememberState(); - virtual void EmitCFIRestoreState(); - virtual void EmitCFISameValue(int64_t Register); - virtual void EmitCFIRestore(int64_t Register); - virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset); - virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment); - virtual void EmitCFIEscape(StringRef Values); - virtual void EmitCFISignalFrame(); - virtual void EmitCFIUndefined(int64_t Register); - virtual void EmitCFIRegister(int64_t Register1, int64_t Register2); - - virtual void EmitWin64EHStartProc(const MCSymbol *Symbol); - virtual void EmitWin64EHEndProc(); - virtual void EmitWin64EHStartChained(); - virtual void EmitWin64EHEndChained(); - virtual void EmitWin64EHHandler(const MCSymbol *Sym, bool Unwind, - bool Except); - virtual void EmitWin64EHHandlerData(); - virtual void EmitWin64EHPushReg(unsigned Register); - virtual void EmitWin64EHSetFrame(unsigned Register, unsigned Offset); - virtual void EmitWin64EHAllocStack(unsigned Size); - virtual void EmitWin64EHSaveReg(unsigned Register, unsigned Offset); - virtual void EmitWin64EHSaveXMM(unsigned Register, unsigned Offset); - virtual void EmitWin64EHPushFrame(bool Code); - virtual void EmitWin64EHEndProlog(); - - /// EmitInstruction - Emit the given @p Instruction into the current - /// section. - virtual void EmitInstruction(const MCInst &Inst) = 0; - - /// \brief Set the bundle alignment mode from now on in the section. - /// The argument is the power of 2 to which the alignment is set. The - /// value 0 means turn the bundle alignment off. - virtual void EmitBundleAlignMode(unsigned AlignPow2) = 0; - - /// \brief The following instructions are a bundle-locked group. - /// - /// \param AlignToEnd - If true, the bundle-locked group will be aligned to - /// the end of a bundle. - virtual void EmitBundleLock(bool AlignToEnd) = 0; - - /// \brief Ends a bundle-locked group. - virtual void EmitBundleUnlock() = 0; - - /// EmitRawText - If this file is backed by a assembly streamer, this dumps - /// the specified string in the output .s file. This capability is - /// indicated by the hasRawTextSupport() predicate. By default this aborts. - virtual void EmitRawText(StringRef String); - void EmitRawText(const Twine &String); - - /// ARM-related methods. - /// FIXME: Eventually we should have some "target MC streamer" and move - /// these methods there. - virtual void EmitFnStart(); - virtual void EmitFnEnd(); - virtual void EmitCantUnwind(); - virtual void EmitPersonality(const MCSymbol *Personality); - virtual void EmitHandlerData(); - virtual void EmitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset = 0); - virtual void EmitPad(int64_t Offset); - virtual void EmitRegSave(const SmallVectorImpl &RegList, - bool isVector); - - /// PPC-related methods. - /// FIXME: Eventually replace it with some "target MC streamer" and move - /// these methods there. - virtual void EmitTCEntry(const MCSymbol &S); - - /// FinishImpl - Streamer specific finalization. - virtual void FinishImpl() = 0; - /// Finish - Finish emission of machine code. - void Finish(); - }; + virtual void EmitDebugLabel(MCSymbol *Symbol); - /// createNullStreamer - Create a dummy machine code streamer, which does - /// nothing. This is useful for timing the assembler front end. - MCStreamer *createNullStreamer(MCContext &Ctx); - - /// createAsmStreamer - Create a machine code streamer which will print out - /// assembly for the native target, suitable for compiling with a native - /// assembler. - /// - /// \param InstPrint - If given, the instruction printer to use. If not given - /// the MCInst representation will be printed. This method takes ownership of - /// InstPrint. - /// - /// \param CE - If given, a code emitter to use to show the instruction - /// encoding inline with the assembly. This method takes ownership of \p CE. - /// - /// \param TAB - If given, a target asm backend to use to show the fixup - /// information in conjunction with encoding information. This method takes - /// ownership of \p TAB. - /// - /// \param ShowInst - Whether to show the MCInst representation inline with - /// the assembly. - MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS, - bool isVerboseAsm, - bool useLoc, - bool useCFI, - bool useDwarfDirectory, - MCInstPrinter *InstPrint = 0, - MCCodeEmitter *CE = 0, - MCAsmBackend *TAB = 0, - bool ShowInst = false); - - /// createMachOStreamer - Create a machine code streamer which will generate - /// Mach-O format object files. - /// - /// Takes ownership of \p TAB and \p CE. - MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB, - raw_ostream &OS, MCCodeEmitter *CE, - bool RelaxAll = false); + virtual void EmitEHSymAttributes(const MCSymbol *Symbol, MCSymbol *EHSymbol); + + /// EmitAssemblerFlag - Note in the output the specified @p Flag. + virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) = 0; - /// createWinCOFFStreamer - Create a machine code streamer which will - /// generate Microsoft COFF format object files. + /// EmitLinkerOptions - Emit the given list @p Options of strings as linker + /// options into the output. + virtual void EmitLinkerOptions(ArrayRef Kind) {} + + /// EmitDataRegion - Note in the output the specified region @p Kind. + virtual void EmitDataRegion(MCDataRegionType Kind) {} + + /// EmitThumbFunc - Note in the output that the specified @p Func is + /// a Thumb mode function (ARM target only). + virtual void EmitThumbFunc(MCSymbol *Func) = 0; + + /// getOrCreateSymbolData - Get symbol data for given symbol. + virtual MCSymbolData &getOrCreateSymbolData(MCSymbol *Symbol); + + /// EmitAssignment - Emit an assignment of @p Value to @p Symbol. + /// + /// This corresponds to an assembler statement such as: + /// symbol = value + /// + /// The assignment generates no code, but has the side effect of binding the + /// value in the current context. For the assembly streamer, this prints the + /// binding into the .s file. /// - /// Takes ownership of \p TAB and \p CE. - MCStreamer *createWinCOFFStreamer(MCContext &Ctx, - MCAsmBackend &TAB, - MCCodeEmitter &CE, raw_ostream &OS, - bool RelaxAll = false); + /// @param Symbol - The symbol being assigned to. + /// @param Value - The value for the symbol. + virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) = 0; - /// createELFStreamer - Create a machine code streamer which will generate - /// ELF format object files. - MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB, - raw_ostream &OS, MCCodeEmitter *CE, - bool RelaxAll, bool NoExecStack); + /// EmitWeakReference - Emit an weak reference from @p Alias to @p Symbol. + /// + /// This corresponds to an assembler statement such as: + /// .weakref alias, symbol + /// + /// @param Alias - The alias that is being created. + /// @param Symbol - The symbol being aliased. + virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) = 0; + + /// EmitSymbolAttribute - Add the given @p Attribute to @p Symbol. + virtual bool EmitSymbolAttribute(MCSymbol *Symbol, + MCSymbolAttr Attribute) = 0; + + /// EmitSymbolDesc - Set the @p DescValue for the @p Symbol. + /// + /// @param Symbol - The symbol to have its n_desc field set. + /// @param DescValue - The value to set into the n_desc field. + virtual void EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) = 0; + + /// BeginCOFFSymbolDef - Start emitting COFF symbol definition + /// + /// @param Symbol - The symbol to have its External & Type fields set. + virtual void BeginCOFFSymbolDef(const MCSymbol *Symbol) = 0; + + /// EmitCOFFSymbolStorageClass - Emit the storage class of the symbol. + /// + /// @param StorageClass - The storage class the symbol should have. + virtual void EmitCOFFSymbolStorageClass(int StorageClass) = 0; + + /// EmitCOFFSymbolType - Emit the type of the symbol. + /// + /// @param Type - A COFF type identifier (see COFF::SymbolType in X86COFF.h) + virtual void EmitCOFFSymbolType(int Type) = 0; + + /// EndCOFFSymbolDef - Marks the end of the symbol definition. + virtual void EndCOFFSymbolDef() = 0; + + /// EmitCOFFSecRel32 - Emits a COFF section relative relocation. + /// + /// @param Symbol - Symbol the section relative realocation should point to. + virtual void EmitCOFFSecRel32(MCSymbol const *Symbol); + + /// EmitELFSize - Emit an ELF .size directive. + /// + /// This corresponds to an assembler statement such as: + /// .size symbol, expression + /// + virtual void EmitELFSize(MCSymbol *Symbol, const MCExpr *Value) = 0; + + /// EmitCommonSymbol - Emit a common symbol. + /// + /// @param Symbol - The common symbol to emit. + /// @param Size - The size of the common symbol. + /// @param ByteAlignment - The alignment of the symbol if + /// non-zero. This must be a power of 2. + virtual void EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size, + unsigned ByteAlignment) = 0; + + /// EmitLocalCommonSymbol - Emit a local common (.lcomm) symbol. + /// + /// @param Symbol - The common symbol to emit. + /// @param Size - The size of the common symbol. + /// @param ByteAlignment - The alignment of the common symbol in bytes. + virtual void EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size, + unsigned ByteAlignment) = 0; + + /// EmitZerofill - Emit the zerofill section and an optional symbol. + /// + /// @param Section - The zerofill section to create and or to put the symbol + /// @param Symbol - The zerofill symbol to emit, if non-NULL. + /// @param Size - The size of the zerofill symbol. + /// @param ByteAlignment - The alignment of the zerofill symbol if + /// non-zero. This must be a power of 2 on some targets. + virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0, + uint64_t Size = 0, unsigned ByteAlignment = 0) = 0; + + /// EmitTBSSSymbol - Emit a thread local bss (.tbss) symbol. + /// + /// @param Section - The thread local common section. + /// @param Symbol - The thread local common symbol to emit. + /// @param Size - The size of the symbol. + /// @param ByteAlignment - The alignment of the thread local common symbol + /// if non-zero. This must be a power of 2 on some targets. + virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol, + uint64_t Size, unsigned ByteAlignment = 0) = 0; + + /// @} + /// @name Generating Data + /// @{ + + /// EmitBytes - Emit the bytes in \p Data into the output. + /// + /// This is used to implement assembler directives such as .byte, .ascii, + /// etc. + virtual void EmitBytes(StringRef Data) = 0; - /// createPureStreamer - Create a machine code streamer which will generate - /// "pure" MC object files, for use with MC-JIT and testing tools. + /// EmitValue - Emit the expression @p Value into the output as a native + /// integer of the given @p Size bytes. + /// + /// This is used to implement assembler directives such as .word, .quad, + /// etc. /// - /// Takes ownership of \p TAB and \p CE. - MCStreamer *createPureStreamer(MCContext &Ctx, MCAsmBackend &TAB, - raw_ostream &OS, MCCodeEmitter *CE); + /// @param Value - The value to emit. + /// @param Size - The size of the integer (in bytes) to emit. This must + /// match a native machine width. + virtual void EmitValueImpl(const MCExpr *Value, unsigned Size) = 0; + + void EmitValue(const MCExpr *Value, unsigned Size); + + /// EmitIntValue - Special case of EmitValue that avoids the client having + /// to pass in a MCExpr for constant integers. + virtual void EmitIntValue(uint64_t Value, unsigned Size); + + /// EmitAbsValue - Emit the Value, but try to avoid relocations. On MachO + /// this is done by producing + /// foo = value + /// .long foo + void EmitAbsValue(const MCExpr *Value, unsigned Size); + + virtual void EmitULEB128Value(const MCExpr *Value) = 0; + + virtual void EmitSLEB128Value(const MCExpr *Value) = 0; + + /// EmitULEB128Value - Special case of EmitULEB128Value that avoids the + /// client having to pass in a MCExpr for constant integers. + void EmitULEB128IntValue(uint64_t Value, unsigned Padding = 0); + + /// EmitSLEB128Value - Special case of EmitSLEB128Value that avoids the + /// client having to pass in a MCExpr for constant integers. + void EmitSLEB128IntValue(int64_t Value); + + /// EmitSymbolValue - Special case of EmitValue that avoids the client + /// having to pass in a MCExpr for MCSymbols. + void EmitSymbolValue(const MCSymbol *Sym, unsigned Size); + + /// EmitGPRel64Value - Emit the expression @p Value into the output as a + /// gprel64 (64-bit GP relative) value. + /// + /// This is used to implement assembler directives such as .gpdword on + /// targets that support them. + virtual void EmitGPRel64Value(const MCExpr *Value); + + /// EmitGPRel32Value - Emit the expression @p Value into the output as a + /// gprel32 (32-bit GP relative) value. + /// + /// This is used to implement assembler directives such as .gprel32 on + /// targets that support them. + virtual void EmitGPRel32Value(const MCExpr *Value); + + /// EmitFill - Emit NumBytes bytes worth of the value specified by + /// FillValue. This implements directives such as '.space'. + virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue); + + /// \brief Emit NumBytes worth of zeros. + /// This function properly handles data in virtual sections. + virtual void EmitZeros(uint64_t NumBytes); + + /// EmitValueToAlignment - Emit some number of copies of @p Value until + /// the byte alignment @p ByteAlignment is reached. + /// + /// If the number of bytes need to emit for the alignment is not a multiple + /// of @p ValueSize, then the contents of the emitted fill bytes is + /// undefined. + /// + /// This used to implement the .align assembler directive. + /// + /// @param ByteAlignment - The alignment to reach. This must be a power of + /// two on some targets. + /// @param Value - The value to use when filling bytes. + /// @param ValueSize - The size of the integer (in bytes) to emit for + /// @p Value. This must match a native machine width. + /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If + /// the alignment cannot be reached in this many bytes, no bytes are + /// emitted. + virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0, + unsigned ValueSize = 1, + unsigned MaxBytesToEmit = 0) = 0; + + /// EmitCodeAlignment - Emit nops until the byte alignment @p ByteAlignment + /// is reached. + /// + /// This used to align code where the alignment bytes may be executed. This + /// can emit different bytes for different sizes to optimize execution. + /// + /// @param ByteAlignment - The alignment to reach. This must be a power of + /// two on some targets. + /// @param MaxBytesToEmit - The maximum numbers of bytes to emit, or 0. If + /// the alignment cannot be reached in this many bytes, no bytes are + /// emitted. + virtual void EmitCodeAlignment(unsigned ByteAlignment, + unsigned MaxBytesToEmit = 0) = 0; + + /// EmitValueToOffset - Emit some number of copies of @p Value until the + /// byte offset @p Offset is reached. + /// + /// This is used to implement assembler directives such as .org. + /// + /// @param Offset - The offset to reach. This may be an expression, but the + /// expression must be associated with the current section. + /// @param Value - The value to use when filling bytes. + /// @return false on success, true if the offset was invalid. + virtual bool EmitValueToOffset(const MCExpr *Offset, + unsigned char Value = 0) = 0; + + /// @} + + /// EmitFileDirective - Switch to a new logical file. This is used to + /// implement the '.file "foo.c"' assembler directive. + virtual void EmitFileDirective(StringRef Filename) = 0; + + /// EmitDwarfFileDirective - Associate a filename with a specified logical + /// file number. This implements the DWARF2 '.file 4 "foo.c"' assembler + /// directive. + virtual bool EmitDwarfFileDirective(unsigned FileNo, StringRef Directory, + StringRef Filename, unsigned CUID = 0); + + /// EmitDwarfLocDirective - This implements the DWARF2 + // '.loc fileno lineno ...' assembler directive. + virtual void EmitDwarfLocDirective(unsigned FileNo, unsigned Line, + unsigned Column, unsigned Flags, + unsigned Isa, unsigned Discriminator, + StringRef FileName); + + virtual void EmitDwarfAdvanceLineAddr(int64_t LineDelta, + const MCSymbol *LastLabel, + const MCSymbol *Label, + unsigned PointerSize) = 0; + + virtual void EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel, + const MCSymbol *Label) {} + + void EmitDwarfSetLineAddr(int64_t LineDelta, const MCSymbol *Label, + int PointerSize); + + virtual void EmitCompactUnwindEncoding(uint32_t CompactUnwindEncoding); + virtual void EmitCFISections(bool EH, bool Debug); + void EmitCFIStartProc(); + void EmitCFIEndProc(); + virtual void EmitCFIDefCfa(int64_t Register, int64_t Offset); + virtual void EmitCFIDefCfaOffset(int64_t Offset); + virtual void EmitCFIDefCfaRegister(int64_t Register); + virtual void EmitCFIOffset(int64_t Register, int64_t Offset); + virtual void EmitCFIPersonality(const MCSymbol *Sym, unsigned Encoding); + virtual void EmitCFILsda(const MCSymbol *Sym, unsigned Encoding); + virtual void EmitCFIRememberState(); + virtual void EmitCFIRestoreState(); + virtual void EmitCFISameValue(int64_t Register); + virtual void EmitCFIRestore(int64_t Register); + virtual void EmitCFIRelOffset(int64_t Register, int64_t Offset); + virtual void EmitCFIAdjustCfaOffset(int64_t Adjustment); + virtual void EmitCFIEscape(StringRef Values); + virtual void EmitCFISignalFrame(); + virtual void EmitCFIUndefined(int64_t Register); + virtual void EmitCFIRegister(int64_t Register1, int64_t Register2); + + virtual void EmitWin64EHStartProc(const MCSymbol *Symbol); + virtual void EmitWin64EHEndProc(); + virtual void EmitWin64EHStartChained(); + virtual void EmitWin64EHEndChained(); + virtual void EmitWin64EHHandler(const MCSymbol *Sym, bool Unwind, + bool Except); + virtual void EmitWin64EHHandlerData(); + virtual void EmitWin64EHPushReg(unsigned Register); + virtual void EmitWin64EHSetFrame(unsigned Register, unsigned Offset); + virtual void EmitWin64EHAllocStack(unsigned Size); + virtual void EmitWin64EHSaveReg(unsigned Register, unsigned Offset); + virtual void EmitWin64EHSaveXMM(unsigned Register, unsigned Offset); + virtual void EmitWin64EHPushFrame(bool Code); + virtual void EmitWin64EHEndProlog(); + + /// EmitInstruction - Emit the given @p Instruction into the current + /// section. + virtual void EmitInstruction(const MCInst &Inst) = 0; + + /// \brief Set the bundle alignment mode from now on in the section. + /// The argument is the power of 2 to which the alignment is set. The + /// value 0 means turn the bundle alignment off. + virtual void EmitBundleAlignMode(unsigned AlignPow2) = 0; + + /// \brief The following instructions are a bundle-locked group. + /// + /// \param AlignToEnd - If true, the bundle-locked group will be aligned to + /// the end of a bundle. + virtual void EmitBundleLock(bool AlignToEnd) = 0; + + /// \brief Ends a bundle-locked group. + virtual void EmitBundleUnlock() = 0; + + /// EmitRawText - If this file is backed by a assembly streamer, this dumps + /// the specified string in the output .s file. This capability is + /// indicated by the hasRawTextSupport() predicate. By default this aborts. + virtual void EmitRawText(StringRef String); + void EmitRawText(const Twine &String); + + /// ARM-related methods. + /// FIXME: Eventually we should have some "target MC streamer" and move + /// these methods there. + virtual void EmitFnStart(); + virtual void EmitFnEnd(); + virtual void EmitCantUnwind(); + virtual void EmitPersonality(const MCSymbol *Personality); + virtual void EmitHandlerData(); + virtual void EmitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset = 0); + virtual void EmitPad(int64_t Offset); + virtual void EmitRegSave(const SmallVectorImpl &RegList, + bool isVector); + + /// PPC-related methods. + /// FIXME: Eventually replace it with some "target MC streamer" and move + /// these methods there. + virtual void EmitTCEntry(const MCSymbol &S); + + /// FinishImpl - Streamer specific finalization. + virtual void FinishImpl() = 0; + /// Finish - Finish emission of machine code. + void Finish(); +}; + +/// createNullStreamer - Create a dummy machine code streamer, which does +/// nothing. This is useful for timing the assembler front end. +MCStreamer *createNullStreamer(MCContext &Ctx); + +/// createAsmStreamer - Create a machine code streamer which will print out +/// assembly for the native target, suitable for compiling with a native +/// assembler. +/// +/// \param InstPrint - If given, the instruction printer to use. If not given +/// the MCInst representation will be printed. This method takes ownership of +/// InstPrint. +/// +/// \param CE - If given, a code emitter to use to show the instruction +/// encoding inline with the assembly. This method takes ownership of \p CE. +/// +/// \param TAB - If given, a target asm backend to use to show the fixup +/// information in conjunction with encoding information. This method takes +/// ownership of \p TAB. +/// +/// \param ShowInst - Whether to show the MCInst representation inline with +/// the assembly. +MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS, + bool isVerboseAsm, bool useLoc, bool useCFI, + bool useDwarfDirectory, + MCInstPrinter *InstPrint = 0, + MCCodeEmitter *CE = 0, MCAsmBackend *TAB = 0, + bool ShowInst = false); + +/// createMachOStreamer - Create a machine code streamer which will generate +/// Mach-O format object files. +/// +/// Takes ownership of \p TAB and \p CE. +MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB, + raw_ostream &OS, MCCodeEmitter *CE, + bool RelaxAll = false); + +/// createWinCOFFStreamer - Create a machine code streamer which will +/// generate Microsoft COFF format object files. +/// +/// Takes ownership of \p TAB and \p CE. +MCStreamer *createWinCOFFStreamer(MCContext &Ctx, MCAsmBackend &TAB, + MCCodeEmitter &CE, raw_ostream &OS, + bool RelaxAll = false); + +/// createELFStreamer - Create a machine code streamer which will generate +/// ELF format object files. +MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB, + raw_ostream &OS, MCCodeEmitter *CE, bool RelaxAll, + bool NoExecStack); + +/// createPureStreamer - Create a machine code streamer which will generate +/// "pure" MC object files, for use with MC-JIT and testing tools. +/// +/// Takes ownership of \p TAB and \p CE. +MCStreamer *createPureStreamer(MCContext &Ctx, MCAsmBackend &TAB, + raw_ostream &OS, MCCodeEmitter *CE); } // end namespace llvm -- cgit v1.1 From d372889eabcd10a9d8ce8fe9a4b2678d3a51d823 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Sun, 8 Sep 2013 04:07:59 +0000 Subject: Debug Info: pass in DIScope instead of DIDescriptor in createMemberType. Improve readability. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190269 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DIBuilder.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/DIBuilder.h b/include/llvm/DIBuilder.h index 39ff317..00fcdab 100644 --- a/include/llvm/DIBuilder.h +++ b/include/llvm/DIBuilder.h @@ -191,7 +191,7 @@ namespace llvm { /// @param Flags Flags to encode member attribute, e.g. private /// @param Ty Parent type. DIDerivedType - createMemberType(DIDescriptor Scope, StringRef Name, DIFile File, + createMemberType(DIScope Scope, StringRef Name, DIFile File, unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, DIType Ty); -- cgit v1.1 From c7a25acefa43adba6623b2cc5b456151531dc7f4 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Sun, 8 Sep 2013 06:02:56 +0000 Subject: Revert r190269 to fix dragonegg failures. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190271 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DIBuilder.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/DIBuilder.h b/include/llvm/DIBuilder.h index 00fcdab..39ff317 100644 --- a/include/llvm/DIBuilder.h +++ b/include/llvm/DIBuilder.h @@ -191,7 +191,7 @@ namespace llvm { /// @param Flags Flags to encode member attribute, e.g. private /// @param Ty Parent type. DIDerivedType - createMemberType(DIScope Scope, StringRef Name, DIFile File, + createMemberType(DIDescriptor Scope, StringRef Name, DIFile File, unsigned LineNo, uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, DIType Ty); -- cgit v1.1 From c3cee57f7d20f69a84fd88464ed8cf050e63c7ad Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 9 Sep 2013 02:37:14 +0000 Subject: Generate compact unwind encoding from CFI directives. We used to generate the compact unwind encoding from the machine instructions. However, this had the problem that if the user used `-save-temps' or compiled their hand-written `.s' file (with CFI directives), we wouldn't generate the compact unwind encoding. Move the algorithm that generates the compact unwind encoding into the MCAsmBackend. This way we can generate the encoding whether the code is from a `.ll' or `.s' file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190290 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAsmBackend.h | 8 ++++++++ include/llvm/MC/MCStreamer.h | 2 ++ include/llvm/Support/TargetRegistry.h | 13 ++++++++----- 3 files changed, 18 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCAsmBackend.h b/include/llvm/MC/MCAsmBackend.h index 8027250..27aaba9 100644 --- a/include/llvm/MC/MCAsmBackend.h +++ b/include/llvm/MC/MCAsmBackend.h @@ -10,7 +10,9 @@ #ifndef LLVM_MC_MCASMBACKEND_H #define LLVM_MC_MCASMBACKEND_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/MC/MCDirectives.h" +#include "llvm/MC/MCDwarf.h" #include "llvm/MC/MCFixup.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/ErrorHandling.h" @@ -158,6 +160,12 @@ public: /// handleAssemblerFlag - Handle any target-specific assembler flags. /// By default, do nothing. virtual void handleAssemblerFlag(MCAssemblerFlag Flag) {} + + /// \brief Generate the compact unwind encoding for the CFI instructions. + virtual unsigned + generateCompactUnwindEncoding(ArrayRef) const { + return 0; + } }; } // End llvm namespace diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 4aaaa35..c849e59 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -134,6 +134,8 @@ public: return *W64UnwindInfos[i]; } + void generateCompactUnwindEncodings(MCAsmBackend &MAB); + /// @name Assembly File Formatting. /// @{ diff --git a/include/llvm/Support/TargetRegistry.h b/include/llvm/Support/TargetRegistry.h index 109b3a2..9282853 100644 --- a/include/llvm/Support/TargetRegistry.h +++ b/include/llvm/Support/TargetRegistry.h @@ -104,6 +104,7 @@ namespace llvm { typedef AsmPrinter *(*AsmPrinterCtorTy)(TargetMachine &TM, MCStreamer &Streamer); typedef MCAsmBackend *(*MCAsmBackendCtorTy)(const Target &T, + const MCRegisterInfo &MRI, StringRef TT, StringRef CPU); typedef MCTargetAsmParser *(*MCAsmParserCtorTy)(MCSubtargetInfo &STI, @@ -373,10 +374,11 @@ namespace llvm { /// createMCAsmBackend - Create a target specific assembly parser. /// /// \param Triple The target triple string. - MCAsmBackend *createMCAsmBackend(StringRef Triple, StringRef CPU) const { + MCAsmBackend *createMCAsmBackend(const MCRegisterInfo &MRI, + StringRef Triple, StringRef CPU) const { if (!MCAsmBackendCtorFn) return 0; - return MCAsmBackendCtorFn(*this, Triple, CPU); + return MCAsmBackendCtorFn(*this, MRI, Triple, CPU); } /// createMCAsmParser - Create a target specific assembly parser. @@ -1118,9 +1120,10 @@ namespace llvm { } private: - static MCAsmBackend *Allocator(const Target &T, StringRef Triple, - StringRef CPU) { - return new MCAsmBackendImpl(T, Triple, CPU); + static MCAsmBackend *Allocator(const Target &T, + const MCRegisterInfo &MRI, + StringRef Triple, StringRef CPU) { + return new MCAsmBackendImpl(T, MRI, Triple, CPU); } }; -- cgit v1.1 From c573305bce147df68051a6dffef034c6210ab89c Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Mon, 9 Sep 2013 19:03:51 +0000 Subject: Debug Info: Rename DITypeRef to DIScopeRef. A reference to a scope is more general than a reference to a type since DIType is a subclass of DIScope. A reference to a type can be either an identifier for the type or the DIType itself, while a reference to a scope can be either an identifier for the type (when the scope is indeed a type) or the DIScope itself. A reference to a type and a reference to a scope will be resolved in the same way. The only difference is in the verifier when a field is a reference to a type (i.e. the containing type field of a DICompositeType) or a field is a reference to a scope (i.e. the context field of a DIType). This is to get ready for switching DIType::getContext to return DIScopeRef instead of DIScope. Tighten up isTypeRef and isScopeRef to make sure the identifier is not empty and the MDNode is DIType for TypeRef and DIScope for ScopeRef. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190322 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 63 ++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 32 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index a3a231b..e8cc793 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -46,7 +46,7 @@ namespace llvm { class DILexicalBlockFile; class DIVariable; class DIType; - class DITypeRef; + class DIScopeRef; class DIObjCProperty; /// Maps from type identifier to the actual MDNode. @@ -56,9 +56,9 @@ namespace llvm { /// This should not be stored in a container, because the underlying MDNode /// may change in certain situations. class DIDescriptor { - // Befriends DITypeRef so DITypeRef can befriend the protected member - // function: getFieldAs. - friend class DITypeRef; + // Befriends DIScopeRef so DIScopeRef can befriend the protected member + // function: getFieldAs. + friend class DIScopeRef; public: enum { FlagPrivate = 1 << 0, @@ -151,9 +151,9 @@ namespace llvm { void dump() const; }; - /// Specialize getFieldAs to handle fields that are references to DITypes. + /// npecialize getFieldAs to handle fields that are references to DIScopes. template <> - DITypeRef DIDescriptor::getFieldAs(unsigned Elt) const; + DIScopeRef DIDescriptor::getFieldAs(unsigned Elt) const; /// DISubrange - This is used to represent ranges, for array bounds. class DISubrange : public DIDescriptor { @@ -205,6 +205,25 @@ namespace llvm { DIScope getContext() const; StringRef getFilename() const; StringRef getDirectory() const; + + /// Generate a reference to this DIScope. Uses the type identifier instead + /// of the actual MDNode if possible, to help type uniquing. + Value *generateRef(); + }; + + /// Represents reference to a DIScope, abstracts over direct and + /// identifier-based metadata scope references. + class DIScopeRef { + template + friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const; + + /// Val can be either a MDNode or a MDString, in the latter, + /// MDString specifies the type identifier. + const Value *Val; + explicit DIScopeRef(const Value *V); + public: + DIScope resolve(const DITypeIdentifierMap &Map) const; + operator Value *() const { return const_cast(Val); } }; /// DIType - This is a wrapper for a type. @@ -271,32 +290,12 @@ namespace llvm { /// isUnsignedDIType - Return true if type encoding is unsigned. bool isUnsignedDIType(); - /// Generate a reference to this DIType. Uses the type identifier instead - /// of the actual MDNode if possible, to help type uniquing. - DITypeRef generateRef(); - /// replaceAllUsesWith - Replace all uses of debug info referenced by /// this descriptor. void replaceAllUsesWith(DIDescriptor &D); void replaceAllUsesWith(MDNode *D); }; - /// Represents reference to a DIType, abstracts over direct and - /// identifier-based metadata type references. - class DITypeRef { - template - friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const; - friend DITypeRef DIType::generateRef(); - - /// TypeVal can be either a MDNode or a MDString, in the latter, - /// MDString specifies the type identifier. - const Value *TypeVal; - explicit DITypeRef(const Value *V); - public: - DIType resolve(const DITypeIdentifierMap &Map) const; - operator Value *() const { return const_cast(TypeVal); } - }; - /// DIBasicType - A basic type, like 'int' or 'float'. class DIBasicType : public DIType { public: @@ -328,9 +327,9 @@ namespace llvm { /// associated with one. MDNode *getObjCProperty() const; - DITypeRef getClassType() const { + DIScopeRef getClassType() const { assert(getTag() == dwarf::DW_TAG_ptr_to_member_type); - return getFieldAs(10); + return getFieldAs(10); } Constant *getConstant() const { @@ -358,8 +357,8 @@ namespace llvm { void setTypeArray(DIArray Elements, DIArray TParams = DIArray()); void addMember(DIDescriptor D); unsigned getRunTimeLang() const { return getUnsignedField(11); } - DITypeRef getContainingType() const { - return getFieldAs(12); + DIScopeRef getContainingType() const { + return getFieldAs(12); } void setContainingType(DICompositeType ContainingType); DIArray getTemplateParams() const { return getFieldAs(13); } @@ -426,8 +425,8 @@ namespace llvm { unsigned getVirtuality() const { return getUnsignedField(10); } unsigned getVirtualIndex() const { return getUnsignedField(11); } - DITypeRef getContainingType() const { - return getFieldAs(12); + DIScopeRef getContainingType() const { + return getFieldAs(12); } unsigned getFlags() const { -- cgit v1.1 From 02d296759cd53f2d6081fd307c4d81cc41f2c9ed Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Mon, 9 Sep 2013 19:05:21 +0000 Subject: Debug Info: Move isSubprogramContext from DebugInfo to DwarfDebug. This helper function needs the type identifier map when we switch DIType::getContext to return DIScopeRef instead of DIScope. Since isSubprogramContext is used by DwarfDebug only, We move it to DwarfDebug to have easy access to the map. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190325 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index e8cc793..df9c0c7 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -729,10 +729,6 @@ namespace llvm { /// getDICompositeType - Find underlying composite type. DICompositeType getDICompositeType(DIType T); - /// isSubprogramContext - Return true if Context is either a subprogram - /// or another context nested inside a subprogram. - bool isSubprogramContext(const MDNode *Context); - /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable /// to hold function specific information. NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP); -- cgit v1.1 From db3a9e64f856e3a233a427da1f3969fd3a65a438 Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Mon, 9 Sep 2013 19:14:35 +0000 Subject: Revert patches to add case-range support for PR1255. The work on this project was left in an unfinished and inconsistent state. Hopefully someone will eventually get a chance to implement this feature, but in the meantime, it is better to put things back the way the were. I have left support in the bitcode reader to handle the case-range bitcode format, so that we do not lose bitcode compatibility with the llvm 3.3 release. This reverts the following commits: 155464, 156374, 156377, 156613, 156704, 156757, 156804 156808, 156985, 157046, 157112, 157183, 157315, 157384, 157575, 157576, 157586, 157612, 157810, 157814, 157815, 157880, 157881, 157882, 157884, 157887, 157901, 158979, 157987, 157989, 158986, 158997, 159076, 159101, 159100, 159200, 159201, 159207, 159527, 159532, 159540, 159583, 159618, 159658, 159659, 159660, 159661, 159703, 159704, 160076, 167356, 172025, 186736 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190328 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Instructions.h | 358 ++++++---------- include/llvm/Support/IntegersSubset.h | 540 ------------------------ include/llvm/Support/IntegersSubsetMapping.h | 588 --------------------------- 3 files changed, 121 insertions(+), 1365 deletions(-) delete mode 100644 include/llvm/Support/IntegersSubset.h delete mode 100644 include/llvm/Support/IntegersSubsetMapping.h (limited to 'include') diff --git a/include/llvm/IR/Instructions.h b/include/llvm/IR/Instructions.h index e05c3a8..6adee6a 100644 --- a/include/llvm/IR/Instructions.h +++ b/include/llvm/IR/Instructions.h @@ -23,8 +23,6 @@ #include "llvm/IR/DerivedTypes.h" #include "llvm/IR/InstrTypes.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/IntegersSubset.h" -#include "llvm/Support/IntegersSubsetMapping.h" #include namespace llvm { @@ -2457,31 +2455,10 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BranchInst, Value) class SwitchInst : public TerminatorInst { void *operator new(size_t, unsigned) LLVM_DELETED_FUNCTION; unsigned ReservedSpace; - // Operands format: // Operand[0] = Value to switch on // Operand[1] = Default basic block destination // Operand[2n ] = Value to match // Operand[2n+1] = BasicBlock to go to on match - - // Store case values separately from operands list. We needn't User-Use - // concept here, since it is just a case value, it will always constant, - // and case value couldn't reused with another instructions/values. - // Additionally: - // It allows us to use custom type for case values that is not inherited - // from Value. Since case value is a complex type that implements - // the subset of integers, we needn't extract sub-constants within - // slow getAggregateElement method. - // For case values we will use std::list to by two reasons: - // 1. It allows to add/remove cases without whole collection reallocation. - // 2. In most of cases we needn't random access. - // Currently case values are also stored in Operands List, but it will moved - // out in future commits. - typedef std::list Subsets; - typedef Subsets::iterator SubsetsIt; - typedef Subsets::const_iterator SubsetsConstIt; - - Subsets TheSubsets; - SwitchInst(const SwitchInst &SI); void init(Value *Value, BasicBlock *Default, unsigned NumReserved); void growOperands(); @@ -2506,25 +2483,121 @@ protected: virtual SwitchInst *clone_impl() const; public: - // FIXME: Currently there are a lot of unclean template parameters, - // we need to make refactoring in future. - // All these parameters are used to implement both iterator and const_iterator - // without code duplication. - // SwitchInstTy may be "const SwitchInst" or "SwitchInst" - // ConstantIntTy may be "const ConstantInt" or "ConstantInt" - // SubsetsItTy may be SubsetsConstIt or SubsetsIt - // BasicBlockTy may be "const BasicBlock" or "BasicBlock" - template - class CaseIteratorT; - - typedef CaseIteratorT ConstCaseIt; - class CaseIt; - // -2 static const unsigned DefaultPseudoIndex = static_cast(~0L-1); + template + class CaseIteratorT { + protected: + + SwitchInstTy *SI; + unsigned Index; + + public: + + typedef CaseIteratorT Self; + + /// Initializes case iterator for given SwitchInst and for given + /// case number. + CaseIteratorT(SwitchInstTy *SI, unsigned CaseNum) { + this->SI = SI; + Index = CaseNum; + } + + /// Initializes case iterator for given SwitchInst and for given + /// TerminatorInst's successor index. + static Self fromSuccessorIndex(SwitchInstTy *SI, unsigned SuccessorIndex) { + assert(SuccessorIndex < SI->getNumSuccessors() && + "Successor index # out of range!"); + return SuccessorIndex != 0 ? + Self(SI, SuccessorIndex - 1) : + Self(SI, DefaultPseudoIndex); + } + + /// Resolves case value for current case. + ConstantIntTy *getCaseValue() { + assert(Index < SI->getNumCases() && "Index out the number of cases."); + return reinterpret_cast(SI->getOperand(2 + Index*2)); + } + + /// Resolves successor for current case. + BasicBlockTy *getCaseSuccessor() { + assert((Index < SI->getNumCases() || + Index == DefaultPseudoIndex) && + "Index out the number of cases."); + return SI->getSuccessor(getSuccessorIndex()); + } + + /// Returns number of current case. + unsigned getCaseIndex() const { return Index; } + + /// Returns TerminatorInst's successor index for current case successor. + unsigned getSuccessorIndex() const { + assert((Index == DefaultPseudoIndex || Index < SI->getNumCases()) && + "Index out the number of cases."); + return Index != DefaultPseudoIndex ? Index + 1 : 0; + } + + Self operator++() { + // Check index correctness after increment. + // Note: Index == getNumCases() means end(). + assert(Index+1 <= SI->getNumCases() && "Index out the number of cases."); + ++Index; + return *this; + } + Self operator++(int) { + Self tmp = *this; + ++(*this); + return tmp; + } + Self operator--() { + // Check index correctness after decrement. + // Note: Index == getNumCases() means end(). + // Also allow "-1" iterator here. That will became valid after ++. + assert((Index == 0 || Index-1 <= SI->getNumCases()) && + "Index out the number of cases."); + --Index; + return *this; + } + Self operator--(int) { + Self tmp = *this; + --(*this); + return tmp; + } + bool operator==(const Self& RHS) const { + assert(RHS.SI == SI && "Incompatible operators."); + return RHS.Index == Index; + } + bool operator!=(const Self& RHS) const { + assert(RHS.SI == SI && "Incompatible operators."); + return RHS.Index != Index; + } + }; + + typedef CaseIteratorT + ConstCaseIt; + + class CaseIt : public CaseIteratorT { + + typedef CaseIteratorT ParentTy; + + public: + + CaseIt(const ParentTy& Src) : ParentTy(Src) {} + CaseIt(SwitchInst *SI, unsigned CaseNum) : ParentTy(SI, CaseNum) {} + + /// Sets the new value for current case. + void setValue(ConstantInt *V) { + assert(Index < SI->getNumCases() && "Index out the number of cases."); + SI->setOperand(2 + Index*2, reinterpret_cast(V)); + } + + /// Sets the new successor for current case. + void setSuccessor(BasicBlock *S) { + SI->setSuccessor(getSuccessorIndex(), S); + } + }; + static SwitchInst *Create(Value *Value, BasicBlock *Default, unsigned NumCases, Instruction *InsertBefore = 0) { return new SwitchInst(Value, Default, NumCases, InsertBefore); @@ -2560,23 +2633,23 @@ public: /// Returns a read/write iterator that points to the first /// case in SwitchInst. CaseIt case_begin() { - return CaseIt(this, 0, TheSubsets.begin()); + return CaseIt(this, 0); } /// Returns a read-only iterator that points to the first /// case in the SwitchInst. ConstCaseIt case_begin() const { - return ConstCaseIt(this, 0, TheSubsets.begin()); + return ConstCaseIt(this, 0); } /// Returns a read/write iterator that points one past the last /// in the SwitchInst. CaseIt case_end() { - return CaseIt(this, getNumCases(), TheSubsets.end()); + return CaseIt(this, getNumCases()); } /// Returns a read-only iterator that points one past the last /// in the SwitchInst. ConstCaseIt case_end() const { - return ConstCaseIt(this, getNumCases(), TheSubsets.end()); + return ConstCaseIt(this, getNumCases()); } /// Returns an iterator that points to the default case. /// Note: this iterator allows to resolve successor only. Attempt @@ -2584,10 +2657,10 @@ public: /// Also note, that increment and decrement also causes an assertion and /// makes iterator invalid. CaseIt case_default() { - return CaseIt(this, DefaultPseudoIndex, TheSubsets.end()); + return CaseIt(this, DefaultPseudoIndex); } ConstCaseIt case_default() const { - return ConstCaseIt(this, DefaultPseudoIndex, TheSubsets.end()); + return ConstCaseIt(this, DefaultPseudoIndex); } /// findCaseValue - Search all of the case values for the specified constant. @@ -2596,13 +2669,13 @@ public: /// that it is handled by the default handler. CaseIt findCaseValue(const ConstantInt *C) { for (CaseIt i = case_begin(), e = case_end(); i != e; ++i) - if (i.getCaseValueEx().isSatisfies(IntItem::fromConstantInt(C))) + if (i.getCaseValue() == C) return i; return case_default(); } ConstCaseIt findCaseValue(const ConstantInt *C) const { for (ConstCaseIt i = case_begin(), e = case_end(); i != e; ++i) - if (i.getCaseValueEx().isSatisfies(IntItem::fromConstantInt(C))) + if (i.getCaseValue() == C) return i; return case_default(); } @@ -2628,19 +2701,13 @@ public: /// point to the added case. void addCase(ConstantInt *OnVal, BasicBlock *Dest); - /// addCase - Add an entry to the switch instruction. - /// Note: - /// This action invalidates case_end(). Old case_end() iterator will - /// point to the added case. - void addCase(IntegersSubset& OnVal, BasicBlock *Dest); - /// removeCase - This method removes the specified case and its successor /// from the switch instruction. Note that this operation may reorder the /// remaining cases at index idx and above. /// Note: /// This action invalidates iterators for all cases following the one removed, /// including the case_end() iterator. - void removeCase(CaseIt& i); + void removeCase(CaseIt i); unsigned getNumSuccessors() const { return getNumOperands()/2; } BasicBlock *getSuccessor(unsigned idx) const { @@ -2652,190 +2719,7 @@ public: setOperand(idx*2+1, (Value*)NewSucc); } - uint16_t hash() const { - uint32_t NumberOfCases = (uint32_t)getNumCases(); - uint16_t Hash = (0xFFFF & NumberOfCases) ^ (NumberOfCases >> 16); - for (ConstCaseIt i = case_begin(), e = case_end(); - i != e; ++i) { - uint32_t NumItems = (uint32_t)i.getCaseValueEx().getNumItems(); - Hash = (Hash << 1) ^ (0xFFFF & NumItems) ^ (NumItems >> 16); - } - return Hash; - } - - // Case iterators definition. - - template - class CaseIteratorT { - protected: - - SwitchInstTy *SI; - unsigned Index; - SubsetsItTy SubsetIt; - - /// Initializes case iterator for given SwitchInst and for given - /// case number. - friend class SwitchInst; - CaseIteratorT(SwitchInstTy *SI, unsigned SuccessorIndex, - SubsetsItTy CaseValueIt) { - this->SI = SI; - Index = SuccessorIndex; - this->SubsetIt = CaseValueIt; - } - - public: - typedef typename SubsetsItTy::reference IntegersSubsetRef; - typedef CaseIteratorT Self; - - CaseIteratorT(SwitchInstTy *SI, unsigned CaseNum) { - this->SI = SI; - Index = CaseNum; - SubsetIt = SI->TheSubsets.begin(); - std::advance(SubsetIt, CaseNum); - } - - - /// Initializes case iterator for given SwitchInst and for given - /// TerminatorInst's successor index. - static Self fromSuccessorIndex(SwitchInstTy *SI, unsigned SuccessorIndex) { - assert(SuccessorIndex < SI->getNumSuccessors() && - "Successor index # out of range!"); - return SuccessorIndex != 0 ? - Self(SI, SuccessorIndex - 1) : - Self(SI, DefaultPseudoIndex); - } - - /// Resolves case value for current case. - ConstantIntTy *getCaseValue() { - assert(Index < SI->getNumCases() && "Index out the number of cases."); - IntegersSubsetRef CaseRanges = *SubsetIt; - - // FIXME: Currently we work with ConstantInt based cases. - // So return CaseValue as ConstantInt. - return CaseRanges.getSingleNumber(0).toConstantInt(); - } - - /// Resolves case value for current case. - IntegersSubsetRef getCaseValueEx() { - assert(Index < SI->getNumCases() && "Index out the number of cases."); - return *SubsetIt; - } - - /// Resolves successor for current case. - BasicBlockTy *getCaseSuccessor() { - assert((Index < SI->getNumCases() || - Index == DefaultPseudoIndex) && - "Index out the number of cases."); - return SI->getSuccessor(getSuccessorIndex()); - } - - /// Returns number of current case. - unsigned getCaseIndex() const { return Index; } - - /// Returns TerminatorInst's successor index for current case successor. - unsigned getSuccessorIndex() const { - assert((Index == DefaultPseudoIndex || Index < SI->getNumCases()) && - "Index out the number of cases."); - return Index != DefaultPseudoIndex ? Index + 1 : 0; - } - - Self operator++() { - // Check index correctness after increment. - // Note: Index == getNumCases() means end(). - assert(Index+1 <= SI->getNumCases() && "Index out the number of cases."); - ++Index; - if (Index == 0) - SubsetIt = SI->TheSubsets.begin(); - else - ++SubsetIt; - return *this; - } - Self operator++(int) { - Self tmp = *this; - ++(*this); - return tmp; - } - Self operator--() { - // Check index correctness after decrement. - // Note: Index == getNumCases() means end(). - // Also allow "-1" iterator here. That will became valid after ++. - unsigned NumCases = SI->getNumCases(); - assert((Index == 0 || Index-1 <= NumCases) && - "Index out the number of cases."); - --Index; - if (Index == NumCases) { - SubsetIt = SI->TheSubsets.end(); - return *this; - } - - if (Index != -1U) - --SubsetIt; - - return *this; - } - Self operator--(int) { - Self tmp = *this; - --(*this); - return tmp; - } - bool operator==(const Self& RHS) const { - assert(RHS.SI == SI && "Incompatible operators."); - return RHS.Index == Index; - } - bool operator!=(const Self& RHS) const { - assert(RHS.SI == SI && "Incompatible operators."); - return RHS.Index != Index; - } - }; - - class CaseIt : public CaseIteratorT { - typedef CaseIteratorT - ParentTy; - - protected: - friend class SwitchInst; - CaseIt(SwitchInst *SI, unsigned CaseNum, SubsetsIt SubsetIt) : - ParentTy(SI, CaseNum, SubsetIt) {} - - void updateCaseValueOperand(IntegersSubset& V) { - SI->setOperand(2 + Index*2, reinterpret_cast((Constant*)V)); - } - - public: - - CaseIt(SwitchInst *SI, unsigned CaseNum) : ParentTy(SI, CaseNum) {} - - CaseIt(const ParentTy& Src) : ParentTy(Src) {} - - /// Sets the new value for current case. - void setValue(ConstantInt *V) { - assert(Index < SI->getNumCases() && "Index out the number of cases."); - IntegersSubsetToBB Mapping; - // FIXME: Currently we work with ConstantInt based cases. - // So inititalize IntItem container directly from ConstantInt. - Mapping.add(IntItem::fromConstantInt(V)); - *SubsetIt = Mapping.getCase(); - updateCaseValueOperand(*SubsetIt); - } - - /// Sets the new value for current case. - void setValueEx(IntegersSubset& V) { - assert(Index < SI->getNumCases() && "Index out the number of cases."); - *SubsetIt = V; - updateCaseValueOperand(*SubsetIt); - } - - /// Sets the new successor for current case. - void setSuccessor(BasicBlock *S) { - SI->setSuccessor(getSuccessorIndex(), S); - } - }; - // Methods for support type inquiry through isa, cast, and dyn_cast: - static inline bool classof(const Instruction *I) { return I->getOpcode() == Instruction::Switch; } diff --git a/include/llvm/Support/IntegersSubset.h b/include/llvm/Support/IntegersSubset.h deleted file mode 100644 index 64b79ee..0000000 --- a/include/llvm/Support/IntegersSubset.h +++ /dev/null @@ -1,540 +0,0 @@ -//===-- llvm/IntegersSubset.h - The subset of integers ----------*- 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 contains class that implements constant set of ranges: -/// [,...,]. Initially, this class was created for -/// SwitchInst and was used for case value representation that may contain -/// multiple ranges for a single successor. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_INTEGERSSUBSET_H -#define LLVM_SUPPORT_INTEGERSSUBSET_H - -#include "llvm/IR/Constants.h" -#include "llvm/IR/DerivedTypes.h" -#include "llvm/IR/LLVMContext.h" -#include - -namespace llvm { - - // The IntItem is a wrapper for APInt. - // 1. It determines sign of integer, it allows to use - // comparison operators >,<,>=,<=, and as result we got shorter and cleaner - // constructions. - // 2. It helps to implement PR1255 (case ranges) as a series of small patches. - // 3. Currently we can interpret IntItem both as ConstantInt and as APInt. - // It allows to provide SwitchInst methods that works with ConstantInt for - // non-updated passes. And it allows to use APInt interface for new methods. - // 4. IntItem can be easily replaced with APInt. - - // The set of macros that allows to propagate APInt operators to the IntItem. - -#define INT_ITEM_DEFINE_COMPARISON(op,func) \ - bool operator op (const APInt& RHS) const { \ - return getAPIntValue().func(RHS); \ - } - -#define INT_ITEM_DEFINE_UNARY_OP(op) \ - IntItem operator op () const { \ - APInt res = op(getAPIntValue()); \ - Constant *NewVal = ConstantInt::get(ConstantIntVal->getContext(), res); \ - return IntItem(cast(NewVal)); \ - } - -#define INT_ITEM_DEFINE_BINARY_OP(op) \ - IntItem operator op (const APInt& RHS) const { \ - APInt res = getAPIntValue() op RHS; \ - Constant *NewVal = ConstantInt::get(ConstantIntVal->getContext(), res); \ - return IntItem(cast(NewVal)); \ - } - -#define INT_ITEM_DEFINE_ASSIGNMENT_BY_OP(op) \ - IntItem& operator op (const APInt& RHS) {\ - APInt res = getAPIntValue();\ - res op RHS; \ - Constant *NewVal = ConstantInt::get(ConstantIntVal->getContext(), res); \ - ConstantIntVal = cast(NewVal); \ - return *this; \ - } - -#define INT_ITEM_DEFINE_PREINCDEC(op) \ - IntItem& operator op () { \ - APInt res = getAPIntValue(); \ - op(res); \ - Constant *NewVal = ConstantInt::get(ConstantIntVal->getContext(), res); \ - ConstantIntVal = cast(NewVal); \ - return *this; \ - } - -#define INT_ITEM_DEFINE_POSTINCDEC(op) \ - IntItem& operator op (int) { \ - APInt res = getAPIntValue();\ - op(res); \ - Constant *NewVal = ConstantInt::get(ConstantIntVal->getContext(), res); \ - OldConstantIntVal = ConstantIntVal; \ - ConstantIntVal = cast(NewVal); \ - return IntItem(OldConstantIntVal); \ - } - -#define INT_ITEM_DEFINE_OP_STANDARD_INT(RetTy, op, IntTy) \ - RetTy operator op (IntTy RHS) const { \ - return (*this) op APInt(getAPIntValue().getBitWidth(), RHS); \ - } - -class IntItem { - ConstantInt *ConstantIntVal; - const APInt* APIntVal; - IntItem(const ConstantInt *V) : - ConstantIntVal(const_cast(V)), - APIntVal(&ConstantIntVal->getValue()){} - const APInt& getAPIntValue() const { - return *APIntVal; - } -public: - - IntItem() {} - - operator const APInt&() const { - return getAPIntValue(); - } - - // Propagate APInt operators. - // Note, that - // /,/=,>>,>>= are not implemented in APInt. - // <<= is implemented for unsigned RHS, but not implemented for APInt RHS. - - INT_ITEM_DEFINE_COMPARISON(<, ult) - INT_ITEM_DEFINE_COMPARISON(>, ugt) - INT_ITEM_DEFINE_COMPARISON(<=, ule) - INT_ITEM_DEFINE_COMPARISON(>=, uge) - - INT_ITEM_DEFINE_COMPARISON(==, eq) - INT_ITEM_DEFINE_OP_STANDARD_INT(bool,==,uint64_t) - - INT_ITEM_DEFINE_COMPARISON(!=, ne) - INT_ITEM_DEFINE_OP_STANDARD_INT(bool,!=,uint64_t) - - INT_ITEM_DEFINE_BINARY_OP(*) - INT_ITEM_DEFINE_BINARY_OP(+) - INT_ITEM_DEFINE_OP_STANDARD_INT(IntItem,+,uint64_t) - INT_ITEM_DEFINE_BINARY_OP(-) - INT_ITEM_DEFINE_OP_STANDARD_INT(IntItem,-,uint64_t) - INT_ITEM_DEFINE_BINARY_OP(<<) - INT_ITEM_DEFINE_OP_STANDARD_INT(IntItem,<<,unsigned) - INT_ITEM_DEFINE_BINARY_OP(&) - INT_ITEM_DEFINE_BINARY_OP(^) - INT_ITEM_DEFINE_BINARY_OP(|) - - INT_ITEM_DEFINE_ASSIGNMENT_BY_OP(*=) - INT_ITEM_DEFINE_ASSIGNMENT_BY_OP(+=) - INT_ITEM_DEFINE_ASSIGNMENT_BY_OP(-=) - INT_ITEM_DEFINE_ASSIGNMENT_BY_OP(&=) - INT_ITEM_DEFINE_ASSIGNMENT_BY_OP(^=) - INT_ITEM_DEFINE_ASSIGNMENT_BY_OP(|=) - - // Special case for <<= - IntItem& operator <<= (unsigned RHS) { - APInt res = getAPIntValue(); - res <<= RHS; - Constant *NewVal = ConstantInt::get(ConstantIntVal->getContext(), res); - ConstantIntVal = cast(NewVal); - return *this; - } - - INT_ITEM_DEFINE_UNARY_OP(-) - INT_ITEM_DEFINE_UNARY_OP(~) - - INT_ITEM_DEFINE_PREINCDEC(++) - INT_ITEM_DEFINE_PREINCDEC(--) - - // The set of workarounds, since currently we use ConstantInt implemented - // integer. - - static IntItem fromConstantInt(const ConstantInt *V) { - return IntItem(V); - } - static IntItem fromType(Type* Ty, const APInt& V) { - ConstantInt *C = cast(ConstantInt::get(Ty, V)); - return fromConstantInt(C); - } - static IntItem withImplLikeThis(const IntItem& LikeThis, const APInt& V) { - ConstantInt *C = cast(ConstantInt::get( - LikeThis.ConstantIntVal->getContext(), V)); - return fromConstantInt(C); - } - ConstantInt *toConstantInt() const { - return ConstantIntVal; - } -}; - -template -class IntRange { -protected: - IntType Low; - IntType High; - bool IsEmpty : 1; - bool IsSingleNumber : 1; - -public: - typedef IntRange self; - typedef std::pair SubRes; - - IntRange() : IsEmpty(true) {} - IntRange(const self &RHS) : - Low(RHS.Low), High(RHS.High), - IsEmpty(RHS.IsEmpty), IsSingleNumber(RHS.IsSingleNumber) {} - IntRange(const IntType &C) : - Low(C), High(C), IsEmpty(false), IsSingleNumber(true) {} - - IntRange(const IntType &L, const IntType &H) : Low(L), High(H), - IsEmpty(false), IsSingleNumber(Low == High) {} - - bool isEmpty() const { return IsEmpty; } - bool isSingleNumber() const { return IsSingleNumber; } - - const IntType& getLow() const { - assert(!IsEmpty && "Range is empty."); - return Low; - } - const IntType& getHigh() const { - assert(!IsEmpty && "Range is empty."); - return High; - } - - bool operator<(const self &RHS) const { - assert(!IsEmpty && "Left range is empty."); - assert(!RHS.IsEmpty && "Right range is empty."); - if (Low == RHS.Low) { - if (High > RHS.High) - return true; - return false; - } - if (Low < RHS.Low) - return true; - return false; - } - - bool operator==(const self &RHS) const { - assert(!IsEmpty && "Left range is empty."); - assert(!RHS.IsEmpty && "Right range is empty."); - return Low == RHS.Low && High == RHS.High; - } - - bool operator!=(const self &RHS) const { - return !operator ==(RHS); - } - - static bool LessBySize(const self &LHS, const self &RHS) { - return (LHS.High - LHS.Low) < (RHS.High - RHS.Low); - } - - bool isInRange(const IntType &IntVal) const { - assert(!IsEmpty && "Range is empty."); - return IntVal >= Low && IntVal <= High; - } - - SubRes sub(const self &RHS) const { - SubRes Res; - - // RHS is either more global and includes this range or - // if it doesn't intersected with this range. - if (!isInRange(RHS.Low) && !isInRange(RHS.High)) { - - // If RHS more global (it is enough to check - // only one border in this case. - if (RHS.isInRange(Low)) - return std::make_pair(self(Low, High), self()); - - return Res; - } - - if (Low < RHS.Low) { - Res.first.Low = Low; - IntType NewHigh = RHS.Low; - --NewHigh; - Res.first.High = NewHigh; - } - if (High > RHS.High) { - IntType NewLow = RHS.High; - ++NewLow; - Res.second.Low = NewLow; - Res.second.High = High; - } - return Res; - } - }; - -//===----------------------------------------------------------------------===// -/// IntegersSubsetGeneric - class that implements the subset of integers. It -/// consists from ranges and single numbers. -template -class IntegersSubsetGeneric { -public: - // Use Chris Lattner idea, that was initially described here: - // http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20120213/136954.html - // In short, for more compact memory consumption we can store flat - // numbers collection, and define range as pair of indices. - // In that case we can safe some memory on 32 bit machines. - typedef std::vector FlatCollectionTy; - typedef std::pair RangeLinkTy; - typedef std::vector RangeLinksTy; - typedef typename RangeLinksTy::const_iterator RangeLinksConstIt; - - typedef IntegersSubsetGeneric self; - -protected: - - FlatCollectionTy FlatCollection; - RangeLinksTy RangeLinks; - - bool IsSingleNumber; - bool IsSingleNumbersOnly; - -public: - - template - explicit IntegersSubsetGeneric(const RangesCollectionTy& Links) { - assert(Links.size() && "Empty ranges are not allowed."); - - // In case of big set of single numbers consumes additional RAM space, - // but allows to avoid additional reallocation. - FlatCollection.reserve(Links.size() * 2); - RangeLinks.reserve(Links.size()); - IsSingleNumbersOnly = true; - for (typename RangesCollectionTy::const_iterator i = Links.begin(), - e = Links.end(); i != e; ++i) { - RangeLinkTy RangeLink; - FlatCollection.push_back(i->getLow()); - RangeLink.first = &FlatCollection.back(); - if (i->getLow() != i->getHigh()) { - FlatCollection.push_back(i->getHigh()); - IsSingleNumbersOnly = false; - } - RangeLink.second = &FlatCollection.back(); - RangeLinks.push_back(RangeLink); - } - IsSingleNumber = IsSingleNumbersOnly && RangeLinks.size() == 1; - } - - IntegersSubsetGeneric(const self& RHS) { - *this = RHS; - } - - self& operator=(const self& RHS) { - FlatCollection.clear(); - RangeLinks.clear(); - FlatCollection.reserve(RHS.RangeLinks.size() * 2); - RangeLinks.reserve(RHS.RangeLinks.size()); - for (RangeLinksConstIt i = RHS.RangeLinks.begin(), e = RHS.RangeLinks.end(); - i != e; ++i) { - RangeLinkTy RangeLink; - FlatCollection.push_back(*(i->first)); - RangeLink.first = &FlatCollection.back(); - if (i->first != i->second) - FlatCollection.push_back(*(i->second)); - RangeLink.second = &FlatCollection.back(); - RangeLinks.push_back(RangeLink); - } - IsSingleNumber = RHS.IsSingleNumber; - IsSingleNumbersOnly = RHS.IsSingleNumbersOnly; - return *this; - } - - typedef IntRange Range; - - /// Checks is the given constant satisfies this case. Returns - /// true if it equals to one of contained values or belongs to the one of - /// contained ranges. - bool isSatisfies(const IntTy &CheckingVal) const { - if (IsSingleNumber) - return FlatCollection.front() == CheckingVal; - if (IsSingleNumbersOnly) - return std::find(FlatCollection.begin(), - FlatCollection.end(), - CheckingVal) != FlatCollection.end(); - - for (size_t i = 0, e = getNumItems(); i < e; ++i) { - if (RangeLinks[i].first == RangeLinks[i].second) { - if (*RangeLinks[i].first == CheckingVal) - return true; - } else if (*RangeLinks[i].first <= CheckingVal && - *RangeLinks[i].second >= CheckingVal) - return true; - } - return false; - } - - /// Returns set's item with given index. - Range getItem(unsigned idx) const { - const RangeLinkTy &Link = RangeLinks[idx]; - if (Link.first != Link.second) - return Range(*Link.first, *Link.second); - else - return Range(*Link.first); - } - - /// Return number of items (ranges) stored in set. - size_t getNumItems() const { - return RangeLinks.size(); - } - - /// Returns true if whole subset contains single element. - bool isSingleNumber() const { - return IsSingleNumber; - } - - /// Returns true if whole subset contains only single numbers, no ranges. - bool isSingleNumbersOnly() const { - return IsSingleNumbersOnly; - } - - /// Does the same like getItem(idx).isSingleNumber(), but - /// works faster, since we avoid creation of temporary range object. - bool isSingleNumber(unsigned idx) const { - return RangeLinks[idx].first == RangeLinks[idx].second; - } - - /// Returns set the size, that equals number of all values + sizes of all - /// ranges. - /// Ranges set is considered as flat numbers collection. - /// E.g.: for range [<0>, <1>, <4,8>] the size will 7; - /// for range [<0>, <1>, <5>] the size will 3 - unsigned getSize() const { - APInt sz(((const APInt&)getItem(0).getLow()).getBitWidth(), 0); - for (size_t i = 0, e = getNumItems(); i != e; ++i) { - const APInt Low = getItem(i).getLow(); - const APInt High = getItem(i).getHigh(); - APInt S = High - Low + 1; - sz += S; - } - return sz.getZExtValue(); - } - - /// Allows to access single value even if it belongs to some range. - /// Ranges set is considered as flat numbers collection. - /// [<1>, <4,8>] is considered as [1,4,5,6,7,8] - /// For range [<1>, <4,8>] getSingleValue(3) returns 6. - APInt getSingleValue(unsigned idx) const { - APInt sz(((const APInt&)getItem(0).getLow()).getBitWidth(), 0); - for (unsigned i = 0, e = getNumItems(); i != e; ++i) { - const APInt Low = getItem(i).getLow(); - const APInt High = getItem(i).getHigh(); - APInt S = High - Low + 1; - APInt oldSz = sz; - sz += S; - if (sz.ugt(idx)) { - APInt Res = Low; - APInt Offset(oldSz.getBitWidth(), idx); - Offset -= oldSz; - Res += Offset; - return Res; - } - } - assert(0 && "Index exceeds high border."); - return sz; - } - - /// Does the same as getSingleValue, but works only if subset contains - /// single numbers only. - const IntTy& getSingleNumber(unsigned idx) const { - assert(IsSingleNumbersOnly && "This method works properly if subset " - "contains single numbers only."); - return FlatCollection[idx]; - } -}; - -//===----------------------------------------------------------------------===// -/// IntegersSubset - currently is extension of IntegersSubsetGeneric -/// that also supports conversion to/from Constant* object. -class IntegersSubset : public IntegersSubsetGeneric { - - typedef IntegersSubsetGeneric ParentTy; - - Constant *Holder; - - static unsigned getNumItemsFromConstant(Constant *C) { - return cast(C->getType())->getNumElements(); - } - - static Range getItemFromConstant(Constant *C, unsigned idx) { - const Constant *CV = C->getAggregateElement(idx); - - unsigned NumEls = cast(CV->getType())->getNumElements(); - switch (NumEls) { - case 1: - return Range(IntItem::fromConstantInt( - cast(CV->getAggregateElement(0U))), - IntItem::fromConstantInt(cast( - cast(CV->getAggregateElement(0U))))); - case 2: - return Range(IntItem::fromConstantInt( - cast(CV->getAggregateElement(0U))), - IntItem::fromConstantInt( - cast(CV->getAggregateElement(1)))); - default: - assert(0 && "Only pairs and single numbers are allowed here."); - return Range(); - } - } - - std::vector rangesFromConstant(Constant *C) { - unsigned NumItems = getNumItemsFromConstant(C); - std::vector r; - r.reserve(NumItems); - for (unsigned i = 0, e = NumItems; i != e; ++i) - r.push_back(getItemFromConstant(C, i)); - return r; - } - -public: - - explicit IntegersSubset(Constant *C) : ParentTy(rangesFromConstant(C)), - Holder(C) {} - - IntegersSubset(const IntegersSubset& RHS) : - ParentTy(*(const ParentTy *)&RHS), // FIXME: tweak for msvc. - Holder(RHS.Holder) {} - - template - explicit IntegersSubset(const RangesCollectionTy& Src) : ParentTy(Src) { - std::vector Elts; - Elts.reserve(Src.size()); - for (typename RangesCollectionTy::const_iterator i = Src.begin(), - e = Src.end(); i != e; ++i) { - const Range &R = *i; - std::vector r; - if (R.isSingleNumber()) { - r.reserve(2); - // FIXME: Since currently we have ConstantInt based numbers - // use hack-conversion of IntItem to ConstantInt - r.push_back(R.getLow().toConstantInt()); - r.push_back(R.getHigh().toConstantInt()); - } else { - r.reserve(1); - r.push_back(R.getLow().toConstantInt()); - } - Constant *CV = ConstantVector::get(r); - Elts.push_back(CV); - } - ArrayType *ArrTy = - ArrayType::get(Elts.front()->getType(), (uint64_t)Elts.size()); - Holder = ConstantArray::get(ArrTy, Elts); - } - - operator Constant*() { return Holder; } - operator const Constant*() const { return Holder; } - Constant *operator->() { return Holder; } - const Constant *operator->() const { return Holder; } -}; - -} - -#endif /* CLLVM_SUPPORT_INTEGERSSUBSET_H */ diff --git a/include/llvm/Support/IntegersSubsetMapping.h b/include/llvm/Support/IntegersSubsetMapping.h deleted file mode 100644 index 641ce78..0000000 --- a/include/llvm/Support/IntegersSubsetMapping.h +++ /dev/null @@ -1,588 +0,0 @@ -//===- IntegersSubsetMapping.h - Mapping subset ==> Successor ---*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -/// @file -/// IntegersSubsetMapping is mapping from A to B, where -/// Items in A is subsets of integers, -/// Items in B some pointers (Successors). -/// If user which to add another subset for successor that is already -/// exists in mapping, IntegersSubsetMapping merges existing subset with -/// added one. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_INTEGERSSUBSETMAPPING_H -#define LLVM_SUPPORT_INTEGERSSUBSETMAPPING_H - -#include "llvm/Support/IntegersSubset.h" -#include -#include -#include - -namespace llvm { - -template -class IntegersSubsetMapping { - // FIXME: To much similar iterators typedefs, similar names. - // - Rename RangeIterator to the cluster iterator. - // - Remove unused "add" methods. - // - Class contents needs cleaning. -public: - - typedef IntRange RangeTy; - - struct RangeEx : public RangeTy { - RangeEx() : Weight(1) {} - RangeEx(const RangeTy &R) : RangeTy(R), Weight(1) {} - RangeEx(const RangeTy &R, unsigned W) : RangeTy(R), Weight(W) {} - RangeEx(const IntTy &C) : RangeTy(C), Weight(1) {} - RangeEx(const IntTy &L, const IntTy &H) : RangeTy(L, H), Weight(1) {} - RangeEx(const IntTy &L, const IntTy &H, unsigned W) : - RangeTy(L, H), Weight(W) {} - unsigned Weight; - }; - - typedef std::pair Cluster; - - typedef std::list RangesCollection; - typedef typename RangesCollection::iterator RangesCollectionIt; - typedef typename RangesCollection::const_iterator RangesCollectionConstIt; - typedef IntegersSubsetMapping self; - -protected: - - typedef std::list CaseItems; - typedef typename CaseItems::iterator CaseItemIt; - typedef typename CaseItems::const_iterator CaseItemConstIt; - - // TODO: Change unclean CRS prefixes to SubsetMap for example. - typedef std::map CRSMap; - typedef typename CRSMap::iterator CRSMapIt; - - struct ClustersCmp { - bool operator()(const Cluster &C1, const Cluster &C2) { - return C1.first < C2.first; - } - }; - - CaseItems Items; - bool Sorted; - - bool isIntersected(CaseItemIt& LItem, CaseItemIt& RItem) { - return LItem->first.getHigh() >= RItem->first.getLow(); - } - - bool isJoinable(CaseItemIt& LItem, CaseItemIt& RItem) { - if (LItem->second != RItem->second) { - assert(!isIntersected(LItem, RItem) && - "Intersected items with different successors!"); - return false; - } - APInt RLow = RItem->first.getLow(); - if (RLow != APInt::getNullValue(RLow.getBitWidth())) - --RLow; - return LItem->first.getHigh() >= RLow; - } - - void sort() { - if (!Sorted) { - std::vector clustersVector; - clustersVector.reserve(Items.size()); - clustersVector.insert(clustersVector.begin(), Items.begin(), Items.end()); - std::sort(clustersVector.begin(), clustersVector.end(), ClustersCmp()); - Items.clear(); - Items.insert(Items.begin(), clustersVector.begin(), clustersVector.end()); - Sorted = true; - } - } - - enum DiffProcessState { - L_OPENED, - INTERSECT_OPENED, - R_OPENED, - ALL_IS_CLOSED - }; - - class DiffStateMachine { - - DiffProcessState State; - IntTy OpenPt; - SuccessorClass *CurrentLSuccessor; - SuccessorClass *CurrentRSuccessor; - - self *LeftMapping; - self *IntersectionMapping; - self *RightMapping; - - public: - - typedef - IntegersSubsetMapping MappingTy; - - DiffStateMachine(MappingTy *L, - MappingTy *Intersection, - MappingTy *R) : - State(ALL_IS_CLOSED), - LeftMapping(L), - IntersectionMapping(Intersection), - RightMapping(R) - {} - - void onLOpen(const IntTy &Pt, SuccessorClass *S) { - switch (State) { - case R_OPENED: - if (Pt > OpenPt/*Don't add empty ranges.*/ && RightMapping) - RightMapping->add(OpenPt, Pt-1, CurrentRSuccessor); - State = INTERSECT_OPENED; - break; - case ALL_IS_CLOSED: - State = L_OPENED; - break; - default: - assert(0 && "Got unexpected point."); - break; - } - CurrentLSuccessor = S; - OpenPt = Pt; - } - - void onLClose(const IntTy &Pt) { - switch (State) { - case L_OPENED: - assert(Pt >= OpenPt && - "Subset is not sorted or contains overlapped ranges"); - if (LeftMapping) - LeftMapping->add(OpenPt, Pt, CurrentLSuccessor); - State = ALL_IS_CLOSED; - break; - case INTERSECT_OPENED: - if (IntersectionMapping) - IntersectionMapping->add(OpenPt, Pt, CurrentLSuccessor); - OpenPt = Pt + 1; - State = R_OPENED; - break; - default: - assert(0 && "Got unexpected point."); - break; - } - } - - void onROpen(const IntTy &Pt, SuccessorClass *S) { - switch (State) { - case L_OPENED: - if (Pt > OpenPt && LeftMapping) - LeftMapping->add(OpenPt, Pt-1, CurrentLSuccessor); - State = INTERSECT_OPENED; - break; - case ALL_IS_CLOSED: - State = R_OPENED; - break; - default: - assert(0 && "Got unexpected point."); - break; - } - CurrentRSuccessor = S; - OpenPt = Pt; - } - - void onRClose(const IntTy &Pt) { - switch (State) { - case R_OPENED: - assert(Pt >= OpenPt && - "Subset is not sorted or contains overlapped ranges"); - if (RightMapping) - RightMapping->add(OpenPt, Pt, CurrentRSuccessor); - State = ALL_IS_CLOSED; - break; - case INTERSECT_OPENED: - if (IntersectionMapping) - IntersectionMapping->add(OpenPt, Pt, CurrentLSuccessor); - OpenPt = Pt + 1; - State = L_OPENED; - break; - default: - assert(0 && "Got unexpected point."); - break; - } - } - - void onLROpen(const IntTy &Pt, - SuccessorClass *LS, - SuccessorClass *RS) { - switch (State) { - case ALL_IS_CLOSED: - State = INTERSECT_OPENED; - break; - default: - assert(0 && "Got unexpected point."); - break; - } - CurrentLSuccessor = LS; - CurrentRSuccessor = RS; - OpenPt = Pt; - } - - void onLRClose(const IntTy &Pt) { - switch (State) { - case INTERSECT_OPENED: - if (IntersectionMapping) - IntersectionMapping->add(OpenPt, Pt, CurrentLSuccessor); - State = ALL_IS_CLOSED; - break; - default: - assert(0 && "Got unexpected point."); - break; - } - } - - bool isLOpened() { return State == L_OPENED; } - bool isROpened() { return State == R_OPENED; } - }; - -public: - - // Don't public CaseItems itself. Don't allow edit the Items directly. - // Just present the user way to iterate over the internal collection - // sharing iterator, begin() and end(). Editing should be controlled by - // factory. - typedef CaseItemIt RangeIterator; - - typedef std::pair Case; - typedef std::list Cases; - typedef typename Cases::iterator CasesIt; - - IntegersSubsetMapping() { - Sorted = false; - } - - bool verify() { - RangeIterator DummyErrItem; - return verify(DummyErrItem); - } - - bool verify(RangeIterator& errItem) { - if (Items.empty()) - return true; - sort(); - for (CaseItemIt j = Items.begin(), i = j++, e = Items.end(); - j != e; i = j++) { - if (isIntersected(i, j) && i->second != j->second) { - errItem = j; - return false; - } - } - return true; - } - - bool isOverlapped(self &RHS) { - if (Items.empty() || RHS.empty()) - return true; - - for (CaseItemIt L = Items.begin(), R = RHS.Items.begin(), - el = Items.end(), er = RHS.Items.end(); L != el && R != er;) { - - const RangeTy &LRange = L->first; - const RangeTy &RRange = R->first; - - if (LRange.getLow() > RRange.getLow()) { - if (RRange.isSingleNumber() || LRange.getLow() > RRange.getHigh()) - ++R; - else - return true; - } else if (LRange.getLow() < RRange.getLow()) { - if (LRange.isSingleNumber() || LRange.getHigh() < RRange.getLow()) - ++L; - else - return true; - } else // iRange.getLow() == jRange.getLow() - return true; - } - return false; - } - - - void optimize() { - if (Items.size() < 2) - return; - sort(); - CaseItems OldItems = Items; - Items.clear(); - const IntTy *Low = &OldItems.begin()->first.getLow(); - const IntTy *High = &OldItems.begin()->first.getHigh(); - unsigned Weight = OldItems.begin()->first.Weight; - SuccessorClass *Successor = OldItems.begin()->second; - for (CaseItemIt j = OldItems.begin(), i = j++, e = OldItems.end(); - j != e; i = j++) { - if (isJoinable(i, j)) { - const IntTy *CurHigh = &j->first.getHigh(); - Weight += j->first.Weight; - if (*CurHigh > *High) - High = CurHigh; - } else { - RangeEx R(*Low, *High, Weight); - add(R, Successor); - Low = &j->first.getLow(); - High = &j->first.getHigh(); - Weight = j->first.Weight; - Successor = j->second; - } - } - RangeEx R(*Low, *High, Weight); - add(R, Successor); - // We recollected the Items, but we kept it sorted. - Sorted = true; - } - - /// Adds a constant value. - void add(const IntTy &C, SuccessorClass *S = 0) { - RangeTy R(C); - add(R, S); - } - - /// Adds a range. - void add(const IntTy &Low, const IntTy &High, SuccessorClass *S = 0) { - RangeTy R(Low, High); - add(R, S); - } - void add(const RangeTy &R, SuccessorClass *S = 0) { - RangeEx REx = R; - add(REx, S); - } - void add(const RangeEx &R, SuccessorClass *S = 0) { - Items.push_back(std::make_pair(R, S)); - Sorted = false; - } - - /// Adds all ranges and values from given ranges set to the current - /// mapping. - void add(const IntegersSubsetTy &CRS, SuccessorClass *S = 0, - unsigned Weight = 0) { - unsigned ItemWeight = 1; - if (Weight) - // Weight is associated with CRS, for now we perform a division to - // get the weight for each item. - ItemWeight = Weight / CRS.getNumItems(); - for (unsigned i = 0, e = CRS.getNumItems(); i < e; ++i) { - RangeTy R = CRS.getItem(i); - RangeEx REx(R, ItemWeight); - add(REx, S); - } - } - - void add(self& RHS) { - Items.insert(Items.end(), RHS.Items.begin(), RHS.Items.end()); - } - - void add(self& RHS, SuccessorClass *S) { - for (CaseItemIt i = RHS.Items.begin(), e = RHS.Items.end(); i != e; ++i) - add(i->first, S); - } - - void add(const RangesCollection& RHS, SuccessorClass *S = 0) { - for (RangesCollectionConstIt i = RHS.begin(), e = RHS.end(); i != e; ++i) - add(*i, S); - } - - /// Removes items from set. - void removeItem(RangeIterator i) { Items.erase(i); } - - /// Moves whole case from current mapping to the NewMapping object. - void detachCase(self& NewMapping, SuccessorClass *Succ) { - for (CaseItemIt i = Items.begin(); i != Items.end();) - if (i->second == Succ) { - NewMapping.add(i->first, i->second); - Items.erase(i++); - } else - ++i; - } - - /// Removes all clusters for given successor. - void removeCase(SuccessorClass *Succ) { - for (CaseItemIt i = Items.begin(); i != Items.end();) - if (i->second == Succ) { - Items.erase(i++); - } else - ++i; - } - - /// Find successor that satisfies given value. - SuccessorClass *findSuccessor(const IntTy& Val) { - for (CaseItemIt i = Items.begin(); i != Items.end(); ++i) { - if (i->first.isInRange(Val)) - return i->second; - } - return 0; - } - - /// Calculates the difference between this mapping and RHS. - /// THIS without RHS is placed into LExclude, - /// RHS without THIS is placed into RExclude, - /// THIS intersect RHS is placed into Intersection. - void diff(self *LExclude, self *Intersection, self *RExclude, - const self& RHS) { - - DiffStateMachine Machine(LExclude, Intersection, RExclude); - - CaseItemConstIt L = Items.begin(), R = RHS.Items.begin(); - while (L != Items.end() && R != RHS.Items.end()) { - const Cluster &LCluster = *L; - const RangeEx &LRange = LCluster.first; - const Cluster &RCluster = *R; - const RangeEx &RRange = RCluster.first; - - if (LRange.getHigh() < RRange.getLow()) { - Machine.onLOpen(LRange.getLow(), LCluster.second); - Machine.onLClose(LRange.getHigh()); - ++L; - continue; - } - - if (LRange.getLow() > RRange.getHigh()) { - Machine.onROpen(RRange.getLow(), RCluster.second); - Machine.onRClose(RRange.getHigh()); - ++R; - continue; - } - - if (LRange.getLow() < RRange.getLow()) { - // May be opened in previous iteration. - if (!Machine.isLOpened()) - Machine.onLOpen(LRange.getLow(), LCluster.second); - Machine.onROpen(RRange.getLow(), RCluster.second); - } - else if (RRange.getLow() < LRange.getLow()) { - if (!Machine.isROpened()) - Machine.onROpen(RRange.getLow(), RCluster.second); - Machine.onLOpen(LRange.getLow(), LCluster.second); - } - else - Machine.onLROpen(LRange.getLow(), LCluster.second, RCluster.second); - - if (LRange.getHigh() < RRange.getHigh()) { - Machine.onLClose(LRange.getHigh()); - ++L; - while(L != Items.end() && L->first.getHigh() < RRange.getHigh()) { - Machine.onLOpen(L->first.getLow(), L->second); - Machine.onLClose(L->first.getHigh()); - ++L; - } - } - else if (RRange.getHigh() < LRange.getHigh()) { - Machine.onRClose(RRange.getHigh()); - ++R; - while(R != RHS.Items.end() && R->first.getHigh() < LRange.getHigh()) { - Machine.onROpen(R->first.getLow(), R->second); - Machine.onRClose(R->first.getHigh()); - ++R; - } - } - else { - Machine.onLRClose(LRange.getHigh()); - ++L; - ++R; - } - } - - if (L != Items.end()) { - if (Machine.isLOpened()) { - Machine.onLClose(L->first.getHigh()); - ++L; - } - if (LExclude) - while (L != Items.end()) { - LExclude->add(L->first, L->second); - ++L; - } - } else if (R != RHS.Items.end()) { - if (Machine.isROpened()) { - Machine.onRClose(R->first.getHigh()); - ++R; - } - if (RExclude) - while (R != RHS.Items.end()) { - RExclude->add(R->first, R->second); - ++R; - } - } - } - - /// Builds the finalized case objects. - void getCases(Cases& TheCases, bool PreventMerging = false) { - //FIXME: PreventMerging is a temporary parameter. - //Currently a set of passes is still knows nothing about - //switches with case ranges, and if these passes meet switch - //with complex case that crashs the application. - if (PreventMerging) { - for (RangeIterator i = this->begin(); i != this->end(); ++i) { - RangesCollection SingleRange; - SingleRange.push_back(i->first); - TheCases.push_back(std::make_pair(i->second, - IntegersSubsetTy(SingleRange))); - } - return; - } - CRSMap TheCRSMap; - for (RangeIterator i = this->begin(); i != this->end(); ++i) - TheCRSMap[i->second].push_back(i->first); - for (CRSMapIt i = TheCRSMap.begin(), e = TheCRSMap.end(); i != e; ++i) - TheCases.push_back(std::make_pair(i->first, IntegersSubsetTy(i->second))); - } - - /// Builds the finalized case objects ignoring successor values, as though - /// all ranges belongs to the same successor. - IntegersSubsetTy getCase() { - RangesCollection Ranges; - for (RangeIterator i = this->begin(); i != this->end(); ++i) - Ranges.push_back(i->first); - return IntegersSubsetTy(Ranges); - } - - /// Returns pointer to value of case if it is single-numbered or 0 - /// in another case. - const IntTy* getCaseSingleNumber(SuccessorClass *Succ) { - const IntTy* Res = 0; - for (CaseItemIt i = Items.begin(); i != Items.end(); ++i) - if (i->second == Succ) { - if (!i->first.isSingleNumber()) - return 0; - if (Res) - return 0; - else - Res = &(i->first.getLow()); - } - return Res; - } - - /// Returns true if there is no ranges and values inside. - bool empty() const { return Items.empty(); } - - void clear() { - Items.clear(); - // Don't reset Sorted flag: - // 1. For empty mapping it matters nothing. - // 2. After first item will added Sorted flag will cleared. - } - - // Returns number of clusters - unsigned size() const { - return Items.size(); - } - - RangeIterator begin() { return Items.begin(); } - RangeIterator end() { return Items.end(); } -}; - -class BasicBlock; -typedef IntegersSubsetMapping IntegersSubsetToBB; - -} - -#endif /* LLVM_SUPPORT_INTEGERSSUBSETMAPPING_CRSBUILDER_H */ -- cgit v1.1 From 18eb245a2e5ec41b5da1367d5f7e7619532f7ceb Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Mon, 9 Sep 2013 19:23:58 +0000 Subject: Debug Info: move DIScope::getContext to DwarfDebug. DIScope::getContext is a wrapper function that calls the specific getContext method on each subclass. When we switch DIType::getContext to return DIScopeRef instead of DIScope, DIScope::getContext can no longer return a DIScope without a type identifier map. DIScope::getContext is only used by DwarfDebug, so we move it to DwarfDebug to have easy access to the type identifier map. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190330 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index df9c0c7..a758fcc 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -200,9 +200,6 @@ namespace llvm { public: explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {} - /// Gets the parent scope for this scope node or returns a - /// default constructed scope. - DIScope getContext() const; StringRef getFilename() const; StringRef getDirectory() const; -- cgit v1.1 From 2c9905a1f3bcf22cc2f93332cc8411d11798ba07 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Mon, 9 Sep 2013 19:47:11 +0000 Subject: Debug Info: Use DIScopeRef for DIType::getContext. In DIBuilder, the context field of a TAG_member is updated to use the scope reference. Verifier is updated accordingly. DebugInfoFinder now needs to generate a type identifier map to have access to the actual scope. Same applies for BreakpointPrinter. processModule of DebugInfoFinder is called during initialization phase of the verifier to make sure the type identifier map is constructed early enough. We are now able to unique a simple class as demonstrated by the added testing case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190334 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index a758fcc..4ea843c 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -237,7 +237,7 @@ namespace llvm { /// Verify - Verify that a type descriptor is well formed. bool Verify() const; - DIScope getContext() const { return getFieldAs(2); } + DIScopeRef getContext() const { return getFieldAs(2); } StringRef getName() const { return getStringField(3); } unsigned getLineNumber() const { return getUnsignedField(4); } uint64_t getSizeInBits() const { return getUInt64Field(5); } @@ -820,6 +820,7 @@ namespace llvm { SmallVector TYs; // Types SmallVector Scopes; // Scopes SmallPtrSet NodesSeen; + DITypeIdentifierMap TypeIdentifierMap; }; } // end namespace llvm -- cgit v1.1 From da11df0c22f5d0ba2e2be3ae4a7076c806233db8 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 9 Sep 2013 19:48:37 +0000 Subject: Call generateCompactUnwindEncodings() right before we need to output the frame information. There are more than one paths to where the frame information is emitted. Place the call to generateCompactUnwindEncodings() into the method which outputs the frame information, thus ensuring that the encoding is there for every path. This involved threading the MCAsmBackend object through to this method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190335 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCDwarf.h | 4 +++- include/llvm/MC/MCStreamer.h | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCDwarf.h b/include/llvm/MC/MCDwarf.h index c671dd9..7a06cc0 100644 --- a/include/llvm/MC/MCDwarf.h +++ b/include/llvm/MC/MCDwarf.h @@ -23,6 +23,7 @@ #include namespace llvm { +class MCAsmBackend; class MCContext; class MCSection; class MCStreamer; @@ -449,7 +450,8 @@ public: // // This emits the frame info section. // - static void Emit(MCStreamer &streamer, bool usingCFI, bool isEH); + static void Emit(MCStreamer &streamer, MCAsmBackend *MAB, + bool usingCFI, bool isEH); static void EmitAdvanceLoc(MCStreamer &Streamer, uint64_t AddrDelta); static void EncodeAdvanceLoc(MCContext &Context, uint64_t AddrDelta, raw_ostream &OS); diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index c849e59..cd297a4 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -104,7 +104,7 @@ protected: virtual void EmitCFIStartProcImpl(MCDwarfFrameInfo &Frame); void RecordProcEnd(MCDwarfFrameInfo &Frame); virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &CurFrame); - void EmitFrames(bool usingCFI); + void EmitFrames(MCAsmBackend *MAB, bool usingCFI); MCWin64EHUnwindInfo *getCurrentW64UnwindInfo() { return CurrentW64UnwindInfo; @@ -134,7 +134,7 @@ public: return *W64UnwindInfos[i]; } - void generateCompactUnwindEncodings(MCAsmBackend &MAB); + void generateCompactUnwindEncodings(MCAsmBackend *MAB); /// @name Assembly File Formatting. /// @{ -- cgit v1.1 From 8e54341935c475d2ea4b64da9933c0103cb83842 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Mon, 9 Sep 2013 20:03:08 +0000 Subject: Formatting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190342 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index 91aef13..0e00761 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -769,9 +769,9 @@ enum AcceleratorTable { // Data layout descriptors. DW_ATOM_null = 0u, // Marker as the end of a list of atoms. DW_ATOM_die_offset = 1u, // DIE offset in the debug_info section. - DW_ATOM_cu_offset = 2u, // Offset of the compile unit header that contains the + DW_ATOM_cu_offset = 2u, // Offset of the compile unit header that contains the // item in question. - DW_ATOM_die_tag = 3u, // A tag entry. + DW_ATOM_die_tag = 3u, // A tag entry. DW_ATOM_type_flags = 4u, // Set of flags for a type. // DW_ATOM_type_flags values. -- cgit v1.1 From d4ad5e32a61da5eb046cc109a2bb7c68cc06745f Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Mon, 9 Sep 2013 20:03:11 +0000 Subject: Add constant defines for gnu pubnames and gnu pubtypes - they're used for the gdb index as the names convey. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190343 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index 0e00761..a31c3f1 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -789,6 +789,23 @@ enum AcceleratorTable { /// 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 GDBIndex { + // Special value to indicate no attributes are present. + GDB_INDEX_SYMBOL_KIND_NONE = 0, + GDB_INDEX_SYMBOL_KIND_TYPE = 1, + GDB_INDEX_SYMBOL_KIND_VARIABLE = 2, + GDB_INDEX_SYMBOL_KIND_FUNCTION = 3, + GDB_INDEX_SYMBOL_KIND_OTHER = 4, + // 3 unused bits. + GDB_INDEX_SYMBOL_KIND_UNUSED5 = 5, + GDB_INDEX_SYMBOL_KIND_UNUSED6 = 6, + GDB_INDEX_SYMBOL_KIND_UNUSED7 = 7 +}; + +/// GDBIndexTypeString - Return the string for the specified index type. +const char *GDBIndexTypeString(unsigned Kind); + } // End of namespace dwarf } // End of namespace llvm -- cgit v1.1 From 328a20471dde690712211ce2b00641fcc6a57e36 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Mon, 9 Sep 2013 20:03:14 +0000 Subject: Add the gnu pubnames and pubtypes sections to the mc object file handling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190344 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCObjectFileInfo.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCObjectFileInfo.h b/include/llvm/MC/MCObjectFileInfo.h index a5853b6..5e5debe 100644 --- a/include/llvm/MC/MCObjectFileInfo.h +++ b/include/llvm/MC/MCObjectFileInfo.h @@ -125,6 +125,10 @@ protected: const MCSection *DwarfStrOffDWOSection; const MCSection *DwarfAddrSection; + /// Sections for newer gnu pubnames and pubtypes. + const MCSection *DwarfGnuPubNamesSection; + const MCSection *DwarfGnuPubTypesSection; + // Extra TLS Variable Data section. If the target needs to put additional // information for a TLS variable, it'll go here. const MCSection *TLSExtraDataSection; @@ -223,6 +227,12 @@ public: const MCSection *getDwarfFrameSection() const { return DwarfFrameSection; } const MCSection *getDwarfPubNamesSection() const{return DwarfPubNamesSection;} const MCSection *getDwarfPubTypesSection() const{return DwarfPubTypesSection;} + const MCSection *getDwarfGnuPubNamesSection() const { + return DwarfGnuPubNamesSection; + } + const MCSection *getDwarfGnuPubTypesSection() const { + return DwarfGnuPubTypesSection; + } const MCSection *getDwarfDebugInlineSection() const { return DwarfDebugInlineSection; } -- cgit v1.1 From 3af4d250676623b88436b89212108eb4fff897d3 Mon Sep 17 00:00:00 2001 From: Jack Carter Date: Mon, 9 Sep 2013 22:02:08 +0000 Subject: white spaces and long lines git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190358 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/SelectionDAGNodes.h | 72 +++++++++++++++++++------------- 1 file changed, 42 insertions(+), 30 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index 987f290..dc9bfbc 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -372,7 +372,7 @@ public: /// \ISD namespace). bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; } - /// isTargetMemoryOpcode - Test if this node has a target-specific + /// isTargetMemoryOpcode - Test if this node has a target-specific /// memory-referencing opcode (in the \ISD namespace and /// greater than FIRST_TARGET_MEMORY_OPCODE). bool isTargetMemoryOpcode() const { @@ -520,7 +520,9 @@ public: /// isPredecessorOf - Return true if this node is a predecessor of N. /// NOTE: Implemented on top of hasPredecessor and every bit as /// expensive. Use carefully. - bool isPredecessorOf(const SDNode *N) const { return N->hasPredecessor(this); } + bool isPredecessorOf(const SDNode *N) const { + return N->hasPredecessor(this); + } /// hasPredecessor - Return true if N is a predecessor of this node. /// N is either an operand of this node, or can be reached by recursively @@ -901,7 +903,8 @@ inline void SDUse::setNode(SDNode *N) { class UnarySDNode : public SDNode { SDUse Op; public: - UnarySDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs, SDValue X) + UnarySDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs, + SDValue X) : SDNode(Opc, Order, dl, VTs) { InitOperands(&Op, X); } @@ -912,7 +915,8 @@ public: class BinarySDNode : public SDNode { SDUse Ops[2]; public: - BinarySDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs, SDValue X, SDValue Y) + BinarySDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs, + SDValue X, SDValue Y) : SDNode(Opc, Order, dl, VTs) { InitOperands(Ops, X, Y); } @@ -966,14 +970,15 @@ public: MemSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs, EVT MemoryVT, MachineMemOperand *MMO); - MemSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs, const SDValue *Ops, + MemSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs, + const SDValue *Ops, unsigned NumOps, EVT MemoryVT, MachineMemOperand *MMO); bool readMem() const { return MMO->isLoad(); } bool writeMem() const { return MMO->isStore(); } /// Returns alignment and volatility of the memory access - unsigned getOriginalAlignment() const { + unsigned getOriginalAlignment() const { return MMO->getBaseAlignment(); } unsigned getAlignment() const { @@ -1090,7 +1095,8 @@ public: // Swp: swap value // SrcVal: address to update as a Value (used for MemOperand) // Align: alignment of memory - AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL, EVT MemVT, + AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL, + EVT MemVT, SDValue Chain, SDValue Ptr, SDValue Cmp, SDValue Swp, MachineMemOperand *MMO, AtomicOrdering Ordering, SynchronizationScope SynchScope) @@ -1098,7 +1104,8 @@ public: InitAtomic(Ordering, SynchScope); InitOperands(Ops, Chain, Ptr, Cmp, Swp); } - AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL, EVT MemVT, + AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL, + EVT MemVT, SDValue Chain, SDValue Ptr, SDValue Val, MachineMemOperand *MMO, AtomicOrdering Ordering, SynchronizationScope SynchScope) @@ -1106,7 +1113,8 @@ public: InitAtomic(Ordering, SynchScope); InitOperands(Ops, Chain, Ptr, Val); } - AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL, EVT MemVT, + AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL, + EVT MemVT, SDValue Chain, SDValue Ptr, MachineMemOperand *MMO, AtomicOrdering Ordering, SynchronizationScope SynchScope) @@ -1286,8 +1294,9 @@ class GlobalAddressSDNode : public SDNode { int64_t Offset; unsigned char TargetFlags; friend class SelectionDAG; - GlobalAddressSDNode(unsigned Opc, unsigned Order, DebugLoc DL, const GlobalValue *GA, EVT VT, - int64_t o, unsigned char TargetFlags); + GlobalAddressSDNode(unsigned Opc, unsigned Order, DebugLoc DL, + const GlobalValue *GA, EVT VT, int64_t o, + unsigned char TargetFlags); public: const GlobalValue *getGlobal() const { return TheGlobal; } @@ -1351,21 +1360,22 @@ class ConstantPoolSDNode : public SDNode { friend class SelectionDAG; ConstantPoolSDNode(bool isTarget, const Constant *c, EVT VT, int o, unsigned Align, unsigned char TF) - : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, DebugLoc(), - getSDVTList(VT)), Offset(o), Alignment(Align), TargetFlags(TF) { + : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, + DebugLoc(), getSDVTList(VT)), Offset(o), Alignment(Align), + TargetFlags(TF) { assert(Offset >= 0 && "Offset is too large"); Val.ConstVal = c; } ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, EVT VT, int o, unsigned Align, unsigned char TF) - : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, DebugLoc(), - getSDVTList(VT)), Offset(o), Alignment(Align), TargetFlags(TF) { + : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, + DebugLoc(), getSDVTList(VT)), Offset(o), Alignment(Align), + TargetFlags(TF) { assert(Offset >= 0 && "Offset is too large"); Val.MachineCPVal = v; Offset |= 1 << (sizeof(unsigned)*CHAR_BIT-1); } public: - bool isMachineConstantPoolEntry() const { return Offset < 0; @@ -1427,8 +1437,8 @@ class BasicBlockSDNode : public SDNode { /// blocks out of order when they're jumped to, which makes it a bit /// harder. Let's see if we need it first. explicit BasicBlockSDNode(MachineBasicBlock *mbb) - : SDNode(ISD::BasicBlock, 0, DebugLoc(), getSDVTList(MVT::Other)), MBB(mbb) { - } + : SDNode(ISD::BasicBlock, 0, DebugLoc(), getSDVTList(MVT::Other)), MBB(mbb) + {} public: MachineBasicBlock *getBasicBlock() const { return MBB; } @@ -1481,22 +1491,22 @@ public: return N->getOpcode() == ISD::SRCVALUE; } }; - + class MDNodeSDNode : public SDNode { const MDNode *MD; friend class SelectionDAG; explicit MDNodeSDNode(const MDNode *md) - : SDNode(ISD::MDNODE_SDNODE, 0, DebugLoc(), getSDVTList(MVT::Other)), MD(md) {} + : SDNode(ISD::MDNODE_SDNODE, 0, DebugLoc(), getSDVTList(MVT::Other)), MD(md) + {} public: - + const MDNode *getMD() const { return MD; } - + static bool classof(const SDNode *N) { return N->getOpcode() == ISD::MDNODE_SDNODE; } }; - class RegisterSDNode : public SDNode { unsigned Reg; friend class SelectionDAG; @@ -1568,7 +1578,7 @@ public: class ExternalSymbolSDNode : public SDNode { const char *Symbol; unsigned char TargetFlags; - + friend class SelectionDAG; ExternalSymbolSDNode(bool isTarget, const char *Sym, unsigned char TF, EVT VT) : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, @@ -1600,14 +1610,15 @@ public: return N->getOpcode() == ISD::CONDCODE; } }; - + /// CvtRndSatSDNode - NOTE: avoid using this node as this may disappear in the /// future and most targets don't support it. class CvtRndSatSDNode : public SDNode { ISD::CvtCode CvtCode; friend class SelectionDAG; - explicit CvtRndSatSDNode(EVT VT, unsigned Order, DebugLoc dl, const SDValue *Ops, - unsigned NumOps, ISD::CvtCode Code) + explicit CvtRndSatSDNode(EVT VT, unsigned Order, DebugLoc dl, + const SDValue *Ops, unsigned NumOps, + ISD::CvtCode Code) : SDNode(ISD::CONVERT_RNDSAT, Order, dl, getSDVTList(VT), Ops, NumOps), CvtCode(Code) { assert(NumOps == 5 && "wrong number of operations"); @@ -1649,9 +1660,10 @@ class LSBaseSDNode : public MemSDNode { */ SDUse Ops[4]; public: - LSBaseSDNode(ISD::NodeType NodeTy, unsigned Order, DebugLoc dl, SDValue *Operands, - unsigned numOperands, SDVTList VTs, ISD::MemIndexedMode AM, - EVT MemVT, MachineMemOperand *MMO) + LSBaseSDNode(ISD::NodeType NodeTy, unsigned Order, DebugLoc dl, + SDValue *Operands, unsigned numOperands, + SDVTList VTs, ISD::MemIndexedMode AM, EVT MemVT, + MachineMemOperand *MMO) : MemSDNode(NodeTy, Order, dl, VTs, MemVT, MMO) { SubclassData |= AM << 2; assert(getAddressingMode() == AM && "MemIndexedMode encoding error!"); -- cgit v1.1 From e72aba9c0ff5b19128f54b09a36d2f4c2a53b40b Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Mon, 9 Sep 2013 22:35:23 +0000 Subject: Debug Info: move DIScope::getContext back from DwarfDebug. This partially reverts r190330. DIScope::getContext now returns DIScopeRef instead of DIScope. We construct a DIScopeRef from DIScope when we are dealing with subprogram, lexical block or name space. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190362 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 4ea843c..e9a7831 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -200,6 +200,9 @@ namespace llvm { public: explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {} + /// Gets the parent scope for this scope node or returns a + /// default constructed scope. + DIScopeRef getContext() const; StringRef getFilename() const; StringRef getDirectory() const; @@ -213,6 +216,7 @@ namespace llvm { class DIScopeRef { template friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const; + friend DIScopeRef DIScope::getContext() const; /// Val can be either a MDNode or a MDString, in the latter, /// MDString specifies the type identifier. -- cgit v1.1 From 436f64567ceb0b45e6b5b680fa09485002094830 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Tue, 10 Sep 2013 09:51:43 +0000 Subject: [mips][msa] Removed unsupported dot product instructions (dotp_[su].b) The dotp_[su].b instructions never existed in any revision of the MSA spec. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190398 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index af01bf9..b4872d2 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -813,8 +813,6 @@ def int_mips_div_u_w : GCCBuiltin<"__builtin_msa_div_u_w">, def int_mips_div_u_d : GCCBuiltin<"__builtin_msa_div_u_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; -def int_mips_dotp_s_b : GCCBuiltin<"__builtin_msa_dotp_s_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_dotp_s_h : GCCBuiltin<"__builtin_msa_dotp_s_h">, Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_dotp_s_w : GCCBuiltin<"__builtin_msa_dotp_s_w">, @@ -822,8 +820,6 @@ def int_mips_dotp_s_w : GCCBuiltin<"__builtin_msa_dotp_s_w">, def int_mips_dotp_s_d : GCCBuiltin<"__builtin_msa_dotp_s_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; -def int_mips_dotp_u_b : GCCBuiltin<"__builtin_msa_dotp_u_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_dotp_u_h : GCCBuiltin<"__builtin_msa_dotp_u_h">, Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_dotp_u_w : GCCBuiltin<"__builtin_msa_dotp_u_w">, -- cgit v1.1 From 2c46deb1d07f4588ee70059cdd4c7145f81bc8e8 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Tue, 10 Sep 2013 18:30:07 +0000 Subject: Debug Info: define a DIRef template. Specialize the constructors for DIRef and DIRef to make sure the Value is indeed a scope ref and a type ref. Use DIScopeRef for DIScope::getContext and DIType::getContext and use DITypeRef for getContainingType and getClassType. DIScope::generateRef now returns a DIScopeRef instead of a "Value *" for readability and type safety. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190418 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 97 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 65 insertions(+), 32 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index e9a7831..deebcfd 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -17,6 +17,7 @@ #ifndef LLVM_DEBUGINFO_H #define LLVM_DEBUGINFO_H +#include "llvm/Support/Casting.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" @@ -46,7 +47,7 @@ namespace llvm { class DILexicalBlockFile; class DIVariable; class DIType; - class DIScopeRef; + class DIScope; class DIObjCProperty; /// Maps from type identifier to the actual MDNode. @@ -56,9 +57,10 @@ namespace llvm { /// This should not be stored in a container, because the underlying MDNode /// may change in certain situations. class DIDescriptor { - // Befriends DIScopeRef so DIScopeRef can befriend the protected member - // function: getFieldAs. - friend class DIScopeRef; + // Befriends DIRef so DIRef can befriend the protected member + // function: getFieldAs. + template + friend class DIRef; public: enum { FlagPrivate = 1 << 0, @@ -151,10 +153,6 @@ namespace llvm { void dump() const; }; - /// npecialize getFieldAs to handle fields that are references to DIScopes. - template <> - DIScopeRef DIDescriptor::getFieldAs(unsigned Elt) const; - /// DISubrange - This is used to represent ranges, for array bounds. class DISubrange : public DIDescriptor { friend class DIDescriptor; @@ -192,6 +190,10 @@ namespace llvm { bool Verify() const; }; + template + class DIRef; + typedef DIRef DIScopeRef; + /// DIScope - A base class for various scopes. class DIScope : public DIDescriptor { protected: @@ -208,23 +210,7 @@ namespace llvm { /// Generate a reference to this DIScope. Uses the type identifier instead /// of the actual MDNode if possible, to help type uniquing. - Value *generateRef(); - }; - - /// Represents reference to a DIScope, abstracts over direct and - /// identifier-based metadata scope references. - class DIScopeRef { - template - friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const; - friend DIScopeRef DIScope::getContext() const; - - /// Val can be either a MDNode or a MDString, in the latter, - /// MDString specifies the type identifier. - const Value *Val; - explicit DIScopeRef(const Value *V); - public: - DIScope resolve(const DITypeIdentifierMap &Map) const; - operator Value *() const { return const_cast(Val); } + DIScopeRef generateRef(); }; /// DIType - This is a wrapper for a type. @@ -241,7 +227,7 @@ namespace llvm { /// Verify - Verify that a type descriptor is well formed. bool Verify() const; - DIScopeRef getContext() const { return getFieldAs(2); } + DIScopeRef getContext() const; StringRef getName() const { return getStringField(3); } unsigned getLineNumber() const { return getUnsignedField(4); } uint64_t getSizeInBits() const { return getUInt64Field(5); } @@ -297,6 +283,53 @@ namespace llvm { void replaceAllUsesWith(MDNode *D); }; + /// Represents reference to a DIDescriptor, abstracts over direct and + /// identifier-based metadata references. + template + class DIRef { + template + friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const; + friend DIScopeRef DIScope::getContext() const; + friend DIScopeRef DIScope::generateRef(); + + /// Val can be either a MDNode or a MDString, in the latter, + /// MDString specifies the type identifier. + const Value *Val; + explicit DIRef(const Value *V); + public: + T resolve(const DITypeIdentifierMap &Map) const { + if (!Val) + return T(); + + if (const MDNode *MD = dyn_cast(Val)) + return T(MD); + + const MDString *MS = cast(Val); + // Find the corresponding MDNode. + DITypeIdentifierMap::const_iterator Iter = Map.find(MS); + assert(Iter != Map.end() && "Identifier not in the type map?"); + assert(DIType(Iter->second).isType() && + "MDNode in DITypeIdentifierMap should be a DIType."); + return T(Iter->second); + } + operator Value *() const { return const_cast(Val); } + }; + + /// Specialize getFieldAs to handle fields that are references to DIScopes. + template <> + DIScopeRef DIDescriptor::getFieldAs(unsigned Elt) const; + /// Specialize DIRef constructor for DIScopeRef. + template <> + DIRef::DIRef(const Value *V); + + typedef DIRef DITypeRef; + /// Specialize getFieldAs to handle fields that are references to DITypes. + template <> + DITypeRef DIDescriptor::getFieldAs(unsigned Elt) const; + /// Specialize DIRef constructor for DITypeRef. + template <> + DIRef::DIRef(const Value *V); + /// DIBasicType - A basic type, like 'int' or 'float'. class DIBasicType : public DIType { public: @@ -328,9 +361,9 @@ namespace llvm { /// associated with one. MDNode *getObjCProperty() const; - DIScopeRef getClassType() const { + DITypeRef getClassType() const { assert(getTag() == dwarf::DW_TAG_ptr_to_member_type); - return getFieldAs(10); + return getFieldAs(10); } Constant *getConstant() const { @@ -358,8 +391,8 @@ namespace llvm { void setTypeArray(DIArray Elements, DIArray TParams = DIArray()); void addMember(DIDescriptor D); unsigned getRunTimeLang() const { return getUnsignedField(11); } - DIScopeRef getContainingType() const { - return getFieldAs(12); + DITypeRef getContainingType() const { + return getFieldAs(12); } void setContainingType(DICompositeType ContainingType); DIArray getTemplateParams() const { return getFieldAs(13); } @@ -426,8 +459,8 @@ namespace llvm { unsigned getVirtuality() const { return getUnsignedField(10); } unsigned getVirtualIndex() const { return getUnsignedField(11); } - DIScopeRef getContainingType() const { - return getFieldAs(12); + DITypeRef getContainingType() const { + return getFieldAs(12); } unsigned getFlags() const { -- cgit v1.1 From f42d4247ae1138c6deed50f92dcd1a4f34e07dec Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 10 Sep 2013 19:45:51 +0000 Subject: Add getenv() wrapper that works on multibyte environment variable. On Windows, character encoding of multibyte environment variable varies depending on settings. The only reliable way to handle it I think is to use GetEnvironmentVariableW(). GetEnvironmentVariableW() works on wchar_t string, which is on Windows UTF16 string. That's not ideal because we use UTF-8 as the internal encoding in LLVM. This patch defines a wrapper function which takes and returns UTF-8 string for GetEnvironmentVariableW(). The wrapper function does not do any conversion and just forwards the argument to getenv() on Unix. Differential Revision: http://llvm-reviews.chandlerc.com/D1612 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190423 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Process.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/llvm/Support/Process.h b/include/llvm/Support/Process.h index a23c4ad..6d6add0 100644 --- a/include/llvm/Support/Process.h +++ b/include/llvm/Support/Process.h @@ -25,11 +25,14 @@ #ifndef LLVM_SUPPORT_PROCESS_H #define LLVM_SUPPORT_PROCESS_H +#include "llvm/ADT/Optional.h" #include "llvm/Config/llvm-config.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/TimeValue.h" namespace llvm { +class StringRef; + namespace sys { class self_process; @@ -161,6 +164,10 @@ public: /// @brief Prevent core file generation. static void PreventCoreFiles(); + // This function returns the environment variable \arg name's value as a UTF-8 + // string. \arg Name is assumed to be in UTF-8 encoding too. + static Optional GetEnv(StringRef name); + /// 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. -- cgit v1.1 From 14807bd8c801f976c999e5a6699f31ee9642021a Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Tue, 10 Sep 2013 19:55:24 +0000 Subject: Teach ScalarEvolution about pointer address spaces git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190425 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/ScalarEvolution.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h index 3817e41..59c8b8a 100644 --- a/include/llvm/Analysis/ScalarEvolution.h +++ b/include/llvm/Analysis/ScalarEvolution.h @@ -636,21 +636,24 @@ namespace llvm { const SCEV *getUnknown(Value *V); const SCEV *getCouldNotCompute(); - /// getSizeOfExpr - Return an expression for sizeof on the given type. + /// getSizeOfExpr - Return an expression for sizeof AllocTy that is type + /// IntTy /// - const SCEV *getSizeOfExpr(Type *AllocTy); + const SCEV *getSizeOfExpr(Type *IntTy, Type *AllocTy); - /// getAlignOfExpr - Return an expression for alignof on the given type. + /// getAlignOfExpr - Return an expression for alignof AllocTy /// const SCEV *getAlignOfExpr(Type *AllocTy); - /// getOffsetOfExpr - Return an expression for offsetof on the given field. + /// getOffsetOfExpr - Return an expression for offsetof on the given field + /// with type IntTy /// - const SCEV *getOffsetOfExpr(StructType *STy, unsigned FieldNo); + const SCEV *getOffsetOfExpr(Type *IntTy, StructType *STy, unsigned FieldNo); - /// getOffsetOfExpr - Return an expression for offsetof on the given field. + /// getOffsetOfExpr - Return an expression for offsetof on the given field + /// that is type IntTy /// - const SCEV *getOffsetOfExpr(Type *CTy, Constant *FieldNo); + const SCEV *getOffsetOfExpr(Type *IntTy, Type *CTy, Constant *FieldNo); /// getNegativeSCEV - Return the SCEV object corresponding to -V. /// -- cgit v1.1 From 44a61bde15d456527156ee2080f0964344b939fe Mon Sep 17 00:00:00 2001 From: Nico Rieck Date: Wed, 11 Sep 2013 00:36:48 +0000 Subject: Support ANSI escape code on Windows In some cases (e.g. when a build system pipes stderr) the Windows console API cannot be used to color output. For these, provide a way to switch to ANSI escape codes. This is required for Clang's -fansi-escape-codes option. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190460 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Process.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/llvm/Support/Process.h b/include/llvm/Support/Process.h index 6d6add0..ce39d04 100644 --- a/include/llvm/Support/Process.h +++ b/include/llvm/Support/Process.h @@ -216,6 +216,12 @@ public: /// terminal, this function returns false. static bool StandardErrHasColors(); + /// Enables or disables whether ANSI escape sequences are used to output + /// colors. This only has an effect on Windows. + /// Note: Setting this option is not thread-safe and should only be done + /// during initialization. + static void UseANSIEscapeCodes(bool enable); + /// Whether changing colors requires the output to be flushed. /// This is needed on systems that don't support escape sequences for /// changing colors. -- cgit v1.1 From 8857294192bdc1992d60a14a6ff6c519ddee63e3 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Wed, 11 Sep 2013 09:59:17 +0000 Subject: [mips][msa] Corrected the definition of the dotp_[su].[hwd] intrinsics The elements of the operands should be half the width of the elements of the result. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190505 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index b4872d2..5bec802 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -814,18 +814,18 @@ def int_mips_div_u_d : GCCBuiltin<"__builtin_msa_div_u_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_dotp_s_h : GCCBuiltin<"__builtin_msa_dotp_s_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_dotp_s_w : GCCBuiltin<"__builtin_msa_dotp_s_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_dotp_s_d : GCCBuiltin<"__builtin_msa_dotp_s_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_dotp_u_h : GCCBuiltin<"__builtin_msa_dotp_u_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_dotp_u_w : GCCBuiltin<"__builtin_msa_dotp_u_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; def int_mips_dotp_u_d : GCCBuiltin<"__builtin_msa_dotp_u_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_mips_dpadd_s_h : GCCBuiltin<"__builtin_msa_dpadd_s_h">, Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v16i8_ty, llvm_v16i8_ty], -- cgit v1.1 From f37a324baa7f3893111827f03959fc036da1ed23 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 11 Sep 2013 10:45:21 +0000 Subject: Path: Add an in-place version of path::native. This reflects the common use case of nativizing a prepared path. The existing version invokes undefined behavior if input = output, add an assert to catch that case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190510 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Path.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/llvm/Support/Path.h b/include/llvm/Support/Path.h index f9a65e5..b2afe1b 100644 --- a/include/llvm/Support/Path.h +++ b/include/llvm/Support/Path.h @@ -173,6 +173,13 @@ void append(SmallVectorImpl &path, /// @param result Holds the result of the transformation. void native(const Twine &path, SmallVectorImpl &result); +/// Convert path to the native form in place. This is used to give paths to +/// users and operating system calls in the platform's normal way. For example, +/// on Windows all '/' are converted to '\'. +/// +/// @param path A path that is transformed to native format. +void native(SmallVectorImpl &path); + /// @} /// @name Lexical Observers /// @{ -- cgit v1.1 From dc293b3fe9e3cb7eb7ce7035b32218251a06fbfe Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Wed, 11 Sep 2013 18:55:55 +0000 Subject: Debug Info: move class definition of DIRef. Definition of DIRef used to require the full definition of DIType because of usage of DIType::isType in DIRef::resolve. We now use DIDescriptor::isType instead to remove the requirement and move definition of DIRef before DIType. With this, we can move the definition of DIType::getContext to the header file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190540 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 96 ++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 48 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index deebcfd..515dc65 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -193,6 +193,7 @@ namespace llvm { template class DIRef; typedef DIRef DIScopeRef; + typedef DIRef DITypeRef; /// DIScope - A base class for various scopes. class DIScope : public DIDescriptor { @@ -213,6 +214,52 @@ namespace llvm { DIScopeRef generateRef(); }; + /// Represents reference to a DIDescriptor, abstracts over direct and + /// identifier-based metadata references. + template + class DIRef { + template + friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const; + friend DIScopeRef DIScope::getContext() const; + friend DIScopeRef DIScope::generateRef(); + + /// Val can be either a MDNode or a MDString, in the latter, + /// MDString specifies the type identifier. + const Value *Val; + explicit DIRef(const Value *V); + public: + T resolve(const DITypeIdentifierMap &Map) const { + if (!Val) + return T(); + + if (const MDNode *MD = dyn_cast(Val)) + return T(MD); + + const MDString *MS = cast(Val); + // Find the corresponding MDNode. + DITypeIdentifierMap::const_iterator Iter = Map.find(MS); + assert(Iter != Map.end() && "Identifier not in the type map?"); + assert(DIDescriptor(Iter->second).isType() && + "MDNode in DITypeIdentifierMap should be a DIType."); + return T(Iter->second); + } + operator Value *() const { return const_cast(Val); } + }; + + /// Specialize getFieldAs to handle fields that are references to DIScopes. + template <> + DIScopeRef DIDescriptor::getFieldAs(unsigned Elt) const; + /// Specialize DIRef constructor for DIScopeRef. + template <> + DIRef::DIRef(const Value *V); + + /// Specialize getFieldAs to handle fields that are references to DITypes. + template <> + DITypeRef DIDescriptor::getFieldAs(unsigned Elt) const; + /// Specialize DIRef constructor for DITypeRef. + template <> + DIRef::DIRef(const Value *V); + /// DIType - This is a wrapper for a type. /// FIXME: Types should be factored much better so that CV qualifiers and /// others do not require a huge and empty descriptor full of zeros. @@ -227,7 +274,7 @@ namespace llvm { /// Verify - Verify that a type descriptor is well formed. bool Verify() const; - DIScopeRef getContext() const; + DIScopeRef getContext() const { return getFieldAs(2); } StringRef getName() const { return getStringField(3); } unsigned getLineNumber() const { return getUnsignedField(4); } uint64_t getSizeInBits() const { return getUInt64Field(5); } @@ -283,53 +330,6 @@ namespace llvm { void replaceAllUsesWith(MDNode *D); }; - /// Represents reference to a DIDescriptor, abstracts over direct and - /// identifier-based metadata references. - template - class DIRef { - template - friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const; - friend DIScopeRef DIScope::getContext() const; - friend DIScopeRef DIScope::generateRef(); - - /// Val can be either a MDNode or a MDString, in the latter, - /// MDString specifies the type identifier. - const Value *Val; - explicit DIRef(const Value *V); - public: - T resolve(const DITypeIdentifierMap &Map) const { - if (!Val) - return T(); - - if (const MDNode *MD = dyn_cast(Val)) - return T(MD); - - const MDString *MS = cast(Val); - // Find the corresponding MDNode. - DITypeIdentifierMap::const_iterator Iter = Map.find(MS); - assert(Iter != Map.end() && "Identifier not in the type map?"); - assert(DIType(Iter->second).isType() && - "MDNode in DITypeIdentifierMap should be a DIType."); - return T(Iter->second); - } - operator Value *() const { return const_cast(Val); } - }; - - /// Specialize getFieldAs to handle fields that are references to DIScopes. - template <> - DIScopeRef DIDescriptor::getFieldAs(unsigned Elt) const; - /// Specialize DIRef constructor for DIScopeRef. - template <> - DIRef::DIRef(const Value *V); - - typedef DIRef DITypeRef; - /// Specialize getFieldAs to handle fields that are references to DITypes. - template <> - DITypeRef DIDescriptor::getFieldAs(unsigned Elt) const; - /// Specialize DIRef constructor for DITypeRef. - template <> - DIRef::DIRef(const Value *V); - /// DIBasicType - A basic type, like 'int' or 'float'. class DIBasicType : public DIType { public: -- cgit v1.1 From 4f7e2c38e864d7eaeb407ac501478e9579624d1b Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Wed, 11 Sep 2013 19:25:43 +0000 Subject: Add getUnrollingPreferences to TTI Allow targets to customize the default behavior of the generic loop unrolling transformation. This will be used by the PowerPC backend when targeting the A2 core (which is in-order with a deep pipeline), and using more aggressive defaults is important. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190542 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/TargetTransformInfo.h | 31 +++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'include') diff --git a/include/llvm/Analysis/TargetTransformInfo.h b/include/llvm/Analysis/TargetTransformInfo.h index 06810a7..eb70e9c 100644 --- a/include/llvm/Analysis/TargetTransformInfo.h +++ b/include/llvm/Analysis/TargetTransformInfo.h @@ -29,6 +29,7 @@ namespace llvm { class GlobalValue; +class Loop; class Type; class User; class Value; @@ -191,6 +192,36 @@ public: /// incurs significant execution cost. virtual bool isLoweredToCall(const Function *F) const; + /// Parameters that control the generic loop unrolling transformation. + struct UnrollingPreferences { + /// The cost threshold for the unrolled loop, compared to + /// CodeMetrics.NumInsts aggregated over all basic blocks in the loop body. + /// The unrolling factor is set such that the unrolled loop body does not + /// exceed this cost. Set this to UINT_MAX to disable the loop body cost + /// restriction. + unsigned Threshold; + /// The cost threshold for the unrolled loop when optimizing for size (set + /// to UINT_MAX to disable). + unsigned OptSizeThreshold; + /// A forced unrolling factor (the number of concatenated bodies of the + /// original loop in the unrolled loop body). When set to 0, the unrolling + /// transformation will select an unrolling factor based on the current cost + /// threshold and other factors. + unsigned Count; + /// Allow partial unrolling (unrolling of loops to expand the size of the + /// loop body, not only to eliminate small constant-trip-count loops). + bool Partial; + /// Allow runtime unrolling (unrolling of loops to expand the size of the + /// loop body even when the number of loop iterations is not known at compile + /// time). + bool Runtime; + }; + + /// \brief Get target-customized preferences for the generic loop unrolling + /// transformation. The caller will initialize UP with the current + /// target-independent defaults. + virtual void getUnrollingPreferences(Loop *L, UnrollingPreferences &UP) const; + /// @} /// \name Scalar Target Information -- cgit v1.1 From 2c35f3b3b1168bd7a411f2ebe0131eeb37c0d6c2 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 11 Sep 2013 21:47:57 +0000 Subject: Use the appropriate return type for the compact unwind encoding. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190551 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAsmBackend.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/MC/MCAsmBackend.h b/include/llvm/MC/MCAsmBackend.h index 27aaba9..f946f41 100644 --- a/include/llvm/MC/MCAsmBackend.h +++ b/include/llvm/MC/MCAsmBackend.h @@ -162,7 +162,7 @@ public: virtual void handleAssemblerFlag(MCAssemblerFlag Flag) {} /// \brief Generate the compact unwind encoding for the CFI instructions. - virtual unsigned + virtual uint32_t generateCompactUnwindEncoding(ArrayRef) const { return 0; } -- cgit v1.1 From b95237f10cf718c63b153e362b3b5b548ce50698 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Thu, 12 Sep 2013 01:07:54 +0000 Subject: Fix comment to match what the assert actually enforces git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190566 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Operator.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/Operator.h b/include/llvm/IR/Operator.h index 13ab72c..5b9bee7 100644 --- a/include/llvm/IR/Operator.h +++ b/include/llvm/IR/Operator.h @@ -439,8 +439,8 @@ public: /// offset of this GEP if the GEP is in fact constant. If the GEP is not /// all-constant, it returns false and the value of the offset APInt is /// undefined (it is *not* preserved!). The APInt passed into this routine - /// must be at least as wide as the IntPtr type for the address space of - /// the base GEP pointer. + /// must be at exactly as wide as the IntPtr type for the address space of the + /// base GEP pointer. bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset) const { assert(Offset.getBitWidth() == DL.getPointerSizeInBits(getPointerAddressSpace()) && -- cgit v1.1 From 715d98d657491b3fb8ea0e14643e9801b2f9628c Mon Sep 17 00:00:00 2001 From: Joey Gouly Date: Thu, 12 Sep 2013 10:28:05 +0000 Subject: Add an instruction deprecation feature to TableGen. The 'Deprecated' class allows you to specify a SubtargetFeature that the instruction is deprecated on. The 'ComplexDeprecationPredicate' class allows you to define a custom predicate that is called to check for deprecation. For example: ComplexDeprecationPredicate<"MCR"> would mean you would have to define the following function: bool getMCRDeprecationInfo(MCInst &MI, MCSubtargetInfo &STI, std::string &Info) Which returns 'false' for not deprecated, and 'true' for deprecated and store the warning message in 'Info'. The MCTargetAsmParser constructor was chaned to take an extra argument of the MCInstrInfo class, so out-of-tree targets will need to be changed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190598 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/AsmPrinter.h | 2 ++ include/llvm/MC/MCInstrDesc.h | 19 +++++++++++++++++++ include/llvm/Support/TargetRegistry.h | 13 ++++++++----- include/llvm/Target/Target.td | 11 +++++++++++ 4 files changed, 40 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h index 59d14cc..5462212 100644 --- a/include/llvm/CodeGen/AsmPrinter.h +++ b/include/llvm/CodeGen/AsmPrinter.h @@ -41,6 +41,7 @@ namespace llvm { class MCAsmInfo; class MCCFIInstruction; class MCContext; + class MCInstrInfo; class MCSection; class MCStreamer; class MCSymbol; @@ -64,6 +65,7 @@ namespace llvm { /// const MCAsmInfo *MAI; + const MCInstrInfo *MII; /// OutContext - This is the context for the output file that we are /// streaming. This owns all of the global MC-related objects for the /// generated translation unit. diff --git a/include/llvm/MC/MCInstrDesc.h b/include/llvm/MC/MCInstrDesc.h index 310f706..84d6380 100644 --- a/include/llvm/MC/MCInstrDesc.h +++ b/include/llvm/MC/MCInstrDesc.h @@ -17,6 +17,7 @@ #include "llvm/MC/MCInst.h" #include "llvm/MC/MCRegisterInfo.h" +#include "llvm/MC/MCSubtargetInfo.h" #include "llvm/Support/DataTypes.h" namespace llvm { @@ -145,6 +146,10 @@ public: const uint16_t *ImplicitUses; // Registers implicitly read by this instr const uint16_t *ImplicitDefs; // Registers implicitly defined by this instr const MCOperandInfo *OpInfo; // 'NumOperands' entries about operands + uint64_t DeprecatedFeatureMask;// Feature bits that this is deprecated on, if any + // A complex method to determine is a certain is deprecated or not, and return + // the reason for deprecation. + bool (*ComplexDeprecationInfo)(MCInst &, MCSubtargetInfo &, std::string &); /// \brief Returns the value of the specific constraint if /// it is set. Returns -1 if it is not set. @@ -158,6 +163,20 @@ public: return -1; } + /// \brief Returns true if a certain instruction is deprecated and if so + /// returns the reason in \p Info. + bool getDeprecatedInfo(MCInst &MI, MCSubtargetInfo &STI, + std::string &Info) const { + if (ComplexDeprecationInfo) + return ComplexDeprecationInfo(MI, STI, Info); + if (DeprecatedFeatureMask != 0) { + // FIXME: it would be nice to include the subtarget feature here. + Info = "deprecated"; + return true; + } + return false; + } + /// \brief Return the opcode number for this descriptor. unsigned getOpcode() const { return Opcode; diff --git a/include/llvm/Support/TargetRegistry.h b/include/llvm/Support/TargetRegistry.h index 9282853..05f7cf2 100644 --- a/include/llvm/Support/TargetRegistry.h +++ b/include/llvm/Support/TargetRegistry.h @@ -108,7 +108,8 @@ namespace llvm { StringRef TT, StringRef CPU); typedef MCTargetAsmParser *(*MCAsmParserCtorTy)(MCSubtargetInfo &STI, - MCAsmParser &P); + MCAsmParser &P, + const MCInstrInfo &MII); typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T, const MCSubtargetInfo &STI); typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Target &T, @@ -386,10 +387,11 @@ namespace llvm { /// \param Parser The target independent parser implementation to use for /// parsing and lexing. MCTargetAsmParser *createMCAsmParser(MCSubtargetInfo &STI, - MCAsmParser &Parser) const { + MCAsmParser &Parser, + const MCInstrInfo &MII) const { if (!MCAsmParserCtorFn) return 0; - return MCAsmParserCtorFn(STI, Parser); + return MCAsmParserCtorFn(STI, Parser, MII); } /// createAsmPrinter - Create a target specific assembly printer pass. This @@ -1142,8 +1144,9 @@ namespace llvm { } private: - static MCTargetAsmParser *Allocator(MCSubtargetInfo &STI, MCAsmParser &P) { - return new MCAsmParserImpl(STI, P); + static MCTargetAsmParser *Allocator(MCSubtargetInfo &STI, MCAsmParser &P, + const MCInstrInfo &MII) { + return new MCAsmParserImpl(STI, P, MII); } }; diff --git a/include/llvm/Target/Target.td b/include/llvm/Target/Target.td index b7f3693..c15a4ab 100644 --- a/include/llvm/Target/Target.td +++ b/include/llvm/Target/Target.td @@ -1010,6 +1010,17 @@ class SubtargetFeature Implies = i; } +/// Specifies a Subtarget feature that this instruction is deprecated on. +class Deprecated { + SubtargetFeature DeprecatedFeatureMask = dep; +} + +/// A custom predicate used to determine if an instruction is +/// deprecated or not. +class ComplexDeprecationPredicate { + string ComplexDeprecationPredicate = dep; +} + //===----------------------------------------------------------------------===// // Processor chip sets - These values represent each of the chip sets supported // by the scheduler. Each Processor definition requires corresponding -- cgit v1.1 From 25d25832d550c1844d27d2034cec1c8d507fa689 Mon Sep 17 00:00:00 2001 From: Joey Gouly Date: Thu, 12 Sep 2013 14:23:19 +0000 Subject: Somehow this important part of the patch, where I actually check the Mask, got lost during my iterations of review. Thanks to Hal for spotting it! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190604 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCInstrDesc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/MC/MCInstrDesc.h b/include/llvm/MC/MCInstrDesc.h index 84d6380..214b593 100644 --- a/include/llvm/MC/MCInstrDesc.h +++ b/include/llvm/MC/MCInstrDesc.h @@ -169,7 +169,7 @@ public: std::string &Info) const { if (ComplexDeprecationInfo) return ComplexDeprecationInfo(MI, STI, Info); - if (DeprecatedFeatureMask != 0) { + if ((DeprecatedFeatureMask & STI.getFeatureBits()) != 0) { // FIXME: it would be nice to include the subtarget feature here. Info = "deprecated"; return true; -- cgit v1.1 From 8f1a9299de0333c8c310b7580ea63ba5b7a3c400 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Fri, 13 Sep 2013 00:35:05 +0000 Subject: Add initial support for handling gnu style pubnames accepted by some versions of gold. This support is designed to allow gold to produce gdb_index sections similar to the accelerator tables and consumable by gdb. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190649 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index a31c3f1..a1ed1d1 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -791,6 +791,17 @@ const char *AtomTypeString(unsigned Atom); // Constants for the GNU pubnames/pubtypes extensions supporting gdb index. enum GDBIndex { + // The full index looks like this for each symbol: + // + // 0-23 CU index + // 24-27 reserved + // 28-30 symbol kind + // 31 0 == global, 1 == static + // + // where each entry refers to the CU and some attributes about the symbol. + + // Attributes kinds for the index. + // Special value to indicate no attributes are present. GDB_INDEX_SYMBOL_KIND_NONE = 0, GDB_INDEX_SYMBOL_KIND_TYPE = 1, @@ -800,7 +811,17 @@ enum GDBIndex { // 3 unused bits. GDB_INDEX_SYMBOL_KIND_UNUSED5 = 5, GDB_INDEX_SYMBOL_KIND_UNUSED6 = 6, - GDB_INDEX_SYMBOL_KIND_UNUSED7 = 7 + GDB_INDEX_SYMBOL_KIND_UNUSED7 = 7, + + // Index values are defined via the set of CUs that define the + // symbol. For the pubnames/pubtypes extensions we need the + // various shifts and masks. + GDB_INDEX_SYMBOL_STATIC_SHIFT = 31, + GDB_INDEX_SYMBOL_STATIC_MASK = 1, + GDB_INDEX_SYMBOL_KIND_SHIFT = 28, + GDB_INDEX_SYMBOL_KIND_MASK = 7, + GDB_INDEX_CU_BITSIZE = 24, + GDB_INDEX_CU_MASK = ((1 << GDB_INDEX_CU_BITSIZE) - 1) }; /// GDBIndexTypeString - Return the string for the specified index type. -- cgit v1.1 From cbe40cfe96a6bb3f2da56445269c2c71e55e0e56 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Fri, 13 Sep 2013 17:33:24 +0000 Subject: Add warn_unused_result to empty() on various containers. empty() doesn't actually empty out the container, making this a common typo. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190708 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/DenseMap.h | 4 +++- include/llvm/ADT/SmallPtrSet.h | 2 +- include/llvm/ADT/SmallVector.h | 2 +- include/llvm/ADT/ilist.h | 6 ++++-- 4 files changed, 9 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/llvm/ADT/DenseMap.h b/include/llvm/ADT/DenseMap.h index 0b30161..fac0b95 100644 --- a/include/llvm/ADT/DenseMap.h +++ b/include/llvm/ADT/DenseMap.h @@ -64,7 +64,9 @@ public: return const_iterator(getBucketsEnd(), getBucketsEnd(), true); } - bool empty() const { return getNumEntries() == 0; } + bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const { + return getNumEntries() == 0; + } unsigned size() const { return getNumEntries(); } /// Grow the densemap so that it has at least Size buckets. Does not shrink diff --git a/include/llvm/ADT/SmallPtrSet.h b/include/llvm/ADT/SmallPtrSet.h index 8c73041..bd0d883 100644 --- a/include/llvm/ADT/SmallPtrSet.h +++ b/include/llvm/ADT/SmallPtrSet.h @@ -71,7 +71,7 @@ protected: ~SmallPtrSetImpl(); public: - bool empty() const { return size() == 0; } + bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const { return size() == 0; } unsigned size() const { return NumElements; } void clear() { diff --git a/include/llvm/ADT/SmallVector.h b/include/llvm/ADT/SmallVector.h index 0dc8904..505aa8d 100644 --- a/include/llvm/ADT/SmallVector.h +++ b/include/llvm/ADT/SmallVector.h @@ -53,7 +53,7 @@ public: return size_t((char*)CapacityX - (char*)BeginX); } - bool empty() const { return BeginX == EndX; } + bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const { return BeginX == EndX; } }; template struct SmallVectorStorage; diff --git a/include/llvm/ADT/ilist.h b/include/llvm/ADT/ilist.h index 71dab2e..6aeaa91 100644 --- a/include/llvm/ADT/ilist.h +++ b/include/llvm/ADT/ilist.h @@ -382,7 +382,9 @@ public: // Miscellaneous inspection routines. size_type max_size() const { return size_type(-1); } - bool empty() const { return Head == 0 || Head == getTail(); } + bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const { + return Head == 0 || Head == getTail(); + } // Front and back accessor functions... reference front() { @@ -534,7 +536,7 @@ public: // Functionality derived from other functions defined above... // - size_type size() const { + size_type LLVM_ATTRIBUTE_UNUSED_RESULT size() const { if (Head == 0) return 0; // Don't require construction of sentinel if empty. return std::distance(begin(), end()); } -- cgit v1.1 From e94e0984dfd22ede6211080d1f3e47138f1ea857 Mon Sep 17 00:00:00 2001 From: Filip Pizlo Date: Fri, 13 Sep 2013 22:59:47 +0000 Subject: Make PrettyStackTraceEntry use ManagedStatic for its ThreadLocal. This was somewhat tricky because ~PrettyStackTraceEntry() may run after llvm_shutdown() has been called. This is rare and only happens for a common idiom used in the main() functions of command-line tools. This works around the idiom by skipping the stack clean-up if the PrettyStackTraceHead ManagedStatic is not constructed (i.e. llvm_shutdown() has been called). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190730 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/ManagedStatic.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/ManagedStatic.h b/include/llvm/Support/ManagedStatic.h index 4171d1b..5587618 100644 --- a/include/llvm/Support/ManagedStatic.h +++ b/include/llvm/Support/ManagedStatic.h @@ -99,7 +99,6 @@ public: /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables. void llvm_shutdown(); - /// llvm_shutdown_obj - This is a simple helper class that calls /// llvm_shutdown() when it is destroyed. struct llvm_shutdown_obj { -- cgit v1.1 From 3748de6e2d7620794ff93b896d85aff6cc0ea9d2 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 14 Sep 2013 09:28:14 +0000 Subject: Remove the long, long defunct IR block placement pass. This pass was based on the previous (essentially unused) profiling infrastructure and the assumption that by ordering the basic blocks at the IR level in a particular way, the correct layout would happen in the end. This sometimes worked, and mostly didn't. It also was a really naive implementation of the classical paper that dates from when branch predictors were primarily directional and when loop structure wasn't commonly available. It also didn't factor into the equation non-fallthrough branches and other machine level details. Anyways, for all of these reasons and more, I wrote MachineBlockPlacement, which completely supercedes this pass. It both uses modern profile information infrastructure, and actually works. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190748 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/InitializePasses.h | 1 - include/llvm/LinkAllPasses.h | 1 - include/llvm/Transforms/Scalar.h | 7 ------- 3 files changed, 9 deletions(-) (limited to 'include') diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h index aa06eca..1b50bb2 100644 --- a/include/llvm/InitializePasses.h +++ b/include/llvm/InitializePasses.h @@ -76,7 +76,6 @@ void initializeBasicCallGraphPass(PassRegistry&); void initializeBasicTTIPass(PassRegistry&); void initializeBlockExtractorPassPass(PassRegistry&); void initializeBlockFrequencyInfoPass(PassRegistry&); -void initializeBlockPlacementPass(PassRegistry&); void initializeBoundsCheckingPass(PassRegistry&); void initializeBranchFolderPassPass(PassRegistry&); void initializeBranchProbabilityInfoPass(PassRegistry&); diff --git a/include/llvm/LinkAllPasses.h b/include/llvm/LinkAllPasses.h index ec1ca49..0639ed1 100644 --- a/include/llvm/LinkAllPasses.h +++ b/include/llvm/LinkAllPasses.h @@ -56,7 +56,6 @@ namespace { (void) llvm::createLibCallAliasAnalysisPass(0); (void) llvm::createScalarEvolutionAliasAnalysisPass(); (void) llvm::createTypeBasedAliasAnalysisPass(); - (void) llvm::createBlockPlacementPass(); (void) llvm::createBoundsCheckingPass(); (void) llvm::createBreakCriticalEdgesPass(); (void) llvm::createCallGraphPrinterPass(); diff --git a/include/llvm/Transforms/Scalar.h b/include/llvm/Transforms/Scalar.h index eec9e59..51aeba4 100644 --- a/include/llvm/Transforms/Scalar.h +++ b/include/llvm/Transforms/Scalar.h @@ -267,13 +267,6 @@ extern char &LowerInvokePassID; //===----------------------------------------------------------------------===// // -// BlockPlacement - This pass reorders basic blocks in order to increase the -// number of fall-through conditional branches. -// -FunctionPass *createBlockPlacementPass(); - -//===----------------------------------------------------------------------===// -// // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop // optimizations. // -- cgit v1.1 From 766f25306af343fb2784350cb4d8cd9ca180f0d3 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sun, 15 Sep 2013 19:53:20 +0000 Subject: ELF: Add support for the exclude section bit for gas compat. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190769 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/ELF.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm/Support/ELF.h b/include/llvm/Support/ELF.h index 54da31c..8f92832 100644 --- a/include/llvm/Support/ELF.h +++ b/include/llvm/Support/ELF.h @@ -1196,6 +1196,9 @@ enum { // This section holds Thread-Local Storage. SHF_TLS = 0x400U, + // This section is excluded from the final executable or shared library. + SHF_EXCLUDE = 0x80000000U, + // Start of target-specific flags. /// XCORE_SHF_CP_SECTION - All sections with the "c" flag are grouped -- cgit v1.1 From 1e3037f0be430ef2339838bbdede11f45658bd82 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Mon, 16 Sep 2013 01:08:15 +0000 Subject: Implement function prefix data as an IR feature. Previous discussion: http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-July/063909.html Differential Revision: http://llvm-reviews.chandlerc.com/D1191 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190773 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Function.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/Function.h b/include/llvm/IR/Function.h index 0e51c6f..bba7ecd 100644 --- a/include/llvm/IR/Function.h +++ b/include/llvm/IR/Function.h @@ -159,11 +159,11 @@ public: /// calling convention of this function. The enum values for the known /// calling conventions are defined in CallingConv.h. CallingConv::ID getCallingConv() const { - return static_cast(getSubclassDataFromValue() >> 1); + return static_cast(getSubclassDataFromValue() >> 2); } void setCallingConv(CallingConv::ID CC) { - setValueSubclassData((getSubclassDataFromValue() & 1) | - (static_cast(CC) << 1)); + setValueSubclassData((getSubclassDataFromValue() & 3) | + (static_cast(CC) << 2)); } /// @brief Return the attribute list for this Function. @@ -427,6 +427,13 @@ public: size_t arg_size() const; bool arg_empty() const; + bool hasPrefixData() const { + return getSubclassDataFromValue() & 2; + } + + Constant *getPrefixData() const; + void setPrefixData(Constant *PrefixData); + /// viewCFG - This function is meant for use from the debugger. You can just /// say 'call F->viewCFG()' and a ghostview window should pop up from the /// program, displaying the CFG of the current function with the code for each -- cgit v1.1 From 4b28ee208895d2a9c98b9e63d0c39985500e9291 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Mon, 16 Sep 2013 22:43:16 +0000 Subject: MemCpyOptimizer: Use max legal int size instead of pointer size If there are no legal integers, assume 1 byte. This makes more sense than using the pointer size as a guess for the maximum GPR width. It is conceivable to want to use some 64-bit pointers on a target where 64-bit integers aren't legal. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190817 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/DataLayout.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/DataLayout.h b/include/llvm/IR/DataLayout.h index 25f7569..10630a2 100644 --- a/include/llvm/IR/DataLayout.h +++ b/include/llvm/IR/DataLayout.h @@ -369,6 +369,17 @@ public: /// least as big as Width bits. Type *getSmallestLegalIntType(LLVMContext &C, unsigned Width = 0) const; + /// getLargestLegalIntType - Return the largest legal integer type, or null if + /// none are set. + Type *getLargestLegalIntType(LLVMContext &C) const { + unsigned LargestSize = getLargestLegalIntTypeSize(); + return (LargestSize == 0) ? 0 : Type::getIntNTy(C, LargestSize); + } + + /// getLargestLegalIntType - Return the size of largest legal integer type + /// size, or 0 if none are set. + unsigned getLargestLegalIntTypeSize() const; + /// getIndexedOffset - return the offset from the beginning of the type for /// the specified indices. This is used to implement getelementptr. uint64_t getIndexedOffset(Type *Ty, ArrayRef Indices) const; -- cgit v1.1 From 818833f27929d650b4323774cd3660860588f687 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Mon, 16 Sep 2013 23:29:03 +0000 Subject: Debug info: Fix PR16736 and rdar://problem/14990587. A DBG_VALUE is register-indirect iff the first operand is a register _and_ the second operand is an immediate. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190821 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineInstr.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index e54c5c5..c67c729 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -637,6 +637,13 @@ public: bool isEHLabel() const { return getOpcode() == TargetOpcode::EH_LABEL; } bool isGCLabel() const { return getOpcode() == TargetOpcode::GC_LABEL; } bool isDebugValue() const { return getOpcode() == TargetOpcode::DBG_VALUE; } + /// A DBG_VALUE is indirect iff the first operand is a register and + /// the second operand is an immediate. + bool isIndirectDebugValue() const { + return (getOpcode() == TargetOpcode::DBG_VALUE) + && getOperand(0).isReg() + && getOperand(1).isImm(); + } bool isPHI() const { return getOpcode() == TargetOpcode::PHI; } bool isKill() const { return getOpcode() == TargetOpcode::KILL; } -- cgit v1.1 From ad577a5c1dc325456c495f50e024711273bdf434 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Tue, 17 Sep 2013 00:15:33 +0000 Subject: simplify expression git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190826 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineInstr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index c67c729..e1349a6 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -640,7 +640,7 @@ public: /// A DBG_VALUE is indirect iff the first operand is a register and /// the second operand is an immediate. bool isIndirectDebugValue() const { - return (getOpcode() == TargetOpcode::DBG_VALUE) + return isDebugValue() && getOperand(0).isReg() && getOperand(1).isImm(); } -- cgit v1.1 From 2898b3c28d13f109b4c741e637eec28e63e79d49 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 17 Sep 2013 03:34:09 +0000 Subject: Make a more clear AVX-512 section header that matches similar in the file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190843 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index c7a68da..92fa761 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -2622,7 +2622,9 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_xtest : GCCBuiltin<"__builtin_ia32_xtest">, Intrinsic<[llvm_i32_ty], [], []>; } -// AVX-512 + +//===----------------------------------------------------------------------===// +// AVX-512 intrinsics. let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". // Mask instructions -- cgit v1.1 From 215585920ff264a46cd41a7c5b4aeb8ce17daa90 Mon Sep 17 00:00:00 2001 From: Ben Langmuir Date: Tue, 17 Sep 2013 13:44:39 +0000 Subject: Add llvm.x86.* intrinsics for Intel SHA Extensions Add llvm.x86.* intrinsics for all of the Intel SHA Extensions instructions, as well as tests. Also remove mayLoad and hasSideEffects, which can be inferred from the instruction patterns. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190864 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index 92fa761..ac48bc0 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -2881,3 +2881,24 @@ let TargetPrefix = "x86" in { Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty], [IntrNoMem]>; } + +//===----------------------------------------------------------------------===// +// SHA intrinsics +let TargetPrefix = "x86" in { + def int_x86_sha1rnds4 : GCCBuiltin<"__builtin_ia32_sha1rnds4">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_i8_ty], + [IntrNoMem]>; + def int_x86_sha1nexte : GCCBuiltin<"__builtin_ia32_sha1nexte">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; + def int_x86_sha1msg1 : GCCBuiltin<"__builtin_ia32_sha1msg1">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; + def int_x86_sha1msg2 : GCCBuiltin<"__builtin_ia32_sha1msg2">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; + def int_x86_sha256rnds2 : GCCBuiltin<"__builtin_ia32_sha256rnds2">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], + [IntrNoMem]>; + def int_x86_sha256msg1 : GCCBuiltin<"__builtin_ia32_sha256msg1">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; + def int_x86_sha256msg2 : GCCBuiltin<"__builtin_ia32_sha256msg2">, + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; +} \ No newline at end of file -- cgit v1.1 From 65457b679ae240c1a37da82c5484dac478c47b6d Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Tue, 17 Sep 2013 18:06:50 +0000 Subject: Costmodel: Add support for horizontal vector reductions Upcoming SLP vectorization improvements will want to be able to estimate costs of horizontal reductions. Add infrastructure to support this. We model reductions as a series of (shufflevector,add) tuples ultimately followed by an extractelement. For example, for an add-reduction of <4 x float> we could generate the following sequence: (v0, v1, v2, v3) \ \ / / \ \ / + + (v0+v2, v1+v3, undef, undef) \ / ((v0+v2) + (v1+v3), undef, undef) %rdx.shuf = shufflevector <4 x float> %rdx, <4 x float> undef, <4 x i32> %bin.rdx = fadd <4 x float> %rdx, %rdx.shuf %rdx.shuf7 = shufflevector <4 x float> %bin.rdx, <4 x float> undef, <4 x i32> %bin.rdx8 = fadd <4 x float> %bin.rdx, %rdx.shuf7 %r = extractelement <4 x float> %bin.rdx8, i32 0 This commit adds a cost model interface "getReductionCost(Opcode, Ty, Pairwise)" that will allow clients to ask for the cost of such a reduction (as backends might generate more efficient code than the cost of the individual instructions summed up). This interface is excercised by the CostModel analysis pass which looks for reduction patterns like the one above - starting at extractelements - and if it sees a matching sequence will call the cost model interface. We will also support a second form of pairwise reduction that is well supported on common architectures (haddps, vpadd, faddp). (v0, v1, v2, v3) \ / \ / (v0+v1, v2+v3, undef, undef) \ / ((v0+v1)+(v2+v3), undef, undef, undef) %rdx.shuf.0.0 = shufflevector <4 x float> %rdx, <4 x float> undef, <4 x i32> %rdx.shuf.0.1 = shufflevector <4 x float> %rdx, <4 x float> undef, <4 x i32> %bin.rdx.0 = fadd <4 x float> %rdx.shuf.0.0, %rdx.shuf.0.1 %rdx.shuf.1.0 = shufflevector <4 x float> %bin.rdx.0, <4 x float> undef, <4 x i32> %rdx.shuf.1.1 = shufflevector <4 x float> %bin.rdx.0, <4 x float> undef, <4 x i32> %bin.rdx.1 = fadd <4 x float> %rdx.shuf.1.0, %rdx.shuf.1.1 %r = extractelement <4 x float> %bin.rdx.1, i32 0 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190876 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/TargetTransformInfo.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include') diff --git a/include/llvm/Analysis/TargetTransformInfo.h b/include/llvm/Analysis/TargetTransformInfo.h index eb70e9c..9104fd4 100644 --- a/include/llvm/Analysis/TargetTransformInfo.h +++ b/include/llvm/Analysis/TargetTransformInfo.h @@ -368,6 +368,22 @@ public: unsigned Alignment, unsigned AddressSpace) const; + /// \brief Calculate the cost of performing a vector reduction. + /// + /// This is the cost of reducing the vector value of type \p Ty to a scalar + /// value using the operation denoted by \p Opcode. The form of the reduction + /// can either be a pairwise reduction or a reduction that splits the vector + /// at every reduction level. + /// + /// Pairwise: + /// (v0, v1, v2, v3) + /// ((v0+v1), (v2, v3), undef, undef) + /// Split: + /// (v0, v1, v2, v3) + /// ((v0+v2), (v1+v3), undef, undef) + virtual unsigned getReductionCost(unsigned Opcode, Type *Ty, + bool IsPairwiseForm) const; + /// \returns The cost of Intrinsic instructions. virtual unsigned getIntrinsicInstrCost(Intrinsic::ID ID, Type *RetTy, ArrayRef Tys) const; -- cgit v1.1 From 773c07606e61c5090d73ea1317a0d1b0c29ec023 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 18 Sep 2013 05:54:09 +0000 Subject: Fix X86 subtarget to not overwrite the autodetected features by calling InitMCProcessorInfo right after detecting them. Instead add a new function that only updates the scheduling model and call that. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190919 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCSubtargetInfo.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCSubtargetInfo.h b/include/llvm/MC/MCSubtargetInfo.h index 346fb2d..01e8236 100644 --- a/include/llvm/MC/MCSubtargetInfo.h +++ b/include/llvm/MC/MCSubtargetInfo.h @@ -72,6 +72,9 @@ public: /// feature string). Recompute feature bits and scheduling model. void InitMCProcessorInfo(StringRef CPU, StringRef FS); + /// InitCPUSchedModel - Recompute scheduling model based on CPU. + void InitCPUSchedModel(StringRef CPU); + /// ToggleFeature - Toggle a feature and returns the re-computed feature /// bits. This version does not change the implied bits. uint64_t ToggleFeature(uint64_t FB); -- cgit v1.1 From a4d46d7fc6431ec3576839f11cb61862b784cb3e Mon Sep 17 00:00:00 2001 From: Joey Gouly Date: Wed, 18 Sep 2013 09:45:55 +0000 Subject: [ARMv8] Add CRC instructions. Patch by Bradley Smith! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190928 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsARM.td | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsARM.td b/include/llvm/IR/IntrinsicsARM.td index 80affe6..a2f0620 100644 --- a/include/llvm/IR/IntrinsicsARM.td +++ b/include/llvm/IR/IntrinsicsARM.td @@ -97,6 +97,22 @@ def int_arm_mcrr2 : GCCBuiltin<"__builtin_arm_mcrr2">, llvm_i32_ty, llvm_i32_ty], []>; //===----------------------------------------------------------------------===// +// CRC32 + +def int_arm_crc32b : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], + [IntrNoMem]>; +def int_arm_crc32cb : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], + [IntrNoMem]>; +def int_arm_crc32h : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], + [IntrNoMem]>; +def int_arm_crc32ch : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], + [IntrNoMem]>; +def int_arm_crc32w : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], + [IntrNoMem]>; +def int_arm_crc32cw : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], + [IntrNoMem]>; + +//===----------------------------------------------------------------------===// // Advanced SIMD (NEON) // The following classes do not correspond directly to GCC builtins. -- cgit v1.1 From 0a4371a2073d8841768cf3e8cf65601a8d7cc4fc Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Wed, 18 Sep 2013 22:08:59 +0000 Subject: Debug info: Get rid of the VLA indirection hack in FastISel. Use the DIVariable::isIndirect() flag set by the frontend instead of guessing whether to set the machine location's indirection bit. Paired commit with CFE. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190961 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MachineLocation.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/MC/MachineLocation.h b/include/llvm/MC/MachineLocation.h index c4a9660..7d9abc3 100644 --- a/include/llvm/MC/MachineLocation.h +++ b/include/llvm/MC/MachineLocation.h @@ -44,7 +44,8 @@ public: Offset == Other.Offset; } - // Accessors + // Accessors. + /// \return true iff this is a register-indirect location. bool isIndirect() const { return !IsRegister; } bool isReg() const { return IsRegister; } unsigned getReg() const { return Register; } -- cgit v1.1 From 7d4e9934e7ca83094c5cf41346966c8350179ff2 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Wed, 18 Sep 2013 23:31:16 +0000 Subject: Encapsulate PassManager debug flags to avoid static init and cxa_exit. This puts all the global PassManager debugging flags, like -print-after-all and -time-passes, behind a managed static. This eliminates their static initializers and, more importantly, exit-time destructors. The only behavioral change I anticipate is that tools need to initialize the PassManager before parsing the command line in order to export these options, which makes sense. Tools that already initialize the standard passes (opt/llc) don't need to do anything new. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190974 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/PassManager.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/llvm/PassManager.h b/include/llvm/PassManager.h index b6a8186..044dc33 100644 --- a/include/llvm/PassManager.h +++ b/include/llvm/PassManager.h @@ -28,6 +28,11 @@ class Module; class PassManagerImpl; class FunctionPassManagerImpl; +/// Called by tools to initialize globals and register options at a particular +/// point (before command line parsing). If this is not called, then PassManager +/// globals are lazily initialized at first use. +void initializePassManager(); + /// PassManagerBase - An abstract interface to allow code to add passes to /// a pass manager without having to hard-code what kind of pass manager /// it is. -- cgit v1.1 From abe68f59174c7418ae73de0a87587abe0be1fb03 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Thu, 19 Sep 2013 06:02:43 +0000 Subject: Revert "Encapsulate PassManager debug flags to avoid static init and cxa_exit." Working on a better solution to this. This reverts commit 7d4e9934e7ca83094c5cf41346966c8350179ff2. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190990 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/PassManager.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include') diff --git a/include/llvm/PassManager.h b/include/llvm/PassManager.h index 044dc33..b6a8186 100644 --- a/include/llvm/PassManager.h +++ b/include/llvm/PassManager.h @@ -28,11 +28,6 @@ class Module; class PassManagerImpl; class FunctionPassManagerImpl; -/// Called by tools to initialize globals and register options at a particular -/// point (before command line parsing). If this is not called, then PassManager -/// globals are lazily initialized at first use. -void initializePassManager(); - /// PassManagerBase - An abstract interface to allow code to add passes to /// a pass manager without having to hard-code what kind of pass manager /// it is. -- cgit v1.1 From 5df37dab763ce377095389c4ea1cff88db369954 Mon Sep 17 00:00:00 2001 From: Amara Emerson Date: Thu, 19 Sep 2013 11:59:01 +0000 Subject: [ARMv8] Add support for the v8 cryptography extensions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190996 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsARM.td | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsARM.td b/include/llvm/IR/IntrinsicsARM.td index a2f0620..8d8c4af 100644 --- a/include/llvm/IR/IntrinsicsARM.td +++ b/include/llvm/IR/IntrinsicsARM.td @@ -466,4 +466,21 @@ def int_arm_neon_vbsl : Intrinsic<[llvm_anyvector_ty], [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>], [IntrNoMem]>; + +// Crypto instructions +def int_arm_neon_aesd : Neon_2Arg_Intrinsic; +def int_arm_neon_aese : Neon_2Arg_Intrinsic; +def int_arm_neon_aesimc : Neon_1Arg_Intrinsic; +def int_arm_neon_aesmc : Neon_1Arg_Intrinsic; +def int_arm_neon_sha1h : Neon_1Arg_Intrinsic; +def int_arm_neon_sha1su1 : Neon_2Arg_Intrinsic; +def int_arm_neon_sha256su0 : Neon_2Arg_Intrinsic; +def int_arm_neon_sha1c : Neon_3Arg_Intrinsic; +def int_arm_neon_sha1m : Neon_3Arg_Intrinsic; +def int_arm_neon_sha1p : Neon_3Arg_Intrinsic; +def int_arm_neon_sha1su0: Neon_3Arg_Intrinsic; +def int_arm_neon_sha256h: Neon_3Arg_Intrinsic; +def int_arm_neon_sha256h2: Neon_3Arg_Intrinsic; +def int_arm_neon_sha256su1: Neon_3Arg_Intrinsic; + } // end TargetPrefix -- cgit v1.1 From 4f77a21d6ca2d560a7508fd54581b12dfc01630b Mon Sep 17 00:00:00 2001 From: Shuxin Yang Date: Thu, 19 Sep 2013 17:18:35 +0000 Subject: Add function DominatorTree::getDescendants(). As its name suggests, this function will return all basic blocks dominated by a given block. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191014 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/Dominators.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include') diff --git a/include/llvm/Analysis/Dominators.h b/include/llvm/Analysis/Dominators.h index 81c04bb..3aa0beb 100644 --- a/include/llvm/Analysis/Dominators.h +++ b/include/llvm/Analysis/Dominators.h @@ -346,6 +346,20 @@ public: DomTreeNodeBase *getRootNode() { return RootNode; } const DomTreeNodeBase *getRootNode() const { return RootNode; } + /// Get all nodes dominated by R, including R itself. Return true on success. + void getDescendants(NodeT *R, SmallVectorImpl &Result) const { + const DomTreeNodeBase *RN = getNode(R); + SmallVector *, 8> WL; + WL.push_back(RN); + Result.clear(); + + while (!WL.empty()) { + const DomTreeNodeBase *N = WL.pop_back_val(); + Result.push_back(N->getBlock()); + WL.append(N->begin(), N->end()); + } + } + /// properlyDominates - Returns true iff A dominates B and A != B. /// Note that this is not a constant time operation! /// @@ -755,6 +769,12 @@ public: return DT->getRootNode(); } + /// Get all nodes dominated by R, including R itself. Return true on success. + void getDescendants(BasicBlock *R, + SmallVectorImpl &Result) const { + DT->getDescendants(R, Result); + } + /// compare - Return false if the other dominator tree matches this /// dominator tree. Otherwise return true. inline bool compare(DominatorTree &Other) const { -- cgit v1.1 From ecb41cfe36c9e60664c95970bfae82e4cf7397c5 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 19 Sep 2013 18:39:59 +0000 Subject: DebugInfo: Simplify gnu_pubnames index computation. Names open to bikeshedding. Could switch back to the constants being unshifted, but this way seems a bit easier to work with. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191025 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index a1ed1d1..f06c480 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -791,37 +791,34 @@ const char *AtomTypeString(unsigned Atom); // Constants for the GNU pubnames/pubtypes extensions supporting gdb index. enum GDBIndex { - // The full index looks like this for each symbol: + // The gnu_pub* index value looks like: // - // 0-23 CU index - // 24-27 reserved - // 28-30 symbol kind - // 31 0 == global, 1 == static - // - // where each entry refers to the CU and some attributes about the symbol. + // 0-3 reserved + // 4-6 symbol kind + // 7 0 == global, 1 == static // Attributes kinds for the index. + GDB_INDEX_SYMBOL_KIND_OFFSET = 4, + GDB_INDEX_SYMBOL_KIND_MASK = 7 << GDB_INDEX_SYMBOL_KIND_OFFSET, // Special value to indicate no attributes are present. GDB_INDEX_SYMBOL_KIND_NONE = 0, - GDB_INDEX_SYMBOL_KIND_TYPE = 1, - GDB_INDEX_SYMBOL_KIND_VARIABLE = 2, - GDB_INDEX_SYMBOL_KIND_FUNCTION = 3, - GDB_INDEX_SYMBOL_KIND_OTHER = 4, - // 3 unused bits. - GDB_INDEX_SYMBOL_KIND_UNUSED5 = 5, - GDB_INDEX_SYMBOL_KIND_UNUSED6 = 6, - GDB_INDEX_SYMBOL_KIND_UNUSED7 = 7, + GDB_INDEX_SYMBOL_KIND_TYPE = 1 << GDB_INDEX_SYMBOL_KIND_OFFSET, + GDB_INDEX_SYMBOL_KIND_VARIABLE = 2 << GDB_INDEX_SYMBOL_KIND_OFFSET, + GDB_INDEX_SYMBOL_KIND_FUNCTION = 3 << GDB_INDEX_SYMBOL_KIND_OFFSET, + GDB_INDEX_SYMBOL_KIND_OTHER = 4 << GDB_INDEX_SYMBOL_KIND_OFFSET, + // 3 unused values. + GDB_INDEX_SYMBOL_KIND_UNUSED5 = 5 << GDB_INDEX_SYMBOL_KIND_OFFSET, + GDB_INDEX_SYMBOL_KIND_UNUSED6 = 6 << GDB_INDEX_SYMBOL_KIND_OFFSET, + GDB_INDEX_SYMBOL_KIND_UNUSED7 = 7 << GDB_INDEX_SYMBOL_KIND_OFFSET, // Index values are defined via the set of CUs that define the // symbol. For the pubnames/pubtypes extensions we need the // various shifts and masks. - GDB_INDEX_SYMBOL_STATIC_SHIFT = 31, - GDB_INDEX_SYMBOL_STATIC_MASK = 1, - GDB_INDEX_SYMBOL_KIND_SHIFT = 28, - GDB_INDEX_SYMBOL_KIND_MASK = 7, - GDB_INDEX_CU_BITSIZE = 24, - GDB_INDEX_CU_MASK = ((1 << GDB_INDEX_CU_BITSIZE) - 1) + GDB_INDEX_SYMBOL_STATIC_OFFSET = 7, + GDB_INDEX_SYMBOL_STATIC_MASK = 1 << GDB_INDEX_SYMBOL_STATIC_OFFSET, + GDB_INDEX_SYMBOL_STATIC = 1 << GDB_INDEX_SYMBOL_STATIC_OFFSET, + GDB_INDEX_SYMBOL_NON_STATIC = 0 }; /// GDBIndexTypeString - Return the string for the specified index type. -- cgit v1.1 From f89dacb78244825a5c555be1eb4c18d12365845c Mon Sep 17 00:00:00 2001 From: Anders Waldenborg Date: Thu, 19 Sep 2013 19:43:55 +0000 Subject: llvm-c: Make LLVMGetFirstTarget a proper prototype This avoids warnings when included in a application that uses -Wstrict-prototypes. Differential Revision: http://llvm-reviews.chandlerc.com/D1713 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191029 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/TargetMachine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm-c/TargetMachine.h b/include/llvm-c/TargetMachine.h index 5e35595..c2d198c 100644 --- a/include/llvm-c/TargetMachine.h +++ b/include/llvm-c/TargetMachine.h @@ -57,7 +57,7 @@ typedef enum { } LLVMCodeGenFileType; /** Returns the first llvm::Target in the registered targets list. */ -LLVMTargetRef LLVMGetFirstTarget(); +LLVMTargetRef LLVMGetFirstTarget(void); /** Returns the next llvm::Target given a previous one (or null if there's none) */ LLVMTargetRef LLVMGetNextTarget(LLVMTargetRef T); -- cgit v1.1 From f2144ed4399c6414a4f35b10c2fcc9782f32fbf3 Mon Sep 17 00:00:00 2001 From: Anders Waldenborg Date: Thu, 19 Sep 2013 19:55:06 +0000 Subject: llvm-c: Add LLVMGetPointerToFunction Differential Revision: http://llvm-reviews.chandlerc.com/D1715 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191030 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/ExecutionEngine.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm-c/ExecutionEngine.h b/include/llvm-c/ExecutionEngine.h index 50fdb6b..696d871 100644 --- a/include/llvm-c/ExecutionEngine.h +++ b/include/llvm-c/ExecutionEngine.h @@ -141,6 +141,8 @@ LLVMGenericValueRef LLVMRunFunction(LLVMExecutionEngineRef EE, LLVMValueRef F, unsigned NumArgs, LLVMGenericValueRef *Args); +void *LLVMGetPointerToFunction(LLVMExecutionEngineRef EE, LLVMValueRef F); + void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F); void LLVMAddModule(LLVMExecutionEngineRef EE, LLVMModuleRef M); -- cgit v1.1 From 9599f51559c692bb20092da23e3a34b2cc841e03 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 19 Sep 2013 20:40:26 +0000 Subject: Unshift the GDB index/GNU pubnames constants modified in r191025 Based on code review feedback from Eric Christopher, unshifting these constants as they can appear in the gdb_index itself, shifted a further 24 bits. This means that keeping them preshifted is a bit inflexible, so let's not do that. Given the motivation, wrap up some nicer enums, more type safety, and some utility functions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191035 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 73 +++++++++++++++++++++++++------------------- 1 file changed, 42 insertions(+), 31 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index f06c480..9f96972 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -790,39 +790,50 @@ enum AcceleratorTable { const char *AtomTypeString(unsigned Atom); // Constants for the GNU pubnames/pubtypes extensions supporting gdb index. -enum GDBIndex { - // The gnu_pub* index value looks like: - // - // 0-3 reserved - // 4-6 symbol kind - // 7 0 == global, 1 == static - - // Attributes kinds for the index. - GDB_INDEX_SYMBOL_KIND_OFFSET = 4, - GDB_INDEX_SYMBOL_KIND_MASK = 7 << GDB_INDEX_SYMBOL_KIND_OFFSET, - - // Special value to indicate no attributes are present. - GDB_INDEX_SYMBOL_KIND_NONE = 0, - GDB_INDEX_SYMBOL_KIND_TYPE = 1 << GDB_INDEX_SYMBOL_KIND_OFFSET, - GDB_INDEX_SYMBOL_KIND_VARIABLE = 2 << GDB_INDEX_SYMBOL_KIND_OFFSET, - GDB_INDEX_SYMBOL_KIND_FUNCTION = 3 << GDB_INDEX_SYMBOL_KIND_OFFSET, - GDB_INDEX_SYMBOL_KIND_OTHER = 4 << GDB_INDEX_SYMBOL_KIND_OFFSET, - // 3 unused values. - GDB_INDEX_SYMBOL_KIND_UNUSED5 = 5 << GDB_INDEX_SYMBOL_KIND_OFFSET, - GDB_INDEX_SYMBOL_KIND_UNUSED6 = 6 << GDB_INDEX_SYMBOL_KIND_OFFSET, - GDB_INDEX_SYMBOL_KIND_UNUSED7 = 7 << GDB_INDEX_SYMBOL_KIND_OFFSET, - - // Index values are defined via the set of CUs that define the - // symbol. For the pubnames/pubtypes extensions we need the - // various shifts and masks. - GDB_INDEX_SYMBOL_STATIC_OFFSET = 7, - GDB_INDEX_SYMBOL_STATIC_MASK = 1 << GDB_INDEX_SYMBOL_STATIC_OFFSET, - GDB_INDEX_SYMBOL_STATIC = 1 << GDB_INDEX_SYMBOL_STATIC_OFFSET, - GDB_INDEX_SYMBOL_NON_STATIC = 0 +enum GDBIndexEntryKind { + GIEK_NONE, + GIEK_TYPE, + GIEK_VARIABLE, + GIEK_FUNCTION, + GIEK_OTHER, + GIEK_UNUSED5, + GIEK_UNUSED6, + GIEK_UNUSED7, }; -/// GDBIndexTypeString - Return the string for the specified index type. -const char *GDBIndexTypeString(unsigned Kind); +enum GDBIndexEntryLinkage { + GIEL_EXTERNAL, + GIEL_STATIC +}; + +/// The gnu_pub* kind looks like: +/// +/// 0-3 reserved +/// 4-6 symbol kind +/// 7 0 == global, 1 == static +/// +/// A gdb_index descriptor includes the above kind, shifted 24 bits up with the +/// offset of the cu within the debug_info section stored in those 24 bits. +struct PubIndexEntryDescriptor { + GDBIndexEntryKind Kind; + bool Static; + PubIndexEntryDescriptor(GDBIndexEntryKind Kind, bool Static) + : Kind(Kind), Static(Static) {} + /* implicit */ PubIndexEntryDescriptor(GDBIndexEntryKind Kind) + : Kind(Kind), Static(false) {} + explicit PubIndexEntryDescriptor(uint8_t Value) + : Kind(static_cast((Value & KIND_MASK) >> + KIND_OFFSET)), + Static(Value & STATIC_MASK) {} + uint8_t toBits() { + return Kind << KIND_OFFSET | Static << STATIC_OFFSET; + } +private: + const uint8_t KIND_OFFSET = 4; + const uint8_t KIND_MASK = 7 << KIND_OFFSET; + const uint8_t STATIC_OFFSET = 7; + const uint8_t STATIC_MASK = 1 << STATIC_OFFSET; +}; } // End of namespace dwarf -- cgit v1.1 From 03fadd7f14c94620a5135968de155505b1bb7c4f Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Thu, 19 Sep 2013 21:30:00 +0000 Subject: Unbreak C++03 build. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191039 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index 9f96972..20c2200 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -829,10 +829,12 @@ struct PubIndexEntryDescriptor { return Kind << KIND_OFFSET | Static << STATIC_OFFSET; } private: - const uint8_t KIND_OFFSET = 4; - const uint8_t KIND_MASK = 7 << KIND_OFFSET; - const uint8_t STATIC_OFFSET = 7; - const uint8_t STATIC_MASK = 1 << STATIC_OFFSET; + enum { + KIND_OFFSET = 4, + KIND_MASK = 7 << KIND_OFFSET, + STATIC_OFFSET = 7, + STATIC_MASK = 1 << STATIC_OFFSET + }; }; } // End of namespace dwarf -- cgit v1.1 From 18a6ade6cd638c1e5d2c7c7d044cec0fec5c63d3 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 19 Sep 2013 22:19:37 +0000 Subject: DebugInfo: Improve IR annotation comments for GNU pubthings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191043 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index 20c2200..30f268c 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -17,6 +17,7 @@ #define LLVM_SUPPORT_DWARF_H #include "llvm/Support/DataTypes.h" +#include "llvm/ADT/StringRef.h" namespace llvm { @@ -801,11 +802,15 @@ enum GDBIndexEntryKind { GIEK_UNUSED7, }; +StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind); + enum GDBIndexEntryLinkage { GIEL_EXTERNAL, GIEL_STATIC }; +StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage); + /// The gnu_pub* kind looks like: /// /// 0-3 reserved @@ -816,24 +821,25 @@ enum GDBIndexEntryLinkage { /// offset of the cu within the debug_info section stored in those 24 bits. struct PubIndexEntryDescriptor { GDBIndexEntryKind Kind; - bool Static; - PubIndexEntryDescriptor(GDBIndexEntryKind Kind, bool Static) + GDBIndexEntryLinkage Static; + PubIndexEntryDescriptor(GDBIndexEntryKind Kind, GDBIndexEntryLinkage Static) : Kind(Kind), Static(Static) {} /* implicit */ PubIndexEntryDescriptor(GDBIndexEntryKind Kind) - : Kind(Kind), Static(false) {} + : Kind(Kind), Static(GIEL_EXTERNAL) {} explicit PubIndexEntryDescriptor(uint8_t Value) : Kind(static_cast((Value & KIND_MASK) >> KIND_OFFSET)), - Static(Value & STATIC_MASK) {} + Static(static_cast((Value & LINKAGE_MASK) >> + LINKAGE_OFFSET)) {} uint8_t toBits() { - return Kind << KIND_OFFSET | Static << STATIC_OFFSET; + return Kind << KIND_OFFSET | Static << LINKAGE_OFFSET; } private: enum { KIND_OFFSET = 4, KIND_MASK = 7 << KIND_OFFSET, - STATIC_OFFSET = 7, - STATIC_MASK = 1 << STATIC_OFFSET + LINKAGE_OFFSET = 7, + LINKAGE_MASK = 1 << LINKAGE_OFFSET }; }; -- cgit v1.1 From 994c37fcb001bc5a53bf2c676009b327b882d765 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 19 Sep 2013 23:01:29 +0000 Subject: DebugInfo: llvm-dwarfdump support for gnu_pubnames section git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191050 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo/DIContext.h | 1 + include/llvm/Support/Dwarf.h | 17 ++++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo/DIContext.h b/include/llvm/DebugInfo/DIContext.h index 4bb7c77..ab0fca5 100644 --- a/include/llvm/DebugInfo/DIContext.h +++ b/include/llvm/DebugInfo/DIContext.h @@ -109,6 +109,7 @@ enum DIDumpType { DIDT_Loc, DIDT_Ranges, DIDT_Pubnames, + DIDT_GnuPubnames, DIDT_Str, DIDT_StrDwo, DIDT_StrOffsetsDwo diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index 30f268c..7b87c6a 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -821,19 +821,18 @@ StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage); /// offset of the cu within the debug_info section stored in those 24 bits. struct PubIndexEntryDescriptor { GDBIndexEntryKind Kind; - GDBIndexEntryLinkage Static; - PubIndexEntryDescriptor(GDBIndexEntryKind Kind, GDBIndexEntryLinkage Static) - : Kind(Kind), Static(Static) {} + GDBIndexEntryLinkage Linkage; + PubIndexEntryDescriptor(GDBIndexEntryKind Kind, GDBIndexEntryLinkage Linkage) + : Kind(Kind), Linkage(Linkage) {} /* implicit */ PubIndexEntryDescriptor(GDBIndexEntryKind Kind) - : Kind(Kind), Static(GIEL_EXTERNAL) {} + : Kind(Kind), Linkage(GIEL_EXTERNAL) {} explicit PubIndexEntryDescriptor(uint8_t Value) : Kind(static_cast((Value & KIND_MASK) >> KIND_OFFSET)), - Static(static_cast((Value & LINKAGE_MASK) >> - LINKAGE_OFFSET)) {} - uint8_t toBits() { - return Kind << KIND_OFFSET | Static << LINKAGE_OFFSET; - } + Linkage(static_cast((Value & LINKAGE_MASK) >> + LINKAGE_OFFSET)) {} + uint8_t toBits() { return Kind << KIND_OFFSET | Linkage << LINKAGE_OFFSET; } + private: enum { KIND_OFFSET = 4, -- cgit v1.1 From 5cc319a42a914b24b164a94d9a563c728a7a4026 Mon Sep 17 00:00:00 2001 From: Richard Mitton Date: Thu, 19 Sep 2013 23:21:01 +0000 Subject: Added support for generate DWARF .debug_aranges sections automatically. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191052 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCELFStreamer.h | 2 ++ include/llvm/MC/MCStreamer.h | 19 +++++++++++++++++++ include/llvm/Support/Dwarf.h | 3 ++- 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/MC/MCELFStreamer.h b/include/llvm/MC/MCELFStreamer.h index bff0cba..76369cc 100644 --- a/include/llvm/MC/MCELFStreamer.h +++ b/include/llvm/MC/MCELFStreamer.h @@ -85,6 +85,8 @@ public: virtual void EmitValueToAlignment(unsigned, int64_t, unsigned, unsigned); + virtual void Flush(); + virtual void FinishImpl(); /// @} diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index cd297a4..8cb5c49 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -86,6 +86,10 @@ private: MCSymbol *LastSymbol; + // SymbolOrdering - Tracks an index to represent the order + // a symbol was emitted in. Zero means we did not emit that symbol. + DenseMap SymbolOrdering; + /// SectionStack - This is stack of current and previous section /// values saved by PushSection. SmallVector, 4> SectionStack; @@ -185,6 +189,12 @@ public: return MCSectionSubPair(); } + /// GetSymbolOrder - Returns an index to represent the order + /// a symbol was emitted in. (zero if we did not emit that symbol) + unsigned GetSymbolOrder(const MCSymbol *Sym) const { + return SymbolOrdering.lookup(Sym); + } + /// ChangeSection - Update streamer for a new active section. /// /// This is called by PopSection and SwitchSection, if the current @@ -264,6 +274,12 @@ public: /// InitToTextSection - Create a text section and switch the streamer to it. virtual void InitToTextSection() = 0; + /// AssignSection - Sets the symbol's section. + /// + /// Each emitted symbol will be tracked in the ordering table, + /// so we can sort on them later. + void AssignSection(MCSymbol *Symbol, const MCSection *Section); + /// EmitLabel - Emit a label for @p Symbol into the current section. /// /// This corresponds to an assembler statement such as: @@ -620,6 +636,9 @@ public: /// these methods there. virtual void EmitTCEntry(const MCSymbol &S); + /// Flush - Causes any cached state to be written out. + virtual void Flush() {} + /// FinishImpl - Streamer specific finalization. virtual void FinishImpl() = 0; /// Finish - Finish emission of machine code. diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index 7b87c6a..d924788 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -59,7 +59,8 @@ enum LLVMConstants { DWARF_VERSION = 4, // Default dwarf version we output. DW_CIE_VERSION = 1, // Common frame information version. DW_PUBTYPES_VERSION = 2, // Section version number for .debug_pubtypes. - DW_PUBNAMES_VERSION = 2 // Section version number for .debug_pubnames. + DW_PUBNAMES_VERSION = 2, // Section version number for .debug_pubnames. + DW_ARANGES_VERSION = 2 // Section version number for .debug_aranges. }; // Special ID values that distinguish a CIE from a FDE in DWARF CFI. -- cgit v1.1 From 0bb2c300a339531b5df3e8c12dbed4e8770e2833 Mon Sep 17 00:00:00 2001 From: Richard Mitton Date: Thu, 19 Sep 2013 23:21:07 +0000 Subject: Fixed warning git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191053 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index d924788..8686699 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -800,7 +800,7 @@ enum GDBIndexEntryKind { GIEK_OTHER, GIEK_UNUSED5, GIEK_UNUSED6, - GIEK_UNUSED7, + GIEK_UNUSED7 }; StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind); -- cgit v1.1 From ac3f016599ac50a4777b0348c43892c041ef489b Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 20 Sep 2013 00:33:15 +0000 Subject: DebugInfo: GDBIndexEntry*String conversion functions now return const char* for easy llvm::formating This was previously invoking UB by passing a user-defined type to format. Thanks to Jordan Rose for pointing this out. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191060 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index 8686699..70c46db 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -17,7 +17,6 @@ #define LLVM_SUPPORT_DWARF_H #include "llvm/Support/DataTypes.h" -#include "llvm/ADT/StringRef.h" namespace llvm { @@ -803,14 +802,14 @@ enum GDBIndexEntryKind { GIEK_UNUSED7 }; -StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind); +const char *GDBIndexEntryKindString(GDBIndexEntryKind Kind); enum GDBIndexEntryLinkage { GIEL_EXTERNAL, GIEL_STATIC }; -StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage); +const char *GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage); /// The gnu_pub* kind looks like: /// -- cgit v1.1 From f45edcc3818757234c20d4d5975c0b992bf1f95e Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Fri, 20 Sep 2013 05:14:41 +0000 Subject: Allow subtarget selection of the default MachineScheduler and document the interface. The global registry is used to allow command line override of the scheduler selection, but does not work well as the normal selection API. For example, the same LLVM process should be able to target multiple targets or subtargets. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191071 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineScheduler.h | 69 ++++++++++++++++++++++++++------- include/llvm/CodeGen/Passes.h | 16 ++++++++ 2 files changed, 71 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineScheduler.h b/include/llvm/CodeGen/MachineScheduler.h index 2003297..e6af370 100644 --- a/include/llvm/CodeGen/MachineScheduler.h +++ b/include/llvm/CodeGen/MachineScheduler.h @@ -7,8 +7,48 @@ // //===----------------------------------------------------------------------===// // -// This file provides a MachineSchedRegistry for registering alternative machine -// schedulers. A Target may provide an alternative scheduler implementation by +// This file provides an interface for customizing the standard MachineScheduler +// pass. Note that the entire pass may be replaced as follows: +// +// TargetMachine::createPassConfig(PassManagerBase &PM) { +// PM.substitutePass(&MachineSchedulerID, &CustomSchedulerPassID); +// ...} +// +// The MachineScheduler pass is only responsible for choosing the regions to be +// scheduled. Targets can override the DAG builder and scheduler without +// replacing the pass as follows: +// +// ScheduleDAGInstrs *PassConfig:: +// createMachineScheduler(MachineSchedContext *C) { +// return new CustomMachineScheduler(C); +// } +// +// The default scheduler, ScheduleDAGMI, builds the DAG and drives list +// scheduling while updating the instruction stream, register pressure, and live +// intervals. Most targets don't need to override the DAG builder and list +// schedulier, but subtargets that require custom scheduling heuristics may +// plugin an alternate MachineSchedStrategy. The strategy is responsible for +// selecting the highest priority node from the list: +// +// ScheduleDAGInstrs *PassConfig:: +// createMachineScheduler(MachineSchedContext *C) { +// return new ScheduleDAGMI(C, CustomStrategy(C)); +// } +// +// The DAG builder can also be customized in a sense by adding DAG mutations +// that will run after DAG building and before list scheduling. DAG mutations +// can adjust dependencies based on target-specific knowledge or add weak edges +// to aid heuristics: +// +// ScheduleDAGInstrs *PassConfig:: +// createMachineScheduler(MachineSchedContext *C) { +// ScheduleDAGMI *DAG = new ScheduleDAGMI(C, CustomStrategy(C)); +// DAG->addMutation(new CustomDependencies(DAG->TII, DAG->TRI)); +// return DAG; +// } +// +// A target that supports alternative schedulers can use the +// MachineSchedRegistry to allow command line selection. This can be done by // implementing the following boilerplate: // // static ScheduleDAGInstrs *createCustomMachineSched(MachineSchedContext *C) { @@ -18,9 +58,19 @@ // SchedCustomRegistry("custom", "Run my target's custom scheduler", // createCustomMachineSched); // -// Inside PassConfig: -// enablePass(&MachineSchedulerID); -// MachineSchedRegistry::setDefault(createCustomMachineSched); +// +// Finally, subtargets that don't need to implement custom heuristics but would +// like to configure the GenericScheduler's policy for a given scheduler region, +// including scheduling direction and register pressure tracking policy, can do +// this: +// +// void Subtarget:: +// overrideSchedPolicy(MachineSchedPolicy &Policy, +// MachineInstr *begin, +// MachineInstr *end, +// unsigned NumRegionInstrs) const { +// Policy. = true; +// } // //===----------------------------------------------------------------------===// @@ -85,15 +135,6 @@ public: static MachineSchedRegistry *getList() { return (MachineSchedRegistry *)Registry.getList(); } - static ScheduleDAGCtor getDefault() { - return (ScheduleDAGCtor)Registry.getDefault(); - } - static void setDefault(ScheduleDAGCtor C) { - Registry.setDefault((MachinePassCtor)C); - } - static void setDefault(StringRef Name) { - Registry.setDefault(Name); - } static void setListener(MachinePassRegistryListener *L) { Registry.setListener(L); } diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h index 9b6f61e..4e9180c 100644 --- a/include/llvm/CodeGen/Passes.h +++ b/include/llvm/CodeGen/Passes.h @@ -23,8 +23,10 @@ namespace llvm { class FunctionPass; class MachineFunctionPass; + struct MachineSchedContext; class PassInfo; class PassManagerBase; + class ScheduleDAGInstrs; class TargetLoweringBase; class TargetLowering; class TargetRegisterClass; @@ -204,6 +206,20 @@ public: /// Fully developed targets will not generally override this. virtual void addMachinePasses(); + /// createTargetScheduler - Create an instance of ScheduleDAGInstrs to be run + /// within the standard MachineScheduler pass for this function and target at + /// the current optimization level. + /// + /// This can also be used to plug a new MachineSchedStrategy into an instance + /// of the standard ScheduleDAGMI: + /// return new ScheduleDAGMI(C, new MyStrategy(C)) + /// + /// Return NULL to select the default (generic) machine scheduler. + virtual ScheduleDAGInstrs * + createMachineScheduler(MachineSchedContext *C) const { + return 0; + } + protected: // Helper to verify the analysis is really immutable. void setOpt(bool &Opt, bool Val); -- cgit v1.1 From f46e5eadc307beaef6e8dd0602bb4c63ca41fd50 Mon Sep 17 00:00:00 2001 From: Anders Waldenborg Date: Fri, 20 Sep 2013 07:00:36 +0000 Subject: Revert "llvm-c: Add LLVMGetPointerToFunction" This reverts r191030 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191075 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/ExecutionEngine.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/llvm-c/ExecutionEngine.h b/include/llvm-c/ExecutionEngine.h index 696d871..50fdb6b 100644 --- a/include/llvm-c/ExecutionEngine.h +++ b/include/llvm-c/ExecutionEngine.h @@ -141,8 +141,6 @@ LLVMGenericValueRef LLVMRunFunction(LLVMExecutionEngineRef EE, LLVMValueRef F, unsigned NumArgs, LLVMGenericValueRef *Args); -void *LLVMGetPointerToFunction(LLVMExecutionEngineRef EE, LLVMValueRef F); - void LLVMFreeMachineCodeForFunction(LLVMExecutionEngineRef EE, LLVMValueRef F); void LLVMAddModule(LLVMExecutionEngineRef EE, LLVMModuleRef M); -- cgit v1.1 From 0d293e45b66c742fdbc3998209bb20ed6c5806bf Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sun, 22 Sep 2013 14:09:50 +0000 Subject: Provide basic type safety for array_pod_sort comparators. This makes using array_pod_sort significantly safer. The implementation relies on function pointer casting but that should be safe as we're dealing with void* here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191175 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/STLExtras.h | 12 ++++++++---- include/llvm/Support/PassNameParser.h | 7 +++---- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/llvm/ADT/STLExtras.h b/include/llvm/ADT/STLExtras.h index bfe1392..3aa8183 100644 --- a/include/llvm/ADT/STLExtras.h +++ b/include/llvm/ADT/STLExtras.h @@ -293,12 +293,16 @@ inline void array_pod_sort(IteratorTy Start, IteratorTy End) { get_array_pod_sort_comparator(*Start)); } -template -inline void array_pod_sort(IteratorTy Start, IteratorTy End, - int (*Compare)(const void*, const void*)) { +template +inline void array_pod_sort( + IteratorTy Start, IteratorTy End, + int (*Compare)( + const typename std::iterator_traits::value_type *, + const typename std::iterator_traits::value_type *)) { // Don't dereference start iterator of empty sequence. if (Start == End) return; - qsort(&*Start, End-Start, sizeof(*Start), Compare); + qsort(&*Start, End - Start, sizeof(*Start), + reinterpret_cast(Compare)); } //===----------------------------------------------------------------------===// diff --git a/include/llvm/Support/PassNameParser.h b/include/llvm/Support/PassNameParser.h index a73dc8f..c0914b1 100644 --- a/include/llvm/Support/PassNameParser.h +++ b/include/llvm/Support/PassNameParser.h @@ -86,10 +86,9 @@ public: private: // ValLessThan - Provide a sorting comparator for Values elements... - static int ValLessThan(const void *VT1, const void *VT2) { - typedef PassNameParser::OptionInfo ValType; - return std::strcmp(static_cast(VT1)->Name, - static_cast(VT2)->Name); + static int ValLessThan(const PassNameParser::OptionInfo *VT1, + const PassNameParser::OptionInfo *VT2) { + return std::strcmp(VT1->Name, VT2->Name); } }; -- cgit v1.1 From eaad5cdc2a3ac1f8813e9ee72c58428fd5e8bc33 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sun, 22 Sep 2013 17:01:50 +0000 Subject: StringRef-ize some things git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191178 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo/DIContext.h | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo/DIContext.h b/include/llvm/DebugInfo/DIContext.h index ab0fca5..0e0bd2c 100644 --- a/include/llvm/DebugInfo/DIContext.h +++ b/include/llvm/DebugInfo/DIContext.h @@ -38,11 +38,10 @@ public: DILineInfo() : FileName(""), FunctionName(""), Line(0), Column(0) {} - DILineInfo(const SmallString<16> &fileName, - const SmallString<16> &functionName, - uint32_t line, uint32_t column) - : FileName(fileName), FunctionName(functionName), - Line(line), Column(column) {} + DILineInfo(StringRef fileName, StringRef functionName, uint32_t line, + uint32_t column) + : FileName(fileName), FunctionName(functionName), Line(line), + Column(column) {} const char *getFileName() { return FileName.c_str(); } const char *getFunctionName() { return FunctionName.c_str(); } -- cgit v1.1 From e7174f183280fa4e3288f48ae01b5190f0011d48 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Sun, 22 Sep 2013 18:25:32 +0000 Subject: Remove dead code git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191179 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo/DWARFFormValue.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo/DWARFFormValue.h b/include/llvm/DebugInfo/DWARFFormValue.h index ad6f71d..5618155 100644 --- a/include/llvm/DebugInfo/DWARFFormValue.h +++ b/include/llvm/DebugInfo/DWARFFormValue.h @@ -58,10 +58,6 @@ public: const uint8_t *BlockData() const; uint64_t getReference(const DWARFCompileUnit* cu) const; - /// Resolve any compile unit specific references so that we don't need - /// the compile unit at a later time in order to work with the form - /// value. - bool resolveCompileUnitReferences(const DWARFCompileUnit* cu); uint64_t getUnsigned() const { return Value.uval; } int64_t getSigned() const { return Value.sval; } const char *getAsCString(const DWARFCompileUnit *CU) const; -- cgit v1.1 From 9a1aaeb012e593fba977015c5d8b6b1aa41a908c Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Mon, 23 Sep 2013 14:03:12 +0000 Subject: [mips][msa] Added support for matching insert and copy from normal IR (i.e. not intrinsics) Changes to MIPS SelectionDAG: * Added nodes VEXTRACT_[SZ]EXT_ELT to represent extract and extend in a single operation and implemented the DAG combines necessary to fold sign/zero extends into the extract. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191199 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 5bec802..055a8cf 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -779,18 +779,18 @@ def int_mips_clti_u_d : GCCBuiltin<"__builtin_msa_clti_u_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_copy_s_b : GCCBuiltin<"__builtin_msa_copy_s_b">, - Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_copy_s_h : GCCBuiltin<"__builtin_msa_copy_s_h">, - Intrinsic<[llvm_i32_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_i32_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_copy_s_w : GCCBuiltin<"__builtin_msa_copy_s_w">, - Intrinsic<[llvm_i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_copy_u_b : GCCBuiltin<"__builtin_msa_copy_u_b">, - Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_copy_u_h : GCCBuiltin<"__builtin_msa_copy_u_h">, - Intrinsic<[llvm_i32_ty], [llvm_v8i16_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_i32_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_copy_u_w : GCCBuiltin<"__builtin_msa_copy_u_w">, - Intrinsic<[llvm_i32_ty], [llvm_v4i32_ty, llvm_i32_ty], []>; + Intrinsic<[llvm_i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_ctcmsa : GCCBuiltin<"__builtin_msa_ctcmsa">, Intrinsic<[], [llvm_i32_ty, llvm_i32_ty], []>; -- cgit v1.1 From cd7c4980d4ee2d22d92a4907f2d029e67b52d732 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 23 Sep 2013 22:44:40 +0000 Subject: Exract most of DWARFCompileUnit into a new DWARFUnit to prepare for the coming DWARFTypeUnit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191233 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo/DWARFFormValue.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo/DWARFFormValue.h b/include/llvm/DebugInfo/DWARFFormValue.h index 5618155..f92d5a9 100644 --- a/include/llvm/DebugInfo/DWARFFormValue.h +++ b/include/llvm/DebugInfo/DWARFFormValue.h @@ -14,7 +14,7 @@ namespace llvm { -class DWARFCompileUnit; +class DWARFUnit; class raw_ostream; class DWARFFormValue { @@ -49,23 +49,23 @@ public: DWARFFormValue(uint16_t form = 0) : Form(form) {} uint16_t getForm() const { return Form; } const ValueType& value() const { return Value; } - void dump(raw_ostream &OS, const DWARFCompileUnit* cu) const; + void dump(raw_ostream &OS, const DWARFUnit *U) const; bool extractValue(DataExtractor data, uint32_t *offset_ptr, - const DWARFCompileUnit *cu); + const DWARFUnit *u); bool isInlinedCStr() const { return Value.data != NULL && Value.data == (const uint8_t*)Value.cstr; } const uint8_t *BlockData() const; - uint64_t getReference(const DWARFCompileUnit* cu) const; + uint64_t getReference(const DWARFUnit *U) const; uint64_t getUnsigned() const { return Value.uval; } int64_t getSigned() const { return Value.sval; } - const char *getAsCString(const DWARFCompileUnit *CU) const; - uint64_t getAsAddress(const DWARFCompileUnit *CU) const; + const char *getAsCString(const DWARFUnit *U) const; + uint64_t getAsAddress(const DWARFUnit *U) const; bool skipValue(DataExtractor debug_info_data, uint32_t *offset_ptr, - const DWARFCompileUnit *cu) const; + const DWARFUnit *u) const; static bool skipValue(uint16_t form, DataExtractor debug_info_data, - uint32_t *offset_ptr, const DWARFCompileUnit *cu); + uint32_t *offset_ptr, const DWARFUnit *u); static bool isBlockForm(uint16_t form); static bool isDataForm(uint16_t form); static const uint8_t *getFixedFormSizes(uint8_t AddrSize, uint16_t Version); -- cgit v1.1 From 438f5391b2d502a132a4a20469e9e56305b221a4 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 23 Sep 2013 22:44:47 +0000 Subject: llvm-dwarfdump/libDebugInfo support for type units git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191234 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo/DIContext.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/DebugInfo/DIContext.h b/include/llvm/DebugInfo/DIContext.h index 0e0bd2c..1b42138 100644 --- a/include/llvm/DebugInfo/DIContext.h +++ b/include/llvm/DebugInfo/DIContext.h @@ -104,6 +104,7 @@ enum DIDumpType { DIDT_Frames, DIDT_Info, DIDT_InfoDwo, + DIDT_Types, DIDT_Line, DIDT_Loc, DIDT_Ranges, -- cgit v1.1 From 118a0659ab8a4d0e0af343b88e5fa71a5c1eb6a6 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Mon, 23 Sep 2013 23:26:57 +0000 Subject: Explicitly request unsigned enum types when desired The underlying type of all plain enums in MSVC is 'int', even if the enumerator contains large 32-bit unsigned values or values greater than UINT_MAX. The only way to get a large or unsigned enum type is to request it explicitly with the C++11 strong enum types feature. However, since LLVM isn't C++11 yet, I had to add a conditional LLVM_ENUM_INT_TYPE to Compiler.h to control its usage. The motivating true positive for this change is compiling PointerIntPair with MSVC for win64. The PointerIntMask value is supposed to be pointer sized value of all ones with some low zeros. Instead, it's truncated to 32-bits! We are only saved later because it is sign extended back in the AND with int64_t, and we happen to want all ones. This silences lots of -Wmicrosoft warnings during a clang self-host targeting Windows. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191241 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/PointerIntPair.h | 3 ++- include/llvm/IR/Attributes.h | 3 ++- include/llvm/IR/InlineAsm.h | 2 +- include/llvm/MC/MCSectionMachO.h | 2 +- include/llvm/MC/MachineLocation.h | 5 ++++- include/llvm/Object/ObjectFile.h | 2 +- include/llvm/Support/COFF.h | 2 +- include/llvm/Support/Compiler.h | 12 ++++++++++++ include/llvm/Support/Dwarf.h | 5 +++-- include/llvm/Support/ELF.h | 12 ++++++------ include/llvm/Support/MachO.h | 25 +++++++++++++------------ 11 files changed, 46 insertions(+), 27 deletions(-) (limited to 'include') diff --git a/include/llvm/ADT/PointerIntPair.h b/include/llvm/ADT/PointerIntPair.h index 0299a83..0cfd470 100644 --- a/include/llvm/ADT/PointerIntPair.h +++ b/include/llvm/ADT/PointerIntPair.h @@ -14,6 +14,7 @@ #ifndef LLVM_ADT_POINTERINTPAIR_H #define LLVM_ADT_POINTERINTPAIR_H +#include "llvm/Support/Compiler.h" #include "llvm/Support/PointerLikeTypeTraits.h" #include @@ -40,7 +41,7 @@ template > class PointerIntPair { intptr_t Value; - enum { + enum LLVM_ENUM_INT_TYPE(uintptr_t) { /// PointerBitMask - The bits that come from the pointer. PointerBitMask = ~(uintptr_t)(((intptr_t)1 << PtrTraits::NumLowBitsAvailable)-1), diff --git a/include/llvm/IR/Attributes.h b/include/llvm/IR/Attributes.h index ebee637..c23ba0f 100644 --- a/include/llvm/IR/Attributes.h +++ b/include/llvm/IR/Attributes.h @@ -18,6 +18,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/FoldingSet.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/PointerLikeTypeTraits.h" #include #include @@ -200,7 +201,7 @@ public: /// index `1'. class AttributeSet { public: - enum AttrIndex { + enum AttrIndex LLVM_ENUM_INT_TYPE(unsigned) { ReturnIndex = 0U, FunctionIndex = ~0U }; diff --git a/include/llvm/IR/InlineAsm.h b/include/llvm/IR/InlineAsm.h index 33e4ab8..3398a83 100644 --- a/include/llvm/IR/InlineAsm.h +++ b/include/llvm/IR/InlineAsm.h @@ -197,7 +197,7 @@ public: // These are helper methods for dealing with flags in the INLINEASM SDNode // in the backend. - enum { + enum LLVM_ENUM_INT_TYPE(uint32_t) { // Fixed operands on an INLINEASM SDNode. Op_InputChain = 0, Op_AsmString = 1, diff --git a/include/llvm/MC/MCSectionMachO.h b/include/llvm/MC/MCSectionMachO.h index b68bd85..d7e88ea 100644 --- a/include/llvm/MC/MCSectionMachO.h +++ b/include/llvm/MC/MCSectionMachO.h @@ -41,7 +41,7 @@ public: /// These are the section type and attributes fields. A MachO section can /// have only one Type, but can have any of the attributes specified. - enum { + enum LLVM_ENUM_INT_TYPE(uint32_t) { // TypeAndAttributes bitmasks. SECTION_TYPE = 0x000000FFU, SECTION_ATTRIBUTES = 0xFFFFFF00U, diff --git a/include/llvm/MC/MachineLocation.h b/include/llvm/MC/MachineLocation.h index 7d9abc3..b3fbee7 100644 --- a/include/llvm/MC/MachineLocation.h +++ b/include/llvm/MC/MachineLocation.h @@ -16,6 +16,9 @@ #ifndef LLVM_MC_MACHINELOCATION_H #define LLVM_MC_MACHINELOCATION_H +#include "llvm/Support/Compiler.h" +#include "llvm/Support/DataTypes.h" + namespace llvm { class MCSymbol; @@ -25,7 +28,7 @@ private: unsigned Register; // gcc/gdb register number. int Offset; // Displacement if not register. public: - enum { + enum LLVM_ENUM_INT_TYPE(uint32_t) { // The target register number for an abstract frame pointer. The value is // an arbitrary value that doesn't collide with any real target register. VirtualFP = ~0U diff --git a/include/llvm/Object/ObjectFile.h b/include/llvm/Object/ObjectFile.h index f434d63..6973c67 100644 --- a/include/llvm/Object/ObjectFile.h +++ b/include/llvm/Object/ObjectFile.h @@ -192,7 +192,7 @@ public: ST_Other }; - enum Flags { + enum Flags LLVM_ENUM_INT_TYPE(unsigned) { SF_None = 0, SF_Undefined = 1U << 0, // Symbol is defined in another object file SF_Global = 1U << 1, // Global symbol diff --git a/include/llvm/Support/COFF.h b/include/llvm/Support/COFF.h index 541d563c..9cc3989 100644 --- a/include/llvm/Support/COFF.h +++ b/include/llvm/Support/COFF.h @@ -222,7 +222,7 @@ namespace COFF { uint32_t Characteristics; }; - enum SectionCharacteristics { + enum SectionCharacteristics LLVM_ENUM_INT_TYPE(uint32_t) { SC_Invalid = 0xffffffff, IMAGE_SCN_TYPE_NO_PAD = 0x00000008, diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index c32a485..13920fc 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -391,4 +391,16 @@ # define LLVM_STATIC_ASSERT(expr, msg) #endif +/// \macro LLVM_ENUM_INT_TYPE +/// \brief Expands to colon followed by the given integral type on compilers +/// which support C++11 strong enums. This can be used to make enums unsigned +/// with MSVC. +#if __has_feature(cxx_strong_enums) +# define LLVM_ENUM_INT_TYPE(intty) : intty +#elif defined(_MSC_VER) && _MSC_VER >= 1600 // Added in MSVC 2010. +# define LLVM_ENUM_INT_TYPE(intty) : intty +#else +# define LLVM_ENUM_INT_TYPE(intty) +#endif + #endif diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index 70c46db..0f33541 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -16,6 +16,7 @@ #ifndef LLVM_SUPPORT_DWARF_H #define LLVM_SUPPORT_DWARF_H +#include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" namespace llvm { @@ -23,7 +24,7 @@ namespace llvm { //===----------------------------------------------------------------------===// // Debug info constants. -enum { +enum LLVM_ENUM_INT_TYPE(uint32_t) { LLVMDebugVersion = (12 << 16), // Current version of debug information. LLVMDebugVersion11 = (11 << 16), // Constant for version 11. LLVMDebugVersion10 = (10 << 16), // Constant for version 10. @@ -46,7 +47,7 @@ namespace dwarf { // Do not mix the following two enumerations sets. DW_TAG_invalid changes the // enumeration base type. -enum LLVMConstants { +enum LLVMConstants LLVM_ENUM_INT_TYPE(uint32_t) { // llvm mock tags DW_TAG_invalid = ~0U, // Tag for invalid results. diff --git a/include/llvm/Support/ELF.h b/include/llvm/Support/ELF.h index 8f92832..61d1a0d 100644 --- a/include/llvm/Support/ELF.h +++ b/include/llvm/Support/ELF.h @@ -650,7 +650,7 @@ enum { }; // ARM Specific e_flags -enum { +enum LLVM_ENUM_INT_TYPE(unsigned) { EF_ARM_SOFT_FLOAT = 0x00000200U, EF_ARM_VFP_FLOAT = 0x00000400U, EF_ARM_EABI_UNKNOWN = 0x00000000U, @@ -800,7 +800,7 @@ enum { }; // Mips Specific e_flags -enum { +enum LLVM_ENUM_INT_TYPE(unsigned) { EF_MIPS_NOREORDER = 0x00000001, // Don't reorder instructions EF_MIPS_PIC = 0x00000002, // Position independent code EF_MIPS_CPIC = 0x00000004, // Call object with Position independent code @@ -1116,7 +1116,7 @@ enum { }; // Section types. -enum { +enum LLVM_ENUM_INT_TYPE(unsigned) { SHT_NULL = 0, // No associated section (inactive entry). SHT_PROGBITS = 1, // Program-defined contents. SHT_SYMTAB = 2, // Symbol table. @@ -1164,7 +1164,7 @@ enum { }; // Section flags. -enum { +enum LLVM_ENUM_INT_TYPE(unsigned) { // Section data should be writable during execution. SHF_WRITE = 0x1, @@ -1234,7 +1234,7 @@ enum { }; // Section Group Flags -enum { +enum LLVM_ENUM_INT_TYPE(unsigned) { GRP_COMDAT = 0x1, GRP_MASKOS = 0x0ff00000, GRP_MASKPROC = 0xf0000000 @@ -1451,7 +1451,7 @@ enum { }; // Segment flag bits. -enum { +enum LLVM_ENUM_INT_TYPE(unsigned) { PF_X = 1, // Execute PF_W = 2, // Write PF_R = 4, // Read diff --git a/include/llvm/Support/MachO.h b/include/llvm/Support/MachO.h index 59998ad..b2ac6b3 100644 --- a/include/llvm/Support/MachO.h +++ b/include/llvm/Support/MachO.h @@ -14,13 +14,14 @@ #ifndef LLVM_SUPPORT_MACHO_H #define LLVM_SUPPORT_MACHO_H +#include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Host.h" namespace llvm { namespace MachO { // Enums from - enum { + enum LLVM_ENUM_INT_TYPE(uint32_t) { // Constants for the "magic" field in llvm::MachO::mach_header and // llvm::MachO::mach_header_64 MH_MAGIC = 0xFEEDFACEu, @@ -75,12 +76,12 @@ namespace llvm { MH_DEAD_STRIPPABLE_DYLIB = 0x00400000u }; - enum { + enum LLVM_ENUM_INT_TYPE(uint32_t) { // Flags for the "cmd" field in llvm::MachO::load_command LC_REQ_DYLD = 0x80000000u }; - enum LoadCommandType { + enum LoadCommandType LLVM_ENUM_INT_TYPE(uint32_t) { // Constants for the "cmd" field in llvm::MachO::load_command LC_SEGMENT = 0x00000001u, LC_SYMTAB = 0x00000002u, @@ -130,7 +131,7 @@ namespace llvm { LC_LINKER_OPTIONS = 0x0000002Du }; - enum { + enum LLVM_ENUM_INT_TYPE(uint32_t) { // Constant bits for the "flags" field in llvm::MachO::segment_command SG_HIGHVM = 0x1u, SG_FVMLIB = 0x2u, @@ -173,7 +174,7 @@ namespace llvm { S_THREAD_LOCAL_INIT_FUNCTION_POINTERS = 0x15u }; - enum { + enum LLVM_ENUM_INT_TYPE(uint32_t) { // Constant masks for the "flags[31:24]" field in llvm::MachO::section and // llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_USR) S_ATTR_PURE_INSTRUCTIONS = 0x80000000u, @@ -235,9 +236,9 @@ namespace llvm { }; enum BindSpecialDylib { - BIND_SPECIAL_DYLIB_SELF = 0u, - BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE = -1u, - BIND_SPECIAL_DYLIB_FLAT_LOOKUP = -2u + BIND_SPECIAL_DYLIB_SELF = 0, + BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE = -1, + BIND_SPECIAL_DYLIB_FLAT_LOOKUP = -2 }; enum { @@ -347,7 +348,7 @@ namespace llvm { N_LENG = 0xFEu }; - enum { + enum LLVM_ENUM_INT_TYPE(uint32_t) { // Constant values for the r_symbolnum field in an // llvm::MachO::relocation_info structure when r_extern is 0. R_ABS = 0, @@ -892,7 +893,7 @@ namespace llvm { } // Enums from - enum { + enum LLVM_ENUM_INT_TYPE(uint32_t) { // Capability bits used in the definition of cpu_type. CPU_ARCH_MASK = 0xff000000, // Mask for architecture bits CPU_ARCH_ABI64 = 0x01000000 // 64 bit ABI @@ -912,13 +913,13 @@ namespace llvm { CPU_TYPE_POWERPC64 = CPU_TYPE_POWERPC | CPU_ARCH_ABI64 }; - enum { + enum LLVM_ENUM_INT_TYPE(uint32_t) { // Capability bits used in the definition of cpusubtype. CPU_SUB_TYPE_MASK = 0xff000000, // Mask for architecture bits CPU_SUB_TYPE_LIB64 = 0x80000000, // 64 bit libraries // Special CPU subtype constants. - CPU_SUBTYPE_MULTIPLE = -1 + CPU_SUBTYPE_MULTIPLE = ~0u }; // Constants for the cpusubtype field. -- cgit v1.1 From 477fc628b3c9ce1c970d4a678dd5607b15242cc8 Mon Sep 17 00:00:00 2001 From: Jiangning Liu Date: Tue, 24 Sep 2013 02:47:27 +0000 Subject: Initial support for Neon scalar instructions. Patch by Ana Pazos. 1.Added support for v1ix and v1fx types. 2.Added Scalar Pairwise Reduce instructions. 3.Added initial implementation of Scalar Arithmetic instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191263 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/ValueTypes.h | 91 +++++++++++++++++++++--------------- include/llvm/CodeGen/ValueTypes.td | 73 +++++++++++++++-------------- include/llvm/IR/Intrinsics.td | 3 ++ include/llvm/IR/IntrinsicsAArch64.td | 79 ++++++++++++++++++++++++++++--- 4 files changed, 167 insertions(+), 79 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h index 82b8d8a..18b324f 100644 --- a/include/llvm/CodeGen/ValueTypes.h +++ b/include/llvm/CodeGen/ValueTypes.h @@ -67,41 +67,44 @@ namespace llvm { v32i1 = 17, // 32 x i1 v64i1 = 18, // 64 x i1 - v2i8 = 19, // 2 x i8 - v4i8 = 20, // 4 x i8 - v8i8 = 21, // 8 x i8 - v16i8 = 22, // 16 x i8 - v32i8 = 23, // 32 x i8 - v64i8 = 24, // 64 x i8 - v1i16 = 25, // 1 x i16 - v2i16 = 26, // 2 x i16 - v4i16 = 27, // 4 x i16 - v8i16 = 28, // 8 x i16 - v16i16 = 29, // 16 x i16 - v32i16 = 30, // 32 x i16 - v1i32 = 31, // 1 x i32 - v2i32 = 32, // 2 x i32 - v4i32 = 33, // 4 x i32 - v8i32 = 34, // 8 x i32 - v16i32 = 35, // 16 x i32 - v1i64 = 36, // 1 x i64 - v2i64 = 37, // 2 x i64 - v4i64 = 38, // 4 x i64 - v8i64 = 39, // 8 x i64 - v16i64 = 40, // 16 x i64 + v1i8 = 19, // 1 x i8 + v2i8 = 20, // 2 x i8 + v4i8 = 21, // 4 x i8 + v8i8 = 22, // 8 x i8 + v16i8 = 23, // 16 x i8 + v32i8 = 24, // 32 x i8 + v64i8 = 25, // 64 x i8 + v1i16 = 26, // 1 x i16 + v2i16 = 27, // 2 x i16 + v4i16 = 28, // 4 x i16 + v8i16 = 29, // 8 x i16 + v16i16 = 30, // 16 x i16 + v32i16 = 31, // 32 x i16 + v1i32 = 32, // 1 x i32 + v2i32 = 33, // 2 x i32 + v4i32 = 34, // 4 x i32 + v8i32 = 35, // 8 x i32 + v16i32 = 36, // 16 x i32 + v1i64 = 37, // 1 x i64 + v2i64 = 38, // 2 x i64 + v4i64 = 39, // 4 x i64 + v8i64 = 40, // 8 x i64 + v16i64 = 41, // 16 x i64 FIRST_INTEGER_VECTOR_VALUETYPE = v2i1, LAST_INTEGER_VECTOR_VALUETYPE = v16i64, - v2f16 = 41, // 2 x f16 - v8f16 = 42, // 8 x f16 - v2f32 = 43, // 2 x f32 - v4f32 = 44, // 4 x f32 - v8f32 = 45, // 8 x f32 - v16f32 = 46, // 16 x f32 - v2f64 = 47, // 2 x f64 - v4f64 = 48, // 4 x f64 - v8f64 = 49, // 8 x f64 + v2f16 = 42, // 2 x f16 + v8f16 = 43, // 8 x f16 + v1f32 = 44, // 1 x f32 + v2f32 = 45, // 2 x f32 + v4f32 = 46, // 4 x f32 + v8f32 = 47, // 8 x f32 + v16f32 = 48, // 16 x f32 + v1f64 = 49, // 1 x f64 + v2f64 = 50, // 2 x f64 + v4f64 = 51, // 4 x f64 + v8f64 = 52, // 8 x f64 FIRST_FP_VECTOR_VALUETYPE = v2f16, LAST_FP_VECTOR_VALUETYPE = v8f64, @@ -109,17 +112,17 @@ namespace llvm { FIRST_VECTOR_VALUETYPE = v2i1, LAST_VECTOR_VALUETYPE = v8f64, - x86mmx = 50, // This is an X86 MMX value + x86mmx = 53, // This is an X86 MMX value - Glue = 51, // This glues nodes together during pre-RA sched + Glue = 54, // This glues nodes together during pre-RA sched - isVoid = 52, // This has no value + isVoid = 55, // This has no value - Untyped = 53, // This value takes a register, but has + Untyped = 56, // This value takes a register, but has // unspecified type. The register class // will be determined by the opcode. - LAST_VALUETYPE = 54, // This always remains at the end of the list. + LAST_VALUETYPE = 57, // This always remains at the end of the list. // This is the current maximum for LAST_VALUETYPE. // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors @@ -266,6 +269,7 @@ namespace llvm { case v16i1 : case v32i1 : case v64i1: return i1; + case v1i8 : case v2i8 : case v4i8 : case v8i8 : @@ -290,10 +294,12 @@ namespace llvm { case v16i64: return i64; case v2f16: case v8f16: return f16; + case v1f32: case v2f32: case v4f32: case v8f32: case v16f32: return f32; + case v1f64: case v2f64: case v4f64: case v8f64: return f64; @@ -338,9 +344,12 @@ namespace llvm { case v2f16: case v2f32: case v2f64: return 2; + case v1i8: case v1i16: case v1i32: - case v1i64: return 1; + case v1i64: + case v1f32: + case v1f64: return 1; } } @@ -363,6 +372,7 @@ namespace llvm { case v2i1: return 2; case v4i1: return 4; case i8 : + case v1i8: case v8i1: return 8; case i16 : case f16: @@ -375,6 +385,7 @@ namespace llvm { case v4i8: case v2i16: case v2f16: + case v1f32: case v1i32: return 32; case x86mmx: case f64 : @@ -384,7 +395,8 @@ namespace llvm { case v4i16: case v2i32: case v1i64: - case v2f32: return 64; + case v2f32: + case v1f64: return 64; case f80 : return 80; case f128: case ppcf128: @@ -494,6 +506,7 @@ namespace llvm { if (NumElements == 64) return MVT::v64i1; break; case MVT::i8: + if (NumElements == 1) return MVT::v1i8; if (NumElements == 2) return MVT::v2i8; if (NumElements == 4) return MVT::v4i8; if (NumElements == 8) return MVT::v8i8; @@ -528,12 +541,14 @@ namespace llvm { if (NumElements == 8) return MVT::v8f16; break; case MVT::f32: + if (NumElements == 1) return MVT::v1f32; if (NumElements == 2) return MVT::v2f32; if (NumElements == 4) return MVT::v4f32; if (NumElements == 8) return MVT::v8f32; if (NumElements == 16) return MVT::v16f32; break; case MVT::f64: + if (NumElements == 1) return MVT::v1f64; if (NumElements == 2) return MVT::v2f64; if (NumElements == 4) return MVT::v4f64; if (NumElements == 8) return MVT::v8f64; diff --git a/include/llvm/CodeGen/ValueTypes.td b/include/llvm/CodeGen/ValueTypes.td index 28ad936..415dbed 100644 --- a/include/llvm/CodeGen/ValueTypes.td +++ b/include/llvm/CodeGen/ValueTypes.td @@ -39,44 +39,47 @@ def v8i1 : ValueType<8 , 15>; // 8 x i1 vector value def v16i1 : ValueType<16, 16>; // 16 x i1 vector value def v32i1 : ValueType<32 , 17>; // 32 x i1 vector value def v64i1 : ValueType<64 , 18>; // 64 x i1 vector value -def v2i8 : ValueType<16 , 19>; // 2 x i8 vector value -def v4i8 : ValueType<32 , 20>; // 4 x i8 vector value -def v8i8 : ValueType<64 , 21>; // 8 x i8 vector value -def v16i8 : ValueType<128, 22>; // 16 x i8 vector value -def v32i8 : ValueType<256, 23>; // 32 x i8 vector value -def v64i8 : ValueType<512, 24>; // 64 x i8 vector value -def v1i16 : ValueType<16 , 25>; // 1 x i16 vector value -def v2i16 : ValueType<32 , 26>; // 2 x i16 vector value -def v4i16 : ValueType<64 , 27>; // 4 x i16 vector value -def v8i16 : ValueType<128, 28>; // 8 x i16 vector value -def v16i16 : ValueType<256, 29>; // 16 x i16 vector value -def v32i16 : ValueType<512, 30>; // 32 x i16 vector value -def v1i32 : ValueType<32 , 31>; // 1 x i32 vector value -def v2i32 : ValueType<64 , 32>; // 2 x i32 vector value -def v4i32 : ValueType<128, 33>; // 4 x i32 vector value -def v8i32 : ValueType<256, 34>; // 8 x i32 vector value -def v16i32 : ValueType<512, 35>; // 16 x i32 vector value -def v1i64 : ValueType<64 , 36>; // 1 x i64 vector value -def v2i64 : ValueType<128, 37>; // 2 x i64 vector value -def v4i64 : ValueType<256, 38>; // 4 x i64 vector value -def v8i64 : ValueType<512, 39>; // 8 x i64 vector value -def v16i64 : ValueType<1024,40>; // 16 x i64 vector value +def v1i8 : ValueType<16, 19>; // 1 x i8 vector value +def v2i8 : ValueType<16 , 20>; // 2 x i8 vector value +def v4i8 : ValueType<32 , 21>; // 4 x i8 vector value +def v8i8 : ValueType<64 , 22>; // 8 x i8 vector value +def v16i8 : ValueType<128, 23>; // 16 x i8 vector value +def v32i8 : ValueType<256, 24>; // 32 x i8 vector value +def v64i8 : ValueType<512, 25>; // 64 x i8 vector value +def v1i16 : ValueType<16 , 26>; // 1 x i16 vector value +def v2i16 : ValueType<32 , 27>; // 2 x i16 vector value +def v4i16 : ValueType<64 , 28>; // 4 x i16 vector value +def v8i16 : ValueType<128, 29>; // 8 x i16 vector value +def v16i16 : ValueType<256, 30>; // 16 x i16 vector value +def v32i16 : ValueType<512, 31>; // 32 x i16 vector value +def v1i32 : ValueType<32 , 32>; // 1 x i32 vector value +def v2i32 : ValueType<64 , 33>; // 2 x i32 vector value +def v4i32 : ValueType<128, 34>; // 4 x i32 vector value +def v8i32 : ValueType<256, 35>; // 8 x i32 vector value +def v16i32 : ValueType<512, 36>; // 16 x i32 vector value +def v1i64 : ValueType<64 , 37>; // 1 x i64 vector value +def v2i64 : ValueType<128, 38>; // 2 x i64 vector value +def v4i64 : ValueType<256, 39>; // 4 x i64 vector value +def v8i64 : ValueType<512, 40>; // 8 x i64 vector value +def v16i64 : ValueType<1024,41>; // 16 x i64 vector value -def v2f16 : ValueType<32 , 41>; // 2 x f16 vector value -def v8f16 : ValueType<128, 42>; // 8 x f16 vector value -def v2f32 : ValueType<64 , 43>; // 2 x f32 vector value -def v4f32 : ValueType<128, 44>; // 4 x f32 vector value -def v8f32 : ValueType<256, 45>; // 8 x f32 vector value -def v16f32 : ValueType<512, 46>; // 16 x f32 vector value -def v2f64 : ValueType<128, 47>; // 2 x f64 vector value -def v4f64 : ValueType<256, 48>; // 4 x f64 vector value -def v8f64 : ValueType<512, 49>; // 8 x f64 vector value +def v2f16 : ValueType<32 , 42>; // 2 x f16 vector value +def v8f16 : ValueType<128, 43>; // 8 x f16 vector value +def v1f32 : ValueType<32 , 44>; // 1 x f32 vector value +def v2f32 : ValueType<64 , 45>; // 2 x f32 vector value +def v4f32 : ValueType<128, 46>; // 4 x f32 vector value +def v8f32 : ValueType<256, 47>; // 8 x f32 vector value +def v16f32 : ValueType<512, 48>; // 16 x f32 vector value +def v1f64 : ValueType<64, 49>; // 1 x f64 vector value +def v2f64 : ValueType<128, 50>; // 2 x f64 vector value +def v4f64 : ValueType<256, 51>; // 4 x f64 vector value +def v8f64 : ValueType<512, 52>; // 8 x f64 vector value -def x86mmx : ValueType<64 , 50>; // X86 MMX value -def FlagVT : ValueType<0 , 51>; // Pre-RA sched glue -def isVoid : ValueType<0 , 52>; // Produces no value -def untyped: ValueType<8 , 53>; // Produces an untyped value +def x86mmx : ValueType<64 , 53>; // X86 MMX value +def FlagVT : ValueType<0 , 54>; // Pre-RA sched glue +def isVoid : ValueType<0 , 55>; // Produces no value +def untyped: ValueType<8 , 56>; // Produces an untyped value def MetadataVT: ValueType<0, 250>; // Metadata // Pseudo valuetype mapped to the current pointer size to any address space. diff --git a/include/llvm/IR/Intrinsics.td b/include/llvm/IR/Intrinsics.td index c7414e0..30cd4be 100644 --- a/include/llvm/IR/Intrinsics.td +++ b/include/llvm/IR/Intrinsics.td @@ -140,6 +140,7 @@ def llvm_v8i1_ty : LLVMType; // 8 x i1 def llvm_v16i1_ty : LLVMType; // 16 x i1 def llvm_v32i1_ty : LLVMType; // 32 x i1 def llvm_v64i1_ty : LLVMType; // 64 x i1 +def llvm_v1i8_ty : LLVMType; // 1 x i8 def llvm_v2i8_ty : LLVMType; // 2 x i8 def llvm_v4i8_ty : LLVMType; // 4 x i8 def llvm_v8i8_ty : LLVMType; // 8 x i8 @@ -166,10 +167,12 @@ def llvm_v8i64_ty : LLVMType; // 8 x i64 def llvm_v16i64_ty : LLVMType; // 16 x i64 def llvm_v8f16_ty : LLVMType; // 8 x half (__fp16) +def llvm_v1f32_ty : LLVMType; // 1 x float def llvm_v2f32_ty : LLVMType; // 2 x float def llvm_v4f32_ty : LLVMType; // 4 x float def llvm_v8f32_ty : LLVMType; // 8 x float def llvm_v16f32_ty : LLVMType; // 16 x float +def llvm_v1f64_ty : LLVMType; // 1 x double def llvm_v2f64_ty : LLVMType; // 2 x double def llvm_v4f64_ty : LLVMType; // 4 x double def llvm_v8f64_ty : LLVMType; // 8 x double diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 0a71ea4..4f7252d 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -17,12 +17,10 @@ let TargetPrefix = "aarch64" in { // All intrinsics start with "llvm.aarch64.". // Vector Absolute Compare (Floating Point) -def int_aarch64_neon_vacgeq : Intrinsic<[llvm_v2i64_ty], - [llvm_v2f64_ty, llvm_v2f64_ty], - [IntrNoMem]>; -def int_aarch64_neon_vacgtq : Intrinsic<[llvm_v2i64_ty], - [llvm_v2f64_ty, llvm_v2f64_ty], - [IntrNoMem]>; +def int_aarch64_neon_vacgeq : + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; +def int_aarch64_neon_vacgtq : + Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; // Vector maxNum (Floating Point) def int_aarch64_neon_vmaxnm : Neon_2Arg_Intrinsic; @@ -66,4 +64,73 @@ def int_aarch64_neon_vsqshrn : Neon_N2V_Narrow_Intrinsic; def int_aarch64_neon_vuqshrn : Neon_N2V_Narrow_Intrinsic; def int_aarch64_neon_vsqrshrn : Neon_N2V_Narrow_Intrinsic; def int_aarch64_neon_vuqrshrn : Neon_N2V_Narrow_Intrinsic; + +// Scalar Add +def int_aarch64_neon_vaddds : + Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], [IntrNoMem]>; +def int_aarch64_neon_vadddu : + Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], [IntrNoMem]>; + +// Scalar Saturating Add (Signed, Unsigned) +def int_aarch64_neon_vqadds : Neon_2Arg_Intrinsic; +def int_aarch64_neon_vqaddu : Neon_2Arg_Intrinsic; + +// Scalar Sub +def int_aarch64_neon_vsubds : + Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], [IntrNoMem]>; +def int_aarch64_neon_vsubdu : + Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], [IntrNoMem]>; + +// Scalar Saturating Sub (Signed, Unsigned) +def int_aarch64_neon_vqsubs : Neon_2Arg_Intrinsic; +def int_aarch64_neon_vqsubu : Neon_2Arg_Intrinsic; + +// Scalar Shift +// Scalar Shift Left +def int_aarch64_neon_vshlds : + Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], [IntrNoMem]>; +def int_aarch64_neon_vshldu : + Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], [IntrNoMem]>; + +// Scalar Saturating Shift Left +def int_aarch64_neon_vqshls : Neon_2Arg_Intrinsic; +def int_aarch64_neon_vqshlu : Neon_2Arg_Intrinsic; + +// Scalar Shift Rouding Left +def int_aarch64_neon_vrshlds : + Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], [IntrNoMem]>; +def int_aarch64_neon_vrshldu : + Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], [IntrNoMem]>; + +// Scalar Saturating Rounding Shift Left +def int_aarch64_neon_vqrshls : Neon_2Arg_Intrinsic; +def int_aarch64_neon_vqrshlu : Neon_2Arg_Intrinsic; + +// Scalar Reduce Pairwise Add. +def int_aarch64_neon_vpadd : + Intrinsic<[llvm_v1i64_ty], [llvm_v2i64_ty],[IntrNoMem]>; +def int_aarch64_neon_vpfadd : + Intrinsic<[llvm_v1f32_ty], [llvm_v2f32_ty], [IntrNoMem]>; +def int_aarch64_neon_vpfaddq : + Intrinsic<[llvm_v1f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; + +// Scalar Reduce Pairwise Floating Point Max/Min. +def int_aarch64_neon_vpmax : + Intrinsic<[llvm_v1f32_ty], [llvm_v2f32_ty], [IntrNoMem]>; +def int_aarch64_neon_vpmaxq : + Intrinsic<[llvm_v1f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; +def int_aarch64_neon_vpmin : + Intrinsic<[llvm_v1f32_ty], [llvm_v2f32_ty], [IntrNoMem]>; +def int_aarch64_neon_vpminq : + Intrinsic<[llvm_v1f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; + +// Scalar Reduce Pairwise Floating Point Maxnm/Minnm. +def int_aarch64_neon_vpfmaxnm : + Intrinsic<[llvm_v1f32_ty], [llvm_v2f32_ty], [IntrNoMem]>; +def int_aarch64_neon_vpfmaxnmq : + Intrinsic<[llvm_v1f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; +def int_aarch64_neon_vpfminnm : + Intrinsic<[llvm_v1f32_ty], [llvm_v2f32_ty], [IntrNoMem]>; +def int_aarch64_neon_vpfminnmq : + Intrinsic<[llvm_v1f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; } -- cgit v1.1 From 38a10ff063971c2f7f7384cceba3253bca32e27a Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Tue, 24 Sep 2013 12:04:44 +0000 Subject: [mips][msa] Added support for matching bsel and bseli from normal IR (i.e. not intrinsics) This required correcting the definition of the bsel and bseli intrinsics. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191290 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 055a8cf..abca235 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -644,16 +644,12 @@ def int_mips_bnz_v : GCCBuiltin<"__builtin_msa_bnz_v">, Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty], [IntrNoMem]>; def int_mips_bsel_v : GCCBuiltin<"__builtin_msa_bsel_v">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty], + [IntrNoMem]>; def int_mips_bseli_b : GCCBuiltin<"__builtin_msa_bseli_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; -def int_mips_bseli_h : GCCBuiltin<"__builtin_msa_bseli_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; -def int_mips_bseli_w : GCCBuiltin<"__builtin_msa_bseli_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; -def int_mips_bseli_d : GCCBuiltin<"__builtin_msa_bseli_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty], + [IntrNoMem]>; def int_mips_bset_b : GCCBuiltin<"__builtin_msa_bset_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; -- cgit v1.1 From 7e0df9aa2966d0462e34511524a4958e226b74ee Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Tue, 24 Sep 2013 14:02:15 +0000 Subject: [mips][msa] Added support for matching vshf from normal IR (i.e. not intrinsics) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191301 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index abca235..01158e3 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -1728,13 +1728,17 @@ def int_mips_subvi_d : GCCBuiltin<"__builtin_msa_subvi_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_vshf_b : GCCBuiltin<"__builtin_msa_vshf_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty], + [IntrNoMem]>; def int_mips_vshf_h : GCCBuiltin<"__builtin_msa_vshf_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], + [IntrNoMem]>; def int_mips_vshf_w : GCCBuiltin<"__builtin_msa_vshf_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], + [IntrNoMem]>; def int_mips_vshf_d : GCCBuiltin<"__builtin_msa_vshf_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty], + [IntrNoMem]>; def int_mips_xor_v : GCCBuiltin<"__builtin_msa_xor_v">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; -- cgit v1.1 From 6629210aaf9d2e4fcbecc80b35f72108304da4b4 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 24 Sep 2013 16:37:51 +0000 Subject: Teach MemoryBuiltins and InstructionSimplify that operator new never returns NULL. This is safe per C++11 18.6.1.1p3: [operator new returns] a non-null pointer to suitably aligned storage (3.7.4), or else throw a bad_alloc exception. This requirement is binding on a replacement version of this function. Brings us a tiny bit closer to eliminating more vector push_backs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191310 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/MemoryBuiltins.h | 4 ++++ include/llvm/Analysis/ValueTracking.h | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Analysis/MemoryBuiltins.h b/include/llvm/Analysis/MemoryBuiltins.h index 0d1ae8c..587b87f 100644 --- a/include/llvm/Analysis/MemoryBuiltins.h +++ b/include/llvm/Analysis/MemoryBuiltins.h @@ -64,6 +64,10 @@ bool isAllocLikeFn(const Value *V, const TargetLibraryInfo *TLI, bool isReallocLikeFn(const Value *V, const TargetLibraryInfo *TLI, bool LookThroughBitCast = false); +/// \brief Tests if a value is a call or invoke to a library function that +/// allocates memory and never returns null (such as operator new). +bool isOperatorNewLikeFn(const Value *V, const TargetLibraryInfo *TLI, + bool LookThroughBitCast = false); //===----------------------------------------------------------------------===// // malloc Call Utility Functions. diff --git a/include/llvm/Analysis/ValueTracking.h b/include/llvm/Analysis/ValueTracking.h index 3775ec9..0392f98 100644 --- a/include/llvm/Analysis/ValueTracking.h +++ b/include/llvm/Analysis/ValueTracking.h @@ -25,6 +25,7 @@ namespace llvm { class DataLayout; class StringRef; class MDNode; + class TargetLibraryInfo; /// ComputeMaskedBits - Determine which of the bits specified in Mask are /// known to be either zero or one and return them in the KnownZero/KnownOne @@ -186,7 +187,7 @@ namespace llvm { /// isKnownNonNull - Return true if this pointer couldn't possibly be null by /// its definition. This returns true for allocas, non-extern-weak globals /// and byval arguments. - bool isKnownNonNull(const Value *V); + bool isKnownNonNull(const Value *V, const TargetLibraryInfo *TLI = 0); } // end namespace llvm -- cgit v1.1 From 9ddf28d501144276fb47ce2e5f48f2497d9898d5 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 24 Sep 2013 19:50:00 +0000 Subject: llvm-dwarfdump support for gnu_pubtypes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191329 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo/DIContext.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/DebugInfo/DIContext.h b/include/llvm/DebugInfo/DIContext.h index 1b42138..d181a83 100644 --- a/include/llvm/DebugInfo/DIContext.h +++ b/include/llvm/DebugInfo/DIContext.h @@ -110,6 +110,7 @@ enum DIDumpType { DIDT_Ranges, DIDT_Pubnames, DIDT_GnuPubnames, + DIDT_GnuPubtypes, DIDT_Str, DIDT_StrDwo, DIDT_StrOffsetsDwo -- cgit v1.1 From cc48854d5d51a2d7557f1040a61f160ad86c9729 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Tue, 24 Sep 2013 23:52:22 +0000 Subject: Move LTO support library to a component, allowing it to be tested more reliably across platforms. Patch by Tom Roeder! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191343 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/LTO/LTOCodeGenerator.h | 130 ++++++++++++++++++++++++ include/llvm/LTO/LTOModule.h | 196 ++++++++++++++++++++++++++++++++++++ 2 files changed, 326 insertions(+) create mode 100644 include/llvm/LTO/LTOCodeGenerator.h create mode 100644 include/llvm/LTO/LTOModule.h (limited to 'include') diff --git a/include/llvm/LTO/LTOCodeGenerator.h b/include/llvm/LTO/LTOCodeGenerator.h new file mode 100644 index 0000000..3d151b9 --- /dev/null +++ b/include/llvm/LTO/LTOCodeGenerator.h @@ -0,0 +1,130 @@ +//===-LTOCodeGenerator.h - LLVM Link Time Optimizer -----------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the LTOCodeGenerator class. +// +// LTO compilation consists of three phases: Pre-IPO, IPO and Post-IPO. +// +// The Pre-IPO phase compiles source code into bitcode file. The resulting +// bitcode files, along with object files and libraries, will be fed to the +// linker to through the IPO and Post-IPO phases. By using obj-file extension, +// the resulting bitcode file disguises itself as an object file, and therefore +// obviates the need of writing a special set of the make-rules only for LTO +// compilation. +// +// The IPO phase perform inter-procedural analyses and optimizations, and +// the Post-IPO consists two sub-phases: intra-procedural scalar optimizations +// (SOPT), and intra-procedural target-dependent code generator (CG). +// +// As of this writing, we don't separate IPO and the Post-IPO SOPT. They +// are intermingled together, and are driven by a single pass manager (see +// PassManagerBuilder::populateLTOPassManager()). +// +// The "LTOCodeGenerator" is the driver for the IPO and Post-IPO stages. +// The "CodeGenerator" here is bit confusing. Don't confuse the "CodeGenerator" +// with the machine specific code generator. +// +//===----------------------------------------------------------------------===// + +#ifndef LTO_CODE_GENERATOR_H +#define LTO_CODE_GENERATOR_H + +#include "llvm-c/lto.h" +#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/Linker.h" +#include +#include + +namespace llvm { + class LLVMContext; + class GlobalValue; + class Mangler; + class MemoryBuffer; + class TargetMachine; + class raw_ostream; +} + +//===----------------------------------------------------------------------===// +/// LTOCodeGenerator - C++ class which implements the opaque lto_code_gen_t +/// type. +/// +struct LTOCodeGenerator { + static const char *getVersionString(); + + LTOCodeGenerator(); + ~LTOCodeGenerator(); + + // Merge given module, return true on success. + bool addModule(struct LTOModule*, std::string &errMsg); + + void setDebugInfo(lto_debug_model); + void setCodePICModel(lto_codegen_model); + + void setCpu(const char *mCpu) { MCpu = mCpu; } + + void addMustPreserveSymbol(const char *sym) { MustPreserveSymbols[sym] = 1; } + + // To pass options to the driver and optimization passes. These options are + // not necessarily for debugging purpose (The function name is misleading). + // This function should be called before LTOCodeGenerator::compilexxx(), + // and LTOCodeGenerator::writeMergedModules(). + // + void setCodeGenDebugOptions(const char *opts); + + // Write the merged module to the file specified by the given path. + // Return true on success. + bool writeMergedModules(const char *path, std::string &errMsg); + + // Compile the merged module into a *single* object file; the path to object + // file is returned to the caller via argument "name". Return true on + // success. + // + // NOTE that it is up to the linker to remove the intermediate object file. + // Do not try to remove the object file in LTOCodeGenerator's destructor + // as we don't who (LTOCodeGenerator or the obj file) will last longer. + // + bool compile_to_file(const char **name, std::string &errMsg); + + // As with compile_to_file(), this function compiles the merged module into + // single object file. Instead of returning the object-file-path to the caller + // (linker), it brings the object to a buffer, and return the buffer to the + // caller. This function should delete intermediate object file once its content + // is brought to memory. Return NULL if the compilation was not successful. + // + const void *compile(size_t *length, std::string &errMsg); + +private: + void initializeLTOPasses(); + + bool generateObjectFile(llvm::raw_ostream &out, std::string &errMsg); + void applyScopeRestrictions(); + void applyRestriction(llvm::GlobalValue &GV, + std::vector &MustPreserveList, + llvm::SmallPtrSet &AsmUsed, + llvm::Mangler &Mangler); + bool determineTarget(std::string &errMsg); + + typedef llvm::StringMap StringSet; + + llvm::LLVMContext &Context; + llvm::Linker Linker; + llvm::TargetMachine *TargetMach; + bool EmitDwarfDebugInfo; + bool ScopeRestrictionsDone; + lto_codegen_model CodeModel; + StringSet MustPreserveSymbols; + StringSet AsmUndefinedRefs; + llvm::MemoryBuffer *NativeObjectFile; + std::vector CodegenOptions; + std::string MCpu; + std::string NativeObjectPath; +}; + +#endif // LTO_CODE_GENERATOR_H diff --git a/include/llvm/LTO/LTOModule.h b/include/llvm/LTO/LTOModule.h new file mode 100644 index 0000000..973466c --- /dev/null +++ b/include/llvm/LTO/LTOModule.h @@ -0,0 +1,196 @@ +//===-LTOModule.h - LLVM Link Time Optimizer ------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the LTOModule class. +// +//===----------------------------------------------------------------------===// + +#ifndef LTO_MODULE_H +#define LTO_MODULE_H + +#include "llvm-c/lto.h" +#include "llvm/ADT/OwningPtr.h" +#include "llvm/ADT/StringMap.h" +#include "llvm/IR/Module.h" +#include "llvm/MC/MCContext.h" +#include "llvm/Target/Mangler.h" +#include "llvm/Target/TargetMachine.h" +#include +#include + +// Forward references to llvm classes. +namespace llvm { + class Function; + class GlobalValue; + class MemoryBuffer; + class TargetOptions; + class Value; +} + +//===----------------------------------------------------------------------===// +/// LTOModule - C++ class which implements the opaque lto_module_t type. +/// +struct LTOModule { +private: + typedef llvm::StringMap StringSet; + + struct NameAndAttributes { + const char *name; + uint32_t attributes; + bool isFunction; + const llvm::GlobalValue *symbol; + }; + + llvm::OwningPtr _module; + llvm::OwningPtr _target; + std::vector _symbols; + + // _defines and _undefines only needed to disambiguate tentative definitions + StringSet _defines; + llvm::StringMap _undefines; + std::vector _asm_undefines; + llvm::MCContext _context; + + // Use mangler to add GlobalPrefix to names to match linker names. + llvm::Mangler _mangler; + + LTOModule(llvm::Module *m, llvm::TargetMachine *t); +public: + /// isBitcodeFile - Returns 'true' if the file or memory contents is LLVM + /// bitcode. + static bool isBitcodeFile(const void *mem, size_t length); + static bool isBitcodeFile(const char *path); + + /// isBitcodeFileForTarget - Returns 'true' if the file or memory contents + /// is LLVM bitcode for the specified triple. + static bool isBitcodeFileForTarget(const void *mem, + size_t length, + const char *triplePrefix); + static bool isBitcodeFileForTarget(const char *path, + const char *triplePrefix); + + /// makeLTOModule - Create an LTOModule. N.B. These methods take ownership + /// of the buffer. The caller must have initialized the Targets, the + /// TargetMCs, the AsmPrinters, and the AsmParsers by calling: + /// + /// InitializeAllTargets(); + /// InitializeAllTargetMCs(); + /// InitializeAllAsmPrinters(); + /// InitializeAllAsmParsers(); + static LTOModule *makeLTOModule(const char* path, + std::string &errMsg); + static LTOModule *makeLTOModule(int fd, const char *path, + size_t size, std::string &errMsg); + static LTOModule *makeLTOModule(int fd, const char *path, + size_t map_size, + off_t offset, + std::string& errMsg); + static LTOModule *makeLTOModule(const void *mem, size_t length, + std::string &errMsg); + + /// getTargetTriple - Return the Module's target triple. + const char *getTargetTriple() { + return _module->getTargetTriple().c_str(); + } + + /// setTargetTriple - Set the Module's target triple. + void setTargetTriple(const char *triple) { + _module->setTargetTriple(triple); + } + + /// getSymbolCount - Get the number of symbols + uint32_t getSymbolCount() { + return _symbols.size(); + } + + /// getSymbolAttributes - Get the attributes for a symbol at the specified + /// index. + lto_symbol_attributes getSymbolAttributes(uint32_t index) { + if (index < _symbols.size()) + return lto_symbol_attributes(_symbols[index].attributes); + return lto_symbol_attributes(0); + } + + /// getSymbolName - Get the name of the symbol at the specified index. + const char *getSymbolName(uint32_t index) { + if (index < _symbols.size()) + return _symbols[index].name; + return NULL; + } + + /// getLLVVMModule - Return the Module. + llvm::Module *getLLVVMModule() { return _module.get(); } + + /// getAsmUndefinedRefs - + const std::vector &getAsmUndefinedRefs() { + return _asm_undefines; + } + + /// getTargetOptions - Fill the TargetOptions object with the options + /// specified on the command line. + static void getTargetOptions(llvm::TargetOptions &Options); + +private: + /// parseSymbols - Parse the symbols from the module and model-level ASM and + /// add them to either the defined or undefined lists. + bool parseSymbols(std::string &errMsg); + + /// addPotentialUndefinedSymbol - Add a symbol which isn't defined just yet + /// to a list to be resolved later. + void addPotentialUndefinedSymbol(const llvm::GlobalValue *dcl, bool isFunc); + + /// addDefinedSymbol - Add a defined symbol to the list. + void addDefinedSymbol(const llvm::GlobalValue *def, bool isFunction); + + /// addDefinedFunctionSymbol - Add a function symbol as defined to the list. + void addDefinedFunctionSymbol(const llvm::Function *f); + + /// addDefinedDataSymbol - Add a data symbol as defined to the list. + void addDefinedDataSymbol(const llvm::GlobalValue *v); + + /// addAsmGlobalSymbols - Add global symbols from module-level ASM to the + /// defined or undefined lists. + bool addAsmGlobalSymbols(std::string &errMsg); + + /// addAsmGlobalSymbol - Add a global symbol from module-level ASM to the + /// defined list. + void addAsmGlobalSymbol(const char *, lto_symbol_attributes scope); + + /// addAsmGlobalSymbolUndef - Add a global symbol from module-level ASM to + /// the undefined list. + void addAsmGlobalSymbolUndef(const char *); + + /// addObjCClass - Parse i386/ppc ObjC class data structure. + void addObjCClass(const llvm::GlobalVariable *clgv); + + /// addObjCCategory - Parse i386/ppc ObjC category data structure. + void addObjCCategory(const llvm::GlobalVariable *clgv); + + /// addObjCClassRef - Parse i386/ppc ObjC class list data structure. + void addObjCClassRef(const llvm::GlobalVariable *clgv); + + /// objcClassNameFromExpression - Get string that the data pointer points + /// to. + bool objcClassNameFromExpression(const llvm::Constant* c, std::string &name); + + /// isTargetMatch - Returns 'true' if the memory buffer is for the specified + /// target triple. + static bool isTargetMatch(llvm::MemoryBuffer *memBuffer, + const char *triplePrefix); + + /// makeLTOModule - Create an LTOModule (private version). N.B. This + /// method takes ownership of the buffer. + static LTOModule *makeLTOModule(llvm::MemoryBuffer *buffer, + std::string &errMsg); + + /// makeBuffer - Create a MemoryBuffer from a memory range. + static llvm::MemoryBuffer *makeBuffer(const void *mem, size_t length); +}; + +#endif // LTO_MODULE_H -- cgit v1.1 From aca74f0e0d221a0dfe355adcdf0592bb64461df7 Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 25 Sep 2013 07:11:58 +0000 Subject: Wrap the #include of in an #ifndef __cplusplus. This should fix the MSVC build. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191357 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/lto.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm-c/lto.h b/include/llvm-c/lto.h index 40110fd..d960617 100644 --- a/include/llvm-c/lto.h +++ b/include/llvm-c/lto.h @@ -16,7 +16,9 @@ #ifndef LLVM_C_LTO_H #define LLVM_C_LTO_H +#ifndef __cplusplus #include +#endif #include #include -- cgit v1.1 From e8a665f696b60834a3087e3d5bccf8cacf3ca39d Mon Sep 17 00:00:00 2001 From: Peter Collingbourne Date: Wed, 25 Sep 2013 07:52:21 +0000 Subject: Try again to fix the MSVC build. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191359 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/lto.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm-c/lto.h b/include/llvm-c/lto.h index d960617..58d5833 100644 --- a/include/llvm-c/lto.h +++ b/include/llvm-c/lto.h @@ -20,7 +20,7 @@ #include #endif #include -#include +#include /** * @defgroup LLVMCLTO LTO -- cgit v1.1 From 8ba3f9c9008223136207295b48b53c8aefffa178 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 25 Sep 2013 09:36:11 +0000 Subject: MC: Remove vestigial PCSymbol field from AsmInfo git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191362 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAsmInfo.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h index 186a8f6..f5acd17 100644 --- a/include/llvm/MC/MCAsmInfo.h +++ b/include/llvm/MC/MCAsmInfo.h @@ -93,10 +93,6 @@ namespace llvm { /// this value. Factored out in .debug_frame and .debug_line. unsigned MinInstAlignment; // Defaults to 1. - /// PCSymbol - The symbol used to represent the current PC. Used in PC - /// relative expressions. - const char *PCSymbol; // Defaults to "$". - /// SeparatorString - This string, if specified, is used to separate /// instructions from each other when on the same line. const char *SeparatorString; // Defaults to ';' @@ -425,9 +421,6 @@ namespace llvm { unsigned getMinInstAlignment() const { return MinInstAlignment; } - const char *getPCSymbol() const { - return PCSymbol; - } const char *getSeparatorString() const { return SeparatorString; } -- cgit v1.1 From 3f22cc1df64a6dd6a3ecc5e7e261f15af083f806 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Wed, 25 Sep 2013 10:47:21 +0000 Subject: MC: Add support for treating $ as a reference to the PC The binutils assembler supports a mode called DOLLAR_DOT which treats the dollar sign token as a reference to the current program counter if the dollar sign doesn't precede a constant or identifier. This commit adds a new MCAsmInfo flag stating whether or not a given target supports this interpretation of the dollar sign token; by default, this flag is not enabled. Further, enable this flag for PPC. The system assembler for AIX and binutils both support using the dollar sign in this manner. This fixes PR17353. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191368 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAsmInfo.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h index f5acd17..3734d7e 100644 --- a/include/llvm/MC/MCAsmInfo.h +++ b/include/llvm/MC/MCAsmInfo.h @@ -93,6 +93,10 @@ namespace llvm { /// this value. Factored out in .debug_frame and .debug_line. unsigned MinInstAlignment; // Defaults to 1. + /// DollarIsPC - The '$' token, when not referencing an identifier or + /// constant, refers to the current PC. + bool DollarIsPC; // Defaults to false. + /// SeparatorString - This string, if specified, is used to separate /// instructions from each other when on the same line. const char *SeparatorString; // Defaults to ';' @@ -421,6 +425,9 @@ namespace llvm { unsigned getMinInstAlignment() const { return MinInstAlignment; } + bool getDollarIsPC() const { + return DollarIsPC; + } const char *getSeparatorString() const { return SeparatorString; } -- cgit v1.1 From 2558c2bfbaa4bfd49ee8e06be78a0ccb0f3ff0e7 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Wed, 25 Sep 2013 17:49:57 +0000 Subject: Undefine NetBSD, it may have been defined by an earlier include of sys/param.h. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191384 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/Triple.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/ADT/Triple.h b/include/llvm/ADT/Triple.h index 3fccf41..84e0b29 100644 --- a/include/llvm/ADT/Triple.h +++ b/include/llvm/ADT/Triple.h @@ -14,6 +14,7 @@ // Some system headers or GCC predefined macros conflict with identifiers in // this file. Undefine them here. +#undef NetBSD #undef mips #undef sparc -- cgit v1.1 From 070156437752179833b1e5fddd50caa03fd7c12f Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Wed, 25 Sep 2013 18:14:12 +0000 Subject: Mark the x86 machine model as incomplete. PR17367. Ideally, the machinel model is added at the time the instructions are defined. But many instructions in X86InstrSSE.td still need a model. Without this workaround the scheduler asserts because x86 already has itinerary classes for these instructions, indicating they should be modeled by the scheduler. Since we use the new machine model for other instructions, it expects a new machine model for these too. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191391 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCSchedule.h | 15 +++++++++++---- include/llvm/Target/TargetSchedule.td | 9 +++++++++ 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCSchedule.h b/include/llvm/MC/MCSchedule.h index 673cdf6..1edf204 100644 --- a/include/llvm/MC/MCSchedule.h +++ b/include/llvm/MC/MCSchedule.h @@ -174,6 +174,8 @@ public: unsigned MispredictPenalty; static const unsigned DefaultMispredictPenalty = 10; + bool CompleteModel; + private: unsigned ProcID; const MCProcResourceDesc *ProcResourceTable; @@ -194,6 +196,7 @@ public: LoadLatency(DefaultLoadLatency), HighLatency(DefaultHighLatency), MispredictPenalty(DefaultMispredictPenalty), + CompleteModel(true), ProcID(0), ProcResourceTable(0), SchedClassTable(0), NumProcResourceKinds(0), NumSchedClasses(0), InstrItineraries(0) { @@ -203,19 +206,23 @@ public: // Table-gen driven ctor. MCSchedModel(unsigned iw, int mbs, unsigned ll, unsigned hl, - unsigned mp, unsigned pi, const MCProcResourceDesc *pr, + unsigned mp, bool cm, unsigned pi, const MCProcResourceDesc *pr, const MCSchedClassDesc *sc, unsigned npr, unsigned nsc, const InstrItinerary *ii): IssueWidth(iw), MicroOpBufferSize(mbs), LoadLatency(ll), HighLatency(hl), - MispredictPenalty(mp), ProcID(pi), ProcResourceTable(pr), - SchedClassTable(sc), NumProcResourceKinds(npr), NumSchedClasses(nsc), - InstrItineraries(ii) {} + MispredictPenalty(mp), CompleteModel(cm), ProcID(pi), + ProcResourceTable(pr), SchedClassTable(sc), NumProcResourceKinds(npr), + NumSchedClasses(nsc), InstrItineraries(ii) {} unsigned getProcessorID() const { return ProcID; } /// Does this machine model include instruction-level scheduling. bool hasInstrSchedModel() const { return SchedClassTable; } + /// Return true if this machine model data for all instructions with a + /// scheduling class (itinerary class or SchedRW list). + bool isComplete() const { return CompleteModel; } + unsigned getNumProcResourceKinds() const { return NumProcResourceKinds; } diff --git a/include/llvm/Target/TargetSchedule.td b/include/llvm/Target/TargetSchedule.td index 575cb83..e81a2fb 100644 --- a/include/llvm/Target/TargetSchedule.td +++ b/include/llvm/Target/TargetSchedule.td @@ -86,6 +86,15 @@ class SchedMachineModel { // Per-cycle resources tables. ProcessorItineraries Itineraries = NoItineraries; + // Subtargets that define a model for only a subset of instructions + // that have a scheduling class (itinerary class or SchedRW list) + // and may actually be generated for that subtarget must clear this + // bit. Otherwise, the scheduler considers an unmodelled opcode to + // be an error. This should only be set during initial bringup, + // or there will be no way to catch simple errors in the model + // resulting from changes to the instruction definitions. + bit CompleteModel = 1; + bit NoModel = 0; // Special tag to indicate missing machine model. } -- cgit v1.1 From 7357f03e888e7d95066ca1bbb26994c278eb465c Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Wed, 25 Sep 2013 23:02:41 +0000 Subject: Dump the normal dwarf pubtypes section as well. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191408 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo/DIContext.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/DebugInfo/DIContext.h b/include/llvm/DebugInfo/DIContext.h index d181a83..a1a4642 100644 --- a/include/llvm/DebugInfo/DIContext.h +++ b/include/llvm/DebugInfo/DIContext.h @@ -109,6 +109,7 @@ enum DIDumpType { DIDT_Loc, DIDT_Ranges, DIDT_Pubnames, + DIDT_Pubtypes, DIDT_GnuPubnames, DIDT_GnuPubtypes, DIDT_Str, -- cgit v1.1 From b6ac11cd03e9dd97b45dc97787171f942ef8e344 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Thu, 26 Sep 2013 05:53:35 +0000 Subject: Added temp flag -misched-bench for staging in default changes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191423 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetSubtargetInfo.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm/Target/TargetSubtargetInfo.h b/include/llvm/Target/TargetSubtargetInfo.h index 37365b2..1b2e06a 100644 --- a/include/llvm/Target/TargetSubtargetInfo.h +++ b/include/llvm/Target/TargetSubtargetInfo.h @@ -56,6 +56,9 @@ public: return 0; } + /// \brief Temporary API to test migration to MI scheduler. + bool useMachineScheduler() const; + /// \brief True if the subtarget should run MachineScheduler after aggressive /// coalescing. /// -- cgit v1.1 From 268c743a3ba44ada364938bc5ff9b1be219df54f Mon Sep 17 00:00:00 2001 From: Amara Emerson Date: Thu, 26 Sep 2013 12:22:36 +0000 Subject: [ARM] Use the load-acquire/store-release instructions optimally in AArch32. Patch by Artyom Skrobov. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191428 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/ISDOpcodes.h | 6 ++++++ include/llvm/CodeGen/SelectionDAG.h | 7 +++++++ include/llvm/CodeGen/SelectionDAGNodes.h | 21 +++++++++++++++++---- 3 files changed, 30 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/ISDOpcodes.h b/include/llvm/CodeGen/ISDOpcodes.h index 45bb7e3..3a49dd8 100644 --- a/include/llvm/CodeGen/ISDOpcodes.h +++ b/include/llvm/CodeGen/ISDOpcodes.h @@ -604,11 +604,17 @@ namespace ISD { ATOMIC_STORE, /// Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) + /// For double-word atomic operations: + /// ValLo, ValHi, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmpLo, cmpHi, + /// swapLo, swapHi) /// This corresponds to the cmpxchg instruction. ATOMIC_CMP_SWAP, /// Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) /// Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amt) + /// For double-word atomic operations: + /// ValLo, ValHi, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amtLo, amtHi) + /// ValLo, ValHi, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN, ptr, amtLo, amtHi) /// These correspond to the atomicrmw instruction. ATOMIC_SWAP, ATOMIC_LOAD_ADD, diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index 79e533e..70920d1 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -677,6 +677,13 @@ public: AtomicOrdering Ordering, SynchronizationScope SynchScope); + /// getAtomic - Gets a node for an atomic op, produces result and chain and + /// takes N operands. + SDValue getAtomic(unsigned Opcode, SDLoc dl, EVT MemVT, SDVTList VTList, + SDValue* Ops, unsigned NumOps, MachineMemOperand *MMO, + AtomicOrdering Ordering, + SynchronizationScope SynchScope); + /// getMemIntrinsicNode - Creates a MemIntrinsicNode that may produce a /// result and takes a list of operands. Opcode may be INTRINSIC_VOID, /// INTRINSIC_W_CHAIN, or a target-specific opcode with a value not diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index dc9bfbc..4166340 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -1073,6 +1073,7 @@ public: /// class AtomicSDNode : public MemSDNode { SDUse Ops[4]; + SDUse* DynOps; void InitAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope) { // This must match encodeMemSDNodeFlags() in SelectionDAG.cpp. @@ -1100,7 +1101,7 @@ public: SDValue Chain, SDValue Ptr, SDValue Cmp, SDValue Swp, MachineMemOperand *MMO, AtomicOrdering Ordering, SynchronizationScope SynchScope) - : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) { + : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO), DynOps(NULL) { InitAtomic(Ordering, SynchScope); InitOperands(Ops, Chain, Ptr, Cmp, Swp); } @@ -1109,7 +1110,7 @@ public: SDValue Chain, SDValue Ptr, SDValue Val, MachineMemOperand *MMO, AtomicOrdering Ordering, SynchronizationScope SynchScope) - : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) { + : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO), DynOps(NULL) { InitAtomic(Ordering, SynchScope); InitOperands(Ops, Chain, Ptr, Val); } @@ -1118,10 +1119,22 @@ public: SDValue Chain, SDValue Ptr, MachineMemOperand *MMO, AtomicOrdering Ordering, SynchronizationScope SynchScope) - : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) { + : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO), DynOps(NULL) { InitAtomic(Ordering, SynchScope); InitOperands(Ops, Chain, Ptr); } + AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL, EVT MemVT, + SDValue* AllOps, unsigned NumOps, + MachineMemOperand *MMO, + AtomicOrdering Ordering, SynchronizationScope SynchScope) + : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) { + DynOps = new SDUse[NumOps]; + InitAtomic(Ordering, SynchScope); + InitOperands(DynOps, AllOps, NumOps); + } + ~AtomicSDNode() { + delete[] DynOps; + } const SDValue &getBasePtr() const { return getOperand(1); } const SDValue &getVal() const { return getOperand(2); } @@ -1852,7 +1865,7 @@ template <> struct GraphTraits { /// LargestSDNode - The largest SDNode class. /// -typedef LoadSDNode LargestSDNode; +typedef AtomicSDNode LargestSDNode; /// MostAlignedSDNode - The SDNode class with the greatest alignment /// requirement. -- cgit v1.1 From 83ba58e5f0a5afbb23d7d2092d817accded4455a Mon Sep 17 00:00:00 2001 From: Venkatraman Govindaraju Date: Thu, 26 Sep 2013 14:49:40 +0000 Subject: Implements parsing and emitting of .cfi_window_save in MC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191431 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCDwarf.h | 8 +++++++- include/llvm/MC/MCStreamer.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/MC/MCDwarf.h b/include/llvm/MC/MCDwarf.h index 7a06cc0..65b920b 100644 --- a/include/llvm/MC/MCDwarf.h +++ b/include/llvm/MC/MCDwarf.h @@ -290,7 +290,8 @@ public: OpEscape, OpRestore, OpUndefined, - OpRegister + OpRegister, + OpWindowSave }; private: @@ -364,6 +365,11 @@ public: return MCCFIInstruction(OpRegister, L, Register1, Register2); } + /// \brief .cfi_window_save SPARC register window is saved. + static MCCFIInstruction createWindowSave(MCSymbol *L) { + return MCCFIInstruction(OpWindowSave, L, 0, 0, ""); + } + /// \brief .cfi_restore says that the rule for Register is now the same as it /// was at the beginning of the function, after all initial instructions added /// by .cfi_startproc were executed. diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 8cb5c49..a5f8bc0 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -578,6 +578,7 @@ public: virtual void EmitCFISignalFrame(); virtual void EmitCFIUndefined(int64_t Register); virtual void EmitCFIRegister(int64_t Register1, int64_t Register2); + virtual void EmitCFIWindowSave(); virtual void EmitWin64EHStartProc(const MCSymbol *Symbol); virtual void EmitWin64EHEndProc(); -- cgit v1.1 From 0c873adc82a81b0bce317c3e2cb3139e990a0f9e Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 27 Sep 2013 00:07:01 +0000 Subject: llvm-objdump: Dump COFF import table if -private-headers option is given. This is a patch to add capability to llvm-objdump to dump COFF Import Table entries, so that we can write tests for LLD checking Import Table contents. llvm-objdump did not print anything but just file name if the format is COFF and -private-headers option is given. This is a patch adds capability for dumping DLL Import Table, which is specific to the COFF format. In this patch I defined a new iterator to iterate over import table entries. Also added a few functions to COFFObjectFile.cpp to access fields of the entry. Differential Revision: http://llvm-reviews.chandlerc.com/D1719 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191472 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/COFF.h | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h index cb464ab..e9ea547 100644 --- a/include/llvm/Object/COFF.h +++ b/include/llvm/Object/COFF.h @@ -23,6 +23,8 @@ namespace llvm { class ArrayRef; namespace object { +class ImportDirectoryEntryRef; +typedef content_iterator import_directory_iterator; /// The DOS compatible header at the front of all PE/COFF executables. struct dos_header { @@ -202,6 +204,7 @@ struct coff_aux_section_definition { class COFFObjectFile : public ObjectFile { private: + friend class ImportDirectoryEntryRef; const coff_file_header *COFFHeader; const pe32_header *PE32Header; const data_directory *DataDirectory; @@ -209,6 +212,8 @@ private: const coff_symbol *SymbolTable; const char *StringTable; uint32_t StringTableSize; + const import_directory_table_entry *ImportDirectory; + uint32_t NumberOfImportDirectory; error_code getString(uint32_t offset, StringRef &Res) const; @@ -216,6 +221,9 @@ private: const coff_section *toSec(DataRefImpl Sec) const; const coff_relocation *toRel(DataRefImpl Rel) const; + error_code initSymbolTablePtr(); + error_code initImportTablePtr(); + protected: virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const; virtual error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const; @@ -287,6 +295,9 @@ public: virtual unsigned getArch() const; virtual StringRef getLoadName() const; + import_directory_iterator getImportDirectoryBegin() const; + import_directory_iterator getImportDirectoryEnd() const; + error_code getHeader(const coff_file_header *&Res) const; error_code getCOFFHeader(const coff_file_header *&Res) const; error_code getPE32Header(const pe32_header *&Res) const; @@ -307,12 +318,37 @@ public: error_code getSectionContents(const coff_section *Sec, ArrayRef &Res) const; + error_code getRvaPtr(uint32_t Rva, uintptr_t &Res) const; + error_code getHintName(uint32_t Rva, uint16_t &Hint, StringRef &Name) const; + static inline bool classof(const Binary *v) { return v->isCOFF(); } }; -} -} +// The iterator for the import directory table. +class ImportDirectoryEntryRef { +public: + ImportDirectoryEntryRef() : OwningObject(0) {} + ImportDirectoryEntryRef(DataRefImpl ImportDirectory, + const COFFObjectFile *Owner) + : ImportDirectoryPimpl(ImportDirectory), OwningObject(Owner) {} + + bool operator==(const ImportDirectoryEntryRef &Other) const; + error_code getNext(ImportDirectoryEntryRef &Result) const; + error_code getName(StringRef &Result) const; + + error_code + getImportTableEntry(const import_directory_table_entry *&Result) const; + + error_code + getImportLookupEntry(const COFF::ImportLookupTableEntry32 *&Result) const; + +private: + DataRefImpl ImportDirectoryPimpl; + const COFFObjectFile *OwningObject; +}; +} // end namespace object +} // end namespace llvm #endif -- cgit v1.1 From 4715a11dcfe79de2a7a8b0b633d6ca272eea0bc3 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 27 Sep 2013 01:29:36 +0000 Subject: Revert "llvm-objdump: Dump COFF import table if -private-headers option is given." This reverts commit r191472 because it's failing on BE machine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191480 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/COFF.h | 40 ++-------------------------------------- 1 file changed, 2 insertions(+), 38 deletions(-) (limited to 'include') diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h index e9ea547..cb464ab 100644 --- a/include/llvm/Object/COFF.h +++ b/include/llvm/Object/COFF.h @@ -23,8 +23,6 @@ namespace llvm { class ArrayRef; namespace object { -class ImportDirectoryEntryRef; -typedef content_iterator import_directory_iterator; /// The DOS compatible header at the front of all PE/COFF executables. struct dos_header { @@ -204,7 +202,6 @@ struct coff_aux_section_definition { class COFFObjectFile : public ObjectFile { private: - friend class ImportDirectoryEntryRef; const coff_file_header *COFFHeader; const pe32_header *PE32Header; const data_directory *DataDirectory; @@ -212,8 +209,6 @@ private: const coff_symbol *SymbolTable; const char *StringTable; uint32_t StringTableSize; - const import_directory_table_entry *ImportDirectory; - uint32_t NumberOfImportDirectory; error_code getString(uint32_t offset, StringRef &Res) const; @@ -221,9 +216,6 @@ private: const coff_section *toSec(DataRefImpl Sec) const; const coff_relocation *toRel(DataRefImpl Rel) const; - error_code initSymbolTablePtr(); - error_code initImportTablePtr(); - protected: virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const; virtual error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const; @@ -295,9 +287,6 @@ public: virtual unsigned getArch() const; virtual StringRef getLoadName() const; - import_directory_iterator getImportDirectoryBegin() const; - import_directory_iterator getImportDirectoryEnd() const; - error_code getHeader(const coff_file_header *&Res) const; error_code getCOFFHeader(const coff_file_header *&Res) const; error_code getPE32Header(const pe32_header *&Res) const; @@ -318,37 +307,12 @@ public: error_code getSectionContents(const coff_section *Sec, ArrayRef &Res) const; - error_code getRvaPtr(uint32_t Rva, uintptr_t &Res) const; - error_code getHintName(uint32_t Rva, uint16_t &Hint, StringRef &Name) const; - static inline bool classof(const Binary *v) { return v->isCOFF(); } }; -// The iterator for the import directory table. -class ImportDirectoryEntryRef { -public: - ImportDirectoryEntryRef() : OwningObject(0) {} - ImportDirectoryEntryRef(DataRefImpl ImportDirectory, - const COFFObjectFile *Owner) - : ImportDirectoryPimpl(ImportDirectory), OwningObject(Owner) {} - - bool operator==(const ImportDirectoryEntryRef &Other) const; - error_code getNext(ImportDirectoryEntryRef &Result) const; - error_code getName(StringRef &Result) const; - - error_code - getImportTableEntry(const import_directory_table_entry *&Result) const; - - error_code - getImportLookupEntry(const COFF::ImportLookupTableEntry32 *&Result) const; - -private: - DataRefImpl ImportDirectoryPimpl; - const COFFObjectFile *OwningObject; -}; -} // end namespace object -} // end namespace llvm +} +} #endif -- cgit v1.1 From e8eafdb67685d4f5d52ab0dce2339c37e39cdc44 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Fri, 27 Sep 2013 13:04:21 +0000 Subject: [mips][msa] Implemented copy_[us].d intrinsic. This intrinsic is lowered into equivalent copy_s.w instructions during legalization. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191518 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 01158e3..e90c975 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -780,6 +780,8 @@ def int_mips_copy_s_h : GCCBuiltin<"__builtin_msa_copy_s_h">, Intrinsic<[llvm_i32_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_copy_s_w : GCCBuiltin<"__builtin_msa_copy_s_w">, Intrinsic<[llvm_i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; +def int_mips_copy_s_d : GCCBuiltin<"__builtin_msa_copy_s_d">, + Intrinsic<[llvm_i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_copy_u_b : GCCBuiltin<"__builtin_msa_copy_u_b">, Intrinsic<[llvm_i32_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; @@ -787,6 +789,8 @@ def int_mips_copy_u_h : GCCBuiltin<"__builtin_msa_copy_u_h">, Intrinsic<[llvm_i32_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_copy_u_w : GCCBuiltin<"__builtin_msa_copy_u_w">, Intrinsic<[llvm_i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; +def int_mips_copy_u_d : GCCBuiltin<"__builtin_msa_copy_u_d">, + Intrinsic<[llvm_i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_ctcmsa : GCCBuiltin<"__builtin_msa_ctcmsa">, Intrinsic<[], [llvm_i32_ty, llvm_i32_ty], []>; -- cgit v1.1 From 9f30d43122dce961ae1625c2c429bf74bf292324 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Fri, 27 Sep 2013 13:20:41 +0000 Subject: [mips][msa] Implemented fill.d intrinsic. This intrinsic is lowered into an equivalent BUILD_VECTOR which is further lowered into a sequence of insert.w's on MIPS32. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191519 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index e90c975..53e2142 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -983,6 +983,8 @@ def int_mips_fill_h : GCCBuiltin<"__builtin_msa_fill_h">, Intrinsic<[llvm_v8i16_ty], [llvm_i32_ty], [IntrNoMem]>; def int_mips_fill_w : GCCBuiltin<"__builtin_msa_fill_w">, Intrinsic<[llvm_v4i32_ty], [llvm_i32_ty], [IntrNoMem]>; +def int_mips_fill_d : GCCBuiltin<"__builtin_msa_fill_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_i64_ty], [IntrNoMem]>; def int_mips_flog2_w : GCCBuiltin<"__builtin_msa_flog2_w">, Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], [IntrNoMem]>; -- cgit v1.1 From 4d835f1cbe5d8c5f6cea4040bea9b180927a1c05 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Fri, 27 Sep 2013 13:36:54 +0000 Subject: [mips][msa] Implemented insert.d intrinsic. This intrinsic is lowered into an equivalent INSERT_VECTOR_ELT which is further lowered into a sequence of insert.w's on MIPS32. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191521 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 53e2142..5d8a7be 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -1208,6 +1208,9 @@ def int_mips_insert_h : GCCBuiltin<"__builtin_msa_insert_h">, def int_mips_insert_w : GCCBuiltin<"__builtin_msa_insert_w">, Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>; +def int_mips_insert_d : GCCBuiltin<"__builtin_msa_insert_d">, + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty, llvm_i64_ty], + [IntrNoMem]>; def int_mips_insve_b : GCCBuiltin<"__builtin_msa_insve_b">, Intrinsic<[llvm_v16i8_ty], -- cgit v1.1 From 685707c28e2c7117f025fb4e95e6ca64ed179bb0 Mon Sep 17 00:00:00 2001 From: Yunzhong Gao Date: Fri, 27 Sep 2013 18:38:42 +0000 Subject: Adding intrinsics to the llvm backend for TBM instruction set. Phabricator code review is located here: http://llvm-reviews.chandlerc.com/D1750 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191539 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 66 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index ac48bc0..3352d67 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -2594,6 +2594,72 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". } //===----------------------------------------------------------------------===// +// TBM + +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_tbm_bextri_u32 : GCCBuiltin<"__builtin_ia32_bextri_u32">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_tbm_bextri_u64 : GCCBuiltin<"__builtin_ia32_bextri_u64">, + Intrinsic<[llvm_i64_ty], [llvm_i64_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_tbm_blcfill_u32 : GCCBuiltin<"__builtin_ia32_blcfill_u32">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty], + [IntrNoMem]>; + def int_x86_tbm_blcfill_u64 : GCCBuiltin<"__builtin_ia32_blcfill_u64">, + Intrinsic<[llvm_i64_ty], [llvm_i64_ty], + [IntrNoMem]>; + def int_x86_tbm_blci_u32 : GCCBuiltin<"__builtin_ia32_blci_u32">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty], + [IntrNoMem]>; + def int_x86_tbm_blci_u64 : GCCBuiltin<"__builtin_ia32_blci_u64">, + Intrinsic<[llvm_i64_ty], [llvm_i64_ty], + [IntrNoMem]>; + def int_x86_tbm_blcic_u32 : GCCBuiltin<"__builtin_ia32_blcic_u32">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty], + [IntrNoMem]>; + def int_x86_tbm_blcic_u64 : GCCBuiltin<"__builtin_ia32_blcic_u64">, + Intrinsic<[llvm_i64_ty], [llvm_i64_ty], + [IntrNoMem]>; + def int_x86_tbm_blcmsk_u32 : GCCBuiltin<"__builtin_ia32_blcmsk_u32">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty], + [IntrNoMem]>; + def int_x86_tbm_blcmsk_u64 : GCCBuiltin<"__builtin_ia32_blcmsk_u64">, + Intrinsic<[llvm_i64_ty], [llvm_i64_ty], + [IntrNoMem]>; + def int_x86_tbm_blcs_u32 : GCCBuiltin<"__builtin_ia32_blcs_u32">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty], + [IntrNoMem]>; + def int_x86_tbm_blcs_u64 : GCCBuiltin<"__builtin_ia32_blcs_u64">, + Intrinsic<[llvm_i64_ty], [llvm_i64_ty], + [IntrNoMem]>; + def int_x86_tbm_blsfill_u32 : GCCBuiltin<"__builtin_ia32_blsfill_u32">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty], + [IntrNoMem]>; + def int_x86_tbm_blsfill_u64 : GCCBuiltin<"__builtin_ia32_blsfill_u64">, + Intrinsic<[llvm_i64_ty], [llvm_i64_ty], + [IntrNoMem]>; + def int_x86_tbm_blsic_u32 : GCCBuiltin<"__builtin_ia32_blsic_u32">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty], + [IntrNoMem]>; + def int_x86_tbm_blsic_u64 : GCCBuiltin<"__builtin_ia32_blsic_u64">, + Intrinsic<[llvm_i64_ty], [llvm_i64_ty], + [IntrNoMem]>; + def int_x86_tbm_t1mskc_u32 : GCCBuiltin<"__builtin_ia32_t1mskc_u32">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty], + [IntrNoMem]>; + def int_x86_tbm_t1mskc_u64 : GCCBuiltin<"__builtin_ia32_t1mskc_u64">, + Intrinsic<[llvm_i64_ty], [llvm_i64_ty], + [IntrNoMem]>; + def int_x86_tbm_tzmsk_u32 : GCCBuiltin<"__builtin_ia32_tzmsk_u32">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty], + [IntrNoMem]>; + def int_x86_tbm_tzmsk_u64 : GCCBuiltin<"__builtin_ia32_tzmsk_u64">, + Intrinsic<[llvm_i64_ty], [llvm_i64_ty], + [IntrNoMem]>; +} + +//===----------------------------------------------------------------------===// // RDRAND intrinsics - Return a random value and whether it is valid. // RDSEED intrinsics - Return a NIST SP800-90B & C compliant random value and // whether it is valid. -- cgit v1.1 From a6610ee882fcb8bcad60d53fc52b80f00a3fddae Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 27 Sep 2013 21:04:00 +0000 Subject: Re-submit r191472 with a fix for big endian. llvm-objdump: Dump COFF import table if -private-headers option is given. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191557 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/COFF.h | 56 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h index cb464ab..838e8f1 100644 --- a/include/llvm/Object/COFF.h +++ b/include/llvm/Object/COFF.h @@ -23,6 +23,8 @@ namespace llvm { class ArrayRef; namespace object { +class ImportDirectoryEntryRef; +typedef content_iterator import_directory_iterator; /// The DOS compatible header at the front of all PE/COFF executables. struct dos_header { @@ -137,6 +139,22 @@ struct import_directory_table_entry { support::ulittle32_t ImportAddressTableRVA; }; +struct import_lookup_table_entry32 { + support::ulittle32_t data; + + bool isOrdinal() const { return data & 0x80000000; } + + uint16_t getOrdinal() const { + assert(isOrdinal() && "ILT entry is not an ordinal!"); + return data & 0xFFFF; + } + + uint32_t getHintNameRVA() const { + assert(!isOrdinal() && "ILT entry is not a Hint/Name RVA!"); + return data; + } +}; + struct coff_symbol { struct StringTableOffset { support::ulittle32_t Zeroes; @@ -202,6 +220,7 @@ struct coff_aux_section_definition { class COFFObjectFile : public ObjectFile { private: + friend class ImportDirectoryEntryRef; const coff_file_header *COFFHeader; const pe32_header *PE32Header; const data_directory *DataDirectory; @@ -209,6 +228,8 @@ private: const coff_symbol *SymbolTable; const char *StringTable; uint32_t StringTableSize; + const import_directory_table_entry *ImportDirectory; + uint32_t NumberOfImportDirectory; error_code getString(uint32_t offset, StringRef &Res) const; @@ -216,6 +237,9 @@ private: const coff_section *toSec(DataRefImpl Sec) const; const coff_relocation *toRel(DataRefImpl Rel) const; + error_code initSymbolTablePtr(); + error_code initImportTablePtr(); + protected: virtual error_code getSymbolNext(DataRefImpl Symb, SymbolRef &Res) const; virtual error_code getSymbolName(DataRefImpl Symb, StringRef &Res) const; @@ -287,6 +311,9 @@ public: virtual unsigned getArch() const; virtual StringRef getLoadName() const; + import_directory_iterator getImportDirectoryBegin() const; + import_directory_iterator getImportDirectoryEnd() const; + error_code getHeader(const coff_file_header *&Res) const; error_code getCOFFHeader(const coff_file_header *&Res) const; error_code getPE32Header(const pe32_header *&Res) const; @@ -307,12 +334,37 @@ public: error_code getSectionContents(const coff_section *Sec, ArrayRef &Res) const; + error_code getRvaPtr(uint32_t Rva, uintptr_t &Res) const; + error_code getHintName(uint32_t Rva, uint16_t &Hint, StringRef &Name) const; + static inline bool classof(const Binary *v) { return v->isCOFF(); } }; -} -} +// The iterator for the import directory table. +class ImportDirectoryEntryRef { +public: + ImportDirectoryEntryRef() : OwningObject(0) {} + ImportDirectoryEntryRef(DataRefImpl ImportDirectory, + const COFFObjectFile *Owner) + : ImportDirectoryPimpl(ImportDirectory), OwningObject(Owner) {} + + bool operator==(const ImportDirectoryEntryRef &Other) const; + error_code getNext(ImportDirectoryEntryRef &Result) const; + error_code getName(StringRef &Result) const; + + error_code + getImportTableEntry(const import_directory_table_entry *&Result) const; + + error_code + getImportLookupEntry(const import_lookup_table_entry32 *&Result) const; + +private: + DataRefImpl ImportDirectoryPimpl; + const COFFObjectFile *OwningObject; +}; +} // end namespace object +} // end namespace llvm #endif -- cgit v1.1 From 8a93c3ab2121f8c9f0739971070b042cd6aa8024 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Fri, 27 Sep 2013 21:09:25 +0000 Subject: Make SourceMgr::PrintMessage() testable and add unit tests git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191558 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/SourceMgr.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/SourceMgr.h b/include/llvm/Support/SourceMgr.h index 5b33d42..dd48974 100644 --- a/include/llvm/Support/SourceMgr.h +++ b/include/llvm/Support/SourceMgr.h @@ -144,11 +144,17 @@ public: /// /// @param ShowColors - Display colored messages if output is a terminal and /// the default error handler is used. - void PrintMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg, + void PrintMessage(raw_ostream &OS, SMLoc Loc, DiagKind Kind, + const Twine &Msg, ArrayRef Ranges = None, ArrayRef FixIts = None, bool ShowColors = true) const; + /// Emits a diagnostic to llvm::errs(). + void PrintMessage(SMLoc Loc, DiagKind Kind, const Twine &Msg, + ArrayRef Ranges = None, + ArrayRef FixIts = None, + bool ShowColors = true) const; /// GetMessage - Return an SMDiagnostic at the specified location with the /// specified string. -- cgit v1.1 From 29552222c2e7cbeb37fcd15d247597467f7b8544 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 27 Sep 2013 21:47:05 +0000 Subject: Object/COFF: Rename getXXX{Begin,End} -> xxx_{begin,end}. It is mentioned in the LLVM coding standard that _begin() and _end() suffixes should be used. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191569 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/COFF.h | 8 ++++---- include/llvm/Object/ELFObjectFile.h | 8 ++++---- include/llvm/Object/MachO.h | 8 ++++---- include/llvm/Object/ObjectFile.h | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) (limited to 'include') diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h index 838e8f1..67cc7c6 100644 --- a/include/llvm/Object/COFF.h +++ b/include/llvm/Object/COFF.h @@ -269,8 +269,8 @@ protected: bool &Res) const; virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, bool &Result) const; - virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const; - virtual relocation_iterator getSectionRelEnd(DataRefImpl Sec) const; + virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const; + virtual relocation_iterator section_rel_end(DataRefImpl Sec) const; virtual error_code getRelocationNext(DataRefImpl Rel, RelocationRef &Res) const; @@ -311,8 +311,8 @@ public: virtual unsigned getArch() const; virtual StringRef getLoadName() const; - import_directory_iterator getImportDirectoryBegin() const; - import_directory_iterator getImportDirectoryEnd() const; + import_directory_iterator import_directory_begin() const; + import_directory_iterator import_directory_end() const; error_code getHeader(const coff_file_header *&Res) const; error_code getCOFFHeader(const coff_file_header *&Res) const; diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index f799f7e..5022be5 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -87,8 +87,8 @@ protected: virtual error_code isSectionReadOnlyData(DataRefImpl Sec, bool &Res) const; virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, bool &Result) const; - virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const; - virtual relocation_iterator getSectionRelEnd(DataRefImpl Sec) const; + virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const; + virtual relocation_iterator section_rel_end(DataRefImpl Sec) const; virtual section_iterator getRelocatedSection(DataRefImpl Sec) const; virtual error_code getRelocationNext(DataRefImpl Rel, @@ -611,7 +611,7 @@ error_code ELFObjectFile::sectionContainsSymbol(DataRefImpl Sec, template relocation_iterator -ELFObjectFile::getSectionRelBegin(DataRefImpl Sec) const { +ELFObjectFile::section_rel_begin(DataRefImpl Sec) const { DataRefImpl RelData; uintptr_t SHT = reinterpret_cast(EF.begin_sections().get()); RelData.d.a = (Sec.p - SHT) / EF.getHeader()->e_shentsize; @@ -621,7 +621,7 @@ ELFObjectFile::getSectionRelBegin(DataRefImpl Sec) const { template relocation_iterator -ELFObjectFile::getSectionRelEnd(DataRefImpl Sec) const { +ELFObjectFile::section_rel_end(DataRefImpl Sec) const { DataRefImpl RelData; uintptr_t SHT = reinterpret_cast(EF.begin_sections().get()); const Elf_Shdr *S = reinterpret_cast(Sec.p); diff --git a/include/llvm/Object/MachO.h b/include/llvm/Object/MachO.h index f3f391e..e91c260 100644 --- a/include/llvm/Object/MachO.h +++ b/include/llvm/Object/MachO.h @@ -89,8 +89,8 @@ public: virtual error_code isSectionReadOnlyData(DataRefImpl Sec, bool &Res) const; virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, bool &Result) const; - virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const; - virtual relocation_iterator getSectionRelEnd(DataRefImpl Sec) const; + virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const; + virtual relocation_iterator section_rel_end(DataRefImpl Sec) const; virtual error_code getRelocationNext(DataRefImpl Rel, RelocationRef &Res) const; @@ -129,8 +129,8 @@ public: virtual StringRef getLoadName() const; - relocation_iterator getSectionRelBegin(unsigned Index) const; - relocation_iterator getSectionRelEnd(unsigned Index) const; + relocation_iterator section_rel_begin(unsigned Index) const; + relocation_iterator section_rel_end(unsigned Index) const; dice_iterator begin_dices() const; dice_iterator end_dices() const; diff --git a/include/llvm/Object/ObjectFile.h b/include/llvm/Object/ObjectFile.h index 6973c67..0ba4952 100644 --- a/include/llvm/Object/ObjectFile.h +++ b/include/llvm/Object/ObjectFile.h @@ -322,8 +322,8 @@ protected: virtual error_code isSectionReadOnlyData(DataRefImpl Sec, bool &Res) const =0; virtual error_code sectionContainsSymbol(DataRefImpl Sec, DataRefImpl Symb, bool &Result) const = 0; - virtual relocation_iterator getSectionRelBegin(DataRefImpl Sec) const = 0; - virtual relocation_iterator getSectionRelEnd(DataRefImpl Sec) const = 0; + virtual relocation_iterator section_rel_begin(DataRefImpl Sec) const = 0; + virtual relocation_iterator section_rel_end(DataRefImpl Sec) const = 0; virtual section_iterator getRelocatedSection(DataRefImpl Sec) const; // Same as above for RelocationRef. @@ -528,11 +528,11 @@ inline error_code SectionRef::containsSymbol(SymbolRef S, bool &Result) const { } inline relocation_iterator SectionRef::begin_relocations() const { - return OwningObject->getSectionRelBegin(SectionPimpl); + return OwningObject->section_rel_begin(SectionPimpl); } inline relocation_iterator SectionRef::end_relocations() const { - return OwningObject->getSectionRelEnd(SectionPimpl); + return OwningObject->section_rel_end(SectionPimpl); } inline section_iterator SectionRef::getRelocatedSection() const { -- cgit v1.1 From 18ebd48960afe9a4e694dac3ba0ee1002044d297 Mon Sep 17 00:00:00 2001 From: Josh Magee Date: Fri, 27 Sep 2013 21:58:43 +0000 Subject: [stackprotector] Refactor the StackProtector pass from a single .cpp file into StackProtector.h and StackProtector.cpp. No functionality change. Future patches will add analysis which will be used in other passes (PEI, StackSlot). The end goal is to support ssp-strong stack layout rules. WIP. Differential Revision: http://llvm-reviews.chandlerc.com/D1521 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191570 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/StackProtector.h | 97 +++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 include/llvm/CodeGen/StackProtector.h (limited to 'include') diff --git a/include/llvm/CodeGen/StackProtector.h b/include/llvm/CodeGen/StackProtector.h new file mode 100644 index 0000000..d23a9d0 --- /dev/null +++ b/include/llvm/CodeGen/StackProtector.h @@ -0,0 +1,97 @@ +//===-- StackProtector.h - Stack Protector Insertion ----------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This pass inserts stack protectors into functions which need them. A variable +// with a random value in it is stored onto the stack before the local variables +// are allocated. Upon exiting the block, the stored value is checked. If it's +// changed, then there was some sort of violation and the program aborts. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CODEGEN_STACKPROTECTOR_H +#define LLVM_CODEGEN_STACKPROTECTOR_H + +#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/Triple.h" +#include "llvm/Pass.h" +#include "llvm/Target/TargetLowering.h" + +namespace llvm { +class DominatorTree; +class Function; +class Module; +class PHINode; + +class StackProtector : public FunctionPass { + const TargetMachine *TM; + + /// TLI - Keep a pointer of a TargetLowering to consult for determining + /// target type sizes. + const TargetLoweringBase *TLI; + const Triple Trip; + + Function *F; + Module *M; + + DominatorTree *DT; + + /// \brief The minimum size of buffers that will receive stack smashing + /// protection when -fstack-protection is used. + unsigned SSPBufferSize; + + /// VisitedPHIs - The set of PHI nodes visited when determining + /// if a variable's reference has been taken. This set + /// is maintained to ensure we don't visit the same PHI node multiple + /// times. + SmallPtrSet VisitedPHIs; + + /// InsertStackProtectors - Insert code into the prologue and epilogue of + /// the function. + /// + /// - The prologue code loads and stores the stack guard onto the stack. + /// - The epilogue checks the value stored in the prologue against the + /// original value. It calls __stack_chk_fail if they differ. + bool InsertStackProtectors(); + + /// CreateFailBB - Create a basic block to jump to when the stack protector + /// check fails. + BasicBlock *CreateFailBB(); + + /// ContainsProtectableArray - Check whether the type either is an array or + /// contains an array of sufficient size so that we need stack protectors + /// for it. + bool ContainsProtectableArray(Type *Ty, bool Strong = false, + bool InStruct = false) const; + + /// \brief Check whether a stack allocation has its address taken. + bool HasAddressTaken(const Instruction *AI); + + /// RequiresStackProtector - Check whether or not this function needs a + /// stack protector based upon the stack protector level. + bool RequiresStackProtector(); +public: + static char ID; // Pass identification, replacement for typeid. + StackProtector() : FunctionPass(ID), TM(0), TLI(0), SSPBufferSize(0) { + initializeStackProtectorPass(*PassRegistry::getPassRegistry()); + } + StackProtector(const TargetMachine *TM) + : FunctionPass(ID), TM(TM), TLI(0), Trip(TM->getTargetTriple()), + SSPBufferSize(8) { + initializeStackProtectorPass(*PassRegistry::getPassRegistry()); + } + + virtual void getAnalysisUsage(AnalysisUsage &AU) const { + AU.addPreserved(); + } + + virtual bool runOnFunction(Function &Fn); +}; +} // end namespace llvm + +#endif // LLVM_CODEGEN_STACKPROTECTOR_H -- cgit v1.1 From 804f034bd18789e9bbf4c70c10189dd6dbf04128 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Sat, 28 Sep 2013 00:22:27 +0000 Subject: AutoUpgrade: upgrade from scalar TBAA format to struct-path aware TBAA format. We treat TBAA tags as struct-path aware TBAA format when the first operand is a MDNode and the tag has 3 or more operands. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191593 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/AutoUpgrade.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/llvm/AutoUpgrade.h b/include/llvm/AutoUpgrade.h index ca3446e..8df87fa 100644 --- a/include/llvm/AutoUpgrade.h +++ b/include/llvm/AutoUpgrade.h @@ -19,6 +19,7 @@ namespace llvm { class GlobalVariable; class Function; class CallInst; + class Instruction; /// This is a more granular function that simply checks an intrinsic function /// for upgrading, and returns true if it requires upgrading. It may return @@ -39,6 +40,10 @@ namespace llvm { /// This checks for global variables which should be upgraded. It returns true /// if it requires upgrading. bool UpgradeGlobalVariable(GlobalVariable *GV); + + /// If the TBAA tag for the given instruction uses the scalar TBAA format, + /// we upgrade it to the struct-path aware TBAA format. + void UpgradeInstWithTBAATag(Instruction *I); } // End llvm namespace #endif -- cgit v1.1 From 3f4f420ab7acb10221ba971543a7eed5489fb626 Mon Sep 17 00:00:00 2001 From: Robert Wilhelm Date: Sat, 28 Sep 2013 13:42:22 +0000 Subject: Even more spelling fixes for "instruction". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191611 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveInterval.h | 2 +- include/llvm/CodeGen/MachineBasicBlock.h | 4 ++-- include/llvm/CodeGen/ScheduleDAGInstrs.h | 2 +- include/llvm/Target/TargetSchedule.td | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index eb2030f..005b154 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -66,7 +66,7 @@ namespace llvm { } /// Returns true if this value is defined by a PHI instruction (or was, - /// PHI instrucions may have been eliminated). + /// PHI instructions may have been eliminated). /// PHI-defs begin at a block boundary, all other defs begin at register or /// EC slots. bool isPHIDef() const { return def.isBlock(); } diff --git a/include/llvm/CodeGen/MachineBasicBlock.h b/include/llvm/CodeGen/MachineBasicBlock.h index e126f86..7717809 100644 --- a/include/llvm/CodeGen/MachineBasicBlock.h +++ b/include/llvm/CodeGen/MachineBasicBlock.h @@ -410,8 +410,8 @@ public: /// branch to do so (e.g., a table jump). True is a conservative answer. bool canFallThrough(); - /// Returns a pointer to the first instructon in this block that is not a - /// PHINode instruction. When adding instruction to the beginning of the + /// Returns a pointer to the first instruction in this block that is not a + /// PHINode instruction. When adding instructions to the beginning of the /// basic block, they should be added before the returned value, not before /// the first instruction, which might be PHI. /// Returns end() is there's no non-PHI instruction. diff --git a/include/llvm/CodeGen/ScheduleDAGInstrs.h b/include/llvm/CodeGen/ScheduleDAGInstrs.h index 999f2d3..fe4f3c2 100644 --- a/include/llvm/CodeGen/ScheduleDAGInstrs.h +++ b/include/llvm/CodeGen/ScheduleDAGInstrs.h @@ -129,7 +129,7 @@ namespace llvm { Reg2SUnitsMap Defs; Reg2SUnitsMap Uses; - /// Track the last instructon in this region defining each virtual register. + /// Track the last instruction in this region defining each virtual register. VReg2SUnitMap VRegDefs; /// PendingLoads - Remember where unknown loads are after the most recent diff --git a/include/llvm/Target/TargetSchedule.td b/include/llvm/Target/TargetSchedule.td index e81a2fb..9d4858a 100644 --- a/include/llvm/Target/TargetSchedule.td +++ b/include/llvm/Target/TargetSchedule.td @@ -76,7 +76,7 @@ def instregex; // See MCSchedule.h for detailed comments. class SchedMachineModel { int IssueWidth = -1; // Max micro-ops that may be scheduled per cycle. - int MinLatency = -1; // Determines which instrucions are allowed in a group. + int MinLatency = -1; // Determines which instructions are allowed in a group. // (-1) inorder (0) ooo, (1): inorder +var latencies. int MicroOpBufferSize = -1; // Max micro-ops that can be buffered. int LoadLatency = -1; // Cycles for loads to access the cache. -- cgit v1.1 From fd40d514ec7e95fe4a59a7a467c887b026364ff2 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sun, 29 Sep 2013 11:18:56 +0000 Subject: Allocate AtomicSDNode operands in SelectionDAG's allocator to stop leakage. SDNode destructors are never called. As an optimization use AtomicSDNode's internal storage if we have a small number of operands. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191636 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/SelectionDAGNodes.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index 4166340..13f5d4e 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -1073,7 +1073,6 @@ public: /// class AtomicSDNode : public MemSDNode { SDUse Ops[4]; - SDUse* DynOps; void InitAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope) { // This must match encodeMemSDNodeFlags() in SelectionDAG.cpp. @@ -1101,7 +1100,7 @@ public: SDValue Chain, SDValue Ptr, SDValue Cmp, SDValue Swp, MachineMemOperand *MMO, AtomicOrdering Ordering, SynchronizationScope SynchScope) - : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO), DynOps(NULL) { + : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) { InitAtomic(Ordering, SynchScope); InitOperands(Ops, Chain, Ptr, Cmp, Swp); } @@ -1110,7 +1109,7 @@ public: SDValue Chain, SDValue Ptr, SDValue Val, MachineMemOperand *MMO, AtomicOrdering Ordering, SynchronizationScope SynchScope) - : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO), DynOps(NULL) { + : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) { InitAtomic(Ordering, SynchScope); InitOperands(Ops, Chain, Ptr, Val); } @@ -1119,21 +1118,19 @@ public: SDValue Chain, SDValue Ptr, MachineMemOperand *MMO, AtomicOrdering Ordering, SynchronizationScope SynchScope) - : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO), DynOps(NULL) { + : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) { InitAtomic(Ordering, SynchScope); InitOperands(Ops, Chain, Ptr); } AtomicSDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTL, EVT MemVT, - SDValue* AllOps, unsigned NumOps, + SDValue* AllOps, SDUse *DynOps, unsigned NumOps, MachineMemOperand *MMO, AtomicOrdering Ordering, SynchronizationScope SynchScope) : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) { - DynOps = new SDUse[NumOps]; InitAtomic(Ordering, SynchScope); - InitOperands(DynOps, AllOps, NumOps); - } - ~AtomicSDNode() { - delete[] DynOps; + assert((DynOps || NumOps <= array_lengthof(Ops)) && + "Too many ops for internal storage!"); + InitOperands(DynOps ? DynOps : Ops, AllOps, NumOps); } const SDValue &getBasePtr() const { return getOperand(1); } -- cgit v1.1 From 67a25537491bb6f9eadf4016e10bbc9504b6b75d Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sun, 29 Sep 2013 19:39:02 +0000 Subject: Remove an old workaround for a compiler that EOL'd years ago. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191643 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/SelectionDAGNodes.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index 13f5d4e..8ec3b09 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -942,13 +942,7 @@ public: class HandleSDNode : public SDNode { SDUse Op; public: - // FIXME: Remove the "noinline" attribute once is - // fixed. -#if __GNUC__==4 && __GNUC_MINOR__==2 && defined(__APPLE__) && !defined(__llvm__) - explicit __attribute__((__noinline__)) HandleSDNode(SDValue X) -#else explicit HandleSDNode(SDValue X) -#endif : SDNode(ISD::HANDLENODE, 0, DebugLoc(), getSDVTList(MVT::Other)) { InitOperands(&Op, X); } -- cgit v1.1 From d42730dc712026cbfb1322a979e0ac72cd31a19e Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Mon, 30 Sep 2013 15:28:56 +0000 Subject: IfConverter: Use TargetSchedule for instruction latencies For targets that have instruction itineraries this means no change. Targets that move over to the new schedule model will use be able the new schedule module for instruction latencies in the if-converter (the logic is such that if there is no itineary we will use the new sched model for the latencies). Before, we queried "TTI->getInstructionLatency()" for the instruction latency and the extra prediction cost. Now, we query the TargetSchedule abstraction for the instruction latency and TargetInstrInfo for the extra predictation cost. The TargetSchedule abstraction will internally call "TTI->getInstructionLatency" if an itinerary exists, otherwise it will use the new schedule model. ATTENTION: Out of tree targets! (I will also send out an email later to LLVMDev) This means, if your target implements unsigned getInstrLatency(const InstrItineraryData *ItinData, const MachineInstr *MI, unsigned *PredCost); and returns a value for "PredCost", you now also need to implement unsigned getPredictationCost(const MachineInstr *MI); (if your target uses the IfConversion.cpp pass) radar://15077010 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191671 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/TargetSchedule.h | 8 +++++++- include/llvm/Target/TargetInstrInfo.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/TargetSchedule.h b/include/llvm/CodeGen/TargetSchedule.h index f2adcf8..8ef26b7 100644 --- a/include/llvm/CodeGen/TargetSchedule.h +++ b/include/llvm/CodeGen/TargetSchedule.h @@ -152,7 +152,13 @@ public: /// Compute and return the expected latency of this instruction independent of /// a particular use. computeOperandLatency is the prefered API, but this is /// occasionally useful to help estimate instruction cost. - unsigned computeInstrLatency(const MachineInstr *MI) const; + /// + /// If UseDefaultDefLatency is false and no new machine sched model is + /// present this method falls back to TII->getInstrLatency with an empty + /// instruction itinerary (this is so we preserve the previous behavior of the + /// if converter after moving it to TargetSchedModel). + unsigned computeInstrLatency(const MachineInstr *MI, + bool UseDefaultDefLatency = true) const; /// \brief Output dependency latency of a pair of defs of the same register. /// diff --git a/include/llvm/Target/TargetInstrInfo.h b/include/llvm/Target/TargetInstrInfo.h index d92ad42..b8599da 100644 --- a/include/llvm/Target/TargetInstrInfo.h +++ b/include/llvm/Target/TargetInstrInfo.h @@ -823,6 +823,8 @@ public: const MachineInstr *MI, unsigned *PredCost = 0) const; + virtual unsigned getPredicationCost(const MachineInstr *MI) const; + virtual int getInstrLatency(const InstrItineraryData *ItinData, SDNode *Node) const; -- cgit v1.1 From 5a17a462cdba1b894cdd618798596076ed79c9ac Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Mon, 30 Sep 2013 15:39:27 +0000 Subject: IRBuilder: Move fast math flags to IRBuilderBase. They don't depend on the templated stuff. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191672 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IRBuilder.h | 62 ++++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 34 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IRBuilder.h b/include/llvm/IR/IRBuilder.h index e396e71..458f87a 100644 --- a/include/llvm/IR/IRBuilder.h +++ b/include/llvm/IR/IRBuilder.h @@ -52,10 +52,13 @@ protected: BasicBlock *BB; BasicBlock::iterator InsertPt; LLVMContext &Context; + + MDNode *DefaultFPMathTag; + FastMathFlags FMF; public: - IRBuilderBase(LLVMContext &context) - : Context(context) { + IRBuilderBase(LLVMContext &context, MDNode *FPMathTag = 0) + : Context(context), DefaultFPMathTag(FPMathTag), FMF() { ClearInsertionPoint(); } @@ -169,6 +172,21 @@ public: ClearInsertionPoint(); } + /// \brief Get the floating point math metadata being used. + MDNode *getDefaultFPMathTag() const { return DefaultFPMathTag; } + + /// \brief Get the flags to be applied to created floating point ops + FastMathFlags getFastMathFlags() const { return FMF; } + + /// \brief Clear the fast-math flags. + void clearFastMathFlags() { FMF.clear(); } + + /// \brief Set the floating point math metadata to be used. + void SetDefaultFPMathTag(MDNode *FPMathTag) { DefaultFPMathTag = FPMathTag; } + + /// \brief Set the fast-math flags to be used with generated fp-math operators + void SetFastMathFlags(FastMathFlags NewFMF) { FMF = NewFMF; } + //===--------------------------------------------------------------------===// // Miscellaneous creation methods. //===--------------------------------------------------------------------===// @@ -354,76 +372,52 @@ template > class IRBuilder : public IRBuilderBase, public Inserter { T Folder; - MDNode *DefaultFPMathTag; - FastMathFlags FMF; public: IRBuilder(LLVMContext &C, const T &F, const Inserter &I = Inserter(), MDNode *FPMathTag = 0) - : IRBuilderBase(C), Inserter(I), Folder(F), DefaultFPMathTag(FPMathTag), - FMF() { + : IRBuilderBase(C, FPMathTag), Inserter(I), Folder(F) { } explicit IRBuilder(LLVMContext &C, MDNode *FPMathTag = 0) - : IRBuilderBase(C), Folder(), DefaultFPMathTag(FPMathTag), FMF() { + : IRBuilderBase(C, FPMathTag), Folder() { } explicit IRBuilder(BasicBlock *TheBB, const T &F, MDNode *FPMathTag = 0) - : IRBuilderBase(TheBB->getContext()), Folder(F), - DefaultFPMathTag(FPMathTag), FMF() { + : IRBuilderBase(TheBB->getContext(), FPMathTag), Folder(F) { SetInsertPoint(TheBB); } explicit IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag = 0) - : IRBuilderBase(TheBB->getContext()), Folder(), - DefaultFPMathTag(FPMathTag), FMF() { + : IRBuilderBase(TheBB->getContext(), FPMathTag), Folder() { SetInsertPoint(TheBB); } explicit IRBuilder(Instruction *IP, MDNode *FPMathTag = 0) - : IRBuilderBase(IP->getContext()), Folder(), DefaultFPMathTag(FPMathTag), - FMF() { + : IRBuilderBase(IP->getContext(), FPMathTag), Folder() { SetInsertPoint(IP); SetCurrentDebugLocation(IP->getDebugLoc()); } explicit IRBuilder(Use &U, MDNode *FPMathTag = 0) - : IRBuilderBase(U->getContext()), Folder(), DefaultFPMathTag(FPMathTag), - FMF() { + : IRBuilderBase(U->getContext(), FPMathTag), Folder() { SetInsertPoint(U); SetCurrentDebugLocation(cast(U.getUser())->getDebugLoc()); } IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F, MDNode *FPMathTag = 0) - : IRBuilderBase(TheBB->getContext()), Folder(F), - DefaultFPMathTag(FPMathTag), FMF() { + : IRBuilderBase(TheBB->getContext(), FPMathTag), Folder(F) { SetInsertPoint(TheBB, IP); } IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, MDNode *FPMathTag = 0) - : IRBuilderBase(TheBB->getContext()), Folder(), - DefaultFPMathTag(FPMathTag), FMF() { + : IRBuilderBase(TheBB->getContext(), FPMathTag), Folder() { SetInsertPoint(TheBB, IP); } /// \brief Get the constant folder being used. const T &getFolder() { return Folder; } - /// \brief Get the floating point math metadata being used. - MDNode *getDefaultFPMathTag() const { return DefaultFPMathTag; } - - /// \brief Get the flags to be applied to created floating point ops - FastMathFlags getFastMathFlags() const { return FMF; } - - /// \brief Clear the fast-math flags. - void clearFastMathFlags() { FMF.clear(); } - - /// \brief SetDefaultFPMathTag - Set the floating point math metadata to be used. - void SetDefaultFPMathTag(MDNode *FPMathTag) { DefaultFPMathTag = FPMathTag; } - - /// \brief Set the fast-math flags to be used with generated fp-math operators - void SetFastMathFlags(FastMathFlags NewFMF) { FMF = NewFMF; } - /// \brief Return true if this builder is configured to actually add the /// requested names to IR created through it. bool isNamePreserving() const { return preserveNames; } -- cgit v1.1 From adb412daa41aef94a9f724dfd1ade9f579bb3a84 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Mon, 30 Sep 2013 15:39:48 +0000 Subject: IRBuilder: Add RAII objects to reset insertion points or fast math flags. Inspired by the object from the SLPVectorizer. This found a minor bug in the debug loc restoration in the vectorizer where the location of a following instruction was attached instead of the location from the original instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191673 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IRBuilder.h | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IRBuilder.h b/include/llvm/IR/IRBuilder.h index 458f87a..0adfbc4 100644 --- a/include/llvm/IR/IRBuilder.h +++ b/include/llvm/IR/IRBuilder.h @@ -25,6 +25,7 @@ #include "llvm/IR/Operator.h" #include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/ConstantFolder.h" +#include "llvm/Support/ValueHandle.h" namespace llvm { class MDNode; @@ -188,6 +189,53 @@ public: void SetFastMathFlags(FastMathFlags NewFMF) { FMF = NewFMF; } //===--------------------------------------------------------------------===// + // RAII helpers. + //===--------------------------------------------------------------------===// + + // \brief RAII object that stores the current insertion point and restores it + // when the object is destroyed. This includes the debug location. + class InsertPointGuard { + IRBuilderBase &Builder; + AssertingVH Block; + AssertingVH Point; + DebugLoc DbgLoc; + + InsertPointGuard(const InsertPointGuard &) LLVM_DELETED_FUNCTION; + InsertPointGuard &operator=(const InsertPointGuard &) LLVM_DELETED_FUNCTION; + + public: + InsertPointGuard(IRBuilderBase &B) + : Builder(B), Block(B.GetInsertBlock()), Point(B.GetInsertPoint()), + DbgLoc(B.getCurrentDebugLocation()) {} + + ~InsertPointGuard() { + Builder.restoreIP(InsertPoint(Block, BasicBlock::iterator(Point))); + Builder.SetCurrentDebugLocation(DbgLoc); + } + }; + + // \brief RAII object that stores the current fast math settings and restores + // them when the object is destroyed. + class FastMathFlagGuard { + IRBuilderBase &Builder; + FastMathFlags FMF; + MDNode *FPMathTag; + + FastMathFlagGuard(const FastMathFlagGuard &) LLVM_DELETED_FUNCTION; + FastMathFlagGuard &operator=( + const FastMathFlagGuard &) LLVM_DELETED_FUNCTION; + + public: + FastMathFlagGuard(IRBuilderBase &B) + : Builder(B), FMF(B.FMF), FPMathTag(B.DefaultFPMathTag) {} + + ~FastMathFlagGuard() { + Builder.FMF = FMF; + Builder.DefaultFPMathTag = FPMathTag; + } + }; + + //===--------------------------------------------------------------------===// // Miscellaneous creation methods. //===--------------------------------------------------------------------===// -- cgit v1.1 From d4278821665aa97f5fc0d19a32ff1fb39a22d395 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Mon, 30 Sep 2013 15:40:17 +0000 Subject: Convert manual insert point restores to the new RAII object. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191675 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/ScalarEvolutionExpander.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Analysis/ScalarEvolutionExpander.h b/include/llvm/Analysis/ScalarEvolutionExpander.h index 00779fc..1e88bd5 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpander.h +++ b/include/llvm/Analysis/ScalarEvolutionExpander.h @@ -252,8 +252,6 @@ namespace llvm { void rememberInstruction(Value *I); - void restoreInsertPoint(BasicBlock *BB, BasicBlock::iterator I); - bool isNormalAddRecExprPHI(PHINode *PN, Instruction *IncV, const Loop *L); bool isExpandedAddRecExprPHI(PHINode *PN, Instruction *IncV, const Loop *L); -- cgit v1.1 From c13c9e5a9d288eac494a38f0710d34446167f940 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 30 Sep 2013 16:39:19 +0000 Subject: Move command line options to the users of libLTO. Fixes --enable-shared build. Patch by Richard Sandiford. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191680 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/LTO/LTOCodeGenerator.h | 21 ++++++++++++++++++--- include/llvm/LTO/LTOModule.h | 12 ++++++------ 2 files changed, 24 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/llvm/LTO/LTOCodeGenerator.h b/include/llvm/LTO/LTOCodeGenerator.h index 3d151b9..08e6374 100644 --- a/include/llvm/LTO/LTOCodeGenerator.h +++ b/include/llvm/LTO/LTOCodeGenerator.h @@ -39,6 +39,7 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/StringMap.h" #include "llvm/Linker.h" +#include "llvm/Target/TargetOptions.h" #include #include @@ -64,6 +65,7 @@ struct LTOCodeGenerator { // Merge given module, return true on success. bool addModule(struct LTOModule*, std::string &errMsg); + void setTargetOptions(llvm::TargetOptions options); void setDebugInfo(lto_debug_model); void setCodePICModel(lto_codegen_model); @@ -90,7 +92,11 @@ struct LTOCodeGenerator { // Do not try to remove the object file in LTOCodeGenerator's destructor // as we don't who (LTOCodeGenerator or the obj file) will last longer. // - bool compile_to_file(const char **name, std::string &errMsg); + bool compile_to_file(const char **name, + bool disableOpt, + bool disableInline, + bool disableGVNLoadPRE, + std::string &errMsg); // As with compile_to_file(), this function compiles the merged module into // single object file. Instead of returning the object-file-path to the caller @@ -98,12 +104,20 @@ struct LTOCodeGenerator { // caller. This function should delete intermediate object file once its content // is brought to memory. Return NULL if the compilation was not successful. // - const void *compile(size_t *length, std::string &errMsg); + const void *compile(size_t *length, + bool disableOpt, + bool disableInline, + bool disableGVNLoadPRE, + std::string &errMsg); private: void initializeLTOPasses(); - bool generateObjectFile(llvm::raw_ostream &out, std::string &errMsg); + bool generateObjectFile(llvm::raw_ostream &out, + bool disableOpt, + bool disableInline, + bool disableGVNLoadPRE, + std::string &errMsg); void applyScopeRestrictions(); void applyRestriction(llvm::GlobalValue &GV, std::vector &MustPreserveList, @@ -125,6 +139,7 @@ private: std::vector CodegenOptions; std::string MCpu; std::string NativeObjectPath; + llvm::TargetOptions Options; }; #endif // LTO_CODE_GENERATOR_H diff --git a/include/llvm/LTO/LTOModule.h b/include/llvm/LTO/LTOModule.h index 973466c..f4693c8 100644 --- a/include/llvm/LTO/LTOModule.h +++ b/include/llvm/LTO/LTOModule.h @@ -84,14 +84,17 @@ public: /// InitializeAllAsmPrinters(); /// InitializeAllAsmParsers(); static LTOModule *makeLTOModule(const char* path, + llvm::TargetOptions options, std::string &errMsg); static LTOModule *makeLTOModule(int fd, const char *path, - size_t size, std::string &errMsg); + size_t size, llvm::TargetOptions options, + std::string &errMsg); static LTOModule *makeLTOModule(int fd, const char *path, size_t map_size, - off_t offset, + off_t offset, llvm::TargetOptions options, std::string& errMsg); static LTOModule *makeLTOModule(const void *mem, size_t length, + llvm::TargetOptions options, std::string &errMsg); /// getTargetTriple - Return the Module's target triple. @@ -132,10 +135,6 @@ public: return _asm_undefines; } - /// getTargetOptions - Fill the TargetOptions object with the options - /// specified on the command line. - static void getTargetOptions(llvm::TargetOptions &Options); - private: /// parseSymbols - Parse the symbols from the module and model-level ASM and /// add them to either the defined or undefined lists. @@ -187,6 +186,7 @@ private: /// makeLTOModule - Create an LTOModule (private version). N.B. This /// method takes ownership of the buffer. static LTOModule *makeLTOModule(llvm::MemoryBuffer *buffer, + llvm::TargetOptions options, std::string &errMsg); /// makeBuffer - Create a MemoryBuffer from a memory range. -- cgit v1.1 From 5be81238f0683d0533f747124aa420e4e79440b1 Mon Sep 17 00:00:00 2001 From: Anders Waldenborg Date: Mon, 30 Sep 2013 19:11:32 +0000 Subject: llvm-c: use typedef for function pointers This makes it consistent with other function pointers used in llvm-c Differential Revision: http://llvm-reviews.chandlerc.com/D1712 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191693 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/ExecutionEngine.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/llvm-c/ExecutionEngine.h b/include/llvm-c/ExecutionEngine.h index 50fdb6b..cf3565c 100644 --- a/include/llvm-c/ExecutionEngine.h +++ b/include/llvm-c/ExecutionEngine.h @@ -171,6 +171,15 @@ void *LLVMGetPointerToGlobal(LLVMExecutionEngineRef EE, LLVMValueRef Global); /*===-- Operations on memory managers -------------------------------------===*/ +typedef uint8_t *(*LLVMMemoryManagerAllocateCodeSectionCallback)(void *Opaque, + uintptr_t Size, unsigned Alignment, + unsigned SectionID); +typedef uint8_t *(*LLVMMemoryManagerAllocateDataSectionCallback)(void *Opaque, + uintptr_t Size, unsigned Alignment, + unsigned SectionID, LLVMBool IsReadOnly); +typedef LLVMBool (*LLVMMemoryManagerFinalizeMemoryCallback)(void *Opaque, char **ErrMsg); +typedef void (*LLVMMemoryManagerDestroyCallback)(void *Opaque); + /** * Create a simple custom MCJIT memory manager. This memory manager can * intercept allocations in a module-oblivious way. This will return NULL @@ -184,14 +193,10 @@ void *LLVMGetPointerToGlobal(LLVMExecutionEngineRef EE, LLVMValueRef Global); */ LLVMMCJITMemoryManagerRef LLVMCreateSimpleMCJITMemoryManager( void *Opaque, - uint8_t *(*AllocateCodeSection)(void *Opaque, - uintptr_t Size, unsigned Alignment, - unsigned SectionID), - uint8_t *(*AllocateDataSection)(void *Opaque, - uintptr_t Size, unsigned Alignment, - unsigned SectionID, LLVMBool IsReadOnly), - LLVMBool (*FinalizeMemory)(void *Opaque, char **ErrMsg), - void (*Destroy)(void *Opaque)); + LLVMMemoryManagerAllocateCodeSectionCallback AllocateCodeSection, + LLVMMemoryManagerAllocateDataSectionCallback AllocateDataSection, + LLVMMemoryManagerFinalizeMemoryCallback FinalizeMemory, + LLVMMemoryManagerDestroyCallback Destory); void LLVMDisposeMCJITMemoryManager(LLVMMCJITMemoryManagerRef MM); -- cgit v1.1 From e5388399c795edd3687b08f33446a253d65247d6 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Mon, 30 Sep 2013 19:42:10 +0000 Subject: Debug Info: constify and rename from generateRef to getRef. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191696 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 515dc65..ecdca49 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -211,7 +211,7 @@ namespace llvm { /// Generate a reference to this DIScope. Uses the type identifier instead /// of the actual MDNode if possible, to help type uniquing. - DIScopeRef generateRef(); + DIScopeRef getRef() const; }; /// Represents reference to a DIDescriptor, abstracts over direct and @@ -221,7 +221,7 @@ namespace llvm { template friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const; friend DIScopeRef DIScope::getContext() const; - friend DIScopeRef DIScope::generateRef(); + friend DIScopeRef DIScope::getRef() const; /// Val can be either a MDNode or a MDString, in the latter, /// MDString specifies the type identifier. -- cgit v1.1 From 8e9ec015348c5419b905c2ca6e39534429eda073 Mon Sep 17 00:00:00 2001 From: Andrew Kaylor Date: Tue, 1 Oct 2013 01:47:35 +0000 Subject: Adding multiple module support for MCJIT. Tests to follow. PIC with small code model and EH frame handling will not work with multiple modules. There are also some rough edges to be smoothed out for remote target support. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191722 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ExecutionEngine/ExecutionEngine.h | 54 ++++++++++++++++++++++ include/llvm/ExecutionEngine/RTDyldMemoryManager.h | 7 +++ 2 files changed, 61 insertions(+) (limited to 'include') diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h index ceac298..46ee7a6 100644 --- a/include/llvm/ExecutionEngine/ExecutionEngine.h +++ b/include/llvm/ExecutionEngine/ExecutionEngine.h @@ -240,6 +240,8 @@ public: /// found, this function silently returns a null pointer. Otherwise, /// it prints a message to stderr and aborts. /// + /// This function is deprecated for the MCJIT execution engine. + /// virtual void *getPointerToNamedFunction(const std::string &Name, bool AbortOnFailure = true) = 0; @@ -252,6 +254,23 @@ public: "EE!"); } + /// generateCodeForModule - Run code generationen for the specified module and + /// load it into memory. + /// + /// When this function has completed, all code and data for the specified + /// module, and any module on which this module depends, will be generated + /// and loaded into memory, but relocations will not yet have been applied + /// and all memory will be readable and writable but not executable. + /// + /// This function is primarily useful when generating code for an external + /// target, allowing the client an opportunity to remap section addresses + /// before relocations are applied. Clients that intend to execute code + /// locally can use the getFunctionAddress call, which will generate code + /// and apply final preparations all in one step. + /// + /// This method has no effect for the legacy JIT engine or the interpeter. + virtual void generateCodeForModule(Module *M) {} + /// finalizeObject - ensure the module is fully processed and is usable. /// /// It is the user-level function for completing the process of making the @@ -307,10 +326,16 @@ public: /// getPointerToGlobalIfAvailable - This returns the address of the specified /// global value if it is has already been codegen'd, otherwise it returns /// null. + /// + /// This function is deprecated for the MCJIT execution engine. It doesn't + /// seem to be needed in that case, but an equivalent can be added if it is. void *getPointerToGlobalIfAvailable(const GlobalValue *GV); /// getPointerToGlobal - This returns the address of the specified global /// value. This may involve code generation if it's a function. + /// + /// This function is deprecated for the MCJIT execution engine. Use + /// getGlobalValueAddress instead. void *getPointerToGlobal(const GlobalValue *GV); /// getPointerToFunction - The different EE's represent function bodies in @@ -318,22 +343,48 @@ public: /// pointer should look like. When F is destroyed, the ExecutionEngine will /// remove its global mapping and free any machine code. Be sure no threads /// are running inside F when that happens. + /// + /// This function is deprecated for the MCJIT execution engine. Use + /// getFunctionAddress instead. virtual void *getPointerToFunction(Function *F) = 0; /// getPointerToBasicBlock - The different EE's represent basic blocks in /// different ways. Return the representation for a blockaddress of the /// specified block. + /// + /// This function will not be implemented for the MCJIT execution engine. virtual void *getPointerToBasicBlock(BasicBlock *BB) = 0; /// getPointerToFunctionOrStub - If the specified function has been /// code-gen'd, return a pointer to the function. If not, compile it, or use /// a stub to implement lazy compilation if available. See /// getPointerToFunction for the requirements on destroying F. + /// + /// This function is deprecated for the MCJIT execution engine. Use + /// getFunctionAddress instead. virtual void *getPointerToFunctionOrStub(Function *F) { // Default implementation, just codegen the function. return getPointerToFunction(F); } + /// getGlobalValueAddress - Return the address of the specified global + /// value. This may involve code generation. + /// + /// This function should not be called with the JIT or interpreter engines. + virtual uint64_t getGlobalValueAddress(const std::string &Name) { + // Default implementation for JIT and interpreter. MCJIT will override this. + // JIT and interpreter clients should use getPointerToGlobal instead. + return 0; + } + + /// getFunctionAddress - Return the address of the specified function. + /// This may involve code generation. + virtual uint64_t getFunctionAddress(const std::string &Name) { + // Default implementation for JIT and interpreter. MCJIT will override this. + // JIT and interpreter clients should use getPointerToFunction instead. + return 0; + } + // The JIT overrides a version that actually does this. virtual void runJITOnFunction(Function *, MachineCodeInfo * = 0) { } @@ -366,6 +417,9 @@ public: /// getOrEmitGlobalVariable - Return the address of the specified global /// variable, possibly emitting it to memory if needed. This is used by the /// Emitter. + /// + /// This function is deprecated for the MCJIT execution engine. Use + /// getGlobalValueAddress instead. virtual void *getOrEmitGlobalVariable(const GlobalVariable *GV) { return getPointerToGlobal((const GlobalValue *)GV); } diff --git a/include/llvm/ExecutionEngine/RTDyldMemoryManager.h b/include/llvm/ExecutionEngine/RTDyldMemoryManager.h index 99e2594..02e6b19 100644 --- a/include/llvm/ExecutionEngine/RTDyldMemoryManager.h +++ b/include/llvm/ExecutionEngine/RTDyldMemoryManager.h @@ -50,12 +50,19 @@ public: /// Register the EH frames with the runtime so that c++ exceptions work. virtual void registerEHFrames(StringRef SectionData); + /// This method returns the address of the specified function or variable. + /// It is used to resolve symbols during module linking. + virtual uint64_t getSymbolAddress(const std::string &Name); + /// This method returns the address of the specified function. As such it is /// only useful for resolving library symbols, not code generated symbols. /// /// If \p AbortOnFailure is false and no function with the given name is /// found, this function returns a null pointer. Otherwise, it prints a /// message to stderr and aborts. + /// + /// This function is deprecated for memory managers used to be used with + /// MCJIT or RuntimeDyld. Use getSymbolAddress instead. virtual void *getPointerToNamedFunction(const std::string &Name, bool AbortOnFailure = true); -- cgit v1.1 From d1311ac171f9cb90cab4906a6c0e091b6b65b862 Mon Sep 17 00:00:00 2001 From: Joey Gouly Date: Tue, 1 Oct 2013 12:39:11 +0000 Subject: [ARM] Introduce the 'sevl' instruction in ARMv8. This also removes the restriction on the immediate field of the 'hint' instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191744 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsARM.td | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsARM.td b/include/llvm/IR/IntrinsicsARM.td index 8d8c4af..2d82735 100644 --- a/include/llvm/IR/IntrinsicsARM.td +++ b/include/llvm/IR/IntrinsicsARM.td @@ -113,6 +113,10 @@ def int_arm_crc32cw : Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>; //===----------------------------------------------------------------------===// +// HINT +def int_arm_sevl : Intrinsic<[], []>; + +//===----------------------------------------------------------------------===// // Advanced SIMD (NEON) // The following classes do not correspond directly to GCC builtins. -- cgit v1.1 From c269c4f505a2dd7c3a88d12706257410ed6c7068 Mon Sep 17 00:00:00 2001 From: "Tareq A. Siraj" Date: Tue, 1 Oct 2013 14:28:18 +0000 Subject: Add non-blocking Wait() for launched processes - New ProcessInfo class to encapsulate information about child processes. - Generalized the Wait() to support non-blocking wait on child processes. - ExecuteNoWait() now returns a ProcessInfo object with information about the launched child. Users will be able to use this object to perform non-blocking wait. - ExecuteNoWait() now accepts an ExecutionFailed param that tells if execution failed or not. These changes will allow users to implement basic process parallel tools. Differential Revision: http://llvm-reviews.chandlerc.com/D1728 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191763 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Program.h | 62 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/Program.h b/include/llvm/Support/Program.h index 5134351..91781f9 100644 --- a/include/llvm/Support/Program.h +++ b/include/llvm/Support/Program.h @@ -30,6 +30,28 @@ namespace sys { const char EnvPathSeparator = ';'; #endif +/// @brief This struct encapsulates information about a process. +struct ProcessInfo { +#if defined(LLVM_ON_UNIX) + typedef pid_t ProcessId; +#elif defined(LLVM_ON_WIN32) + typedef unsigned long ProcessId; // Must match the type of DWORD on Windows. + typedef void * HANDLE; // Must match the type of HANDLE on Windows. + /// The handle to the process (available on Windows only). + HANDLE ProcessHandle; +#else +#error "ProcessInfo is not defined for this platform!" +#endif + + /// The process identifier. + ProcessId Pid; + + /// The return code, set after execution. + int ReturnCode; + + ProcessInfo(); +}; + /// This static constructor (factory) will attempt 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 @@ -87,15 +109,41 @@ namespace sys { ///< program. bool *ExecutionFailed = 0); - /// Similar to ExecuteAndWait, but return immediately. - void ExecuteNoWait(StringRef Program, const char **args, const char **env = 0, - const StringRef **redirects = 0, unsigned memoryLimit = 0, - std::string *ErrMsg = 0); + /// Similar to ExecuteAndWait, but returns immediately. + /// @returns The \see ProcessInfo of the newly launced process. + /// \Note On Microsoft Windows systems, users will need to either call \see + /// Wait until the process finished execution or win32 CloseHandle() API on + /// ProcessInfo.ProcessHandle to avoid memory leaks. + ProcessInfo + ExecuteNoWait(StringRef Program, const char **args, const char **env = 0, + const StringRef **redirects = 0, unsigned memoryLimit = 0, + std::string *ErrMsg = 0, bool *ExecutionFailed = 0); - // Return true if the given arguments fit within system-specific - // argument length limits. + /// Return true if the given arguments fit within system-specific + /// argument length limits. bool argumentsFitWithinSystemLimits(ArrayRef Args); -} + + /// 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 + /// state. + /// \li 0 if the child process has not changed state. + /// \Note Users of this function should always check the ReturnCode member of + /// the \see ProcessInfo returned from this function. + ProcessInfo Wait( + const ProcessInfo &PI, ///< The child process that should be waited on. + unsigned SecondsToWait, ///< If non-zero, this specifies the amount of + ///< time to wait for the child process to exit. If the time expires, the + ///< child is killed and this function returns. If zero, this function + ///< will perform a non-blocking wait on the child process. + bool WaitUntilTerminates, ///< If true, ignores \p SecondsToWait and waits + ///< until child has terminated. + std::string *ErrMsg = 0 ///< If non-zero, provides a pointer to a string + ///< instance in which error messages will be returned. If the string + ///< is non-empty upon return an error occurred while invoking the + ///< program. + ); + } } #endif -- cgit v1.1 From 76502a756da8fbc3cf6f2f26bc09cce598a9fc03 Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Tue, 1 Oct 2013 22:14:56 +0000 Subject: [llvm-c][Disassembler] Add an option to reproduce in disassembled output the comments issued with verbose assembly. E.g., on a vector shuffle operation, disassembled output are: * Without the option: vpshufd $-0x79, (%rsp), %xmm0 * With the option: vpshufd $-0x79, (%rsp), %xmm0 ## xmm0 = mem[3,1,0,2] This part of . git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191799 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Disassembler.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Disassembler.h b/include/llvm-c/Disassembler.h index df65a7b..0c5bd5c 100644 --- a/include/llvm-c/Disassembler.h +++ b/include/llvm-c/Disassembler.h @@ -170,6 +170,8 @@ int LLVMSetDisasmOptions(LLVMDisasmContextRef DC, uint64_t Options); #define LLVMDisassembler_Option_PrintImmHex 2 /* The option use the other assembler printer variant */ #define LLVMDisassembler_Option_AsmPrinterVariant 4 +/* The option to set comment on instructions */ +#define LLVMDisassembler_Option_SetInstrComments 8 /** * Dispose of a disassembler context. -- cgit v1.1 From 2b53089bd017139f0125b870ace94ff27dffd2ff Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Tue, 1 Oct 2013 23:45:54 +0000 Subject: Debug Info: In DIBuilder, the derived-from field of a DW_TAG_pointer_type is updated to use DITypeRef. Move isUnsignedDIType and getOriginalTypeSize from DebugInfo.h to be static helper functions in DwarfCompileUnit. We already have a static helper function "isTypeSigned" in DwarfCompileUnit, and a pointer to DwarfDebug is added to resolve the derived-from field. All three functions need to go across link for derived-from fields, so we need to get hold of a type identifier map. A pointer to DwarfDebug is also added to DbgVariable in order to resolve the derived-from field. Debug info verifier is updated to check a derived-from field is a TypeRef. Verifier will not go across link for derived-from fields, in debug info finder, we go across the link to add derived-from fields to types. Function getDICompositeType is only used by dragonegg and since dragonegg does not generate identifier for types, we use an empty map to resolve the derived-from field. When printing a derived-from field, we use DITypeRef::getName to either return the type identifier or getName of the DIType. A paired commit at clang is required due to changes to DIBuilder. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191800 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index ecdca49..cd4777d 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -22,6 +22,7 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" +#include "llvm/IR/Metadata.h" #include "llvm/Support/Dwarf.h" namespace llvm { @@ -206,6 +207,8 @@ namespace llvm { /// Gets the parent scope for this scope node or returns a /// default constructed scope. DIScopeRef getContext() const; + /// If the scope node has a name, return that, else return an empty string. + StringRef getName() const; StringRef getFilename() const; StringRef getDirectory() const; @@ -243,6 +246,16 @@ namespace llvm { "MDNode in DITypeIdentifierMap should be a DIType."); return T(Iter->second); } + StringRef getName() const { + if (!Val) + return StringRef(); + + if (const MDNode *MD = dyn_cast(Val)) + return T(MD).getName(); + + const MDString *MS = cast(Val); + return MS->getString(); + } operator Value *() const { return const_cast(Val); } }; @@ -321,9 +334,6 @@ namespace llvm { return DbgNode && isType(); } - /// isUnsignedDIType - Return true if type encoding is unsigned. - bool isUnsignedDIType(); - /// replaceAllUsesWith - Replace all uses of debug info referenced by /// this descriptor. void replaceAllUsesWith(DIDescriptor &D); @@ -351,11 +361,7 @@ namespace llvm { public: explicit DIDerivedType(const MDNode *N = 0) : DIType(N) {} - DIType getTypeDerivedFrom() const { return getFieldAs(9); } - - /// getOriginalTypeSize - If this type is derived from a base type then - /// return base type size. - uint64_t getOriginalTypeSize() const; + DITypeRef getTypeDerivedFrom() const { return getFieldAs(9); } /// getObjCProperty - Return property node, if this ivar is /// associated with one. -- cgit v1.1 From 6eb43d295625cd2ff314c59b49d4fd11f3348cad Mon Sep 17 00:00:00 2001 From: Filip Pizlo Date: Wed, 2 Oct 2013 00:59:25 +0000 Subject: This threads SectionName through the allocateCodeSection/allocateDataSection APIs, both in C++ and C land. It's useful for the memory managers that are allocating a section to know what the name of the section is. At a minimum, this is useful for low-level debugging - it's customary for JITs to be able to tell you what memory they allocated, and as part of any such dump, they should be able to tell you some meta-data about what each allocation is for. This allows clients that supply their own memory managers to do this. Additionally, we also envision the SectionName being useful for passing meta-data from within LLVM to an LLVM client. This changes both the C and C++ APIs, and all of the clients of those APIs within LLVM. I'm assuming that it's safe to change the C++ API because that API is allowed to change. I'm assuming that it's safe to change the C API because we haven't shipped the API in a release yet (LLVM 3.3 doesn't include the MCJIT memory management C API). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191804 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/ExecutionEngine.h | 15 ++++++++------- include/llvm/ExecutionEngine/RTDyldMemoryManager.h | 12 +++++++----- include/llvm/ExecutionEngine/SectionMemoryManager.h | 4 +++- 3 files changed, 18 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/llvm-c/ExecutionEngine.h b/include/llvm-c/ExecutionEngine.h index cf3565c..4e767b2 100644 --- a/include/llvm-c/ExecutionEngine.h +++ b/include/llvm-c/ExecutionEngine.h @@ -171,13 +171,14 @@ void *LLVMGetPointerToGlobal(LLVMExecutionEngineRef EE, LLVMValueRef Global); /*===-- Operations on memory managers -------------------------------------===*/ -typedef uint8_t *(*LLVMMemoryManagerAllocateCodeSectionCallback)(void *Opaque, - uintptr_t Size, unsigned Alignment, - unsigned SectionID); -typedef uint8_t *(*LLVMMemoryManagerAllocateDataSectionCallback)(void *Opaque, - uintptr_t Size, unsigned Alignment, - unsigned SectionID, LLVMBool IsReadOnly); -typedef LLVMBool (*LLVMMemoryManagerFinalizeMemoryCallback)(void *Opaque, char **ErrMsg); +typedef uint8_t *(*LLVMMemoryManagerAllocateCodeSectionCallback)( + void *Opaque, uintptr_t Size, unsigned Alignment, unsigned SectionID, + const char *SectionName); +typedef uint8_t *(*LLVMMemoryManagerAllocateDataSectionCallback)( + void *Opaque, uintptr_t Size, unsigned Alignment, unsigned SectionID, + const char *SectionName, LLVMBool IsReadOnly); +typedef LLVMBool (*LLVMMemoryManagerFinalizeMemoryCallback)( + void *Opaque, char **ErrMsg); typedef void (*LLVMMemoryManagerDestroyCallback)(void *Opaque); /** diff --git a/include/llvm/ExecutionEngine/RTDyldMemoryManager.h b/include/llvm/ExecutionEngine/RTDyldMemoryManager.h index 02e6b19..5932687 100644 --- a/include/llvm/ExecutionEngine/RTDyldMemoryManager.h +++ b/include/llvm/ExecutionEngine/RTDyldMemoryManager.h @@ -38,14 +38,16 @@ public: /// executable code. The SectionID is a unique identifier assigned by the JIT /// engine, and optionally recorded by the memory manager to access a loaded /// section. - virtual uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment, - unsigned SectionID) = 0; - + virtual uint8_t *allocateCodeSection( + uintptr_t Size, unsigned Alignment, unsigned SectionID, + StringRef SectionName) = 0; + /// Allocate a memory block of (at least) the given size suitable for data. /// The SectionID is a unique identifier assigned by the JIT engine, and /// optionally recorded by the memory manager to access a loaded section. - virtual uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment, - unsigned SectionID, bool IsReadOnly) = 0; + virtual uint8_t *allocateDataSection( + uintptr_t Size, unsigned Alignment, unsigned SectionID, + StringRef SectionName, bool IsReadOnly) = 0; /// Register the EH frames with the runtime so that c++ exceptions work. virtual void registerEHFrames(StringRef SectionData); diff --git a/include/llvm/ExecutionEngine/SectionMemoryManager.h b/include/llvm/ExecutionEngine/SectionMemoryManager.h index 6ee2a2a..fd6e41f 100644 --- a/include/llvm/ExecutionEngine/SectionMemoryManager.h +++ b/include/llvm/ExecutionEngine/SectionMemoryManager.h @@ -49,7 +49,8 @@ public: /// The value of \p Alignment must be a power of two. If \p Alignment is zero /// a default alignment of 16 will be used. virtual uint8_t *allocateCodeSection(uintptr_t Size, unsigned Alignment, - unsigned SectionID); + unsigned SectionID, + StringRef SectionName); /// \brief Allocates a memory block of (at least) the given size suitable for /// executable code. @@ -58,6 +59,7 @@ public: /// a default alignment of 16 will be used. virtual uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment, unsigned SectionID, + StringRef SectionName, bool isReadOnly); /// \brief Update section-specific memory permissions and other attributes. -- cgit v1.1 From 0d1785a2e64648584d8230172125d171d5f1ca02 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 2 Oct 2013 08:14:38 +0000 Subject: Program.h: Fix \Note into \note. [-Wdocumentation] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191815 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Program.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/Program.h b/include/llvm/Support/Program.h index 91781f9..00571a4 100644 --- a/include/llvm/Support/Program.h +++ b/include/llvm/Support/Program.h @@ -111,7 +111,7 @@ struct ProcessInfo { /// Similar to ExecuteAndWait, but returns immediately. /// @returns The \see ProcessInfo of the newly launced process. - /// \Note On Microsoft Windows systems, users will need to either call \see + /// \note On Microsoft Windows systems, users will need to either call \see /// Wait until the process finished execution or win32 CloseHandle() API on /// ProcessInfo.ProcessHandle to avoid memory leaks. ProcessInfo @@ -128,7 +128,7 @@ struct ProcessInfo { /// \li The process id of the child process if the child process has changed /// state. /// \li 0 if the child process has not changed state. - /// \Note Users of this function should always check the ReturnCode member of + /// \note Users of this function should always check the ReturnCode member of /// the \see ProcessInfo returned from this function. ProcessInfo Wait( const ProcessInfo &PI, ///< The child process that should be waited on. -- cgit v1.1 From 0e95b3aba9b2039ae3af617e681aacca2ff81f79 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 2 Oct 2013 14:36:23 +0000 Subject: Fix option parsing in the gold plugin. This was broken when options were moved up in r191680. No test because this is specific LLVMgold.so/libLTO.so. Patch by Tom Roeder! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191829 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/LTO/LTOCodeGenerator.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/llvm/LTO/LTOCodeGenerator.h b/include/llvm/LTO/LTOCodeGenerator.h index 08e6374..97a5066 100644 --- a/include/llvm/LTO/LTOCodeGenerator.h +++ b/include/llvm/LTO/LTOCodeGenerator.h @@ -79,6 +79,11 @@ struct LTOCodeGenerator { // and LTOCodeGenerator::writeMergedModules(). // void setCodeGenDebugOptions(const char *opts); + + // Parse the options set in setCodeGenDebugOptions. Like + // setCodeGenDebugOptions, this must be called before + // LTOCodeGenerator::compilexxx() and LTOCodeGenerator::writeMergedModules() + void parseCodeGenDebugOptions(); // Write the merged module to the file specified by the given path. // Return true on success. -- cgit v1.1 From dd5d86d992eb129ecd0bb013d2db2d6a0e8d2605 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Wed, 2 Oct 2013 15:42:23 +0000 Subject: Remove the very substantial, largely unmaintained legacy PGO infrastructure. This was essentially work toward PGO based on a design that had several flaws, partially dating from a time when LLVM had a different architecture, and with an effort to modernize it abandoned without being completed. Since then, it has bitrotted for several years further. The result is nearly unusable, and isn't helping any of the modern PGO efforts. Instead, it is getting in the way, adding confusion about PGO in LLVM and distracting everyone with maintenance on essentially dead code. Removing it paves the way for modern efforts around PGO. Among other effects, this removes the last of the runtime libraries from LLVM. Those are being developed in the separate 'compiler-rt' project now, with somewhat different licensing specifically more approriate for runtimes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191835 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/Passes.h | 58 ------ include/llvm/Analysis/PathNumbering.h | 304 ------------------------------ include/llvm/Analysis/PathProfileInfo.h | 112 ----------- include/llvm/Analysis/ProfileDataLoader.h | 140 -------------- include/llvm/Analysis/ProfileDataTypes.h | 39 ---- include/llvm/Analysis/ProfileInfo.h | 247 ------------------------ include/llvm/Analysis/ProfileInfoLoader.h | 81 -------- include/llvm/Analysis/ProfileInfoTypes.h | 52 ----- include/llvm/InitializePasses.h | 12 -- include/llvm/LinkAllPasses.h | 10 - include/llvm/Transforms/Instrumentation.h | 9 - 11 files changed, 1064 deletions(-) delete mode 100644 include/llvm/Analysis/PathNumbering.h delete mode 100644 include/llvm/Analysis/PathProfileInfo.h delete mode 100644 include/llvm/Analysis/ProfileDataLoader.h delete mode 100644 include/llvm/Analysis/ProfileDataTypes.h delete mode 100644 include/llvm/Analysis/ProfileInfo.h delete mode 100644 include/llvm/Analysis/ProfileInfoLoader.h delete mode 100644 include/llvm/Analysis/ProfileInfoTypes.h (limited to 'include') diff --git a/include/llvm/Analysis/Passes.h b/include/llvm/Analysis/Passes.h index ae11713..0b4e96f 100644 --- a/include/llvm/Analysis/Passes.h +++ b/include/llvm/Analysis/Passes.h @@ -95,64 +95,6 @@ namespace llvm { //===--------------------------------------------------------------------===// // - // createProfileLoaderPass - This pass loads information from a profile dump - // file. - // - ModulePass *createProfileLoaderPass(); - extern char &ProfileLoaderPassID; - - //===--------------------------------------------------------------------===// - // - // createProfileMetadataLoaderPass - This pass loads information from a - // profile dump file and sets branch weight metadata. - // - ModulePass *createProfileMetadataLoaderPass(); - extern char &ProfileMetadataLoaderPassID; - - //===--------------------------------------------------------------------===// - // - // createNoProfileInfoPass - This pass implements the default "no profile". - // - ImmutablePass *createNoProfileInfoPass(); - - //===--------------------------------------------------------------------===// - // - // createProfileEstimatorPass - This pass estimates profiling information - // instead of loading it from a previous run. - // - FunctionPass *createProfileEstimatorPass(); - extern char &ProfileEstimatorPassID; - - //===--------------------------------------------------------------------===// - // - // createProfileVerifierPass - This pass verifies profiling information. - // - FunctionPass *createProfileVerifierPass(); - - //===--------------------------------------------------------------------===// - // - // createPathProfileLoaderPass - This pass loads information from a path - // profile dump file. - // - ModulePass *createPathProfileLoaderPass(); - extern char &PathProfileLoaderPassID; - - //===--------------------------------------------------------------------===// - // - // createNoPathProfileInfoPass - This pass implements the default - // "no path profile". - // - ImmutablePass *createNoPathProfileInfoPass(); - - //===--------------------------------------------------------------------===// - // - // createPathProfileVerifierPass - This pass verifies path profiling - // information. - // - ModulePass *createPathProfileVerifierPass(); - - //===--------------------------------------------------------------------===// - // // createDSAAPass - This pass implements simple context sensitive alias // analysis. // diff --git a/include/llvm/Analysis/PathNumbering.h b/include/llvm/Analysis/PathNumbering.h deleted file mode 100644 index 400a37d..0000000 --- a/include/llvm/Analysis/PathNumbering.h +++ /dev/null @@ -1,304 +0,0 @@ -//===- PathNumbering.h ----------------------------------------*- C++ -*---===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// Ball-Larus path numbers uniquely identify paths through a directed acyclic -// graph (DAG) [Ball96]. For a CFG backedges are removed and replaced by phony -// edges to obtain a DAG, and thus the unique path numbers [Ball96]. -// -// The purpose of this analysis is to enumerate the edges in a CFG in order -// to obtain paths from path numbers in a convenient manner. As described in -// [Ball96] edges can be enumerated such that given a path number by following -// the CFG and updating the path number, the path is obtained. -// -// [Ball96] -// T. Ball and J. R. Larus. "Efficient Path Profiling." -// International Symposium on Microarchitecture, pages 46-57, 1996. -// http://portal.acm.org/citation.cfm?id=243857 -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_ANALYSIS_PATHNUMBERING_H -#define LLVM_ANALYSIS_PATHNUMBERING_H - -#include "llvm/Analysis/ProfileInfoTypes.h" -#include "llvm/IR/BasicBlock.h" -#include "llvm/IR/Instructions.h" -#include "llvm/Pass.h" -#include "llvm/Support/CFG.h" -#include -#include -#include - -namespace llvm { -class BallLarusNode; -class BallLarusEdge; -class BallLarusDag; - -// typedefs for storage/ interators of various DAG components -typedef std::vector BLNodeVector; -typedef std::vector::iterator BLNodeIterator; -typedef std::vector BLEdgeVector; -typedef std::vector::iterator BLEdgeIterator; -typedef std::map BLBlockNodeMap; -typedef std::stack BLNodeStack; - -// Represents a basic block with information necessary for the BallLarus -// algorithms. -class BallLarusNode { -public: - enum NodeColor { WHITE, GRAY, BLACK }; - - // Constructor: Initializes a new Node for the given BasicBlock - BallLarusNode(BasicBlock* BB) : - _basicBlock(BB), _numberPaths(0), _color(WHITE) { - static unsigned nextUID = 0; - _uid = nextUID++; - } - - // Returns the basic block for the BallLarusNode - BasicBlock* getBlock(); - - // Get/set the number of paths to the exit starting at the node. - unsigned getNumberPaths(); - void setNumberPaths(unsigned numberPaths); - - // Get/set the NodeColor used in graph algorithms. - NodeColor getColor(); - void setColor(NodeColor color); - - // Iterator information for predecessor edges. Includes phony and - // backedges. - BLEdgeIterator predBegin(); - BLEdgeIterator predEnd(); - unsigned getNumberPredEdges(); - - // Iterator information for successor edges. Includes phony and - // backedges. - BLEdgeIterator succBegin(); - BLEdgeIterator succEnd(); - unsigned getNumberSuccEdges(); - - // Add an edge to the predecessor list. - void addPredEdge(BallLarusEdge* edge); - - // Remove an edge from the predecessor list. - void removePredEdge(BallLarusEdge* edge); - - // Add an edge to the successor list. - void addSuccEdge(BallLarusEdge* edge); - - // Remove an edge from the successor list. - void removeSuccEdge(BallLarusEdge* edge); - - // Returns the name of the BasicBlock being represented. If BasicBlock - // is null then returns "". If BasicBlock has no name, then - // "" is returned. Intended for use with debug output. - std::string getName(); - -private: - // The corresponding underlying BB. - BasicBlock* _basicBlock; - - // Holds the predecessor edges of this node. - BLEdgeVector _predEdges; - - // Holds the successor edges of this node. - BLEdgeVector _succEdges; - - // The number of paths from the node to the exit. - unsigned _numberPaths; - - // 'Color' used by graph algorithms to mark the node. - NodeColor _color; - - // Unique ID to ensure naming difference with dotgraphs - unsigned _uid; - - // Removes an edge from an edgeVector. Used by removePredEdge and - // removeSuccEdge. - void removeEdge(BLEdgeVector& v, BallLarusEdge* e); -}; - -// Represents an edge in the Dag. For an edge, v -> w, v is the source, and -// w is the target. -class BallLarusEdge { -public: - enum EdgeType { NORMAL, BACKEDGE, SPLITEDGE, - BACKEDGE_PHONY, SPLITEDGE_PHONY, CALLEDGE_PHONY }; - - // Constructor: Initializes an BallLarusEdge with a source and target. - BallLarusEdge(BallLarusNode* source, BallLarusNode* target, - unsigned duplicateNumber) - : _source(source), _target(target), _weight(0), _edgeType(NORMAL), - _realEdge(NULL), _duplicateNumber(duplicateNumber) {} - - // Returns the source/ target node of this edge. - BallLarusNode* getSource() const; - BallLarusNode* getTarget() const; - - // Sets the type of the edge. - EdgeType getType() const; - - // Gets the type of the edge. - void setType(EdgeType type); - - // Returns the weight of this edge. Used to decode path numbers to - // sequences of basic blocks. - unsigned getWeight(); - - // Sets the weight of the edge. Used during path numbering. - void setWeight(unsigned weight); - - // Gets/sets the phony edge originating at the root. - BallLarusEdge* getPhonyRoot(); - void setPhonyRoot(BallLarusEdge* phonyRoot); - - // Gets/sets the phony edge terminating at the exit. - BallLarusEdge* getPhonyExit(); - void setPhonyExit(BallLarusEdge* phonyExit); - - // Gets/sets the associated real edge if this is a phony edge. - BallLarusEdge* getRealEdge(); - void setRealEdge(BallLarusEdge* realEdge); - - // Returns the duplicate number of the edge. - unsigned getDuplicateNumber(); - -protected: - // Source node for this edge. - BallLarusNode* _source; - - // Target node for this edge. - BallLarusNode* _target; - -private: - // Edge weight cooresponding to path number increments before removing - // increments along a spanning tree. The sum over the edge weights gives - // the path number. - unsigned _weight; - - // Type to represent for what this edge is intended - EdgeType _edgeType; - - // For backedges and split-edges, the phony edge which is linked to the - // root node of the DAG. This contains a path number initialization. - BallLarusEdge* _phonyRoot; - - // For backedges and split-edges, the phony edge which is linked to the - // exit node of the DAG. This contains a path counter increment, and - // potentially a path number increment. - BallLarusEdge* _phonyExit; - - // If this is a phony edge, _realEdge is a link to the back or split - // edge. Otherwise, this is null. - BallLarusEdge* _realEdge; - - // An ID to differentiate between those edges which have the same source - // and destination blocks. - unsigned _duplicateNumber; -}; - -// Represents the Ball Larus DAG for a given Function. Can calculate -// various properties required for instrumentation or analysis. E.g. the -// edge weights that determine the path number. -class BallLarusDag { -public: - // Initializes a BallLarusDag from the CFG of a given function. Must - // call init() after creation, since some initialization requires - // virtual functions. - BallLarusDag(Function &F) - : _root(NULL), _exit(NULL), _function(F) {} - - // Initialization that requires virtual functions which are not fully - // functional in the constructor. - void init(); - - // Frees all memory associated with the DAG. - virtual ~BallLarusDag(); - - // Calculate the path numbers by assigning edge increments as prescribed - // in Ball-Larus path profiling. - void calculatePathNumbers(); - - // Returns the number of paths for the DAG. - unsigned getNumberOfPaths(); - - // Returns the root (i.e. entry) node for the DAG. - BallLarusNode* getRoot(); - - // Returns the exit node for the DAG. - BallLarusNode* getExit(); - - // Returns the function for the DAG. - Function& getFunction(); - - // Clears the node colors. - void clearColors(BallLarusNode::NodeColor color); - -protected: - // All nodes in the DAG. - BLNodeVector _nodes; - - // All edges in the DAG. - BLEdgeVector _edges; - - // All backedges in the DAG. - BLEdgeVector _backEdges; - - // Allows subclasses to determine which type of Node is created. - // Override this method to produce subclasses of BallLarusNode if - // necessary. The destructor of BallLarusDag will call free on each pointer - // created. - virtual BallLarusNode* createNode(BasicBlock* BB); - - // Allows subclasses to determine which type of Edge is created. - // Override this method to produce subclasses of BallLarusEdge if - // necessary. Parameters source and target will have been created by - // createNode and can be cast to the subclass of BallLarusNode* - // returned by createNode. The destructor of BallLarusDag will call free - // on each pointer created. - virtual BallLarusEdge* createEdge(BallLarusNode* source, BallLarusNode* - target, unsigned duplicateNumber); - - // Proxy to node's constructor. Updates the DAG state. - BallLarusNode* addNode(BasicBlock* BB); - - // Proxy to edge's constructor. Updates the DAG state. - BallLarusEdge* addEdge(BallLarusNode* source, BallLarusNode* target, - unsigned duplicateNumber); - -private: - // The root (i.e. entry) node for this DAG. - BallLarusNode* _root; - - // The exit node for this DAG. - BallLarusNode* _exit; - - // The function represented by this DAG. - Function& _function; - - // Processes one node and its imediate edges for building the DAG. - void buildNode(BLBlockNodeMap& inDag, std::stack& dfsStack); - - // Process an edge in the CFG for DAG building. - void buildEdge(BLBlockNodeMap& inDag, std::stack& dfsStack, - BallLarusNode* currentNode, BasicBlock* succBB, - unsigned duplicateNumber); - - // The weight on each edge is the increment required along any path that - // contains that edge. - void calculatePathNumbersFrom(BallLarusNode* node); - - // Adds a backedge with its phony edges. Updates the DAG state. - void addBackedge(BallLarusNode* source, BallLarusNode* target, - unsigned duplicateCount); -}; -} // end namespace llvm - -#endif diff --git a/include/llvm/Analysis/PathProfileInfo.h b/include/llvm/Analysis/PathProfileInfo.h deleted file mode 100644 index 4fce16e..0000000 --- a/include/llvm/Analysis/PathProfileInfo.h +++ /dev/null @@ -1,112 +0,0 @@ -//===- PathProfileInfo.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 outlines the interface used by optimizers to load path profiles. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_ANALYSIS_PATHPROFILEINFO_H -#define LLVM_ANALYSIS_PATHPROFILEINFO_H - -#include "llvm/Analysis/PathNumbering.h" -#include "llvm/IR/BasicBlock.h" - -namespace llvm { - -class ProfilePath; -class ProfilePathEdge; -class PathProfileInfo; - -typedef std::vector ProfilePathEdgeVector; -typedef std::vector::iterator ProfilePathEdgeIterator; - -typedef std::vector ProfilePathBlockVector; -typedef std::vector::iterator ProfilePathBlockIterator; - -typedef std::map ProfilePathMap; -typedef std::map::iterator ProfilePathIterator; - -typedef std::map FunctionPathCountMap; -typedef std::map FunctionPathMap; -typedef std::map::iterator FunctionPathIterator; - -class ProfilePathEdge { -public: - ProfilePathEdge(BasicBlock* source, BasicBlock* target, - unsigned duplicateNumber); - - inline unsigned getDuplicateNumber() { return _duplicateNumber; } - inline BasicBlock* getSource() { return _source; } - inline BasicBlock* getTarget() { return _target; } - -protected: - BasicBlock* _source; - BasicBlock* _target; - unsigned _duplicateNumber; -}; - -class ProfilePath { -public: - ProfilePath(unsigned int number, unsigned int count, - double countStdDev, PathProfileInfo* ppi); - - double getFrequency() const; - - inline unsigned int getNumber() const { return _number; } - inline unsigned int getCount() const { return _count; } - inline double getCountStdDev() const { return _countStdDev; } - - ProfilePathEdgeVector* getPathEdges() const; - ProfilePathBlockVector* getPathBlocks() const; - - BasicBlock* getFirstBlockInPath() const; - -private: - unsigned int _number; - unsigned int _count; - double _countStdDev; - - // double pointer back to the profiling info - PathProfileInfo* _ppi; -}; - -// TODO: overload [] operator for getting path -// Add: getFunctionCallCount() -class PathProfileInfo { - public: - PathProfileInfo(); - ~PathProfileInfo(); - - void setCurrentFunction(Function* F); - Function* getCurrentFunction() const; - BasicBlock* getCurrentFunctionEntry(); - - ProfilePath* getPath(unsigned int number); - unsigned int getPotentialPathCount(); - - ProfilePathIterator pathBegin(); - ProfilePathIterator pathEnd(); - unsigned int pathsRun(); - - static char ID; // Pass identification - std::string argList; - -protected: - FunctionPathMap _functionPaths; - FunctionPathCountMap _functionPathCounts; - -private: - BallLarusDag* _currentDag; - Function* _currentFunction; - - friend class ProfilePath; -}; -} // end namespace llvm - -#endif diff --git a/include/llvm/Analysis/ProfileDataLoader.h b/include/llvm/Analysis/ProfileDataLoader.h deleted file mode 100644 index 90097f7..0000000 --- a/include/llvm/Analysis/ProfileDataLoader.h +++ /dev/null @@ -1,140 +0,0 @@ -//===- ProfileDataLoader.h - Load & convert profile info ----*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// The ProfileDataLoader class is used to load profiling data from a dump file. -// The ProfileDataT class is used to store the mapping of this -// data to control flow edges. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_ANALYSIS_PROFILEDATALOADER_H -#define LLVM_ANALYSIS_PROFILEDATALOADER_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/Support/Debug.h" -#include "llvm/Support/ErrorHandling.h" -#include - -namespace llvm { - -class ModulePass; -class Function; -class BasicBlock; - -// Helper for dumping edges to dbgs(). -raw_ostream& operator<<(raw_ostream &O, std::pair E); - -/// \brief The ProfileDataT class is used to store the mapping of -/// profiling data to control flow edges. -/// -/// An edge is defined by its source and sink basic blocks. -template -class ProfileDataT { -public: - // The profiling information defines an Edge by its source and sink basic - // blocks. - typedef std::pair Edge; - -private: - typedef DenseMap EdgeWeights; - - /// \brief Count the number of times a transition between two blocks is - /// executed. - /// - /// As a special case, we also hold an edge from the null BasicBlock to the - /// entry block to indicate how many times the function was entered. - DenseMap EdgeInformation; - -public: - /// getFunction() - Returns the Function for an Edge. - static const FType *getFunction(Edge e) { - // e.first may be NULL - assert(((!e.first) || (e.first->getParent() == e.second->getParent())) - && "A ProfileData::Edge can not be between two functions"); - assert(e.second && "A ProfileData::Edge must have a real sink"); - return e.second->getParent(); - } - - /// getEdge() - Creates an Edge between two BasicBlocks. - static Edge getEdge(const BType *Src, const BType *Dest) { - return Edge(Src, Dest); - } - - /// getEdgeWeight - Return the number of times that a given edge was - /// executed. - unsigned getEdgeWeight(Edge e) const { - const FType *f = getFunction(e); - assert((EdgeInformation.find(f) != EdgeInformation.end()) - && "No profiling information for function"); - EdgeWeights weights = EdgeInformation.find(f)->second; - - assert((weights.find(e) != weights.end()) - && "No profiling information for edge"); - return weights.find(e)->second; - } - - /// addEdgeWeight - Add 'weight' to the already stored execution count for - /// this edge. - void addEdgeWeight(Edge e, unsigned weight) { - EdgeInformation[getFunction(e)][e] += weight; - } -}; - -typedef ProfileDataT ProfileData; -//typedef ProfileDataT MachineProfileData; - -/// The ProfileDataLoader class is used to load raw profiling data from the -/// dump file. -class ProfileDataLoader { -private: - /// The name of the file where the raw profiling data is stored. - const std::string &Filename; - - /// A vector of the command line arguments used when the target program was - /// run to generate profiling data. One entry per program run. - SmallVector CommandLines; - - /// The raw values for how many times each edge was traversed, values from - /// multiple program runs are accumulated. - SmallVector EdgeCounts; - -public: - /// ProfileDataLoader ctor - Read the specified profiling data file, exiting - /// the program if the file is invalid or broken. - ProfileDataLoader(const char *ToolName, const std::string &Filename); - - /// A special value used to represent the weight of an edge which has not - /// been counted yet. - static const unsigned Uncounted; - - /// getNumExecutions - Return the number of times the target program was run - /// to generate this profiling data. - unsigned getNumExecutions() const { return CommandLines.size(); } - - /// getExecution - Return the command line parameters used to generate the - /// i'th set of profiling data. - const std::string &getExecution(unsigned i) const { return CommandLines[i]; } - - const std::string &getFileName() const { return Filename; } - - /// getRawEdgeCounts - Return the raw profiling data, this is just a list of - /// numbers with no mappings to edges. - ArrayRef getRawEdgeCounts() const { return EdgeCounts; } -}; - -/// createProfileMetadataLoaderPass - This function returns a Pass that loads -/// the profiling information for the module from the specified filename. -ModulePass *createProfileMetadataLoaderPass(const std::string &Filename); - -} // End llvm namespace - -#endif diff --git a/include/llvm/Analysis/ProfileDataTypes.h b/include/llvm/Analysis/ProfileDataTypes.h deleted file mode 100644 index 1be15e0..0000000 --- a/include/llvm/Analysis/ProfileDataTypes.h +++ /dev/null @@ -1,39 +0,0 @@ -/*===-- ProfileDataTypes.h - Profiling info shared constants --------------===*\ -|* -|* The LLVM Compiler Infrastructure -|* -|* This file is distributed under the University of Illinois Open Source -|* License. See LICENSE.TXT for details. -|* -|*===----------------------------------------------------------------------===*| -|* -|* This file defines constants shared by the various different profiling -|* runtime libraries and the LLVM C++ profile metadata loader. It must be a -|* C header because, at present, the profiling runtimes are written in C. -|* -\*===----------------------------------------------------------------------===*/ - -#ifndef LLVM_ANALYSIS_PROFILEDATATYPES_H -#define LLVM_ANALYSIS_PROFILEDATATYPES_H - -/* Included by libprofile. */ -#if defined(__cplusplus) -extern "C" { -#endif - -/* TODO: Strip out unused entries once ProfileInfo etc has been removed. */ -enum ProfilingType { - ArgumentInfo = 1, /* The command line argument block */ - FunctionInfo = 2, /* Function profiling information */ - BlockInfo = 3, /* Block profiling information */ - EdgeInfo = 4, /* Edge profiling information */ - PathInfo = 5, /* Path profiling information */ - BBTraceInfo = 6, /* Basic block trace information */ - OptEdgeInfo = 7 /* Edge profiling information, optimal version */ -}; - -#if defined(__cplusplus) -} -#endif - -#endif /* LLVM_ANALYSIS_PROFILEDATATYPES_H */ diff --git a/include/llvm/Analysis/ProfileInfo.h b/include/llvm/Analysis/ProfileInfo.h deleted file mode 100644 index 5d17fa1..0000000 --- a/include/llvm/Analysis/ProfileInfo.h +++ /dev/null @@ -1,247 +0,0 @@ -//===- llvm/Analysis/ProfileInfo.h - Profile Info Interface -----*- 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 generic ProfileInfo interface, which is used as the -// common interface used by all clients of profiling information, and -// implemented either by making static guestimations, or by actually reading in -// profiling information gathered by running the program. -// -// Note that to be useful, all profile-based optimizations should preserve -// ProfileInfo, which requires that they notify it when changes to the CFG are -// made. (This is not implemented yet.) -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_ANALYSIS_PROFILEINFO_H -#define LLVM_ANALYSIS_PROFILEINFO_H - -#include "llvm/Support/Debug.h" -#include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/Format.h" -#include "llvm/Support/raw_ostream.h" -#include -#include -#include -#include - -namespace llvm { - class Pass; - class raw_ostream; - - class BasicBlock; - class Function; - class MachineBasicBlock; - class MachineFunction; - - // Helper for dumping edges to dbgs(). - raw_ostream& operator<<(raw_ostream &O, std::pair E); - raw_ostream& operator<<(raw_ostream &O, std::pair E); - - raw_ostream& operator<<(raw_ostream &O, const BasicBlock *BB); - raw_ostream& operator<<(raw_ostream &O, const MachineBasicBlock *MBB); - - raw_ostream& operator<<(raw_ostream &O, const Function *F); - raw_ostream& operator<<(raw_ostream &O, const MachineFunction *MF); - - /// ProfileInfo Class - This class holds and maintains profiling - /// information for some unit of code. - template - class ProfileInfoT { - public: - // Types for handling profiling information. - typedef std::pair Edge; - typedef std::pair EdgeWeight; - typedef std::map EdgeWeights; - typedef std::map BlockCounts; - typedef std::map Path; - - protected: - // EdgeInformation - Count the number of times a transition between two - // blocks is executed. As a special case, we also hold an edge from the - // null BasicBlock to the entry block to indicate how many times the - // function was entered. - std::map EdgeInformation; - - // BlockInformation - Count the number of times a block is executed. - std::map BlockInformation; - - // FunctionInformation - Count the number of times a function is executed. - std::map FunctionInformation; - - ProfileInfoT *MachineProfile; - public: - static char ID; // Class identification, replacement for typeinfo - ProfileInfoT(); - ~ProfileInfoT(); // We want to be subclassed - - // MissingValue - The value that is returned for execution counts in case - // no value is available. - static const double MissingValue; - - // getFunction() - Returns the Function for an Edge, checking for validity. - static const FType* getFunction(Edge e) { - if (e.first) - return e.first->getParent(); - if (e.second) - return e.second->getParent(); - llvm_unreachable("Invalid ProfileInfo::Edge"); - } - - // getEdge() - Creates an Edge from two BasicBlocks. - static Edge getEdge(const BType *Src, const BType *Dest) { - return std::make_pair(Src, Dest); - } - - //===------------------------------------------------------------------===// - /// Profile Information Queries - /// - double getExecutionCount(const FType *F); - - double getExecutionCount(const BType *BB); - - void setExecutionCount(const BType *BB, double w); - - void addExecutionCount(const BType *BB, double w); - - double getEdgeWeight(Edge e) const { - typename std::map::const_iterator J = - EdgeInformation.find(getFunction(e)); - if (J == EdgeInformation.end()) return MissingValue; - - typename EdgeWeights::const_iterator I = J->second.find(e); - if (I == J->second.end()) return MissingValue; - - return I->second; - } - - void setEdgeWeight(Edge e, double w) { - DEBUG_WITH_TYPE("profile-info", - dbgs() << "Creating Edge " << e - << " (weight: " << format("%.20g",w) << ")\n"); - EdgeInformation[getFunction(e)][e] = w; - } - - void addEdgeWeight(Edge e, double w); - - EdgeWeights &getEdgeWeights (const FType *F) { - return EdgeInformation[F]; - } - - //===------------------------------------------------------------------===// - /// Analysis Update Methods - /// - void removeBlock(const BType *BB); - - void removeEdge(Edge e); - - void replaceEdge(const Edge &, const Edge &); - - enum GetPathMode { - GetPathToExit = 1, - GetPathToValue = 2, - GetPathToDest = 4, - GetPathWithNewEdges = 8 - }; - - const BType *GetPath(const BType *Src, const BType *Dest, - Path &P, unsigned Mode); - - void divertFlow(const Edge &, const Edge &); - - void splitEdge(const BType *FirstBB, const BType *SecondBB, - const BType *NewBB, bool MergeIdenticalEdges = false); - - void splitBlock(const BType *Old, const BType* New); - - void splitBlock(const BType *BB, const BType* NewBB, - BType *const *Preds, unsigned NumPreds); - - void replaceAllUses(const BType *RmBB, const BType *DestBB); - - void transfer(const FType *Old, const FType *New); - - void repair(const FType *F); - - void dump(FType *F = 0, bool real = true) { - dbgs() << "**** This is ProfileInfo " << this << " speaking:\n"; - if (!real) { - typename std::set Functions; - - dbgs() << "Functions: \n"; - if (F) { - dbgs() << F << "@" << format("%p", F) << ": " << format("%.20g",getExecutionCount(F)) << "\n"; - Functions.insert(F); - } else { - for (typename std::map::iterator fi = FunctionInformation.begin(), - fe = FunctionInformation.end(); fi != fe; ++fi) { - dbgs() << fi->first << "@" << format("%p",fi->first) << ": " << format("%.20g",fi->second) << "\n"; - Functions.insert(fi->first); - } - } - - for (typename std::set::iterator FI = Functions.begin(), FE = Functions.end(); - FI != FE; ++FI) { - const FType *F = *FI; - typename std::map::iterator bwi = BlockInformation.find(F); - dbgs() << "BasicBlocks for Function " << F << ":\n"; - for (typename BlockCounts::const_iterator bi = bwi->second.begin(), be = bwi->second.end(); bi != be; ++bi) { - dbgs() << bi->first << "@" << format("%p", bi->first) << ": " << format("%.20g",bi->second) << "\n"; - } - } - - for (typename std::set::iterator FI = Functions.begin(), FE = Functions.end(); - FI != FE; ++FI) { - typename std::map::iterator ei = EdgeInformation.find(*FI); - dbgs() << "Edges for Function " << ei->first << ":\n"; - for (typename EdgeWeights::iterator ewi = ei->second.begin(), ewe = ei->second.end(); - ewi != ewe; ++ewi) { - dbgs() << ewi->first << ": " << format("%.20g",ewi->second) << "\n"; - } - } - } else { - assert(F && "No function given, this is not supported!"); - dbgs() << "Functions: \n"; - dbgs() << F << "@" << format("%p", F) << ": " << format("%.20g",getExecutionCount(F)) << "\n"; - - dbgs() << "BasicBlocks for Function " << F << ":\n"; - for (typename FType::const_iterator BI = F->begin(), BE = F->end(); - BI != BE; ++BI) { - const BType *BB = &(*BI); - dbgs() << BB << "@" << format("%p", BB) << ": " << format("%.20g",getExecutionCount(BB)) << "\n"; - } - } - dbgs() << "**** ProfileInfo " << this << ", over and out.\n"; - } - - bool CalculateMissingEdge(const BType *BB, Edge &removed, bool assumeEmptyExit = false); - - bool EstimateMissingEdges(const BType *BB); - - ProfileInfoT *MI() { - if (MachineProfile == 0) - MachineProfile = new ProfileInfoT(); - return MachineProfile; - } - - bool hasMI() const { - return (MachineProfile != 0); - } - }; - - typedef ProfileInfoT ProfileInfo; - typedef ProfileInfoT MachineProfileInfo; - - /// createProfileLoaderPass - This function returns a Pass that loads the - /// profiling information for the module from the specified filename, making - /// it available to the optimizers. - Pass *createProfileLoaderPass(const std::string &Filename); - -} // End llvm namespace - -#endif diff --git a/include/llvm/Analysis/ProfileInfoLoader.h b/include/llvm/Analysis/ProfileInfoLoader.h deleted file mode 100644 index e0f49f3..0000000 --- a/include/llvm/Analysis/ProfileInfoLoader.h +++ /dev/null @@ -1,81 +0,0 @@ -//===- ProfileInfoLoader.h - Load & convert profile information -*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// The ProfileInfoLoader class is used to load and represent profiling -// information read in from the dump file. If conversions between formats are -// needed, it can also do this. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_ANALYSIS_PROFILEINFOLOADER_H -#define LLVM_ANALYSIS_PROFILEINFOLOADER_H - -#include -#include -#include - -namespace llvm { - -class Module; -class Function; -class BasicBlock; - -class ProfileInfoLoader { - const std::string &Filename; - std::vector CommandLines; - std::vector FunctionCounts; - std::vector BlockCounts; - std::vector EdgeCounts; - std::vector OptimalEdgeCounts; - std::vector BBTrace; -public: - // ProfileInfoLoader ctor - Read the specified profiling data file, exiting - // the program if the file is invalid or broken. - ProfileInfoLoader(const char *ToolName, const std::string &Filename); - - static const unsigned Uncounted; - - unsigned getNumExecutions() const { return CommandLines.size(); } - const std::string &getExecution(unsigned i) const { return CommandLines[i]; } - - const std::string &getFileName() const { return Filename; } - - // getRawFunctionCounts - This method is used by consumers of function - // counting information. - // - const std::vector &getRawFunctionCounts() const { - return FunctionCounts; - } - - // getRawBlockCounts - This method is used by consumers of block counting - // information. - // - const std::vector &getRawBlockCounts() const { - return BlockCounts; - } - - // getEdgeCounts - This method is used by consumers of edge counting - // information. - // - const std::vector &getRawEdgeCounts() const { - return EdgeCounts; - } - - // getEdgeOptimalCounts - This method is used by consumers of optimal edge - // counting information. - // - const std::vector &getRawOptimalEdgeCounts() const { - return OptimalEdgeCounts; - } - -}; - -} // End llvm namespace - -#endif diff --git a/include/llvm/Analysis/ProfileInfoTypes.h b/include/llvm/Analysis/ProfileInfoTypes.h deleted file mode 100644 index 45aab5b..0000000 --- a/include/llvm/Analysis/ProfileInfoTypes.h +++ /dev/null @@ -1,52 +0,0 @@ -/*===-- ProfileInfoTypes.h - Profiling info shared constants --------------===*\ -|* -|* The LLVM Compiler Infrastructure -|* -|* This file is distributed under the University of Illinois Open Source -|* License. See LICENSE.TXT for details. -|* -|*===----------------------------------------------------------------------===*| -|* -|* This file defines constants shared by the various different profiling -|* runtime libraries and the LLVM C++ profile info loader. It must be a -|* C header because, at present, the profiling runtimes are written in C. -|* -\*===----------------------------------------------------------------------===*/ - -#ifndef LLVM_ANALYSIS_PROFILEINFOTYPES_H -#define LLVM_ANALYSIS_PROFILEINFOTYPES_H - -/* Included by libprofile. */ -#if defined(__cplusplus) -extern "C" { -#endif - -/* IDs to distinguish between those path counters stored in hashses vs arrays */ -enum ProfilingStorageType { - ProfilingArray = 1, - ProfilingHash = 2 -}; - -#include "llvm/Analysis/ProfileDataTypes.h" - -/* - * The header for tables that map path numbers to path counters. - */ -typedef struct { - unsigned fnNumber; /* function number for these counters */ - unsigned numEntries; /* number of entries stored */ -} PathProfileHeader; - -/* - * Describes an entry in a tagged table for path counters. - */ -typedef struct { - unsigned pathNumber; - unsigned pathCounter; -} PathProfileTableEntry; - -#if defined(__cplusplus) -} -#endif - -#endif /* LLVM_ANALYSIS_PROFILEINFOTYPES_H */ diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h index 1b50bb2..bb82d94 100644 --- a/include/llvm/InitializePasses.h +++ b/include/llvm/InitializePasses.h @@ -113,9 +113,7 @@ void initializeDominanceFrontierPass(PassRegistry&); void initializeDominatorTreePass(PassRegistry&); void initializeEarlyIfConverterPass(PassRegistry&); void initializeEdgeBundlesPass(PassRegistry&); -void initializeEdgeProfilerPass(PassRegistry&); void initializeExpandPostRAPass(PassRegistry&); -void initializePathProfilerPass(PassRegistry&); void initializeGCOVProfilerPass(PassRegistry&); void initializeAddressSanitizerPass(PassRegistry&); void initializeAddressSanitizerModulePass(PassRegistry&); @@ -155,8 +153,6 @@ void initializeLiveRegMatrixPass(PassRegistry&); void initializeLiveStacksPass(PassRegistry&); void initializeLiveVariablesPass(PassRegistry&); void initializeLoaderPassPass(PassRegistry&); -void initializeProfileMetadataLoaderPassPass(PassRegistry&); -void initializePathProfileLoaderPassPass(PassRegistry&); void initializeLocalStackSlotPassPass(PassRegistry&); void initializeLoopDeletionPass(PassRegistry&); void initializeLoopExtractorPass(PassRegistry&); @@ -195,14 +191,11 @@ void initializeMetaRenamerPass(PassRegistry&); void initializeMergeFunctionsPass(PassRegistry&); void initializeModuleDebugInfoPrinterPass(PassRegistry&); void initializeNoAAPass(PassRegistry&); -void initializeNoProfileInfoPass(PassRegistry&); -void initializeNoPathProfileInfoPass(PassRegistry&); void initializeObjCARCAliasAnalysisPass(PassRegistry&); void initializeObjCARCAPElimPass(PassRegistry&); void initializeObjCARCExpandPass(PassRegistry&); void initializeObjCARCContractPass(PassRegistry&); void initializeObjCARCOptPass(PassRegistry&); -void initializeOptimalEdgeProfilerPass(PassRegistry&); void initializeOptimizePHIsPass(PassRegistry&); void initializePartiallyInlineLibCallsPass(PassRegistry&); void initializePEIPass(PassRegistry&); @@ -220,11 +213,6 @@ void initializePrintFunctionPassPass(PassRegistry&); void initializePrintModulePassPass(PassRegistry&); void initializePrintBasicBlockPassPass(PassRegistry&); void initializeProcessImplicitDefsPass(PassRegistry&); -void initializeProfileEstimatorPassPass(PassRegistry&); -void initializeProfileInfoAnalysisGroup(PassRegistry&); -void initializePathProfileInfoAnalysisGroup(PassRegistry&); -void initializePathProfileVerifierPass(PassRegistry&); -void initializeProfileVerifierPassPass(PassRegistry&); void initializePromotePassPass(PassRegistry&); void initializePruneEHPass(PassRegistry&); void initializeReassociatePass(PassRegistry&); diff --git a/include/llvm/LinkAllPasses.h b/include/llvm/LinkAllPasses.h index 0639ed1..d97e54c 100644 --- a/include/llvm/LinkAllPasses.h +++ b/include/llvm/LinkAllPasses.h @@ -74,9 +74,6 @@ namespace { (void) llvm::createDomPrinterPass(); (void) llvm::createDomOnlyViewerPass(); (void) llvm::createDomViewerPass(); - (void) llvm::createEdgeProfilerPass(); - (void) llvm::createOptimalEdgeProfilerPass(); - (void) llvm::createPathProfilerPass(); (void) llvm::createGCOVProfilerPass(); (void) llvm::createFunctionInliningPass(); (void) llvm::createAlwaysInlinerPass(); @@ -102,18 +99,11 @@ namespace { (void) llvm::createLowerInvokePass(); (void) llvm::createLowerSwitchPass(); (void) llvm::createNoAAPass(); - (void) llvm::createNoProfileInfoPass(); (void) llvm::createObjCARCAliasAnalysisPass(); (void) llvm::createObjCARCAPElimPass(); (void) llvm::createObjCARCExpandPass(); (void) llvm::createObjCARCContractPass(); (void) llvm::createObjCARCOptPass(); - (void) llvm::createProfileEstimatorPass(); - (void) llvm::createProfileVerifierPass(); - (void) llvm::createPathProfileVerifierPass(); - (void) llvm::createProfileLoaderPass(); - (void) llvm::createProfileMetadataLoaderPass(); - (void) llvm::createPathProfileLoaderPass(); (void) llvm::createPromoteMemoryToRegisterPass(); (void) llvm::createDemoteRegisterToMemoryPass(); (void) llvm::createPruneEHPass(); diff --git a/include/llvm/Transforms/Instrumentation.h b/include/llvm/Transforms/Instrumentation.h index a5cac00..8a1b34e 100644 --- a/include/llvm/Transforms/Instrumentation.h +++ b/include/llvm/Transforms/Instrumentation.h @@ -35,15 +35,6 @@ namespace llvm { class ModulePass; class FunctionPass; -// Insert edge profiling instrumentation -ModulePass *createEdgeProfilerPass(); - -// Insert optimal edge profiling instrumentation -ModulePass *createOptimalEdgeProfilerPass(); - -// Insert path profiling instrumentation -ModulePass *createPathProfilerPass(); - // Insert GCOV profiling instrumentation struct GCOVOptions { static GCOVOptions getDefault(); -- cgit v1.1 From 797f06e19b6f17217a69dea4d6ce900625432595 Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Wed, 2 Oct 2013 22:07:57 +0000 Subject: [llvm-c][Disassembler] Add an option to print latency information in disassembled output alongside the instructions. E.g., on a vector shuffle operation with a memory operand, disassembled outputs are: * Without the option: vpshufd $-0x79, (%rsp), %xmm0 * With the option: vpshufd $-0x79, (%rsp), %xmm0 ## Latency: 5 The printed latency is extracted from the schedule model available in the disassembler context. Thus, this option has no effect if there is not a scheduling model for the target. This boils down to one may need to specify the CPU string, so that this option could have an effect. Note: Latency < 2 are not printed. This part of . git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191859 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Disassembler.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Disassembler.h b/include/llvm-c/Disassembler.h index 0c5bd5c..4732e51 100644 --- a/include/llvm-c/Disassembler.h +++ b/include/llvm-c/Disassembler.h @@ -172,6 +172,8 @@ int LLVMSetDisasmOptions(LLVMDisasmContextRef DC, uint64_t Options); #define LLVMDisassembler_Option_AsmPrinterVariant 4 /* The option to set comment on instructions */ #define LLVMDisassembler_Option_SetInstrComments 8 + /* The option to print latency information alongside instructions */ +#define LLVMDisassembler_Option_PrintLatency 16 /** * Dispose of a disassembler context. -- cgit v1.1 From da750239bd1f02aef403baa4805805fb580e78e1 Mon Sep 17 00:00:00 2001 From: Pete Cooper Date: Thu, 3 Oct 2013 03:29:21 +0000 Subject: Add v4f16 to supported value types. This is useful for some ARM intrinsics such as VCVTN which does a <4 x float> <-> <4 x half> conversion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191870 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/ValueTypes.h | 35 ++++++++++++++++++++--------------- include/llvm/CodeGen/ValueTypes.td | 29 +++++++++++++++-------------- include/llvm/IR/Intrinsics.td | 2 ++ 3 files changed, 37 insertions(+), 29 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h index 18b324f..2e8f637 100644 --- a/include/llvm/CodeGen/ValueTypes.h +++ b/include/llvm/CodeGen/ValueTypes.h @@ -95,16 +95,17 @@ namespace llvm { LAST_INTEGER_VECTOR_VALUETYPE = v16i64, v2f16 = 42, // 2 x f16 - v8f16 = 43, // 8 x f16 - v1f32 = 44, // 1 x f32 - v2f32 = 45, // 2 x f32 - v4f32 = 46, // 4 x f32 - v8f32 = 47, // 8 x f32 - v16f32 = 48, // 16 x f32 - v1f64 = 49, // 1 x f64 - v2f64 = 50, // 2 x f64 - v4f64 = 51, // 4 x f64 - v8f64 = 52, // 8 x f64 + v4f16 = 43, // 4 x f16 + v8f16 = 44, // 8 x f16 + v1f32 = 45, // 1 x f32 + v2f32 = 46, // 2 x f32 + v4f32 = 47, // 4 x f32 + v8f32 = 48, // 8 x f32 + v16f32 = 49, // 16 x f32 + v1f64 = 50, // 1 x f64 + v2f64 = 51, // 2 x f64 + v4f64 = 52, // 4 x f64 + v8f64 = 53, // 8 x f64 FIRST_FP_VECTOR_VALUETYPE = v2f16, LAST_FP_VECTOR_VALUETYPE = v8f64, @@ -112,17 +113,17 @@ namespace llvm { FIRST_VECTOR_VALUETYPE = v2i1, LAST_VECTOR_VALUETYPE = v8f64, - x86mmx = 53, // This is an X86 MMX value + x86mmx = 54, // This is an X86 MMX value - Glue = 54, // This glues nodes together during pre-RA sched + Glue = 55, // This glues nodes together during pre-RA sched - isVoid = 55, // This has no value + isVoid = 56, // This has no value - Untyped = 56, // This value takes a register, but has + Untyped = 57, // This value takes a register, but has // unspecified type. The register class // will be determined by the opcode. - LAST_VALUETYPE = 57, // This always remains at the end of the list. + LAST_VALUETYPE = 58, // This always remains at the end of the list. // This is the current maximum for LAST_VALUETYPE. // MVT::MAX_ALLOWED_VALUETYPE is used for asserts and to size bit vectors @@ -293,6 +294,7 @@ namespace llvm { case v8i64: case v16i64: return i64; case v2f16: + case v4f16: case v8f16: return f16; case v1f32: case v2f32: @@ -334,6 +336,7 @@ namespace llvm { case v4i16: case v4i32: case v4i64: + case v4f16: case v4f32: case v4f64: return 4; case v2i1: @@ -395,6 +398,7 @@ namespace llvm { case v4i16: case v2i32: case v1i64: + case v4f16: case v2f32: case v1f64: return 64; case f80 : return 80; @@ -538,6 +542,7 @@ namespace llvm { break; case MVT::f16: if (NumElements == 2) return MVT::v2f16; + if (NumElements == 4) return MVT::v4f16; if (NumElements == 8) return MVT::v8f16; break; case MVT::f32: diff --git a/include/llvm/CodeGen/ValueTypes.td b/include/llvm/CodeGen/ValueTypes.td index 415dbed..5fc98bf 100644 --- a/include/llvm/CodeGen/ValueTypes.td +++ b/include/llvm/CodeGen/ValueTypes.td @@ -64,22 +64,23 @@ def v8i64 : ValueType<512, 40>; // 8 x i64 vector value def v16i64 : ValueType<1024,41>; // 16 x i64 vector value def v2f16 : ValueType<32 , 42>; // 2 x f16 vector value -def v8f16 : ValueType<128, 43>; // 8 x f16 vector value -def v1f32 : ValueType<32 , 44>; // 1 x f32 vector value -def v2f32 : ValueType<64 , 45>; // 2 x f32 vector value -def v4f32 : ValueType<128, 46>; // 4 x f32 vector value -def v8f32 : ValueType<256, 47>; // 8 x f32 vector value -def v16f32 : ValueType<512, 48>; // 16 x f32 vector value -def v1f64 : ValueType<64, 49>; // 1 x f64 vector value -def v2f64 : ValueType<128, 50>; // 2 x f64 vector value -def v4f64 : ValueType<256, 51>; // 4 x f64 vector value -def v8f64 : ValueType<512, 52>; // 8 x f64 vector value +def v4f16 : ValueType<64 , 43>; // 4 x f16 vector value +def v8f16 : ValueType<128, 44>; // 8 x f16 vector value +def v1f32 : ValueType<32 , 45>; // 1 x f32 vector value +def v2f32 : ValueType<64 , 46>; // 2 x f32 vector value +def v4f32 : ValueType<128, 47>; // 4 x f32 vector value +def v8f32 : ValueType<256, 48>; // 8 x f32 vector value +def v16f32 : ValueType<512, 49>; // 16 x f32 vector value +def v1f64 : ValueType<64, 50>; // 1 x f64 vector value +def v2f64 : ValueType<128, 51>; // 2 x f64 vector value +def v4f64 : ValueType<256, 52>; // 4 x f64 vector value +def v8f64 : ValueType<512, 53>; // 8 x f64 vector value -def x86mmx : ValueType<64 , 53>; // X86 MMX value -def FlagVT : ValueType<0 , 54>; // Pre-RA sched glue -def isVoid : ValueType<0 , 55>; // Produces no value -def untyped: ValueType<8 , 56>; // Produces an untyped value +def x86mmx : ValueType<64 , 54>; // X86 MMX value +def FlagVT : ValueType<0 , 55>; // Pre-RA sched glue +def isVoid : ValueType<0 , 56>; // Produces no value +def untyped: ValueType<8 , 57>; // Produces an untyped value def MetadataVT: ValueType<0, 250>; // Metadata // Pseudo valuetype mapped to the current pointer size to any address space. diff --git a/include/llvm/IR/Intrinsics.td b/include/llvm/IR/Intrinsics.td index 30cd4be..57c99d9 100644 --- a/include/llvm/IR/Intrinsics.td +++ b/include/llvm/IR/Intrinsics.td @@ -166,6 +166,8 @@ def llvm_v4i64_ty : LLVMType; // 4 x i64 def llvm_v8i64_ty : LLVMType; // 8 x i64 def llvm_v16i64_ty : LLVMType; // 16 x i64 +def llvm_v2f16_ty : LLVMType; // 2 x half (__fp16) +def llvm_v4f16_ty : LLVMType; // 4 x half (__fp16) def llvm_v8f16_ty : LLVMType; // 8 x half (__fp16) def llvm_v1f32_ty : LLVMType; // 1 x float def llvm_v2f32_ty : LLVMType; // 2 x float -- cgit v1.1 From fafe4bbd6c25551b7ea92cf63a8bb4a79c6c4324 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Thu, 3 Oct 2013 04:16:45 +0000 Subject: Add patterns for selecting TBM instructions from logical operations. Patch from Yunzhong Gao. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191871 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index 3352d67..4eb6960 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -2602,7 +2602,7 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". llvm_i32_ty], [IntrNoMem]>; def int_x86_tbm_bextri_u64 : GCCBuiltin<"__builtin_ia32_bextri_u64">, Intrinsic<[llvm_i64_ty], [llvm_i64_ty, - llvm_i32_ty], [IntrNoMem]>; + llvm_i64_ty], [IntrNoMem]>; def int_x86_tbm_blcfill_u32 : GCCBuiltin<"__builtin_ia32_blcfill_u32">, Intrinsic<[llvm_i32_ty], [llvm_i32_ty], [IntrNoMem]>; -- cgit v1.1 From 438900938c3ac9d7fac2dd5d2c85ca4b9b2e35f7 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 3 Oct 2013 18:29:09 +0000 Subject: Optimize linkonce_odr unnamed_addr functions during LTO. Generalize the API so we can distinguish symbols that are needed just for a DSO symbol table from those that are used from some native .o. The symbols that are only wanted for the dso symbol table can be dropped if llvm can prove every other dso has a copy (linkonce_odr) and the address is not important (unnamed_addr). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191922 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/lto.h | 16 ++++++++++++---- include/llvm/LTO/LTOCodeGenerator.h | 6 ++++++ include/llvm/Transforms/IPO.h | 26 +++++++++++++++++++++++--- 3 files changed, 41 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/llvm-c/lto.h b/include/llvm-c/lto.h index 58d5833..85d5439 100644 --- a/include/llvm-c/lto.h +++ b/include/llvm-c/lto.h @@ -29,7 +29,7 @@ * @{ */ -#define LTO_API_VERSION 4 +#define LTO_API_VERSION 5 typedef enum { LTO_SYMBOL_ALIGNMENT_MASK = 0x0000001F, /* log2 of alignment */ @@ -253,13 +253,21 @@ lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args, int nargs); /** - * Adds to a list of all global symbols that must exist in the final - * generated code. If a function is not listed, it might be - * inlined into every usage and optimized away. + * Tells LTO optimization passes that this symbol must be preserved + * because it is referenced by native code or a command line option. */ extern void lto_codegen_add_must_preserve_symbol(lto_code_gen_t cg, const char* symbol); + +/** + * Tells LTO optimization passes that a dynamic shared library is being + * built and this symbol may be exported. Unless IR semantics allow the symbol + * to be made local to the library, it should remain so it can be exported by + * the shared library. + */ +extern void lto_codegen_add_dso_symbol(lto_code_gen_t cg, const char *symbol); + /** * Writes a new object file at the specified path that contains the * merged contents of all modules added so far. diff --git a/include/llvm/LTO/LTOCodeGenerator.h b/include/llvm/LTO/LTOCodeGenerator.h index 97a5066..9f50770 100644 --- a/include/llvm/LTO/LTOCodeGenerator.h +++ b/include/llvm/LTO/LTOCodeGenerator.h @@ -73,6 +73,10 @@ struct LTOCodeGenerator { void addMustPreserveSymbol(const char *sym) { MustPreserveSymbols[sym] = 1; } + void addDSOSymbol(const char* Sym) { + DSOSymbols[Sym] = 1; + } + // To pass options to the driver and optimization passes. These options are // not necessarily for debugging purpose (The function name is misleading). // This function should be called before LTOCodeGenerator::compilexxx(), @@ -126,6 +130,7 @@ private: void applyScopeRestrictions(); void applyRestriction(llvm::GlobalValue &GV, std::vector &MustPreserveList, + std::vector &SymtabList, llvm::SmallPtrSet &AsmUsed, llvm::Mangler &Mangler); bool determineTarget(std::string &errMsg); @@ -138,6 +143,7 @@ private: bool EmitDwarfDebugInfo; bool ScopeRestrictionsDone; lto_codegen_model CodeModel; + StringSet DSOSymbols; StringSet MustPreserveSymbols; StringSet AsmUndefinedRefs; llvm::MemoryBuffer *NativeObjectFile; diff --git a/include/llvm/Transforms/IPO.h b/include/llvm/Transforms/IPO.h index 6ebb6c4..ed28230 100644 --- a/include/llvm/Transforms/IPO.h +++ b/include/llvm/Transforms/IPO.h @@ -104,12 +104,32 @@ Pass *createPruneEHPass(); //===----------------------------------------------------------------------===// /// createInternalizePass - This pass loops over all of the functions in the -/// input module, internalizing all globals (functions and variables) not in the -/// given exportList. +/// input module, internalizing all globals (functions and variables) it can. +//// +/// The symbols in \p ExportList are never internalized. +/// +/// The symbol in DSOList are internalized if it is safe to drop them from +/// the symbol table. +/// +/// For example of the difference, consider a dynamic library being built from +/// two translation units. The first one compiled to a native object +/// (ELF/MachO/COFF) and second one compiled to IL. Translation unit A has a +/// copy of linkonce_odr unnamed_addr function F. The translation unit B has a +/// copy of the linkonce_odr unnamed_addr functions F and G. +/// +/// Assume the linker decides to keep the copy of F in B. This means that LLVM +/// must produce F in the object file it passes to the linker, otherwise we +/// will have an undefined reference. For G the situation is different. The +/// linker puts the function in the DSOList, since it is only wanted for the +/// symbol table. With this information internalize can now reason that since +/// the function is a linkonce_odr and its address is not important, it can be +/// omitted. Any other shared library needing this function will have a copy of +/// it. /// /// Note that commandline options that are used with the above function are not /// used now! -ModulePass *createInternalizePass(ArrayRef ExportList); +ModulePass *createInternalizePass(ArrayRef ExportList, + ArrayRef DSOList); /// createInternalizePass - Same as above, but with an empty exportList. ModulePass *createInternalizePass(); -- cgit v1.1 From cee51c48030f37133ad4004d3e5c14d8ebfc91c4 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Thu, 3 Oct 2013 19:50:01 +0000 Subject: Rename DataLayout variables TD -> DL git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191927 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/MemoryBuiltins.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/llvm/Analysis/MemoryBuiltins.h b/include/llvm/Analysis/MemoryBuiltins.h index 587b87f..c54b7e6 100644 --- a/include/llvm/Analysis/MemoryBuiltins.h +++ b/include/llvm/Analysis/MemoryBuiltins.h @@ -85,7 +85,7 @@ static inline CallInst *extractMallocCall(Value *I, /// isArrayMalloc - Returns the corresponding CallInst if the instruction /// is a call to malloc whose array size can be determined and the array size /// is not constant 1. Otherwise, return NULL. -const CallInst *isArrayMalloc(const Value *I, const DataLayout *TD, +const CallInst *isArrayMalloc(const Value *I, const DataLayout *DL, const TargetLibraryInfo *TLI); /// getMallocType - Returns the PointerType resulting from the malloc call. @@ -107,7 +107,7 @@ Type *getMallocAllocatedType(const CallInst *CI, const TargetLibraryInfo *TLI); /// then return that multiple. For non-array mallocs, the multiple is /// constant 1. Otherwise, return NULL for mallocs whose array size cannot be /// determined. -Value *getMallocArraySize(CallInst *CI, const DataLayout *TD, +Value *getMallocArraySize(CallInst *CI, const DataLayout *DL, const TargetLibraryInfo *TLI, bool LookThroughSExt = false); @@ -147,7 +147,7 @@ static inline CallInst *isFreeCall(Value *I, const TargetLibraryInfo *TLI) { /// underlying object pointed to by Ptr. /// If RoundToAlign is true, then Size is rounded up to the aligment of allocas, /// byval arguments, and global variables. -bool getObjectSize(const Value *Ptr, uint64_t &Size, const DataLayout *TD, +bool getObjectSize(const Value *Ptr, uint64_t &Size, const DataLayout *DL, const TargetLibraryInfo *TLI, bool RoundToAlign = false); @@ -159,7 +159,7 @@ typedef std::pair SizeOffsetType; class ObjectSizeOffsetVisitor : public InstVisitor { - const DataLayout *TD; + const DataLayout *DL; const TargetLibraryInfo *TLI; bool RoundToAlign; unsigned IntTyBits; @@ -173,7 +173,7 @@ class ObjectSizeOffsetVisitor } public: - ObjectSizeOffsetVisitor(const DataLayout *TD, const TargetLibraryInfo *TLI, + ObjectSizeOffsetVisitor(const DataLayout *DL, const TargetLibraryInfo *TLI, LLVMContext &Context, bool RoundToAlign = false); SizeOffsetType compute(Value *V); @@ -220,7 +220,7 @@ class ObjectSizeOffsetEvaluator typedef DenseMap CacheMapTy; typedef SmallPtrSet PtrSetTy; - const DataLayout *TD; + const DataLayout *DL; const TargetLibraryInfo *TLI; LLVMContext &Context; BuilderTy Builder; @@ -235,7 +235,7 @@ class ObjectSizeOffsetEvaluator SizeOffsetEvalType compute_(Value *V); public: - ObjectSizeOffsetEvaluator(const DataLayout *TD, const TargetLibraryInfo *TLI, + ObjectSizeOffsetEvaluator(const DataLayout *DL, const TargetLibraryInfo *TLI, LLVMContext &Context); SizeOffsetEvalType compute(Value *V); -- cgit v1.1 From b868e9101c138016aad5bd910b67f40a3213d6fc Mon Sep 17 00:00:00 2001 From: Andrew Kaylor Date: Fri, 4 Oct 2013 00:49:38 +0000 Subject: Adding support and tests for multiple module handling in lli git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191938 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ExecutionEngine/RTDyldMemoryManager.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/ExecutionEngine/RTDyldMemoryManager.h b/include/llvm/ExecutionEngine/RTDyldMemoryManager.h index 5932687..09a5cb4 100644 --- a/include/llvm/ExecutionEngine/RTDyldMemoryManager.h +++ b/include/llvm/ExecutionEngine/RTDyldMemoryManager.h @@ -21,6 +21,9 @@ namespace llvm { +class ExecutionEngine; +class ObjectImage; + // RuntimeDyld clients often want to handle the memory management of // what gets placed where. For JIT clients, this is the subset of // JITMemoryManager required for dynamic loading of binaries. @@ -41,7 +44,7 @@ public: virtual uint8_t *allocateCodeSection( uintptr_t Size, unsigned Alignment, unsigned SectionID, StringRef SectionName) = 0; - + /// Allocate a memory block of (at least) the given size suitable for data. /// The SectionID is a unique identifier assigned by the JIT engine, and /// optionally recorded by the memory manager to access a loaded section. @@ -63,11 +66,24 @@ public: /// found, this function returns a null pointer. Otherwise, it prints a /// message to stderr and aborts. /// - /// This function is deprecated for memory managers used to be used with + /// This function is deprecated for memory managers to be used with /// MCJIT or RuntimeDyld. Use getSymbolAddress instead. virtual void *getPointerToNamedFunction(const std::string &Name, bool AbortOnFailure = true); + /// This method is called after an object has been loaded into memory but + /// before relocations are applied to the loaded sections. The object load + /// may have been initiated by MCJIT to resolve an external symbol for another + /// object that is being finalized. In that case, the object about which + /// the memory manager is being notified will be finalized immediately after + /// the memory manager returns from this call. + /// + /// Memory managers which are preparing code for execution in an external + /// address space can use this call to remap the section addresses for the + /// newly loaded object. + virtual void notifyObjectLoaded(ExecutionEngine *EE, + const ObjectImage *) {} + /// This method is called when object loading is complete and section page /// permissions can be applied. It is up to the memory manager implementation /// to decide whether or not to act on this method. The memory manager will -- cgit v1.1 From d3562956789dbd0571a7e46052bee64b153fa7c4 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Fri, 4 Oct 2013 05:22:20 +0000 Subject: Add OPC_CheckChildSame0-3 to the DAG isel matcher. This replaces sequences of MoveChild, CheckSame, MoveParent. Saves 846 bytes from the X86 DAG isel matcher, ~300 from ARM, ~840 from Hexagon. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191940 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/SelectionDAGISel.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/SelectionDAGISel.h b/include/llvm/CodeGen/SelectionDAGISel.h index 3d55d3a..b5ec8cb 100644 --- a/include/llvm/CodeGen/SelectionDAGISel.h +++ b/include/llvm/CodeGen/SelectionDAGISel.h @@ -113,6 +113,8 @@ public: OPC_MoveChild, OPC_MoveParent, OPC_CheckSame, + OPC_CheckChild0Same, OPC_CheckChild1Same, + OPC_CheckChild2Same, OPC_CheckChild3Same, OPC_CheckPatternPredicate, OPC_CheckPredicate, OPC_CheckOpcode, -- cgit v1.1 From 596cfd045fa05c249083b5ff7cdb5e32f4d92b97 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Fri, 4 Oct 2013 05:52:17 +0000 Subject: Revert r191940 to see if it fixes the build bots. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191941 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/SelectionDAGISel.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/SelectionDAGISel.h b/include/llvm/CodeGen/SelectionDAGISel.h index b5ec8cb..3d55d3a 100644 --- a/include/llvm/CodeGen/SelectionDAGISel.h +++ b/include/llvm/CodeGen/SelectionDAGISel.h @@ -113,8 +113,6 @@ public: OPC_MoveChild, OPC_MoveParent, OPC_CheckSame, - OPC_CheckChild0Same, OPC_CheckChild1Same, - OPC_CheckChild2Same, OPC_CheckChild3Same, OPC_CheckPatternPredicate, OPC_CheckPredicate, OPC_CheckOpcode, -- cgit v1.1 From 3f045005bf96b6521b2769fc824283589bfa133a Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Fri, 4 Oct 2013 17:08:38 +0000 Subject: Temporarily revert r191792 as it is causing some LTO debug failures on platforms with relocations in debug info and also temporarily revert r191800 due to conflicts with the revert of r191792. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191967 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index cd4777d..ecdca49 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -22,7 +22,6 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" -#include "llvm/IR/Metadata.h" #include "llvm/Support/Dwarf.h" namespace llvm { @@ -207,8 +206,6 @@ namespace llvm { /// Gets the parent scope for this scope node or returns a /// default constructed scope. DIScopeRef getContext() const; - /// If the scope node has a name, return that, else return an empty string. - StringRef getName() const; StringRef getFilename() const; StringRef getDirectory() const; @@ -246,16 +243,6 @@ namespace llvm { "MDNode in DITypeIdentifierMap should be a DIType."); return T(Iter->second); } - StringRef getName() const { - if (!Val) - return StringRef(); - - if (const MDNode *MD = dyn_cast(Val)) - return T(MD).getName(); - - const MDString *MS = cast(Val); - return MS->getString(); - } operator Value *() const { return const_cast(Val); } }; @@ -334,6 +321,9 @@ namespace llvm { return DbgNode && isType(); } + /// isUnsignedDIType - Return true if type encoding is unsigned. + bool isUnsignedDIType(); + /// replaceAllUsesWith - Replace all uses of debug info referenced by /// this descriptor. void replaceAllUsesWith(DIDescriptor &D); @@ -361,7 +351,11 @@ namespace llvm { public: explicit DIDerivedType(const MDNode *N = 0) : DIType(N) {} - DITypeRef getTypeDerivedFrom() const { return getFieldAs(9); } + DIType getTypeDerivedFrom() const { return getFieldAs(9); } + + /// getOriginalTypeSize - If this type is derived from a base type then + /// return base type size. + uint64_t getOriginalTypeSize() const; /// getObjCProperty - Return property node, if this ivar is /// associated with one. -- cgit v1.1 From 8e48edcf3dd7dea9fec58b05a6ace6fbd0260d7c Mon Sep 17 00:00:00 2001 From: Jack Carter Date: Fri, 4 Oct 2013 21:26:15 +0000 Subject: [MC][AsmParser] Hook for post assembly file processing This patch handles LLVM standalone assembler (llvm-mc) ELF flag setting based on input file directive processing. Mips assembly requires processing inline directives that directly and indirectly affect the output ELF header flags. This patch handles one ".abicalls". To process these directives we are following the model the code generator uses by storing state in a container as we go through processing and when we detect the end of input file processing, AsmParser is notified and we update the ELF header flags through a MipsELFStreamer method with a call from MCTargetAsmParser::emitEndOfAsmFile(MCStreamer &OutStreamer). This patch will allow other targets the same functionality. Jack git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191982 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCTargetAsmParser.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCTargetAsmParser.h b/include/llvm/MC/MCTargetAsmParser.h index 6e96e8b..512fd864 100644 --- a/include/llvm/MC/MCTargetAsmParser.h +++ b/include/llvm/MC/MCTargetAsmParser.h @@ -176,6 +176,11 @@ public: virtual void convertToMapAndConstraints(unsigned Kind, const SmallVectorImpl &Operands) = 0; + /// End of assembly processing. + /// This gets called when all assembly has been read and gives the local + /// Target AsmParsers an opportunity for any final data processing, etc.. + virtual void emitEndOfAsmFile(MCStreamer &Out) {} + virtual const MCExpr *applyModifierToExpr(const MCExpr *E, MCSymbolRefExpr::VariantKind, MCContext &Ctx) { -- cgit v1.1 From 6d389f5ebae9aa08309c5795234cf155054b6b39 Mon Sep 17 00:00:00 2001 From: Jack Carter Date: Fri, 4 Oct 2013 22:52:31 +0000 Subject: reverting per request git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191992 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCTargetAsmParser.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCTargetAsmParser.h b/include/llvm/MC/MCTargetAsmParser.h index 512fd864..6e96e8b 100644 --- a/include/llvm/MC/MCTargetAsmParser.h +++ b/include/llvm/MC/MCTargetAsmParser.h @@ -176,11 +176,6 @@ public: virtual void convertToMapAndConstraints(unsigned Kind, const SmallVectorImpl &Operands) = 0; - /// End of assembly processing. - /// This gets called when all assembly has been read and gives the local - /// Target AsmParsers an opportunity for any final data processing, etc.. - virtual void emitEndOfAsmFile(MCStreamer &Out) {} - virtual const MCExpr *applyModifierToExpr(const MCExpr *E, MCSymbolRefExpr::VariantKind, MCContext &Ctx) { -- cgit v1.1 From fc753102300a704e4385910c279520b0edb19034 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Fri, 4 Oct 2013 23:06:14 +0000 Subject: Formatting. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191995 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index ecdca49..6d63d66 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -161,7 +161,7 @@ namespace llvm { explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {} int64_t getLo() const { return getInt64Field(1); } - int64_t getCount() const { return getInt64Field(2); } + int64_t getCount() const { return getInt64Field(2); } bool Verify() const; }; -- cgit v1.1 From f2fff255de51eec0e9d4a85724bb433be7e4c24b Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Fri, 4 Oct 2013 23:15:52 +0000 Subject: Reformat. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191997 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 1623 ++++++++++++++++++++++------------------------ 1 file changed, 791 insertions(+), 832 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 6d63d66..8486b10 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -25,840 +25,799 @@ #include "llvm/Support/Dwarf.h" namespace llvm { - class BasicBlock; - class Constant; - class Function; - class GlobalVariable; - class Module; - class Type; - class Value; - class DbgDeclareInst; - class DbgValueInst; - class Instruction; - class MDNode; - class MDString; - class NamedMDNode; - class LLVMContext; - class raw_ostream; - - class DIFile; - class DISubprogram; - class DILexicalBlock; - class DILexicalBlockFile; - class DIVariable; - class DIType; - class DIScope; - class DIObjCProperty; - - /// Maps from type identifier to the actual MDNode. - typedef DenseMap DITypeIdentifierMap; - - /// DIDescriptor - A thin wraper around MDNode to access encoded debug info. - /// This should not be stored in a container, because the underlying MDNode - /// may change in certain situations. - class DIDescriptor { - // Befriends DIRef so DIRef can befriend the protected member - // function: getFieldAs. - template - friend class DIRef; - public: - enum { - FlagPrivate = 1 << 0, - FlagProtected = 1 << 1, - FlagFwdDecl = 1 << 2, - FlagAppleBlock = 1 << 3, - FlagBlockByrefStruct = 1 << 4, - FlagVirtual = 1 << 5, - FlagArtificial = 1 << 6, - FlagExplicit = 1 << 7, - FlagPrototyped = 1 << 8, - FlagObjcClassComplete = 1 << 9, - FlagObjectPointer = 1 << 10, - FlagVector = 1 << 11, - FlagStaticMember = 1 << 12, - FlagIndirectVariable = 1 << 13 - }; - protected: - const MDNode *DbgNode; - - StringRef getStringField(unsigned Elt) const; - unsigned getUnsignedField(unsigned Elt) const { - return (unsigned)getUInt64Field(Elt); - } - uint64_t getUInt64Field(unsigned Elt) const; - int64_t getInt64Field(unsigned Elt) const; - DIDescriptor getDescriptorField(unsigned Elt) const; - - template - DescTy getFieldAs(unsigned Elt) const { - return DescTy(getDescriptorField(Elt)); - } - - GlobalVariable *getGlobalVariableField(unsigned Elt) const; - Constant *getConstantField(unsigned Elt) const; - Function *getFunctionField(unsigned Elt) const; - void replaceFunctionField(unsigned Elt, Function *F); - - public: - explicit DIDescriptor(const MDNode *N = 0) : DbgNode(N) {} - - bool Verify() const; - - operator MDNode *() const { return const_cast(DbgNode); } - MDNode *operator ->() const { return const_cast(DbgNode); } - - // An explicit operator bool so that we can do testing of DI values - // easily. - // FIXME: This operator bool isn't actually protecting anything at the - // moment due to the conversion operator above making DIDescriptor nodes - // implicitly convertable to bool. - LLVM_EXPLICIT operator bool() const { return DbgNode != 0; } - - bool operator==(DIDescriptor Other) const { - return DbgNode == Other.DbgNode; - } - bool operator!=(DIDescriptor Other) const { - return !operator==(Other); - } - - uint16_t getTag() const { - return getUnsignedField(0) & ~LLVMDebugVersionMask; - } - - bool isDerivedType() const; - bool isCompositeType() const; - bool isBasicType() const; - bool isVariable() const; - bool isSubprogram() const; - bool isGlobalVariable() const; - bool isScope() const; - bool isFile() const; - bool isCompileUnit() const; - bool isNameSpace() const; - bool isLexicalBlockFile() const; - bool isLexicalBlock() const; - bool isSubrange() const; - bool isEnumerator() const; - bool isType() const; - bool isUnspecifiedParameter() const; - bool isTemplateTypeParameter() const; - bool isTemplateValueParameter() const; - bool isObjCProperty() const; - bool isImportedEntity() const; - - /// print - print descriptor. - void print(raw_ostream &OS) const; - - /// dump - print descriptor to dbgs() with a newline. - void dump() const; +class BasicBlock; +class Constant; +class Function; +class GlobalVariable; +class Module; +class Type; +class Value; +class DbgDeclareInst; +class DbgValueInst; +class Instruction; +class MDNode; +class MDString; +class NamedMDNode; +class LLVMContext; +class raw_ostream; + +class DIFile; +class DISubprogram; +class DILexicalBlock; +class DILexicalBlockFile; +class DIVariable; +class DIType; +class DIScope; +class DIObjCProperty; + +/// Maps from type identifier to the actual MDNode. +typedef DenseMap DITypeIdentifierMap; + +/// DIDescriptor - A thin wraper around MDNode to access encoded debug info. +/// This should not be stored in a container, because the underlying MDNode +/// may change in certain situations. +class DIDescriptor { + // Befriends DIRef so DIRef can befriend the protected member + // function: getFieldAs. + template friend class DIRef; + +public: + enum { + FlagPrivate = 1 << 0, + FlagProtected = 1 << 1, + FlagFwdDecl = 1 << 2, + FlagAppleBlock = 1 << 3, + FlagBlockByrefStruct = 1 << 4, + FlagVirtual = 1 << 5, + FlagArtificial = 1 << 6, + FlagExplicit = 1 << 7, + FlagPrototyped = 1 << 8, + FlagObjcClassComplete = 1 << 9, + FlagObjectPointer = 1 << 10, + FlagVector = 1 << 11, + FlagStaticMember = 1 << 12, + FlagIndirectVariable = 1 << 13 }; - /// DISubrange - This is used to represent ranges, for array bounds. - class DISubrange : public DIDescriptor { - friend class DIDescriptor; - void printInternal(raw_ostream &OS) const; - public: - explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {} - - int64_t getLo() const { return getInt64Field(1); } - int64_t getCount() const { return getInt64Field(2); } - bool Verify() const; - }; - - /// DIArray - This descriptor holds an array of descriptors. - class DIArray : public DIDescriptor { - public: - explicit DIArray(const MDNode *N = 0) : DIDescriptor(N) {} - - unsigned getNumElements() const; - DIDescriptor getElement(unsigned Idx) const { - return getDescriptorField(Idx); - } - }; - - /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}'). - /// FIXME: it seems strange that this doesn't have either a reference to the - /// type/precision or a file/line pair for location info. - class DIEnumerator : public DIDescriptor { - friend class DIDescriptor; - void printInternal(raw_ostream &OS) const; - public: - explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {} - - StringRef getName() const { return getStringField(1); } - int64_t getEnumValue() const { return getInt64Field(2); } - bool Verify() const; - }; - - template - class DIRef; - typedef DIRef DIScopeRef; - typedef DIRef DITypeRef; - - /// DIScope - A base class for various scopes. - class DIScope : public DIDescriptor { - protected: - friend class DIDescriptor; - void printInternal(raw_ostream &OS) const; - public: - explicit DIScope(const MDNode *N = 0) : DIDescriptor (N) {} - - /// Gets the parent scope for this scope node or returns a - /// default constructed scope. - DIScopeRef getContext() const; - StringRef getFilename() const; - StringRef getDirectory() const; - - /// Generate a reference to this DIScope. Uses the type identifier instead - /// of the actual MDNode if possible, to help type uniquing. - DIScopeRef getRef() const; - }; - - /// Represents reference to a DIDescriptor, abstracts over direct and - /// identifier-based metadata references. - template - class DIRef { - template - friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const; - friend DIScopeRef DIScope::getContext() const; - friend DIScopeRef DIScope::getRef() const; - - /// Val can be either a MDNode or a MDString, in the latter, - /// MDString specifies the type identifier. - const Value *Val; - explicit DIRef(const Value *V); - public: - T resolve(const DITypeIdentifierMap &Map) const { - if (!Val) - return T(); - - if (const MDNode *MD = dyn_cast(Val)) - return T(MD); - - const MDString *MS = cast(Val); - // Find the corresponding MDNode. - DITypeIdentifierMap::const_iterator Iter = Map.find(MS); - assert(Iter != Map.end() && "Identifier not in the type map?"); - assert(DIDescriptor(Iter->second).isType() && - "MDNode in DITypeIdentifierMap should be a DIType."); - return T(Iter->second); - } - operator Value *() const { return const_cast(Val); } - }; - - /// Specialize getFieldAs to handle fields that are references to DIScopes. - template <> - DIScopeRef DIDescriptor::getFieldAs(unsigned Elt) const; - /// Specialize DIRef constructor for DIScopeRef. - template <> - DIRef::DIRef(const Value *V); - - /// Specialize getFieldAs to handle fields that are references to DITypes. - template <> - DITypeRef DIDescriptor::getFieldAs(unsigned Elt) const; - /// Specialize DIRef constructor for DITypeRef. - template <> - DIRef::DIRef(const Value *V); - - /// DIType - This is a wrapper for a type. - /// FIXME: Types should be factored much better so that CV qualifiers and - /// others do not require a huge and empty descriptor full of zeros. - class DIType : public DIScope { - protected: - friend class DIDescriptor; - void printInternal(raw_ostream &OS) const; - - public: - DIType(const MDNode *N = 0) : DIScope(N) {} - - /// Verify - Verify that a type descriptor is well formed. - bool Verify() const; - - DIScopeRef getContext() const { return getFieldAs(2); } - StringRef getName() const { return getStringField(3); } - unsigned getLineNumber() const { return getUnsignedField(4); } - uint64_t getSizeInBits() const { return getUInt64Field(5); } - uint64_t getAlignInBits() const { return getUInt64Field(6); } - // FIXME: Offset is only used for DW_TAG_member nodes. Making every type - // carry this is just plain insane. - uint64_t getOffsetInBits() const { return getUInt64Field(7); } - unsigned getFlags() const { return getUnsignedField(8); } - bool isPrivate() const { - return (getFlags() & FlagPrivate) != 0; - } - bool isProtected() const { - return (getFlags() & FlagProtected) != 0; - } - bool isForwardDecl() const { - return (getFlags() & FlagFwdDecl) != 0; - } - // isAppleBlock - Return true if this is the Apple Blocks extension. - bool isAppleBlockExtension() const { - return (getFlags() & FlagAppleBlock) != 0; - } - bool isBlockByrefStruct() const { - return (getFlags() & FlagBlockByrefStruct) != 0; - } - bool isVirtual() const { - return (getFlags() & FlagVirtual) != 0; - } - bool isArtificial() const { - return (getFlags() & FlagArtificial) != 0; - } - bool isObjectPointer() const { - return (getFlags() & FlagObjectPointer) != 0; - } - bool isObjcClassComplete() const { - return (getFlags() & FlagObjcClassComplete) != 0; - } - bool isVector() const { - return (getFlags() & FlagVector) != 0; - } - bool isStaticMember() const { - return (getFlags() & FlagStaticMember) != 0; - } - bool isValid() const { - return DbgNode && isType(); - } - - /// isUnsignedDIType - Return true if type encoding is unsigned. - bool isUnsignedDIType(); - - /// replaceAllUsesWith - Replace all uses of debug info referenced by - /// this descriptor. - void replaceAllUsesWith(DIDescriptor &D); - void replaceAllUsesWith(MDNode *D); - }; - - /// DIBasicType - A basic type, like 'int' or 'float'. - class DIBasicType : public DIType { - public: - explicit DIBasicType(const MDNode *N = 0) : DIType(N) {} - - unsigned getEncoding() const { return getUnsignedField(9); } - - /// Verify - Verify that a basic type descriptor is well formed. - bool Verify() const; - }; - - /// DIDerivedType - A simple derived type, like a const qualified type, - /// a typedef, a pointer or reference, et cetera. Or, a data member of - /// a class/struct/union. - class DIDerivedType : public DIType { - friend class DIDescriptor; - void printInternal(raw_ostream &OS) const; - - public: - explicit DIDerivedType(const MDNode *N = 0) : DIType(N) {} - - DIType getTypeDerivedFrom() const { return getFieldAs(9); } - - /// getOriginalTypeSize - If this type is derived from a base type then - /// return base type size. - uint64_t getOriginalTypeSize() const; - - /// getObjCProperty - Return property node, if this ivar is - /// associated with one. - MDNode *getObjCProperty() const; - - DITypeRef getClassType() const { - assert(getTag() == dwarf::DW_TAG_ptr_to_member_type); - return getFieldAs(10); - } - - Constant *getConstant() const { - assert((getTag() == dwarf::DW_TAG_member) && isStaticMember()); - return getConstantField(10); - } - - /// Verify - Verify that a derived type descriptor is well formed. - bool Verify() const; - }; - - /// DICompositeType - This descriptor holds a type that can refer to multiple - /// other types, like a function or struct. - /// DICompositeType is derived from DIDerivedType because some - /// composite types (such as enums) can be derived from basic types - // FIXME: Make this derive from DIType directly & just store the - // base type in a single DIType field. - class DICompositeType : public DIDerivedType { - friend class DIDescriptor; - void printInternal(raw_ostream &OS) const; - public: - explicit DICompositeType(const MDNode *N = 0) : DIDerivedType(N) {} - - DIArray getTypeArray() const { return getFieldAs(10); } - void setTypeArray(DIArray Elements, DIArray TParams = DIArray()); - void addMember(DIDescriptor D); - unsigned getRunTimeLang() const { return getUnsignedField(11); } - DITypeRef getContainingType() const { - return getFieldAs(12); - } - void setContainingType(DICompositeType ContainingType); - DIArray getTemplateParams() const { return getFieldAs(13); } - MDString *getIdentifier() const; - - /// Verify - Verify that a composite type descriptor is well formed. - bool Verify() const; - }; - - /// DIFile - This is a wrapper for a file. - class DIFile : public DIScope { - friend class DIDescriptor; - public: - explicit DIFile(const MDNode *N = 0) : DIScope(N) {} - MDNode *getFileNode() const; - bool Verify() const; - }; - - /// DICompileUnit - A wrapper for a compile unit. - class DICompileUnit : public DIScope { - friend class DIDescriptor; - void printInternal(raw_ostream &OS) const; - public: - explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {} - - unsigned getLanguage() const { return getUnsignedField(2); } - StringRef getProducer() const { return getStringField(3); } - - bool isOptimized() const { return getUnsignedField(4) != 0; } - StringRef getFlags() const { return getStringField(5); } - unsigned getRunTimeVersion() const { return getUnsignedField(6); } - - DIArray getEnumTypes() const; - DIArray getRetainedTypes() const; - DIArray getSubprograms() const; - DIArray getGlobalVariables() const; - DIArray getImportedEntities() const; - - StringRef getSplitDebugFilename() const { return getStringField(12); } - - /// Verify - Verify that a compile unit is well formed. - bool Verify() const; - }; - - /// DISubprogram - This is a wrapper for a subprogram (e.g. a function). - class DISubprogram : public DIScope { - friend class DIDescriptor; - void printInternal(raw_ostream &OS) const; - public: - explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {} - - DIScope getContext() const { return getFieldAs(2); } - StringRef getName() const { return getStringField(3); } - StringRef getDisplayName() const { return getStringField(4); } - StringRef getLinkageName() const { return getStringField(5); } - unsigned getLineNumber() const { return getUnsignedField(6); } - DICompositeType getType() const { return getFieldAs(7); } - - /// isLocalToUnit - Return true if this subprogram is local to the current - /// compile unit, like 'static' in C. - unsigned isLocalToUnit() const { return getUnsignedField(8); } - unsigned isDefinition() const { return getUnsignedField(9); } - - unsigned getVirtuality() const { return getUnsignedField(10); } - unsigned getVirtualIndex() const { return getUnsignedField(11); } - - DITypeRef getContainingType() const { - return getFieldAs(12); - } - - unsigned getFlags() const { - return getUnsignedField(13); - } - - unsigned isArtificial() const { - return (getUnsignedField(13) & FlagArtificial) != 0; - } - /// isPrivate - Return true if this subprogram has "private" - /// access specifier. - bool isPrivate() const { - return (getUnsignedField(13) & FlagPrivate) != 0; - } - /// isProtected - Return true if this subprogram has "protected" - /// access specifier. - bool isProtected() const { - return (getUnsignedField(13) & FlagProtected) != 0; - } - /// isExplicit - Return true if this subprogram is marked as explicit. - bool isExplicit() const { - return (getUnsignedField(13) & FlagExplicit) != 0; - } - /// isPrototyped - Return true if this subprogram is prototyped. - bool isPrototyped() const { - return (getUnsignedField(13) & FlagPrototyped) != 0; - } - - unsigned isOptimized() const; - - /// Verify - Verify that a subprogram descriptor is well formed. - bool Verify() const; - - /// describes - Return true if this subprogram provides debugging - /// information for the function F. - bool describes(const Function *F); - - Function *getFunction() const { return getFunctionField(15); } - void replaceFunction(Function *F) { replaceFunctionField(15, F); } - DIArray getTemplateParams() const { return getFieldAs(16); } - DISubprogram getFunctionDeclaration() const { - return getFieldAs(17); - } - MDNode *getVariablesNodes() const; - DIArray getVariables() const; - - /// getScopeLineNumber - Get the beginning of the scope of the - /// function, not necessarily where the name of the program - /// starts. - unsigned getScopeLineNumber() const { return getUnsignedField(19); } - }; - - /// DILexicalBlock - This is a wrapper for a lexical block. - class DILexicalBlock : public DIScope { - public: - explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {} - DIScope getContext() const { return getFieldAs(2); } - unsigned getLineNumber() const { return getUnsignedField(3); } - unsigned getColumnNumber() const { return getUnsignedField(4); } - bool Verify() const; - }; - - /// DILexicalBlockFile - This is a wrapper for a lexical block with - /// a filename change. - class DILexicalBlockFile : public DIScope { - public: - explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {} - DIScope getContext() const { - if (getScope().isSubprogram()) - return getScope(); - return getScope().getContext(); - } - unsigned getLineNumber() const { return getScope().getLineNumber(); } - unsigned getColumnNumber() const { return getScope().getColumnNumber(); } - DILexicalBlock getScope() const { return getFieldAs(2); } - bool Verify() const; - }; - - /// DINameSpace - A wrapper for a C++ style name space. - class DINameSpace : public DIScope { - friend class DIDescriptor; - void printInternal(raw_ostream &OS) const; - public: - explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {} - DIScope getContext() const { return getFieldAs(2); } - StringRef getName() const { return getStringField(3); } - unsigned getLineNumber() const { return getUnsignedField(4); } - bool Verify() const; - }; - - /// DITemplateTypeParameter - This is a wrapper for template type parameter. - class DITemplateTypeParameter : public DIDescriptor { - public: - explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {} - - DIScope getContext() const { return getFieldAs(1); } - StringRef getName() const { return getStringField(2); } - DIType getType() const { return getFieldAs(3); } - StringRef getFilename() const { - return getFieldAs(4).getFilename(); - } - StringRef getDirectory() const { - return getFieldAs(4).getDirectory(); - } - unsigned getLineNumber() const { return getUnsignedField(5); } - unsigned getColumnNumber() const { return getUnsignedField(6); } - bool Verify() const; - }; - - /// DITemplateValueParameter - This is a wrapper for template value parameter. - class DITemplateValueParameter : public DIDescriptor { - public: - explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {} - - DIScope getContext() const { return getFieldAs(1); } - StringRef getName() const { return getStringField(2); } - DIType getType() const { return getFieldAs(3); } - Value *getValue() const; - StringRef getFilename() const { - return getFieldAs(5).getFilename(); - } - StringRef getDirectory() const { - return getFieldAs(5).getDirectory(); - } - unsigned getLineNumber() const { return getUnsignedField(6); } - unsigned getColumnNumber() const { return getUnsignedField(7); } - bool Verify() const; - }; - - /// DIGlobalVariable - This is a wrapper for a global variable. - class DIGlobalVariable : public DIDescriptor { - friend class DIDescriptor; - void printInternal(raw_ostream &OS) const; - public: - explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {} - - DIScope getContext() const { return getFieldAs(2); } - StringRef getName() const { return getStringField(3); } - StringRef getDisplayName() const { return getStringField(4); } - StringRef getLinkageName() const { return getStringField(5); } - StringRef getFilename() const { - return getFieldAs(6).getFilename(); - } - StringRef getDirectory() const { - return getFieldAs(6).getDirectory(); - - } - - unsigned getLineNumber() const { return getUnsignedField(7); } - DIType getType() const { return getFieldAs(8); } - unsigned isLocalToUnit() const { return getUnsignedField(9); } - unsigned isDefinition() const { return getUnsignedField(10); } - - GlobalVariable *getGlobal() const { return getGlobalVariableField(11); } - Constant *getConstant() const { return getConstantField(11); } - DIDerivedType getStaticDataMemberDeclaration() const { - return getFieldAs(12); - } - - /// Verify - Verify that a global variable descriptor is well formed. - bool Verify() const; - }; - - /// DIVariable - This is a wrapper for a variable (e.g. parameter, local, - /// global etc). - class DIVariable : public DIDescriptor { - friend class DIDescriptor; - void printInternal(raw_ostream &OS) const; - public: - explicit DIVariable(const MDNode *N = 0) : DIDescriptor(N) {} - - DIScope getContext() const { return getFieldAs(1); } - StringRef getName() const { return getStringField(2); } - DIFile getFile() const { return getFieldAs(3); } - unsigned getLineNumber() const { - return (getUnsignedField(4) << 8) >> 8; - } - unsigned getArgNumber() const { - unsigned L = getUnsignedField(4); - return L >> 24; - } - DIType getType() const { return getFieldAs(5); } - - /// isArtificial - Return true if this variable is marked as "artificial". - bool isArtificial() const { - return (getUnsignedField(6) & FlagArtificial) != 0; - } - - bool isObjectPointer() const { - return (getUnsignedField(6) & FlagObjectPointer) != 0; - } - - /// \brief Return true if this variable is represented as a pointer. - bool isIndirect() const { - return (getUnsignedField(6) & FlagIndirectVariable) != 0; - } - - /// getInlinedAt - If this variable is inlined then return inline location. - MDNode *getInlinedAt() const; - - /// Verify - Verify that a variable descriptor is well formed. - bool Verify() const; - - /// HasComplexAddr - Return true if the variable has a complex address. - bool hasComplexAddress() const { - return getNumAddrElements() > 0; - } - - unsigned getNumAddrElements() const; - - uint64_t getAddrElement(unsigned Idx) const { - return getUInt64Field(Idx+8); - } - - /// isBlockByrefVariable - Return true if the variable was declared as - /// a "__block" variable (Apple Blocks). - bool isBlockByrefVariable() const { - return getType().isBlockByrefStruct(); - } - - /// isInlinedFnArgument - Return true if this variable provides debugging - /// information for an inlined function arguments. - bool isInlinedFnArgument(const Function *CurFn); - - void printExtendedName(raw_ostream &OS) const; - }; - - /// DILocation - This object holds location information. This object - /// is not associated with any DWARF tag. - class DILocation : public DIDescriptor { - public: - explicit DILocation(const MDNode *N) : DIDescriptor(N) { } - - unsigned getLineNumber() const { return getUnsignedField(0); } - unsigned getColumnNumber() const { return getUnsignedField(1); } - DIScope getScope() const { return getFieldAs(2); } - DILocation getOrigLocation() const { return getFieldAs(3); } - StringRef getFilename() const { return getScope().getFilename(); } - StringRef getDirectory() const { return getScope().getDirectory(); } - bool Verify() const; - }; - - class DIObjCProperty : public DIDescriptor { - friend class DIDescriptor; - void printInternal(raw_ostream &OS) const; - public: - explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) { } - - StringRef getObjCPropertyName() const { return getStringField(1); } - DIFile getFile() const { return getFieldAs(2); } - unsigned getLineNumber() const { return getUnsignedField(3); } - - StringRef getObjCPropertyGetterName() const { - return getStringField(4); - } - StringRef getObjCPropertySetterName() const { - return getStringField(5); - } - bool isReadOnlyObjCProperty() const { - return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readonly) != 0; - } - bool isReadWriteObjCProperty() const { - return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0; - } - bool isAssignObjCProperty() const { - return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_assign) != 0; - } - bool isRetainObjCProperty() const { - return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_retain) != 0; - } - bool isCopyObjCProperty() const { - return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_copy) != 0; - } - bool isNonAtomicObjCProperty() const { - return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0; - } - - DIType getType() const { return getFieldAs(7); } - - /// Verify - Verify that a derived type descriptor is well formed. - bool Verify() const; - }; - - /// \brief An imported module (C++ using directive or similar). - class DIImportedEntity : public DIDescriptor { - friend class DIDescriptor; - void printInternal(raw_ostream &OS) const; - public: - explicit DIImportedEntity(const MDNode *N) : DIDescriptor(N) { } - DIScope getContext() const { return getFieldAs(1); } - DIDescriptor getEntity() const { return getFieldAs(2); } - unsigned getLineNumber() const { return getUnsignedField(3); } - StringRef getName() const { return getStringField(4); } - bool Verify() const; - }; - - /// getDISubprogram - Find subprogram that is enclosing this scope. - DISubprogram getDISubprogram(const MDNode *Scope); - - /// getDICompositeType - Find underlying composite type. - DICompositeType getDICompositeType(DIType T); - - /// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable - /// to hold function specific information. - NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP); - - /// getFnSpecificMDNode - Return a NameMDNode, if available, that is - /// suitable to hold function specific information. - NamedMDNode *getFnSpecificMDNode(const Module &M, DISubprogram SP); - - /// createInlinedVariable - Create a new inlined variable based on current - /// variable. - /// @param DV Current Variable. - /// @param InlinedScope Location at current variable is inlined. - DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope, - LLVMContext &VMContext); - - /// cleanseInlinedVariable - Remove inlined scope from the variable. - DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext); - - /// Construct DITypeIdentifierMap by going through retained types of each CU. - DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes); - - /// DebugInfoFinder tries to list all debug info MDNodes used in a module. To - /// list debug info MDNodes used by an instruction, DebugInfoFinder uses - /// processDeclare, processValue and processLocation to handle DbgDeclareInst, - /// DbgValueInst and DbgLoc attached to instructions. processModule will go - /// through all DICompileUnits in llvm.dbg.cu and list debug info MDNodes - /// used by the CUs. - class DebugInfoFinder { - public: - /// processModule - Process entire module and collect debug info - /// anchors. - void processModule(const Module &M); - - /// processDeclare - Process DbgDeclareInst. - void processDeclare(const DbgDeclareInst *DDI); - /// Process DbgValueInst. - void processValue(const DbgValueInst *DVI); - /// processLocation - Process DILocation. - void processLocation(DILocation Loc); - - /// Clear all lists. - void reset(); - private: - /// processType - Process DIType. - void processType(DIType DT); - - /// processLexicalBlock - Process DILexicalBlock. - void processLexicalBlock(DILexicalBlock LB); - - /// processSubprogram - Process DISubprogram. - void processSubprogram(DISubprogram SP); - - void processScope(DIScope Scope); - - /// addCompileUnit - Add compile unit into CUs. - bool addCompileUnit(DICompileUnit CU); - - /// addGlobalVariable - Add global variable into GVs. - bool addGlobalVariable(DIGlobalVariable DIG); - - // addSubprogram - Add subprogram into SPs. - bool addSubprogram(DISubprogram SP); - - /// addType - Add type into Tys. - bool addType(DIType DT); - - bool addScope(DIScope Scope); - - public: - typedef SmallVectorImpl::const_iterator iterator; - iterator compile_unit_begin() const { return CUs.begin(); } - iterator compile_unit_end() const { return CUs.end(); } - iterator subprogram_begin() const { return SPs.begin(); } - iterator subprogram_end() const { return SPs.end(); } - iterator global_variable_begin() const { return GVs.begin(); } - iterator global_variable_end() const { return GVs.end(); } - iterator type_begin() const { return TYs.begin(); } - iterator type_end() const { return TYs.end(); } - iterator scope_begin() const { return Scopes.begin(); } - iterator scope_end() const { return Scopes.end(); } - - unsigned compile_unit_count() const { return CUs.size(); } - unsigned global_variable_count() const { return GVs.size(); } - unsigned subprogram_count() const { return SPs.size(); } - unsigned type_count() const { return TYs.size(); } - unsigned scope_count() const { return Scopes.size(); } - - private: - SmallVector CUs; // Compile Units - SmallVector SPs; // Subprograms - SmallVector GVs; // Global Variables; - SmallVector TYs; // Types - SmallVector Scopes; // Scopes - SmallPtrSet NodesSeen; - DITypeIdentifierMap TypeIdentifierMap; - }; +protected: + const MDNode *DbgNode; + + StringRef getStringField(unsigned Elt) const; + unsigned getUnsignedField(unsigned Elt) const { + return (unsigned)getUInt64Field(Elt); + } + uint64_t getUInt64Field(unsigned Elt) const; + int64_t getInt64Field(unsigned Elt) const; + DIDescriptor getDescriptorField(unsigned Elt) const; + + template DescTy getFieldAs(unsigned Elt) const { + return DescTy(getDescriptorField(Elt)); + } + + GlobalVariable *getGlobalVariableField(unsigned Elt) const; + Constant *getConstantField(unsigned Elt) const; + Function *getFunctionField(unsigned Elt) const; + void replaceFunctionField(unsigned Elt, Function *F); + +public: + explicit DIDescriptor(const MDNode *N = 0) : DbgNode(N) {} + + bool Verify() const; + + operator MDNode *() const { return const_cast(DbgNode); } + MDNode *operator->() const { return const_cast(DbgNode); } + + // An explicit operator bool so that we can do testing of DI values + // easily. + // FIXME: This operator bool isn't actually protecting anything at the + // moment due to the conversion operator above making DIDescriptor nodes + // implicitly convertable to bool. + LLVM_EXPLICIT operator bool() const { return DbgNode != 0; } + + bool operator==(DIDescriptor Other) const { return DbgNode == Other.DbgNode; } + bool operator!=(DIDescriptor Other) const { return !operator==(Other); } + + uint16_t getTag() const { + return getUnsignedField(0) & ~LLVMDebugVersionMask; + } + + bool isDerivedType() const; + bool isCompositeType() const; + bool isBasicType() const; + bool isVariable() const; + bool isSubprogram() const; + bool isGlobalVariable() const; + bool isScope() const; + bool isFile() const; + bool isCompileUnit() const; + bool isNameSpace() const; + bool isLexicalBlockFile() const; + bool isLexicalBlock() const; + bool isSubrange() const; + bool isEnumerator() const; + bool isType() const; + bool isUnspecifiedParameter() const; + bool isTemplateTypeParameter() const; + bool isTemplateValueParameter() const; + bool isObjCProperty() const; + bool isImportedEntity() const; + + /// print - print descriptor. + void print(raw_ostream &OS) const; + + /// dump - print descriptor to dbgs() with a newline. + void dump() const; +}; + +/// DISubrange - This is used to represent ranges, for array bounds. +class DISubrange : public DIDescriptor { + friend class DIDescriptor; + void printInternal(raw_ostream &OS) const; + +public: + explicit DISubrange(const MDNode *N = 0) : DIDescriptor(N) {} + + int64_t getLo() const { return getInt64Field(1); } + int64_t getCount() const { return getInt64Field(2); } + bool Verify() const; +}; + +/// DIArray - This descriptor holds an array of descriptors. +class DIArray : public DIDescriptor { +public: + explicit DIArray(const MDNode *N = 0) : DIDescriptor(N) {} + + unsigned getNumElements() const; + DIDescriptor getElement(unsigned Idx) const { + return getDescriptorField(Idx); + } +}; + +/// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}'). +/// FIXME: it seems strange that this doesn't have either a reference to the +/// type/precision or a file/line pair for location info. +class DIEnumerator : public DIDescriptor { + friend class DIDescriptor; + void printInternal(raw_ostream &OS) const; + +public: + explicit DIEnumerator(const MDNode *N = 0) : DIDescriptor(N) {} + + StringRef getName() const { return getStringField(1); } + int64_t getEnumValue() const { return getInt64Field(2); } + bool Verify() const; +}; + +template class DIRef; +typedef DIRef DIScopeRef; +typedef DIRef DITypeRef; + +/// DIScope - A base class for various scopes. +class DIScope : public DIDescriptor { +protected: + friend class DIDescriptor; + void printInternal(raw_ostream &OS) const; + +public: + explicit DIScope(const MDNode *N = 0) : DIDescriptor(N) {} + + /// Gets the parent scope for this scope node or returns a + /// default constructed scope. + DIScopeRef getContext() const; + StringRef getFilename() const; + StringRef getDirectory() const; + + /// Generate a reference to this DIScope. Uses the type identifier instead + /// of the actual MDNode if possible, to help type uniquing. + DIScopeRef getRef() const; +}; + +/// Represents reference to a DIDescriptor, abstracts over direct and +/// identifier-based metadata references. +template class DIRef { + template + friend DescTy DIDescriptor::getFieldAs(unsigned Elt) const; + friend DIScopeRef DIScope::getContext() const; + friend DIScopeRef DIScope::getRef() const; + + /// Val can be either a MDNode or a MDString, in the latter, + /// MDString specifies the type identifier. + const Value *Val; + explicit DIRef(const Value *V); + +public: + T resolve(const DITypeIdentifierMap &Map) const { + if (!Val) + return T(); + + if (const MDNode *MD = dyn_cast(Val)) + return T(MD); + + const MDString *MS = cast(Val); + // Find the corresponding MDNode. + DITypeIdentifierMap::const_iterator Iter = Map.find(MS); + assert(Iter != Map.end() && "Identifier not in the type map?"); + assert(DIDescriptor(Iter->second).isType() && + "MDNode in DITypeIdentifierMap should be a DIType."); + return T(Iter->second); + } + operator Value *() const { return const_cast(Val); } +}; + +/// Specialize getFieldAs to handle fields that are references to DIScopes. +template <> DIScopeRef DIDescriptor::getFieldAs(unsigned Elt) const; +/// Specialize DIRef constructor for DIScopeRef. +template <> DIRef::DIRef(const Value *V); + +/// Specialize getFieldAs to handle fields that are references to DITypes. +template <> DITypeRef DIDescriptor::getFieldAs(unsigned Elt) const; +/// Specialize DIRef constructor for DITypeRef. +template <> DIRef::DIRef(const Value *V); + +/// DIType - This is a wrapper for a type. +/// FIXME: Types should be factored much better so that CV qualifiers and +/// others do not require a huge and empty descriptor full of zeros. +class DIType : public DIScope { +protected: + friend class DIDescriptor; + void printInternal(raw_ostream &OS) const; + +public: + DIType(const MDNode *N = 0) : DIScope(N) {} + + /// Verify - Verify that a type descriptor is well formed. + bool Verify() const; + + DIScopeRef getContext() const { return getFieldAs(2); } + StringRef getName() const { return getStringField(3); } + unsigned getLineNumber() const { return getUnsignedField(4); } + uint64_t getSizeInBits() const { return getUInt64Field(5); } + uint64_t getAlignInBits() const { return getUInt64Field(6); } + // FIXME: Offset is only used for DW_TAG_member nodes. Making every type + // carry this is just plain insane. + uint64_t getOffsetInBits() const { return getUInt64Field(7); } + unsigned getFlags() const { return getUnsignedField(8); } + bool isPrivate() const { return (getFlags() & FlagPrivate) != 0; } + bool isProtected() const { return (getFlags() & FlagProtected) != 0; } + bool isForwardDecl() const { return (getFlags() & FlagFwdDecl) != 0; } + // isAppleBlock - Return true if this is the Apple Blocks extension. + bool isAppleBlockExtension() const { + return (getFlags() & FlagAppleBlock) != 0; + } + bool isBlockByrefStruct() const { + return (getFlags() & FlagBlockByrefStruct) != 0; + } + bool isVirtual() const { return (getFlags() & FlagVirtual) != 0; } + bool isArtificial() const { return (getFlags() & FlagArtificial) != 0; } + bool isObjectPointer() const { return (getFlags() & FlagObjectPointer) != 0; } + bool isObjcClassComplete() const { + return (getFlags() & FlagObjcClassComplete) != 0; + } + bool isVector() const { return (getFlags() & FlagVector) != 0; } + bool isStaticMember() const { return (getFlags() & FlagStaticMember) != 0; } + bool isValid() const { return DbgNode && isType(); } + + /// isUnsignedDIType - Return true if type encoding is unsigned. + bool isUnsignedDIType(); + + /// replaceAllUsesWith - Replace all uses of debug info referenced by + /// this descriptor. + void replaceAllUsesWith(DIDescriptor &D); + void replaceAllUsesWith(MDNode *D); +}; + +/// DIBasicType - A basic type, like 'int' or 'float'. +class DIBasicType : public DIType { +public: + explicit DIBasicType(const MDNode *N = 0) : DIType(N) {} + + unsigned getEncoding() const { return getUnsignedField(9); } + + /// Verify - Verify that a basic type descriptor is well formed. + bool Verify() const; +}; + +/// DIDerivedType - A simple derived type, like a const qualified type, +/// a typedef, a pointer or reference, et cetera. Or, a data member of +/// a class/struct/union. +class DIDerivedType : public DIType { + friend class DIDescriptor; + void printInternal(raw_ostream &OS) const; + +public: + explicit DIDerivedType(const MDNode *N = 0) : DIType(N) {} + + DIType getTypeDerivedFrom() const { return getFieldAs(9); } + + /// getOriginalTypeSize - If this type is derived from a base type then + /// return base type size. + uint64_t getOriginalTypeSize() const; + + /// getObjCProperty - Return property node, if this ivar is + /// associated with one. + MDNode *getObjCProperty() const; + + DITypeRef getClassType() const { + assert(getTag() == dwarf::DW_TAG_ptr_to_member_type); + return getFieldAs(10); + } + + Constant *getConstant() const { + assert((getTag() == dwarf::DW_TAG_member) && isStaticMember()); + return getConstantField(10); + } + + /// Verify - Verify that a derived type descriptor is well formed. + bool Verify() const; +}; + +/// DICompositeType - This descriptor holds a type that can refer to multiple +/// other types, like a function or struct. +/// DICompositeType is derived from DIDerivedType because some +/// composite types (such as enums) can be derived from basic types +// FIXME: Make this derive from DIType directly & just store the +// base type in a single DIType field. +class DICompositeType : public DIDerivedType { + friend class DIDescriptor; + void printInternal(raw_ostream &OS) const; + +public: + explicit DICompositeType(const MDNode *N = 0) : DIDerivedType(N) {} + + DIArray getTypeArray() const { return getFieldAs(10); } + void setTypeArray(DIArray Elements, DIArray TParams = DIArray()); + void addMember(DIDescriptor D); + unsigned getRunTimeLang() const { return getUnsignedField(11); } + DITypeRef getContainingType() const { return getFieldAs(12); } + void setContainingType(DICompositeType ContainingType); + DIArray getTemplateParams() const { return getFieldAs(13); } + MDString *getIdentifier() const; + + /// Verify - Verify that a composite type descriptor is well formed. + bool Verify() const; +}; + +/// DIFile - This is a wrapper for a file. +class DIFile : public DIScope { + friend class DIDescriptor; + +public: + explicit DIFile(const MDNode *N = 0) : DIScope(N) {} + MDNode *getFileNode() const; + bool Verify() const; +}; + +/// DICompileUnit - A wrapper for a compile unit. +class DICompileUnit : public DIScope { + friend class DIDescriptor; + void printInternal(raw_ostream &OS) const; + +public: + explicit DICompileUnit(const MDNode *N = 0) : DIScope(N) {} + + unsigned getLanguage() const { return getUnsignedField(2); } + StringRef getProducer() const { return getStringField(3); } + + bool isOptimized() const { return getUnsignedField(4) != 0; } + StringRef getFlags() const { return getStringField(5); } + unsigned getRunTimeVersion() const { return getUnsignedField(6); } + + DIArray getEnumTypes() const; + DIArray getRetainedTypes() const; + DIArray getSubprograms() const; + DIArray getGlobalVariables() const; + DIArray getImportedEntities() const; + + StringRef getSplitDebugFilename() const { return getStringField(12); } + + /// Verify - Verify that a compile unit is well formed. + bool Verify() const; +}; + +/// DISubprogram - This is a wrapper for a subprogram (e.g. a function). +class DISubprogram : public DIScope { + friend class DIDescriptor; + void printInternal(raw_ostream &OS) const; + +public: + explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {} + + DIScope getContext() const { return getFieldAs(2); } + StringRef getName() const { return getStringField(3); } + StringRef getDisplayName() const { return getStringField(4); } + StringRef getLinkageName() const { return getStringField(5); } + unsigned getLineNumber() const { return getUnsignedField(6); } + DICompositeType getType() const { return getFieldAs(7); } + + /// isLocalToUnit - Return true if this subprogram is local to the current + /// compile unit, like 'static' in C. + unsigned isLocalToUnit() const { return getUnsignedField(8); } + unsigned isDefinition() const { return getUnsignedField(9); } + + unsigned getVirtuality() const { return getUnsignedField(10); } + unsigned getVirtualIndex() const { return getUnsignedField(11); } + + DITypeRef getContainingType() const { return getFieldAs(12); } + + unsigned getFlags() const { return getUnsignedField(13); } + + unsigned isArtificial() const { + return (getUnsignedField(13) & FlagArtificial) != 0; + } + /// isPrivate - Return true if this subprogram has "private" + /// access specifier. + bool isPrivate() const { return (getUnsignedField(13) & FlagPrivate) != 0; } + /// isProtected - Return true if this subprogram has "protected" + /// access specifier. + bool isProtected() const { + return (getUnsignedField(13) & FlagProtected) != 0; + } + /// isExplicit - Return true if this subprogram is marked as explicit. + bool isExplicit() const { return (getUnsignedField(13) & FlagExplicit) != 0; } + /// isPrototyped - Return true if this subprogram is prototyped. + bool isPrototyped() const { + return (getUnsignedField(13) & FlagPrototyped) != 0; + } + + unsigned isOptimized() const; + + /// Verify - Verify that a subprogram descriptor is well formed. + bool Verify() const; + + /// describes - Return true if this subprogram provides debugging + /// information for the function F. + bool describes(const Function *F); + + Function *getFunction() const { return getFunctionField(15); } + void replaceFunction(Function *F) { replaceFunctionField(15, F); } + DIArray getTemplateParams() const { return getFieldAs(16); } + DISubprogram getFunctionDeclaration() const { + return getFieldAs(17); + } + MDNode *getVariablesNodes() const; + DIArray getVariables() const; + + /// getScopeLineNumber - Get the beginning of the scope of the + /// function, not necessarily where the name of the program + /// starts. + unsigned getScopeLineNumber() const { return getUnsignedField(19); } +}; + +/// DILexicalBlock - This is a wrapper for a lexical block. +class DILexicalBlock : public DIScope { +public: + explicit DILexicalBlock(const MDNode *N = 0) : DIScope(N) {} + DIScope getContext() const { return getFieldAs(2); } + unsigned getLineNumber() const { return getUnsignedField(3); } + unsigned getColumnNumber() const { return getUnsignedField(4); } + bool Verify() const; +}; + +/// DILexicalBlockFile - This is a wrapper for a lexical block with +/// a filename change. +class DILexicalBlockFile : public DIScope { +public: + explicit DILexicalBlockFile(const MDNode *N = 0) : DIScope(N) {} + DIScope getContext() const { + if (getScope().isSubprogram()) + return getScope(); + return getScope().getContext(); + } + unsigned getLineNumber() const { return getScope().getLineNumber(); } + unsigned getColumnNumber() const { return getScope().getColumnNumber(); } + DILexicalBlock getScope() const { return getFieldAs(2); } + bool Verify() const; +}; + +/// DINameSpace - A wrapper for a C++ style name space. +class DINameSpace : public DIScope { + friend class DIDescriptor; + void printInternal(raw_ostream &OS) const; + +public: + explicit DINameSpace(const MDNode *N = 0) : DIScope(N) {} + DIScope getContext() const { return getFieldAs(2); } + StringRef getName() const { return getStringField(3); } + unsigned getLineNumber() const { return getUnsignedField(4); } + bool Verify() const; +}; + +/// DITemplateTypeParameter - This is a wrapper for template type parameter. +class DITemplateTypeParameter : public DIDescriptor { +public: + explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {} + + DIScope getContext() const { return getFieldAs(1); } + StringRef getName() const { return getStringField(2); } + DIType getType() const { return getFieldAs(3); } + StringRef getFilename() const { return getFieldAs(4).getFilename(); } + StringRef getDirectory() const { + return getFieldAs(4).getDirectory(); + } + unsigned getLineNumber() const { return getUnsignedField(5); } + unsigned getColumnNumber() const { return getUnsignedField(6); } + bool Verify() const; +}; + +/// DITemplateValueParameter - This is a wrapper for template value parameter. +class DITemplateValueParameter : public DIDescriptor { +public: + explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {} + + DIScope getContext() const { return getFieldAs(1); } + StringRef getName() const { return getStringField(2); } + DIType getType() const { return getFieldAs(3); } + Value *getValue() const; + StringRef getFilename() const { return getFieldAs(5).getFilename(); } + StringRef getDirectory() const { + return getFieldAs(5).getDirectory(); + } + unsigned getLineNumber() const { return getUnsignedField(6); } + unsigned getColumnNumber() const { return getUnsignedField(7); } + bool Verify() const; +}; + +/// DIGlobalVariable - This is a wrapper for a global variable. +class DIGlobalVariable : public DIDescriptor { + friend class DIDescriptor; + void printInternal(raw_ostream &OS) const; + +public: + explicit DIGlobalVariable(const MDNode *N = 0) : DIDescriptor(N) {} + + DIScope getContext() const { return getFieldAs(2); } + StringRef getName() const { return getStringField(3); } + StringRef getDisplayName() const { return getStringField(4); } + StringRef getLinkageName() const { return getStringField(5); } + StringRef getFilename() const { return getFieldAs(6).getFilename(); } + StringRef getDirectory() const { + return getFieldAs(6).getDirectory(); + } + + unsigned getLineNumber() const { return getUnsignedField(7); } + DIType getType() const { return getFieldAs(8); } + unsigned isLocalToUnit() const { return getUnsignedField(9); } + unsigned isDefinition() const { return getUnsignedField(10); } + + GlobalVariable *getGlobal() const { return getGlobalVariableField(11); } + Constant *getConstant() const { return getConstantField(11); } + DIDerivedType getStaticDataMemberDeclaration() const { + return getFieldAs(12); + } + + /// Verify - Verify that a global variable descriptor is well formed. + bool Verify() const; +}; + +/// DIVariable - This is a wrapper for a variable (e.g. parameter, local, +/// global etc). +class DIVariable : public DIDescriptor { + friend class DIDescriptor; + void printInternal(raw_ostream &OS) const; + +public: + explicit DIVariable(const MDNode *N = 0) : DIDescriptor(N) {} + + DIScope getContext() const { return getFieldAs(1); } + StringRef getName() const { return getStringField(2); } + DIFile getFile() const { return getFieldAs(3); } + unsigned getLineNumber() const { return (getUnsignedField(4) << 8) >> 8; } + unsigned getArgNumber() const { + unsigned L = getUnsignedField(4); + return L >> 24; + } + DIType getType() const { return getFieldAs(5); } + + /// isArtificial - Return true if this variable is marked as "artificial". + bool isArtificial() const { + return (getUnsignedField(6) & FlagArtificial) != 0; + } + + bool isObjectPointer() const { + return (getUnsignedField(6) & FlagObjectPointer) != 0; + } + + /// \brief Return true if this variable is represented as a pointer. + bool isIndirect() const { + return (getUnsignedField(6) & FlagIndirectVariable) != 0; + } + + /// getInlinedAt - If this variable is inlined then return inline location. + MDNode *getInlinedAt() const; + + /// Verify - Verify that a variable descriptor is well formed. + bool Verify() const; + + /// HasComplexAddr - Return true if the variable has a complex address. + bool hasComplexAddress() const { return getNumAddrElements() > 0; } + + unsigned getNumAddrElements() const; + + uint64_t getAddrElement(unsigned Idx) const { + return getUInt64Field(Idx + 8); + } + + /// isBlockByrefVariable - Return true if the variable was declared as + /// a "__block" variable (Apple Blocks). + bool isBlockByrefVariable() const { return getType().isBlockByrefStruct(); } + + /// isInlinedFnArgument - Return true if this variable provides debugging + /// information for an inlined function arguments. + bool isInlinedFnArgument(const Function *CurFn); + + void printExtendedName(raw_ostream &OS) const; +}; + +/// DILocation - This object holds location information. This object +/// is not associated with any DWARF tag. +class DILocation : public DIDescriptor { +public: + explicit DILocation(const MDNode *N) : DIDescriptor(N) {} + + unsigned getLineNumber() const { return getUnsignedField(0); } + unsigned getColumnNumber() const { return getUnsignedField(1); } + DIScope getScope() const { return getFieldAs(2); } + DILocation getOrigLocation() const { return getFieldAs(3); } + StringRef getFilename() const { return getScope().getFilename(); } + StringRef getDirectory() const { return getScope().getDirectory(); } + bool Verify() const; +}; + +class DIObjCProperty : public DIDescriptor { + friend class DIDescriptor; + void printInternal(raw_ostream &OS) const; + +public: + explicit DIObjCProperty(const MDNode *N) : DIDescriptor(N) {} + + StringRef getObjCPropertyName() const { return getStringField(1); } + DIFile getFile() const { return getFieldAs(2); } + unsigned getLineNumber() const { return getUnsignedField(3); } + + StringRef getObjCPropertyGetterName() const { return getStringField(4); } + StringRef getObjCPropertySetterName() const { return getStringField(5); } + bool isReadOnlyObjCProperty() const { + return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readonly) != 0; + } + bool isReadWriteObjCProperty() const { + return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_readwrite) != 0; + } + bool isAssignObjCProperty() const { + return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_assign) != 0; + } + bool isRetainObjCProperty() const { + return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_retain) != 0; + } + bool isCopyObjCProperty() const { + return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_copy) != 0; + } + bool isNonAtomicObjCProperty() const { + return (getUnsignedField(6) & dwarf::DW_APPLE_PROPERTY_nonatomic) != 0; + } + + DIType getType() const { return getFieldAs(7); } + + /// Verify - Verify that a derived type descriptor is well formed. + bool Verify() const; +}; + +/// \brief An imported module (C++ using directive or similar). +class DIImportedEntity : public DIDescriptor { + friend class DIDescriptor; + void printInternal(raw_ostream &OS) const; + +public: + explicit DIImportedEntity(const MDNode *N) : DIDescriptor(N) {} + DIScope getContext() const { return getFieldAs(1); } + DIDescriptor getEntity() const { return getFieldAs(2); } + unsigned getLineNumber() const { return getUnsignedField(3); } + StringRef getName() const { return getStringField(4); } + bool Verify() const; +}; + +/// getDISubprogram - Find subprogram that is enclosing this scope. +DISubprogram getDISubprogram(const MDNode *Scope); + +/// getDICompositeType - Find underlying composite type. +DICompositeType getDICompositeType(DIType T); + +/// getOrInsertFnSpecificMDNode - Return a NameMDNode that is suitable +/// to hold function specific information. +NamedMDNode *getOrInsertFnSpecificMDNode(Module &M, DISubprogram SP); + +/// getFnSpecificMDNode - Return a NameMDNode, if available, that is +/// suitable to hold function specific information. +NamedMDNode *getFnSpecificMDNode(const Module &M, DISubprogram SP); + +/// createInlinedVariable - Create a new inlined variable based on current +/// variable. +/// @param DV Current Variable. +/// @param InlinedScope Location at current variable is inlined. +DIVariable createInlinedVariable(MDNode *DV, MDNode *InlinedScope, + LLVMContext &VMContext); + +/// cleanseInlinedVariable - Remove inlined scope from the variable. +DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext); + +/// Construct DITypeIdentifierMap by going through retained types of each CU. +DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes); + +/// DebugInfoFinder tries to list all debug info MDNodes used in a module. To +/// list debug info MDNodes used by an instruction, DebugInfoFinder uses +/// processDeclare, processValue and processLocation to handle DbgDeclareInst, +/// DbgValueInst and DbgLoc attached to instructions. processModule will go +/// through all DICompileUnits in llvm.dbg.cu and list debug info MDNodes +/// used by the CUs. +class DebugInfoFinder { +public: + /// processModule - Process entire module and collect debug info + /// anchors. + void processModule(const Module &M); + + /// processDeclare - Process DbgDeclareInst. + void processDeclare(const DbgDeclareInst *DDI); + /// Process DbgValueInst. + void processValue(const DbgValueInst *DVI); + /// processLocation - Process DILocation. + void processLocation(DILocation Loc); + + /// Clear all lists. + void reset(); + +private: + /// processType - Process DIType. + void processType(DIType DT); + + /// processLexicalBlock - Process DILexicalBlock. + void processLexicalBlock(DILexicalBlock LB); + + /// processSubprogram - Process DISubprogram. + void processSubprogram(DISubprogram SP); + + void processScope(DIScope Scope); + + /// addCompileUnit - Add compile unit into CUs. + bool addCompileUnit(DICompileUnit CU); + + /// addGlobalVariable - Add global variable into GVs. + bool addGlobalVariable(DIGlobalVariable DIG); + + // addSubprogram - Add subprogram into SPs. + bool addSubprogram(DISubprogram SP); + + /// addType - Add type into Tys. + bool addType(DIType DT); + + bool addScope(DIScope Scope); + +public: + typedef SmallVectorImpl::const_iterator iterator; + iterator compile_unit_begin() const { return CUs.begin(); } + iterator compile_unit_end() const { return CUs.end(); } + iterator subprogram_begin() const { return SPs.begin(); } + iterator subprogram_end() const { return SPs.end(); } + iterator global_variable_begin() const { return GVs.begin(); } + iterator global_variable_end() const { return GVs.end(); } + iterator type_begin() const { return TYs.begin(); } + iterator type_end() const { return TYs.end(); } + iterator scope_begin() const { return Scopes.begin(); } + iterator scope_end() const { return Scopes.end(); } + + unsigned compile_unit_count() const { return CUs.size(); } + unsigned global_variable_count() const { return GVs.size(); } + unsigned subprogram_count() const { return SPs.size(); } + unsigned type_count() const { return TYs.size(); } + unsigned scope_count() const { return Scopes.size(); } + +private: + SmallVector CUs; // Compile Units + SmallVector SPs; // Subprograms + SmallVector GVs; // Global Variables; + SmallVector TYs; // Types + SmallVector Scopes; // Scopes + SmallPtrSet NodesSeen; + DITypeIdentifierMap TypeIdentifierMap; +}; } // end namespace llvm #endif -- cgit v1.1 From 164793918c325b25425f962fc9540a1e1cd9224b Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Fri, 4 Oct 2013 23:35:30 +0000 Subject: Pull this out for a bit of readability. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191999 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 8486b10..ad01494 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -226,24 +226,27 @@ template class DIRef { explicit DIRef(const Value *V); public: - T resolve(const DITypeIdentifierMap &Map) const { - if (!Val) - return T(); - - if (const MDNode *MD = dyn_cast(Val)) - return T(MD); - - const MDString *MS = cast(Val); - // Find the corresponding MDNode. - DITypeIdentifierMap::const_iterator Iter = Map.find(MS); - assert(Iter != Map.end() && "Identifier not in the type map?"); - assert(DIDescriptor(Iter->second).isType() && - "MDNode in DITypeIdentifierMap should be a DIType."); - return T(Iter->second); - } + T resolve(const DITypeIdentifierMap &Map) const; operator Value *() const { return const_cast(Val); } }; +template +T DIRef::resolve(const DITypeIdentifierMap &Map) const { + if (!Val) + return T(); + + if (const MDNode *MD = dyn_cast(Val)) + return T(MD); + + const MDString *MS = cast(Val); + // Find the corresponding MDNode. + DITypeIdentifierMap::const_iterator Iter = Map.find(MS); + assert(Iter != Map.end() && "Identifier not in the type map?"); + assert(DIDescriptor(Iter->second).isType() && + "MDNode in DITypeIdentifierMap should be a DIType."); + return T(Iter->second); +} + /// Specialize getFieldAs to handle fields that are references to DIScopes. template <> DIScopeRef DIDescriptor::getFieldAs(unsigned Elt) const; /// Specialize DIRef constructor for DIScopeRef. -- cgit v1.1 From c664d76716ba87577b6c2a513ce4fe0712a2d3e2 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Sat, 5 Oct 2013 01:43:03 +0000 Subject: Debug Info: In DIBuilder, the derived-from field of a DW_TAG_pointer_type is updated to use DITypeRef. Move isUnsignedDIType and getOriginalTypeSize from DebugInfo.h to be static helper functions in DwarfCompileUnit. We already have a static helper function "isTypeSigned" in DwarfCompileUnit, and a pointer to DwarfDebug is added to resolve the derived-from field. All three functions need to go across link for derived-from fields, so we need to get hold of a type identifier map. A pointer to DwarfDebug is also added to DbgVariable in order to resolve the derived-from field. Debug info verifier is updated to check a derived-from field is a TypeRef. Verifier will not go across link for derived-from fields, in debug info finder, we go across the link to add derived-from fields to types. Function getDICompositeType is only used by dragonegg and since dragonegg does not generate identifier for types, we use an empty map to resolve the derived-from field. When printing a derived-from field, we use DITypeRef::getName to either return the type identifier or getName of the DIType. A paired commit at clang is required due to changes to DIBuilder. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192018 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index ad01494..506b84c 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -22,6 +22,7 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" +#include "llvm/IR/Metadata.h" #include "llvm/Support/Dwarf.h" namespace llvm { @@ -204,6 +205,8 @@ public: /// Gets the parent scope for this scope node or returns a /// default constructed scope. DIScopeRef getContext() const; + /// If the scope node has a name, return that, else return an empty string. + StringRef getName() const; StringRef getFilename() const; StringRef getDirectory() const; @@ -227,6 +230,16 @@ template class DIRef { public: T resolve(const DITypeIdentifierMap &Map) const; + StringRef getName() const { + if (!Val) + return StringRef(); + + if (const MDNode *MD = dyn_cast(Val)) + return T(MD).getName(); + + const MDString *MS = cast(Val); + return MS->getString(); + } operator Value *() const { return const_cast(Val); } }; @@ -300,9 +313,6 @@ public: bool isStaticMember() const { return (getFlags() & FlagStaticMember) != 0; } bool isValid() const { return DbgNode && isType(); } - /// isUnsignedDIType - Return true if type encoding is unsigned. - bool isUnsignedDIType(); - /// replaceAllUsesWith - Replace all uses of debug info referenced by /// this descriptor. void replaceAllUsesWith(DIDescriptor &D); @@ -330,11 +340,7 @@ class DIDerivedType : public DIType { public: explicit DIDerivedType(const MDNode *N = 0) : DIType(N) {} - DIType getTypeDerivedFrom() const { return getFieldAs(9); } - - /// getOriginalTypeSize - If this type is derived from a base type then - /// return base type size. - uint64_t getOriginalTypeSize() const; + DITypeRef getTypeDerivedFrom() const { return getFieldAs(9); } /// getObjCProperty - Return property node, if this ivar is /// associated with one. -- cgit v1.1 From 936910d9293f7118056498c75c7bca79a7fc579c Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sat, 5 Oct 2013 05:38:16 +0000 Subject: Add OPC_CheckChildSame0-3 to the DAG isel matcher. This replaces sequences of MoveChild, CheckSame, MoveParent. Saves 846 bytes from the X86 DAG isel matcher, ~300 from ARM, ~840 from Hexagon. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192026 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/SelectionDAGISel.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/SelectionDAGISel.h b/include/llvm/CodeGen/SelectionDAGISel.h index 3d55d3a..b5ec8cb 100644 --- a/include/llvm/CodeGen/SelectionDAGISel.h +++ b/include/llvm/CodeGen/SelectionDAGISel.h @@ -113,6 +113,8 @@ public: OPC_MoveChild, OPC_MoveParent, OPC_CheckSame, + OPC_CheckChild0Same, OPC_CheckChild1Same, + OPC_CheckChild2Same, OPC_CheckChild3Same, OPC_CheckPatternPredicate, OPC_CheckPredicate, OPC_CheckOpcode, -- cgit v1.1 From beb6afa84397a27e48a9d72ac1d588bc6fcaf564 Mon Sep 17 00:00:00 2001 From: Jiangning Liu Date: Sat, 5 Oct 2013 08:22:10 +0000 Subject: Implement aarch64 neon instruction set AdvSIMD (Across). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192028 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/ValueTypes.td | 2 +- include/llvm/IR/IntrinsicsAArch64.td | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/ValueTypes.td b/include/llvm/CodeGen/ValueTypes.td index 5fc98bf..b5fa0e8 100644 --- a/include/llvm/CodeGen/ValueTypes.td +++ b/include/llvm/CodeGen/ValueTypes.td @@ -26,7 +26,7 @@ def i16 : ValueType<16 , 3>; // 16-bit integer value def i32 : ValueType<32 , 4>; // 32-bit integer value def i64 : ValueType<64 , 5>; // 64-bit integer value def i128 : ValueType<128, 6>; // 128-bit integer value -def f16 : ValueType<16 , 7>; // 32-bit floating point value +def f16 : ValueType<16 , 7>; // 16-bit floating point value def f32 : ValueType<32 , 8>; // 32-bit floating point value def f64 : ValueType<64 , 9>; // 64-bit floating point value def f80 : ValueType<80 , 10>; // 80-bit floating point value diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 4f7252d..526ebef 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -65,6 +65,25 @@ def int_aarch64_neon_vuqshrn : Neon_N2V_Narrow_Intrinsic; def int_aarch64_neon_vsqrshrn : Neon_N2V_Narrow_Intrinsic; def int_aarch64_neon_vuqrshrn : Neon_N2V_Narrow_Intrinsic; +// Vector across +class Neon_Across_Intrinsic + : Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>; + +class Neon_2Arg_Across_Float_Intrinsic + : Intrinsic<[llvm_anyvector_ty], [llvm_v4f32_ty], [IntrNoMem]>; + +def int_aarch64_neon_saddlv : Neon_Across_Intrinsic; +def int_aarch64_neon_uaddlv : Neon_Across_Intrinsic; +def int_aarch64_neon_smaxv : Neon_Across_Intrinsic; +def int_aarch64_neon_umaxv : Neon_Across_Intrinsic; +def int_aarch64_neon_sminv : Neon_Across_Intrinsic; +def int_aarch64_neon_uminv : Neon_Across_Intrinsic; +def int_aarch64_neon_vaddv : Neon_Across_Intrinsic; +def int_aarch64_neon_vmaxv : Neon_Across_Intrinsic; +def int_aarch64_neon_vminv : Neon_Across_Intrinsic; +def int_aarch64_neon_vmaxnmv : Neon_Across_Intrinsic; +def int_aarch64_neon_vminnmv : Neon_Across_Intrinsic; + // Scalar Add def int_aarch64_neon_vaddds : Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], [IntrNoMem]>; -- cgit v1.1 From 5e195a4c8d8cd4498ab7e0aa16a3b6f273daf457 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sat, 5 Oct 2013 16:42:21 +0000 Subject: Remove some really nasty uses of hasRawTextSupport. When MC was first added, targets could use hasRawTextSupport to keep features working before they were added to the MC interface. The design goal of MC is to provide an uniform api for printing assembly and object files. Short of relaxations and other corner cases, a object file is just another representation of the assembly. It was never the intention that targets would keep doing things like if (hasRawTextSupport()) Set flags in one way. else Set flags in another way. When they do that they create two code paths and the object file is no longer just another representation of the assembly. This also then requires testing with llc -filetype=obj, which is extremelly brittle. This patch removes some of these hacks by replacing them with smaller ones. The ARM flag setting is trivial, so I just moved it to the constructor. For Mips, the patch adds two temporary hack directives that allow the assembly to represent the same things as the object file was already able to. The hope is that the mips developers will replace the hack directives with the same ones that gas uses and drop the -print-hack-directives flag. I will also try to implement a target streamer interface, so that we can move this out of the common code. In summary, for any new work, two rules of the thumb are * Don't use "llc -filetype=obj" in tests. * Don't add calls to hasRawTextSupport. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192035 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCELFStreamer.h | 24 +++++++++++------------- include/llvm/MC/MCObjectStreamer.h | 15 ++++----------- include/llvm/MC/MCStreamer.h | 25 +++++-------------------- 3 files changed, 20 insertions(+), 44 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCELFStreamer.h b/include/llvm/MC/MCELFStreamer.h index 76369cc..0f45a93 100644 --- a/include/llvm/MC/MCELFStreamer.h +++ b/include/llvm/MC/MCELFStreamer.h @@ -28,20 +28,14 @@ class MCSymbolData; class raw_ostream; class MCELFStreamer : public MCObjectStreamer { -protected: - MCELFStreamer(StreamerKind Kind, MCContext &Context, MCAsmBackend &TAB, - raw_ostream &OS, MCCodeEmitter *Emitter) - : MCObjectStreamer(Kind, Context, TAB, OS, Emitter) {} - public: MCELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter) - : MCObjectStreamer(SK_ELFStreamer, Context, TAB, OS, Emitter) {} + : MCObjectStreamer(Context, TAB, OS, Emitter) {} MCELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter, MCAssembler *Assembler) - : MCObjectStreamer(SK_ELFStreamer, Context, TAB, OS, Emitter, - Assembler) {} + : MCObjectStreamer(Context, TAB, OS, Emitter, Assembler) {} virtual ~MCELFStreamer(); @@ -88,11 +82,6 @@ public: virtual void Flush(); virtual void FinishImpl(); - /// @} - - static bool classof(const MCStreamer *S) { - return S->getKind() == SK_ELFStreamer || S->getKind() == SK_ARMELFStreamer; - } private: virtual void EmitInstToFragment(const MCInst &Inst); @@ -122,6 +111,15 @@ private: void SetSectionBss(); }; +MCELFStreamer *createMipsELFStreamer(MCContext &Context, MCAsmBackend &TAB, + raw_ostream &OS, MCCodeEmitter *Emitter, + bool RelaxAll, bool NoExecStack); + +MCELFStreamer *createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB, + raw_ostream &OS, MCCodeEmitter *Emitter, + bool RelaxAll, bool NoExecStack, + bool IsThumb); + } // end namespace llvm #endif diff --git a/include/llvm/MC/MCObjectStreamer.h b/include/llvm/MC/MCObjectStreamer.h index 0affeee..f6a7e71 100644 --- a/include/llvm/MC/MCObjectStreamer.h +++ b/include/llvm/MC/MCObjectStreamer.h @@ -40,11 +40,10 @@ class MCObjectStreamer : public MCStreamer { virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame); protected: - MCObjectStreamer(StreamerKind Kind, MCContext &Context, MCAsmBackend &TAB, - raw_ostream &_OS, MCCodeEmitter *_Emitter); - MCObjectStreamer(StreamerKind Kind, MCContext &Context, MCAsmBackend &TAB, - raw_ostream &_OS, MCCodeEmitter *_Emitter, - MCAssembler *_Assembler); + MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &_OS, + MCCodeEmitter *_Emitter); + MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &_OS, + MCCodeEmitter *_Emitter, MCAssembler *_Assembler); ~MCObjectStreamer(); public: @@ -116,12 +115,6 @@ public: virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue); virtual void EmitZeros(uint64_t NumBytes); virtual void FinishImpl(); - - /// @} - - static bool classof(const MCStreamer *S) { - return S->getKind() >= SK_ELFStreamer && S->getKind() <= SK_WinCOFFStreamer; - } }; } // end namespace llvm diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index a5f8bc0..3cd5c77 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -49,23 +49,6 @@ typedef std::pair MCSectionSubPair; /// a .s file, and implementations that write out .o files of various formats. /// class MCStreamer { -public: - enum StreamerKind { - SK_AsmStreamer, - SK_NullStreamer, - SK_RecordStreamer, - - // MCObjectStreamer subclasses. - SK_ELFStreamer, - SK_ARMELFStreamer, - SK_MachOStreamer, - SK_PureStreamer, - SK_MipsELFStreamer, - SK_WinCOFFStreamer - }; - -private: - const StreamerKind Kind; MCContext &Context; MCStreamer(const MCStreamer &) LLVM_DELETED_FUNCTION; @@ -97,7 +80,7 @@ private: bool AutoInitSections; protected: - MCStreamer(StreamerKind Kind, MCContext &Ctx); + MCStreamer(MCContext &Ctx); const MCExpr *BuildSymbolDiff(MCContext &Context, const MCSymbol *A, const MCSymbol *B); @@ -118,8 +101,6 @@ protected: public: virtual ~MCStreamer(); - StreamerKind getKind() const { return Kind; } - /// State management /// virtual void reset(); @@ -632,6 +613,10 @@ public: virtual void EmitRegSave(const SmallVectorImpl &RegList, bool isVector); + /// Mips-related methods. + virtual void emitMipsHackELFFlags(unsigned Flags); + virtual void emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val); + /// PPC-related methods. /// FIXME: Eventually replace it with some "target MC streamer" and move /// these methods there. -- cgit v1.1 From 22abf7e17f47f26691fdf4c590ebd88ebf560c73 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Sat, 5 Oct 2013 19:22:59 +0000 Subject: Remove unneeded TBM intrinsics. The arithmetic/logical operation patterns are sufficient. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192039 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 62 ++-------------------------------------- 1 file changed, 3 insertions(+), 59 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index 4eb6960..34f43c3 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -2598,65 +2598,9 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_tbm_bextri_u32 : GCCBuiltin<"__builtin_ia32_bextri_u32">, - Intrinsic<[llvm_i32_ty], [llvm_i32_ty, - llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_x86_tbm_bextri_u64 : GCCBuiltin<"__builtin_ia32_bextri_u64">, - Intrinsic<[llvm_i64_ty], [llvm_i64_ty, - llvm_i64_ty], [IntrNoMem]>; - def int_x86_tbm_blcfill_u32 : GCCBuiltin<"__builtin_ia32_blcfill_u32">, - Intrinsic<[llvm_i32_ty], [llvm_i32_ty], - [IntrNoMem]>; - def int_x86_tbm_blcfill_u64 : GCCBuiltin<"__builtin_ia32_blcfill_u64">, - Intrinsic<[llvm_i64_ty], [llvm_i64_ty], - [IntrNoMem]>; - def int_x86_tbm_blci_u32 : GCCBuiltin<"__builtin_ia32_blci_u32">, - Intrinsic<[llvm_i32_ty], [llvm_i32_ty], - [IntrNoMem]>; - def int_x86_tbm_blci_u64 : GCCBuiltin<"__builtin_ia32_blci_u64">, - Intrinsic<[llvm_i64_ty], [llvm_i64_ty], - [IntrNoMem]>; - def int_x86_tbm_blcic_u32 : GCCBuiltin<"__builtin_ia32_blcic_u32">, - Intrinsic<[llvm_i32_ty], [llvm_i32_ty], - [IntrNoMem]>; - def int_x86_tbm_blcic_u64 : GCCBuiltin<"__builtin_ia32_blcic_u64">, - Intrinsic<[llvm_i64_ty], [llvm_i64_ty], - [IntrNoMem]>; - def int_x86_tbm_blcmsk_u32 : GCCBuiltin<"__builtin_ia32_blcmsk_u32">, - Intrinsic<[llvm_i32_ty], [llvm_i32_ty], - [IntrNoMem]>; - def int_x86_tbm_blcmsk_u64 : GCCBuiltin<"__builtin_ia32_blcmsk_u64">, - Intrinsic<[llvm_i64_ty], [llvm_i64_ty], - [IntrNoMem]>; - def int_x86_tbm_blcs_u32 : GCCBuiltin<"__builtin_ia32_blcs_u32">, - Intrinsic<[llvm_i32_ty], [llvm_i32_ty], - [IntrNoMem]>; - def int_x86_tbm_blcs_u64 : GCCBuiltin<"__builtin_ia32_blcs_u64">, - Intrinsic<[llvm_i64_ty], [llvm_i64_ty], - [IntrNoMem]>; - def int_x86_tbm_blsfill_u32 : GCCBuiltin<"__builtin_ia32_blsfill_u32">, - Intrinsic<[llvm_i32_ty], [llvm_i32_ty], - [IntrNoMem]>; - def int_x86_tbm_blsfill_u64 : GCCBuiltin<"__builtin_ia32_blsfill_u64">, - Intrinsic<[llvm_i64_ty], [llvm_i64_ty], - [IntrNoMem]>; - def int_x86_tbm_blsic_u32 : GCCBuiltin<"__builtin_ia32_blsic_u32">, - Intrinsic<[llvm_i32_ty], [llvm_i32_ty], - [IntrNoMem]>; - def int_x86_tbm_blsic_u64 : GCCBuiltin<"__builtin_ia32_blsic_u64">, - Intrinsic<[llvm_i64_ty], [llvm_i64_ty], - [IntrNoMem]>; - def int_x86_tbm_t1mskc_u32 : GCCBuiltin<"__builtin_ia32_t1mskc_u32">, - Intrinsic<[llvm_i32_ty], [llvm_i32_ty], - [IntrNoMem]>; - def int_x86_tbm_t1mskc_u64 : GCCBuiltin<"__builtin_ia32_t1mskc_u64">, - Intrinsic<[llvm_i64_ty], [llvm_i64_ty], - [IntrNoMem]>; - def int_x86_tbm_tzmsk_u32 : GCCBuiltin<"__builtin_ia32_tzmsk_u32">, - Intrinsic<[llvm_i32_ty], [llvm_i32_ty], - [IntrNoMem]>; - def int_x86_tbm_tzmsk_u64 : GCCBuiltin<"__builtin_ia32_tzmsk_u64">, - Intrinsic<[llvm_i64_ty], [llvm_i64_ty], - [IntrNoMem]>; + Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>; } //===----------------------------------------------------------------------===// @@ -2967,4 +2911,4 @@ let TargetPrefix = "x86" in { Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; def int_x86_sha256msg2 : GCCBuiltin<"__builtin_ia32_sha256msg2">, Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; -} \ No newline at end of file +} -- cgit v1.1 From 26ba5df2ebc123b1d214a5e7334c650e90d3738a Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Sun, 6 Oct 2013 08:49:41 +0000 Subject: [Mips] Add MIPS program header types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192059 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/ELF.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/ELF.h b/include/llvm/Support/ELF.h index 61d1a0d..8acaa4a 100644 --- a/include/llvm/Support/ELF.h +++ b/include/llvm/Support/ELF.h @@ -1447,7 +1447,12 @@ enum { PT_ARM_ARCHEXT = 0x70000000, // Platform architecture compatibility info // These all contain stack unwind tables. PT_ARM_EXIDX = 0x70000001, - PT_ARM_UNWIND = 0x70000001 + PT_ARM_UNWIND = 0x70000001, + + // MIPS program header types. + PT_MIPS_REGINFO = 0x70000000, // Register usage information. + PT_MIPS_RTPROC = 0x70000001, // Runtime procedure table. + PT_MIPS_OPTIONS = 0x70000002 // Options segment. }; // Segment flag bits. -- cgit v1.1 From 714319a169784577e33fb1ea28ac06be32c9e735 Mon Sep 17 00:00:00 2001 From: Elena Demikhovsky Date: Sun, 6 Oct 2013 13:11:09 +0000 Subject: AVX-512: added scalar convert instructions and intrinsics. Fixed load folding in VPERM2I instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192063 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index 34f43c3..bd22e1b 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -206,6 +206,22 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_sse_cvtsi642ss : GCCBuiltin<"__builtin_ia32_cvtsi642ss">, Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_i64_ty], [IntrNoMem]>; + // avx-512 for unsigned conversion + def int_x86_avx512_cvtss2usi : GCCBuiltin<"__builtin_ia32_cvtss2usi">, + Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>; + def int_x86_avx512_cvtss2usi64 : GCCBuiltin<"__builtin_ia32_cvtss2usi64">, + Intrinsic<[llvm_i64_ty], [llvm_v4f32_ty], [IntrNoMem]>; + def int_x86_avx512_cvttss2usi : GCCBuiltin<"__builtin_ia32_cvttss2usi">, + Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>; + def int_x86_avx512_cvttss2usi64 : GCCBuiltin<"__builtin_ia32_cvttss2usi64">, + Intrinsic<[llvm_i64_ty], [llvm_v4f32_ty], [IntrNoMem]>; + def int_x86_avx512_cvtusi2ss : GCCBuiltin<"__builtin_ia32_cvtusi2ss">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_avx512_cvtusi642ss : GCCBuiltin<"__builtin_ia32_cvtusi642ss">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, + llvm_i64_ty], [IntrNoMem]>; + def int_x86_sse_cvtps2pi : GCCBuiltin<"__builtin_ia32_cvtps2pi">, Intrinsic<[llvm_x86mmx_ty], [llvm_v4f32_ty], [IntrNoMem]>; def int_x86_sse_cvttps2pi: GCCBuiltin<"__builtin_ia32_cvttps2pi">, @@ -484,6 +500,20 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_sse2_cvtsi642sd : GCCBuiltin<"__builtin_ia32_cvtsi642sd">, Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_i64_ty], [IntrNoMem]>; + def int_x86_avx512_cvtsd2usi : GCCBuiltin<"__builtin_ia32_cvtsd2usi">, + Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>; + def int_x86_avx512_cvtsd2usi64 : GCCBuiltin<"__builtin_ia32_cvtsd2usi64">, + Intrinsic<[llvm_i64_ty], [llvm_v2f64_ty], [IntrNoMem]>; + def int_x86_avx512_cvttsd2usi : GCCBuiltin<"__builtin_ia32_cvttsd2usi">, + Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>; + def int_x86_avx512_cvttsd2usi64 : GCCBuiltin<"__builtin_ia32_cvttsd2usi64">, + Intrinsic<[llvm_i64_ty], [llvm_v2f64_ty], [IntrNoMem]>; + def int_x86_avx512_cvtusi2sd : GCCBuiltin<"__builtin_ia32_cvtusi2sd">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_avx512_cvtusi642sd : GCCBuiltin<"__builtin_ia32_cvtusi642sd">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, + llvm_i64_ty], [IntrNoMem]>; def int_x86_sse2_cvtsd2ss : GCCBuiltin<"__builtin_ia32_cvtsd2ss">, Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v2f64_ty], [IntrNoMem]>; -- cgit v1.1 From 5a1a1856a4dfa1335d937437fade5c0bbab06560 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sun, 6 Oct 2013 20:25:49 +0000 Subject: Windows: Add support for unicode command lines Summary: The MSVCRT deliberately sends main() code-page specific characters. This isn't too useful to LLVM as we end up converting the arguments to UTF-16 and subsequently attempt to use the result as, for example, a file name. Instead, we need to have the ability to access the Unicode command line and transform it to UTF-8. This has the distinct advantage over using the MSVC-specific wmain() function as our entry point because: - It doesn't work on cygwin. - It only work on MinGW with caveats and only then on certain versions. - We get to keep our entry point as main(). :) N.B. This patch includes fixes to other parts of lib/Support/Windows s.t. we would be able to take advantage of getting the Unicode paths. E.G. clang spawning clang -cc1 would want to give it Unicode arguments. Reviewers: aaron.ballman, Bigcheese, rnk, ruiu Reviewed By: rnk CC: llvm-commits, ygao Differential Revision: http://llvm-reviews.chandlerc.com/D1834 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192069 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Config/config.h.cmake | 3 +++ include/llvm/Config/config.h.in | 3 +++ include/llvm/Support/Process.h | 11 +++++++++++ 3 files changed, 17 insertions(+) (limited to 'include') diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake index 77de967..4c49cbb 100644 --- a/include/llvm/Config/config.h.cmake +++ b/include/llvm/Config/config.h.cmake @@ -203,6 +203,9 @@ /* Define to 1 if you have the `pthread' library (-lpthread). */ #cmakedefine HAVE_LIBPTHREAD ${HAVE_LIBPTHREAD} +/* Define to 1 if you have the `shell32' library (-lshell32). */ +#cmakedefine HAVE_LIBSHELL32 ${HAVE_LIBSHELL32} + /* Define to 1 if you have the `udis86' library (-ludis86). */ #undef HAVE_LIBUDIS86 diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in index 860bccb..0d43ae5 100644 --- a/include/llvm/Config/config.h.in +++ b/include/llvm/Config/config.h.in @@ -217,6 +217,9 @@ /* Define to 1 if you have the `pthread' library (-lpthread). */ #undef HAVE_LIBPTHREAD +/* Define to 1 if you have the `shell32' library (-lshell32). */ +#undef HAVE_LIBSHELL32 + /* Define to 1 if you have the `udis86' library (-ludis86). */ #undef HAVE_LIBUDIS86 diff --git a/include/llvm/Support/Process.h b/include/llvm/Support/Process.h index ce39d04..2172036 100644 --- a/include/llvm/Support/Process.h +++ b/include/llvm/Support/Process.h @@ -25,8 +25,11 @@ #ifndef LLVM_SUPPORT_PROCESS_H #define LLVM_SUPPORT_PROCESS_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/Config/llvm-config.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/system_error.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/TimeValue.h" @@ -168,6 +171,14 @@ public: // string. \arg Name is assumed to be in UTF-8 encoding too. static Optional GetEnv(StringRef name); + /// This function returns a SmallVector containing the arguments passed from + /// the operating system to the program. This function expects to be handed + /// the vector passed in from main. + static error_code + GetArgumentVector(SmallVectorImpl &Args, + ArrayRef ArgsFromMain, + SpecificBumpPtrAllocator &ArgAllocator); + /// 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. -- cgit v1.1 From b262556c45bb7b3add826bc3f050c99db6990c37 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Sun, 6 Oct 2013 20:44:34 +0000 Subject: Revert "Windows: Add support for unicode command lines" This is causing MinGW bots to fail. This reverts commit r192069. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192070 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Config/config.h.cmake | 3 --- include/llvm/Config/config.h.in | 3 --- include/llvm/Support/Process.h | 11 ----------- 3 files changed, 17 deletions(-) (limited to 'include') diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake index 4c49cbb..77de967 100644 --- a/include/llvm/Config/config.h.cmake +++ b/include/llvm/Config/config.h.cmake @@ -203,9 +203,6 @@ /* Define to 1 if you have the `pthread' library (-lpthread). */ #cmakedefine HAVE_LIBPTHREAD ${HAVE_LIBPTHREAD} -/* Define to 1 if you have the `shell32' library (-lshell32). */ -#cmakedefine HAVE_LIBSHELL32 ${HAVE_LIBSHELL32} - /* Define to 1 if you have the `udis86' library (-ludis86). */ #undef HAVE_LIBUDIS86 diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in index 0d43ae5..860bccb 100644 --- a/include/llvm/Config/config.h.in +++ b/include/llvm/Config/config.h.in @@ -217,9 +217,6 @@ /* Define to 1 if you have the `pthread' library (-lpthread). */ #undef HAVE_LIBPTHREAD -/* Define to 1 if you have the `shell32' library (-lshell32). */ -#undef HAVE_LIBSHELL32 - /* Define to 1 if you have the `udis86' library (-ludis86). */ #undef HAVE_LIBUDIS86 diff --git a/include/llvm/Support/Process.h b/include/llvm/Support/Process.h index 2172036..ce39d04 100644 --- a/include/llvm/Support/Process.h +++ b/include/llvm/Support/Process.h @@ -25,11 +25,8 @@ #ifndef LLVM_SUPPORT_PROCESS_H #define LLVM_SUPPORT_PROCESS_H -#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/Config/llvm-config.h" -#include "llvm/Support/Allocator.h" -#include "llvm/Support/system_error.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/TimeValue.h" @@ -171,14 +168,6 @@ public: // string. \arg Name is assumed to be in UTF-8 encoding too. static Optional GetEnv(StringRef name); - /// This function returns a SmallVector containing the arguments passed from - /// the operating system to the program. This function expects to be handed - /// the vector passed in from main. - static error_code - GetArgumentVector(SmallVectorImpl &Args, - ArrayRef ArgsFromMain, - SpecificBumpPtrAllocator &ArgAllocator); - /// 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. -- cgit v1.1 From 6a971bb8f59f4e20c953a2cc360cab7bae8642e4 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Mon, 7 Oct 2013 01:00:07 +0000 Subject: Revert "Revert "Windows: Add support for unicode command lines"" This reverts commit r192070 which reverted r192069, I forgot to regenerate the configure scripts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192079 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Config/config.h.cmake | 3 +++ include/llvm/Config/config.h.in | 3 +++ include/llvm/Support/Process.h | 11 +++++++++++ 3 files changed, 17 insertions(+) (limited to 'include') diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake index 77de967..4c49cbb 100644 --- a/include/llvm/Config/config.h.cmake +++ b/include/llvm/Config/config.h.cmake @@ -203,6 +203,9 @@ /* Define to 1 if you have the `pthread' library (-lpthread). */ #cmakedefine HAVE_LIBPTHREAD ${HAVE_LIBPTHREAD} +/* Define to 1 if you have the `shell32' library (-lshell32). */ +#cmakedefine HAVE_LIBSHELL32 ${HAVE_LIBSHELL32} + /* Define to 1 if you have the `udis86' library (-ludis86). */ #undef HAVE_LIBUDIS86 diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in index 860bccb..0d43ae5 100644 --- a/include/llvm/Config/config.h.in +++ b/include/llvm/Config/config.h.in @@ -217,6 +217,9 @@ /* Define to 1 if you have the `pthread' library (-lpthread). */ #undef HAVE_LIBPTHREAD +/* Define to 1 if you have the `shell32' library (-lshell32). */ +#undef HAVE_LIBSHELL32 + /* Define to 1 if you have the `udis86' library (-ludis86). */ #undef HAVE_LIBUDIS86 diff --git a/include/llvm/Support/Process.h b/include/llvm/Support/Process.h index ce39d04..2172036 100644 --- a/include/llvm/Support/Process.h +++ b/include/llvm/Support/Process.h @@ -25,8 +25,11 @@ #ifndef LLVM_SUPPORT_PROCESS_H #define LLVM_SUPPORT_PROCESS_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/Config/llvm-config.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/system_error.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/TimeValue.h" @@ -168,6 +171,14 @@ public: // string. \arg Name is assumed to be in UTF-8 encoding too. static Optional GetEnv(StringRef name); + /// This function returns a SmallVector containing the arguments passed from + /// the operating system to the program. This function expects to be handed + /// the vector passed in from main. + static error_code + GetArgumentVector(SmallVectorImpl &Args, + ArrayRef ArgsFromMain, + SpecificBumpPtrAllocator &ArgAllocator); + /// 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. -- cgit v1.1 From c697f8b28832a0dcb8b7ceb919b02628050b7730 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 7 Oct 2013 13:34:05 +0000 Subject: Fix the documentation of getDefaultSubtargetFeatures. Patch by David Nadlinger. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192098 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/SubtargetFeature.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/SubtargetFeature.h b/include/llvm/MC/SubtargetFeature.h index 8862c8b..acebf99 100644 --- a/include/llvm/MC/SubtargetFeature.h +++ b/include/llvm/MC/SubtargetFeature.h @@ -99,8 +99,7 @@ public: // Dump feature info. void dump() const; - /// Retrieve a formatted string of the default features for the specified - /// target triple. + /// Adds the default features for the specified target triple. void getDefaultSubtargetFeatures(const Triple& Triple); }; -- cgit v1.1 From d0acc84b2b98d7c4ba5057cfb004ecf9f9db6a3d Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 7 Oct 2013 13:54:50 +0000 Subject: Remove dead code. Support for exception handling in the legacy JIT was removed in r181354 and this code was dead since then. Thanks to Yaron Keren for noticing it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192101 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ExecutionEngine/ExecutionEngine.h | 45 -------------------------- 1 file changed, 45 deletions(-) (limited to 'include') diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h index 46ee7a6..c78faa6 100644 --- a/include/llvm/ExecutionEngine/ExecutionEngine.h +++ b/include/llvm/ExecutionEngine/ExecutionEngine.h @@ -16,7 +16,6 @@ #define LLVM_EXECUTIONENGINE_EXECUTIONENGINE_H #include "llvm-c/ExecutionEngine.h" -#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/ValueMap.h" @@ -153,15 +152,6 @@ protected: /// abort. void *(*LazyFunctionCreator)(const std::string &); - /// ExceptionTableRegister - If Exception Handling is set, the JIT will - /// register dwarf tables with this function. - typedef void (*EERegisterFn)(void*); - EERegisterFn ExceptionTableRegister; - EERegisterFn ExceptionTableDeregister; - /// This maps functions to their exception tables frames. - DenseMap AllExceptionTables; - - public: /// lock - This lock protects the ExecutionEngine, JIT, JITResolver and /// JITEmitter classes. It must be held while changing the internal state of @@ -489,41 +479,6 @@ public: LazyFunctionCreator = P; } - /// InstallExceptionTableRegister - The JIT will use the given function - /// to register the exception tables it generates. - void InstallExceptionTableRegister(EERegisterFn F) { - ExceptionTableRegister = F; - } - void InstallExceptionTableDeregister(EERegisterFn F) { - ExceptionTableDeregister = F; - } - - /// RegisterTable - Registers the given pointer as an exception table. It - /// uses the ExceptionTableRegister function. - void RegisterTable(const Function *fn, void* res) { - if (ExceptionTableRegister) { - ExceptionTableRegister(res); - AllExceptionTables[fn] = res; - } - } - - /// DeregisterTable - Deregisters the exception frame previously registered - /// for the given function. - void DeregisterTable(const Function *Fn) { - if (ExceptionTableDeregister) { - DenseMap::iterator frame = - AllExceptionTables.find(Fn); - if(frame != AllExceptionTables.end()) { - ExceptionTableDeregister(frame->second); - AllExceptionTables.erase(frame); - } - } - } - - /// DeregisterAllTables - Deregisters all previously registered pointers to an - /// exception tables. It uses the ExceptionTableoDeregister function. - void DeregisterAllTables(); - protected: explicit ExecutionEngine(Module *M); -- cgit v1.1 From c4a8c07f6489c0081207f722ce0a4502614aef69 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Mon, 7 Oct 2013 18:06:48 +0000 Subject: Change objectsize intrinsic to accept different address spaces. Bitcasting everything to i8* won't work. Autoupgrade the old intrinsic declarations to use the new mangling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192117 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Intrinsics.td | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/IR/Intrinsics.td b/include/llvm/IR/Intrinsics.td index 57c99d9..53341b7 100644 --- a/include/llvm/IR/Intrinsics.td +++ b/include/llvm/IR/Intrinsics.td @@ -328,7 +328,7 @@ def int_sigsetjmp : Intrinsic<[llvm_i32_ty] , [llvm_ptr_ty, llvm_i32_ty]>; def int_siglongjmp : Intrinsic<[], [llvm_ptr_ty, llvm_i32_ty], [IntrNoReturn]>; // Internal interface for object size checking -def int_objectsize : Intrinsic<[llvm_anyint_ty], [llvm_ptr_ty, llvm_i1_ty], +def int_objectsize : Intrinsic<[llvm_anyint_ty], [llvm_anyptr_ty, llvm_i1_ty], [IntrNoMem]>, GCCBuiltin<"__builtin_object_size">; -- cgit v1.1 From 379f76e873b91550e3d9cee79dff814e3ce1e86e Mon Sep 17 00:00:00 2001 From: Richard Mitton Date: Mon, 7 Oct 2013 18:39:18 +0000 Subject: Formally added an explicit enum for DWARF TLS support. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192118 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index 0f33541..f4a9acf 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -486,6 +486,9 @@ enum Constants { DW_OP_lo_user = 0xe0, DW_OP_hi_user = 0xff, + // Extensions for GNU-style thread-local storage. + DW_OP_GNU_push_tls_address = 0xe0, + // Extensions for Fission proposal. DW_OP_GNU_addr_index = 0xfb, DW_OP_GNU_const_index = 0xfc, -- cgit v1.1 From 0d94d8f9f1f8b8d45560b1e30cb6b3504e682371 Mon Sep 17 00:00:00 2001 From: Nick Kledzik Date: Tue, 8 Oct 2013 00:59:13 +0000 Subject: update mach-o EXPORT_SYMBOL_* names git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192151 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/MachO.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/MachO.h b/include/llvm/Support/MachO.h index b2ac6b3..dcf9e42 100644 --- a/include/llvm/Support/MachO.h +++ b/include/llvm/Support/MachO.h @@ -268,8 +268,8 @@ namespace llvm { enum { EXPORT_SYMBOL_FLAGS_KIND_MASK = 0x03u, EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION = 0x04u, - EXPORT_SYMBOL_FLAGS_INDIRECT_DEFINITION = 0x08u, - EXPORT_SYMBOL_FLAGS_HAS_SPECIALIZATIONS = 0x10u + EXPORT_SYMBOL_FLAGS_REEXPORT = 0x08u, + EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER = 0x10u }; enum ExportSymbolKind { -- cgit v1.1 From 320296a4cfe414ce59f406b8a5ce15272f563103 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 8 Oct 2013 13:08:17 +0000 Subject: Add a MCTargetStreamer interface. This patch fixes an old FIXME by creating a MCTargetStreamer interface and moving the target specific functions for ARM, Mips and PPC to it. The ARM streamer is still declared in a common place because it is used from lib/CodeGen/ARMException.cpp, but the Mips and PPC are completely hidden in the corresponding Target directories. I will send an email to llvmdev with instructions on how to use this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192181 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCELFStreamer.h | 20 +++----- include/llvm/MC/MCObjectStreamer.h | 8 +-- include/llvm/MC/MCStreamer.h | 91 ++++++++++++++++++++++++----------- include/llvm/Support/TargetRegistry.h | 32 ++++++++---- 4 files changed, 98 insertions(+), 53 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCELFStreamer.h b/include/llvm/MC/MCELFStreamer.h index 0f45a93..8dbe337 100644 --- a/include/llvm/MC/MCELFStreamer.h +++ b/include/llvm/MC/MCELFStreamer.h @@ -29,13 +29,15 @@ class raw_ostream; class MCELFStreamer : public MCObjectStreamer { public: - MCELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS, - MCCodeEmitter *Emitter) - : MCObjectStreamer(Context, TAB, OS, Emitter) {} + MCELFStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer, + MCAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter) + : MCObjectStreamer(Context, TargetStreamer, TAB, OS, Emitter) {} - MCELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS, - MCCodeEmitter *Emitter, MCAssembler *Assembler) - : MCObjectStreamer(Context, TAB, OS, Emitter, Assembler) {} + MCELFStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer, + MCAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter, + MCAssembler *Assembler) + : MCObjectStreamer(Context, TargetStreamer, TAB, OS, Emitter, Assembler) { + } virtual ~MCELFStreamer(); @@ -75,8 +77,6 @@ public: virtual void EmitFileDirective(StringRef Filename); - virtual void EmitTCEntry(const MCSymbol &S); - virtual void EmitValueToAlignment(unsigned, int64_t, unsigned, unsigned); virtual void Flush(); @@ -111,10 +111,6 @@ private: void SetSectionBss(); }; -MCELFStreamer *createMipsELFStreamer(MCContext &Context, MCAsmBackend &TAB, - raw_ostream &OS, MCCodeEmitter *Emitter, - bool RelaxAll, bool NoExecStack); - MCELFStreamer *createARMELFStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter, bool RelaxAll, bool NoExecStack, diff --git a/include/llvm/MC/MCObjectStreamer.h b/include/llvm/MC/MCObjectStreamer.h index f6a7e71..5667544 100644 --- a/include/llvm/MC/MCObjectStreamer.h +++ b/include/llvm/MC/MCObjectStreamer.h @@ -40,10 +40,12 @@ class MCObjectStreamer : public MCStreamer { virtual void EmitCFIEndProcImpl(MCDwarfFrameInfo &Frame); protected: - MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &_OS, + MCObjectStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer, + MCAsmBackend &TAB, raw_ostream &_OS, MCCodeEmitter *_Emitter); - MCObjectStreamer(MCContext &Context, MCAsmBackend &TAB, raw_ostream &_OS, - MCCodeEmitter *_Emitter, MCAssembler *_Assembler); + MCObjectStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer, + MCAsmBackend &TAB, raw_ostream &_OS, MCCodeEmitter *_Emitter, + MCAssembler *_Assembler); ~MCObjectStreamer(); public: diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 3cd5c77..10fc69e 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -31,6 +31,7 @@ class MCExpr; class MCInst; class MCInstPrinter; class MCSection; +class MCStreamer; class MCSymbol; class StringRef; class Twine; @@ -39,6 +40,55 @@ class formatted_raw_ostream; typedef std::pair MCSectionSubPair; +/// Target specific streamer interface. This is used so that targets can +/// implement support for target specific assembly directives. +/// +/// If target foo wants to use this, it should implement 3 classes: +/// * FooTargetStreamer : public MCTargetStreamer +/// * FooTargetAsmSreamer : public FooTargetStreamer +/// * FooTargetELFStreamer : public FooTargetStreamer +/// +/// FooTargetStreamer should have a pure virtual method for each directive. For +/// example, for a ".bar symbol_name" directive, it should have +/// virtual emitBar(const MCSymbol &Symbol) = 0; +/// +/// The FooTargetAsmSreamer and FooTargetELFStreamer classes implement the +/// method. The assembly streamer just prints ".bar symbol_name". The object +/// streamer does whatever is needed to implement .bar in the object file. +/// +/// In the assembly printer and parser the target streamer can be used by +/// calling getTargetStreamer and casting it to FooTargetStreamer: +/// +/// MCTargetStreamer &TS = OutStreamer.getTargetStreamer(); +/// FooTargetStreamer &ATS = static_cast(TS); +/// +/// The base classes FooTargetAsmSreamer and FooTargetELFStreamer should *never* +/// be treated differently. Callers should always talk to a FooTargetStreamer. +class MCTargetStreamer { +protected: + OwningPtr Streamer; + +public: + virtual ~MCTargetStreamer(); + void setStreamer(MCStreamer *S) { Streamer.reset(S); } +}; + +// FIXME: declared here because it is used from +// lib/CodeGen/AsmPrinter/ARMException.cpp. +class ARMTargetStreamer : public MCTargetStreamer { +public: + virtual void emitFnStart() = 0; + virtual void emitFnEnd() = 0; + virtual void emitCantUnwind() = 0; + virtual void emitPersonality(const MCSymbol *Personality) = 0; + virtual void emitHandlerData() = 0; + virtual void emitSetFP(unsigned FpReg, unsigned SpReg, + int64_t Offset = 0) = 0; + virtual void emitPad(int64_t Offset) = 0; + virtual void emitRegSave(const SmallVectorImpl &RegList, + bool isVector) = 0; +}; + /// MCStreamer - Streaming machine code generation interface. This interface /// is intended to provide a programatic interface that is very similar to the /// level that an assembler .s file provides. It has callbacks to emit bytes, @@ -50,6 +100,7 @@ typedef std::pair MCSectionSubPair; /// class MCStreamer { MCContext &Context; + MCTargetStreamer *TargetStreamer; MCStreamer(const MCStreamer &) LLVM_DELETED_FUNCTION; MCStreamer &operator=(const MCStreamer &) LLVM_DELETED_FUNCTION; @@ -80,7 +131,7 @@ class MCStreamer { bool AutoInitSections; protected: - MCStreamer(MCContext &Ctx); + MCStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer); const MCExpr *BuildSymbolDiff(MCContext &Context, const MCSymbol *A, const MCSymbol *B); @@ -107,6 +158,11 @@ public: MCContext &getContext() const { return Context; } + MCTargetStreamer &getTargetStreamer() { + assert(TargetStreamer); + return *TargetStreamer; + } + unsigned getNumFrameInfos() { return FrameInfos.size(); } const MCDwarfFrameInfo &getFrameInfo(unsigned i) { return FrameInfos[i]; } @@ -600,28 +656,6 @@ public: virtual void EmitRawText(StringRef String); void EmitRawText(const Twine &String); - /// ARM-related methods. - /// FIXME: Eventually we should have some "target MC streamer" and move - /// these methods there. - virtual void EmitFnStart(); - virtual void EmitFnEnd(); - virtual void EmitCantUnwind(); - virtual void EmitPersonality(const MCSymbol *Personality); - virtual void EmitHandlerData(); - virtual void EmitSetFP(unsigned FpReg, unsigned SpReg, int64_t Offset = 0); - virtual void EmitPad(int64_t Offset); - virtual void EmitRegSave(const SmallVectorImpl &RegList, - bool isVector); - - /// Mips-related methods. - virtual void emitMipsHackELFFlags(unsigned Flags); - virtual void emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val); - - /// PPC-related methods. - /// FIXME: Eventually replace it with some "target MC streamer" and move - /// these methods there. - virtual void EmitTCEntry(const MCSymbol &S); - /// Flush - Causes any cached state to be written out. virtual void Flush() {} @@ -652,9 +686,9 @@ MCStreamer *createNullStreamer(MCContext &Ctx); /// /// \param ShowInst - Whether to show the MCInst representation inline with /// the assembly. -MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS, - bool isVerboseAsm, bool useLoc, bool useCFI, - bool useDwarfDirectory, +MCStreamer *createAsmStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer, + formatted_raw_ostream &OS, bool isVerboseAsm, + bool useLoc, bool useCFI, bool useDwarfDirectory, MCInstPrinter *InstPrint = 0, MCCodeEmitter *CE = 0, MCAsmBackend *TAB = 0, bool ShowInst = false); @@ -677,8 +711,9 @@ MCStreamer *createWinCOFFStreamer(MCContext &Ctx, MCAsmBackend &TAB, /// createELFStreamer - Create a machine code streamer which will generate /// ELF format object files. -MCStreamer *createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB, - raw_ostream &OS, MCCodeEmitter *CE, bool RelaxAll, +MCStreamer *createELFStreamer(MCContext &Ctx, MCTargetStreamer *TargetStreamer, + MCAsmBackend &TAB, raw_ostream &OS, + MCCodeEmitter *CE, bool RelaxAll, bool NoExecStack); /// createPureStreamer - Create a machine code streamer which will generate diff --git a/include/llvm/Support/TargetRegistry.h b/include/llvm/Support/TargetRegistry.h index 05f7cf2..8c9a917 100644 --- a/include/llvm/Support/TargetRegistry.h +++ b/include/llvm/Support/TargetRegistry.h @@ -46,18 +46,18 @@ namespace llvm { class MCRelocationInfo; class MCTargetAsmParser; class TargetMachine; + class MCTargetStreamer; class TargetOptions; class raw_ostream; class formatted_raw_ostream; - MCStreamer *createAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS, - bool isVerboseAsm, + MCStreamer *createAsmStreamer(MCContext &Ctx, + MCTargetStreamer *TargetStreamer, + formatted_raw_ostream &OS, bool isVerboseAsm, bool useLoc, bool useCFI, bool useDwarfDirectory, - MCInstPrinter *InstPrint, - MCCodeEmitter *CE, - MCAsmBackend *TAB, - bool ShowInst); + MCInstPrinter *InstPrint, MCCodeEmitter *CE, + MCAsmBackend *TAB, bool ShowInst); MCRelocationInfo *createMCRelocationInfo(StringRef TT, MCContext &Ctx); @@ -235,10 +235,22 @@ namespace llvm { /// MCSymbolizer, if registered (default = llvm::createMCSymbolizer) MCSymbolizerCtorTy MCSymbolizerCtorFn; + static MCStreamer * + createDefaultAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS, + bool isVerboseAsm, bool useLoc, bool useCFI, + bool useDwarfDirectory, MCInstPrinter *InstPrint, + MCCodeEmitter *CE, MCAsmBackend *TAB, + bool ShowInst) { + return llvm::createAsmStreamer(Ctx, 0, OS, isVerboseAsm, useLoc, useCFI, + useDwarfDirectory, InstPrint, CE, TAB, + ShowInst); + } + public: - Target() : AsmStreamerCtorFn(llvm::createAsmStreamer), - MCRelocationInfoCtorFn(llvm::createMCRelocationInfo), - MCSymbolizerCtorFn(llvm::createMCSymbolizer) {} + Target() + : AsmStreamerCtorFn(createDefaultAsmStreamer), + MCRelocationInfoCtorFn(llvm::createMCRelocationInfo), + MCSymbolizerCtorFn(llvm::createMCSymbolizer) {} /// @name Target Information /// @{ @@ -816,7 +828,7 @@ namespace llvm { /// @param T - The target being registered. /// @param Fn - A function to construct an MCStreamer for the target. static void RegisterAsmStreamer(Target &T, Target::AsmStreamerCtorTy Fn) { - if (T.AsmStreamerCtorFn == createAsmStreamer) + if (T.AsmStreamerCtorFn == Target::createDefaultAsmStreamer) T.AsmStreamerCtorFn = Fn; } -- cgit v1.1 From e3c2f07005aa2e4c935adb65f7f3e0176810fe68 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 8 Oct 2013 17:44:56 +0000 Subject: IRBuilder: Downgrade InsertPointGuard's instruction pointer to a raw pointer. Sadly this loses the checking from AssertingVH, but apparently storing the end() of a BasicBlock into an AssertingVH has bad consequences as it's not really an instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192209 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IRBuilder.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IRBuilder.h b/include/llvm/IR/IRBuilder.h index 0adfbc4..e2aeed3 100644 --- a/include/llvm/IR/IRBuilder.h +++ b/include/llvm/IR/IRBuilder.h @@ -197,7 +197,7 @@ public: class InsertPointGuard { IRBuilderBase &Builder; AssertingVH Block; - AssertingVH Point; + BasicBlock::iterator Point; DebugLoc DbgLoc; InsertPointGuard(const InsertPointGuard &) LLVM_DELETED_FUNCTION; @@ -209,7 +209,7 @@ public: DbgLoc(B.getCurrentDebugLocation()) {} ~InsertPointGuard() { - Builder.restoreIP(InsertPoint(Block, BasicBlock::iterator(Point))); + Builder.restoreIP(InsertPoint(Block, Point)); Builder.SetCurrentDebugLocation(DbgLoc); } }; -- cgit v1.1 From d88ccb6480b65d7560bfc840b689fbc8f36501bf Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Tue, 8 Oct 2013 18:42:03 +0000 Subject: Move DIRef::getName out of line. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192214 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 506b84c..49b81e3 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -230,16 +230,7 @@ template class DIRef { public: T resolve(const DITypeIdentifierMap &Map) const; - StringRef getName() const { - if (!Val) - return StringRef(); - - if (const MDNode *MD = dyn_cast(Val)) - return T(MD).getName(); - - const MDString *MS = cast(Val); - return MS->getString(); - } + StringRef getName() const; operator Value *() const { return const_cast(Val); } }; @@ -260,6 +251,18 @@ T DIRef::resolve(const DITypeIdentifierMap &Map) const { return T(Iter->second); } +template +StringRef DIRef::getName() const { + if (!Val) + return StringRef(); + + if (const MDNode *MD = dyn_cast(Val)) + return T(MD).getName(); + + const MDString *MS = cast(Val); + return MS->getString(); +} + /// Specialize getFieldAs to handle fields that are references to DIScopes. template <> DIScopeRef DIDescriptor::getFieldAs(unsigned Elt) const; /// Specialize DIRef constructor for DIScopeRef. -- cgit v1.1 From 73f615b0bd822db3a2a8aab2fd4ed58f093c9769 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Tue, 8 Oct 2013 20:15:11 +0000 Subject: Explicitly request unsigned enum types when desired This fixes repeated -Wmicrosoft warnings when self-hosting clang on Windows, and gets us real unsigned enum types with MSVC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192227 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/ScheduleDAG.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/ScheduleDAG.h b/include/llvm/CodeGen/ScheduleDAG.h index 371ac6c..ccba1b0 100644 --- a/include/llvm/CodeGen/ScheduleDAG.h +++ b/include/llvm/CodeGen/ScheduleDAG.h @@ -248,7 +248,7 @@ namespace llvm { /// SUnit - Scheduling unit. This is a node in the scheduling DAG. class SUnit { private: - enum { BoundaryID = ~0u }; + enum LLVM_ENUM_INT_TYPE(unsigned) { BoundaryID = ~0u }; SDNode *Node; // Representative node. MachineInstr *Instr; // Alternatively, a MachineInstr. -- cgit v1.1 From 3dfe644f7b6a560e1991b03d8c419c973ac7ed8d Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Tue, 8 Oct 2013 20:43:30 +0000 Subject: [AArch64] Add support for NEON scalar signed/unsigned integer to floating-point convert instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192231 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 526ebef..52810be 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -152,4 +152,16 @@ def int_aarch64_neon_vpfminnm : Intrinsic<[llvm_v1f32_ty], [llvm_v2f32_ty], [IntrNoMem]>; def int_aarch64_neon_vpfminnmq : Intrinsic<[llvm_v1f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; + +// Scalar Signed Integer Convert To Floating-point +def int_aarch64_neon_vcvtf32_s32 : + Intrinsic<[llvm_v1f32_ty], [llvm_v1i32_ty], [IntrNoMem]>; +def int_aarch64_neon_vcvtf64_s64 : + Intrinsic<[llvm_v1f64_ty], [llvm_v1i64_ty], [IntrNoMem]>; + +// Scalar Unsigned Integer Convert To Floating-point +def int_aarch64_neon_vcvtf32_u32 : + Intrinsic<[llvm_v1f32_ty], [llvm_v1i32_ty], [IntrNoMem]>; +def int_aarch64_neon_vcvtf64_u64 : + Intrinsic<[llvm_v1f64_ty], [llvm_v1i64_ty], [IntrNoMem]>; } -- cgit v1.1 From 25180dc319774a68d8aa8c3264e3ce63b8e01f00 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Tue, 8 Oct 2013 21:11:12 +0000 Subject: Fix duplicated assertions. Do what some other instructions do, and add an assert method. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192236 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Instructions.h | 48 ++++++++++++++++++------------------------ 1 file changed, 21 insertions(+), 27 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/Instructions.h b/include/llvm/IR/Instructions.h index 6adee6a..4c21bc0 100644 --- a/include/llvm/IR/Instructions.h +++ b/include/llvm/IR/Instructions.h @@ -909,6 +909,18 @@ DEFINE_TRANSPARENT_OPERAND_ACCESSORS(GetElementPtrInst, Value) /// must be identical types. /// \brief Represent an integer comparison operator. class ICmpInst: public CmpInst { + void AssertOK() { + assert(getPredicate() >= CmpInst::FIRST_ICMP_PREDICATE && + getPredicate() <= CmpInst::LAST_ICMP_PREDICATE && + "Invalid ICmp predicate value"); + assert(getOperand(0)->getType() == getOperand(1)->getType() && + "Both operands to ICmp instruction are not of the same type!"); + // Check that the operands are the right type + assert((getOperand(0)->getType()->isIntOrIntVectorTy() || + getOperand(0)->getType()->isPtrOrPtrVectorTy()) && + "Invalid operand types for ICmp instruction"); + } + protected: /// \brief Clone an identical ICmpInst virtual ICmpInst *clone_impl() const; @@ -923,15 +935,9 @@ public: ) : CmpInst(makeCmpResultType(LHS->getType()), Instruction::ICmp, pred, LHS, RHS, NameStr, InsertBefore) { - assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && - pred <= CmpInst::LAST_ICMP_PREDICATE && - "Invalid ICmp predicate value"); - assert(getOperand(0)->getType() == getOperand(1)->getType() && - "Both operands to ICmp instruction are not of the same type!"); - // Check that the operands are the right type - assert((getOperand(0)->getType()->isIntOrIntVectorTy() || - getOperand(0)->getType()->getScalarType()->isPointerTy()) && - "Invalid operand types for ICmp instruction"); +#ifndef NDEBUG + AssertOK(); +#endif } /// \brief Constructor with insert-at-end semantics. @@ -944,15 +950,9 @@ public: ) : CmpInst(makeCmpResultType(LHS->getType()), Instruction::ICmp, pred, LHS, RHS, NameStr, &InsertAtEnd) { - assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && - pred <= CmpInst::LAST_ICMP_PREDICATE && - "Invalid ICmp predicate value"); - assert(getOperand(0)->getType() == getOperand(1)->getType() && - "Both operands to ICmp instruction are not of the same type!"); - // Check that the operands are the right type - assert((getOperand(0)->getType()->isIntOrIntVectorTy() || - getOperand(0)->getType()->getScalarType()->isPointerTy()) && - "Invalid operand types for ICmp instruction"); +#ifndef NDEBUG + AssertOK(); +#endif } /// \brief Constructor with no-insertion semantics @@ -963,15 +963,9 @@ public: const Twine &NameStr = "" ///< Name of the instruction ) : CmpInst(makeCmpResultType(LHS->getType()), Instruction::ICmp, pred, LHS, RHS, NameStr) { - assert(pred >= CmpInst::FIRST_ICMP_PREDICATE && - pred <= CmpInst::LAST_ICMP_PREDICATE && - "Invalid ICmp predicate value"); - assert(getOperand(0)->getType() == getOperand(1)->getType() && - "Both operands to ICmp instruction are not of the same type!"); - // Check that the operands are the right type - assert((getOperand(0)->getType()->isIntOrIntVectorTy() || - getOperand(0)->getType()->getScalarType()->isPointerTy()) && - "Invalid operand types for ICmp instruction"); +#ifndef NDEBUG + AssertOK(); +#endif } /// For example, EQ->EQ, SLE->SLE, UGT->SGT, etc. -- cgit v1.1 From c97650079383110d66ab104ee60d03ded2be8e35 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Tue, 8 Oct 2013 22:09:04 +0000 Subject: [AArch64] Add support for NEON scalar floating-point reciprocal estimate, reciprocal exponent, and reciprocal square root estimate instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192242 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 52810be..8fcef7f 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -164,4 +164,7 @@ def int_aarch64_neon_vcvtf32_u32 : Intrinsic<[llvm_v1f32_ty], [llvm_v1i32_ty], [IntrNoMem]>; def int_aarch64_neon_vcvtf64_u64 : Intrinsic<[llvm_v1f64_ty], [llvm_v1i64_ty], [IntrNoMem]>; + +// Scalar Floating-point Reciprocal Exponent +def int_aarch64_neon_vrecpx : Neon_1Arg_Intrinsic; } -- cgit v1.1 From 50dc2ad46ca9a5391bc75c9e3620337afefb995c Mon Sep 17 00:00:00 2001 From: Elena Demikhovsky Date: Wed, 9 Oct 2013 08:16:14 +0000 Subject: AVX-512: Added VRCP28 and VRSQRT28 instructions and intrinsics. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192283 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 55 +++++++++++++++++++++++++++++----------- 1 file changed, 40 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index bd22e1b..54ea37e 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -2745,29 +2745,54 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx512_sqrt_ps_512 : GCCBuiltin<"__builtin_ia32_sqrtps512">, Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty], [IntrNoMem]>; - def int_x86_avx512_rcp14_ps_512 : GCCBuiltin<"__builtin_ia32_avx512_rcp14ps512">, + def int_x86_avx512_rcp14_ps_512 : GCCBuiltin<"__builtin_ia32_rcp14ps512">, Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty], [IntrNoMem]>; - def int_x86_avx512_rcp14_pd_512 : GCCBuiltin<"__builtin_ia32_avx512_rcp14pd512">, + def int_x86_avx512_rcp14_pd_512 : GCCBuiltin<"__builtin_ia32_rcp14pd512">, Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty], [IntrNoMem]>; - def int_x86_avx512_rcp14_ss : GCCBuiltin<"__builtin_ia32_avx512_rcp14ss">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], + def int_x86_avx512_rcp14_ss : GCCBuiltin<"__builtin_ia32_rcp14ss">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], [IntrNoMem]>; - def int_x86_avx512_rcp14_sd : GCCBuiltin<"__builtin_ia32_avx512_rcp14sd">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], + def int_x86_avx512_rcp14_sd : GCCBuiltin<"__builtin_ia32_rcp14sd">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; - def int_x86_avx512_rsqrt14_ps_512 : GCCBuiltin<"__builtin_ia32_avx512_rsqrt14ps512">, + def int_x86_avx512_rsqrt14_ps_512 : GCCBuiltin<"__builtin_ia32_rsqrt14ps512">, Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty], [IntrNoMem]>; - def int_x86_avx512_rsqrt14_pd_512 : GCCBuiltin<"__builtin_ia32_avx512_rsqrt14pd512">, + def int_x86_avx512_rsqrt14_pd_512 : GCCBuiltin<"__builtin_ia32_rsqrt14pd512">, Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty], [IntrNoMem]>; - def int_x86_avx512_rsqrt14_ss : GCCBuiltin<"__builtin_ia32_avx512_rsqrt14ss">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty], + def int_x86_avx512_rsqrt14_ss : GCCBuiltin<"__builtin_ia32_rsqrt14ss">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], [IntrNoMem]>; - def int_x86_avx512_rsqrt14_sd : GCCBuiltin<"__builtin_ia32_avx512_rsqrt14sd">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], + def int_x86_avx512_rsqrt14_sd : GCCBuiltin<"__builtin_ia32_rsqrt14sd">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], + [IntrNoMem]>; + + def int_x86_avx512_rcp28_ps_512 : GCCBuiltin<"__builtin_ia32_rcp28ps512">, + Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty], + [IntrNoMem]>; + def int_x86_avx512_rcp28_pd_512 : GCCBuiltin<"__builtin_ia32_rcp28pd512">, + Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty], + [IntrNoMem]>; + def int_x86_avx512_rcp28_ss : GCCBuiltin<"__builtin_ia32_rcp28ss">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], + [IntrNoMem]>; + def int_x86_avx512_rcp28_sd : GCCBuiltin<"__builtin_ia32_rcp28sd">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], + [IntrNoMem]>; + def int_x86_avx512_rsqrt28_ps_512 : GCCBuiltin<"__builtin_ia32_rsqrt28ps512">, + Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty], + [IntrNoMem]>; + def int_x86_avx512_rsqrt28_pd_512 : GCCBuiltin<"__builtin_ia32_rsqrt28pd512">, + Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty], + [IntrNoMem]>; + def int_x86_avx512_rsqrt28_ss : GCCBuiltin<"__builtin_ia32_rsqrt28ss">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty], + [IntrNoMem]>; + def int_x86_avx512_rsqrt28_sd : GCCBuiltin<"__builtin_ia32_rsqrt28sd">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; } @@ -2910,14 +2935,14 @@ let TargetPrefix = "x86" in { } let TargetPrefix = "x86" in { - def int_x86_avx512_mskblend_ps_512 : GCCBuiltin<"__builtin_ia32_avx512_mskblendps512">, + def int_x86_avx512_mskblend_ps_512 : GCCBuiltin<"__builtin_ia32_mskblendps512">, Intrinsic<[llvm_v16f32_ty], [llvm_i16_ty, llvm_v16f32_ty, llvm_v16f32_ty], [IntrNoMem]>; - def int_x86_avx512_cmpeq_pi_512 : GCCBuiltin<"__builtin_ia32_avx512_cmpeqpi512">, + def int_x86_avx512_cmpeq_pi_512 : GCCBuiltin<"__builtin_ia32_cmpeqpi512">, Intrinsic<[llvm_i16_ty], [llvm_v16i32_ty, llvm_v16i32_ty], [IntrNoMem]>; - def int_x86_avx512_and_pi : GCCBuiltin<"__builtin_ia32_avx512_andpi512">, + def int_x86_avx512_and_pi : GCCBuiltin<"__builtin_ia32_andpi512">, Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i32_ty], [IntrNoMem]>; } -- cgit v1.1 From 1a525e8c80305777e3ca0cba0e1903fdbf04aa86 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 9 Oct 2013 16:07:32 +0000 Subject: Add a GlobalAlias::isValidLinkage to reduce code duplication. Thanks to Reid Kleckner for the suggestion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192298 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/GlobalAlias.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/GlobalAlias.h b/include/llvm/IR/GlobalAlias.h index e09fb6a..fec61a7 100644 --- a/include/llvm/IR/GlobalAlias.h +++ b/include/llvm/IR/GlobalAlias.h @@ -81,6 +81,11 @@ public: return const_cast(this)->resolveAliasedGlobal(stopOnWeak); } + static bool isValidLinkage(LinkageTypes L) { + return isExternalLinkage(L) || isLocalLinkage(L) || + isWeakLinkage(L) || isLinkOnceLinkage(L); + } + // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const Value *V) { return V->getValueID() == Value::GlobalAliasVal; -- cgit v1.1 From 3353c592de08c4a7b7b282714b8044d7cfc4c6ad Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 9 Oct 2013 17:23:41 +0000 Subject: Flip the ownership of MCStreamer and MCTargetStreamer. MCStreamer now owns the target streamer. This prevents leaking the target streamer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192303 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCStreamer.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 10fc69e..d24f3fd 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -66,11 +66,11 @@ typedef std::pair MCSectionSubPair; /// be treated differently. Callers should always talk to a FooTargetStreamer. class MCTargetStreamer { protected: - OwningPtr Streamer; + MCStreamer *Streamer; public: virtual ~MCTargetStreamer(); - void setStreamer(MCStreamer *S) { Streamer.reset(S); } + void setStreamer(MCStreamer *S) { Streamer = S; } }; // FIXME: declared here because it is used from @@ -100,7 +100,7 @@ public: /// class MCStreamer { MCContext &Context; - MCTargetStreamer *TargetStreamer; + OwningPtr TargetStreamer; MCStreamer(const MCStreamer &) LLVM_DELETED_FUNCTION; MCStreamer &operator=(const MCStreamer &) LLVM_DELETED_FUNCTION; -- cgit v1.1 From 9360e64e60f600bff98dbff96fabaab536947f86 Mon Sep 17 00:00:00 2001 From: Anders Waldenborg Date: Wed, 9 Oct 2013 19:02:09 +0000 Subject: llvm-c: Make target initializer functions external functions in lib. Making them proper functions defined in the (shared)lib instead of static inlines defined in the header files makes it possible to actually distribute a binary compiled against the shared library without having to worry about getting undefined symbol errors when calling e.g LLVMInitializeAllTargetInfos because the shared library on the other system was compiled with different targets. Differential Revision: http://llvm-reviews.chandlerc.com/D1714 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192316 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Target.h | 47 +++++++++++------------------------------------ 1 file changed, 11 insertions(+), 36 deletions(-) (limited to 'include') diff --git a/include/llvm-c/Target.h b/include/llvm-c/Target.h index 80fc3e5..1d7884f 100644 --- a/include/llvm-c/Target.h +++ b/include/llvm-c/Target.h @@ -71,62 +71,37 @@ typedef struct LLVMStructLayout *LLVMStructLayoutRef; void LLVMInitialize##TargetName##Disassembler(void); #include "llvm/Config/Disassemblers.def" #undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */ - + /** LLVMInitializeAllTargetInfos - The main program should call this function if it wants access to all available targets that LLVM is configured to support. */ -static inline void LLVMInitializeAllTargetInfos(void) { -#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo(); -#include "llvm/Config/Targets.def" -#undef LLVM_TARGET /* Explicit undef to make SWIG happier */ -} +void LLVMInitializeAllTargetInfos(void); /** LLVMInitializeAllTargets - The main program should call this function if it wants to link in all available targets that LLVM is configured to support. */ -static inline void LLVMInitializeAllTargets(void) { -#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target(); -#include "llvm/Config/Targets.def" -#undef LLVM_TARGET /* Explicit undef to make SWIG happier */ -} +void LLVMInitializeAllTargets(void); /** LLVMInitializeAllTargetMCs - The main program should call this function if it wants access to all available target MC that LLVM is configured to support. */ -static inline void LLVMInitializeAllTargetMCs(void) { -#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC(); -#include "llvm/Config/Targets.def" -#undef LLVM_TARGET /* Explicit undef to make SWIG happier */ -} - +void LLVMInitializeAllTargetMCs(void); + /** LLVMInitializeAllAsmPrinters - The main program should call this function if it wants all asm printers that LLVM is configured to support, to make them available via the TargetRegistry. */ -static inline void LLVMInitializeAllAsmPrinters(void) { -#define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter(); -#include "llvm/Config/AsmPrinters.def" -#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */ -} - +void LLVMInitializeAllAsmPrinters(void); + /** LLVMInitializeAllAsmParsers - The main program should call this function if it wants all asm parsers that LLVM is configured to support, to make them available via the TargetRegistry. */ -static inline void LLVMInitializeAllAsmParsers(void) { -#define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser(); -#include "llvm/Config/AsmParsers.def" -#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */ -} - +void LLVMInitializeAllAsmParsers(void); + /** LLVMInitializeAllDisassemblers - The main program should call this function if it wants all disassemblers that LLVM is configured to support, to make them available via the TargetRegistry. */ -static inline void LLVMInitializeAllDisassemblers(void) { -#define LLVM_DISASSEMBLER(TargetName) \ - LLVMInitialize##TargetName##Disassembler(); -#include "llvm/Config/Disassemblers.def" -#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */ -} - +void LLVMInitializeAllDisassemblers(void); + /** LLVMInitializeNativeTarget - The main program should call this function to initialize the native target corresponding to the host. This is useful for JIT applications to ensure that the target gets linked in correctly. */ -- cgit v1.1 From b4d9c11f6c7e0a38e750f946d5cea3ffa5ae8f61 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Wed, 9 Oct 2013 19:46:28 +0000 Subject: Debug Info: In DIBuilder, the context and type fields of template_type and template_value are updated to use DIRef. A paired commit at clang is required due to changes to DIBuilder. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192320 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 49b81e3..3f1c1c8 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -539,9 +539,9 @@ class DITemplateTypeParameter : public DIDescriptor { public: explicit DITemplateTypeParameter(const MDNode *N = 0) : DIDescriptor(N) {} - DIScope getContext() const { return getFieldAs(1); } + DIScopeRef getContext() const { return getFieldAs(1); } StringRef getName() const { return getStringField(2); } - DIType getType() const { return getFieldAs(3); } + DITypeRef getType() const { return getFieldAs(3); } StringRef getFilename() const { return getFieldAs(4).getFilename(); } StringRef getDirectory() const { return getFieldAs(4).getDirectory(); @@ -556,9 +556,9 @@ class DITemplateValueParameter : public DIDescriptor { public: explicit DITemplateValueParameter(const MDNode *N = 0) : DIDescriptor(N) {} - DIScope getContext() const { return getFieldAs(1); } + DIScopeRef getContext() const { return getFieldAs(1); } StringRef getName() const { return getStringField(2); } - DIType getType() const { return getFieldAs(3); } + DITypeRef getType() const { return getFieldAs(3); } Value *getValue() const; StringRef getFilename() const { return getFieldAs(5).getFilename(); } StringRef getDirectory() const { -- cgit v1.1 From 6bba6bb12f020206baf242ca6b76e1609cdf0d4b Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 9 Oct 2013 23:15:49 +0000 Subject: Revert "llvm-c: Make target initializer functions external functions in lib." This reverts commit r192316. The original change introduced circular dependencies between libTarget and backends. That would broke a build unless link everything into one big binary. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192329 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Target.h | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/llvm-c/Target.h b/include/llvm-c/Target.h index 1d7884f..80fc3e5 100644 --- a/include/llvm-c/Target.h +++ b/include/llvm-c/Target.h @@ -71,37 +71,62 @@ typedef struct LLVMStructLayout *LLVMStructLayoutRef; void LLVMInitialize##TargetName##Disassembler(void); #include "llvm/Config/Disassemblers.def" #undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */ - + /** LLVMInitializeAllTargetInfos - The main program should call this function if it wants access to all available targets that LLVM is configured to support. */ -void LLVMInitializeAllTargetInfos(void); +static inline void LLVMInitializeAllTargetInfos(void) { +#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo(); +#include "llvm/Config/Targets.def" +#undef LLVM_TARGET /* Explicit undef to make SWIG happier */ +} /** LLVMInitializeAllTargets - The main program should call this function if it wants to link in all available targets that LLVM is configured to support. */ -void LLVMInitializeAllTargets(void); +static inline void LLVMInitializeAllTargets(void) { +#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target(); +#include "llvm/Config/Targets.def" +#undef LLVM_TARGET /* Explicit undef to make SWIG happier */ +} /** LLVMInitializeAllTargetMCs - The main program should call this function if it wants access to all available target MC that LLVM is configured to support. */ -void LLVMInitializeAllTargetMCs(void); - +static inline void LLVMInitializeAllTargetMCs(void) { +#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC(); +#include "llvm/Config/Targets.def" +#undef LLVM_TARGET /* Explicit undef to make SWIG happier */ +} + /** LLVMInitializeAllAsmPrinters - The main program should call this function if it wants all asm printers that LLVM is configured to support, to make them available via the TargetRegistry. */ -void LLVMInitializeAllAsmPrinters(void); - +static inline void LLVMInitializeAllAsmPrinters(void) { +#define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter(); +#include "llvm/Config/AsmPrinters.def" +#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */ +} + /** LLVMInitializeAllAsmParsers - The main program should call this function if it wants all asm parsers that LLVM is configured to support, to make them available via the TargetRegistry. */ -void LLVMInitializeAllAsmParsers(void); - +static inline void LLVMInitializeAllAsmParsers(void) { +#define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser(); +#include "llvm/Config/AsmParsers.def" +#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */ +} + /** LLVMInitializeAllDisassemblers - The main program should call this function if it wants all disassemblers that LLVM is configured to support, to make them available via the TargetRegistry. */ -void LLVMInitializeAllDisassemblers(void); - +static inline void LLVMInitializeAllDisassemblers(void) { +#define LLVM_DISASSEMBLER(TargetName) \ + LLVMInitialize##TargetName##Disassembler(); +#include "llvm/Config/Disassemblers.def" +#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */ +} + /** LLVMInitializeNativeTarget - The main program should call this function to initialize the native target corresponding to the host. This is useful for JIT applications to ensure that the target gets linked in correctly. */ -- cgit v1.1 From d622bef31d11a5a6429fe7fad557c9b111e96f69 Mon Sep 17 00:00:00 2001 From: Hao Liu Date: Thu, 10 Oct 2013 15:01:24 +0000 Subject: Implement AArch64 vector load/store multiple N-element structure class SIMD(lselem). Including following 14 instructions: 4 ld1 insts: load multiple 1-element structure to sequential 1/2/3/4 registers. ld2/ld3/ld4: load multiple N-element structure to sequential N registers (N=2,3,4). 4 st1 insts: store multiple 1-element structure from sequential 1/2/3/4 registers. st2/st3/st4: store multiple N-element structure from sequential N registers (N = 2,3,4). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192352 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/ValueTypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h index 2e8f637..79f3233 100644 --- a/include/llvm/CodeGen/ValueTypes.h +++ b/include/llvm/CodeGen/ValueTypes.h @@ -208,7 +208,7 @@ namespace llvm { bool is64BitVector() const { return (SimpleTy == MVT::v8i8 || SimpleTy == MVT::v4i16 || SimpleTy == MVT::v2i32 || SimpleTy == MVT::v1i64 || - SimpleTy == MVT::v2f32); + SimpleTy == MVT::v1f64 || SimpleTy == MVT::v2f32); } /// is128BitVector - Return true if this is a 128-bit vector type. -- cgit v1.1 From 812ddcc50f8bc3ec6ce115863ff2263815906aaf Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 10 Oct 2013 15:15:17 +0000 Subject: Revert "Implement AArch64 vector load/store multiple N-element structure class SIMD(lselem). Including following 14 instructions: 4 ld1 insts: load multiple 1-element structure to sequential 1/2/3/4 registers. ld2/ld3/ld4: load multiple N-element structure to sequential N registers (N=2,3,4). 4 st1 insts: store multiple 1-element structure from sequential 1/2/3/4 registers. st2/st3/st4: store multiple N-element structure from sequential N registers (N = 2,3,4)." This reverts commit r192352. It broke the build. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192354 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/ValueTypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h index 79f3233..2e8f637 100644 --- a/include/llvm/CodeGen/ValueTypes.h +++ b/include/llvm/CodeGen/ValueTypes.h @@ -208,7 +208,7 @@ namespace llvm { bool is64BitVector() const { return (SimpleTy == MVT::v8i8 || SimpleTy == MVT::v4i16 || SimpleTy == MVT::v2i32 || SimpleTy == MVT::v1i64 || - SimpleTy == MVT::v1f64 || SimpleTy == MVT::v2f32); + SimpleTy == MVT::v2f32); } /// is128BitVector - Return true if this is a 128-bit vector type. -- cgit v1.1 From 6a5a667517160ca1b557002a29d08868ae029451 Mon Sep 17 00:00:00 2001 From: Hao Liu Date: Thu, 10 Oct 2013 17:00:52 +0000 Subject: Implement AArch64 vector load/store multiple N-element structure class SIMD(lselem). Including following 14 instructions: 4 ld1 insts: load multiple 1-element structure to sequential 1/2/3/4 registers. ld2/ld3/ld4: load multiple N-element structure to sequential N registers (N=2,3,4). 4 st1 insts: store multiple 1-element structure from sequential 1/2/3/4 registers. st2/st3/st4: store multiple N-element structure from sequential N registers (N = 2,3,4). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192361 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/ValueTypes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/ValueTypes.h b/include/llvm/CodeGen/ValueTypes.h index 2e8f637..79f3233 100644 --- a/include/llvm/CodeGen/ValueTypes.h +++ b/include/llvm/CodeGen/ValueTypes.h @@ -208,7 +208,7 @@ namespace llvm { bool is64BitVector() const { return (SimpleTy == MVT::v8i8 || SimpleTy == MVT::v4i16 || SimpleTy == MVT::v2i32 || SimpleTy == MVT::v1i64 || - SimpleTy == MVT::v2f32); + SimpleTy == MVT::v1f64 || SimpleTy == MVT::v2f32); } /// is128BitVector - Return true if this is a 128-bit vector type. -- cgit v1.1 From b8e48a636e7ee6c13140382eb93d9695a65b0624 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Thu, 10 Oct 2013 18:40:01 +0000 Subject: Debug Info: In DIBuilder, the context field of subprogram is updated to use DIScopeRef. A paired commit at clang is required due to changes to DIBuilder. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192378 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DIBuilder.h | 14 ++++++++++++++ include/llvm/DebugInfo.h | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/DIBuilder.h b/include/llvm/DIBuilder.h index 39ff317..44ce3e4 100644 --- a/include/llvm/DIBuilder.h +++ b/include/llvm/DIBuilder.h @@ -562,6 +562,20 @@ namespace llvm { MDNode *TParam = 0, MDNode *Decl = 0); + /// FIXME: this is added for dragonegg. Once we update dragonegg + /// to call resolve function, this will be removed. + DISubprogram createFunction(DIScopeRef Scope, StringRef Name, + StringRef LinkageName, + DIFile File, unsigned LineNo, + DICompositeType Ty, bool isLocalToUnit, + bool isDefinition, + unsigned ScopeLine, + unsigned Flags = 0, + bool isOptimized = false, + Function *Fn = 0, + MDNode *TParam = 0, + MDNode *Decl = 0); + /// createMethod - Create a new descriptor for the specified C++ method. /// See comments in DISubprogram for descriptions of these fields. /// @param Scope Function scope. diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 3f1c1c8..3e4a960 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -434,7 +434,7 @@ class DISubprogram : public DIScope { public: explicit DISubprogram(const MDNode *N = 0) : DIScope(N) {} - DIScope getContext() const { return getFieldAs(2); } + DIScopeRef getContext() const { return getFieldAs(2); } StringRef getName() const { return getStringField(3); } StringRef getDisplayName() const { return getStringField(4); } StringRef getLinkageName() const { return getStringField(5); } -- cgit v1.1 From 89dedc1b65cb09a652d251273e2eae938dead60b Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Thu, 10 Oct 2013 18:47:35 +0000 Subject: Fix grammar / missing words git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192380 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetOpcodes.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Target/TargetOpcodes.h b/include/llvm/Target/TargetOpcodes.h index 516e070..86ac7df 100644 --- a/include/llvm/Target/TargetOpcodes.h +++ b/include/llvm/Target/TargetOpcodes.h @@ -69,8 +69,9 @@ namespace TargetOpcode { DBG_VALUE = 11, /// REG_SEQUENCE - This variadic instruction is used to form a register that - /// represent a consecutive sequence of sub-registers. It's used as register - /// coalescing / allocation aid and must be eliminated before code emission. + /// represents a consecutive sequence of sub-registers. It's used as a + /// register coalescing / allocation aid and must be eliminated before code + /// emission. // In SDNode form, the first operand encodes the register class created by // the REG_SEQUENCE, while each subsequent pair names a vreg + subreg index // pair. Once it has been lowered to a MachineInstr, the regclass operand -- cgit v1.1 From 4d91232df1f385f0f89c767f1d297b1088f26f67 Mon Sep 17 00:00:00 2001 From: Sriram Murali Date: Thu, 10 Oct 2013 20:24:53 +0000 Subject: test commit - fix comments on vector type legalization git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192389 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLowering.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index cd95a73..0130e07 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -1473,10 +1473,12 @@ public: if (NumElts == 1) return LegalizeKind(TypeScalarizeVector, EltVT); - // Try to widen vector elements until a legal type is found. + // Try to widen vector elements until the element type is a power of two and + // promote it to a legal type later on, for example: + // <3 x i8> -> <4 x i8> -> <4 x i32> if (EltVT.isInteger()) { // Vectors with a number of elements that is not a power of two are always - // widened, for example <3 x float> -> <4 x float>. + // widened, for example <3 x i8> -> <4 x i8>. if (!VT.isPow2VectorType()) { NumElts = (unsigned)NextPowerOf2(NumElts); EVT NVT = EVT::getVectorVT(Context, EltVT, NumElts); -- cgit v1.1 From 4afb5f560d2c3171eda8be6ae64998080dddec0c Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Thu, 10 Oct 2013 21:28:38 +0000 Subject: Rename parameter: defined regs are not incoming. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192391 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineInstr.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineInstr.h b/include/llvm/CodeGen/MachineInstr.h index e1349a6..cccab81 100644 --- a/include/llvm/CodeGen/MachineInstr.h +++ b/include/llvm/CodeGen/MachineInstr.h @@ -893,13 +893,12 @@ public: /// Look for the operand that defines it and mark it as IsDead. If /// AddIfNotFound is true, add a implicit operand if it's not found. Returns /// true if the operand exists / is added. - bool addRegisterDead(unsigned IncomingReg, const TargetRegisterInfo *RegInfo, + bool addRegisterDead(unsigned Reg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound = false); /// addRegisterDefined - We have determined MI defines a register. Make sure /// there is an operand defining Reg. - void addRegisterDefined(unsigned IncomingReg, - const TargetRegisterInfo *RegInfo = 0); + void addRegisterDefined(unsigned Reg, const TargetRegisterInfo *RegInfo = 0); /// setPhysRegsDeadExcept - Mark every physreg used by this instruction as /// dead except those in the UsedRegs list. -- cgit v1.1 From 331de11a0acc6a095b98914b5f05ff242c9d7819 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Thu, 10 Oct 2013 21:28:43 +0000 Subject: Rename LiveRange to LiveInterval::Segment The Segment struct contains a single interval; multiple instances of this struct are used to construct a live range, but the struct is not a live range by itself. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192392 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveInterval.h | 243 ++++++++++++++-------------- include/llvm/CodeGen/LiveIntervalAnalysis.h | 8 +- include/llvm/CodeGen/LiveIntervalUnion.h | 2 +- 3 files changed, 124 insertions(+), 129 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index 005b154..f194161 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -7,14 +7,14 @@ // //===----------------------------------------------------------------------===// // -// This file implements the LiveRange and LiveInterval classes. Given some -// numbering of each the machine instructions an interval [i, j) is said to be a +// This file implements the LiveInterval class. Given some numbering of each +// the machine instructions an interval [i, j) is said to be a // live interval for register v if there is no instruction with number j' >= j // such that v is live at j' and there is no instruction with number i' < i such // that v is live at i'. In this implementation intervals can have holes, // i.e. an interval might look like [1,20), [50,65), [1000,1001). Each -// individual range is represented as an instance of LiveRange, and the whole -// interval is represented as an instance of LiveInterval. +// individual segment is represented as an instance of LiveInterval::Segment, +// and the whole range is represented as an instance of LiveInterval. // //===----------------------------------------------------------------------===// @@ -78,82 +78,66 @@ namespace llvm { void markUnused() { def = SlotIndex(); } }; - /// LiveRange structure - This represents a simple register range in the - /// program, with an inclusive start point and an exclusive end point. - /// These ranges are rendered as [start,end). - struct LiveRange { - SlotIndex start; // Start point of the interval (inclusive) - SlotIndex end; // End point of the interval (exclusive) - VNInfo *valno; // identifier for the value contained in this interval. - - LiveRange() : valno(0) {} - - LiveRange(SlotIndex S, SlotIndex E, VNInfo *V) - : start(S), end(E), valno(V) { - assert(S < E && "Cannot create empty or backwards range"); - } - - /// contains - Return true if the index is covered by this range. - /// - bool contains(SlotIndex I) const { - return start <= I && I < end; - } - - /// containsRange - Return true if the given range, [S, E), is covered by - /// this range. - bool containsRange(SlotIndex S, SlotIndex E) const { - assert((S < E) && "Backwards interval?"); - return (start <= S && S < end) && (start < E && E <= end); - } - - bool operator<(const LiveRange &LR) const { - return start < LR.start || (start == LR.start && end < LR.end); - } - bool operator==(const LiveRange &LR) const { - return start == LR.start && end == LR.end; - } + /// LiveInterval - This class represents some number of live segments for a + /// register or value. This class also contains a bit of register allocator + /// state. + class LiveInterval { + public: - void dump() const; - void print(raw_ostream &os) const; - }; + /// This represents a simple continuous liveness interval for a value. + /// The start point is inclusive, the end point exclusive. These intervals + /// are rendered as [start,end). + struct Segment { + SlotIndex start; // Start point of the interval (inclusive) + SlotIndex end; // End point of the interval (exclusive) + VNInfo *valno; // identifier for the value contained in this segment. - template <> struct isPodLike { static const bool value = true; }; + Segment() : valno(0) {} - raw_ostream& operator<<(raw_ostream& os, const LiveRange &LR); + Segment(SlotIndex S, SlotIndex E, VNInfo *V) + : start(S), end(E), valno(V) { + assert(S < E && "Cannot create empty or backwards segment"); + } + /// Return true if the index is covered by this segment. + bool contains(SlotIndex I) const { + return start <= I && I < end; + } - inline bool operator<(SlotIndex V, const LiveRange &LR) { - return V < LR.start; - } + /// Return true if the given interval, [S, E), is covered by this segment. + bool containsInterval(SlotIndex S, SlotIndex E) const { + assert((S < E) && "Backwards interval?"); + return (start <= S && S < end) && (start < E && E <= end); + } - inline bool operator<(const LiveRange &LR, SlotIndex V) { - return LR.start < V; - } + bool operator<(const Segment &Other) const { + return start < Other.start || (start == Other.start && end < Other.end); + } + bool operator==(const Segment &Other) const { + return start == Other.start && end == Other.end; + } - /// LiveInterval - This class represents some number of live ranges for a - /// register or value. This class also contains a bit of register allocator - /// state. - class LiveInterval { - public: + void dump() const; + }; - typedef SmallVector Ranges; + typedef SmallVector Segments; typedef SmallVector VNInfoList; const unsigned reg; // the register or stack slot of this interval. float weight; // weight of this interval - Ranges ranges; // the ranges in which this register is live + Segments segments; // the segments in which this register is live VNInfoList valnos; // value#'s LiveInterval(unsigned Reg, float Weight) : reg(Reg), weight(Weight) {} - typedef Ranges::iterator iterator; - iterator begin() { return ranges.begin(); } - iterator end() { return ranges.end(); } + typedef Segments::iterator iterator; + iterator begin() { return segments.begin(); } + iterator end() { return segments.end(); } - typedef Ranges::const_iterator const_iterator; - const_iterator begin() const { return ranges.begin(); } - const_iterator end() const { return ranges.end(); } + typedef Segments::const_iterator const_iterator; + const_iterator begin() const { return segments.begin(); } + const_iterator end() const { return segments.end(); } typedef VNInfoList::iterator vni_iterator; vni_iterator vni_begin() { return valnos.begin(); } @@ -163,11 +147,11 @@ namespace llvm { const_vni_iterator vni_begin() const { return valnos.begin(); } const_vni_iterator vni_end() const { return valnos.end(); } - /// advanceTo - Advance the specified iterator to point to the LiveRange + /// advanceTo - Advance the specified iterator to point to the Segment /// containing the specified position, or end() if the position is past the - /// end of the interval. If no LiveRange contains this position, but the + /// end of the interval. If no Segment contains this position, but the /// position is in a hole, this method returns an iterator pointing to the - /// LiveRange immediately after the hole. + /// Segment immediately after the hole. iterator advanceTo(iterator I, SlotIndex Pos) { assert(I != end()); if (Pos >= endIndex()) @@ -176,12 +160,12 @@ namespace llvm { return I; } - /// find - Return an iterator pointing to the first range that ends after + /// find - Return an iterator pointing to the first segment that ends after /// Pos, or end(). This is the same as advanceTo(begin(), Pos), but faster /// when searching large intervals. /// - /// If Pos is contained in a LiveRange, that range is returned. - /// If Pos is in a hole, the following LiveRange is returned. + /// If Pos is contained in a Segment, that segment is returned. + /// If Pos is in a hole, the following Segment is returned. /// If Pos is beyond endIndex, end() is returned. iterator find(SlotIndex Pos); @@ -191,11 +175,11 @@ namespace llvm { void clear() { valnos.clear(); - ranges.clear(); + segments.clear(); } size_t size() const { - return ranges.size(); + return segments.size(); } bool hasAtLeastOneValue() const { return !valnos.empty(); } @@ -248,38 +232,38 @@ namespace llvm { /// MergeValueNumberInto - This method is called when two value numbers /// are found to be equivalent. This eliminates V1, replacing all - /// LiveRanges with the V1 value number with the V2 value number. This can + /// segments with the V1 value number with the V2 value number. This can /// cause merging of V1/V2 values numbers and compaction of the value space. VNInfo* MergeValueNumberInto(VNInfo *V1, VNInfo *V2); - /// MergeValueInAsValue - Merge all of the live ranges of a specific val# - /// in RHS into this live interval as the specified value number. - /// The LiveRanges in RHS are allowed to overlap with LiveRanges in the - /// current interval, it will replace the value numbers of the overlaped - /// live ranges with the specified value number. - void MergeRangesInAsValue(const LiveInterval &RHS, VNInfo *LHSValNo); + /// Merge all of the live segments of a specific val# in RHS into this live + /// interval as the specified value number. The segments in RHS are allowed + /// to overlap with segments in the current interval, it will replace the + /// value numbers of the overlaped live segments with the specified value + /// number. + void MergeSegmentsInAsValue(const LiveInterval &RHS, VNInfo *LHSValNo); - /// MergeValueInAsValue - Merge all of the live ranges of a specific val# + /// MergeValueInAsValue - Merge all of the segments of a specific val# /// in RHS into this live interval as the specified value number. - /// The LiveRanges in RHS are allowed to overlap with LiveRanges in the - /// current interval, but only if the overlapping LiveRanges have the + /// The segments in RHS are allowed to overlap with segments in the + /// current interval, but only if the overlapping segments have the /// specified value number. void MergeValueInAsValue(const LiveInterval &RHS, const VNInfo *RHSValNo, VNInfo *LHSValNo); - bool empty() const { return ranges.empty(); } + bool empty() const { return segments.empty(); } /// beginIndex - Return the lowest numbered slot covered by interval. SlotIndex beginIndex() const { assert(!empty() && "Call to beginIndex() on empty interval."); - return ranges.front().start; + return segments.front().start; } /// endNumber - return the maximum point of the interval of the whole, /// exclusive. SlotIndex endIndex() const { assert(!empty() && "Call to endIndex() on empty interval."); - return ranges.back().end; + return segments.back().end; } bool expiredAt(SlotIndex index) const { @@ -291,23 +275,23 @@ namespace llvm { return r != end() && r->start <= index; } - /// getLiveRangeContaining - Return the live range that contains the - /// specified index, or null if there is none. - const LiveRange *getLiveRangeContaining(SlotIndex Idx) const { - const_iterator I = FindLiveRangeContaining(Idx); + /// Return the segment that contains the specified index, or null if there + /// is none. + const Segment *getSegmentContaining(SlotIndex Idx) const { + const_iterator I = FindSegmentContaining(Idx); return I == end() ? 0 : &*I; } - /// getLiveRangeContaining - Return the live range that contains the - /// specified index, or null if there is none. - LiveRange *getLiveRangeContaining(SlotIndex Idx) { - iterator I = FindLiveRangeContaining(Idx); + /// Return the live segment that contains the specified index, or null if + /// there is none. + Segment *getSegmentContaining(SlotIndex Idx) { + iterator I = FindSegmentContaining(Idx); return I == end() ? 0 : &*I; } /// getVNInfoAt - Return the VNInfo that is live at Idx, or NULL. VNInfo *getVNInfoAt(SlotIndex Idx) const { - const_iterator I = FindLiveRangeContaining(Idx); + const_iterator I = FindSegmentContaining(Idx); return I == end() ? 0 : I->valno; } @@ -315,18 +299,18 @@ namespace llvm { /// necessarilly including Idx, or NULL. Use this to find the reaching def /// used by an instruction at this SlotIndex position. VNInfo *getVNInfoBefore(SlotIndex Idx) const { - const_iterator I = FindLiveRangeContaining(Idx.getPrevSlot()); + const_iterator I = FindSegmentContaining(Idx.getPrevSlot()); return I == end() ? 0 : I->valno; } - /// FindLiveRangeContaining - Return an iterator to the live range that - /// contains the specified index, or end() if there is none. - iterator FindLiveRangeContaining(SlotIndex Idx) { + /// Return an iterator to the segment that contains the specified index, or + /// end() if there is none. + iterator FindSegmentContaining(SlotIndex Idx) { iterator I = find(Idx); return I != end() && I->start <= Idx ? I : end(); } - const_iterator FindLiveRangeContaining(SlotIndex Idx) const { + const_iterator FindSegmentContaining(SlotIndex Idx) const { const_iterator I = find(Idx); return I != end() && I->start <= Idx ? I : end(); } @@ -347,8 +331,8 @@ namespace llvm { bool overlaps(const LiveInterval &Other, const CoalescerPair &CP, const SlotIndexes&) const; - /// overlaps - Return true if the live interval overlaps a range specified - /// by [Start, End). + /// overlaps - Return true if the live interval overlaps an interval + /// specified by [Start, End). bool overlaps(SlotIndex Start, SlotIndex End) const; /// overlapsFrom - Return true if the intersection of the two live intervals @@ -356,16 +340,16 @@ namespace llvm { /// scanning the Other interval starting at I. bool overlapsFrom(const LiveInterval& other, const_iterator I) const; - /// addRange - Add the specified LiveRange to this interval, merging - /// intervals as appropriate. This returns an iterator to the inserted live - /// range (which may have grown since it was inserted. - iterator addRange(LiveRange LR) { - return addRangeFrom(LR, ranges.begin()); + /// Add the specified Segment to this interval, merging segments as + /// appropriate. This returns an iterator to the inserted segment (which + /// may have grown since it was inserted). + iterator addSegment(Segment S) { + return addSegmentFrom(S, segments.begin()); } /// extendInBlock - If this interval is live before Kill in the basic block /// that starts at StartIdx, extend it to be live up to Kill, and return - /// the value. If there is no live range before Kill, return NULL. + /// the value. If there is no segment before Kill, return NULL. VNInfo *extendInBlock(SlotIndex StartIdx, SlotIndex Kill); /// join - Join two live intervals (this, and other) together. This applies @@ -376,7 +360,7 @@ namespace llvm { const int *RHSValNoAssignments, SmallVectorImpl &NewVNInfo); - /// True iff this live range is a single segment that lies between the + /// True iff this segment is a single segment that lies between the /// specified boundaries, exclusively. Vregs live across a backedge are not /// considered local. The boundaries are expected to lie within an extended /// basic block, so vregs that are not live out should contain no holes. @@ -385,24 +369,24 @@ namespace llvm { endIndex() < End.getBoundaryIndex(); } - /// removeRange - Remove the specified range from this interval. Note that - /// the range must be a single LiveRange in its entirety. - void removeRange(SlotIndex Start, SlotIndex End, - bool RemoveDeadValNo = false); + /// Remove the specified segment from this interval. Note that the segment + /// must be a single Segment in its entirety. + void removeSegment(SlotIndex Start, SlotIndex End, + bool RemoveDeadValNo = false); - void removeRange(LiveRange LR, bool RemoveDeadValNo = false) { - removeRange(LR.start, LR.end, RemoveDeadValNo); + void removeSegment(Segment S, bool RemoveDeadValNo = false) { + removeSegment(S.start, S.end, RemoveDeadValNo); } - /// removeValNo - Remove all the ranges defined by the specified value#. + /// removeValNo - Remove all the segments defined by the specified value#. /// Also remove the value# from value# list. void removeValNo(VNInfo *ValNo); - /// getSize - Returns the sum of sizes of all the LiveRange's. + /// getSize - Returns the sum of sizes of all the Segment's. /// unsigned getSize() const; - /// Returns true if the live interval is zero length, i.e. no live ranges + /// Returns true if the live interval is zero length, i.e. no segments /// span instructions. It doesn't pay to spill such an interval. bool isZeroLength(SlotIndexes *Indexes) const { for (const_iterator i = begin(), e = end(); i != e; ++i) @@ -443,9 +427,9 @@ namespace llvm { private: - iterator addRangeFrom(LiveRange LR, iterator From); - void extendIntervalEndTo(iterator I, SlotIndex NewEnd); - iterator extendIntervalStartTo(iterator I, SlotIndex NewStr); + iterator addSegmentFrom(Segment S, iterator From); + void extendSegmentEndTo(iterator I, SlotIndex NewEnd); + iterator extendSegmentStartTo(iterator I, SlotIndex NewStr); void markValNoForDeletion(VNInfo *V); LiveInterval& operator=(const LiveInterval& rhs) LLVM_DELETED_FUNCTION; @@ -457,9 +441,19 @@ namespace llvm { return OS; } + raw_ostream &operator<<(raw_ostream &OS, const LiveInterval::Segment &S); + + inline bool operator<(SlotIndex V, const LiveInterval::Segment &S) { + return V < S.start; + } + + inline bool operator<(const LiveInterval::Segment &S, SlotIndex V) { + return S.start < V; + } + /// Helper class for performant LiveInterval bulk updates. /// - /// Calling LiveInterval::addRange() repeatedly can be expensive on large + /// Calling LiveInterval::addSegment() repeatedly can be expensive on large /// live ranges because segments after the insertion point may need to be /// shifted. The LiveRangeUpdater class can defer the shifting when adding /// many segments in order. @@ -470,7 +464,7 @@ namespace llvm { SlotIndex LastStart; LiveInterval::iterator WriteI; LiveInterval::iterator ReadI; - SmallVector Spills; + SmallVector Spills; void mergeSpills(); public: @@ -480,12 +474,13 @@ namespace llvm { ~LiveRangeUpdater() { flush(); } - /// Add a segment to LI and coalesce when possible, just like LI.addRange(). - /// Segments should be added in increasing start order for best performance. - void add(LiveRange); + /// Add a segment to LI and coalesce when possible, just like + /// LI.addSegment(). Segments should be added in increasing start order for + /// best performance. + void add(LiveInterval::Segment); void add(SlotIndex Start, SlotIndex End, VNInfo *VNI) { - add(LiveRange(Start, End, VNI)); + add(LiveInterval::Segment(Start, End, VNI)); } /// Return true if the LI is currently in an invalid state, and flush() diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h index d134781..dd01636 100644 --- a/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -137,10 +137,10 @@ namespace llvm { VirtRegIntervals[Reg] = 0; } - /// addLiveRangeToEndOfBlock - Given a register and an instruction, - /// adds a live range from that instruction to the end of its MBB. - LiveRange addLiveRangeToEndOfBlock(unsigned reg, - MachineInstr* startInst); + /// Given a register and an instruction, adds a live segment from that + /// instruction to the end of its MBB. + LiveInterval::Segment addSegmentToEndOfBlock(unsigned reg, + MachineInstr* startInst); /// shrinkToUses - After removing some uses of a register, shrink its live /// range to just the remaining uses. This method does not compute reaching diff --git a/include/llvm/CodeGen/LiveIntervalUnion.h b/include/llvm/CodeGen/LiveIntervalUnion.h index 615b339..95933d1 100644 --- a/include/llvm/CodeGen/LiveIntervalUnion.h +++ b/include/llvm/CodeGen/LiveIntervalUnion.h @@ -32,7 +32,7 @@ typedef SparseBitVector<128> LiveVirtRegBitSet; /// Compare a live virtual register segment to a LiveIntervalUnion segment. inline bool -overlap(const LiveRange &VRSeg, +overlap(const LiveInterval::Segment &VRSeg, const IntervalMap::const_iterator &LUSeg) { return VRSeg.start < LUSeg.stop() && LUSeg.start() < VRSeg.end; } -- cgit v1.1 From 87a86058fa0726328de42ace85b5532d18775646 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Thu, 10 Oct 2013 21:28:47 +0000 Subject: Refactor LiveInterval: introduce new LiveRange class LiveRange just manages a list of segments and a list of value numbers now as LiveInterval did previously, but without having details like spill weight or a fixed register number. LiveInterval is now a subclass of LiveRange and simply adds the spill weight and the register number. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192393 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveInterval.h | 219 ++++++++++++++++------------ include/llvm/CodeGen/LiveIntervalAnalysis.h | 8 +- 2 files changed, 126 insertions(+), 101 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index f194161..11c45e4 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -7,14 +7,14 @@ // //===----------------------------------------------------------------------===// // -// This file implements the LiveInterval class. Given some numbering of each -// the machine instructions an interval [i, j) is said to be a -// live interval for register v if there is no instruction with number j' >= j +// This file implements the LiveRange and LiveInterval classes. Given some +// numbering of each the machine instructions an interval [i, j) is said to be a +// live range for register v if there is no instruction with number j' >= j // such that v is live at j' and there is no instruction with number i' < i such -// that v is live at i'. In this implementation intervals can have holes, -// i.e. an interval might look like [1,20), [50,65), [1000,1001). Each -// individual segment is represented as an instance of LiveInterval::Segment, -// and the whole range is represented as an instance of LiveInterval. +// that v is live at i'. In this implementation ranges can have holes, +// i.e. a range might look like [1,20), [50,65), [1000,1001). Each +// individual segment is represented as an instance of LiveRange::Segment, +// and the whole range is represented as an instance of LiveRange. // //===----------------------------------------------------------------------===// @@ -35,6 +35,7 @@ namespace llvm { class MachineRegisterInfo; class TargetRegisterInfo; class raw_ostream; + template class SmallPtrSet; /// VNInfo - Value Number Information. /// This class holds information about a machine level values, including @@ -78,10 +79,12 @@ namespace llvm { void markUnused() { def = SlotIndex(); } }; - /// LiveInterval - This class represents some number of live segments for a - /// register or value. This class also contains a bit of register allocator - /// state. - class LiveInterval { + /// This class represents the liveness of a register, stack slot, etc. + /// It manages an ordered list of Segment objects. + /// The Segments are organized in a static single assignment form: At places + /// where a new value is defined or different values reach a CFG join a new + /// segment with a new value number is used. + class LiveRange { public: /// This represents a simple continuous liveness interval for a value. @@ -123,14 +126,9 @@ namespace llvm { typedef SmallVector Segments; typedef SmallVector VNInfoList; - const unsigned reg; // the register or stack slot of this interval. - float weight; // weight of this interval - Segments segments; // the segments in which this register is live + Segments segments; // the liveness segments VNInfoList valnos; // value#'s - LiveInterval(unsigned Reg, float Weight) - : reg(Reg), weight(Weight) {} - typedef Segments::iterator iterator; iterator begin() { return segments.begin(); } iterator end() { return segments.end(); } @@ -141,15 +139,15 @@ namespace llvm { typedef VNInfoList::iterator vni_iterator; vni_iterator vni_begin() { return valnos.begin(); } - vni_iterator vni_end() { return valnos.end(); } + vni_iterator vni_end() { return valnos.end(); } typedef VNInfoList::const_iterator const_vni_iterator; const_vni_iterator vni_begin() const { return valnos.begin(); } - const_vni_iterator vni_end() const { return valnos.end(); } + const_vni_iterator vni_end() const { return valnos.end(); } /// advanceTo - Advance the specified iterator to point to the Segment /// containing the specified position, or end() if the position is past the - /// end of the interval. If no Segment contains this position, but the + /// end of the range. If no Segment contains this position, but the /// position is in a hole, this method returns an iterator pointing to the /// Segment immediately after the hole. iterator advanceTo(iterator I, SlotIndex Pos) { @@ -162,7 +160,7 @@ namespace llvm { /// find - Return an iterator pointing to the first segment that ends after /// Pos, or end(). This is the same as advanceTo(begin(), Pos), but faster - /// when searching large intervals. + /// when searching large ranges. /// /// If Pos is contained in a Segment, that segment is returned. /// If Pos is in a hole, the following Segment is returned. @@ -170,7 +168,7 @@ namespace llvm { iterator find(SlotIndex Pos); const_iterator find(SlotIndex Pos) const { - return const_cast(this)->find(Pos); + return const_cast(this)->find(Pos); } void clear() { @@ -197,7 +195,7 @@ namespace llvm { return valnos[ValNo]; } - /// containsValue - Returns true if VNI belongs to this interval. + /// containsValue - Returns true if VNI belongs to this range. bool containsValue(const VNInfo *VNI) const { return VNI && VNI->id < getNumValNums() && VNI == getValNumInfo(VNI->id); } @@ -211,7 +209,7 @@ namespace llvm { return VNI; } - /// createDeadDef - Make sure the interval has a value defined at Def. + /// createDeadDef - Make sure the range has a value defined at Def. /// If one already exists, return it. Otherwise allocate a new value and /// add liveness for a dead def. VNInfo *createDeadDef(SlotIndex Def, VNInfo::Allocator &VNInfoAllocator); @@ -237,32 +235,32 @@ namespace llvm { VNInfo* MergeValueNumberInto(VNInfo *V1, VNInfo *V2); /// Merge all of the live segments of a specific val# in RHS into this live - /// interval as the specified value number. The segments in RHS are allowed - /// to overlap with segments in the current interval, it will replace the + /// range as the specified value number. The segments in RHS are allowed + /// to overlap with segments in the current range, it will replace the /// value numbers of the overlaped live segments with the specified value /// number. - void MergeSegmentsInAsValue(const LiveInterval &RHS, VNInfo *LHSValNo); + void MergeSegmentsInAsValue(const LiveRange &RHS, VNInfo *LHSValNo); /// MergeValueInAsValue - Merge all of the segments of a specific val# - /// in RHS into this live interval as the specified value number. + /// in RHS into this live range as the specified value number. /// The segments in RHS are allowed to overlap with segments in the - /// current interval, but only if the overlapping segments have the + /// current range, but only if the overlapping segments have the /// specified value number. - void MergeValueInAsValue(const LiveInterval &RHS, + void MergeValueInAsValue(const LiveRange &RHS, const VNInfo *RHSValNo, VNInfo *LHSValNo); bool empty() const { return segments.empty(); } - /// beginIndex - Return the lowest numbered slot covered by interval. + /// beginIndex - Return the lowest numbered slot covered. SlotIndex beginIndex() const { - assert(!empty() && "Call to beginIndex() on empty interval."); + assert(!empty() && "Call to beginIndex() on empty range."); return segments.front().start; } - /// endNumber - return the maximum point of the interval of the whole, + /// endNumber - return the maximum point of the range of the whole, /// exclusive. SlotIndex endIndex() const { - assert(!empty() && "Call to endIndex() on empty interval."); + assert(!empty() && "Call to endIndex() on empty range."); return segments.back().end; } @@ -315,47 +313,47 @@ namespace llvm { return I != end() && I->start <= Idx ? I : end(); } - /// overlaps - Return true if the intersection of the two live intervals is + /// overlaps - Return true if the intersection of the two live ranges is /// not empty. - bool overlaps(const LiveInterval& other) const { + bool overlaps(const LiveRange &other) const { if (other.empty()) return false; return overlapsFrom(other, other.begin()); } - /// overlaps - Return true if the two intervals have overlapping segments + /// overlaps - Return true if the two ranges have overlapping segments /// that are not coalescable according to CP. /// - /// Overlapping segments where one interval is defined by a coalescable + /// Overlapping segments where one range is defined by a coalescable /// copy are allowed. - bool overlaps(const LiveInterval &Other, const CoalescerPair &CP, + bool overlaps(const LiveRange &Other, const CoalescerPair &CP, const SlotIndexes&) const; - /// overlaps - Return true if the live interval overlaps an interval - /// specified by [Start, End). + /// overlaps - Return true if the live range overlaps an interval specified + /// by [Start, End). bool overlaps(SlotIndex Start, SlotIndex End) const; - /// overlapsFrom - Return true if the intersection of the two live intervals + /// overlapsFrom - Return true if the intersection of the two live ranges /// is not empty. The specified iterator is a hint that we can begin - /// scanning the Other interval starting at I. - bool overlapsFrom(const LiveInterval& other, const_iterator I) const; + /// scanning the Other range starting at I. + bool overlapsFrom(const LiveRange &Other, const_iterator I) const; - /// Add the specified Segment to this interval, merging segments as + /// Add the specified Segment to this range, merging segments as /// appropriate. This returns an iterator to the inserted segment (which /// may have grown since it was inserted). iterator addSegment(Segment S) { return addSegmentFrom(S, segments.begin()); } - /// extendInBlock - If this interval is live before Kill in the basic block + /// extendInBlock - If this range is live before Kill in the basic block /// that starts at StartIdx, extend it to be live up to Kill, and return /// the value. If there is no segment before Kill, return NULL. VNInfo *extendInBlock(SlotIndex StartIdx, SlotIndex Kill); - /// join - Join two live intervals (this, and other) together. This applies - /// mappings to the value numbers in the LHS/RHS intervals as specified. If - /// the intervals are not joinable, this aborts. - void join(LiveInterval &Other, + /// join - Join two live ranges (this, and other) together. This applies + /// mappings to the value numbers in the LHS/RHS ranges as specified. If + /// the ranges are not joinable, this aborts. + void join(LiveRange &Other, const int *ValNoAssignments, const int *RHSValNoAssignments, SmallVectorImpl &NewVNInfo); @@ -369,7 +367,7 @@ namespace llvm { endIndex() < End.getBoundaryIndex(); } - /// Remove the specified segment from this interval. Note that the segment + /// Remove the specified segment from this range. Note that the segment /// must be a single Segment in its entirety. void removeSegment(SlotIndex Start, SlotIndex End, bool RemoveDeadValNo = false); @@ -382,12 +380,8 @@ namespace llvm { /// Also remove the value# from value# list. void removeValNo(VNInfo *ValNo); - /// getSize - Returns the sum of sizes of all the Segment's. - /// - unsigned getSize() const; - - /// Returns true if the live interval is zero length, i.e. no segments - /// span instructions. It doesn't pay to spill such an interval. + /// Returns true if the live range is zero length, i.e. no live segments + /// span instructions. It doesn't pay to spill such a range. bool isZeroLength(SlotIndexes *Indexes) const { for (const_iterator i = begin(), e = end(); i != e; ++i) if (Indexes->getNextNonNullIndex(i->start).getBaseIndex() < @@ -396,27 +390,16 @@ namespace llvm { return true; } - /// isSpillable - Can this interval be spilled? - bool isSpillable() const { - return weight != HUGE_VALF; - } - - /// markNotSpillable - Mark interval as not spillable - void markNotSpillable() { - weight = HUGE_VALF; - } - - bool operator<(const LiveInterval& other) const { + bool operator<(const LiveRange& other) const { const SlotIndex &thisIndex = beginIndex(); const SlotIndex &otherIndex = other.beginIndex(); - return (thisIndex < otherIndex || - (thisIndex == otherIndex && reg < other.reg)); + return thisIndex < otherIndex; } void print(raw_ostream &OS) const; void dump() const; - /// \brief Walk the interval and assert if any invariants fail to hold. + /// \brief Walk the range and assert if any invariants fail to hold. /// /// Note that this is a no-op when asserts are disabled. #ifdef NDEBUG @@ -432,6 +415,45 @@ namespace llvm { iterator extendSegmentStartTo(iterator I, SlotIndex NewStr); void markValNoForDeletion(VNInfo *V); + }; + + inline raw_ostream &operator<<(raw_ostream &OS, const LiveRange &LR) { + LR.print(OS); + return OS; + } + + /// LiveInterval - This class represents the liveness of a register, + /// or stack slot. + class LiveInterval : public LiveRange { + public: + const unsigned reg; // the register or stack slot of this interval. + float weight; // weight of this interval + + LiveInterval(unsigned Reg, float Weight) + : reg(Reg), weight(Weight) {} + + /// getSize - Returns the sum of sizes of all the LiveRange's. + /// + unsigned getSize() const; + + /// isSpillable - Can this interval be spilled? + bool isSpillable() const { + return weight != HUGE_VALF; + } + + /// markNotSpillable - Mark interval as not spillable + void markNotSpillable() { + weight = HUGE_VALF; + } + + bool operator<(const LiveInterval& other) const { + const SlotIndex &thisIndex = beginIndex(); + const SlotIndex &otherIndex = other.beginIndex(); + return thisIndex < otherIndex || + (thisIndex == otherIndex && reg < other.reg); + } + + private: LiveInterval& operator=(const LiveInterval& rhs) LLVM_DELETED_FUNCTION; }; @@ -441,65 +463,65 @@ namespace llvm { return OS; } - raw_ostream &operator<<(raw_ostream &OS, const LiveInterval::Segment &S); + raw_ostream &operator<<(raw_ostream &OS, const LiveRange::Segment &S); - inline bool operator<(SlotIndex V, const LiveInterval::Segment &S) { + inline bool operator<(SlotIndex V, const LiveRange::Segment &S) { return V < S.start; } - inline bool operator<(const LiveInterval::Segment &S, SlotIndex V) { + inline bool operator<(const LiveRange::Segment &S, SlotIndex V) { return S.start < V; } - /// Helper class for performant LiveInterval bulk updates. + /// Helper class for performant LiveRange bulk updates. /// - /// Calling LiveInterval::addSegment() repeatedly can be expensive on large + /// Calling LiveRange::addSegment() repeatedly can be expensive on large /// live ranges because segments after the insertion point may need to be /// shifted. The LiveRangeUpdater class can defer the shifting when adding /// many segments in order. /// - /// The LiveInterval will be in an invalid state until flush() is called. + /// The LiveRange will be in an invalid state until flush() is called. class LiveRangeUpdater { - LiveInterval *LI; + LiveRange *LR; SlotIndex LastStart; - LiveInterval::iterator WriteI; - LiveInterval::iterator ReadI; - SmallVector Spills; + LiveRange::iterator WriteI; + LiveRange::iterator ReadI; + SmallVector Spills; void mergeSpills(); public: - /// Create a LiveRangeUpdater for adding segments to LI. - /// LI will temporarily be in an invalid state until flush() is called. - LiveRangeUpdater(LiveInterval *li = 0) : LI(li) {} + /// Create a LiveRangeUpdater for adding segments to LR. + /// LR will temporarily be in an invalid state until flush() is called. + LiveRangeUpdater(LiveRange *lr = 0) : LR(lr) {} ~LiveRangeUpdater() { flush(); } - /// Add a segment to LI and coalesce when possible, just like - /// LI.addSegment(). Segments should be added in increasing start order for + /// Add a segment to LR and coalesce when possible, just like + /// LR.addSegment(). Segments should be added in increasing start order for /// best performance. - void add(LiveInterval::Segment); + void add(LiveRange::Segment); void add(SlotIndex Start, SlotIndex End, VNInfo *VNI) { - add(LiveInterval::Segment(Start, End, VNI)); + add(LiveRange::Segment(Start, End, VNI)); } - /// Return true if the LI is currently in an invalid state, and flush() + /// Return true if the LR is currently in an invalid state, and flush() /// needs to be called. bool isDirty() const { return LastStart.isValid(); } - /// Flush the updater state to LI so it is valid and contains all added + /// Flush the updater state to LR so it is valid and contains all added /// segments. void flush(); /// Select a different destination live range. - void setDest(LiveInterval *li) { - if (LI != li && isDirty()) + void setDest(LiveRange *lr) { + if (LR != lr && isDirty()) flush(); - LI = li; + LR = lr; } /// Get the current destination live range. - LiveInterval *getDest() const { return LI; } + LiveRange *getDest() const { return LR; } void dump() const; void print(raw_ostream&) const; @@ -521,15 +543,18 @@ namespace llvm { SlotIndex EndPoint; bool Kill; + void init(const LiveRange &LR, SlotIndex Idx) { + } + public: /// Create a LiveRangeQuery for the given live range and instruction index. /// The sub-instruction slot of Idx doesn't matter, only the instruction it /// refers to is considered. - LiveRangeQuery(const LiveInterval &LI, SlotIndex Idx) + LiveRangeQuery(const LiveRange &LR, SlotIndex Idx) : EarlyVal(0), LateVal(0), Kill(false) { // Find the segment that enters the instruction. - LiveInterval::const_iterator I = LI.find(Idx.getBaseIndex()); - LiveInterval::const_iterator E = LI.end(); + LiveRange::const_iterator I = LR.find(Idx.getBaseIndex()); + LiveRange::const_iterator E = LR.end(); if (I == E) return; // Is this an instruction live-in segment? diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h index dd01636..216a179 100644 --- a/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -206,14 +206,14 @@ namespace llvm { return Indexes->getMBBEndIdx(mbb); } - bool isLiveInToMBB(const LiveInterval &li, + bool isLiveInToMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const { - return li.liveAt(getMBBStartIdx(mbb)); + return LR.liveAt(getMBBStartIdx(mbb)); } - bool isLiveOutOfMBB(const LiveInterval &li, + bool isLiveOutOfMBB(const LiveRange &LR, const MachineBasicBlock *mbb) const { - return li.liveAt(getMBBEndIdx(mbb).getPrevSlot()); + return LR.liveAt(getMBBEndIdx(mbb).getPrevSlot()); } MachineBasicBlock* getMBBFromIndex(SlotIndex index) const { -- cgit v1.1 From 5649e25ce86b9d89d228ae7c392413571b0f8c19 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Thu, 10 Oct 2013 21:28:52 +0000 Subject: Pass LiveQueryResult by value This makes the API a bit more natural to use and makes it easier to make LiveRanges implementation details private. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192394 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveInterval.h | 197 ++++++++++++++++++------------------ 1 file changed, 101 insertions(+), 96 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index 11c45e4..d28cb04 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -79,6 +79,65 @@ namespace llvm { void markUnused() { def = SlotIndex(); } }; + /// Result of a LiveRange query. This class hides the implementation details + /// of live ranges, and it should be used as the primary interface for + /// examining live ranges around instructions. + class LiveQueryResult { + VNInfo *const EarlyVal; + VNInfo *const LateVal; + const SlotIndex EndPoint; + const bool Kill; + + public: + LiveQueryResult(VNInfo *EarlyVal, VNInfo *LateVal, SlotIndex EndPoint, + bool Kill) + : EarlyVal(EarlyVal), LateVal(LateVal), EndPoint(EndPoint), Kill(Kill) + {} + + /// Return the value that is live-in to the instruction. This is the value + /// that will be read by the instruction's use operands. Return NULL if no + /// value is live-in. + VNInfo *valueIn() const { + return EarlyVal; + } + + /// Return true if the live-in value is killed by this instruction. This + /// means that either the live range ends at the instruction, or it changes + /// value. + bool isKill() const { + return Kill; + } + + /// Return true if this instruction has a dead def. + bool isDeadDef() const { + return EndPoint.isDead(); + } + + /// Return the value leaving the instruction, if any. This can be a + /// live-through value, or a live def. A dead def returns NULL. + VNInfo *valueOut() const { + return isDeadDef() ? 0 : LateVal; + } + + /// Return the value defined by this instruction, if any. This includes + /// dead defs, it is the value created by the instruction's def operands. + VNInfo *valueDefined() const { + return EarlyVal == LateVal ? 0 : LateVal; + } + + /// Return the end point of the last live range segment to interact with + /// the instruction, if any. + /// + /// The end point is an invalid SlotIndex only if the live range doesn't + /// intersect the instruction at all. + /// + /// The end point may be at or past the end of the instruction's basic + /// block. That means the value was live out of the block. + SlotIndex endPoint() const { + return EndPoint; + } + }; + /// This class represents the liveness of a register, stack slot, etc. /// It manages an ordered list of Segment objects. /// The Segments are organized in a static single assignment form: At places @@ -376,6 +435,48 @@ namespace llvm { removeSegment(S.start, S.end, RemoveDeadValNo); } + /// Query Liveness at Idx. + /// The sub-instruction slot of Idx doesn't matter, only the instruction + /// it refers to is considered. + LiveQueryResult Query(SlotIndex Idx) const { + // Find the segment that enters the instruction. + const_iterator I = find(Idx.getBaseIndex()); + const_iterator E = end(); + if (I == E) + return LiveQueryResult(0, 0, SlotIndex(), false); + + // Is this an instruction live-in segment? + // If Idx is the start index of a basic block, include live-in segments + // that start at Idx.getBaseIndex(). + VNInfo *EarlyVal = 0; + VNInfo *LateVal = 0; + SlotIndex EndPoint; + bool Kill = false; + if (I->start <= Idx.getBaseIndex()) { + EarlyVal = I->valno; + EndPoint = I->end; + // Move to the potentially live-out segment. + if (SlotIndex::isSameInstr(Idx, I->end)) { + Kill = true; + if (++I == E) + return LiveQueryResult(EarlyVal, LateVal, EndPoint, Kill); + } + // Special case: A PHIDef value can have its def in the middle of a + // segment if the value happens to be live out of the layout + // predecessor. + // Such a value is not live-in. + if (EarlyVal->def == Idx.getBaseIndex()) + EarlyVal = 0; + } + // I now points to the segment that may be live-through, or defined by + // this instr. Ignore segments starting after the current instr. + if (!SlotIndex::isEarlierInstr(Idx, I->start)) { + LateVal = I->valno; + EndPoint = I->end; + } + return LiveQueryResult(EarlyVal, LateVal, EndPoint, Kill); + } + /// removeValNo - Remove all the segments defined by the specified value#. /// Also remove the value# from value# list. void removeValNo(VNInfo *ValNo); @@ -532,102 +633,6 @@ namespace llvm { return OS; } - /// LiveRangeQuery - Query information about a live range around a given - /// instruction. This class hides the implementation details of live ranges, - /// and it should be used as the primary interface for examining live ranges - /// around instructions. - /// - class LiveRangeQuery { - VNInfo *EarlyVal; - VNInfo *LateVal; - SlotIndex EndPoint; - bool Kill; - - void init(const LiveRange &LR, SlotIndex Idx) { - } - - public: - /// Create a LiveRangeQuery for the given live range and instruction index. - /// The sub-instruction slot of Idx doesn't matter, only the instruction it - /// refers to is considered. - LiveRangeQuery(const LiveRange &LR, SlotIndex Idx) - : EarlyVal(0), LateVal(0), Kill(false) { - // Find the segment that enters the instruction. - LiveRange::const_iterator I = LR.find(Idx.getBaseIndex()); - LiveRange::const_iterator E = LR.end(); - if (I == E) - return; - // Is this an instruction live-in segment? - // If Idx is the start index of a basic block, include live-in segments - // that start at Idx.getBaseIndex(). - if (I->start <= Idx.getBaseIndex()) { - EarlyVal = I->valno; - EndPoint = I->end; - // Move to the potentially live-out segment. - if (SlotIndex::isSameInstr(Idx, I->end)) { - Kill = true; - if (++I == E) - return; - } - // Special case: A PHIDef value can have its def in the middle of a - // segment if the value happens to be live out of the layout - // predecessor. - // Such a value is not live-in. - if (EarlyVal->def == Idx.getBaseIndex()) - EarlyVal = 0; - } - // I now points to the segment that may be live-through, or defined by - // this instr. Ignore segments starting after the current instr. - if (SlotIndex::isEarlierInstr(Idx, I->start)) - return; - LateVal = I->valno; - EndPoint = I->end; - } - - /// Return the value that is live-in to the instruction. This is the value - /// that will be read by the instruction's use operands. Return NULL if no - /// value is live-in. - VNInfo *valueIn() const { - return EarlyVal; - } - - /// Return true if the live-in value is killed by this instruction. This - /// means that either the live range ends at the instruction, or it changes - /// value. - bool isKill() const { - return Kill; - } - - /// Return true if this instruction has a dead def. - bool isDeadDef() const { - return EndPoint.isDead(); - } - - /// Return the value leaving the instruction, if any. This can be a - /// live-through value, or a live def. A dead def returns NULL. - VNInfo *valueOut() const { - return isDeadDef() ? 0 : LateVal; - } - - /// Return the value defined by this instruction, if any. This includes - /// dead defs, it is the value created by the instruction's def operands. - VNInfo *valueDefined() const { - return EarlyVal == LateVal ? 0 : LateVal; - } - - /// Return the end point of the last live range segment to interact with - /// the instruction, if any. - /// - /// The end point is an invalid SlotIndex only if the live range doesn't - /// intersect the instruction at all. - /// - /// The end point may be at or past the end of the instruction's basic - /// block. That means the value was live out of the block. - SlotIndex endPoint() const { - return EndPoint; - } - }; - /// ConnectedVNInfoEqClasses - Helper class that can divide VNInfos in a /// LiveInterval into equivalence clases of connected components. A /// LiveInterval that has multiple connected components can be broken into -- cgit v1.1 From e25dde550baec1f79caf2fc06edd74e7ae6ffa33 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Thu, 10 Oct 2013 21:28:57 +0000 Subject: Work on LiveRange instead of LiveInterval where possible Also change some pointer arguments to references at some places where 0-pointers are not allowed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192396 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveIntervalAnalysis.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h index 216a179..922c2a0 100644 --- a/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -127,7 +127,7 @@ namespace llvm { LiveInterval &createAndComputeVirtRegInterval(unsigned Reg) { LiveInterval &LI = createEmptyInterval(Reg); - computeVirtRegInterval(&LI); + computeVirtRegInterval(LI); return LI; } @@ -160,7 +160,7 @@ namespace llvm { /// extended to be live out of the basic block. /// /// See also LiveRangeCalc::extend(). - void extendToIndices(LiveInterval *LI, ArrayRef Indices); + void extendToIndices(LiveRange &LR, ArrayRef Indices); /// pruneValue - If an LI value is live at Kill, prune its live range by /// removing any liveness reachable from Kill. Add live range end points to @@ -369,7 +369,7 @@ namespace llvm { if (!LI) { // Compute missing ranges on demand. RegUnitIntervals[Unit] = LI = new LiveInterval(Unit, HUGE_VALF); - computeRegUnitInterval(LI); + computeRegUnitInterval(*LI); } return *LI; } @@ -397,8 +397,8 @@ namespace llvm { void dumpInstrs() const; void computeLiveInRegUnits(); - void computeRegUnitInterval(LiveInterval*); - void computeVirtRegInterval(LiveInterval*); + void computeRegUnitInterval(LiveInterval&); + void computeVirtRegInterval(LiveInterval&); class HMEditor; }; -- cgit v1.1 From 4f3b5e8c9232e43d1291aab8db5f5698d7ee0ea4 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Thu, 10 Oct 2013 21:29:02 +0000 Subject: Represent RegUnit liveness with LiveRange instance Previously LiveInterval has been used, but having a spill weight and register number is unnecessary for a register unit. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192397 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveIntervalAnalysis.h | 28 ++++++++++++++-------------- include/llvm/CodeGen/RegisterPressure.h | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveIntervalAnalysis.h b/include/llvm/CodeGen/LiveIntervalAnalysis.h index 922c2a0..d8437f0 100644 --- a/include/llvm/CodeGen/LiveIntervalAnalysis.h +++ b/include/llvm/CodeGen/LiveIntervalAnalysis.h @@ -90,9 +90,9 @@ namespace llvm { /// block. SmallVector, 8> RegMaskBlocks; - /// RegUnitIntervals - Keep a live interval for each register unit as a way - /// of tracking fixed physreg interference. - SmallVector RegUnitIntervals; + /// Keeps a live range set for each register unit to track fixed physreg + /// interference. + SmallVector RegUnitRanges; public: static char ID; // Pass identification, replacement for typeid @@ -364,24 +364,24 @@ namespace llvm { /// getRegUnit - Return the live range for Unit. /// It will be computed if it doesn't exist. - LiveInterval &getRegUnit(unsigned Unit) { - LiveInterval *LI = RegUnitIntervals[Unit]; - if (!LI) { + LiveRange &getRegUnit(unsigned Unit) { + LiveRange *LR = RegUnitRanges[Unit]; + if (!LR) { // Compute missing ranges on demand. - RegUnitIntervals[Unit] = LI = new LiveInterval(Unit, HUGE_VALF); - computeRegUnitInterval(*LI); + RegUnitRanges[Unit] = LR = new LiveRange(); + computeRegUnitRange(*LR, Unit); } - return *LI; + return *LR; } /// getCachedRegUnit - Return the live range for Unit if it has already /// been computed, or NULL if it hasn't been computed yet. - LiveInterval *getCachedRegUnit(unsigned Unit) { - return RegUnitIntervals[Unit]; + LiveRange *getCachedRegUnit(unsigned Unit) { + return RegUnitRanges[Unit]; } - const LiveInterval *getCachedRegUnit(unsigned Unit) const { - return RegUnitIntervals[Unit]; + const LiveRange *getCachedRegUnit(unsigned Unit) const { + return RegUnitRanges[Unit]; } private: @@ -397,7 +397,7 @@ namespace llvm { void dumpInstrs() const; void computeLiveInRegUnits(); - void computeRegUnitInterval(LiveInterval&); + void computeRegUnitRange(LiveRange&, unsigned Unit); void computeVirtRegInterval(LiveInterval&); class HMEditor; diff --git a/include/llvm/CodeGen/RegisterPressure.h b/include/llvm/CodeGen/RegisterPressure.h index 1db0b9f..a801d1d 100644 --- a/include/llvm/CodeGen/RegisterPressure.h +++ b/include/llvm/CodeGen/RegisterPressure.h @@ -22,7 +22,7 @@ namespace llvm { class LiveIntervals; -class LiveInterval; +class LiveRange; class RegisterClassInfo; class MachineInstr; @@ -424,7 +424,7 @@ public: void dump() const; protected: - const LiveInterval *getInterval(unsigned Reg) const; + const LiveRange *getLiveRange(unsigned Reg) const; void increaseRegPressure(ArrayRef Regs); void decreaseRegPressure(ArrayRef Regs); -- cgit v1.1 From 03d9609c6154ed91daefb4e4f89b7298c11961f3 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Thu, 10 Oct 2013 21:29:05 +0000 Subject: Print register in LiveInterval::print() git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192398 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveInterval.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index d28cb04..1b30bf5 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -527,6 +527,8 @@ namespace llvm { /// or stack slot. class LiveInterval : public LiveRange { public: + typedef LiveRange super; + const unsigned reg; // the register or stack slot of this interval. float weight; // weight of this interval @@ -554,6 +556,9 @@ namespace llvm { (thisIndex == otherIndex && reg < other.reg); } + void print(raw_ostream &OS) const; + void dump() const; + private: LiveInterval& operator=(const LiveInterval& rhs) LLVM_DELETED_FUNCTION; -- cgit v1.1 From 43777c3150c1dd12c661f62d5d7c95bf9b04c16a Mon Sep 17 00:00:00 2001 From: Justin Holewinski Date: Fri, 11 Oct 2013 12:39:36 +0000 Subject: Make AsmPrinter::emitImplicitDef a virtual method so targets can emit custom comments for implicit defs For NVPTX, this fixes a crash where the emitImplicitDef implementation was expecting physical registers, while NVPTX uses virtual registers (with a couple of exceptions). Now, the implicit def comment will be emitted as a true PTX register name. Other targets can use this to customize the output of implicit def comments. Fixes PR17519 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192444 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/AsmPrinter.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h index 5462212..997f5f3 100644 --- a/include/llvm/CodeGen/AsmPrinter.h +++ b/include/llvm/CodeGen/AsmPrinter.h @@ -286,6 +286,10 @@ namespace llvm { virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const; + /// emitImplicitDef - Targets can override this to customize the output of + /// IMPLICIT_DEF instructions in verbose mode. + virtual void emitImplicitDef(const MachineInstr *MI) const; + //===------------------------------------------------------------------===// // Symbol Lowering Routines. //===------------------------------------------------------------------===// -- cgit v1.1 From c34693f6efc670b71e11f3479844c36d9696b535 Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Fri, 11 Oct 2013 18:01:14 +0000 Subject: [DAGCombiner] Slice a big load in two loads when the element are next to each other in memory and the target has paired load and performs post-isel loads combining. E.g., this optimization will transform something like this: a = load i64* addr b = trunc i64 a to i32 c = lshr i64 a, 32 d = trunc i64 c to i32 into: b = load i32* addr1 d = load i32* addr2 Where addr1 = addr2 +/- sizeof(i32), if the target supports paired load and performs post-isel loads combining. One should overload TargetLowering::hasPairedLoad to provide this information. The default is false. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192471 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLowering.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'include') diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 0130e07..1c0ad63 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -1183,6 +1183,35 @@ public: return false; } + /// Return true if the target supplies and combines to a paired load + /// two loaded values of type LoadedType next to each other in memory. + /// RequiredAlignment gives the minimal alignment constraints that must be met to + /// be able to select this paired load. + /// + /// This information is *not* used to generate actual paired loads, but it is used + /// to generate a sequence of loads that is easier to combine into a paired load. + /// For instance, something like this: + /// a = load i64* addr + /// b = trunc i64 a to i32 + /// c = lshr i64 a, 32 + /// d = trunc i64 c to i32 + /// will be optimized into: + /// b = load i32* addr1 + /// d = load i32* addr2 + /// Where addr1 = addr2 +/- sizeof(i32). + /// + /// In other words, unless the target performs a post-isel load combining, this + /// information should not be provided because it will generate more loads. + virtual bool hasPairedLoad(Type * /*LoadedType*/, + unsigned & /*RequiredAligment*/) const { + return false; + } + + virtual bool hasPairedLoad(EVT /*LoadedType*/, + unsigned & /*RequiredAligment*/) const { + return false; + } + /// Return true if zero-extending the specific node Val to type VT2 is free /// (either because it's implicitly zero-extended such as ARM ldrb / ldrh or /// because it's folded such as X86 zero-extending loads). -- cgit v1.1 From 4351741a3b36bfe1ac1b385334fc5fa6f6ef5a11 Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Fri, 11 Oct 2013 18:17:17 +0000 Subject: [DAGCombiner] Revert load slicing (r192471), until I figure out why it fails on ubuntu. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192474 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLowering.h | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'include') diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 1c0ad63..0130e07 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -1183,35 +1183,6 @@ public: return false; } - /// Return true if the target supplies and combines to a paired load - /// two loaded values of type LoadedType next to each other in memory. - /// RequiredAlignment gives the minimal alignment constraints that must be met to - /// be able to select this paired load. - /// - /// This information is *not* used to generate actual paired loads, but it is used - /// to generate a sequence of loads that is easier to combine into a paired load. - /// For instance, something like this: - /// a = load i64* addr - /// b = trunc i64 a to i32 - /// c = lshr i64 a, 32 - /// d = trunc i64 c to i32 - /// will be optimized into: - /// b = load i32* addr1 - /// d = load i32* addr2 - /// Where addr1 = addr2 +/- sizeof(i32). - /// - /// In other words, unless the target performs a post-isel load combining, this - /// information should not be provided because it will generate more loads. - virtual bool hasPairedLoad(Type * /*LoadedType*/, - unsigned & /*RequiredAligment*/) const { - return false; - } - - virtual bool hasPairedLoad(EVT /*LoadedType*/, - unsigned & /*RequiredAligment*/) const { - return false; - } - /// Return true if zero-extending the specific node Val to type VT2 is free /// (either because it's implicitly zero-extended such as ARM ldrb / ldrh or /// because it's folded such as X86 zero-extending loads). -- cgit v1.1 From 83f743a4d5b4298893adaada0270ff2d832a50c7 Mon Sep 17 00:00:00 2001 From: Quentin Colombet Date: Fri, 11 Oct 2013 18:29:42 +0000 Subject: [DAGCombiner] Reapply load slicing (192471) with a test that explicitly set sse4.2 support. This should fix the buildbots. Original commit message: [DAGCombiner] Slice a big load in two loads when the element are next to each other in memory and the target has paired load and performs post-isel loads combining. E.g., this optimization will transform something like this: a = load i64* addr b = trunc i64 a to i32 c = lshr i64 a, 32 d = trunc i64 c to i32 into: b = load i32* addr1 d = load i32* addr2 Where addr1 = addr2 +/- sizeof(i32), if the target supports paired load and performs post-isel loads combining. One should overload TargetLowering::hasPairedLoad to provide this information. The default is false. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192476 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLowering.h | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'include') diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 0130e07..1c0ad63 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -1183,6 +1183,35 @@ public: return false; } + /// Return true if the target supplies and combines to a paired load + /// two loaded values of type LoadedType next to each other in memory. + /// RequiredAlignment gives the minimal alignment constraints that must be met to + /// be able to select this paired load. + /// + /// This information is *not* used to generate actual paired loads, but it is used + /// to generate a sequence of loads that is easier to combine into a paired load. + /// For instance, something like this: + /// a = load i64* addr + /// b = trunc i64 a to i32 + /// c = lshr i64 a, 32 + /// d = trunc i64 c to i32 + /// will be optimized into: + /// b = load i32* addr1 + /// d = load i32* addr2 + /// Where addr1 = addr2 +/- sizeof(i32). + /// + /// In other words, unless the target performs a post-isel load combining, this + /// information should not be provided because it will generate more loads. + virtual bool hasPairedLoad(Type * /*LoadedType*/, + unsigned & /*RequiredAligment*/) const { + return false; + } + + virtual bool hasPairedLoad(EVT /*LoadedType*/, + unsigned & /*RequiredAligment*/) const { + return false; + } + /// Return true if zero-extending the specific node Val to type VT2 is free /// (either because it's implicitly zero-extended such as ARM ldrb / ldrh or /// because it's folded such as X86 zero-extending loads). -- cgit v1.1 From da74817c50873d0691a3e4d3f392235584ead551 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Fri, 11 Oct 2013 19:04:35 +0000 Subject: Introduce ad hoc liveness tracking utility: LiveRegUnits Contains a set of live register (units) and code to move forward and backward in the schedule while updating the live set. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192481 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveRegUnits.h | 156 ++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 include/llvm/CodeGen/LiveRegUnits.h (limited to 'include') diff --git a/include/llvm/CodeGen/LiveRegUnits.h b/include/llvm/CodeGen/LiveRegUnits.h new file mode 100644 index 0000000..2a9ca65 --- /dev/null +++ b/include/llvm/CodeGen/LiveRegUnits.h @@ -0,0 +1,156 @@ +//===-- llvm/CodeGen/LiveRegUnits.h - Live register unit set ----*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file implements a Set of live register units. This can be used for ad +// hoc liveness tracking after register allocation. You can start with the +// live-ins/live-outs at the beginning/end of a block and update the information +// while walking the instructions inside the block. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CODEGEN_LIVEREGUNITS_H +#define LLVM_CODEGEN_LIVEREGUNITS_H + +#include "llvm/ADT/SmallSet.h" +#include "llvm/CodeGen/MachineBasicBlock.h" +#include "llvm/MC/MCRegisterInfo.h" +#include + +namespace llvm { + + class MachineInstr; + + /// A set of live register units with functions to track liveness when walking + /// backward/forward through a basic block. + class LiveRegUnits { + SmallSet LiveUnits; + + public: + /// Constructs a new empty LiveRegUnits set. + LiveRegUnits() { + } + + /// Constructs a new LiveRegUnits set by copying @p Other. + LiveRegUnits(const LiveRegUnits &Other) + : LiveUnits(Other.LiveUnits) { + } + + /// Adds a register to the set. + void AddReg(unsigned Reg, const MCRegisterInfo &MCRI) { + for (MCRegUnitIterator RUnits(Reg, &MCRI); RUnits.isValid(); ++RUnits) + LiveUnits.insert(*RUnits); + } + + /// Removes a register from the set. + void RemoveReg(unsigned Reg, const MCRegisterInfo &MCRI) { + for (MCRegUnitIterator RUnits(Reg, &MCRI); RUnits.isValid(); ++RUnits) + LiveUnits.erase(*RUnits); + } + + /// \brief Removes registers clobbered by the regmask operand @p Op. + /// Note that we assume the high bits of a physical super register are not + /// preserved unless the instruction has an implicit-use operand reading + /// the super-register or a register unit for the upper bits is available. + void RemoveRegsInMask(const MachineOperand &Op, + const MCRegisterInfo &MCRI) { + const uint32_t *Mask = Op.getRegMask(); + unsigned Bit = 0; + for (unsigned R = 0; R < MCRI.getNumRegs(); ++R) { + if ((*Mask & (1u << Bit)) == 0) + RemoveReg(R, MCRI); + ++Bit; + if (Bit >= 32) { + Bit = 0; + ++Mask; + } + } + } + + /// Returns true if register @p Reg (or one of its super register) is + /// contained in the set. + bool Contains(unsigned Reg, const MCRegisterInfo &MCRI) const { + for (MCRegUnitIterator RUnits(Reg, &MCRI); RUnits.isValid(); ++RUnits) { + if (LiveUnits.count(*RUnits)) + return true; + } + return false; + } + + /// Simulates liveness when stepping backwards over an instruction(bundle): + /// Defs are removed from the set, uses added. + void StepBackward(const MachineInstr &MI, const MCRegisterInfo &MCRI) { + // Remove defined registers and regmask kills from the set. + for (ConstMIBundleOperands O(&MI); O.isValid(); ++O) { + if (O->isReg()) { + if (!O->isDef()) + continue; + unsigned Reg = O->getReg(); + if (Reg == 0) + continue; + RemoveReg(Reg, MCRI); + } else if (O->isRegMask()) { + RemoveRegsInMask(*O, MCRI); + } + } + // Add uses to the set. + for (ConstMIBundleOperands O(&MI); O.isValid(); ++O) { + if (!O->isReg() || !O->readsReg() || O->isUndef()) + continue; + unsigned Reg = O->getReg(); + if (Reg == 0) + continue; + AddReg(Reg, MCRI); + } + } + + /// \brief Simulates liveness when stepping forward over an + /// instruction(bundle). + /// + /// Uses with kill flag get removed from the set, defs added. If possible + /// use StepBackward() instead of this function because some kill flags may + /// be missing. + void StepForward(const MachineInstr &MI, const MCRegisterInfo &MCRI) { + SmallVector Defs; + // Remove killed registers from the set. + for (ConstMIBundleOperands O(&MI); O.isValid(); ++O) { + if (O->isReg()) { + unsigned Reg = O->getReg(); + if (Reg == 0) + continue; + if (O->isDef()) { + if (!O->isDead()) + Defs.push_back(Reg); + } else { + if (!O->isKill()) + continue; + assert(O->isUse()); + RemoveReg(Reg, MCRI); + } + } else if (O->isRegMask()) { + RemoveRegsInMask(*O, MCRI); + } + } + // Add defs to the set. + for (unsigned i = 0, e = Defs.size(); i != e; ++i) { + AddReg(Defs[i], MCRI); + } + } + + /// Adds all registers in the live-in list of block @p BB. + void AddLiveIns(const MachineBasicBlock &BB, const MCRegisterInfo &MCRI) { + for (MachineBasicBlock::livein_iterator L = BB.livein_begin(), + LE = BB.livein_end(); L != LE; ++L) { + AddReg(*L, MCRI); + } + } + }; + +} + +#endif -- cgit v1.1 From 528f6d787b1a847e61eb2f1114559f423fdeb68c Mon Sep 17 00:00:00 2001 From: Andrew Kaylor Date: Fri, 11 Oct 2013 21:25:48 +0000 Subject: Adding multiple object support to MCJIT EH frame handling git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192504 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ExecutionEngine/RTDyldMemoryManager.h | 7 ++++++- include/llvm/ExecutionEngine/RuntimeDyld.h | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/ExecutionEngine/RTDyldMemoryManager.h b/include/llvm/ExecutionEngine/RTDyldMemoryManager.h index 09a5cb4..468b823 100644 --- a/include/llvm/ExecutionEngine/RTDyldMemoryManager.h +++ b/include/llvm/ExecutionEngine/RTDyldMemoryManager.h @@ -53,7 +53,12 @@ public: StringRef SectionName, bool IsReadOnly) = 0; /// Register the EH frames with the runtime so that c++ exceptions work. - virtual void registerEHFrames(StringRef SectionData); + /// + /// \p Addr parameter provides the local address of the EH frame section + /// data, while \p LoadAddr provides the address of the data in the target + /// address space. If the section has not been remapped (which will usually + /// be the case for local execution) these two values will be the same. + virtual void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size); /// This method returns the address of the specified function or variable. /// It is used to resolve symbols during module linking. diff --git a/include/llvm/ExecutionEngine/RuntimeDyld.h b/include/llvm/ExecutionEngine/RuntimeDyld.h index 1a57317..a5610fb 100644 --- a/include/llvm/ExecutionEngine/RuntimeDyld.h +++ b/include/llvm/ExecutionEngine/RuntimeDyld.h @@ -64,9 +64,14 @@ public: /// This is the address which will be used for relocation resolution. void mapSectionAddress(const void *LocalAddress, uint64_t TargetAddress); - StringRef getErrorString(); + /// Register any EH frame sections that have been loaded but not previously + /// registered with the memory manager. Note, RuntimeDyld is responsible + /// for identifying the EH frame and calling the memory manager with the + /// EH frame section data. However, the memory manager itself will handle + /// the actual target-specific EH frame registration. + void registerEHFrames(); - StringRef getEHFrameSection(); + StringRef getErrorString(); }; } // end namespace llvm -- cgit v1.1 From e3ba15c794839abe076e3e2bdf6c626396a19d4d Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Sat, 12 Oct 2013 00:55:57 +0000 Subject: Add missing #include's to cctype when using isdigit/alpha/etc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192519 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/ELFObjectFile.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index 5022be5..31783d4 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -28,6 +28,7 @@ #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" #include +#include #include #include -- cgit v1.1 From 4df7c5baa1dfe2d9de7eef2600c9ac325e9fdcd6 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Sun, 13 Oct 2013 22:09:26 +0000 Subject: MC: Don't assume incoming StringRef's are null terminated. This can happen when processing command line arguments, which are often stored as std::string's and later turned into StringRef's via std::string::data(). Unfortunately this is not guaranteed to return a null-terminated string until C++11, causing breakage on platforms that don't do this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192558 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/SubtargetFeature.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/SubtargetFeature.h b/include/llvm/MC/SubtargetFeature.h index acebf99..d0735cc 100644 --- a/include/llvm/MC/SubtargetFeature.h +++ b/include/llvm/MC/SubtargetFeature.h @@ -37,9 +37,9 @@ struct SubtargetFeatureKV { uint64_t Value; // K-V integer value uint64_t Implies; // K-V bit mask - // Compare routine for std binary search - bool operator<(const SubtargetFeatureKV &S) const { - return strcmp(Key, S.Key) < 0; + // Compare routine for std::lower_bound + bool operator<(StringRef S) const { + return StringRef(Key) < S; } }; @@ -52,9 +52,9 @@ struct SubtargetInfoKV { const char *Key; // K-V key string const void *Value; // K-V pointer value - // Compare routine for std binary search - bool operator<(const SubtargetInfoKV &S) const { - return strcmp(Key, S.Key) < 0; + // Compare routine for std::lower_bound + bool operator<(StringRef S) const { + return StringRef(Key) < S; } }; -- cgit v1.1 From 942827b1139c432239648ef54d1df5074eac36ec Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Mon, 14 Oct 2013 14:37:20 +0000 Subject: [AArch64] Add support for NEON scalar integer compare instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192596 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 8fcef7f..a2f4905 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -167,4 +167,28 @@ def int_aarch64_neon_vcvtf64_u64 : // Scalar Floating-point Reciprocal Exponent def int_aarch64_neon_vrecpx : Neon_1Arg_Intrinsic; + +class Neon_ICmp_Intrinsic + : Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], [IntrNoMem]>; + +// Scalar Integer Compare Equal +def int_aarch64_neon_vceq : Neon_ICmp_Intrinsic; + +// Scalar Integer Compare Greater-Than or Equal +def int_aarch64_neon_vcge : Neon_ICmp_Intrinsic; +def int_aarch64_neon_vchs : Neon_ICmp_Intrinsic; + +// Scalar Integer Compare Less-Than or Equal +def int_aarch64_neon_vclez : Neon_ICmp_Intrinsic; + +// Scalar Compare Less-Than +def int_aarch64_neon_vcltz : Neon_ICmp_Intrinsic; + +// Scalar Compare Greater-Than +def int_aarch64_neon_vcgt : Neon_ICmp_Intrinsic; +def int_aarch64_neon_vchi : Neon_ICmp_Intrinsic; + +// Scalar Compare Bitwise Test Bits +def int_aarch64_neon_vtstd : Neon_ICmp_Intrinsic; + } -- cgit v1.1 From 67b28826cdc7be697acdd3e536a05665fd2a9752 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 14 Oct 2013 16:39:04 +0000 Subject: Remove the now unused strong phi elimination pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192604 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/Passes.h | 8 -------- include/llvm/InitializePasses.h | 1 - 2 files changed, 9 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h index 4e9180c..552ed45 100644 --- a/include/llvm/CodeGen/Passes.h +++ b/include/llvm/CodeGen/Passes.h @@ -381,14 +381,6 @@ namespace llvm { /// these register allocator like this: AU.addRequiredID(PHIEliminationID); extern char &PHIEliminationID; - /// StrongPHIElimination - This pass eliminates machine instruction PHI - /// nodes by inserting copy instructions. This destroys SSA information, but - /// is the desired input for some register allocators. This pass is - /// "required" by these register allocator like this: - /// AU.addRequiredID(PHIEliminationID); - /// This pass is still in development - extern char &StrongPHIEliminationID; - /// LiveIntervals - This analysis keeps track of the live ranges of virtual /// and physical registers. extern char &LiveIntervalsID; diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h index bb82d94..6cb75cb 100644 --- a/include/llvm/InitializePasses.h +++ b/include/llvm/InitializePasses.h @@ -242,7 +242,6 @@ void initializeStripDeadPrototypesPassPass(PassRegistry&); void initializeStripDebugDeclarePass(PassRegistry&); void initializeStripNonDebugSymbolsPass(PassRegistry&); void initializeStripSymbolsPass(PassRegistry&); -void initializeStrongPHIEliminationPass(PassRegistry&); void initializeTailCallElimPass(PassRegistry&); void initializeTailDuplicatePassPass(PassRegistry&); void initializeTargetPassConfigPass(PassRegistry&); -- cgit v1.1 From 5601abb60dcf9617ee24f4fd2da13b1caa0f6965 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Mon, 14 Oct 2013 20:45:09 +0000 Subject: Convert LiveRegUnits methods to the current convention (it's new code). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192619 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveRegUnits.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveRegUnits.h b/include/llvm/CodeGen/LiveRegUnits.h index 2a9ca65..24ce911 100644 --- a/include/llvm/CodeGen/LiveRegUnits.h +++ b/include/llvm/CodeGen/LiveRegUnits.h @@ -42,13 +42,13 @@ namespace llvm { } /// Adds a register to the set. - void AddReg(unsigned Reg, const MCRegisterInfo &MCRI) { + void addReg(unsigned Reg, const MCRegisterInfo &MCRI) { for (MCRegUnitIterator RUnits(Reg, &MCRI); RUnits.isValid(); ++RUnits) LiveUnits.insert(*RUnits); } /// Removes a register from the set. - void RemoveReg(unsigned Reg, const MCRegisterInfo &MCRI) { + void removeReg(unsigned Reg, const MCRegisterInfo &MCRI) { for (MCRegUnitIterator RUnits(Reg, &MCRI); RUnits.isValid(); ++RUnits) LiveUnits.erase(*RUnits); } @@ -57,13 +57,13 @@ namespace llvm { /// Note that we assume the high bits of a physical super register are not /// preserved unless the instruction has an implicit-use operand reading /// the super-register or a register unit for the upper bits is available. - void RemoveRegsInMask(const MachineOperand &Op, + void removeRegsInMask(const MachineOperand &Op, const MCRegisterInfo &MCRI) { const uint32_t *Mask = Op.getRegMask(); unsigned Bit = 0; for (unsigned R = 0; R < MCRI.getNumRegs(); ++R) { if ((*Mask & (1u << Bit)) == 0) - RemoveReg(R, MCRI); + removeReg(R, MCRI); ++Bit; if (Bit >= 32) { Bit = 0; @@ -74,7 +74,7 @@ namespace llvm { /// Returns true if register @p Reg (or one of its super register) is /// contained in the set. - bool Contains(unsigned Reg, const MCRegisterInfo &MCRI) const { + bool contains(unsigned Reg, const MCRegisterInfo &MCRI) const { for (MCRegUnitIterator RUnits(Reg, &MCRI); RUnits.isValid(); ++RUnits) { if (LiveUnits.count(*RUnits)) return true; @@ -84,7 +84,7 @@ namespace llvm { /// Simulates liveness when stepping backwards over an instruction(bundle): /// Defs are removed from the set, uses added. - void StepBackward(const MachineInstr &MI, const MCRegisterInfo &MCRI) { + void stepBackward(const MachineInstr &MI, const MCRegisterInfo &MCRI) { // Remove defined registers and regmask kills from the set. for (ConstMIBundleOperands O(&MI); O.isValid(); ++O) { if (O->isReg()) { @@ -93,9 +93,9 @@ namespace llvm { unsigned Reg = O->getReg(); if (Reg == 0) continue; - RemoveReg(Reg, MCRI); + removeReg(Reg, MCRI); } else if (O->isRegMask()) { - RemoveRegsInMask(*O, MCRI); + removeRegsInMask(*O, MCRI); } } // Add uses to the set. @@ -105,7 +105,7 @@ namespace llvm { unsigned Reg = O->getReg(); if (Reg == 0) continue; - AddReg(Reg, MCRI); + addReg(Reg, MCRI); } } @@ -115,7 +115,7 @@ namespace llvm { /// Uses with kill flag get removed from the set, defs added. If possible /// use StepBackward() instead of this function because some kill flags may /// be missing. - void StepForward(const MachineInstr &MI, const MCRegisterInfo &MCRI) { + void stepForward(const MachineInstr &MI, const MCRegisterInfo &MCRI) { SmallVector Defs; // Remove killed registers from the set. for (ConstMIBundleOperands O(&MI); O.isValid(); ++O) { @@ -130,23 +130,23 @@ namespace llvm { if (!O->isKill()) continue; assert(O->isUse()); - RemoveReg(Reg, MCRI); + removeReg(Reg, MCRI); } } else if (O->isRegMask()) { - RemoveRegsInMask(*O, MCRI); + removeRegsInMask(*O, MCRI); } } // Add defs to the set. for (unsigned i = 0, e = Defs.size(); i != e; ++i) { - AddReg(Defs[i], MCRI); + addReg(Defs[i], MCRI); } } /// Adds all registers in the live-in list of block @p BB. - void AddLiveIns(const MachineBasicBlock &BB, const MCRegisterInfo &MCRI) { + void addLiveIns(const MachineBasicBlock &BB, const MCRegisterInfo &MCRI) { for (MachineBasicBlock::livein_iterator L = BB.livein_begin(), LE = BB.livein_end(); L != LE; ++L) { - AddReg(*L, MCRI); + addReg(*L, MCRI); } } }; -- cgit v1.1 From a3e69a0467f1d6462909988b1c763f54f9189eb9 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Mon, 14 Oct 2013 20:45:11 +0000 Subject: Remove extra indentation in LiveRegUnits. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192620 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveRegUnits.h | 224 ++++++++++++++++++------------------ 1 file changed, 112 insertions(+), 112 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveRegUnits.h b/include/llvm/CodeGen/LiveRegUnits.h index 24ce911..c7b811d 100644 --- a/include/llvm/CodeGen/LiveRegUnits.h +++ b/include/llvm/CodeGen/LiveRegUnits.h @@ -24,133 +24,133 @@ namespace llvm { - class MachineInstr; - - /// A set of live register units with functions to track liveness when walking - /// backward/forward through a basic block. - class LiveRegUnits { - SmallSet LiveUnits; - - public: - /// Constructs a new empty LiveRegUnits set. - LiveRegUnits() { - } - - /// Constructs a new LiveRegUnits set by copying @p Other. - LiveRegUnits(const LiveRegUnits &Other) - : LiveUnits(Other.LiveUnits) { - } - - /// Adds a register to the set. - void addReg(unsigned Reg, const MCRegisterInfo &MCRI) { - for (MCRegUnitIterator RUnits(Reg, &MCRI); RUnits.isValid(); ++RUnits) - LiveUnits.insert(*RUnits); - } - - /// Removes a register from the set. - void removeReg(unsigned Reg, const MCRegisterInfo &MCRI) { - for (MCRegUnitIterator RUnits(Reg, &MCRI); RUnits.isValid(); ++RUnits) - LiveUnits.erase(*RUnits); - } - - /// \brief Removes registers clobbered by the regmask operand @p Op. - /// Note that we assume the high bits of a physical super register are not - /// preserved unless the instruction has an implicit-use operand reading - /// the super-register or a register unit for the upper bits is available. - void removeRegsInMask(const MachineOperand &Op, - const MCRegisterInfo &MCRI) { - const uint32_t *Mask = Op.getRegMask(); - unsigned Bit = 0; - for (unsigned R = 0; R < MCRI.getNumRegs(); ++R) { - if ((*Mask & (1u << Bit)) == 0) - removeReg(R, MCRI); - ++Bit; - if (Bit >= 32) { - Bit = 0; - ++Mask; - } +class MachineInstr; + +/// A set of live register units with functions to track liveness when walking +/// backward/forward through a basic block. +class LiveRegUnits { + SmallSet LiveUnits; + +public: + /// Constructs a new empty LiveRegUnits set. + LiveRegUnits() { + } + + /// Constructs a new LiveRegUnits set by copying @p Other. + LiveRegUnits(const LiveRegUnits &Other) + : LiveUnits(Other.LiveUnits) { + } + + /// Adds a register to the set. + void addReg(unsigned Reg, const MCRegisterInfo &MCRI) { + for (MCRegUnitIterator RUnits(Reg, &MCRI); RUnits.isValid(); ++RUnits) + LiveUnits.insert(*RUnits); + } + + /// Removes a register from the set. + void removeReg(unsigned Reg, const MCRegisterInfo &MCRI) { + for (MCRegUnitIterator RUnits(Reg, &MCRI); RUnits.isValid(); ++RUnits) + LiveUnits.erase(*RUnits); + } + + /// \brief Removes registers clobbered by the regmask operand @p Op. + /// Note that we assume the high bits of a physical super register are not + /// preserved unless the instruction has an implicit-use operand reading + /// the super-register or a register unit for the upper bits is available. + void removeRegsInMask(const MachineOperand &Op, + const MCRegisterInfo &MCRI) { + const uint32_t *Mask = Op.getRegMask(); + unsigned Bit = 0; + for (unsigned R = 0; R < MCRI.getNumRegs(); ++R) { + if ((*Mask & (1u << Bit)) == 0) + removeReg(R, MCRI); + ++Bit; + if (Bit >= 32) { + Bit = 0; + ++Mask; } } - - /// Returns true if register @p Reg (or one of its super register) is - /// contained in the set. - bool contains(unsigned Reg, const MCRegisterInfo &MCRI) const { - for (MCRegUnitIterator RUnits(Reg, &MCRI); RUnits.isValid(); ++RUnits) { - if (LiveUnits.count(*RUnits)) - return true; - } - return false; + } + + /// Returns true if register @p Reg (or one of its super register) is + /// contained in the set. + bool contains(unsigned Reg, const MCRegisterInfo &MCRI) const { + for (MCRegUnitIterator RUnits(Reg, &MCRI); RUnits.isValid(); ++RUnits) { + if (LiveUnits.count(*RUnits)) + return true; } - - /// Simulates liveness when stepping backwards over an instruction(bundle): - /// Defs are removed from the set, uses added. - void stepBackward(const MachineInstr &MI, const MCRegisterInfo &MCRI) { - // Remove defined registers and regmask kills from the set. - for (ConstMIBundleOperands O(&MI); O.isValid(); ++O) { - if (O->isReg()) { - if (!O->isDef()) - continue; - unsigned Reg = O->getReg(); - if (Reg == 0) - continue; - removeReg(Reg, MCRI); - } else if (O->isRegMask()) { - removeRegsInMask(*O, MCRI); - } - } - // Add uses to the set. - for (ConstMIBundleOperands O(&MI); O.isValid(); ++O) { - if (!O->isReg() || !O->readsReg() || O->isUndef()) + return false; + } + + /// Simulates liveness when stepping backwards over an instruction(bundle): + /// Defs are removed from the set, uses added. + void stepBackward(const MachineInstr &MI, const MCRegisterInfo &MCRI) { + // Remove defined registers and regmask kills from the set. + for (ConstMIBundleOperands O(&MI); O.isValid(); ++O) { + if (O->isReg()) { + if (!O->isDef()) continue; unsigned Reg = O->getReg(); if (Reg == 0) continue; - addReg(Reg, MCRI); + removeReg(Reg, MCRI); + } else if (O->isRegMask()) { + removeRegsInMask(*O, MCRI); } } - - /// \brief Simulates liveness when stepping forward over an - /// instruction(bundle). - /// - /// Uses with kill flag get removed from the set, defs added. If possible - /// use StepBackward() instead of this function because some kill flags may - /// be missing. - void stepForward(const MachineInstr &MI, const MCRegisterInfo &MCRI) { - SmallVector Defs; - // Remove killed registers from the set. - for (ConstMIBundleOperands O(&MI); O.isValid(); ++O) { - if (O->isReg()) { - unsigned Reg = O->getReg(); - if (Reg == 0) + // Add uses to the set. + for (ConstMIBundleOperands O(&MI); O.isValid(); ++O) { + if (!O->isReg() || !O->readsReg() || O->isUndef()) + continue; + unsigned Reg = O->getReg(); + if (Reg == 0) + continue; + addReg(Reg, MCRI); + } + } + + /// \brief Simulates liveness when stepping forward over an + /// instruction(bundle). + /// + /// Uses with kill flag get removed from the set, defs added. If possible + /// use StepBackward() instead of this function because some kill flags may + /// be missing. + void stepForward(const MachineInstr &MI, const MCRegisterInfo &MCRI) { + SmallVector Defs; + // Remove killed registers from the set. + for (ConstMIBundleOperands O(&MI); O.isValid(); ++O) { + if (O->isReg()) { + unsigned Reg = O->getReg(); + if (Reg == 0) + continue; + if (O->isDef()) { + if (!O->isDead()) + Defs.push_back(Reg); + } else { + if (!O->isKill()) continue; - if (O->isDef()) { - if (!O->isDead()) - Defs.push_back(Reg); - } else { - if (!O->isKill()) - continue; - assert(O->isUse()); - removeReg(Reg, MCRI); - } - } else if (O->isRegMask()) { - removeRegsInMask(*O, MCRI); + assert(O->isUse()); + removeReg(Reg, MCRI); } + } else if (O->isRegMask()) { + removeRegsInMask(*O, MCRI); } - // Add defs to the set. - for (unsigned i = 0, e = Defs.size(); i != e; ++i) { - addReg(Defs[i], MCRI); - } } + // Add defs to the set. + for (unsigned i = 0, e = Defs.size(); i != e; ++i) { + addReg(Defs[i], MCRI); + } + } - /// Adds all registers in the live-in list of block @p BB. - void addLiveIns(const MachineBasicBlock &BB, const MCRegisterInfo &MCRI) { - for (MachineBasicBlock::livein_iterator L = BB.livein_begin(), - LE = BB.livein_end(); L != LE; ++L) { - addReg(*L, MCRI); - } + /// Adds all registers in the live-in list of block @p BB. + void addLiveIns(const MachineBasicBlock &BB, const MCRegisterInfo &MCRI) { + for (MachineBasicBlock::livein_iterator L = BB.livein_begin(), + LE = BB.livein_end(); L != LE; ++L) { + addReg(*L, MCRI); } - }; + } +}; -} +} // namespace llvm #endif -- cgit v1.1 From eb3b9f8ed979c34b7c11d749efb85df7fe1cfc9a Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Mon, 14 Oct 2013 20:45:14 +0000 Subject: Move LiveRegUnits implementation into .cpp. Comment and format. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192621 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveRegUnits.h | 100 +++++------------------------------- 1 file changed, 13 insertions(+), 87 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveRegUnits.h b/include/llvm/CodeGen/LiveRegUnits.h index c7b811d..0c6df88 100644 --- a/include/llvm/CodeGen/LiveRegUnits.h +++ b/include/llvm/CodeGen/LiveRegUnits.h @@ -32,47 +32,30 @@ class LiveRegUnits { SmallSet LiveUnits; public: - /// Constructs a new empty LiveRegUnits set. - LiveRegUnits() { - } + /// \brief Constructs a new empty LiveRegUnits set. + LiveRegUnits() {} - /// Constructs a new LiveRegUnits set by copying @p Other. + /// \brief Constructs a new LiveRegUnits set by copying @p Other. LiveRegUnits(const LiveRegUnits &Other) : LiveUnits(Other.LiveUnits) { } - /// Adds a register to the set. + /// \brief Adds a register to the set. void addReg(unsigned Reg, const MCRegisterInfo &MCRI) { for (MCRegUnitIterator RUnits(Reg, &MCRI); RUnits.isValid(); ++RUnits) LiveUnits.insert(*RUnits); } - /// Removes a register from the set. + /// \brief Removes a register from the set. void removeReg(unsigned Reg, const MCRegisterInfo &MCRI) { for (MCRegUnitIterator RUnits(Reg, &MCRI); RUnits.isValid(); ++RUnits) LiveUnits.erase(*RUnits); } /// \brief Removes registers clobbered by the regmask operand @p Op. - /// Note that we assume the high bits of a physical super register are not - /// preserved unless the instruction has an implicit-use operand reading - /// the super-register or a register unit for the upper bits is available. - void removeRegsInMask(const MachineOperand &Op, - const MCRegisterInfo &MCRI) { - const uint32_t *Mask = Op.getRegMask(); - unsigned Bit = 0; - for (unsigned R = 0; R < MCRI.getNumRegs(); ++R) { - if ((*Mask & (1u << Bit)) == 0) - removeReg(R, MCRI); - ++Bit; - if (Bit >= 32) { - Bit = 0; - ++Mask; - } - } - } + void removeRegsInMask(const MachineOperand &Op, const MCRegisterInfo &MCRI); - /// Returns true if register @p Reg (or one of its super register) is + /// \brief Returns true if register @p Reg (or one of its super register) is /// contained in the set. bool contains(unsigned Reg, const MCRegisterInfo &MCRI) const { for (MCRegUnitIterator RUnits(Reg, &MCRI); RUnits.isValid(); ++RUnits) { @@ -82,73 +65,16 @@ public: return false; } - /// Simulates liveness when stepping backwards over an instruction(bundle): - /// Defs are removed from the set, uses added. - void stepBackward(const MachineInstr &MI, const MCRegisterInfo &MCRI) { - // Remove defined registers and regmask kills from the set. - for (ConstMIBundleOperands O(&MI); O.isValid(); ++O) { - if (O->isReg()) { - if (!O->isDef()) - continue; - unsigned Reg = O->getReg(); - if (Reg == 0) - continue; - removeReg(Reg, MCRI); - } else if (O->isRegMask()) { - removeRegsInMask(*O, MCRI); - } - } - // Add uses to the set. - for (ConstMIBundleOperands O(&MI); O.isValid(); ++O) { - if (!O->isReg() || !O->readsReg() || O->isUndef()) - continue; - unsigned Reg = O->getReg(); - if (Reg == 0) - continue; - addReg(Reg, MCRI); - } - } + /// \brief Simulates liveness when stepping backwards over an + /// instruction(bundle): Remove Defs, add uses. + void stepBackward(const MachineInstr &MI, const MCRegisterInfo &MCRI); /// \brief Simulates liveness when stepping forward over an - /// instruction(bundle). - /// - /// Uses with kill flag get removed from the set, defs added. If possible - /// use StepBackward() instead of this function because some kill flags may - /// be missing. - void stepForward(const MachineInstr &MI, const MCRegisterInfo &MCRI) { - SmallVector Defs; - // Remove killed registers from the set. - for (ConstMIBundleOperands O(&MI); O.isValid(); ++O) { - if (O->isReg()) { - unsigned Reg = O->getReg(); - if (Reg == 0) - continue; - if (O->isDef()) { - if (!O->isDead()) - Defs.push_back(Reg); - } else { - if (!O->isKill()) - continue; - assert(O->isUse()); - removeReg(Reg, MCRI); - } - } else if (O->isRegMask()) { - removeRegsInMask(*O, MCRI); - } - } - // Add defs to the set. - for (unsigned i = 0, e = Defs.size(); i != e; ++i) { - addReg(Defs[i], MCRI); - } - } + /// instruction(bundle): Remove killed-uses, add defs. + void stepForward(const MachineInstr &MI, const MCRegisterInfo &MCRI); /// Adds all registers in the live-in list of block @p BB. - void addLiveIns(const MachineBasicBlock &BB, const MCRegisterInfo &MCRI) { - for (MachineBasicBlock::livein_iterator L = BB.livein_begin(), - LE = BB.livein_end(); L != LE; ++L) { - addReg(*L, MCRI); - } - } + void addLiveIns(const MachineBasicBlock &BB, const MCRegisterInfo &MCRI); }; } // namespace llvm -- cgit v1.1 From 7c489ab36564ddde3fa672aff52cfcae06517dfc Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Mon, 14 Oct 2013 20:45:17 +0000 Subject: Use a SparseSet in LiveRegUnits. Some clients may add block live ins and may track liveness over a large scope. This guarantees an efficient implementation in all cases with no memory allocation/deallocation, independent of the number of target registers. It could be slightly less convenient but is fine in the expected case. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192622 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveRegUnits.h | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveRegUnits.h b/include/llvm/CodeGen/LiveRegUnits.h index 0c6df88..1e24e69 100644 --- a/include/llvm/CodeGen/LiveRegUnits.h +++ b/include/llvm/CodeGen/LiveRegUnits.h @@ -17,9 +17,9 @@ #ifndef LLVM_CODEGEN_LIVEREGUNITS_H #define LLVM_CODEGEN_LIVEREGUNITS_H -#include "llvm/ADT/SmallSet.h" +#include "llvm/ADT/SparseSet.h" #include "llvm/CodeGen/MachineBasicBlock.h" -#include "llvm/MC/MCRegisterInfo.h" +#include "llvm/Target/TargetRegisterInfo.h" #include namespace llvm { @@ -29,17 +29,23 @@ class MachineInstr; /// A set of live register units with functions to track liveness when walking /// backward/forward through a basic block. class LiveRegUnits { - SmallSet LiveUnits; + SparseSet LiveUnits; + LiveRegUnits(const LiveRegUnits&) LLVM_DELETED_FUNCTION; + LiveRegUnits &operator=(const LiveRegUnits&) LLVM_DELETED_FUNCTION; public: /// \brief Constructs a new empty LiveRegUnits set. LiveRegUnits() {} - /// \brief Constructs a new LiveRegUnits set by copying @p Other. - LiveRegUnits(const LiveRegUnits &Other) - : LiveUnits(Other.LiveUnits) { + void init(const TargetRegisterInfo *TRI) { + LiveUnits.clear(); + LiveUnits.setUniverse(TRI->getNumRegs()); } + void clear() { LiveUnits.clear(); } + + bool empty() const { return LiveUnits.empty(); } + /// \brief Adds a register to the set. void addReg(unsigned Reg, const MCRegisterInfo &MCRI) { for (MCRegUnitIterator RUnits(Reg, &MCRI); RUnits.isValid(); ++RUnits) @@ -73,7 +79,7 @@ public: /// instruction(bundle): Remove killed-uses, add defs. void stepForward(const MachineInstr &MI, const MCRegisterInfo &MCRI); - /// Adds all registers in the live-in list of block @p BB. + /// \brief Adds all registers in the live-in list of block @p BB. void addLiveIns(const MachineBasicBlock &BB, const MCRegisterInfo &MCRI); }; -- cgit v1.1 From 966772931eea7cdc3cdd7199e304d667aa344bd7 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Mon, 14 Oct 2013 22:18:59 +0000 Subject: LiveRegUnits: Use *MBB for consistency and convenience. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192634 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveRegUnits.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveRegUnits.h b/include/llvm/CodeGen/LiveRegUnits.h index 1e24e69..02b9c55 100644 --- a/include/llvm/CodeGen/LiveRegUnits.h +++ b/include/llvm/CodeGen/LiveRegUnits.h @@ -80,7 +80,7 @@ public: void stepForward(const MachineInstr &MI, const MCRegisterInfo &MCRI); /// \brief Adds all registers in the live-in list of block @p BB. - void addLiveIns(const MachineBasicBlock &BB, const MCRegisterInfo &MCRI); + void addLiveIns(const MachineBasicBlock *MBB, const MCRegisterInfo &MCRI); }; } // namespace llvm -- cgit v1.1 From a6a9ac5aa1092067e6e1546226d8bdd6a4bfcf99 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Mon, 14 Oct 2013 22:19:03 +0000 Subject: Fix the ExecutionDepsFix pass to handle AVX instructions. This pass is needed to break false dependencies. Without it, unlucky register assignment can result in wild (5x) swings in performance. This pass was trying to handle AVX but not getting it right. AVX doesn't have partial register defs, it has unused register reads in which the high bits of a source operand are copied into the unused bits of the dest. Fixing this requires conservative liveness analysis. This is awkard because the pass already has its own pseudo-liveness. However, proper liveness is expensive, and we would like to use a generic utility to compute it. The fix only invokes liveness on-demand. It is rare to detect a case that needs undef-read dependence breaking, but when it happens, it can be needed many times within a very large block. I think the existing heuristic which uses a register window of 16 is too conservative for loop-carried false dependencies. If the loop is a reduction. The out-of-order engine may be able to execute several loop iterations in parallel. However, I'll leave this tuning exercise for next time. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192635 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetInstrInfo.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include') diff --git a/include/llvm/Target/TargetInstrInfo.h b/include/llvm/Target/TargetInstrInfo.h index b8599da..f9edc7d 100644 --- a/include/llvm/Target/TargetInstrInfo.h +++ b/include/llvm/Target/TargetInstrInfo.h @@ -942,6 +942,26 @@ public: return 0; } + /// \brief Return the minimum clearance before an instruction that reads an + /// unused register. + /// + /// For example, AVX instructions may copy part of an register operand into + /// the unused high bits of the destination register. + /// + /// vcvtsi2sdq %rax, %xmm0, %xmm14 + /// + /// In the code above, vcvtsi2sdq copies %xmm0[127:64] into %xmm14 creating a + /// false dependence on any previous write to %xmm0. + /// + /// This hook works similarly to getPartialRegUpdateClearance, except that it + /// does not take an operand index. Instead sets \p OpNum to the index of the + /// unused register. + virtual unsigned getUndefRegClearance(const MachineInstr *MI, unsigned &OpNum, + const TargetRegisterInfo *TRI) const { + // The default implementation returns 0 for no undef register dependency. + return 0; + } + /// breakPartialRegDependency - Insert a dependency-breaking instruction /// before MI to eliminate an unwanted dependency on OpNum. /// -- cgit v1.1 From efc053bd679aec40cc3fc0ac9a3ff7ecca35be2a Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 14 Oct 2013 23:40:11 +0000 Subject: Remove dead code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192642 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/TargetRegistry.h | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/TargetRegistry.h b/include/llvm/Support/TargetRegistry.h index 8c9a917..0bcb0ba 100644 --- a/include/llvm/Support/TargetRegistry.h +++ b/include/llvm/Support/TargetRegistry.h @@ -277,27 +277,6 @@ namespace llvm { /// hasMCAsmBackend - Check if this target supports .o generation. bool hasMCAsmBackend() const { return MCAsmBackendCtorFn != 0; } - /// hasAsmParser - Check if this target supports .s parsing. - bool hasMCAsmParser() const { return MCAsmParserCtorFn != 0; } - - /// hasAsmPrinter - Check if this target supports .s printing. - bool hasAsmPrinter() const { return AsmPrinterCtorFn != 0; } - - /// hasMCDisassembler - Check if this target has a disassembler. - bool hasMCDisassembler() const { return MCDisassemblerCtorFn != 0; } - - /// hasMCInstPrinter - Check if this target has an instruction printer. - bool hasMCInstPrinter() const { return MCInstPrinterCtorFn != 0; } - - /// hasMCCodeEmitter - Check if this target supports instruction encoding. - bool hasMCCodeEmitter() const { return MCCodeEmitterCtorFn != 0; } - - /// hasMCObjectStreamer - Check if this target supports streaming to files. - bool hasMCObjectStreamer() const { return MCObjectStreamerCtorFn != 0; } - - /// hasAsmStreamer - Check if this target supports streaming to files. - bool hasAsmStreamer() const { return AsmStreamerCtorFn != 0; } - /// @} /// @name Feature Constructors /// @{ -- cgit v1.1 From cc3d76d98259ef82c9592022cb0e31fb42b36ab6 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Tue, 15 Oct 2013 02:03:44 +0000 Subject: Simplify formatting and sort these. No functionality changed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192668 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/Passes.h | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h index 552ed45..7df4cbf 100644 --- a/include/llvm/CodeGen/Passes.h +++ b/include/llvm/CodeGen/Passes.h @@ -21,21 +21,17 @@ namespace llvm { - class FunctionPass; - class MachineFunctionPass; - struct MachineSchedContext; - class PassInfo; - class PassManagerBase; - class ScheduleDAGInstrs; - class TargetLoweringBase; - class TargetLowering; - class TargetRegisterClass; - class raw_ostream; -} - -namespace llvm { - +class FunctionPass; +class MachineFunctionPass; class PassConfigImpl; +class PassInfo; +class PassManagerBase; +class ScheduleDAGInstrs; +class TargetLowering; +class TargetLoweringBase; +class TargetRegisterClass; +class raw_ostream; +struct MachineSchedContext; /// Discriminated union of Pass ID types. /// -- cgit v1.1 From 390ff499f053771cba51a2f42651f126a7e096f7 Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Tue, 15 Oct 2013 05:20:47 +0000 Subject: Remove x86_sse42_crc32_64_8 intrinsic. It has no functional difference from x86_sse42_crc32_32_8 and was not mapped to a clang builtin. I'm not even sure why this form of the instruction is even called out explicitly in the docs. Also add AutoUpgrade support to convert it into the other intrinsic with appropriate trunc and zext. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192672 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 3 --- 1 file changed, 3 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index 54ea37e..052fa84 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -966,9 +966,6 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_sse42_crc32_32_32 : GCCBuiltin<"__builtin_ia32_crc32si">, Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty], [IntrNoMem]>; - def int_x86_sse42_crc32_64_8 : - Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i8_ty], - [IntrNoMem]>; def int_x86_sse42_crc32_64_64 : GCCBuiltin<"__builtin_ia32_crc32di">, Intrinsic<[llvm_i64_ty], [llvm_i64_ty, llvm_i64_ty], [IntrNoMem]>; -- cgit v1.1 From 6480db4b3afb0adb0ffcedc6e88e3b3f394a86cf Mon Sep 17 00:00:00 2001 From: Anders Waldenborg Date: Tue, 15 Oct 2013 12:08:59 +0000 Subject: Add AllTargetsBindings sublibrary instead of having static inlines in the llvm-c headers. This new library will be linked in when using the "all-targets" component and contains the LLVMInitializeAll* functions. This means that those functions will exist as real symbols in the shared library, and can therefore can be called from bindings that are using ffi the shared library. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192690 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Target.h | 47 +++++++++++------------------------------------ 1 file changed, 11 insertions(+), 36 deletions(-) (limited to 'include') diff --git a/include/llvm-c/Target.h b/include/llvm-c/Target.h index 80fc3e5..1d7884f 100644 --- a/include/llvm-c/Target.h +++ b/include/llvm-c/Target.h @@ -71,62 +71,37 @@ typedef struct LLVMStructLayout *LLVMStructLayoutRef; void LLVMInitialize##TargetName##Disassembler(void); #include "llvm/Config/Disassemblers.def" #undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */ - + /** LLVMInitializeAllTargetInfos - The main program should call this function if it wants access to all available targets that LLVM is configured to support. */ -static inline void LLVMInitializeAllTargetInfos(void) { -#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo(); -#include "llvm/Config/Targets.def" -#undef LLVM_TARGET /* Explicit undef to make SWIG happier */ -} +void LLVMInitializeAllTargetInfos(void); /** LLVMInitializeAllTargets - The main program should call this function if it wants to link in all available targets that LLVM is configured to support. */ -static inline void LLVMInitializeAllTargets(void) { -#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target(); -#include "llvm/Config/Targets.def" -#undef LLVM_TARGET /* Explicit undef to make SWIG happier */ -} +void LLVMInitializeAllTargets(void); /** LLVMInitializeAllTargetMCs - The main program should call this function if it wants access to all available target MC that LLVM is configured to support. */ -static inline void LLVMInitializeAllTargetMCs(void) { -#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC(); -#include "llvm/Config/Targets.def" -#undef LLVM_TARGET /* Explicit undef to make SWIG happier */ -} - +void LLVMInitializeAllTargetMCs(void); + /** LLVMInitializeAllAsmPrinters - The main program should call this function if it wants all asm printers that LLVM is configured to support, to make them available via the TargetRegistry. */ -static inline void LLVMInitializeAllAsmPrinters(void) { -#define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter(); -#include "llvm/Config/AsmPrinters.def" -#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */ -} - +void LLVMInitializeAllAsmPrinters(void); + /** LLVMInitializeAllAsmParsers - The main program should call this function if it wants all asm parsers that LLVM is configured to support, to make them available via the TargetRegistry. */ -static inline void LLVMInitializeAllAsmParsers(void) { -#define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser(); -#include "llvm/Config/AsmParsers.def" -#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */ -} - +void LLVMInitializeAllAsmParsers(void); + /** LLVMInitializeAllDisassemblers - The main program should call this function if it wants all disassemblers that LLVM is configured to support, to make them available via the TargetRegistry. */ -static inline void LLVMInitializeAllDisassemblers(void) { -#define LLVM_DISASSEMBLER(TargetName) \ - LLVMInitialize##TargetName##Disassembler(); -#include "llvm/Config/Disassemblers.def" -#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */ -} - +void LLVMInitializeAllDisassemblers(void); + /** LLVMInitializeNativeTarget - The main program should call this function to initialize the native target corresponding to the host. This is useful for JIT applications to ensure that the target gets linked in correctly. */ -- cgit v1.1 From bfcd45cfe114311b32b171c529fd387dd8eac55f Mon Sep 17 00:00:00 2001 From: Anders Waldenborg Date: Tue, 15 Oct 2013 13:04:27 +0000 Subject: Revert "Add AllTargetsBindings sublibrary" as it breaks cmake build on (atleast) windows and darwin. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192697 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Target.h | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/llvm-c/Target.h b/include/llvm-c/Target.h index 1d7884f..80fc3e5 100644 --- a/include/llvm-c/Target.h +++ b/include/llvm-c/Target.h @@ -71,37 +71,62 @@ typedef struct LLVMStructLayout *LLVMStructLayoutRef; void LLVMInitialize##TargetName##Disassembler(void); #include "llvm/Config/Disassemblers.def" #undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */ - + /** LLVMInitializeAllTargetInfos - The main program should call this function if it wants access to all available targets that LLVM is configured to support. */ -void LLVMInitializeAllTargetInfos(void); +static inline void LLVMInitializeAllTargetInfos(void) { +#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetInfo(); +#include "llvm/Config/Targets.def" +#undef LLVM_TARGET /* Explicit undef to make SWIG happier */ +} /** LLVMInitializeAllTargets - The main program should call this function if it wants to link in all available targets that LLVM is configured to support. */ -void LLVMInitializeAllTargets(void); +static inline void LLVMInitializeAllTargets(void) { +#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##Target(); +#include "llvm/Config/Targets.def" +#undef LLVM_TARGET /* Explicit undef to make SWIG happier */ +} /** LLVMInitializeAllTargetMCs - The main program should call this function if it wants access to all available target MC that LLVM is configured to support. */ -void LLVMInitializeAllTargetMCs(void); - +static inline void LLVMInitializeAllTargetMCs(void) { +#define LLVM_TARGET(TargetName) LLVMInitialize##TargetName##TargetMC(); +#include "llvm/Config/Targets.def" +#undef LLVM_TARGET /* Explicit undef to make SWIG happier */ +} + /** LLVMInitializeAllAsmPrinters - The main program should call this function if it wants all asm printers that LLVM is configured to support, to make them available via the TargetRegistry. */ -void LLVMInitializeAllAsmPrinters(void); - +static inline void LLVMInitializeAllAsmPrinters(void) { +#define LLVM_ASM_PRINTER(TargetName) LLVMInitialize##TargetName##AsmPrinter(); +#include "llvm/Config/AsmPrinters.def" +#undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */ +} + /** LLVMInitializeAllAsmParsers - The main program should call this function if it wants all asm parsers that LLVM is configured to support, to make them available via the TargetRegistry. */ -void LLVMInitializeAllAsmParsers(void); - +static inline void LLVMInitializeAllAsmParsers(void) { +#define LLVM_ASM_PARSER(TargetName) LLVMInitialize##TargetName##AsmParser(); +#include "llvm/Config/AsmParsers.def" +#undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */ +} + /** LLVMInitializeAllDisassemblers - The main program should call this function if it wants all disassemblers that LLVM is configured to support, to make them available via the TargetRegistry. */ -void LLVMInitializeAllDisassemblers(void); - +static inline void LLVMInitializeAllDisassemblers(void) { +#define LLVM_DISASSEMBLER(TargetName) \ + LLVMInitialize##TargetName##Disassembler(); +#include "llvm/Config/Disassemblers.def" +#undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */ +} + /** LLVMInitializeNativeTarget - The main program should call this function to initialize the native target corresponding to the host. This is useful for JIT applications to ensure that the target gets linked in correctly. */ -- cgit v1.1 From 977ce007ad49f122f8132a042ddb6b2c0fd53491 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Tue, 15 Oct 2013 21:22:12 +0000 Subject: Reformat. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192735 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 3e4a960..0a070fe 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -251,8 +251,7 @@ T DIRef::resolve(const DITypeIdentifierMap &Map) const { return T(Iter->second); } -template -StringRef DIRef::getName() const { +template StringRef DIRef::getName() const { if (!Val) return StringRef(); -- cgit v1.1 From b32b0376d4ac04fc2401e70aa0bdd2f6ce5a8968 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Tue, 15 Oct 2013 22:45:38 +0000 Subject: Path: Recognize Windows compiled resource file. Some background: One can pass compiled resource files (.res files) directly to the linker on Windows. If a resource file is given, the linker will run "cvtres" command in background to convert the resource file to a COFF file to link it. What I'm trying to do with this patch is to make the linker to recognize the resource file by file magic, so that it can run cvtres command. Differential Revision: http://llvm-reviews.chandlerc.com/D1943 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192742 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/FileSystem.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/FileSystem.h b/include/llvm/Support/FileSystem.h index 9d72a66..24bb8ea 100644 --- a/include/llvm/Support/FileSystem.h +++ b/include/llvm/Support/FileSystem.h @@ -238,7 +238,8 @@ struct file_magic { macho_dsym_companion, ///< Mach-O dSYM companion file macho_universal_binary, ///< Mach-O universal binary coff_object, ///< COFF object file - pecoff_executable ///< PECOFF executable file + pecoff_executable, ///< PECOFF executable file + windows_resource, ///< Windows compiled resource file (.rc) }; bool is_object() const { -- cgit v1.1 From cdfdb5e92bef3333be8445c4a6a78134f088bb63 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Tue, 15 Oct 2013 23:01:44 +0000 Subject: Support/FileSystem.h: Remove a trailing comma in enum file_magic::Impl. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192745 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/FileSystem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/FileSystem.h b/include/llvm/Support/FileSystem.h index 24bb8ea..f52785b 100644 --- a/include/llvm/Support/FileSystem.h +++ b/include/llvm/Support/FileSystem.h @@ -239,7 +239,7 @@ struct file_magic { macho_universal_binary, ///< Mach-O universal binary coff_object, ///< COFF object file pecoff_executable, ///< PECOFF executable file - windows_resource, ///< Windows compiled resource file (.rc) + windows_resource ///< Windows compiled resource file (.rc) }; bool is_object() const { -- cgit v1.1 From 43507d026bef31100cb0c35614bcf419029a265b Mon Sep 17 00:00:00 2001 From: Andrew Kaylor Date: Wed, 16 Oct 2013 00:14:21 +0000 Subject: Adding support for deregistering EH frames with MCJIT. Patch by Yaron Keren git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192753 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ExecutionEngine/RTDyldMemoryManager.h | 2 ++ include/llvm/ExecutionEngine/RuntimeDyld.h | 2 ++ 2 files changed, 4 insertions(+) (limited to 'include') diff --git a/include/llvm/ExecutionEngine/RTDyldMemoryManager.h b/include/llvm/ExecutionEngine/RTDyldMemoryManager.h index 468b823..3ad2e50 100644 --- a/include/llvm/ExecutionEngine/RTDyldMemoryManager.h +++ b/include/llvm/ExecutionEngine/RTDyldMemoryManager.h @@ -60,6 +60,8 @@ public: /// be the case for local execution) these two values will be the same. virtual void registerEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size); + virtual void deregisterEHFrames(uint8_t *Addr, uint64_t LoadAddr, size_t Size); + /// This method returns the address of the specified function or variable. /// It is used to resolve symbols during module linking. virtual uint64_t getSymbolAddress(const std::string &Name); diff --git a/include/llvm/ExecutionEngine/RuntimeDyld.h b/include/llvm/ExecutionEngine/RuntimeDyld.h index a5610fb..b832438 100644 --- a/include/llvm/ExecutionEngine/RuntimeDyld.h +++ b/include/llvm/ExecutionEngine/RuntimeDyld.h @@ -71,6 +71,8 @@ public: /// the actual target-specific EH frame registration. void registerEHFrames(); + void deregisterEHFrames(); + StringRef getErrorString(); }; -- cgit v1.1 From c7ce3e4f42219003f30382be17d966cb2dfb4e71 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 16 Oct 2013 01:05:45 +0000 Subject: Move .ident handling to MCStreamer. No functionality change, but exposes the API so that codegen can use it too. Patch by Katya Romanova. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192757 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAsmInfo.h | 5 +++++ include/llvm/MC/MCELFStreamer.h | 11 ++++++++--- include/llvm/MC/MCStreamer.h | 4 ++++ 3 files changed, 17 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h index 3734d7e..c9cecc1 100644 --- a/include/llvm/MC/MCAsmInfo.h +++ b/include/llvm/MC/MCAsmInfo.h @@ -271,6 +271,10 @@ namespace llvm { /// .file directive, this is true for ELF targets. bool HasSingleParameterDotFile; // Defaults to true. + /// hasIdentDirective - True if the target has a .ident directive, this is + /// true for ELF targets. + bool HasIdentDirective; // Defaults to false. + /// HasNoDeadStrip - True if this target supports the MachO .no_dead_strip /// directive. bool HasNoDeadStrip; // Defaults to false. @@ -523,6 +527,7 @@ namespace llvm { } bool hasDotTypeDotSizeDirective() const {return HasDotTypeDotSizeDirective;} bool hasSingleParameterDotFile() const { return HasSingleParameterDotFile; } + bool hasIdentDirective() const { return HasIdentDirective; } bool hasNoDeadStrip() const { return HasNoDeadStrip; } bool hasSymbolResolver() const { return HasSymbolResolver; } const char *getWeakRefDirective() const { return WeakRefDirective; } diff --git a/include/llvm/MC/MCELFStreamer.h b/include/llvm/MC/MCELFStreamer.h index 8dbe337..4e24dcf 100644 --- a/include/llvm/MC/MCELFStreamer.h +++ b/include/llvm/MC/MCELFStreamer.h @@ -31,13 +31,14 @@ class MCELFStreamer : public MCObjectStreamer { public: MCELFStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer, MCAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter) - : MCObjectStreamer(Context, TargetStreamer, TAB, OS, Emitter) {} + : MCObjectStreamer(Context, TargetStreamer, TAB, OS, Emitter), + SeenIdent(false) {} MCELFStreamer(MCContext &Context, MCTargetStreamer *TargetStreamer, MCAsmBackend &TAB, raw_ostream &OS, MCCodeEmitter *Emitter, MCAssembler *Assembler) - : MCObjectStreamer(Context, TargetStreamer, TAB, OS, Emitter, Assembler) { - } + : MCObjectStreamer(Context, TargetStreamer, TAB, OS, Emitter, Assembler), + SeenIdent(false) {} virtual ~MCELFStreamer(); @@ -77,6 +78,8 @@ public: virtual void EmitFileDirective(StringRef Filename); + virtual void EmitIdent(StringRef IdentString); + virtual void EmitValueToAlignment(unsigned, int64_t, unsigned, unsigned); virtual void Flush(); @@ -93,6 +96,8 @@ private: void fixSymbolsInTLSFixups(const MCExpr *expr); + bool SeenIdent; + struct LocalCommon { MCSymbolData *SD; uint64_t Size; diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index d24f3fd..974feea 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -571,6 +571,10 @@ public: /// implement the '.file "foo.c"' assembler directive. virtual void EmitFileDirective(StringRef Filename) = 0; + /// Emit the "identifiers" directive. This implements the + /// '.ident "version foo"' assembler directive. + virtual void EmitIdent(StringRef IdentString) {} + /// EmitDwarfFileDirective - Associate a filename with a specified logical /// file number. This implements the DWARF2 '.file 4 "foo.c"' assembler /// directive. -- cgit v1.1 From 06957f43f6051901590b318c10b1a0a5c7f898d4 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 16 Oct 2013 01:34:32 +0000 Subject: Add a MCAsmInfoELF class and factor some code into it. We had a MCAsmInfoCOFF, but no common class for all the ELF MCAsmInfos before. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192760 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAsmInfoELF.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 include/llvm/MC/MCAsmInfoELF.h (limited to 'include') diff --git a/include/llvm/MC/MCAsmInfoELF.h b/include/llvm/MC/MCAsmInfoELF.h new file mode 100644 index 0000000..27fea84 --- /dev/null +++ b/include/llvm/MC/MCAsmInfoELF.h @@ -0,0 +1,23 @@ +//===-- llvm/MC/MCAsmInfoELF.h - ELF Asm info -------------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_MC_MCASMINFOELF_H +#define LLVM_MC_MCASMINFOELF_H + +#include "llvm/MC/MCAsmInfo.h" + +namespace llvm { +class MCAsmInfoELF : public MCAsmInfo { + virtual void anchor(); +protected: + MCAsmInfoELF(); +}; +} + +#endif -- cgit v1.1 From 3aa342be500a55c3bbee302f3a8db937eaa2c241 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 16 Oct 2013 01:49:05 +0000 Subject: Add support for metadata representing .ident directives. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192764 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/AsmPrinter.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h index 997f5f3..d6a6ab4 100644 --- a/include/llvm/CodeGen/AsmPrinter.h +++ b/include/llvm/CodeGen/AsmPrinter.h @@ -491,6 +491,8 @@ namespace llvm { const MachineBasicBlock *MBB, unsigned uid) const; void EmitLLVMUsedList(const ConstantArray *InitList); + /// Emit llvm.ident metadata in an '.ident' directive. + void EmitModuleIdents(Module &M); void EmitXXStructorList(const Constant *List, bool isCtor); GCMetadataPrinter *GetOrCreateGCPrinter(GCStrategy *C); }; -- cgit v1.1 From 1e6810005f426798ce2541c26f0cdc7a08670846 Mon Sep 17 00:00:00 2001 From: Will Dietz Date: Wed, 16 Oct 2013 04:10:06 +0000 Subject: TypeFinder: prefer iterative algorithm to keep stack usage low. Introduce subtype_reverse_iterator to maintain the numbering assigned during the recursive type walk. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192770 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Type.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/Type.h b/include/llvm/IR/Type.h index 1bf8789..3cfb84e 100644 --- a/include/llvm/IR/Type.h +++ b/include/llvm/IR/Type.h @@ -324,6 +324,14 @@ public: subtype_iterator subtype_begin() const { return ContainedTys; } subtype_iterator subtype_end() const { return &ContainedTys[NumContainedTys];} + typedef std::reverse_iterator subtype_reverse_iterator; + subtype_reverse_iterator subtype_rbegin() const { + return subtype_reverse_iterator(subtype_end()); + } + subtype_reverse_iterator subtype_rend() const { + return subtype_reverse_iterator(subtype_begin()); + } + /// getContainedType - This method is used to implement the type iterator /// (defined a the end of the file). For derived types, this returns the /// types 'contained' in the derived type. -- cgit v1.1 From b4a0ba17183e1b4aa385e81e896c2a95671a40b2 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 16 Oct 2013 08:59:57 +0000 Subject: Add a 'deleteModule' method to the Linker class. This deletes the Module ivar instead of having the LTO code generater do it. It also sets the pointer to 'NULL', so that if it's used again it will abort quickly. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192778 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Linker.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm/Linker.h b/include/llvm/Linker.h index 3667b85..4f37459 100644 --- a/include/llvm/Linker.h +++ b/include/llvm/Linker.h @@ -32,7 +32,9 @@ class Linker { Linker(Module *M); ~Linker(); + Module *getModule() const { return Composite; } + void deleteModule(); /// \brief Link \p Src into the composite. The source is destroyed if /// \p Mode is DestroySource and preserved if it is PreserveSource. -- cgit v1.1 From a2cd42a0a7c46d158714c09047a77b7bc1cf9d69 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Wed, 16 Oct 2013 16:09:02 +0000 Subject: [AArch64] Add support for NEON scalar signed saturating accumulated of unsigned value and unsigned saturating accumulate of signed value instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192800 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index a2f4905..f99c597 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -191,4 +191,9 @@ def int_aarch64_neon_vchi : Neon_ICmp_Intrinsic; // Scalar Compare Bitwise Test Bits def int_aarch64_neon_vtstd : Neon_ICmp_Intrinsic; +// Scalar Signed Saturating Accumulated of Unsigned Value +def int_aarch64_neon_vuqadd : Neon_2Arg_Intrinsic; + +// Scalar Unsigned Saturating Accumulated of Unsigned Value +def int_aarch64_neon_vsqadd : Neon_2Arg_Intrinsic; } -- cgit v1.1 From 670655471dfc35d90271393bd3e6e26a708f1a3c Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 16 Oct 2013 16:21:40 +0000 Subject: Assert on duplicate registration. Don't depend on function pointer equality. Before this patch we would assert when building llvm as multiple shared libraries (cmake's BUILD_SHARED_LIBS). The problem was the line if (T.AsmStreamerCtorFn == Target::createDefaultAsmStreamer) which returns false because of -fvisibility-inlines-hidden. It is easy to fix just this one case, but I decided to try to also make the registration more strict. It looks like the old logic for ignoring followup registration was just a temporary hack that outlived its usefulness. This patch converts the ifs to asserts, fixes the few cases that were registering twice and makes sure all the asserts compare with null. Thanks for Joerg for reporting the problem and reviewing the patch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192803 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/TargetRegistry.h | 112 +++++++++++++++------------------- 1 file changed, 50 insertions(+), 62 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/TargetRegistry.h b/include/llvm/Support/TargetRegistry.h index 0bcb0ba..6cca9e8 100644 --- a/include/llvm/Support/TargetRegistry.h +++ b/include/llvm/Support/TargetRegistry.h @@ -235,22 +235,10 @@ namespace llvm { /// MCSymbolizer, if registered (default = llvm::createMCSymbolizer) MCSymbolizerCtorTy MCSymbolizerCtorFn; - static MCStreamer * - createDefaultAsmStreamer(MCContext &Ctx, formatted_raw_ostream &OS, - bool isVerboseAsm, bool useLoc, bool useCFI, - bool useDwarfDirectory, MCInstPrinter *InstPrint, - MCCodeEmitter *CE, MCAsmBackend *TAB, - bool ShowInst) { - return llvm::createAsmStreamer(Ctx, 0, OS, isVerboseAsm, useLoc, useCFI, - useDwarfDirectory, InstPrint, CE, TAB, - ShowInst); - } - public: Target() - : AsmStreamerCtorFn(createDefaultAsmStreamer), - MCRelocationInfoCtorFn(llvm::createMCRelocationInfo), - MCSymbolizerCtorFn(llvm::createMCSymbolizer) {} + : AsmStreamerCtorFn(0), MCRelocationInfoCtorFn(0), + MCSymbolizerCtorFn(0) {} /// @name Target Information /// @{ @@ -452,9 +440,13 @@ namespace llvm { MCCodeEmitter *CE, MCAsmBackend *TAB, bool ShowInst) const { - // AsmStreamerCtorFn is default to llvm::createAsmStreamer - return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useLoc, useCFI, - useDwarfDirectory, InstPrint, CE, TAB, ShowInst); + if (AsmStreamerCtorFn) + return AsmStreamerCtorFn(Ctx, OS, isVerboseAsm, useLoc, useCFI, + useDwarfDirectory, InstPrint, CE, TAB, + ShowInst); + return llvm::createAsmStreamer(Ctx, 0, OS, isVerboseAsm, useLoc, useCFI, + useDwarfDirectory, InstPrint, CE, TAB, + ShowInst); } /// createMCRelocationInfo - Create a target specific MCRelocationInfo. @@ -463,7 +455,10 @@ namespace llvm { /// \param Ctx The target context. MCRelocationInfo * createMCRelocationInfo(StringRef TT, MCContext &Ctx) const { - return MCRelocationInfoCtorFn(TT, Ctx); + MCRelocationInfoCtorTy Fn = MCRelocationInfoCtorFn + ? MCRelocationInfoCtorFn + : llvm::createMCRelocationInfo; + return Fn(TT, Ctx); } /// createMCSymbolizer - Create a target specific MCSymbolizer. @@ -480,8 +475,9 @@ namespace llvm { LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx, MCRelocationInfo *RelInfo) const { - return MCSymbolizerCtorFn(TT, GetOpInfo, SymbolLookUp, DisInfo, - Ctx, RelInfo); + MCSymbolizerCtorTy Fn = + MCSymbolizerCtorFn ? MCSymbolizerCtorFn : llvm::createMCSymbolizer; + return Fn(TT, GetOpInfo, SymbolLookUp, DisInfo, Ctx, RelInfo); } /// @} @@ -602,9 +598,8 @@ namespace llvm { /// @param T - The target being registered. /// @param Fn - A function to construct a MCAsmInfo for the target. static void RegisterMCAsmInfo(Target &T, Target::MCAsmInfoCtorFnTy Fn) { - // Ignore duplicate registration. - if (!T.MCAsmInfoCtorFn) - T.MCAsmInfoCtorFn = Fn; + assert(!T.MCAsmInfoCtorFn); + T.MCAsmInfoCtorFn = Fn; } /// RegisterMCCodeGenInfo - Register a MCCodeGenInfo implementation for the @@ -618,9 +613,8 @@ namespace llvm { /// @param Fn - A function to construct a MCCodeGenInfo for the target. static void RegisterMCCodeGenInfo(Target &T, Target::MCCodeGenInfoCtorFnTy Fn) { - // Ignore duplicate registration. - if (!T.MCCodeGenInfoCtorFn) - T.MCCodeGenInfoCtorFn = Fn; + assert(!T.MCCodeGenInfoCtorFn); + T.MCCodeGenInfoCtorFn = Fn; } /// RegisterMCInstrInfo - Register a MCInstrInfo implementation for the @@ -633,18 +627,16 @@ namespace llvm { /// @param T - The target being registered. /// @param Fn - A function to construct a MCInstrInfo for the target. static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn) { - // Ignore duplicate registration. - if (!T.MCInstrInfoCtorFn) - T.MCInstrInfoCtorFn = Fn; + assert(!T.MCInstrInfoCtorFn); + T.MCInstrInfoCtorFn = Fn; } /// RegisterMCInstrAnalysis - Register a MCInstrAnalysis implementation for /// the given target. static void RegisterMCInstrAnalysis(Target &T, Target::MCInstrAnalysisCtorFnTy Fn) { - // Ignore duplicate registration. - if (!T.MCInstrAnalysisCtorFn) - T.MCInstrAnalysisCtorFn = Fn; + assert(!T.MCInstrAnalysisCtorFn); + T.MCInstrAnalysisCtorFn = Fn; } /// RegisterMCRegInfo - Register a MCRegisterInfo implementation for the @@ -657,9 +649,8 @@ namespace llvm { /// @param T - The target being registered. /// @param Fn - A function to construct a MCRegisterInfo for the target. static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn) { - // Ignore duplicate registration. - if (!T.MCRegInfoCtorFn) - T.MCRegInfoCtorFn = Fn; + assert(!T.MCRegInfoCtorFn); + T.MCRegInfoCtorFn = Fn; } /// RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for @@ -673,9 +664,8 @@ namespace llvm { /// @param Fn - A function to construct a MCSubtargetInfo for the target. static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn) { - // Ignore duplicate registration. - if (!T.MCSubtargetInfoCtorFn) - T.MCSubtargetInfoCtorFn = Fn; + assert(!T.MCSubtargetInfoCtorFn); + T.MCSubtargetInfoCtorFn = Fn; } /// RegisterTargetMachine - Register a TargetMachine implementation for the @@ -689,9 +679,8 @@ namespace llvm { /// @param Fn - A function to construct a TargetMachine for the target. static void RegisterTargetMachine(Target &T, Target::TargetMachineCtorTy Fn) { - // Ignore duplicate registration. - if (!T.TargetMachineCtorFn) - T.TargetMachineCtorFn = Fn; + assert(!T.TargetMachineCtorFn); + T.TargetMachineCtorFn = Fn; } /// RegisterMCAsmBackend - Register a MCAsmBackend implementation for the @@ -704,8 +693,8 @@ namespace llvm { /// @param T - The target being registered. /// @param Fn - A function to construct an AsmBackend for the target. static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn) { - if (!T.MCAsmBackendCtorFn) - T.MCAsmBackendCtorFn = Fn; + assert(!T.MCAsmBackendCtorFn); + T.MCAsmBackendCtorFn = Fn; } /// RegisterMCAsmParser - Register a MCTargetAsmParser implementation for @@ -718,8 +707,8 @@ namespace llvm { /// @param T - The target being registered. /// @param Fn - A function to construct an MCTargetAsmParser for the target. static void RegisterMCAsmParser(Target &T, Target::MCAsmParserCtorTy Fn) { - if (!T.MCAsmParserCtorFn) - T.MCAsmParserCtorFn = Fn; + assert(!T.MCAsmParserCtorFn); + T.MCAsmParserCtorFn = Fn; } /// RegisterAsmPrinter - Register an AsmPrinter implementation for the given @@ -732,9 +721,8 @@ namespace llvm { /// @param T - The target being registered. /// @param Fn - A function to construct an AsmPrinter for the target. static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn) { - // Ignore duplicate registration. - if (!T.AsmPrinterCtorFn) - T.AsmPrinterCtorFn = Fn; + assert(!T.AsmPrinterCtorFn); + T.AsmPrinterCtorFn = Fn; } /// RegisterMCDisassembler - Register a MCDisassembler implementation for @@ -748,8 +736,8 @@ namespace llvm { /// @param Fn - A function to construct an MCDisassembler for the target. static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn) { - if (!T.MCDisassemblerCtorFn) - T.MCDisassemblerCtorFn = Fn; + assert(!T.MCDisassemblerCtorFn); + T.MCDisassemblerCtorFn = Fn; } /// RegisterMCInstPrinter - Register a MCInstPrinter implementation for the @@ -763,8 +751,8 @@ namespace llvm { /// @param Fn - A function to construct an MCInstPrinter for the target. static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn) { - if (!T.MCInstPrinterCtorFn) - T.MCInstPrinterCtorFn = Fn; + assert(!T.MCInstPrinterCtorFn); + T.MCInstPrinterCtorFn = Fn; } /// RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the @@ -778,8 +766,8 @@ namespace llvm { /// @param Fn - A function to construct an MCCodeEmitter for the target. static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn) { - if (!T.MCCodeEmitterCtorFn) - T.MCCodeEmitterCtorFn = Fn; + assert(!T.MCCodeEmitterCtorFn); + T.MCCodeEmitterCtorFn = Fn; } /// RegisterMCObjectStreamer - Register a object code MCStreamer @@ -793,8 +781,8 @@ namespace llvm { /// @param Fn - A function to construct an MCStreamer for the target. static void RegisterMCObjectStreamer(Target &T, Target::MCObjectStreamerCtorTy Fn) { - if (!T.MCObjectStreamerCtorFn) - T.MCObjectStreamerCtorFn = Fn; + assert(!T.MCObjectStreamerCtorFn); + T.MCObjectStreamerCtorFn = Fn; } /// RegisterAsmStreamer - Register an assembly MCStreamer implementation @@ -807,8 +795,8 @@ namespace llvm { /// @param T - The target being registered. /// @param Fn - A function to construct an MCStreamer for the target. static void RegisterAsmStreamer(Target &T, Target::AsmStreamerCtorTy Fn) { - if (T.AsmStreamerCtorFn == Target::createDefaultAsmStreamer) - T.AsmStreamerCtorFn = Fn; + assert(!T.AsmStreamerCtorFn); + T.AsmStreamerCtorFn = Fn; } /// RegisterMCRelocationInfo - Register an MCRelocationInfo @@ -822,8 +810,8 @@ namespace llvm { /// @param Fn - A function to construct an MCRelocationInfo for the target. static void RegisterMCRelocationInfo(Target &T, Target::MCRelocationInfoCtorTy Fn) { - if (T.MCRelocationInfoCtorFn == llvm::createMCRelocationInfo) - T.MCRelocationInfoCtorFn = Fn; + assert(!T.MCRelocationInfoCtorFn); + T.MCRelocationInfoCtorFn = Fn; } /// RegisterMCSymbolizer - Register an MCSymbolizer @@ -837,8 +825,8 @@ namespace llvm { /// @param Fn - A function to construct an MCSymbolizer for the target. static void RegisterMCSymbolizer(Target &T, Target::MCSymbolizerCtorTy Fn) { - if (T.MCSymbolizerCtorFn == llvm::createMCSymbolizer) - T.MCSymbolizerCtorFn = Fn; + assert(!T.MCSymbolizerCtorFn); + T.MCSymbolizerCtorFn = Fn; } /// @} -- cgit v1.1 From 8225b23c6adcb1be605108425b7eb169b6439b64 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Wed, 16 Oct 2013 16:30:10 +0000 Subject: Update comment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192806 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index f99c597..79bd969 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -194,6 +194,6 @@ def int_aarch64_neon_vtstd : Neon_ICmp_Intrinsic; // Scalar Signed Saturating Accumulated of Unsigned Value def int_aarch64_neon_vuqadd : Neon_2Arg_Intrinsic; -// Scalar Unsigned Saturating Accumulated of Unsigned Value +// Scalar Unsigned Saturating Accumulated of Signed Value def int_aarch64_neon_vsqadd : Neon_2Arg_Intrinsic; } -- cgit v1.1 From 2906b519d1f47f1b269ed1be9c70f752b3dca928 Mon Sep 17 00:00:00 2001 From: Anders Waldenborg Date: Wed, 16 Oct 2013 18:00:54 +0000 Subject: [llvm-c] Add LLVMPrintModuleToString. Like LLVMDumpModule but returns the string (that needs to be freed with LLVMDisposeMessage) instead of printing it to stderr. Differential Revision: http://llvm-reviews.chandlerc.com/D1941 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192821 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 57834c5..caadab1 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -541,6 +541,14 @@ LLVMBool LLVMPrintModuleToFile(LLVMModuleRef M, const char *Filename, char **ErrorMessage); /** + * Return a string representation of the module. Use + * LLVMDisposeMessage to free the string. + * + * @see Module::print() + */ +char *LLVMPrintModuleToString(LLVMModuleRef M); + +/** * Set inline assembly for a module. * * @see Module::setModuleInlineAsm() -- cgit v1.1 From 49978e61250a7229ad1040b002a609858f158584 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 16 Oct 2013 18:26:16 +0000 Subject: Fix MCDataAtom never calling remap when adding data. This patch fixes a small mistake in MCDataAtom::addData() where it doesn't ever call remap(): - if (Data.size() > Begin - End - 1) + if (Data.size() > End + 1 - Begin) remap(Begin, End + 1); This is currently not visible because of another bug is the disassembler, so the patch includes a unit test. Patch by Stephen Checkoway. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192823 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAtom.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/MC/MCAtom.h b/include/llvm/MC/MCAtom.h index 686f8e1..4758588 100644 --- a/include/llvm/MC/MCAtom.h +++ b/include/llvm/MC/MCAtom.h @@ -188,7 +188,9 @@ private: friend class MCModule; // Private constructor - only callable by MCModule MCDataAtom(MCModule *P, uint64_t Begin, uint64_t End) - : MCAtom(DataAtom, P, Begin, End), Data(End - Begin) {} + : MCAtom(DataAtom, P, Begin, End) { + Data.reserve(End + 1 - Begin); + } }; } -- cgit v1.1 From e6b1095e31677720708181f1bc998924340e5d46 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 16 Oct 2013 20:21:39 +0000 Subject: Allow repeated registration again. Our use of -fvisibility-inlines-hidden means we cannot check function pointers against non null values. Unfortunately, we also cannot assert that the callbacks are initialized only once. The problem is that lldb has multiple subsystems that need to call this and they don't have a unique initialization order. Thanks to Sean Callanan for reporting it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192835 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/TargetRegistry.h | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/TargetRegistry.h b/include/llvm/Support/TargetRegistry.h index 6cca9e8..9ecee3b 100644 --- a/include/llvm/Support/TargetRegistry.h +++ b/include/llvm/Support/TargetRegistry.h @@ -598,7 +598,6 @@ namespace llvm { /// @param T - The target being registered. /// @param Fn - A function to construct a MCAsmInfo for the target. static void RegisterMCAsmInfo(Target &T, Target::MCAsmInfoCtorFnTy Fn) { - assert(!T.MCAsmInfoCtorFn); T.MCAsmInfoCtorFn = Fn; } @@ -613,7 +612,6 @@ namespace llvm { /// @param Fn - A function to construct a MCCodeGenInfo for the target. static void RegisterMCCodeGenInfo(Target &T, Target::MCCodeGenInfoCtorFnTy Fn) { - assert(!T.MCCodeGenInfoCtorFn); T.MCCodeGenInfoCtorFn = Fn; } @@ -627,7 +625,6 @@ namespace llvm { /// @param T - The target being registered. /// @param Fn - A function to construct a MCInstrInfo for the target. static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn) { - assert(!T.MCInstrInfoCtorFn); T.MCInstrInfoCtorFn = Fn; } @@ -635,7 +632,6 @@ namespace llvm { /// the given target. static void RegisterMCInstrAnalysis(Target &T, Target::MCInstrAnalysisCtorFnTy Fn) { - assert(!T.MCInstrAnalysisCtorFn); T.MCInstrAnalysisCtorFn = Fn; } @@ -649,7 +645,6 @@ namespace llvm { /// @param T - The target being registered. /// @param Fn - A function to construct a MCRegisterInfo for the target. static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn) { - assert(!T.MCRegInfoCtorFn); T.MCRegInfoCtorFn = Fn; } @@ -664,7 +659,6 @@ namespace llvm { /// @param Fn - A function to construct a MCSubtargetInfo for the target. static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn) { - assert(!T.MCSubtargetInfoCtorFn); T.MCSubtargetInfoCtorFn = Fn; } @@ -679,7 +673,6 @@ namespace llvm { /// @param Fn - A function to construct a TargetMachine for the target. static void RegisterTargetMachine(Target &T, Target::TargetMachineCtorTy Fn) { - assert(!T.TargetMachineCtorFn); T.TargetMachineCtorFn = Fn; } @@ -693,7 +686,6 @@ namespace llvm { /// @param T - The target being registered. /// @param Fn - A function to construct an AsmBackend for the target. static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn) { - assert(!T.MCAsmBackendCtorFn); T.MCAsmBackendCtorFn = Fn; } @@ -707,7 +699,6 @@ namespace llvm { /// @param T - The target being registered. /// @param Fn - A function to construct an MCTargetAsmParser for the target. static void RegisterMCAsmParser(Target &T, Target::MCAsmParserCtorTy Fn) { - assert(!T.MCAsmParserCtorFn); T.MCAsmParserCtorFn = Fn; } @@ -721,7 +712,6 @@ namespace llvm { /// @param T - The target being registered. /// @param Fn - A function to construct an AsmPrinter for the target. static void RegisterAsmPrinter(Target &T, Target::AsmPrinterCtorTy Fn) { - assert(!T.AsmPrinterCtorFn); T.AsmPrinterCtorFn = Fn; } @@ -736,7 +726,6 @@ namespace llvm { /// @param Fn - A function to construct an MCDisassembler for the target. static void RegisterMCDisassembler(Target &T, Target::MCDisassemblerCtorTy Fn) { - assert(!T.MCDisassemblerCtorFn); T.MCDisassemblerCtorFn = Fn; } @@ -751,7 +740,6 @@ namespace llvm { /// @param Fn - A function to construct an MCInstPrinter for the target. static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn) { - assert(!T.MCInstPrinterCtorFn); T.MCInstPrinterCtorFn = Fn; } @@ -766,7 +754,6 @@ namespace llvm { /// @param Fn - A function to construct an MCCodeEmitter for the target. static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn) { - assert(!T.MCCodeEmitterCtorFn); T.MCCodeEmitterCtorFn = Fn; } @@ -781,7 +768,6 @@ namespace llvm { /// @param Fn - A function to construct an MCStreamer for the target. static void RegisterMCObjectStreamer(Target &T, Target::MCObjectStreamerCtorTy Fn) { - assert(!T.MCObjectStreamerCtorFn); T.MCObjectStreamerCtorFn = Fn; } @@ -795,7 +781,6 @@ namespace llvm { /// @param T - The target being registered. /// @param Fn - A function to construct an MCStreamer for the target. static void RegisterAsmStreamer(Target &T, Target::AsmStreamerCtorTy Fn) { - assert(!T.AsmStreamerCtorFn); T.AsmStreamerCtorFn = Fn; } @@ -810,7 +795,6 @@ namespace llvm { /// @param Fn - A function to construct an MCRelocationInfo for the target. static void RegisterMCRelocationInfo(Target &T, Target::MCRelocationInfoCtorTy Fn) { - assert(!T.MCRelocationInfoCtorFn); T.MCRelocationInfoCtorFn = Fn; } @@ -825,7 +809,6 @@ namespace llvm { /// @param Fn - A function to construct an MCSymbolizer for the target. static void RegisterMCSymbolizer(Target &T, Target::MCSymbolizerCtorTy Fn) { - assert(!T.MCSymbolizerCtorFn); T.MCSymbolizerCtorFn = Fn; } -- cgit v1.1 From a249914462c7b8f0c25b21eca77df264455290ee Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Wed, 16 Oct 2013 21:04:34 +0000 Subject: [AArch64] Add support for NEON scalar absolute value instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192842 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 79bd969..d11c672 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -196,4 +196,8 @@ def int_aarch64_neon_vuqadd : Neon_2Arg_Intrinsic; // Scalar Unsigned Saturating Accumulated of Signed Value def int_aarch64_neon_vsqadd : Neon_2Arg_Intrinsic; + +// Scalar Absolute Value +def int_aarch64_neon_vabs : + Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty], [IntrNoMem]>; } -- cgit v1.1 From dceac4c5a611f26ebcc88c75cc39075c7df2466e Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Wed, 16 Oct 2013 21:04:39 +0000 Subject: [AArch64] Add support for NEON scalar negate instruction. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192843 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index d11c672..f707df7 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -200,4 +200,8 @@ def int_aarch64_neon_vsqadd : Neon_2Arg_Intrinsic; // Scalar Absolute Value def int_aarch64_neon_vabs : Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty], [IntrNoMem]>; + +// Scalar Negate Value +def int_aarch64_neon_vneg : + Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty], [IntrNoMem]>; } -- cgit v1.1 From 75a5df1d1e086f3d9c46e1b602381fb56a8911f3 Mon Sep 17 00:00:00 2001 From: Anders Waldenborg Date: Wed, 16 Oct 2013 21:30:25 +0000 Subject: llvm-c: Add LLVMDumpType The C API currently allows to dump values (LLVMDumpValue), but a similar method for types was not exported. Patch by Peter Zotov Differential Revision: http://llvm-reviews.chandlerc.com/D1911 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192852 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index caadab1..d39128d 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -700,6 +700,13 @@ LLVMBool LLVMTypeIsSized(LLVMTypeRef Ty); LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty); /** + * Dump a representation of a type to stderr. + * + * @see llvm::Type::dump() + */ +void LLVMDumpType(LLVMTypeRef Val); + +/** * @defgroup LLVMCCoreTypeInt Integer Types * * Functions in this section operate on integer types. -- cgit v1.1 From adbd3ae1dfa7530d23653b6fd910d28de8217fbd Mon Sep 17 00:00:00 2001 From: Jack Carter Date: Thu, 17 Oct 2013 01:34:33 +0000 Subject: [projects/test-suite] White space and long line fixes. No functionality changes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192863 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLowering.h | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 1c0ad63..8aa0abd 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -576,7 +576,7 @@ public: VectorType *VTy = cast(Ty); Type *Elm = VTy->getElementType(); // Lower vectors of pointers to native pointer types. - if (Elm->isPointerTy()) + if (Elm->isPointerTy()) Elm = EVT(PointerTy).getTypeForEVT(Ty->getContext()); return EVT::getVectorVT(Ty->getContext(), EVT::getEVT(Elm, false), VTy->getNumElements()); @@ -1185,11 +1185,12 @@ public: /// Return true if the target supplies and combines to a paired load /// two loaded values of type LoadedType next to each other in memory. - /// RequiredAlignment gives the minimal alignment constraints that must be met to - /// be able to select this paired load. + /// RequiredAlignment gives the minimal alignment constraints that must be met + /// to be able to select this paired load. /// - /// This information is *not* used to generate actual paired loads, but it is used - /// to generate a sequence of loads that is easier to combine into a paired load. + /// This information is *not* used to generate actual paired loads, but it is + /// used to generate a sequence of loads that is easier to combine into a + /// paired load. /// For instance, something like this: /// a = load i64* addr /// b = trunc i64 a to i32 @@ -1200,8 +1201,9 @@ public: /// d = load i32* addr2 /// Where addr1 = addr2 +/- sizeof(i32). /// - /// In other words, unless the target performs a post-isel load combining, this - /// information should not be provided because it will generate more loads. + /// In other words, unless the target performs a post-isel load combining, + /// this information should not be provided because it will generate more + /// loads. virtual bool hasPairedLoad(Type * /*LoadedType*/, unsigned & /*RequiredAligment*/) const { return false; @@ -1502,7 +1504,7 @@ public: if (NumElts == 1) return LegalizeKind(TypeScalarizeVector, EltVT); - // Try to widen vector elements until the element type is a power of two and + // Try to widen vector elements until the element type is a power of two and // promote it to a legal type later on, for example: // <3 x i8> -> <4 x i8> -> <4 x i32> if (EltVT.isInteger()) { @@ -1536,7 +1538,8 @@ public: // Stop trying when getting a non-simple element type. // Note that vector elements may be greater than legal vector element - // types. Example: X86 XMM registers hold 64bit element on 32bit systems. + // types. Example: X86 XMM registers hold 64bit element on 32bit + // systems. if (!EltVT.isSimple()) break; // Build a new vector type and check if it is legal. @@ -1697,7 +1700,8 @@ public: /// by reference if this node can be combined with a load / store to form a /// post-indexed load / store. virtual bool getPostIndexedAddressParts(SDNode * /*N*/, SDNode * /*Op*/, - SDValue &/*Base*/, SDValue &/*Offset*/, + SDValue &/*Base*/, + SDValue &/*Offset*/, ISD::MemIndexedMode &/*AM*/, SelectionDAG &/*DAG*/) const { return false; -- cgit v1.1 From 0739140b05337d97c22fd17c97ac71ab5a34f5d9 Mon Sep 17 00:00:00 2001 From: Filip Pizlo Date: Thu, 17 Oct 2013 01:38:28 +0000 Subject: Expose install_fatal_error_handler() through the C API. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I expose the API with some caveats: - The C++ API involves a traditional void* opaque pointer for the fatal error callback. The C API doesn’t do this. I don’t think that the void* opaque pointer makes any sense since this is a global callback - there will only be one of them. So if you need to pass some data to your callback, just put it in a global variable. - The bindings will ignore the gen_crash_diag boolean. I ignore it because (1) I don’t know what it does, (2) it’s not documented AFAIK, and (3) I couldn’t imagine any use for it. I made the gut call that it probably wasn’t important enough to expose through the C API. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192864 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index d39128d..f9717cc 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -416,6 +416,22 @@ void LLVMShutdown(); char *LLVMCreateMessage(const char *Message); void LLVMDisposeMessage(char *Message); +typedef void (*LLVMFatalErrorHandler)(const char *Reason); + +/** + * Install a fatal error handler. By default, if LLVM detects a fatal error, it + * will call exit(1). This may not be appropriate in many contexts. For example, + * doing exit(1) will bypass many crash reporting/tracing system tools. This + * function allows you to install a callback that will be invoked prior to the + * call to exit(1). + */ +void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler); + +/** + * Reset the fatal error handler. This resets LLVM's fatal error handling + * behavior to the default. + */ +void LLVMResetFatalErrorHandler(void); /** * @defgroup LLVMCCoreContext Contexts -- cgit v1.1 From db8a16252b9d29bd7a3442d5c3bad0398dd85908 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Thu, 17 Oct 2013 12:16:03 +0000 Subject: [mips][msa] Removed ldx.[bhwd] and stx.[bhwd]. These were present in a previous version of the MSA spec but are not present in the published version. There is no hardware that uses these instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192888 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 26 -------------------------- 1 file changed, 26 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 5d8a7be..4824ae5 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -1242,19 +1242,6 @@ def int_mips_ld_d : GCCBuiltin<"__builtin_msa_ld_d">, Intrinsic<[llvm_v2i64_ty], [llvm_ptr_ty, llvm_i32_ty], [IntrReadArgMem]>; -def int_mips_ldx_b : GCCBuiltin<"__builtin_msa_ldx_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_ptr_ty, llvm_i32_ty], - [IntrReadArgMem]>; -def int_mips_ldx_h : GCCBuiltin<"__builtin_msa_ldx_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_ptr_ty, llvm_i32_ty], - [IntrReadArgMem]>; -def int_mips_ldx_w : GCCBuiltin<"__builtin_msa_ldx_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_ptr_ty, llvm_i32_ty], - [IntrReadArgMem]>; -def int_mips_ldx_d : GCCBuiltin<"__builtin_msa_ldx_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_ptr_ty, llvm_i32_ty], - [IntrReadArgMem]>; - def int_mips_ldi_b : GCCBuiltin<"__builtin_msa_ldi_b">, Intrinsic<[llvm_v16i8_ty], [llvm_i32_ty], [IntrNoMem]>; def int_mips_ldi_h : GCCBuiltin<"__builtin_msa_ldi_h">, @@ -1669,19 +1656,6 @@ def int_mips_st_d : GCCBuiltin<"__builtin_msa_st_d">, Intrinsic<[], [llvm_v2i64_ty, llvm_ptr_ty, llvm_i32_ty], [IntrReadWriteArgMem]>; -def int_mips_stx_b : GCCBuiltin<"__builtin_msa_stx_b">, - Intrinsic<[], [llvm_v16i8_ty, llvm_ptr_ty, llvm_i32_ty], - [IntrReadWriteArgMem]>; -def int_mips_stx_h : GCCBuiltin<"__builtin_msa_stx_h">, - Intrinsic<[], [llvm_v8i16_ty, llvm_ptr_ty, llvm_i32_ty], - [IntrReadWriteArgMem]>; -def int_mips_stx_w : GCCBuiltin<"__builtin_msa_stx_w">, - Intrinsic<[], [llvm_v4i32_ty, llvm_ptr_ty, llvm_i32_ty], - [IntrReadWriteArgMem]>; -def int_mips_stx_d : GCCBuiltin<"__builtin_msa_stx_d">, - Intrinsic<[], [llvm_v2i64_ty, llvm_ptr_ty, llvm_i32_ty], - [IntrReadWriteArgMem]>; - def int_mips_subs_s_b : GCCBuiltin<"__builtin_msa_subs_s_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; def int_mips_subs_s_h : GCCBuiltin<"__builtin_msa_subs_s_h">, -- cgit v1.1 From 52244da7f2b3def646900520668b859343b84a33 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Thu, 17 Oct 2013 13:38:20 +0000 Subject: [mips][msa] Added lsa instruction git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192895 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 4824ae5..0634c18 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -1251,6 +1251,12 @@ def int_mips_ldi_w : GCCBuiltin<"__builtin_msa_ldi_w">, def int_mips_ldi_d : GCCBuiltin<"__builtin_msa_ldi_d">, Intrinsic<[llvm_v2i64_ty], [llvm_i32_ty], [IntrNoMem]>; +// This instruction is part of the MSA spec but it does not share the +// __builtin_msa prefix because it operates on the GPR registers. +def int_mips_lsa : GCCBuiltin<"__builtin_mips_lsa">, + Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty], + [IntrNoMem]>; + def int_mips_madd_q_h : GCCBuiltin<"__builtin_msa_madd_q_h">, Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; -- cgit v1.1 From 3b370a2ac433c4abfbfe8f47c63fee0dbcfcc9e6 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Thu, 17 Oct 2013 18:12:29 +0000 Subject: [AArch64] Add support for NEON scalar three register different instruction class. The instruction class includes the signed saturating doubling multiply-add long, signed saturating doubling multiply-subtract long, and the signed saturating doubling multiply long instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192908 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index f707df7..7fa5a06 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -204,4 +204,13 @@ def int_aarch64_neon_vabs : // Scalar Negate Value def int_aarch64_neon_vneg : Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty], [IntrNoMem]>; + +// Signed Saturating Doubling Multiply-Add Long +def int_aarch64_neon_vqdmlal : Neon_2Arg_Long_Intrinsic; + +// Signed Saturating Doubling Multiply-Subtract Long +def int_aarch64_neon_vqdmlsl : Neon_2Arg_Long_Intrinsic; + +// Signed Saturating Doubling Multiply Long +def int_aarch64_neon_vqdmull : Neon_2Arg_Long_Intrinsic; } -- cgit v1.1 From f4094e5ed7387b29eda8d9a7865f6b5dfd47ce82 Mon Sep 17 00:00:00 2001 From: Anders Waldenborg Date: Thu, 17 Oct 2013 18:51:01 +0000 Subject: llvm-c: Add LLVMIntPtrType{,ForAS}InContext All of the Core API functions have versions which accept explicit context, in addition to ones which work on global context. This commit adds functions which accept explicit context to the Target API for consistency. Patch by Peter Zotov Differential Revision: http://llvm-reviews.chandlerc.com/D1912 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192913 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Target.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Target.h b/include/llvm-c/Target.h index 80fc3e5..27eb147 100644 --- a/include/llvm-c/Target.h +++ b/include/llvm-c/Target.h @@ -186,6 +186,15 @@ LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef); See the method llvm::DataLayout::getIntPtrType. */ LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef, unsigned AS); +/** Returns the integer type that is the same size as a pointer on a target. + See the method llvm::DataLayout::getIntPtrType. */ +LLVMTypeRef LLVMIntPtrTypeInContext(LLVMContextRef, LLVMTargetDataRef); + +/** Returns the integer type that is the same size as a pointer on a target. + This version allows the address space to be specified. + See the method llvm::DataLayout::getIntPtrType. */ +LLVMTypeRef LLVMIntPtrTypeForASInContext(LLVMContextRef, LLVMTargetDataRef, unsigned AS); + /** Computes the size of a type in bytes for a target. See the method llvm::DataLayout::getTypeSizeInBits. */ unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef, LLVMTypeRef); -- cgit v1.1 From 71f6d6ee1a42a39b897f165802716baaad91e21b Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Fri, 18 Oct 2013 07:03:16 +0000 Subject: [DebugInfo] Remove dead code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192952 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo/DWARFFormValue.h | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo/DWARFFormValue.h b/include/llvm/DebugInfo/DWARFFormValue.h index f92d5a9..c88e42a 100644 --- a/include/llvm/DebugInfo/DWARFFormValue.h +++ b/include/llvm/DebugInfo/DWARFFormValue.h @@ -33,14 +33,6 @@ public: bool IsDWOIndex; }; - enum { - eValueTypeInvalid = 0, - eValueTypeUnsigned, - eValueTypeSigned, - eValueTypeCStr, - eValueTypeBlock - }; - private: uint16_t Form; // Form for this value. ValueType Value; // Contains all data for the form. @@ -55,19 +47,18 @@ public: bool isInlinedCStr() const { return Value.data != NULL && Value.data == (const uint8_t*)Value.cstr; } - const uint8_t *BlockData() const; - uint64_t getReference(const DWARFUnit *U) const; + uint64_t getReference(const DWARFUnit *U) const; uint64_t getUnsigned() const { return Value.uval; } int64_t getSigned() const { return Value.sval; } const char *getAsCString(const DWARFUnit *U) const; uint64_t getAsAddress(const DWARFUnit *U) const; + bool skipValue(DataExtractor debug_info_data, uint32_t *offset_ptr, const DWARFUnit *u) const; static bool skipValue(uint16_t form, DataExtractor debug_info_data, uint32_t *offset_ptr, const DWARFUnit *u); - static bool isBlockForm(uint16_t form); - static bool isDataForm(uint16_t form); + static const uint8_t *getFixedFormSizes(uint8_t AddrSize, uint16_t Version); }; -- cgit v1.1 From 8d433bd458b37327e2fa979a3234762f206b3467 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Fri, 18 Oct 2013 07:13:32 +0000 Subject: [DebugInfo] Remove unneeded struct member and hide struct definition. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192954 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo/DWARFFormValue.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo/DWARFFormValue.h b/include/llvm/DebugInfo/DWARFFormValue.h index c88e42a..c8d6008 100644 --- a/include/llvm/DebugInfo/DWARFFormValue.h +++ b/include/llvm/DebugInfo/DWARFFormValue.h @@ -18,9 +18,8 @@ class DWARFUnit; class raw_ostream; class DWARFFormValue { -public: struct ValueType { - ValueType() : data(NULL), IsDWOIndex(false) { + ValueType() : data(NULL) { uval = 0; } @@ -30,10 +29,8 @@ public: const char* cstr; }; const uint8_t* data; - bool IsDWOIndex; }; -private: uint16_t Form; // Form for this value. ValueType Value; // Contains all data for the form. -- cgit v1.1 From 641bea117d2f5e68c11156b9eea1c9270825dfb9 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Fri, 18 Oct 2013 08:03:43 +0000 Subject: CodeGen: Emit a libcall if the target doesn't support 16-byte wide atomics There are targets that support i128 sized scalars but cannot emit instructions that modify them directly. The proper thing to do is to emit a libcall. This fixes PR17481. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192957 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/RuntimeLibcalls.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/RuntimeLibcalls.h b/include/llvm/CodeGen/RuntimeLibcalls.h index 14769ec..d8c60df 100644 --- a/include/llvm/CodeGen/RuntimeLibcalls.h +++ b/include/llvm/CodeGen/RuntimeLibcalls.h @@ -325,34 +325,42 @@ namespace RTLIB { SYNC_VAL_COMPARE_AND_SWAP_2, SYNC_VAL_COMPARE_AND_SWAP_4, SYNC_VAL_COMPARE_AND_SWAP_8, + SYNC_VAL_COMPARE_AND_SWAP_16, SYNC_LOCK_TEST_AND_SET_1, SYNC_LOCK_TEST_AND_SET_2, SYNC_LOCK_TEST_AND_SET_4, SYNC_LOCK_TEST_AND_SET_8, + SYNC_LOCK_TEST_AND_SET_16, SYNC_FETCH_AND_ADD_1, SYNC_FETCH_AND_ADD_2, SYNC_FETCH_AND_ADD_4, SYNC_FETCH_AND_ADD_8, + SYNC_FETCH_AND_ADD_16, SYNC_FETCH_AND_SUB_1, SYNC_FETCH_AND_SUB_2, SYNC_FETCH_AND_SUB_4, SYNC_FETCH_AND_SUB_8, + SYNC_FETCH_AND_SUB_16, SYNC_FETCH_AND_AND_1, SYNC_FETCH_AND_AND_2, SYNC_FETCH_AND_AND_4, SYNC_FETCH_AND_AND_8, + SYNC_FETCH_AND_AND_16, SYNC_FETCH_AND_OR_1, SYNC_FETCH_AND_OR_2, SYNC_FETCH_AND_OR_4, SYNC_FETCH_AND_OR_8, + SYNC_FETCH_AND_OR_16, SYNC_FETCH_AND_XOR_1, SYNC_FETCH_AND_XOR_2, SYNC_FETCH_AND_XOR_4, SYNC_FETCH_AND_XOR_8, + SYNC_FETCH_AND_XOR_16, SYNC_FETCH_AND_NAND_1, SYNC_FETCH_AND_NAND_2, SYNC_FETCH_AND_NAND_4, SYNC_FETCH_AND_NAND_8, + SYNC_FETCH_AND_NAND_16, // Stack Protector Fail. STACKPROTECTOR_CHECK_FAIL, -- cgit v1.1 From 22f9dd4591e8af6d6feed10a4b6e11a784582edc Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Fri, 18 Oct 2013 20:46:28 +0000 Subject: MC asm parser: allow ?'s in symbol names, and handle @'s in names in MS asm This is another (final?) stab at making us able to parse our own asm output on Windows. Symbols on Windows often contain @'s and ?'s in their names. Our asm parser didn't like this. ?'s were not allowed, and @'s were intepreted as trying to reference PLT/GOT/etc. We can't just add quotes around the bad names, since e.g. for MinGW, we use gas to assemble, and it doesn't like quotes in some places (notably in .def directives). This commit makes us allow ?'s in symbol names, and @'s in symbol names for MS assembly. Differential Revision: http://llvm-reviews.chandlerc.com/D1978 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193000 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAsmInfo.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h index c9cecc1..bcf6fe8 100644 --- a/include/llvm/MC/MCAsmInfo.h +++ b/include/llvm/MC/MCAsmInfo.h @@ -156,6 +156,10 @@ namespace llvm { /// symbol names. This defaults to true. bool AllowPeriodsInName; + /// \brief This is true if the assembler allows @ characters in symbol + /// names. Defaults to false. + bool AllowAtInName; + /// AllowUTF8 - This is true if the assembler accepts UTF-8 input. // FIXME: Make this a more general encoding setting? bool AllowUTF8; @@ -485,6 +489,9 @@ namespace llvm { bool doesAllowPeriodsInName() const { return AllowPeriodsInName; } + bool doesAllowAtInName() const { + return AllowAtInName; + } bool doesAllowUTF8() const { return AllowUTF8; } -- cgit v1.1 From 44a4cfb63d87dc0ba778982a1796673ca1513e90 Mon Sep 17 00:00:00 2001 From: "Michael J. Spencer" Date: Fri, 18 Oct 2013 22:38:04 +0000 Subject: [Support][YAML] Add support for accessing tags and tag handle substitution. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193004 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/YAMLParser.h | 73 +++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 29 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/YAMLParser.h b/include/llvm/Support/YAMLParser.h index 338bb4b..0e780ba 100644 --- a/include/llvm/Support/YAMLParser.h +++ b/include/llvm/Support/YAMLParser.h @@ -43,6 +43,8 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/Allocator.h" #include "llvm/Support/SMLoc.h" + +#include #include #include @@ -99,9 +101,6 @@ private: OwningPtr CurrentDoc; friend class Document; - - /// @brief Validate a %YAML x.x directive. - void handleYAMLDirective(const Token &); }; /// @brief Abstract base class for all Nodes. @@ -116,12 +115,21 @@ public: NK_Alias }; - Node(unsigned int Type, OwningPtr&, StringRef Anchor); + Node(unsigned int Type, OwningPtr &, StringRef Anchor, + StringRef Tag); /// @brief Get the value of the anchor attached to this node. If it does not /// have one, getAnchor().size() will be 0. StringRef getAnchor() const { return Anchor; } + /// \brief Get the tag as it was written in the document. This does not + /// perform tag resolution. + StringRef getRawTag() const { return Tag; } + + /// \brief Get the verbatium tag for a given Node. This performs tag resoluton + /// and substitution. + std::string getVerbatimTag() const; + SMRange getSourceRange() const { return SourceRange; } void setSourceRange(SMRange SR) { SourceRange = SR; } @@ -158,6 +166,8 @@ protected: private: unsigned int TypeID; StringRef Anchor; + /// \brief The tag as typed in the document. + StringRef Tag; }; /// @brief A null value. @@ -166,7 +176,8 @@ private: /// !!null null class NullNode : public Node { public: - NullNode(OwningPtr &D) : Node(NK_Null, D, StringRef()) {} + NullNode(OwningPtr &D) + : Node(NK_Null, D, StringRef(), StringRef()) {} static inline bool classof(const Node *N) { return N->getType() == NK_Null; @@ -180,9 +191,9 @@ public: /// Adena class ScalarNode : public Node { public: - ScalarNode(OwningPtr &D, StringRef Anchor, StringRef Val) - : Node(NK_Scalar, D, Anchor) - , Value(Val) { + ScalarNode(OwningPtr &D, StringRef Anchor, StringRef Tag, + StringRef Val) + : Node(NK_Scalar, D, Anchor, Tag), Value(Val) { SMLoc Start = SMLoc::getFromPointer(Val.begin()); SMLoc End = SMLoc::getFromPointer(Val.end()); SourceRange = SMRange(Start, End); @@ -222,7 +233,7 @@ private: class KeyValueNode : public Node { public: KeyValueNode(OwningPtr &D) - : Node(NK_KeyValue, D, StringRef()) + : Node(NK_KeyValue, D, StringRef(), StringRef()) , Key(0) , Value(0) {} @@ -338,13 +349,10 @@ public: MT_Inline ///< An inline mapping node is used for "[key: value]". }; - MappingNode(OwningPtr &D, StringRef Anchor, MappingType MT) - : Node(NK_Mapping, D, Anchor) - , Type(MT) - , IsAtBeginning(true) - , IsAtEnd(false) - , CurrentEntry(0) - {} + MappingNode(OwningPtr &D, StringRef Anchor, StringRef Tag, + MappingType MT) + : Node(NK_Mapping, D, Anchor, Tag), Type(MT), IsAtBeginning(true), + IsAtEnd(false), CurrentEntry(0) {} friend class basic_collection_iterator; typedef basic_collection_iterator iterator; @@ -397,14 +405,12 @@ public: ST_Indentless }; - SequenceNode(OwningPtr &D, StringRef Anchor, SequenceType ST) - : Node(NK_Sequence, D, Anchor) - , SeqType(ST) - , IsAtBeginning(true) - , IsAtEnd(false) - , WasPreviousTokenFlowEntry(true) // Start with an imaginary ','. - , CurrentEntry(0) - {} + SequenceNode(OwningPtr &D, StringRef Anchor, StringRef Tag, + SequenceType ST) + : Node(NK_Sequence, D, Anchor, Tag), SeqType(ST), IsAtBeginning(true), + IsAtEnd(false), + WasPreviousTokenFlowEntry(true), // Start with an imaginary ','. + CurrentEntry(0) {} friend class basic_collection_iterator; typedef basic_collection_iterator iterator; @@ -442,7 +448,7 @@ private: class AliasNode : public Node { public: AliasNode(OwningPtr &D, StringRef Val) - : Node(NK_Alias, D, StringRef()), Name(Val) {} + : Node(NK_Alias, D, StringRef(), StringRef()), Name(Val) {} StringRef getName() const { return Name; } Node *getTarget(); @@ -475,6 +481,10 @@ public: return Root = parseBlockNode(); } + const std::map &getTagMap() const { + return TagMap; + } + private: friend class Node; friend class document_iterator; @@ -490,18 +500,23 @@ private: /// document. Node *Root; + /// \brief Maps tag prefixes to their expansion. + std::map TagMap; + Token &peekNext(); Token getNext(); void setError(const Twine &Message, Token &Location) const; bool failed() const; - void handleTagDirective(const Token &Tag) { - // TODO: Track tags. - } - /// @brief Parse %BLAH directives and return true if any were encountered. bool parseDirectives(); + /// \brief Parse %YAML + void parseYAMLDirective(); + + /// \brief Parse %TAG + void parseTAGDirective(); + /// @brief Consume the next token and error if it is not \a TK. bool expectToken(int TK); }; -- cgit v1.1 From f89f66e61b26974bb73b5832d5825091873b51dc Mon Sep 17 00:00:00 2001 From: Matheus Almeida Date: Mon, 21 Oct 2013 11:47:56 +0000 Subject: [mips][msa] Fix definition of SLD instruction. The second parameter of the SLD intrinsic is the number of columns (GPR) to slide left the source array. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193076 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 0634c18..4118f3e 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -1524,13 +1524,13 @@ def int_mips_shf_w : GCCBuiltin<"__builtin_msa_shf_w">, Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sld_b : GCCBuiltin<"__builtin_msa_sld_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sld_h : GCCBuiltin<"__builtin_msa_sld_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sld_w : GCCBuiltin<"__builtin_msa_sld_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sld_d : GCCBuiltin<"__builtin_msa_sld_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_sldi_b : GCCBuiltin<"__builtin_msa_sldi_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; -- cgit v1.1 From 713cab059ebb67c2f51d8da9d8e57be2b1dcd9c2 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Mon, 21 Oct 2013 17:14:55 +0000 Subject: Optimize more linkonce_odr values during LTO. When a linkonce_odr value that is on the dso list is not unnamed_addr we can still look to see if anything is actually using its address. If not, it is safe to hide it. This patch implements that by moving GlobalStatus to Transforms/Utils and using it in Internalize. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193090 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/Utils/GlobalStatus.h | 82 ++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 include/llvm/Transforms/Utils/GlobalStatus.h (limited to 'include') diff --git a/include/llvm/Transforms/Utils/GlobalStatus.h b/include/llvm/Transforms/Utils/GlobalStatus.h new file mode 100644 index 0000000..c366095 --- /dev/null +++ b/include/llvm/Transforms/Utils/GlobalStatus.h @@ -0,0 +1,82 @@ +//===- GlobalStatus.h - Compute status info for globals ---------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_TRANSFORMS_UTILS_GLOBALSTATUS_H +#define LLVM_TRANSFORMS_UTILS_GLOBALSTATUS_H + +#include "llvm/IR/Instructions.h" + +namespace llvm { +class Value; +class Function; + +/// It is safe to destroy a constant iff it is only used by constants itself. +/// Note that constants cannot be cyclic, so this test is pretty easy to +/// implement recursively. +/// +bool isSafeToDestroyConstant(const Constant *C); + +/// As we analyze each global, keep track of some information about it. If we +/// find out that the address of the global is taken, none of this info will be +/// accurate. +struct GlobalStatus { + /// True if the global's address is used in a comparison. + bool IsCompared; + + /// True if the global is ever loaded. If the global isn't ever loaded it + /// can be deleted. + bool IsLoaded; + + /// Keep track of what stores to the global look like. + enum StoredType { + /// There is no store to this global. It can thus be marked constant. + NotStored, + + /// This global is stored to, but the only thing stored is the constant it + /// was initialized with. This is only tracked for scalar globals. + InitializerStored, + + /// This global is stored to, but only its initializer and one other value + /// is ever stored to it. If this global isStoredOnce, we track the value + /// stored to it in StoredOnceValue below. This is only tracked for scalar + /// globals. + StoredOnce, + + /// This global is stored to by multiple values or something else that we + /// cannot track. + Stored + } StoredType; + + /// If only one value (besides the initializer constant) is ever stored to + /// this global, keep track of what value it is. + Value *StoredOnceValue; + + /// These start out null/false. When the first accessing function is noticed, + /// it is recorded. When a second different accessing function is noticed, + /// HasMultipleAccessingFunctions is set to true. + const Function *AccessingFunction; + bool HasMultipleAccessingFunctions; + + /// Set to true if this global has a user that is not an instruction (e.g. a + /// constant expr or GV initializer). + bool HasNonInstructionUser; + + /// Set to the strongest atomic ordering requirement. + AtomicOrdering Ordering; + + /// Look at all uses of the global and fill in the GlobalStatus structure. If + /// the global has its address taken, return true to indicate we can't do + /// anything with it. + static bool analyzeGlobal(const Value *V, GlobalStatus &GS); + + GlobalStatus(); +}; +} + +#endif -- cgit v1.1 From 770530babc78e444bb6d0aadc87702ef138293fd Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 21 Oct 2013 17:28:37 +0000 Subject: DebugInfo: Put each kind of constant (form, attribute, tag, etc) into its own enum for ease of use. This allows various variables to be more self-documenting and easier to debug by being of specific types without overlapping enum values. Precommit review by Eric Christopher. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193091 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 95 +++++++++++++++++++++++++++++++------------- 1 file changed, 68 insertions(+), 27 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index f4a9acf..f3f4274 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -68,8 +68,7 @@ enum LLVMConstants LLVM_ENUM_INT_TYPE(uint32_t) { const uint32_t DW_CIE_ID = UINT32_MAX; const uint64_t DW64_CIE_ID = UINT64_MAX; -enum Constants { - // Tags +enum Tag LLVM_ENUM_INT_TYPE(uint16_t) { DW_TAG_array_type = 0x01, DW_TAG_class_type = 0x02, DW_TAG_entry_point = 0x03, @@ -139,12 +138,10 @@ enum Constants { DW_TAG_GNU_formal_parameter_pack = 0x4108, DW_TAG_lo_user = 0x4080, DW_TAG_APPLE_property = 0x4200, - DW_TAG_hi_user = 0xffff, - - // Children flag - DW_CHILDREN_no = 0x00, - DW_CHILDREN_yes = 0x01, + DW_TAG_hi_user = 0xffff +}; +enum Attribute LLVM_ENUM_INT_TYPE(uint16_t) { // Attributes DW_AT_sibling = 0x01, DW_AT_location = 0x02, @@ -295,8 +292,10 @@ enum Constants { DW_AT_APPLE_property_setter = 0x3fea, DW_AT_APPLE_property_attribute = 0x3feb, DW_AT_APPLE_objc_complete_type = 0x3fec, - DW_AT_APPLE_property = 0x3fed, + DW_AT_APPLE_property = 0x3fed +}; +enum Form LLVM_ENUM_INT_TYPE(uint16_t) { // Attribute form encodings DW_FORM_addr = 0x01, DW_FORM_block2 = 0x03, @@ -326,8 +325,10 @@ enum Constants { // Extensions for Fission proposal DW_FORM_GNU_addr_index = 0x1f01, - DW_FORM_GNU_str_index = 0x1f02, + DW_FORM_GNU_str_index = 0x1f02 +}; +enum LocationAtom { // Operation encodings DW_OP_addr = 0x03, DW_OP_deref = 0x06, @@ -491,8 +492,10 @@ enum Constants { // Extensions for Fission proposal. DW_OP_GNU_addr_index = 0xfb, - DW_OP_GNU_const_index = 0xfc, + DW_OP_GNU_const_index = 0xfc +}; +enum TypeKind { // Encoding attribute values DW_ATE_address = 0x01, DW_ATE_boolean = 0x02, @@ -511,37 +514,49 @@ enum Constants { DW_ATE_decimal_float = 0x0f, DW_ATE_UTF = 0x10, DW_ATE_lo_user = 0x80, - DW_ATE_hi_user = 0xff, + DW_ATE_hi_user = 0xff +}; +enum DecimalSignEncoding { // Decimal sign attribute values DW_DS_unsigned = 0x01, DW_DS_leading_overpunch = 0x02, DW_DS_trailing_overpunch = 0x03, DW_DS_leading_separate = 0x04, - DW_DS_trailing_separate = 0x05, + DW_DS_trailing_separate = 0x05 +}; +enum EndianityEncoding { // Endianity attribute values DW_END_default = 0x00, DW_END_big = 0x01, DW_END_little = 0x02, DW_END_lo_user = 0x40, - DW_END_hi_user = 0xff, + DW_END_hi_user = 0xff +}; +enum AccessAttribute { // Accessibility codes DW_ACCESS_public = 0x01, DW_ACCESS_protected = 0x02, - DW_ACCESS_private = 0x03, + DW_ACCESS_private = 0x03 +}; +enum VisibilityAttribute { // Visibility codes DW_VIS_local = 0x01, DW_VIS_exported = 0x02, - DW_VIS_qualified = 0x03, + DW_VIS_qualified = 0x03 +}; +enum VirtualityAttribute { // Virtuality codes DW_VIRTUALITY_none = 0x00, DW_VIRTUALITY_virtual = 0x01, - DW_VIRTUALITY_pure_virtual = 0x02, + DW_VIRTUALITY_pure_virtual = 0x02 +}; +enum SourceLanguage { // Language names DW_LANG_C89 = 0x0001, DW_LANG_C = 0x0002, @@ -565,35 +580,47 @@ enum Constants { DW_LANG_Python = 0x0014, DW_LANG_lo_user = 0x8000, DW_LANG_Mips_Assembler = 0x8001, - DW_LANG_hi_user = 0xffff, + DW_LANG_hi_user = 0xffff +}; +enum CaseSensitivity { // Identifier case codes DW_ID_case_sensitive = 0x00, DW_ID_up_case = 0x01, DW_ID_down_case = 0x02, - DW_ID_case_insensitive = 0x03, + DW_ID_case_insensitive = 0x03 +}; +enum CallingConvention { // Calling convention codes DW_CC_normal = 0x01, DW_CC_program = 0x02, DW_CC_nocall = 0x03, DW_CC_lo_user = 0x40, - DW_CC_hi_user = 0xff, + DW_CC_hi_user = 0xff +}; +enum InlineAttribute { // Inline codes DW_INL_not_inlined = 0x00, DW_INL_inlined = 0x01, DW_INL_declared_not_inlined = 0x02, - DW_INL_declared_inlined = 0x03, + DW_INL_declared_inlined = 0x03 +}; +enum ArrayDimensionOrdering { // Array ordering DW_ORD_row_major = 0x00, - DW_ORD_col_major = 0x01, + DW_ORD_col_major = 0x01 +}; +enum DiscriminantList { // Discriminant descriptor values DW_DSC_label = 0x00, - DW_DSC_range = 0x01, + DW_DSC_range = 0x01 +}; +enum LineNumberOps { // Line Number Standard Opcode Encodings DW_LNS_extended_op = 0x00, DW_LNS_copy = 0x01, @@ -607,23 +634,29 @@ enum Constants { DW_LNS_fixed_advance_pc = 0x09, DW_LNS_set_prologue_end = 0x0a, DW_LNS_set_epilogue_begin = 0x0b, - DW_LNS_set_isa = 0x0c, + DW_LNS_set_isa = 0x0c +}; +enum LineNumberExtendedOps { // Line Number Extended Opcode Encodings DW_LNE_end_sequence = 0x01, DW_LNE_set_address = 0x02, DW_LNE_define_file = 0x03, DW_LNE_set_discriminator = 0x04, DW_LNE_lo_user = 0x80, - DW_LNE_hi_user = 0xff, + DW_LNE_hi_user = 0xff +}; +enum MacinfoRecordType { // Macinfo Type Encodings DW_MACINFO_define = 0x01, DW_MACINFO_undef = 0x02, DW_MACINFO_start_file = 0x03, DW_MACINFO_end_file = 0x04, - DW_MACINFO_vendor_ext = 0xff, + DW_MACINFO_vendor_ext = 0xff +}; +enum CallFrameInfo { // Call frame instruction encodings DW_CFA_extended = 0x00, DW_CFA_nop = 0x00, @@ -656,7 +689,13 @@ enum Constants { DW_CFA_GNU_window_save = 0x2d, DW_CFA_GNU_args_size = 0x2e, DW_CFA_lo_user = 0x1c, - DW_CFA_hi_user = 0x3f, + DW_CFA_hi_user = 0x3f +}; + +enum Constants { + // Children flag + DW_CHILDREN_no = 0x00, + DW_CHILDREN_yes = 0x01, DW_EH_PE_absptr = 0x00, DW_EH_PE_omit = 0xff, @@ -674,8 +713,10 @@ enum Constants { DW_EH_PE_datarel = 0x30, DW_EH_PE_funcrel = 0x40, DW_EH_PE_aligned = 0x50, - DW_EH_PE_indirect = 0x80, + DW_EH_PE_indirect = 0x80 +}; +enum ApplePropertyAttributes { // Apple Objective-C Property Attributes DW_APPLE_PROPERTY_readonly = 0x01, DW_APPLE_PROPERTY_readwrite = 0x02, -- cgit v1.1 From 6169453ba37ac353655f2475f336e66f31276752 Mon Sep 17 00:00:00 2001 From: Andrew Kaylor Date: Mon, 21 Oct 2013 17:42:06 +0000 Subject: Improving MCJIT/RuntimeDyld thread safety git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193094 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ExecutionEngine/ExecutionEngine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h index c78faa6..10b3fed 100644 --- a/include/llvm/ExecutionEngine/ExecutionEngine.h +++ b/include/llvm/ExecutionEngine/ExecutionEngine.h @@ -153,7 +153,7 @@ protected: void *(*LazyFunctionCreator)(const std::string &); public: - /// lock - This lock protects the ExecutionEngine, JIT, JITResolver and + /// lock - This lock protects the ExecutionEngine, MCJIT, JIT, JITResolver and /// JITEmitter classes. It must be held while changing the internal state of /// any of those classes. sys::Mutex lock; -- cgit v1.1 From 325ee6e115e97a2e0c2a37d69d25269dabbe77df Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Mon, 21 Oct 2013 18:08:09 +0000 Subject: Remove unused SCEV functions git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193097 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/ScalarEvolution.h | 9 --------- 1 file changed, 9 deletions(-) (limited to 'include') diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h index 59c8b8a..3d37651 100644 --- a/include/llvm/Analysis/ScalarEvolution.h +++ b/include/llvm/Analysis/ScalarEvolution.h @@ -641,20 +641,11 @@ namespace llvm { /// const SCEV *getSizeOfExpr(Type *IntTy, Type *AllocTy); - /// getAlignOfExpr - Return an expression for alignof AllocTy - /// - const SCEV *getAlignOfExpr(Type *AllocTy); - /// getOffsetOfExpr - Return an expression for offsetof on the given field /// with type IntTy /// const SCEV *getOffsetOfExpr(Type *IntTy, StructType *STy, unsigned FieldNo); - /// getOffsetOfExpr - Return an expression for offsetof on the given field - /// that is type IntTy - /// - const SCEV *getOffsetOfExpr(Type *IntTy, Type *CTy, Constant *FieldNo); - /// getNegativeSCEV - Return the SCEV object corresponding to -V. /// const SCEV *getNegativeSCEV(const SCEV *V); -- cgit v1.1 From 2d7d477d9469695a13c61d0e8b33776aed77f065 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Mon, 21 Oct 2013 20:03:58 +0000 Subject: Fix CodeGen for vectors of pointers with address spaces. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193112 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLowering.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 8aa0abd..51d9e00 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -570,14 +570,18 @@ public: /// otherwise it will assert. EVT getValueType(Type *Ty, bool AllowUnknown = false) const { // Lower scalar pointers to native pointer types. - if (Ty->isPointerTy()) return getPointerTy(Ty->getPointerAddressSpace()); + if (PointerType *PTy = dyn_cast(Ty)) + return getPointerTy(PTy->getAddressSpace()); if (Ty->isVectorTy()) { VectorType *VTy = cast(Ty); Type *Elm = VTy->getElementType(); // Lower vectors of pointers to native pointer types. - if (Elm->isPointerTy()) - Elm = EVT(PointerTy).getTypeForEVT(Ty->getContext()); + if (PointerType *PT = dyn_cast(Elm)) { + EVT PointerTy(getPointerTy(PT->getAddressSpace())); + Elm = PointerTy.getTypeForEVT(Ty->getContext()); + } + return EVT::getVectorVT(Ty->getContext(), EVT::getEVT(Elm, false), VTy->getNumElements()); } -- cgit v1.1 From e161dc28a8a58431e5e1df98834aaee72baada85 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Mon, 21 Oct 2013 20:04:01 +0000 Subject: Remove unused TargetLowering field. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193113 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLowering.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 51d9e00..3cde173 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -1299,10 +1299,6 @@ private: const DataLayout *TD; const TargetLoweringObjectFile &TLOF; - /// The type to use for pointers for the default address space, usually i32 or - /// i64. - MVT PointerTy; - /// True if this is a little endian target. bool IsLittleEndian; -- cgit v1.1 From b5eae81267649a7ce53debe8196533f7a0472f5b Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Mon, 21 Oct 2013 20:11:47 +0000 Subject: [AArch64] Add the constraint to NEON scalar mla/mls instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193117 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 7fa5a06..944c144 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -206,10 +206,10 @@ def int_aarch64_neon_vneg : Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty], [IntrNoMem]>; // Signed Saturating Doubling Multiply-Add Long -def int_aarch64_neon_vqdmlal : Neon_2Arg_Long_Intrinsic; +def int_aarch64_neon_vqdmlal : Neon_3Arg_Long_Intrinsic; // Signed Saturating Doubling Multiply-Subtract Long -def int_aarch64_neon_vqdmlsl : Neon_2Arg_Long_Intrinsic; +def int_aarch64_neon_vqdmlsl : Neon_3Arg_Long_Intrinsic; // Signed Saturating Doubling Multiply Long def int_aarch64_neon_vqdmull : Neon_2Arg_Long_Intrinsic; -- cgit v1.1 From 8d6ad83253a8fcf4dbf48850db096c27fc45c3f0 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Mon, 21 Oct 2013 23:55:19 +0000 Subject: fix two typos. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193133 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DIBuilder.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/DIBuilder.h b/include/llvm/DIBuilder.h index 44ce3e4..420dcef 100644 --- a/include/llvm/DIBuilder.h +++ b/include/llvm/DIBuilder.h @@ -507,7 +507,7 @@ namespace llvm { /// @param AlwaysPreserve Boolean. Set to true if debug info for this /// variable should be preserved in optimized build. /// @param Flags Flags, e.g. artificial variable. - /// @param ArgNo If this variable is an arugment then this argument's + /// @param ArgNo If this variable is an argument then this argument's /// number. 1 indicates 1st argument. DIVariable createLocalVariable(unsigned Tag, DIDescriptor Scope, StringRef Name, @@ -527,7 +527,7 @@ namespace llvm { /// @param LineNo Line number. /// @param Ty Variable Type /// @param Addr An array of complex address operations. - /// @param ArgNo If this variable is an arugment then this argument's + /// @param ArgNo If this variable is an argument then this argument's /// number. 1 indicates 1st argument. DIVariable createComplexVariable(unsigned Tag, DIDescriptor Scope, StringRef Name, DIFile F, unsigned LineNo, -- cgit v1.1 From e877eebfe9d716ed1101aecf958af473836e70e1 Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Tue, 22 Oct 2013 05:09:41 +0000 Subject: Change llvm-cov output formatting to be more similar to gcov. - Replaced tabs with proper padding - print() takes two arguments, which are the GCNO and GCDA filenames - Files are listed at the top of output, appended by line 0 - Stripped strings of trailing \0s - Removed last two lines of whitespace in output Patch by Yuchen Wu! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193148 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/GCOV.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h index f1040f5..67d6370 100644 --- a/include/llvm/Support/GCOV.h +++ b/include/llvm/Support/GCOV.h @@ -145,7 +145,7 @@ public: uint32_t Len = readInt() * 4; StringRef Str = Buffer->getBuffer().slice(Cursor, Cursor+Len); Cursor += Len; - return Str; + return Str.split('\0').first; } uint64_t getCursor() const { return Cursor; } @@ -216,7 +216,7 @@ typedef SmallVector LineCounts; class FileInfo { public: void addLineCount(StringRef Filename, uint32_t Line, uint32_t Count); - void print(); + void print(StringRef gcnoFile, StringRef gcdaFile); private: StringMap LineInfo; }; -- cgit v1.1 From 18b9105d02ee152e7f8faab751d6f356428c3054 Mon Sep 17 00:00:00 2001 From: Anders Waldenborg Date: Tue, 22 Oct 2013 06:58:34 +0000 Subject: llvm-c: Add LLVMPrintTypeToString Differential Revision: http://llvm-reviews.chandlerc.com/D1963 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193149 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index f9717cc..a48ea7e 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -723,6 +723,14 @@ LLVMContextRef LLVMGetTypeContext(LLVMTypeRef Ty); void LLVMDumpType(LLVMTypeRef Val); /** + * Return a string representation of the type. Use + * LLVMDisposeMessage to free the string. + * + * @see llvm::Type::print() + */ +char *LLVMPrintTypeToString(LLVMTypeRef Val); + +/** * @defgroup LLVMCCoreTypeInt Integer Types * * Functions in this section operate on integer types. -- cgit v1.1 From 8c955ea858b0c99c856c7c10a3eee7576d13abd1 Mon Sep 17 00:00:00 2001 From: Wan Xiaofei Date: Tue, 22 Oct 2013 08:02:02 +0000 Subject: Using FoldingSet in SelectionDAG::getVTList. VTList has a long life cycle through the module and getVTList is frequently called. In current getVTList, sequential search over a std::vector is used, this is inefficient in big module. This patch use FoldingSet to implement hashing mechanism when searching. Reviewer: Nadav Rotem Test : Pass unit tests & LNT test suite git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193150 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/SelectionDAG.h | 41 ++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index 70920d1..1615e4b 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -38,6 +38,45 @@ class TargetLowering; class TargetSelectionDAGInfo; class TargetTransformInfo; +class SDVTListNode : public FoldingSetNode { + friend struct FoldingSetTrait; + /// FastID - A reference to an Interned FoldingSetNodeID for this node. + /// The Allocator in SelectionDAG holds the data. + /// SDVTList contains all types which are frequently accessed in SelectionDAG. + /// The size of this list is not expected big so it won't introduce memory penalty. + FoldingSetNodeIDRef FastID; + const EVT *VTs; + unsigned int NumVTs; + /// The hash value for SDVTList is fixed so cache it to avoid hash calculation + unsigned HashValue; +public: + SDVTListNode(const FoldingSetNodeIDRef ID, const EVT *VT, unsigned int Num) : + FastID(ID), VTs(VT), NumVTs(Num) { + HashValue = ID.ComputeHash(); + } + SDVTList getSDVTList() { + SDVTList result = {VTs, NumVTs}; + return result; + } +}; + +// Specialize FoldingSetTrait for SDVTListNode +// To avoid computing temp FoldingSetNodeID and hash value. +template<> struct FoldingSetTrait : DefaultFoldingSetTrait { + static void Profile(const SDVTListNode &X, FoldingSetNodeID& ID) { + ID = X.FastID; + } + static bool Equals(const SDVTListNode &X, const FoldingSetNodeID &ID, + unsigned IDHash, FoldingSetNodeID &TempID) { + if (X.HashValue != IDHash) + return false; + return ID == X.FastID; + } + static unsigned ComputeHash(const SDVTListNode &X, FoldingSetNodeID &TempID) { + return X.HashValue; + } +}; + template<> struct ilist_traits : public ilist_default_traits { private: mutable ilist_half_node Sentinel; @@ -1093,7 +1132,7 @@ private: void allnodes_clear(); /// VTList - List of non-single value types. - std::vector VTList; + FoldingSet VTListMap; /// CondCodeNodes - Maps to auto-CSE operations. std::vector CondCodeNodes; -- cgit v1.1 From 135fe6ac5f5b80ef68c19b3ec7bb0063e28f2bab Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Tue, 22 Oct 2013 15:18:03 +0000 Subject: Speling fixes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193165 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/ExecutionEngine.h | 2 +- include/llvm/Analysis/TargetTransformInfo.h | 2 +- include/llvm/CodeGen/CommandFlags.h | 2 +- include/llvm/MC/MCContext.h | 2 +- include/llvm/MC/MCSchedule.h | 2 +- include/llvm/Support/ErrorOr.h | 6 +++--- include/llvm/Support/FileSystem.h | 2 +- include/llvm/TableGen/Record.h | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/llvm-c/ExecutionEngine.h b/include/llvm-c/ExecutionEngine.h index 4e767b2..3ae4d89 100644 --- a/include/llvm-c/ExecutionEngine.h +++ b/include/llvm-c/ExecutionEngine.h @@ -197,7 +197,7 @@ LLVMMCJITMemoryManagerRef LLVMCreateSimpleMCJITMemoryManager( LLVMMemoryManagerAllocateCodeSectionCallback AllocateCodeSection, LLVMMemoryManagerAllocateDataSectionCallback AllocateDataSection, LLVMMemoryManagerFinalizeMemoryCallback FinalizeMemory, - LLVMMemoryManagerDestroyCallback Destory); + LLVMMemoryManagerDestroyCallback Destroy); void LLVMDisposeMCJITMemoryManager(LLVMMCJITMemoryManagerRef MM); diff --git a/include/llvm/Analysis/TargetTransformInfo.h b/include/llvm/Analysis/TargetTransformInfo.h index 9104fd4..4f47562 100644 --- a/include/llvm/Analysis/TargetTransformInfo.h +++ b/include/llvm/Analysis/TargetTransformInfo.h @@ -314,7 +314,7 @@ public: SK_ExtractSubvector ///< ExtractSubvector Index indicates start offset. }; - /// \brief Additonal information about an operand's possible values. + /// \brief Additional information about an operand's possible values. enum OperandValueKind { OK_AnyValue, // Operand can have any value. OK_UniformValue, // Operand is uniform (splat of a value). diff --git a/include/llvm/CodeGen/CommandFlags.h b/include/llvm/CodeGen/CommandFlags.h index 0c21e76..bc8dce3 100644 --- a/include/llvm/CodeGen/CommandFlags.h +++ b/include/llvm/CodeGen/CommandFlags.h @@ -150,7 +150,7 @@ FloatABIForCalls("float-abi", cl::opt FuseFPOps("fp-contract", - cl::desc("Enable aggresive formation of fused FP ops"), + cl::desc("Enable aggressive formation of fused FP ops"), cl::init(FPOpFusion::Standard), cl::values( clEnumValN(FPOpFusion::Fast, "fast", diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h index c012ed0..8fba18c 100644 --- a/include/llvm/MC/MCContext.h +++ b/include/llvm/MC/MCContext.h @@ -406,7 +406,7 @@ namespace llvm { void Deallocate(void *Ptr) { } - // Unrecoverable error has occured. Display the best diagnostic we can + // Unrecoverable error has occurred. Display the best diagnostic we can // and bail via exit(1). For now, most MC backend errors are unrecoverable. // FIXME: We should really do something about that. LLVM_ATTRIBUTE_NORETURN void FatalError(SMLoc L, const Twine &Msg); diff --git a/include/llvm/MC/MCSchedule.h b/include/llvm/MC/MCSchedule.h index 1edf204..6881e1d 100644 --- a/include/llvm/MC/MCSchedule.h +++ b/include/llvm/MC/MCSchedule.h @@ -124,7 +124,7 @@ struct MCSchedClassDesc { /// microarchitecture to the scheduler in the form of properties. It also /// optionally refers to scheduler resource tables and itinerary /// tables. Scheduler resource tables model the latency and cost for each -/// instruction type. Itinerary tables are an independant mechanism that +/// instruction type. Itinerary tables are an independent mechanism that /// provides a detailed reservation table describing each cycle of instruction /// execution. Subtargets may define any or all of the above categories of data /// depending on the type of CPU and selected scheduler. diff --git a/include/llvm/Support/ErrorOr.h b/include/llvm/Support/ErrorOr.h index f3ac305..6832e3d 100644 --- a/include/llvm/Support/ErrorOr.h +++ b/include/llvm/Support/ErrorOr.h @@ -34,7 +34,7 @@ struct ErrorHolderBase { ErrorHolderBase() : RefCount(1) {} - void aquire() { + void acquire() { ++RefCount; } @@ -308,7 +308,7 @@ private: // Get other's error. Error = Other.Error; HasError = true; - Error->aquire(); + Error->acquire(); } } @@ -437,7 +437,7 @@ public: ErrorOr(const ErrorOr &Other) : Error(0, 0) { Error = Other.Error; if (Other.Error.getPointer()->Error) { - Error.getPointer()->aquire(); + Error.getPointer()->acquire(); } } diff --git a/include/llvm/Support/FileSystem.h b/include/llvm/Support/FileSystem.h index f52785b..6baaeb8 100644 --- a/include/llvm/Support/FileSystem.h +++ b/include/llvm/Support/FileSystem.h @@ -732,7 +732,7 @@ public: /// should begin. Must be a multiple of /// mapped_file_region::alignment(). /// \param ec This is set to errc::success if the map was constructed - /// sucessfully. Otherwise it is set to a platform dependent error. + /// successfully. Otherwise it is set to a platform dependent error. mapped_file_region(const Twine &path, mapmode mode, uint64_t length, diff --git a/include/llvm/TableGen/Record.h b/include/llvm/TableGen/Record.h index e17cddd..50352bd 100644 --- a/include/llvm/TableGen/Record.h +++ b/include/llvm/TableGen/Record.h @@ -694,7 +694,7 @@ public: }; -/// IntInit - 7 - Represent an initalization by a literal integer value. +/// IntInit - 7 - Represent an initialization by a literal integer value. /// class IntInit : public TypedInit { int64_t Value; -- cgit v1.1 From 51ec77d880ce53cbc8a48168185edc085df9b6d9 Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Tue, 22 Oct 2013 17:43:47 +0000 Subject: Fix llvm-cov counts to be 64-bit integers to avoid overflows. Line counts in llvm-cov are read in as 64-bit integers but were being truncated to 32-bit in collectLineCounts(), which caused overflow for large counts. This patch fixes all counts to be uint64_t. Patch by Yuchen Wu! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193172 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/GCOV.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h index 67d6370..aa436fb 100644 --- a/include/llvm/Support/GCOV.h +++ b/include/llvm/Support/GCOV.h @@ -205,17 +205,17 @@ class GCOVLines { public: ~GCOVLines() { Lines.clear(); } void add(uint32_t N) { Lines.push_back(N); } - void collectLineCounts(FileInfo &FI, StringRef Filename, uint32_t Count); + void collectLineCounts(FileInfo &FI, StringRef Filename, uint64_t Count); void dump(); private: SmallVector Lines; }; -typedef SmallVector LineCounts; +typedef SmallVector LineCounts; class FileInfo { public: - void addLineCount(StringRef Filename, uint32_t Line, uint32_t Count); + void addLineCount(StringRef Filename, uint32_t Line, uint64_t Count); void print(StringRef gcnoFile, StringRef gcdaFile); private: StringMap LineInfo; -- cgit v1.1 From d0716b064744598ba7df33b8b47de0375c450570 Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Wed, 23 Oct 2013 00:44:24 +0000 Subject: SelectionDAG: Pass along the original argument/element type in ISD::InputArg For some targets, it is useful to be able to look at the original type of an argument without having to dig through the original IR. This also fixes a bug in SelectionDAGBuilder where InputArg.PartOffset was not taking into account the offset of structure elements. Patch by: Justin Holewinski Tom Stellard: - Changed the type of ArgVT to EVT, so it can store non-simple types like v3i32. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193214 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetCallingConv.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Target/TargetCallingConv.h b/include/llvm/Target/TargetCallingConv.h index 1fd0bd9..9cc52a5 100644 --- a/include/llvm/Target/TargetCallingConv.h +++ b/include/llvm/Target/TargetCallingConv.h @@ -113,6 +113,7 @@ namespace ISD { struct InputArg { ArgFlagsTy Flags; MVT VT; + EVT ArgVT; bool Used; /// Index original Function's argument. @@ -124,10 +125,11 @@ namespace ISD { unsigned PartOffset; InputArg() : VT(MVT::Other), Used(false) {} - InputArg(ArgFlagsTy flags, EVT vt, bool used, + InputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool used, unsigned origIdx, unsigned partOffs) : Flags(flags), Used(used), OrigArgIndex(origIdx), PartOffset(partOffs) { VT = vt.getSimpleVT(); + ArgVT = argvt; } }; @@ -138,6 +140,7 @@ namespace ISD { struct OutputArg { ArgFlagsTy Flags; MVT VT; + EVT ArgVT; /// IsFixed - Is this a "fixed" value, ie not passed through a vararg "...". bool IsFixed; @@ -151,11 +154,12 @@ namespace ISD { unsigned PartOffset; OutputArg() : IsFixed(false) {} - OutputArg(ArgFlagsTy flags, EVT vt, bool isfixed, + OutputArg(ArgFlagsTy flags, EVT vt, EVT argvt, bool isfixed, unsigned origIdx, unsigned partOffs) : Flags(flags), IsFixed(isfixed), OrigArgIndex(origIdx), PartOffset(partOffs) { VT = vt.getSimpleVT(); + ArgVT = argvt; } }; } -- cgit v1.1 From 0082717cb537e2d1424f755a49510fa9f9e67071 Mon Sep 17 00:00:00 2001 From: Zoran Jovanovic Date: Wed, 23 Oct 2013 16:14:44 +0000 Subject: Support for microMIPS relocations 1. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193247 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/ELF.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/llvm/Support/ELF.h b/include/llvm/Support/ELF.h index 8acaa4a..a7cc206 100644 --- a/include/llvm/Support/ELF.h +++ b/include/llvm/Support/ELF.h @@ -880,6 +880,17 @@ enum { R_MIPS_GLOB_DAT = 51, R_MIPS_COPY = 126, R_MIPS_JUMP_SLOT = 127, + R_MICROMIPS_HI16 = 134, + R_MICROMIPS_LO16 = 135, + R_MICROMIPS_GOT16 = 138, + R_MICROMIPS_CALL16 = 142, + R_MICROMIPS_GOT_DISP = 145, + R_MICROMIPS_GOT_PAGE = 146, + R_MICROMIPS_GOT_OFST = 147, + 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 }; -- cgit v1.1 From f39fe46062d2093fc3d7c092bc8c4561b744164c Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 23 Oct 2013 16:57:34 +0000 Subject: Mark zero-argument functions explicitly in C headers. Pacifies GCC's -Wstrict-prototypes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193249 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index a48ea7e..cdaade3 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -408,7 +408,7 @@ void LLVMInitializeCore(LLVMPassRegistryRef R); /** Deallocate and destroy all ManagedStatic variables. @see llvm::llvm_shutdown @see ManagedStatic */ -void LLVMShutdown(); +void LLVMShutdown(void); /*===-- Error handling ----------------------------------------------------===*/ @@ -2748,16 +2748,16 @@ void LLVMDisposePassManager(LLVMPassManagerRef PM); initialization succeeded. Must be executed in isolation from all other LLVM api calls. @see llvm::llvm_start_multithreaded */ -LLVMBool LLVMStartMultithreaded(); +LLVMBool LLVMStartMultithreaded(void); /** Deallocate structures necessary to make LLVM safe for multithreading. Must be executed in isolation from all other LLVM api calls. @see llvm::llvm_stop_multithreaded */ -void LLVMStopMultithreaded(); +void LLVMStopMultithreaded(void); /** Check whether LLVM is executing in thread-safe mode or not. @see llvm::llvm_is_multithreaded */ -LLVMBool LLVMIsMultithreaded(); +LLVMBool LLVMIsMultithreaded(void); /** * @} -- cgit v1.1 From 8e3851a6eb9fe5fc30094c3a00d2b89c7cd68cbd Mon Sep 17 00:00:00 2001 From: Shuxin Yang Date: Wed, 23 Oct 2013 17:28:19 +0000 Subject: Use address-taken to disambiguate global variable and indirect memops. Major steps include: 1). introduces a not-addr-taken bit-field in GlobalVariable 2). GlobalOpt pass sets "not-address-taken" if it proves a global varirable dosen't have its address taken. 3). AA use this info for disambiguation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193251 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/GlobalVariable.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/GlobalVariable.h b/include/llvm/IR/GlobalVariable.h index bfed507..a5ab97d 100644 --- a/include/llvm/IR/GlobalVariable.h +++ b/include/llvm/IR/GlobalVariable.h @@ -48,6 +48,7 @@ class GlobalVariable : public GlobalValue, public ilist_node { // can change from its initial // value before global // initializers are run? + bool notAddrTaken : 1; // Dose not have address taken. public: // allocate space for exactly one operand @@ -174,6 +175,9 @@ public: isExternallyInitializedConstant = Val; } + void setAddressMaybeTaken(bool Val) { notAddrTaken = !Val; } + bool AddressMaybeTaken(void) const { return !notAddrTaken; } + /// copyAttributesFrom - copy all additional attributes (those not needed to /// create a GlobalVariable) from the GlobalVariable Src to this one. void copyAttributesFrom(const GlobalValue *Src); -- cgit v1.1 From e21c3137e1dfcd9644d3870a0a4528374375271f Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 23 Oct 2013 17:56:29 +0000 Subject: include/llvm-c: Whitespace. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193253 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/BitReader.h | 4 ++-- include/llvm-c/BitWriter.h | 4 ++-- include/llvm-c/Core.h | 44 +++++++++++++++++++------------------- include/llvm-c/Disassembler.h | 4 ++-- include/llvm-c/ExecutionEngine.h | 2 +- include/llvm-c/LinkTimeOptimizer.h | 4 ++-- include/llvm-c/Object.h | 1 - include/llvm-c/Target.h | 18 ++++++++-------- 8 files changed, 40 insertions(+), 41 deletions(-) (limited to 'include') diff --git a/include/llvm-c/BitReader.h b/include/llvm-c/BitReader.h index 5228035..7af209b 100644 --- a/include/llvm-c/BitReader.h +++ b/include/llvm-c/BitReader.h @@ -34,7 +34,7 @@ extern "C" { /* Builds a module from the bitcode in the specified memory buffer, returning a reference to the module via the OutModule parameter. Returns 0 on success. - Optionally returns a human-readable error message via OutMessage. */ + Optionally returns a human-readable error message via OutMessage. */ LLVMBool LLVMParseBitcode(LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutModule, char **OutMessage); @@ -44,7 +44,7 @@ LLVMBool LLVMParseBitcodeInContext(LLVMContextRef ContextRef, /** Reads a module from the specified path, returning via the OutMP parameter a module provider which performs lazy deserialization. Returns 0 on success. - Optionally returns a human-readable error message via OutMessage. */ + Optionally returns a human-readable error message via OutMessage. */ LLVMBool LLVMGetBitcodeModuleInContext(LLVMContextRef ContextRef, LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutM, diff --git a/include/llvm-c/BitWriter.h b/include/llvm-c/BitWriter.h index ba5a677..f605e24 100644 --- a/include/llvm-c/BitWriter.h +++ b/include/llvm-c/BitWriter.h @@ -34,7 +34,7 @@ extern "C" { /*===-- Operations on modules ---------------------------------------------===*/ -/** Writes a module to the specified path. Returns 0 on success. */ +/** Writes a module to the specified path. Returns 0 on success. */ int LLVMWriteBitcodeToFile(LLVMModuleRef M, const char *Path); /** Writes a module to an open file descriptor. Returns 0 on success. */ @@ -42,7 +42,7 @@ int LLVMWriteBitcodeToFD(LLVMModuleRef M, int FD, int ShouldClose, int Unbuffered); /** Deprecated for LLVMWriteBitcodeToFD. Writes a module to an open file - descriptor. Returns 0 on success. Closes the Handle. */ + descriptor. Returns 0 on success. Closes the Handle. */ int LLVMWriteBitcodeToFileHandle(LLVMModuleRef M, int Handle); /** diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index cdaade3..b9bae7e 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -354,26 +354,26 @@ typedef enum { LLVMAtomicOrderingNotAtomic = 0, /**< A load or store which is not atomic */ LLVMAtomicOrderingUnordered = 1, /**< Lowest level of atomicity, guarantees somewhat sane results, lock free. */ - LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the - operations affecting a specific address, + LLVMAtomicOrderingMonotonic = 2, /**< guarantees that if you take all the + operations affecting a specific address, a consistent ordering exists */ - LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort - necessary to acquire a lock to access other + LLVMAtomicOrderingAcquire = 4, /**< Acquire provides a barrier of the sort + necessary to acquire a lock to access other memory with normal loads and stores. */ - LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with - a barrier of the sort necessary to release + LLVMAtomicOrderingRelease = 5, /**< Release is similar to Acquire, but with + a barrier of the sort necessary to release a lock. */ - LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a - Release barrier (for fences and + LLVMAtomicOrderingAcquireRelease = 6, /**< provides both an Acquire and a + Release barrier (for fences and operations which both read and write memory). */ - LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics - for loads and Release - semantics for stores. - Additionally, it guarantees - that a total ordering exists - between all - SequentiallyConsistent + LLVMAtomicOrderingSequentiallyConsistent = 7 /**< provides Acquire semantics + for loads and Release + semantics for stores. + Additionally, it guarantees + that a total ordering exists + between all + SequentiallyConsistent operations. */ } LLVMAtomicOrdering; @@ -386,16 +386,16 @@ typedef enum { LLVMAtomicRMWBinOpOr, /**< OR a value and return the old one */ LLVMAtomicRMWBinOpXor, /**< Xor a value and return the old one */ LLVMAtomicRMWBinOpMax, /**< Sets the value if it's greater than the - original using a signed comparison and return + original using a signed comparison and return the old one */ LLVMAtomicRMWBinOpMin, /**< Sets the value if it's Smaller than the - original using a signed comparison and return + original using a signed comparison and return the old one */ LLVMAtomicRMWBinOpUMax, /**< Sets the value if it's greater than the - original using an unsigned comparison and return + original using an unsigned comparison and return the old one */ LLVMAtomicRMWBinOpUMin /**< Sets the value if it's greater than the - original using an unsigned comparison and return + original using an unsigned comparison and return the old one */ } LLVMAtomicRMWBinOp; @@ -2613,9 +2613,9 @@ LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val, const char *Name); LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS, LLVMValueRef RHS, const char *Name); -LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B,LLVMAtomicRMWBinOp op, - LLVMValueRef PTR, LLVMValueRef Val, - LLVMAtomicOrdering ordering, +LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B,LLVMAtomicRMWBinOp op, + LLVMValueRef PTR, LLVMValueRef Val, + LLVMAtomicOrdering ordering, LLVMBool singleThread); /** diff --git a/include/llvm-c/Disassembler.h b/include/llvm-c/Disassembler.h index 4732e51..5e0b618 100644 --- a/include/llvm-c/Disassembler.h +++ b/include/llvm-c/Disassembler.h @@ -42,7 +42,7 @@ typedef void *LLVMDisasmContextRef; * instruction are specified by the Offset parameter and its byte widith is the * size parameter. For instructions sets with fixed widths and one symbolic * operand per instruction, the Offset parameter will be zero and Size parameter - * will be the instruction width. The information is returned in TagBuf and is + * will be the instruction width. The information is returned in TagBuf and is * Triple specific with its specific information defined by the value of * TagType for that Triple. If symbolic information is returned the function * returns 1, otherwise it returns 0. @@ -58,7 +58,7 @@ typedef int (*LLVMOpInfoCallback)(void *DisInfo, uint64_t PC, * SubtractSymbol can be link edited independent of each other. Many other * platforms only allow a relocatable expression of the form AddSymbol + Offset * to be encoded. - * + * * The LLVMOpInfoCallback() for the TagType value of 1 uses the struct * LLVMOpInfo1. The value of the relocatable expression for the operand, * including any PC adjustment, is passed in to the call back in the Value diff --git a/include/llvm-c/ExecutionEngine.h b/include/llvm-c/ExecutionEngine.h index 3ae4d89..3564312 100644 --- a/include/llvm-c/ExecutionEngine.h +++ b/include/llvm-c/ExecutionEngine.h @@ -206,7 +206,7 @@ void LLVMDisposeMCJITMemoryManager(LLVMMCJITMemoryManagerRef MM); */ #ifdef __cplusplus -} +} #endif /* defined(__cplusplus) */ #endif diff --git a/include/llvm-c/LinkTimeOptimizer.h b/include/llvm-c/LinkTimeOptimizer.h index 7a0fbf6..8bcf599 100644 --- a/include/llvm-c/LinkTimeOptimizer.h +++ b/include/llvm-c/LinkTimeOptimizer.h @@ -4,7 +4,7 @@ // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. -// +// //===----------------------------------------------------------------------===// // // This header provides a C API to use the LLVM link time optimization @@ -46,7 +46,7 @@ extern "C" { // Added C-specific error codes LLVM_LTO_NULL_OBJECT } llvm_lto_status_t; - + /// This provides C interface to initialize link time optimizer. This allows /// linker to use dlopen() interface to dynamically load LinkTimeOptimizer. /// extern "C" helps, because dlopen() interface uses name to find the symbol. diff --git a/include/llvm-c/Object.h b/include/llvm-c/Object.h index ecccfee..c271552 100644 --- a/include/llvm-c/Object.h +++ b/include/llvm-c/Object.h @@ -100,4 +100,3 @@ const char *LLVMGetRelocationValueString(LLVMRelocationIteratorRef RI); #endif /* defined(__cplusplus) */ #endif - diff --git a/include/llvm-c/Target.h b/include/llvm-c/Target.h index 27eb147..46ee59a 100644 --- a/include/llvm-c/Target.h +++ b/include/llvm-c/Target.h @@ -44,7 +44,7 @@ typedef struct LLVMStructLayout *LLVMStructLayoutRef; void LLVMInitialize##TargetName##TargetInfo(void); #include "llvm/Config/Targets.def" #undef LLVM_TARGET /* Explicit undef to make SWIG happier */ - + #define LLVM_TARGET(TargetName) void LLVMInitialize##TargetName##Target(void); #include "llvm/Config/Targets.def" #undef LLVM_TARGET /* Explicit undef to make SWIG happier */ @@ -53,7 +53,7 @@ typedef struct LLVMStructLayout *LLVMStructLayoutRef; void LLVMInitialize##TargetName##TargetMC(void); #include "llvm/Config/Targets.def" #undef LLVM_TARGET /* Explicit undef to make SWIG happier */ - + /* Declare all of the available assembly printer initialization functions. */ #define LLVM_ASM_PRINTER(TargetName) \ void LLVMInitialize##TargetName##AsmPrinter(void); @@ -71,7 +71,7 @@ typedef struct LLVMStructLayout *LLVMStructLayoutRef; void LLVMInitialize##TargetName##Disassembler(void); #include "llvm/Config/Disassemblers.def" #undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */ - + /** LLVMInitializeAllTargetInfos - The main program should call this function if it wants access to all available targets that LLVM is configured to support. */ @@ -98,7 +98,7 @@ static inline void LLVMInitializeAllTargetMCs(void) { #include "llvm/Config/Targets.def" #undef LLVM_TARGET /* Explicit undef to make SWIG happier */ } - + /** LLVMInitializeAllAsmPrinters - The main program should call this function if it wants all asm printers that LLVM is configured to support, to make them available via the TargetRegistry. */ @@ -107,7 +107,7 @@ static inline void LLVMInitializeAllAsmPrinters(void) { #include "llvm/Config/AsmPrinters.def" #undef LLVM_ASM_PRINTER /* Explicit undef to make SWIG happier */ } - + /** LLVMInitializeAllAsmParsers - The main program should call this function if it wants all asm parsers that LLVM is configured to support, to make them available via the TargetRegistry. */ @@ -116,7 +116,7 @@ static inline void LLVMInitializeAllAsmParsers(void) { #include "llvm/Config/AsmParsers.def" #undef LLVM_ASM_PARSER /* Explicit undef to make SWIG happier */ } - + /** LLVMInitializeAllDisassemblers - The main program should call this function if it wants all disassemblers that LLVM is configured to support, to make them available via the TargetRegistry. */ @@ -126,9 +126,9 @@ static inline void LLVMInitializeAllDisassemblers(void) { #include "llvm/Config/Disassemblers.def" #undef LLVM_DISASSEMBLER /* Explicit undef to make SWIG happier */ } - + /** LLVMInitializeNativeTarget - The main program should call this function to - initialize the native target corresponding to the host. This is useful + initialize the native target corresponding to the host. This is useful for JIT applications to ensure that the target gets linked in correctly. */ static inline LLVMBool LLVMInitializeNativeTarget(void) { /* If we have a native target, initialize it to ensure it is linked in. */ @@ -140,7 +140,7 @@ static inline LLVMBool LLVMInitializeNativeTarget(void) { #else return 1; #endif -} +} /*===-- Target Data -------------------------------------------------------===*/ -- cgit v1.1 From 266acb9fee5bcb760d9dffe2afc10d62bb86b0e1 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 23 Oct 2013 17:56:46 +0000 Subject: llvm-c/lto.h: Avoid use of bool. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193255 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/lto.h | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/llvm-c/lto.h b/include/llvm-c/lto.h index 85d5439..5004240 100644 --- a/include/llvm-c/lto.h +++ b/include/llvm-c/lto.h @@ -16,9 +16,6 @@ #ifndef LLVM_C_LTO_H #define LLVM_C_LTO_H -#ifndef __cplusplus -#include -#endif #include #include @@ -89,14 +86,14 @@ lto_get_error_message(void); /** * Checks if a file is a loadable object file. */ -extern bool +extern int lto_module_is_object_file(const char* path); /** * Checks if a file is a loadable object compiled for requested target. */ -extern bool +extern int lto_module_is_object_file_for_target(const char* path, const char* target_triple_prefix); @@ -104,14 +101,14 @@ lto_module_is_object_file_for_target(const char* path, /** * Checks if a buffer is a loadable object file. */ -extern bool +extern int lto_module_is_object_file_in_memory(const void* mem, size_t length); /** * Checks if a buffer is a loadable object compiled for requested target. */ -extern bool +extern int lto_module_is_object_file_in_memory_for_target(const void* mem, size_t length, const char* target_triple_prefix); @@ -210,7 +207,7 @@ lto_codegen_dispose(lto_code_gen_t); * Add an object module to the set of modules for which code will be generated. * Returns true on error (check lto_get_error_message() for details). */ -extern bool +extern int lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod); @@ -219,7 +216,7 @@ lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod); * Sets if debug info should be generated. * Returns true on error (check lto_get_error_message() for details). */ -extern bool +extern int lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model); @@ -227,7 +224,7 @@ lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model); * Sets which PIC code model to generated. * Returns true on error (check lto_get_error_message() for details). */ -extern bool +extern int lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model); @@ -273,7 +270,7 @@ extern void lto_codegen_add_dso_symbol(lto_code_gen_t cg, const char *symbol); * merged contents of all modules added so far. * Returns true on error (check lto_get_error_message() for details). */ -extern bool +extern int lto_codegen_write_merged_modules(lto_code_gen_t cg, const char* path); /** @@ -291,7 +288,7 @@ lto_codegen_compile(lto_code_gen_t cg, size_t* length); * Generates code for all added modules into one native object file. * The name of the file is written to name. Returns true on error. */ -extern bool +extern int lto_codegen_compile_to_file(lto_code_gen_t cg, const char** name); -- cgit v1.1 From 473436709959f09ed3ed415de0f17820d9188d09 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 23 Oct 2013 17:56:52 +0000 Subject: llvm-c/Target.h: Tweak "inline" for msvc to use __inline instead. FIXME: I don't think it'd be smart. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193256 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Target.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Target.h b/include/llvm-c/Target.h index 46ee59a..71a2481 100644 --- a/include/llvm-c/Target.h +++ b/include/llvm-c/Target.h @@ -22,6 +22,10 @@ #include "llvm-c/Core.h" #include "llvm/Config/llvm-config.h" +#if defined(_MSC_VER) && !defined(inline) +#define inline __inline +#endif + #ifdef __cplusplus extern "C" { #endif -- cgit v1.1 From 9db9663d1d2e4e336c2787bacff4ee7125622e21 Mon Sep 17 00:00:00 2001 From: Yuchen Wu Date: Wed, 23 Oct 2013 19:45:03 +0000 Subject: Use a map instead of vector to store line counts. There are a few motivations for this: - Using a map allows for checking if line is in map. This differentiates unexecutable lines (such as comments) from unexecuted logical lines of code. "#####" is now outputted in this case, in line with gcov. - Source files are no longer read in twice: once when storing the line counts, and once when outputting the data. - Greatly simplifies the function FileInfo::addLineCount(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193264 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/GCOV.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h index aa436fb..f1e7998 100644 --- a/include/llvm/Support/GCOV.h +++ b/include/llvm/Support/GCOV.h @@ -15,6 +15,7 @@ #ifndef LLVM_SUPPORT_GCOV_H #define LLVM_SUPPORT_GCOV_H +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringMap.h" #include "llvm/Support/MemoryBuffer.h" @@ -212,10 +213,12 @@ private: SmallVector Lines; }; -typedef SmallVector LineCounts; +typedef DenseMap LineCounts; class FileInfo { public: - void addLineCount(StringRef Filename, uint32_t Line, uint64_t Count); + void addLineCount(StringRef Filename, uint32_t Line, uint64_t Count) { + LineInfo[Filename][Line-1] = Count; + } void print(StringRef gcnoFile, StringRef gcdaFile); private: StringMap LineInfo; -- cgit v1.1 From 3d0b7e1cc5856ae0c17687e1be3cddeb79704bca Mon Sep 17 00:00:00 2001 From: Yuchen Wu Date: Wed, 23 Oct 2013 21:25:44 +0000 Subject: Fixed doxygen comment to match Module.cpp git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193273 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Module.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/IR/Module.h b/include/llvm/IR/Module.h index 3dbc5ff..b30a9a3 100644 --- a/include/llvm/IR/Module.h +++ b/include/llvm/IR/Module.h @@ -391,7 +391,7 @@ public: /// @name Named Metadata Accessors /// @{ - /// getNamedMetadata - Return the NamedMDNode in the module with the + /// getNamedMetadata - Return the first NamedMDNode in the module with the /// specified name. This method returns null if a NamedMDNode with the /// specified name is not found. NamedMDNode *getNamedMetadata(const Twine &Name) const; -- cgit v1.1 From 2ad18efdc73bc2356aa7fbf811d5ecbbaac0f2c9 Mon Sep 17 00:00:00 2001 From: Andrew Kaylor Date: Thu, 24 Oct 2013 00:19:14 +0000 Subject: Optimizing MCJIT module state tracking Patch co-developed with Yaron Keren. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193291 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ExecutionEngine/ExecutionEngine.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h index 10b3fed..233084d 100644 --- a/include/llvm/ExecutionEngine/ExecutionEngine.h +++ b/include/llvm/ExecutionEngine/ExecutionEngine.h @@ -215,7 +215,7 @@ public: /// FindFunctionNamed - Search all of the active modules to find the one that /// defines FnName. This is very slow operation and shouldn't be used for /// general code. - Function *FindFunctionNamed(const char *FnName); + virtual Function *FindFunctionNamed(const char *FnName); /// runFunction - Execute the specified function with the specified arguments, /// and return the result. @@ -232,6 +232,9 @@ public: /// /// This function is deprecated for the MCJIT execution engine. /// + /// FIXME: the JIT and MCJIT interfaces should be disentangled or united + /// again, if possible. + /// virtual void *getPointerToNamedFunction(const std::string &Name, bool AbortOnFailure = true) = 0; @@ -275,7 +278,7 @@ public: /// the static constructors or destructors for a program. /// /// \param isDtors - Run the destructors instead of constructors. - void runStaticConstructorsDestructors(bool isDtors); + virtual void runStaticConstructorsDestructors(bool isDtors); /// runStaticConstructorsDestructors - This method is used to execute all of /// the static constructors or destructors for a particular module. -- cgit v1.1 From cbbd20879e8acf35d3326a2459e17a298b5f5d15 Mon Sep 17 00:00:00 2001 From: Yuchen Wu Date: Thu, 24 Oct 2013 01:51:04 +0000 Subject: Fixed llvm-cov to count edges instead of blocks. This was a fundamental flaw in llvm-cov where it treated the values in the GCDA files as block counts instead of edge counts. This created incorrect line counts when branching was present. Instead, the edge counts should be summed to obtain the correct block count. The fix was tested using custom test files as well as single source files from the test-suite directory. The behaviour can be verified by reading the GCOV documentation that describes the GCDA spec ("ARC_COUNTS gives the counter values for those arcs that are instrumented") and the header description provided by GCOVProfiling.cpp ("instruments the code that runs to records (sic) the edges between blocks that run and emit a complementary "gcda" file on exit"). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193299 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/GCOV.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h index f1e7998..4bcd0ed 100644 --- a/include/llvm/Support/GCOV.h +++ b/include/llvm/Support/GCOV.h @@ -191,7 +191,8 @@ public: ~GCOVBlock(); void addEdge(uint32_t N) { Edges.push_back(N); } void addLine(StringRef Filename, uint32_t LineNo); - void addCount(uint64_t N) { Counter = N; } + void addCount(uint64_t N) { Counter += N; } + size_t getNumEdges() { return Edges.size(); } void dump(); void collectLineCounts(FileInfo &FI); private: @@ -217,7 +218,7 @@ typedef DenseMap LineCounts; class FileInfo { public: void addLineCount(StringRef Filename, uint32_t Line, uint64_t Count) { - LineInfo[Filename][Line-1] = Count; + LineInfo[Filename][Line-1] += Count; } void print(StringRef gcnoFile, StringRef gcdaFile); private: -- cgit v1.1 From 62ef05811661d7aff6276e64cc4ba7d325a408d6 Mon Sep 17 00:00:00 2001 From: Elena Demikhovsky Date: Thu, 24 Oct 2013 07:16:35 +0000 Subject: AVX-512: added VCVTPH2PS, VCVTPS2PH with intrinsics git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193312 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index 052fa84..537089d 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -2618,6 +2618,11 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_vcvtps2ph_256 : GCCBuiltin<"__builtin_ia32_vcvtps2ph256">, Intrinsic<[llvm_v8i16_ty], [llvm_v8f32_ty, llvm_i32_ty], [IntrNoMem]>; + def int_x86_avx512_vcvtph2ps_512 : GCCBuiltin<"__builtin_ia32_vcvtph2ps512">, + Intrinsic<[llvm_v16f32_ty], [llvm_v16i16_ty], [IntrNoMem]>; + def int_x86_avx512_vcvtps2ph_512 : GCCBuiltin<"__builtin_ia32_vcvtps2ph512">, + Intrinsic<[llvm_v16i16_ty], [llvm_v16f32_ty, llvm_i32_ty], + [IntrNoMem]>; } //===----------------------------------------------------------------------===// -- cgit v1.1 From 5e4d8a5eca03c977ba01e061078a2d740ee6130a Mon Sep 17 00:00:00 2001 From: Zonr Chang Date: Thu, 24 Oct 2013 08:17:39 +0000 Subject: Include missing Compiler.h for using LLVM_ENUM_INT_TYPE. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193315 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/ELF.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/Support/ELF.h b/include/llvm/Support/ELF.h index a7cc206..ca53f55 100644 --- a/include/llvm/Support/ELF.h +++ b/include/llvm/Support/ELF.h @@ -20,6 +20,7 @@ #ifndef LLVM_SUPPORT_ELF_H #define LLVM_SUPPORT_ELF_H +#include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" #include -- cgit v1.1 From 5e1d0d39db5fefe013f58c124a94694f96bce2f1 Mon Sep 17 00:00:00 2001 From: Nuno Lopes Date: Thu, 24 Oct 2013 09:17:24 +0000 Subject: fix PR17635: false positive with packed structures LLVM optimizers may widen accesses to packed structures that overflow the structure itself, but should be in bounds up to the alignment of the object git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193317 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/MemoryBuiltins.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Analysis/MemoryBuiltins.h b/include/llvm/Analysis/MemoryBuiltins.h index c54b7e6..91224ad 100644 --- a/include/llvm/Analysis/MemoryBuiltins.h +++ b/include/llvm/Analysis/MemoryBuiltins.h @@ -228,6 +228,7 @@ class ObjectSizeOffsetEvaluator Value *Zero; CacheMapTy CacheMap; PtrSetTy SeenVals; + bool RoundToAlign; SizeOffsetEvalType unknown() { return std::make_pair((Value*)0, (Value*)0); @@ -236,7 +237,7 @@ class ObjectSizeOffsetEvaluator public: ObjectSizeOffsetEvaluator(const DataLayout *DL, const TargetLibraryInfo *TLI, - LLVMContext &Context); + LLVMContext &Context, bool RoundToAlign = false); SizeOffsetEvalType compute(Value *V); bool knownSize(SizeOffsetEvalType SizeOffset) { -- cgit v1.1 From 43752f2d4f29ebb40318e8da05633c994b694f46 Mon Sep 17 00:00:00 2001 From: John Thompson Date: Thu, 24 Oct 2013 13:36:58 +0000 Subject: Added std::string as a built-in type for mapping. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193344 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/YAMLTraits.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h index 98964fc..a57e049 100644 --- a/include/llvm/Support/YAMLTraits.h +++ b/include/llvm/Support/YAMLTraits.h @@ -1,4 +1,4 @@ -//===- llvm/Supporrt/YAMLTraits.h -------------------------------*- C++ -*-===// +//===- llvm/Support/YAMLTraits.h -------------------------------*- C++ -*-===// // // The LLVM Linker // @@ -539,6 +539,12 @@ struct ScalarTraits { }; template<> +struct ScalarTraits { + static void output(const std::string &, void*, llvm::raw_ostream &); + static StringRef input(StringRef, void*, std::string &); +}; + +template<> struct ScalarTraits { static void output(const uint8_t &, void*, llvm::raw_ostream &); static StringRef input(StringRef, void*, uint8_t &); -- cgit v1.1 From 96b40055489a044a1815d5316f8b865794dd7550 Mon Sep 17 00:00:00 2001 From: John Thompson Date: Thu, 24 Oct 2013 14:52:56 +0000 Subject: Reverting my r193344 checkin due to build breakage. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193350 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/YAMLTraits.h | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h index a57e049..98964fc 100644 --- a/include/llvm/Support/YAMLTraits.h +++ b/include/llvm/Support/YAMLTraits.h @@ -1,4 +1,4 @@ -//===- llvm/Support/YAMLTraits.h -------------------------------*- C++ -*-===// +//===- llvm/Supporrt/YAMLTraits.h -------------------------------*- C++ -*-===// // // The LLVM Linker // @@ -539,12 +539,6 @@ struct ScalarTraits { }; template<> -struct ScalarTraits { - static void output(const std::string &, void*, llvm::raw_ostream &); - static StringRef input(StringRef, void*, std::string &); -}; - -template<> struct ScalarTraits { static void output(const uint8_t &, void*, llvm::raw_ostream &); static StringRef input(StringRef, void*, uint8_t &); -- cgit v1.1 From 2ea3b539289bd4261915192c7da35bddd7634cb9 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Thu, 24 Oct 2013 21:04:51 +0000 Subject: Formatting and whitespace. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193370 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/AsmPrinter.h | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h index d6a6ab4..3dfde20 100644 --- a/include/llvm/CodeGen/AsmPrinter.h +++ b/include/llvm/CodeGen/AsmPrinter.h @@ -365,14 +365,14 @@ namespace llvm { /// where the size in bytes of the directive is specified by Size and Label /// specifies the label. This implicitly uses .set if it is available. void EmitLabelPlusOffset(const MCSymbol *Label, uint64_t Offset, - unsigned Size, - bool IsSectionRelative = false) const; + unsigned Size, + bool IsSectionRelative = false) const; /// EmitLabelReference - Emit something like ".long Label" /// where the size in bytes of the directive is specified by Size and Label /// specifies the label. - void EmitLabelReference(const MCSymbol *Label, unsigned Size, - bool IsSectionRelative = false) const { + void EmitLabelReference(const MCSymbol *Label, unsigned Size, + bool IsSectionRelative = false) const { EmitLabelPlusOffset(Label, 0, Size, IsSectionRelative); } @@ -457,8 +457,7 @@ namespace llvm { /// return true if the operand is erroneous. virtual bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, - const char *ExtraCode, - raw_ostream &OS); + const char *ExtraCode, raw_ostream &OS); private: /// Private state for PrintSpecial() @@ -470,7 +469,8 @@ namespace llvm { /// EmitInlineAsm - Emit a blob of inline asm to the output streamer. void EmitInlineAsm(StringRef Str, const MDNode *LocMDNode = 0, - InlineAsm::AsmDialect AsmDialect = InlineAsm::AD_ATT) const; + InlineAsm::AsmDialect AsmDialect = + InlineAsm::AD_ATT) const; /// EmitInlineAsm - This method formats and emits the specified machine /// instruction that is an inline asm. @@ -488,8 +488,7 @@ namespace llvm { void EmitLinkage(unsigned Linkage, MCSymbol *GVSym) const; void EmitJumpTableEntry(const MachineJumpTableInfo *MJTI, - const MachineBasicBlock *MBB, - unsigned uid) const; + const MachineBasicBlock *MBB, unsigned uid) const; void EmitLLVMUsedList(const ConstantArray *InitList); /// Emit llvm.ident metadata in an '.ident' directive. void EmitModuleIdents(Module &M); -- cgit v1.1 From 07d5aef3057b2e403b20d683e7477c93fde67d99 Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Thu, 24 Oct 2013 22:26:04 +0000 Subject: lto.h: Use lto_bool_t instead of int to restore the ABI This reverts commit r193255 and instead creates an lto_bool_t typedef that points to bool, _Bool, or unsigned char depending on what is available. Only recent versions of MSVC provide a stdbool.h header. Reviewers: rafael.espindola Differential Revision: http://llvm-reviews.chandlerc.com/D2019 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193377 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/lto.h | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/llvm-c/lto.h b/include/llvm-c/lto.h index 5004240..02105bc 100644 --- a/include/llvm-c/lto.h +++ b/include/llvm-c/lto.h @@ -19,6 +19,20 @@ #include #include +#ifndef __cplusplus +#if !defined(_MSC_VER) +#include +typedef bool lto_bool_t; +#else +// MSVC in particular does not have anything like _Bool or bool in C, but we can +// at least make sure the type is the same size. The implementation side will +// use C++ bool. +typedef unsigned char lto_bool_t; +#endif +#else +typedef bool lto_bool_t; +#endif + /** * @defgroup LLVMCLTO LTO * @ingroup LLVMC @@ -86,14 +100,14 @@ lto_get_error_message(void); /** * Checks if a file is a loadable object file. */ -extern int +extern lto_bool_t lto_module_is_object_file(const char* path); /** * Checks if a file is a loadable object compiled for requested target. */ -extern int +extern lto_bool_t lto_module_is_object_file_for_target(const char* path, const char* target_triple_prefix); @@ -101,14 +115,14 @@ lto_module_is_object_file_for_target(const char* path, /** * Checks if a buffer is a loadable object file. */ -extern int +extern lto_bool_t lto_module_is_object_file_in_memory(const void* mem, size_t length); /** * Checks if a buffer is a loadable object compiled for requested target. */ -extern int +extern lto_bool_t lto_module_is_object_file_in_memory_for_target(const void* mem, size_t length, const char* target_triple_prefix); @@ -207,7 +221,7 @@ lto_codegen_dispose(lto_code_gen_t); * Add an object module to the set of modules for which code will be generated. * Returns true on error (check lto_get_error_message() for details). */ -extern int +extern lto_bool_t lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod); @@ -216,7 +230,7 @@ lto_codegen_add_module(lto_code_gen_t cg, lto_module_t mod); * Sets if debug info should be generated. * Returns true on error (check lto_get_error_message() for details). */ -extern int +extern lto_bool_t lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model); @@ -224,7 +238,7 @@ lto_codegen_set_debug_model(lto_code_gen_t cg, lto_debug_model); * Sets which PIC code model to generated. * Returns true on error (check lto_get_error_message() for details). */ -extern int +extern lto_bool_t lto_codegen_set_pic_model(lto_code_gen_t cg, lto_codegen_model); @@ -270,7 +284,7 @@ extern void lto_codegen_add_dso_symbol(lto_code_gen_t cg, const char *symbol); * merged contents of all modules added so far. * Returns true on error (check lto_get_error_message() for details). */ -extern int +extern lto_bool_t lto_codegen_write_merged_modules(lto_code_gen_t cg, const char* path); /** @@ -288,7 +302,7 @@ lto_codegen_compile(lto_code_gen_t cg, size_t* length); * Generates code for all added modules into one native object file. * The name of the file is written to name. Returns true on error. */ -extern int +extern lto_bool_t lto_codegen_compile_to_file(lto_code_gen_t cg, const char** name); -- cgit v1.1 From 5759c3a02902026a27a0d1bc24a5bad85f52bd71 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Thu, 24 Oct 2013 22:43:10 +0000 Subject: MCStreamer: Reimplement the virtual EmitRawText as a protected member, EmitRawTextImpl, to avoid string literal ambiguities Also improve the implementation of EmitRawText(Twine) so it doesn't bother using the SmallString buffer if the Twine is a simple StringRef anyway. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193378 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCStreamer.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 974feea..47d798d 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -149,6 +149,8 @@ protected: } void EmitW64Tables(); + virtual void EmitRawTextImpl(StringRef String); + public: virtual ~MCStreamer(); @@ -657,7 +659,6 @@ public: /// EmitRawText - If this file is backed by a assembly streamer, this dumps /// the specified string in the output .s file. This capability is /// indicated by the hasRawTextSupport() predicate. By default this aborts. - virtual void EmitRawText(StringRef String); void EmitRawText(const Twine &String); /// Flush - Causes any cached state to be written out. -- cgit v1.1 From 76fa4d629b22903632529e2cb19c86105a0d1247 Mon Sep 17 00:00:00 2001 From: Yuchen Wu Date: Fri, 25 Oct 2013 02:22:21 +0000 Subject: Support for reading program counts in llvm-cov. llvm-cov will now be able to read program counts from the GCDA file and output it in the same format as gcov. The program summary tag was identified from gcov-io.h as "\0\0\0\a3". There is currently a bug in GCOVProfiling.cpp which does not generate the run- or program-counting IR, so this change was tested manually by modifying the GCDA file and comparing the gcov and llvm-cov outputs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193389 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/GCOV.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h index 4bcd0ed..ef1a4eb 100644 --- a/include/llvm/Support/GCOV.h +++ b/include/llvm/Support/GCOV.h @@ -126,6 +126,19 @@ public: return true; } + /// readProgramTag - If cursor points to a program summary tag then increment + /// the cursor and return true otherwise return false. + bool readProgramTag() { + StringRef Tag = Buffer->getBuffer().slice(Cursor, Cursor+4); + if (Tag.empty() || + Tag[0] != '\0' || Tag[1] != '\0' || + Tag[2] != '\0' || Tag[3] != '\xa3') { + return false; + } + Cursor += 4; + return true; + } + uint32_t readInt() { uint32_t Result; StringRef Str = Buffer->getBuffer().slice(Cursor, Cursor+4); @@ -159,13 +172,14 @@ private: /// (.gcno and .gcda). class GCOVFile { public: - GCOVFile() {} + GCOVFile() : Functions(), ProgramCount(0) {} ~GCOVFile(); bool read(GCOVBuffer &Buffer); void dump(); void collectLineCounts(FileInfo &FI); private: SmallVector Functions; + uint32_t ProgramCount; }; /// GCOVFunction - Collects function information. @@ -220,9 +234,11 @@ public: void addLineCount(StringRef Filename, uint32_t Line, uint64_t Count) { LineInfo[Filename][Line-1] += Count; } + void setProgramCount(uint32_t PC) { ProgramCount = PC; } void print(StringRef gcnoFile, StringRef gcdaFile); private: StringMap LineInfo; + uint32_t ProgramCount; }; } -- cgit v1.1 From be3cf5f3e449ea54785ab49d9f01543b710a5125 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Fri, 25 Oct 2013 03:29:42 +0000 Subject: Fix ODR violation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193391 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCELFSymbolFlags.h | 2 +- include/llvm/MC/MCMachOSymbolFlags.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCELFSymbolFlags.h b/include/llvm/MC/MCELFSymbolFlags.h index 2225ea0..d0e1dac 100644 --- a/include/llvm/MC/MCELFSymbolFlags.h +++ b/include/llvm/MC/MCELFSymbolFlags.h @@ -27,7 +27,7 @@ namespace llvm { ELF_Other_Shift = 10 // Shift value for other flags. }; - enum SymbolFlags { + enum ELFSymbolFlags { ELF_STB_Local = (ELF::STB_LOCAL << ELF_STB_Shift), ELF_STB_Global = (ELF::STB_GLOBAL << ELF_STB_Shift), ELF_STB_Weak = (ELF::STB_WEAK << ELF_STB_Shift), diff --git a/include/llvm/MC/MCMachOSymbolFlags.h b/include/llvm/MC/MCMachOSymbolFlags.h index 696436d..71f01fa 100644 --- a/include/llvm/MC/MCMachOSymbolFlags.h +++ b/include/llvm/MC/MCMachOSymbolFlags.h @@ -19,9 +19,9 @@ // the correct relocation information. namespace llvm { - /// SymbolFlags - We store the value for the 'desc' symbol field in the lowest - /// 16 bits of the implementation defined flags. - enum SymbolFlags { // See . + /// MachOSymbolFlags - We store the value for the 'desc' symbol field in the + /// lowest 16 bits of the implementation defined flags. + enum MachOSymbolFlags { // See . SF_DescFlagsMask = 0xFFFF, // Reference type flags. -- cgit v1.1 From 5a42ae81f742aaab826b7a72cb0a9a7e5a957a07 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Fri, 25 Oct 2013 09:30:20 +0000 Subject: LegalizeDAG: allow libcalls for max/min atomic operations ARM processors without ldrex/strex need to be able to make libcalls for all atomic operations, including the newer min/max versions. The alternative would probably be expanding these operations in terms of cmpxchg (as x86 does always), but in the configurations where this matters code-size tends to be paramount so the libcall is more desirable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193398 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/RuntimeLibcalls.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/RuntimeLibcalls.h b/include/llvm/CodeGen/RuntimeLibcalls.h index d8c60df..37920ae 100644 --- a/include/llvm/CodeGen/RuntimeLibcalls.h +++ b/include/llvm/CodeGen/RuntimeLibcalls.h @@ -361,6 +361,26 @@ namespace RTLIB { SYNC_FETCH_AND_NAND_4, SYNC_FETCH_AND_NAND_8, SYNC_FETCH_AND_NAND_16, + SYNC_FETCH_AND_MAX_1, + SYNC_FETCH_AND_MAX_2, + SYNC_FETCH_AND_MAX_4, + SYNC_FETCH_AND_MAX_8, + SYNC_FETCH_AND_MAX_16, + SYNC_FETCH_AND_UMAX_1, + SYNC_FETCH_AND_UMAX_2, + SYNC_FETCH_AND_UMAX_4, + SYNC_FETCH_AND_UMAX_8, + SYNC_FETCH_AND_UMAX_16, + SYNC_FETCH_AND_MIN_1, + SYNC_FETCH_AND_MIN_2, + SYNC_FETCH_AND_MIN_4, + SYNC_FETCH_AND_MIN_8, + SYNC_FETCH_AND_MIN_16, + SYNC_FETCH_AND_UMIN_1, + SYNC_FETCH_AND_UMIN_2, + SYNC_FETCH_AND_UMIN_4, + SYNC_FETCH_AND_UMIN_8, + SYNC_FETCH_AND_UMIN_16, // Stack Protector Fail. STACKPROTECTOR_CHECK_FAIL, -- cgit v1.1 From c8f4e5db29270fc7ed164af973ece7ba5921539b Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Fri, 25 Oct 2013 12:49:50 +0000 Subject: ARM: allow .thumb_func to be separated from symbol definition When assembling, a .thumb_func directive is supposed to be applicable to the next symbol definition, even if there are intervening directives. We were racing ahead to try and find it, and this commit should fix the issue. Patch by Gabor Ballabas git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193403 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCTargetAsmParser.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCTargetAsmParser.h b/include/llvm/MC/MCTargetAsmParser.h index 6e96e8b..d132a73 100644 --- a/include/llvm/MC/MCTargetAsmParser.h +++ b/include/llvm/MC/MCTargetAsmParser.h @@ -181,6 +181,8 @@ public: MCContext &Ctx) { return 0; } + + virtual void onLabelParsed(MCSymbol *Symbol) { }; }; } // End llvm namespace -- cgit v1.1 From c7ef7c2de7f809f6407471048dd0302ebbc824ac Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 25 Oct 2013 12:59:02 +0000 Subject: Use c comments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193404 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/lto.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm-c/lto.h b/include/llvm-c/lto.h index 02105bc..a09db24 100644 --- a/include/llvm-c/lto.h +++ b/include/llvm-c/lto.h @@ -24,9 +24,9 @@ #include typedef bool lto_bool_t; #else -// MSVC in particular does not have anything like _Bool or bool in C, but we can -// at least make sure the type is the same size. The implementation side will -// use C++ bool. +/* MSVC in particular does not have anything like _Bool or bool in C, but we can + at least make sure the type is the same size. The implementation side will + use C++ bool. */ typedef unsigned char lto_bool_t; #endif #else -- cgit v1.1 From 6e1c511aba87ab5f9962ae9328014897459f777a Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 25 Oct 2013 15:01:34 +0000 Subject: Call destroy from ~BasicCallGraph. This fix a memory leak found by valgrind. Calling it from the base class destructor would not destroy the BasicCallGraph bits. FIXME: BasicCallGraph is the only thing that inherits from CallGraph. Can we merge the two? git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193412 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/CallGraph.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h index 591484d..926da76 100644 --- a/include/llvm/Analysis/CallGraph.h +++ b/include/llvm/Analysis/CallGraph.h @@ -152,7 +152,7 @@ protected: CallGraph() {} public: - virtual ~CallGraph() { destroy(); } + virtual ~CallGraph() { } /// initialize - Call this method before calling other methods, /// re/initializes the state of the CallGraph. -- cgit v1.1 From a954618c6e6c5f94d3cedc0b6bc19dbc49e56ac2 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Fri, 25 Oct 2013 18:38:43 +0000 Subject: DIEHash: Summary hashing of nested types git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193427 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index f3f4274..23bbd1c 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -141,6 +141,34 @@ enum Tag LLVM_ENUM_INT_TYPE(uint16_t) { DW_TAG_hi_user = 0xffff }; +inline bool isType(Tag T) { + switch (T) { + case DW_TAG_array_type: + case DW_TAG_class_type: + case DW_TAG_interface_type: + case DW_TAG_enumeration_type: + case DW_TAG_pointer_type: + case DW_TAG_reference_type: + case DW_TAG_rvalue_reference_type: + case DW_TAG_string_type: + case DW_TAG_structure_type: + case DW_TAG_subroutine_type: + case DW_TAG_union_type: + case DW_TAG_ptr_to_member_type: + case DW_TAG_set_type: + case DW_TAG_subrange_type: + case DW_TAG_base_type: + case DW_TAG_const_type: + case DW_TAG_file_type: + case DW_TAG_packed_type: + case DW_TAG_volatile_type: + case DW_TAG_typedef: + return true; + default: + return false; + } +} + enum Attribute LLVM_ENUM_INT_TYPE(uint16_t) { // Attributes DW_AT_sibling = 0x01, -- cgit v1.1 From 76a74f72534452b53ba3ba054bd8ab27efc48487 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 25 Oct 2013 19:06:52 +0000 Subject: Change MemoryBuffer::getFile to take a Twine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193429 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/MemoryBuffer.h | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/MemoryBuffer.h b/include/llvm/Support/MemoryBuffer.h index 4f28da4..ff22fb6 100644 --- a/include/llvm/Support/MemoryBuffer.h +++ b/include/llvm/Support/MemoryBuffer.h @@ -14,7 +14,7 @@ #ifndef LLVM_SUPPORT_MEMORYBUFFER_H #define LLVM_SUPPORT_MEMORYBUFFER_H -#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/Twine.h" #include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/DataTypes.h" @@ -66,11 +66,7 @@ public: /// MemoryBuffer if successful, otherwise returning null. If FileSize is /// specified, this means that the client knows that the file exists and that /// it has the specified size. - static error_code getFile(StringRef Filename, OwningPtr &result, - int64_t FileSize = -1, - bool RequiresNullTerminator = true); - static error_code getFile(const char *Filename, - OwningPtr &result, + static error_code getFile(Twine Filename, OwningPtr &result, int64_t FileSize = -1, bool RequiresNullTerminator = true); -- cgit v1.1 From 4d4bbaf997c16f9e79503bd640306d784efd090e Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Fri, 25 Oct 2013 21:35:56 +0000 Subject: Fix SCEVExpander: don't try to expand quadratic recurrences outside a loop. Partial fix for PR17459: wrong code at -O3 on x86_64-linux-gnu (affecting trunk and 3.3) When SCEV expands a recurrence outside of a loop it attempts to scale by the stride of the recurrence. Chained recurrences don't work that way. We could compute binomial coefficients, but would hve to guarantee that the chained AddRec's are in a perfectly reduced form. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193438 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/ScalarEvolutionExpander.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Analysis/ScalarEvolutionExpander.h b/include/llvm/Analysis/ScalarEvolutionExpander.h index 1e88bd5..4433be0 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpander.h +++ b/include/llvm/Analysis/ScalarEvolutionExpander.h @@ -26,7 +26,7 @@ namespace llvm { /// Return true if the given expression is safe to expand in the sense that /// all materialized values are safe to speculate. - bool isSafeToExpand(const SCEV *S); + bool isSafeToExpand(const SCEV *S, ScalarEvolution &SE); /// SCEVExpander - This class uses information about analyze scalars to /// rewrite expressions in canonical form. -- cgit v1.1 From 887f9c5ec15582aec34aa6c28955d01e4e9961e2 Mon Sep 17 00:00:00 2001 From: Wan Xiaofei Date: Sat, 26 Oct 2013 03:08:02 +0000 Subject: Quick look-up for block in loop. This patch implements quick look-up for block in loop by maintaining a hash set for blocks. It improves the efficiency of loop analysis a lot, the biggest improvement could be 5-6%(458.sjeng). Below are the compilation time for our benchmark in llc before & after the patch. Benchmark llc - trunk llc - patched 401.bzip2 0.339081 100.00% 0.329657 102.86% 403.gcc 19.853966 100.00% 19.605466 101.27% 429.mcf 0.049823 100.00% 0.048451 102.83% 433.milc 0.514898 100.00% 0.510217 100.92% 444.namd 1.109328 100.00% 1.103481 100.53% 445.gobmk 4.988028 100.00% 4.929114 101.20% 456.hmmer 0.843871 100.00% 0.825865 102.18% 458.sjeng 0.754238 100.00% 0.714095 105.62% 464.h264ref 2.9668 100.00% 2.90612 102.09% 471.omnetpp 4.556533 100.00% 4.511886 100.99% bitmnp01 0.038168 100.00% 0.0357 106.91% idctrn01 0.037745 100.00% 0.037332 101.11% libquake2 3.78689 100.00% 3.76209 100.66% libquake_ 2.251525 100.00% 2.234104 100.78% linpack 0.033159 100.00% 0.032788 101.13% matrix01 0.045319 100.00% 0.043497 104.19% nbench 0.333161 100.00% 0.329799 101.02% tblook01 0.017863 100.00% 0.017666 101.12% ttsprk01 0.054337 100.00% 0.053057 102.41% Reviewer : Andrew Trick , Hal Finkel Approver : Andrew Trick Test : Pass make check-all & llvm test-suite git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193460 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/LoopInfo.h | 18 ++++++++++++++-- include/llvm/Analysis/LoopInfoImpl.h | 41 +++++++++--------------------------- 2 files changed, 26 insertions(+), 33 deletions(-) (limited to 'include') diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 7b3eed7..62f5aca 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -69,6 +69,8 @@ class LoopBase { // Blocks - The list of blocks in this loop. First entry is the header node. std::vector Blocks; + SmallPtrSet DenseBlockSet; + LoopBase(const LoopBase &) LLVM_DELETED_FUNCTION; const LoopBase& operator=(const LoopBase &) LLVM_DELETED_FUNCTION; @@ -108,7 +110,7 @@ public: /// contains - Return true if the specified basic block is in this loop. /// bool contains(const BlockT *BB) const { - return std::find(block_begin(), block_end(), BB) != block_end(); + return DenseBlockSet.count(BB); } /// contains - Return true if the specified instruction is in this loop. @@ -134,7 +136,6 @@ public: /// getBlocks - Get a list of the basic blocks which make up this loop. /// const std::vector &getBlocks() const { return Blocks; } - std::vector &getBlocksVector() { return Blocks; } typedef typename std::vector::const_iterator block_iterator; block_iterator block_begin() const { return Blocks.begin(); } block_iterator block_end() const { return Blocks.end(); } @@ -271,6 +272,17 @@ public: /// transformations should use addBasicBlockToLoop. void addBlockEntry(BlockT *BB) { Blocks.push_back(BB); + DenseBlockSet.insert(BB); + } + + /// reverseBlocks - interface to reverse Blocks[from, end of loop] in this loop + void reverseBlock(unsigned from) { + std::reverse(Blocks.begin() + from, Blocks.end()); + } + + /// reserveBlocks- interface to do reserve() for Blocks + void reserveBlocks(unsigned size) { + Blocks.reserve(size); } /// moveToHeader - This method is used to move BB (which must be part of this @@ -293,6 +305,7 @@ public: /// the mapping in the LoopInfo class. void removeBlockFromLoop(BlockT *BB) { RemoveFromVector(Blocks, BB); + DenseBlockSet.erase(BB); } /// verifyLoop - Verify loop structure @@ -307,6 +320,7 @@ protected: friend class LoopInfoBase; explicit LoopBase(BlockT *BB) : ParentLoop(0) { Blocks.push_back(BB); + DenseBlockSet.insert(BB); } }; diff --git a/include/llvm/Analysis/LoopInfoImpl.h b/include/llvm/Analysis/LoopInfoImpl.h index 5485f3c..c98cb58 100644 --- a/include/llvm/Analysis/LoopInfoImpl.h +++ b/include/llvm/Analysis/LoopInfoImpl.h @@ -31,17 +31,12 @@ namespace llvm { template void LoopBase:: getExitingBlocks(SmallVectorImpl &ExitingBlocks) const { - // Sort the blocks vector so that we can use binary search to do quick - // lookups. - SmallVector LoopBBs(block_begin(), block_end()); - std::sort(LoopBBs.begin(), LoopBBs.end()); - typedef GraphTraits BlockTraits; for (block_iterator BI = block_begin(), BE = block_end(); BI != BE; ++BI) for (typename BlockTraits::ChildIteratorType I = BlockTraits::child_begin(*BI), E = BlockTraits::child_end(*BI); I != E; ++I) - if (!std::binary_search(LoopBBs.begin(), LoopBBs.end(), *I)) { + if (!contains(*I)) { // Not in current loop? It must be an exit block. ExitingBlocks.push_back(*BI); break; @@ -65,17 +60,12 @@ BlockT *LoopBase::getExitingBlock() const { template void LoopBase:: getExitBlocks(SmallVectorImpl &ExitBlocks) const { - // Sort the blocks vector so that we can use binary search to do quick - // lookups. - SmallVector LoopBBs(block_begin(), block_end()); - std::sort(LoopBBs.begin(), LoopBBs.end()); - typedef GraphTraits BlockTraits; for (block_iterator BI = block_begin(), BE = block_end(); BI != BE; ++BI) for (typename BlockTraits::ChildIteratorType I = BlockTraits::child_begin(*BI), E = BlockTraits::child_end(*BI); I != E; ++I) - if (!std::binary_search(LoopBBs.begin(), LoopBBs.end(), *I)) + if (!contains(*I)) // Not in current loop? It must be an exit block. ExitBlocks.push_back(*I); } @@ -95,17 +85,12 @@ BlockT *LoopBase::getExitBlock() const { template void LoopBase:: getExitEdges(SmallVectorImpl &ExitEdges) const { - // Sort the blocks vector so that we can use binary search to do quick - // lookups. - SmallVector LoopBBs(block_begin(), block_end()); - array_pod_sort(LoopBBs.begin(), LoopBBs.end()); - typedef GraphTraits BlockTraits; for (block_iterator BI = block_begin(), BE = block_end(); BI != BE; ++BI) for (typename BlockTraits::ChildIteratorType I = BlockTraits::child_begin(*BI), E = BlockTraits::child_end(*BI); I != E; ++I) - if (!std::binary_search(LoopBBs.begin(), LoopBBs.end(), *I)) + if (!contains(*I)) // Not in current loop? It must be an exit block. ExitEdges.push_back(Edge(*BI, *I)); } @@ -210,7 +195,7 @@ addBasicBlockToLoop(BlockT *NewBB, LoopInfoBase &LIB) { // Add the basic block to this loop and all parent loops... while (L) { - L->Blocks.push_back(NewBB); + L->addBlockEntry(NewBB); L = L->getParentLoop(); } } @@ -250,11 +235,6 @@ void LoopBase::verifyLoop() const { // Keep track of the number of BBs visited. unsigned NumVisited = 0; - // Sort the blocks vector so that we can use binary search to do quick - // lookups. - SmallVector LoopBBs(block_begin(), block_end()); - std::sort(LoopBBs.begin(), LoopBBs.end()); - // Check the individual blocks. for ( ; BI != BE; ++BI) { BlockT *BB = *BI; @@ -266,7 +246,7 @@ void LoopBase::verifyLoop() const { for (typename BlockTraits::ChildIteratorType SI = BlockTraits::child_begin(BB), SE = BlockTraits::child_end(BB); SI != SE; ++SI) - if (std::binary_search(LoopBBs.begin(), LoopBBs.end(), *SI)) { + if (contains(*SI)) { HasInsideLoopSuccs = true; break; } @@ -275,7 +255,7 @@ void LoopBase::verifyLoop() const { InvBlockTraits::child_begin(BB), PE = InvBlockTraits::child_end(BB); PI != PE; ++PI) { BlockT *N = *PI; - if (std::binary_search(LoopBBs.begin(), LoopBBs.end(), N)) + if (contains(N)) HasInsideLoopPreds = true; else OutsideLoopPreds.push_back(N); @@ -309,7 +289,7 @@ void LoopBase::verifyLoop() const { // Each block in each subloop should be contained within this loop. for (block_iterator BI = (*I)->block_begin(), BE = (*I)->block_end(); BI != BE; ++BI) { - assert(std::binary_search(LoopBBs.begin(), LoopBBs.end(), *BI) && + assert(contains(*BI) && "Loop does not contain all the blocks of a subloop!"); } @@ -418,7 +398,7 @@ static void discoverAndMapSubloop(LoopT *L, ArrayRef Backedges, } } L->getSubLoopsVector().reserve(NumSubloops); - L->getBlocksVector().reserve(NumBlocks); + L->reserveBlocks(NumBlocks); } namespace { @@ -489,15 +469,14 @@ void PopulateLoopsDFS::insertIntoLoop(BlockT *Block) { // For convenience, Blocks and Subloops are inserted in postorder. Reverse // the lists, except for the loop header, which is always at the beginning. - std::reverse(Subloop->getBlocksVector().begin()+1, - Subloop->getBlocksVector().end()); + Subloop->reverseBlock(1); std::reverse(Subloop->getSubLoopsVector().begin(), Subloop->getSubLoopsVector().end()); Subloop = Subloop->getParentLoop(); } for (; Subloop; Subloop = Subloop->getParentLoop()) - Subloop->getBlocksVector().push_back(Block); + Subloop->addBlockEntry(Block); } /// Analyze LoopInfo discovers loops during a postorder DominatorTree traversal -- cgit v1.1 From 69bd41dfe33f24414be281ba5e2204b7348c33ae Mon Sep 17 00:00:00 2001 From: Shuxin Yang Date: Sun, 27 Oct 2013 03:08:44 +0000 Subject: Revert r193251 : Use address-taken to disambiguate global variable and indirect memops. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193489 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/GlobalVariable.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/GlobalVariable.h b/include/llvm/IR/GlobalVariable.h index a5ab97d..bfed507 100644 --- a/include/llvm/IR/GlobalVariable.h +++ b/include/llvm/IR/GlobalVariable.h @@ -48,7 +48,6 @@ class GlobalVariable : public GlobalValue, public ilist_node { // can change from its initial // value before global // initializers are run? - bool notAddrTaken : 1; // Dose not have address taken. public: // allocate space for exactly one operand @@ -175,9 +174,6 @@ public: isExternallyInitializedConstant = Val; } - void setAddressMaybeTaken(bool Val) { notAddrTaken = !Val; } - bool AddressMaybeTaken(void) const { return !notAddrTaken; } - /// copyAttributesFrom - copy all additional attributes (those not needed to /// create a GlobalVariable) from the GlobalVariable Src to this one. void copyAttributesFrom(const GlobalValue *Src); -- cgit v1.1 From 62d66cbec5b2d4e00e86457762df0127ae234e6f Mon Sep 17 00:00:00 2001 From: Elena Demikhovsky Date: Sun, 27 Oct 2013 08:18:37 +0000 Subject: AVX-512: PMIN/PMAX intrinsics and patterns Patch by Cameron McInally git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193497 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index 537089d..e39eea8 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -2719,6 +2719,32 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx512_max_pd_512 : GCCBuiltin<"__builtin_ia32_maxpd512">, Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_v8f64_ty], [IntrNoMem]>; + + def int_x86_avx512_pmaxu_d : GCCBuiltin<"__builtin_ia32_pmaxud512">, + Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, + llvm_v16i32_ty], [IntrNoMem]>; + def int_x86_avx512_pmaxu_q : GCCBuiltin<"__builtin_ia32_pmaxuq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, + llvm_v8i64_ty], [IntrNoMem]>; + def int_x86_avx512_pmaxs_d : GCCBuiltin<"__builtin_ia32_pmaxsd512">, + Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, + llvm_v16i32_ty], [IntrNoMem]>; + def int_x86_avx512_pmaxs_q : GCCBuiltin<"__builtin_ia32_pmaxsq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, + llvm_v8i64_ty], [IntrNoMem]>; + + def int_x86_avx512_pminu_d : GCCBuiltin<"__builtin_ia32_pminud512">, + Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, + llvm_v16i32_ty], [IntrNoMem]>; + def int_x86_avx512_pminu_q : GCCBuiltin<"__builtin_ia32_pminuq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, + llvm_v8i64_ty], [IntrNoMem]>; + def int_x86_avx512_pmins_d : GCCBuiltin<"__builtin_ia32_pminsd512">, + Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, + llvm_v16i32_ty], [IntrNoMem]>; + def int_x86_avx512_pmins_q : GCCBuiltin<"__builtin_ia32_pminsq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, + llvm_v8i64_ty], [IntrNoMem]>; } let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". -- cgit v1.1 From 66589dcc8fb5dcf0894a9a80a8dee890a4f3a379 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Mon, 28 Oct 2013 11:17:59 +0000 Subject: Keep TBAA info when rewriting SelectionDAG loads and stores Most SelectionDAG code drops the TBAA info when creating a new form of a load and store (e.g. during legalization, or when converting a plain load to an extending one). This patch tries to catch all cases where the TBAA information can legitimately be carried over. The patch adds alternative forms of getLoad() and getExtLoad() that take a MachineMemOperand instead of individual fields. (The corresponding getTruncStore() already exists.) The idea is to use the MachineMemOperand forms when all fields are carried over (size, pointer info, isVolatile, isNonTemporal, alignment and TBAA info). If some adjustment is being made, e.g. to narrow the load, then we still pass the individual fields but also pass the TBAA info. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193517 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/SelectionDAG.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index 1615e4b..3f27bce 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -754,11 +754,16 @@ public: MachinePointerInfo PtrInfo, bool isVolatile, bool isNonTemporal, bool isInvariant, unsigned Alignment, const MDNode *TBAAInfo = 0, const MDNode *Ranges = 0); + SDValue getLoad(EVT VT, SDLoc dl, SDValue Chain, SDValue Ptr, + MachineMemOperand *MMO); SDValue getExtLoad(ISD::LoadExtType ExtType, SDLoc dl, EVT VT, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, bool isVolatile, bool isNonTemporal, unsigned Alignment, const MDNode *TBAAInfo = 0); + SDValue getExtLoad(ISD::LoadExtType ExtType, SDLoc dl, EVT VT, + SDValue Chain, SDValue Ptr, EVT MemVT, + MachineMemOperand *MMO); SDValue getIndexedLoad(SDValue OrigLoad, SDLoc dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM); SDValue getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, -- cgit v1.1 From 23125d02d929758e1b0dbb30b13f1deff7a5ea4b Mon Sep 17 00:00:00 2001 From: Logan Chien Date: Mon, 28 Oct 2013 17:51:12 +0000 Subject: [arm] Implement eabi_attribute, cpu, and fpu directives. This commit allows the ARM integrated assembler to parse and assemble the code with .eabi_attribute, .cpu, and .fpu directives. To implement the feature, this commit moves the code from AttrEmitter to ARMTargetStreamers, and several new test cases related to cortex-m4, cortex-r5, and cortex-a15 are added. Besides, this commit also change the Subtarget->isFPOnlySP() to Subtarget->hasD16() to match the usage of .fpu directive. This commit changes the test cases: * Several .eabi_attribute directives in 2010-09-29-mc-asm-header-test.ll are removed because the .fpu directive already cover the functionality. * In the Cortex-A15 test case, the value for Tag_Advanced_SIMD_arch has be changed from 1 to 2, which is more precise. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193524 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCStreamer.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 47d798d..04af407 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -87,6 +87,12 @@ public: virtual void emitPad(int64_t Offset) = 0; virtual void emitRegSave(const SmallVectorImpl &RegList, bool isVector) = 0; + + virtual void switchVendor(StringRef Vendor) = 0; + virtual void emitAttribute(unsigned Attribute, unsigned Value) = 0; + virtual void emitTextAttribute(unsigned Attribute, StringRef String) = 0; + virtual void emitFPU(unsigned FPU) = 0; + virtual void finishAttributeSection() = 0; }; /// MCStreamer - Streaming machine code generation interface. This interface -- cgit v1.1 From c5253237f8b3b4eb888f7f85f39acd7d4d0f57cf Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Mon, 28 Oct 2013 23:01:48 +0000 Subject: DebugInfo: Introduce the notion of "form classes" Summary: Use DWARF4 table of form classes to fetch attributes from DIE in a more consistent way. This shouldn't change the functionality and serves as a refactoring for upcoming change: DW_AT_high_pc has different semantics depending on its form class. Reviewers: dblaikie, echristo Reviewed By: echristo CC: echristo, llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1961 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193553 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo/DWARFFormValue.h | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo/DWARFFormValue.h b/include/llvm/DebugInfo/DWARFFormValue.h index c8d6008..a9d1ec0 100644 --- a/include/llvm/DebugInfo/DWARFFormValue.h +++ b/include/llvm/DebugInfo/DWARFFormValue.h @@ -10,6 +10,7 @@ #ifndef LLVM_DEBUGINFO_DWARFFORMVALUE_H #define LLVM_DEBUGINFO_DWARFFORMVALUE_H +#include "llvm/ADT/Optional.h" #include "llvm/Support/DataExtractor.h" namespace llvm { @@ -18,6 +19,21 @@ class DWARFUnit; class raw_ostream; class DWARFFormValue { +public: + enum FormClass { + FC_Unknown, + FC_Address, + FC_Block, + FC_Constant, + FC_String, + FC_Flag, + FC_Reference, + FC_Indirect, + FC_SectionOffset, + FC_Exprloc + }; + +private: struct ValueType { ValueType() : data(NULL) { uval = 0; @@ -35,9 +51,10 @@ class DWARFFormValue { ValueType Value; // Contains all data for the form. public: - DWARFFormValue(uint16_t form = 0) : Form(form) {} + DWARFFormValue(uint16_t Form = 0) : Form(Form) {} uint16_t getForm() const { return Form; } - const ValueType& value() const { return Value; } + bool isFormClass(FormClass FC) const; + void dump(raw_ostream &OS, const DWARFUnit *U) const; bool extractValue(DataExtractor data, uint32_t *offset_ptr, const DWARFUnit *u); @@ -45,11 +62,13 @@ public: return Value.data != NULL && Value.data == (const uint8_t*)Value.cstr; } - uint64_t getReference(const DWARFUnit *U) const; - uint64_t getUnsigned() const { return Value.uval; } - int64_t getSigned() const { return Value.sval; } - const char *getAsCString(const DWARFUnit *U) const; - uint64_t getAsAddress(const DWARFUnit *U) const; + /// getAsFoo functions below return the extracted value as Foo if only + /// DWARFFormValue has form class is suitable for representing Foo. + Optional getAsReference(const DWARFUnit *U) const; + Optional getAsUnsignedConstant() const; + Optional getAsCString(const DWARFUnit *U) const; + Optional getAsAddress(const DWARFUnit *U) const; + Optional getAsSectionOffset() const; bool skipValue(DataExtractor debug_info_data, uint32_t *offset_ptr, const DWARFUnit *u) const; -- cgit v1.1 From 6faff4886a3059a8cda08f015d29a6c9a0a4de3c Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Mon, 28 Oct 2013 23:41:49 +0000 Subject: DWARF parser: Use ArrayRef to represent form sizes and simplify DWARFDIE::extractFast() interface. No functionality change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193560 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo/DWARFFormValue.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/DebugInfo/DWARFFormValue.h b/include/llvm/DebugInfo/DWARFFormValue.h index a9d1ec0..533d259 100644 --- a/include/llvm/DebugInfo/DWARFFormValue.h +++ b/include/llvm/DebugInfo/DWARFFormValue.h @@ -10,6 +10,7 @@ #ifndef LLVM_DEBUGINFO_DWARFFORMVALUE_H #define LLVM_DEBUGINFO_DWARFFORMVALUE_H +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/Support/DataExtractor.h" @@ -75,7 +76,8 @@ public: static bool skipValue(uint16_t form, DataExtractor debug_info_data, uint32_t *offset_ptr, const DWARFUnit *u); - static const uint8_t *getFixedFormSizes(uint8_t AddrSize, uint16_t Version); + static ArrayRef getFixedFormSizes(uint8_t AddrSize, + uint16_t Version); }; } -- cgit v1.1 From 72580780a98cb8b0019b7ec4ed88e3f3328b9969 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Tue, 29 Oct 2013 01:06:17 +0000 Subject: Move the STT_FILE symbols out of the normal symbol table processing for ELF. They can overlap with the other symbols, e.g. if a source file "foo.c" contains a function "foo" with a static variable "c". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193569 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAssembler.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCAssembler.h b/include/llvm/MC/MCAssembler.h index 38a70f0..8735a55 100644 --- a/include/llvm/MC/MCAssembler.h +++ b/include/llvm/MC/MCAssembler.h @@ -19,6 +19,7 @@ #include "llvm/MC/MCInst.h" #include "llvm/Support/Casting.h" #include "llvm/Support/DataTypes.h" +#include #include // FIXME: Shouldn't be needed. namespace llvm { @@ -816,6 +817,9 @@ public: typedef SymbolDataListType::const_iterator const_symbol_iterator; typedef SymbolDataListType::iterator symbol_iterator; + typedef std::vector FileNameVectorType; + typedef FileNameVectorType::const_iterator const_file_name_iterator; + typedef std::vector::const_iterator const_indirect_symbol_iterator; typedef std::vector::iterator indirect_symbol_iterator; @@ -859,6 +863,9 @@ private: /// The list of linker options to propagate into the object file. std::vector > LinkerOptions; + /// List of declared file names + FileNameVectorType FileNames; + /// The set of function symbols for which a .thumb_func directive has /// been seen. // @@ -1152,6 +1159,20 @@ public: return *Entry; } + const_file_name_iterator file_names_begin() const { + return FileNames.begin(); + } + + const_file_name_iterator file_names_end() const { + return FileNames.end(); + } + + void addFileName(StringRef FileName) { + if (std::find(file_names_begin(), file_names_end(), FileName) == + file_names_end()) + FileNames.push_back(FileName); + } + /// @} void dump(); -- cgit v1.1 From 18a988e3a76eb0f8783d115618e48466854f5901 Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Tue, 29 Oct 2013 02:35:28 +0000 Subject: Fix "existant" typos git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193579 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h b/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h index 54506cf..933c85c 100644 --- a/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h +++ b/include/llvm/Transforms/Utils/UnifyFunctionExitNodes.h @@ -34,7 +34,7 @@ public: // We can preserve non-critical-edgeness when we unify function exit nodes virtual void getAnalysisUsage(AnalysisUsage &AU) const; - // getReturn|Unwind|UnreachableBlock - Return the new single (or nonexistant) + // getReturn|Unwind|UnreachableBlock - Return the new single (or nonexistent) // return, unwind, or unreachable basic blocks in the CFG. // BasicBlock *getReturnBlock() const { return ReturnBlock; } -- cgit v1.1 From 7959f209ba8e63ffaf7335842deddda4ca0480e7 Mon Sep 17 00:00:00 2001 From: Anders Waldenborg Date: Tue, 29 Oct 2013 09:02:02 +0000 Subject: llvm-c: Make LLVM{Get,Set}Alignment work on {Load,Store}Inst too Patch by Peter Zotov Differential Revision: http://llvm-reviews.chandlerc.com/D1910 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193597 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index b9bae7e..004492b 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -1665,8 +1665,33 @@ const char *LLVMGetSection(LLVMValueRef Global); void LLVMSetSection(LLVMValueRef Global, const char *Section); LLVMVisibility LLVMGetVisibility(LLVMValueRef Global); void LLVMSetVisibility(LLVMValueRef Global, LLVMVisibility Viz); -unsigned LLVMGetAlignment(LLVMValueRef Global); -void LLVMSetAlignment(LLVMValueRef Global, unsigned Bytes); + +/** + * @defgroup LLVMCCoreValueWithAlignment Values with alignment + * + * Functions in this group only apply to values with alignment, i.e. + * global variables, load and store instructions. + */ + +/** + * Obtain the preferred alignment of the value. + * @see llvm::LoadInst::getAlignment() + * @see llvm::StoreInst::getAlignment() + * @see llvm::GlobalValue::getAlignment() + */ +unsigned LLVMGetAlignment(LLVMValueRef V); + +/** + * Set the preferred alignment of the value. + * @see llvm::LoadInst::setAlignment() + * @see llvm::StoreInst::setAlignment() + * @see llvm::GlobalValue::setAlignment() + */ +void LLVMSetAlignment(LLVMValueRef V, unsigned Bytes); + +/** + * @} + */ /** * @defgroup LLVMCoreValueConstantGlobalVariable Global Variables -- cgit v1.1 From 1313a223ed2e8d41b6a13d3738123042b5573b88 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 29 Oct 2013 13:44:11 +0000 Subject: Clarify that GlobalVariables definitions must have an initializer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193609 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/GlobalVariable.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/GlobalVariable.h b/include/llvm/IR/GlobalVariable.h index bfed507..660092d 100644 --- a/include/llvm/IR/GlobalVariable.h +++ b/include/llvm/IR/GlobalVariable.h @@ -84,9 +84,7 @@ public: /// Provide fast operand accessors DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value); - /// hasInitializer - Unless a global variable isExternal(), it has an - /// initializer. The initializer for the global variable/constant is held by - /// Initializer if an initializer is specified. + /// Definitions have initializers, declarations don't. /// inline bool hasInitializer() const { return !isDeclaration(); } -- cgit v1.1 From 1aaf43c2a2ec0fd4c8dbfe56558237219c5f8af7 Mon Sep 17 00:00:00 2001 From: Zoran Jovanovic Date: Tue, 29 Oct 2013 16:38:59 +0000 Subject: Support for microMIPS jump instructions git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193623 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/ELF.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/Support/ELF.h b/include/llvm/Support/ELF.h index ca53f55..ae3b1d3 100644 --- a/include/llvm/Support/ELF.h +++ b/include/llvm/Support/ELF.h @@ -881,6 +881,7 @@ enum { R_MIPS_GLOB_DAT = 51, 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, -- cgit v1.1 From ffc7dca885151ed42642c2d6733e8db75d276621 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 29 Oct 2013 17:07:16 +0000 Subject: Add a helper getSymbol to AsmPrinter. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193627 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/AsmPrinter.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h index 3dfde20..d66665c 100644 --- a/include/llvm/CodeGen/AsmPrinter.h +++ b/include/llvm/CodeGen/AsmPrinter.h @@ -145,6 +145,7 @@ namespace llvm { /// getCurrentSection() - Return the current section we are emitting to. const MCSection *getCurrentSection() const; + MCSymbol *getSymbol(const GlobalValue *GV) const; //===------------------------------------------------------------------===// // MachineFunctionPass Implementation. -- cgit v1.1 From 93cf0939f95b3d580d9c05375a7c84164e1ba72e Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 29 Oct 2013 17:28:26 +0000 Subject: Move getSymbol to TargetLoweringObjectFile. This allows constructing a Mangler with just a TargetMachine. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193630 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/Mangler.h | 9 +-------- include/llvm/Target/TargetLoweringObjectFile.h | 4 ++++ 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/llvm/Target/Mangler.h b/include/llvm/Target/Mangler.h index e925cd5..eee7bf6 100644 --- a/include/llvm/Target/Mangler.h +++ b/include/llvm/Target/Mangler.h @@ -20,7 +20,6 @@ namespace llvm { class GlobalValue; class MCContext; -class MCSymbol; template class SmallVectorImpl; class TargetMachine; class Twine; @@ -34,7 +33,6 @@ public: }; private: - MCContext &Context; const TargetMachine *TM; /// AnonGlobalIDs - We need to give global values the same name every time @@ -48,12 +46,7 @@ private: unsigned NextAnonGlobalID; public: - Mangler(MCContext &Context, const TargetMachine *TM) - : Context(Context), TM(TM), NextAnonGlobalID(1) {} - - /// getSymbol - Return the MCSymbol for the specified global value. This - /// symbol is the main label that is the address of the global. - MCSymbol *getSymbol(const GlobalValue *GV); + Mangler(const TargetMachine *TM) : TM(TM), NextAnonGlobalID(1) {} /// getNameWithPrefix - Fill OutName with the name of the appropriate prefix /// and the specified global variable's name. If the global variable doesn't diff --git a/include/llvm/Target/TargetLoweringObjectFile.h b/include/llvm/Target/TargetLoweringObjectFile.h index 7f15b74..284b6bb 100644 --- a/include/llvm/Target/TargetLoweringObjectFile.h +++ b/include/llvm/Target/TargetLoweringObjectFile.h @@ -117,6 +117,10 @@ public: MachineModuleInfo *MMI, unsigned Encoding, MCStreamer &Streamer) const; + /// Return the MCSymbol for the specified global value. This symbol is the + /// main label that is the address of the global + MCSymbol *getSymbol(Mangler &M, const GlobalValue *GV) const; + // getCFIPersonalitySymbol - The symbol that gets passed to .cfi_personality. virtual MCSymbol * getCFIPersonalitySymbol(const GlobalValue *GV, Mangler *Mang, -- cgit v1.1 From 8b1d5e20528617b9f026c97714e74b8f7252f343 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 29 Oct 2013 18:31:14 +0000 Subject: Remove declared but not implemented function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193637 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/FileSystem.h | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/FileSystem.h b/include/llvm/Support/FileSystem.h index 6baaeb8..48ff224 100644 --- a/include/llvm/Support/FileSystem.h +++ b/include/llvm/Support/FileSystem.h @@ -639,17 +639,6 @@ error_code openFileForWrite(const Twine &Name, int &ResultFD, OpenFlags Flags, error_code openFileForRead(const Twine &Name, int &ResultFD); -/// @brief Canonicalize path. -/// -/// Sets result to the file system's idea of what path is. The result is always -/// absolute and has the same capitalization as the file system. -/// -/// @param path Input path. -/// @param result Set to the canonicalized version of \a path. -/// @returns errc::success if result has been successfully set, otherwise a -/// platform specific error_code. -error_code canonicalize(const Twine &path, SmallVectorImpl &result); - /// @brief Are \a path's first bytes \a magic? /// /// @param path Input path. -- cgit v1.1 From 2b0002b579dba5604a2673bbee2cd9969e183a71 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Tue, 29 Oct 2013 20:59:29 +0000 Subject: Workaround MSVC 32-bit miscompile of getCondCodeAction. Use 32-bit types for the array instead of 64. This should generally be better anyway. In optimized + assert builds, I saw a failure when a cond code / type combination that is never set was loading a non-zero value and hitting the != Promote assert. It turns out when loading the 64-bit value to do the shift, the assembly loads the 2 32-bit halves from non-consecutive addresses. The address the second half of the loaded uint64_t doesn't include the offset of the array in the struct. Instead of being offset + 4, it's just + 4. I'm not entirely sure why this wasn't observed before. setCondCodeAction isn't heavily used by the in-tree targets, and not with the higher valued vector SimpleValueTypes. Only PPC is using one of the > 32 valued types, and that is probably never used by anyone on a 32-bit MSVC compiled host. I ran into this when upgrading LLVM versions, so I guess the value loaded from the nonsense address happened to work out before. No test since I'm not really sure if / how it can be reproduced with the current in tree targets, and it's not supposed to change anything. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193650 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLowering.h | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 3cde173..5b9e377 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -520,13 +520,12 @@ public: LegalizeAction getCondCodeAction(ISD::CondCode CC, MVT VT) const { assert((unsigned)CC < array_lengthof(CondCodeActions) && - (unsigned)VT.SimpleTy < sizeof(CondCodeActions[0])*4 && + ((unsigned)VT.SimpleTy >> 4) < array_lengthof(CondCodeActions[0]) && "Table isn't big enough!"); - /// The lower 5 bits of the SimpleTy index into Nth 2bit set from the 64bit - /// value and the upper 27 bits index into the second dimension of the - /// array to select what 64bit value to use. - LegalizeAction Action = (LegalizeAction) - ((CondCodeActions[CC][VT.SimpleTy >> 5] >> (2*(VT.SimpleTy & 0x1F))) & 3); + // See setCondCodeAction for how this is encoded. + uint32_t Shift = 2 * (VT.SimpleTy & 0xF); + uint32_t Value = CondCodeActions[CC][VT.SimpleTy >> 4]; + LegalizeAction Action = (LegalizeAction) ((Value >> Shift) & 0x3); assert(Action != Promote && "Can't promote condition code!"); return Action; } @@ -1020,13 +1019,12 @@ protected: assert(VT < MVT::LAST_VALUETYPE && (unsigned)CC < array_lengthof(CondCodeActions) && "Table isn't big enough!"); - /// The lower 5 bits of the SimpleTy index into Nth 2bit set from the 64bit - /// value and the upper 27 bits index into the second dimension of the - /// array to select what 64bit value to use. - CondCodeActions[(unsigned)CC][VT.SimpleTy >> 5] - &= ~(uint64_t(3UL) << (VT.SimpleTy & 0x1F)*2); - CondCodeActions[(unsigned)CC][VT.SimpleTy >> 5] - |= (uint64_t)Action << (VT.SimpleTy & 0x1F)*2; + /// The lower 5 bits of the SimpleTy index into Nth 2bit set from the 32-bit + /// value and the upper 27 bits index into the second dimension of the array + /// to select what 32-bit value to use. + uint32_t Shift = 2 * (VT.SimpleTy & 0xF); + CondCodeActions[CC][VT.SimpleTy >> 4] &= ~((uint32_t)0x3 << Shift); + CondCodeActions[CC][VT.SimpleTy >> 4] |= (uint32_t)Action << Shift; } /// If Opc/OrigVT is specified as being promoted, the promotion code defaults @@ -1448,8 +1446,8 @@ private: /// /// Because each CC action takes up 2 bits, we need to have the array size be /// large enough to fit all of the value types. This can be done by dividing - /// the MVT::LAST_VALUETYPE by 32 and adding one. - uint64_t CondCodeActions[ISD::SETCC_INVALID][(MVT::LAST_VALUETYPE / 32) + 1]; + /// the MVT::LAST_VALUETYPE by 16 and adding one. + uint32_t CondCodeActions[ISD::SETCC_INVALID][(MVT::LAST_VALUETYPE + 15) / 16]; ValueTypeActionImpl ValueTypeActions; -- cgit v1.1 From f7c6da6fe8ba43205d2a1fb1152720bd72e7ea23 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Tue, 29 Oct 2013 21:04:19 +0000 Subject: Update comment git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193651 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLowering.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 5b9e377..01b579b 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -1445,8 +1445,8 @@ private: /// indicates how instruction selection should deal with the condition code. /// /// Because each CC action takes up 2 bits, we need to have the array size be - /// large enough to fit all of the value types. This can be done by dividing - /// the MVT::LAST_VALUETYPE by 16 and adding one. + /// large enough to fit all of the value types. This can be done by rounding + /// up the MVT::LAST_VALUETYPE value to the next multiple of 16. uint32_t CondCodeActions[ISD::SETCC_INVALID][(MVT::LAST_VALUETYPE + 15) / 16]; ValueTypeActionImpl ValueTypeActions; -- cgit v1.1 From 4598b40ce62dceb5ff96bbb7caeebd1ca57ae3fe Mon Sep 17 00:00:00 2001 From: Josh Magee Date: Tue, 29 Oct 2013 21:16:16 +0000 Subject: [stackprotector] Update the StackProtector pass to perform datalayout analysis. This modifies the pass to classify every SSP-triggering AllocaInst according to an SSPLayoutKind (LargeArray, SmallArray, AddrOf). This analysis is collected by the pass and made available for use, but no other pass uses it yet. The next patch will make use of this analysis in PEI and StackSlot passes. The end goal is to support ssp-strong stack layout rules. WIP. Differential Revision: http://llvm-reviews.chandlerc.com/D1789 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193653 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/StackProtector.h | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/StackProtector.h b/include/llvm/CodeGen/StackProtector.h index d23a9d0..63cf942 100644 --- a/include/llvm/CodeGen/StackProtector.h +++ b/include/llvm/CodeGen/StackProtector.h @@ -19,6 +19,7 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/Triple.h" +#include "llvm/ADT/ValueMap.h" #include "llvm/Pass.h" #include "llvm/Target/TargetLowering.h" @@ -29,6 +30,24 @@ class Module; class PHINode; class StackProtector : public FunctionPass { +public: + /// SSPLayoutKind. Stack Smashing Protection (SSP) rules require that + /// vulnerable stack allocations are located close the stack protector. + enum SSPLayoutKind { + SSPLK_None, //< Did not trigger a stack protector. No effect on data + //< layout. + SSPLK_LargeArray, //< Array or nested array >= SSP-buffer-size. Closest + //< to the stack protector. + SSPLK_SmallArray, //< Array or nested array < SSP-buffer-size. 2nd closest + //< to the stack protector. + SSPLK_AddrOf //< The address of this allocation is exposed and + //< triggered protection. 3rd closest to the protector. + }; + + /// A mapping of AllocaInsts to their required SSP layout. + typedef ValueMap SSPLayoutMap; + +private: const TargetMachine *TM; /// TLI - Keep a pointer of a TargetLowering to consult for determining @@ -41,6 +60,11 @@ class StackProtector : public FunctionPass { DominatorTree *DT; + /// Layout - Mapping of allocations to the required SSPLayoutKind. + /// StackProtector analysis will update this map when determining if an + /// AllocaInst triggers a stack protector. + SSPLayoutMap Layout; + /// \brief The minimum size of buffers that will receive stack smashing /// protection when -fstack-protection is used. unsigned SSPBufferSize; @@ -66,7 +90,10 @@ class StackProtector : public FunctionPass { /// ContainsProtectableArray - Check whether the type either is an array or /// contains an array of sufficient size so that we need stack protectors /// for it. - bool ContainsProtectableArray(Type *Ty, bool Strong = false, + /// \param [out] IsLarge is set to true if a protectable array is found and + /// it is "large" ( >= ssp-buffer-size). In the case of a structure with + /// multiple arrays, this gets set if any of them is large. + bool ContainsProtectableArray(Type *Ty, bool &IsLarge, bool Strong = false, bool InStruct = false) const; /// \brief Check whether a stack allocation has its address taken. @@ -90,6 +117,8 @@ public: AU.addPreserved(); } + SSPLayoutKind getSSPLayout(const AllocaInst *AI) const; + virtual bool runOnFunction(Function &Fn); }; } // end namespace llvm -- cgit v1.1 From ec4b5398c93a855da292589242d7369adc0a54a4 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 30 Oct 2013 00:49:33 +0000 Subject: Trailing whitespace in a comment line. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193668 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/StackProtector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/StackProtector.h b/include/llvm/CodeGen/StackProtector.h index 63cf942..5d0d6b9 100644 --- a/include/llvm/CodeGen/StackProtector.h +++ b/include/llvm/CodeGen/StackProtector.h @@ -31,7 +31,7 @@ class PHINode; class StackProtector : public FunctionPass { public: - /// SSPLayoutKind. Stack Smashing Protection (SSP) rules require that + /// SSPLayoutKind. Stack Smashing Protection (SSP) rules require that /// vulnerable stack allocations are located close the stack protector. enum SSPLayoutKind { SSPLK_None, //< Did not trigger a stack protector. No effect on data -- cgit v1.1 From 9794186889189efaee69a127123fffd26c834fa4 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Wed, 30 Oct 2013 00:49:39 +0000 Subject: StackProtector.h: Fix trailing comments for doxygen. [-Wdocumentation] s!//= SSP-buffer-size. Closest - //< to the stack protector. - SSPLK_SmallArray, //< Array or nested array < SSP-buffer-size. 2nd closest - //< to the stack protector. - SSPLK_AddrOf //< The address of this allocation is exposed and - //< triggered protection. 3rd closest to the protector. + SSPLK_None, ///< Did not trigger a stack protector. No effect on data + ///< layout. + SSPLK_LargeArray, ///< Array or nested array >= SSP-buffer-size. Closest + ///< to the stack protector. + SSPLK_SmallArray, ///< Array or nested array < SSP-buffer-size. 2nd closest + ///< to the stack protector. + SSPLK_AddrOf ///< The address of this allocation is exposed and + ///< triggered protection. 3rd closest to the protector. }; /// A mapping of AllocaInsts to their required SSP layout. -- cgit v1.1 From 62406fdc6f199e4e7df60830be45de4da97b34c7 Mon Sep 17 00:00:00 2001 From: Josh Magee Date: Wed, 30 Oct 2013 02:25:14 +0000 Subject: Reformat code with clang-format. Differential Revision: http://llvm-reviews.chandlerc.com/D2057 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193672 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/StackProtector.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/StackProtector.h b/include/llvm/CodeGen/StackProtector.h index 12d7c75..d09a933 100644 --- a/include/llvm/CodeGen/StackProtector.h +++ b/include/llvm/CodeGen/StackProtector.h @@ -45,7 +45,7 @@ public: }; /// A mapping of AllocaInsts to their required SSP layout. - typedef ValueMap SSPLayoutMap; + typedef ValueMap SSPLayoutMap; private: const TargetMachine *TM; @@ -73,7 +73,7 @@ private: /// if a variable's reference has been taken. This set /// is maintained to ensure we don't visit the same PHI node multiple /// times. - SmallPtrSet VisitedPHIs; + SmallPtrSet VisitedPHIs; /// InsertStackProtectors - Insert code into the prologue and epilogue of /// the function. @@ -102,14 +102,15 @@ private: /// RequiresStackProtector - Check whether or not this function needs a /// stack protector based upon the stack protector level. bool RequiresStackProtector(); + public: - static char ID; // Pass identification, replacement for typeid. + static char ID; // Pass identification, replacement for typeid. StackProtector() : FunctionPass(ID), TM(0), TLI(0), SSPBufferSize(0) { initializeStackProtectorPass(*PassRegistry::getPassRegistry()); } StackProtector(const TargetMachine *TM) - : FunctionPass(ID), TM(TM), TLI(0), Trip(TM->getTargetTriple()), - SSPBufferSize(8) { + : FunctionPass(ID), TM(TM), TLI(0), Trip(TM->getTargetTriple()), + SSPBufferSize(8) { initializeStackProtectorPass(*PassRegistry::getPassRegistry()); } -- cgit v1.1 From 6ff1ef9931b50763a40e9ae8696cfab9e25cf4de Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Wed, 30 Oct 2013 14:45:14 +0000 Subject: [mips][msa] Added support for matching bins[lr]i.[bhwd] from normal IR (i.e. not intrinsics) This required correcting the definition of the bins[lr]i intrinsics because the result is also the first operand. It also required removing the (arbitrary) check for 32-bit immediates in MipsSEDAGToDAGISel::selectVSplat(). Currently using binsli.d with 2 bits set in the mask doesn't select binsli.d because the constant is legalized into a ConstantPool. Similar things can happen with binsri.d with more than 10 bits set in the mask. The resulting code when this happens is correct but not optimal. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193687 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 4118f3e..6276646 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -575,13 +575,17 @@ def int_mips_binsl_d : GCCBuiltin<"__builtin_msa_binsl_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_binsli_b : GCCBuiltin<"__builtin_msa_binsli_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty], + [IntrNoMem]>; def int_mips_binsli_h : GCCBuiltin<"__builtin_msa_binsli_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_i32_ty], + [IntrNoMem]>; def int_mips_binsli_w : GCCBuiltin<"__builtin_msa_binsli_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_i32_ty], + [IntrNoMem]>; def int_mips_binsli_d : GCCBuiltin<"__builtin_msa_binsli_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_i32_ty], + [IntrNoMem]>; def int_mips_binsr_b : GCCBuiltin<"__builtin_msa_binsr_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; @@ -593,13 +597,17 @@ def int_mips_binsr_d : GCCBuiltin<"__builtin_msa_binsr_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; def int_mips_binsri_b : GCCBuiltin<"__builtin_msa_binsri_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty], + [IntrNoMem]>; def int_mips_binsri_h : GCCBuiltin<"__builtin_msa_binsri_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_i32_ty], + [IntrNoMem]>; def int_mips_binsri_w : GCCBuiltin<"__builtin_msa_binsri_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_i32_ty], + [IntrNoMem]>; def int_mips_binsri_d : GCCBuiltin<"__builtin_msa_binsri_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_i32_ty], + [IntrNoMem]>; def int_mips_bmnz_v : GCCBuiltin<"__builtin_msa_bmnz_v">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; -- cgit v1.1 From 2aaa47f396f185d28aa7855d345f7385681098e2 Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Wed, 30 Oct 2013 15:10:54 +0000 Subject: Rehash but don't grow when full of tombstones. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This problem was found and fixed by José Fonseca in March 2011 for SmallPtrSet, committed r128566. But as far as I can tell, all other llvm hash tables retain the same problem: the bucket count can grow without bound while size() remains near constant by repeated insert/erase cycles that tend to fill the container with tombstones. Here is a demo that has been reduced to a trivial case: int main() { llvm::DenseSet d; for (unsigned i = 0; i < 0xFFFFFFF; ++i) { d.insert(i); d.erase(i); } } While the container size() never grows above 1, the bucket count grows like this: nb = 64 nb = 128 nb = 256 nb = 512 nb = 1024 nb = 2048 nb = 4096 nb = 8192 nb = 16384 nb = 32768 nb = 65536 nb = 131072 nb = 262144 nb = 524288 nb = 1048576 nb = 2097152 nb = 4194304 nb = 8388608 nb = 16777216 nb = 33554432 nb = 67108864 nb = 134217728 nb = 268435456 The above program currently consumes a few GB ram. This patch brings the memory consumption down by several orders of magnitude, and keeps the bucket count at 64 for the above test. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193689 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/DenseMap.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/ADT/DenseMap.h b/include/llvm/ADT/DenseMap.h index fac0b95..ce322cc 100644 --- a/include/llvm/ADT/DenseMap.h +++ b/include/llvm/ADT/DenseMap.h @@ -438,9 +438,8 @@ private: this->grow(NumBuckets * 2); LookupBucketFor(Key, TheBucket); NumBuckets = getNumBuckets(); - } - if (NumBuckets-(NewNumEntries+getNumTombstones()) <= NumBuckets/8) { - this->grow(NumBuckets * 2); + } else if (NumBuckets-(NewNumEntries+getNumTombstones()) <= NumBuckets/8) { + this->grow(NumBuckets); LookupBucketFor(Key, TheBucket); } assert(TheBucket); -- cgit v1.1 From 95efb037f7ddc4cac67007eb3a9864e6012eda3b Mon Sep 17 00:00:00 2001 From: Cameron McInally Date: Wed, 30 Oct 2013 15:19:10 +0000 Subject: Refactor the AVX512 intrinsics. Cluster the intrinsics into the appropriate vector extension class within the .td file. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193690 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 186 ++++++++++++++++++++++----------------- 1 file changed, 104 insertions(+), 82 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index e39eea8..74df280 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -206,21 +206,6 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_sse_cvtsi642ss : GCCBuiltin<"__builtin_ia32_cvtsi642ss">, Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_i64_ty], [IntrNoMem]>; - // avx-512 for unsigned conversion - def int_x86_avx512_cvtss2usi : GCCBuiltin<"__builtin_ia32_cvtss2usi">, - Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>; - def int_x86_avx512_cvtss2usi64 : GCCBuiltin<"__builtin_ia32_cvtss2usi64">, - Intrinsic<[llvm_i64_ty], [llvm_v4f32_ty], [IntrNoMem]>; - def int_x86_avx512_cvttss2usi : GCCBuiltin<"__builtin_ia32_cvttss2usi">, - Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>; - def int_x86_avx512_cvttss2usi64 : GCCBuiltin<"__builtin_ia32_cvttss2usi64">, - Intrinsic<[llvm_i64_ty], [llvm_v4f32_ty], [IntrNoMem]>; - def int_x86_avx512_cvtusi2ss : GCCBuiltin<"__builtin_ia32_cvtusi2ss">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, - llvm_i32_ty], [IntrNoMem]>; - def int_x86_avx512_cvtusi642ss : GCCBuiltin<"__builtin_ia32_cvtusi642ss">, - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, - llvm_i64_ty], [IntrNoMem]>; def int_x86_sse_cvtps2pi : GCCBuiltin<"__builtin_ia32_cvtps2pi">, Intrinsic<[llvm_x86mmx_ty], [llvm_v4f32_ty], [IntrNoMem]>; @@ -500,20 +485,6 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_sse2_cvtsi642sd : GCCBuiltin<"__builtin_ia32_cvtsi642sd">, Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, llvm_i64_ty], [IntrNoMem]>; - def int_x86_avx512_cvtsd2usi : GCCBuiltin<"__builtin_ia32_cvtsd2usi">, - Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>; - def int_x86_avx512_cvtsd2usi64 : GCCBuiltin<"__builtin_ia32_cvtsd2usi64">, - Intrinsic<[llvm_i64_ty], [llvm_v2f64_ty], [IntrNoMem]>; - def int_x86_avx512_cvttsd2usi : GCCBuiltin<"__builtin_ia32_cvttsd2usi">, - Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>; - def int_x86_avx512_cvttsd2usi64 : GCCBuiltin<"__builtin_ia32_cvttsd2usi64">, - Intrinsic<[llvm_i64_ty], [llvm_v2f64_ty], [IntrNoMem]>; - def int_x86_avx512_cvtusi2sd : GCCBuiltin<"__builtin_ia32_cvtusi2sd">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, - llvm_i32_ty], [IntrNoMem]>; - def int_x86_avx512_cvtusi642sd : GCCBuiltin<"__builtin_ia32_cvtusi642sd">, - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, - llvm_i64_ty], [IntrNoMem]>; def int_x86_sse2_cvtsd2ss : GCCBuiltin<"__builtin_ia32_cvtsd2ss">, Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v2f64_ty], [IntrNoMem]>; @@ -1226,10 +1197,6 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". Intrinsic<[llvm_v4i32_ty], [llvm_v4f64_ty], [IntrNoMem]>; def int_x86_avx_cvtt_ps2dq_256 : GCCBuiltin<"__builtin_ia32_cvttps2dq256">, Intrinsic<[llvm_v8i32_ty], [llvm_v8f32_ty], [IntrNoMem]>; - def int_x86_avx512_cvt_ps2dq_512 : GCCBuiltin<"__builtin_ia32_cvtps2dq512">, - Intrinsic<[llvm_v16i32_ty], [llvm_v16f32_ty], [IntrNoMem]>; - def int_x86_avx512_cvtdq2_ps_512 : GCCBuiltin<"__builtin_ia32_cvtdq2ps512">, - Intrinsic<[llvm_v16f32_ty], [llvm_v16i32_ty], [IntrNoMem]>; } // Vector bit test @@ -1314,12 +1281,6 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx_vbroadcastf128_ps_256 : GCCBuiltin<"__builtin_ia32_vbroadcastf128_ps256">, Intrinsic<[llvm_v8f32_ty], [llvm_ptr_ty], [IntrReadArgMem]>; - def int_x86_avx512_vbroadcast_sd_512 : - GCCBuiltin<"__builtin_ia32_vbroadcastsd512">, - Intrinsic<[llvm_v8f64_ty], [llvm_ptr_ty], [IntrReadArgMem]>; - def int_x86_avx512_vbroadcast_ss_512 : - GCCBuiltin<"__builtin_ia32_vbroadcastss512">, - Intrinsic<[llvm_v16f32_ty], [llvm_ptr_ty], [IntrReadArgMem]>; } // SIMD load ops @@ -1531,19 +1492,6 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx2_psrl_dq_bs : GCCBuiltin<"__builtin_ia32_psrldqi256_byteshift">, Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_i32_ty], [IntrNoMem]>; - - def int_x86_avx512_psll_dq : GCCBuiltin<"__builtin_ia32_pslldqi512">, - Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, - llvm_i32_ty], [IntrNoMem]>; - def int_x86_avx512_psrl_dq : GCCBuiltin<"__builtin_ia32_psrldqi512">, - Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, - llvm_i32_ty], [IntrNoMem]>; - def int_x86_avx512_psll_dq_bs : GCCBuiltin<"__builtin_ia32_pslldqi512_byteshift">, - Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, - llvm_i32_ty], [IntrNoMem]>; - def int_x86_avx512_psrl_dq_bs : GCCBuiltin<"__builtin_ia32_psrldqi512_byteshift">, - Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, - llvm_i32_ty], [IntrNoMem]>; } // Pack ops. @@ -1655,22 +1603,6 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx2_pmovzxwq : GCCBuiltin<"__builtin_ia32_pmovzxwq256">, Intrinsic<[llvm_v4i64_ty], [llvm_v8i16_ty], [IntrNoMem]>; - // AVX-512 - def int_x86_avx512_pmovzxbq : GCCBuiltin<"__builtin_ia32_pmovzxbq512">, - Intrinsic<[llvm_v8i64_ty], [llvm_v16i8_ty], - [IntrNoMem]>; - def int_x86_avx512_pmovzxwd : GCCBuiltin<"__builtin_ia32_pmovzxwd512">, - Intrinsic<[llvm_v16i32_ty], [llvm_v16i16_ty], - [IntrNoMem]>; - def int_x86_avx512_pmovzxbd : GCCBuiltin<"__builtin_ia32_pmovzxbd512">, - Intrinsic<[llvm_v16i32_ty], [llvm_v16i8_ty], - [IntrNoMem]>; - def int_x86_avx512_pmovzxwq : GCCBuiltin<"__builtin_ia32_pmovzxwq512">, - Intrinsic<[llvm_v8i64_ty], [llvm_v8i16_ty], - [IntrNoMem]>; - def int_x86_avx512_pmovzxdq : GCCBuiltin<"__builtin_ia32_pmovzxdq512">, - Intrinsic<[llvm_v8i64_ty], [llvm_v8i32_ty], - [IntrNoMem]>; } // Vector blend @@ -1697,15 +1629,9 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx2_vbroadcast_sd_pd_256 : GCCBuiltin<"__builtin_ia32_vbroadcastsd_pd256">, Intrinsic<[llvm_v4f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; - def int_x86_avx512_vbroadcast_sd_pd_512 : - GCCBuiltin<"__builtin_ia32_vbroadcastsd_pd512">, - Intrinsic<[llvm_v8f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; def int_x86_avx2_vbroadcast_ss_ps_256 : GCCBuiltin<"__builtin_ia32_vbroadcastss_ps256">, Intrinsic<[llvm_v8f32_ty], [llvm_v4f32_ty], [IntrNoMem]>; - def int_x86_avx512_vbroadcast_ss_ps_512 : - GCCBuiltin<"__builtin_ia32_vbroadcastss_ps512">, - Intrinsic<[llvm_v16f32_ty], [llvm_v4f32_ty], [IntrNoMem]>; def int_x86_avx2_vbroadcasti128 : Intrinsic<[llvm_v4i64_ty], [llvm_ptr_ty], [IntrReadArgMem]>; def int_x86_avx2_pbroadcastb_128 : @@ -2618,11 +2544,6 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_vcvtps2ph_256 : GCCBuiltin<"__builtin_ia32_vcvtps2ph256">, Intrinsic<[llvm_v8i16_ty], [llvm_v8f32_ty, llvm_i32_ty], [IntrNoMem]>; - def int_x86_avx512_vcvtph2ps_512 : GCCBuiltin<"__builtin_ia32_vcvtph2ps512">, - Intrinsic<[llvm_v16f32_ty], [llvm_v16i16_ty], [IntrNoMem]>; - def int_x86_avx512_vcvtps2ph_512 : GCCBuiltin<"__builtin_ia32_vcvtps2ph512">, - Intrinsic<[llvm_v16i16_ty], [llvm_v16f32_ty, llvm_i32_ty], - [IntrNoMem]>; } //===----------------------------------------------------------------------===// @@ -2666,8 +2587,9 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". } //===----------------------------------------------------------------------===// -// AVX-512 intrinsics. +// AVX512 +// Mask ops let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". // Mask instructions // 16-bit mask @@ -2706,6 +2628,90 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". [IntrNoMem]>; } +// Conversion ops +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx512_cvtss2usi : GCCBuiltin<"__builtin_ia32_cvtss2usi">, + Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>; + def int_x86_avx512_cvtss2usi64 : GCCBuiltin<"__builtin_ia32_cvtss2usi64">, + Intrinsic<[llvm_i64_ty], [llvm_v4f32_ty], [IntrNoMem]>; + def int_x86_avx512_cvttss2usi : GCCBuiltin<"__builtin_ia32_cvttss2usi">, + Intrinsic<[llvm_i32_ty], [llvm_v4f32_ty], [IntrNoMem]>; + def int_x86_avx512_cvttss2usi64 : GCCBuiltin<"__builtin_ia32_cvttss2usi64">, + Intrinsic<[llvm_i64_ty], [llvm_v4f32_ty], [IntrNoMem]>; + def int_x86_avx512_cvtusi2ss : GCCBuiltin<"__builtin_ia32_cvtusi2ss">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_avx512_cvtusi642ss : GCCBuiltin<"__builtin_ia32_cvtusi642ss">, + Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, + llvm_i64_ty], [IntrNoMem]>; + + def int_x86_avx512_cvtsd2usi : GCCBuiltin<"__builtin_ia32_cvtsd2usi">, + Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>; + def int_x86_avx512_cvtsd2usi64 : GCCBuiltin<"__builtin_ia32_cvtsd2usi64">, + Intrinsic<[llvm_i64_ty], [llvm_v2f64_ty], [IntrNoMem]>; + def int_x86_avx512_cvttsd2usi : GCCBuiltin<"__builtin_ia32_cvttsd2usi">, + Intrinsic<[llvm_i32_ty], [llvm_v2f64_ty], [IntrNoMem]>; + def int_x86_avx512_cvttsd2usi64 : GCCBuiltin<"__builtin_ia32_cvttsd2usi64">, + Intrinsic<[llvm_i64_ty], [llvm_v2f64_ty], [IntrNoMem]>; + def int_x86_avx512_cvtusi2sd : GCCBuiltin<"__builtin_ia32_cvtusi2sd">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_avx512_cvtusi642sd : GCCBuiltin<"__builtin_ia32_cvtusi642sd">, + Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, + llvm_i64_ty], [IntrNoMem]>; + + def int_x86_avx512_vcvtph2ps_512 : GCCBuiltin<"__builtin_ia32_vcvtph2ps512">, + Intrinsic<[llvm_v16f32_ty], [llvm_v16i16_ty], [IntrNoMem]>; + def int_x86_avx512_vcvtps2ph_512 : GCCBuiltin<"__builtin_ia32_vcvtps2ph512">, + Intrinsic<[llvm_v16i16_ty], [llvm_v16f32_ty, llvm_i32_ty], + [IntrNoMem]>; +} + +// Vector convert +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx512_cvt_ps2dq_512 : GCCBuiltin<"__builtin_ia32_cvtps2dq512">, + Intrinsic<[llvm_v16i32_ty], [llvm_v16f32_ty], [IntrNoMem]>; + def int_x86_avx512_cvtdq2_ps_512 : GCCBuiltin<"__builtin_ia32_cvtdq2ps512">, + Intrinsic<[llvm_v16f32_ty], [llvm_v16i32_ty], [IntrNoMem]>; +} + +// Vector load with broadcast +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx512_vbroadcast_ss_512 : + GCCBuiltin<"__builtin_ia32_vbroadcastss512">, + Intrinsic<[llvm_v16f32_ty], [llvm_ptr_ty], [IntrReadArgMem]>; + def int_x86_avx512_vbroadcast_ss_ps_512 : + GCCBuiltin<"__builtin_ia32_vbroadcastss_ps512">, + Intrinsic<[llvm_v16f32_ty], [llvm_v4f32_ty], [IntrNoMem]>; + + def int_x86_avx512_vbroadcast_sd_512 : + GCCBuiltin<"__builtin_ia32_vbroadcastsd512">, + Intrinsic<[llvm_v8f64_ty], [llvm_ptr_ty], [IntrReadArgMem]>; + def int_x86_avx512_vbroadcast_sd_pd_512 : + GCCBuiltin<"__builtin_ia32_vbroadcastsd_pd512">, + Intrinsic<[llvm_v8f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; +} + +// Vector sign and zero extend +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx512_pmovzxbq : GCCBuiltin<"__builtin_ia32_pmovzxbq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v16i8_ty], + [IntrNoMem]>; + def int_x86_avx512_pmovzxwd : GCCBuiltin<"__builtin_ia32_pmovzxwd512">, + Intrinsic<[llvm_v16i32_ty], [llvm_v16i16_ty], + [IntrNoMem]>; + def int_x86_avx512_pmovzxbd : GCCBuiltin<"__builtin_ia32_pmovzxbd512">, + Intrinsic<[llvm_v16i32_ty], [llvm_v16i8_ty], + [IntrNoMem]>; + def int_x86_avx512_pmovzxwq : GCCBuiltin<"__builtin_ia32_pmovzxwq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i16_ty], + [IntrNoMem]>; + def int_x86_avx512_pmovzxdq : GCCBuiltin<"__builtin_ia32_pmovzxdq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i32_ty], + [IntrNoMem]>; +} + +// Arithmetic ops let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx512_min_ps_512 : GCCBuiltin<"__builtin_ia32_minps512">, Intrinsic<[llvm_v16f32_ty], [llvm_v16f32_ty, @@ -2745,9 +2751,7 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx512_pmins_q : GCCBuiltin<"__builtin_ia32_pminsq512">, Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i64_ty], [IntrNoMem]>; -} -let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx512_rndscale_ss : GCCBuiltin<"__builtin_ia32_rndscaless">, Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_i32_ty], [IntrNoMem]>; @@ -2824,6 +2828,23 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". [IntrNoMem]>; } +// Integer shift ops. +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". + def int_x86_avx512_psll_dq : GCCBuiltin<"__builtin_ia32_pslldqi512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_avx512_psrl_dq : GCCBuiltin<"__builtin_ia32_psrldqi512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_avx512_psll_dq_bs : GCCBuiltin<"__builtin_ia32_pslldqi512_byteshift">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, + llvm_i32_ty], [IntrNoMem]>; + def int_x86_avx512_psrl_dq_bs : GCCBuiltin<"__builtin_ia32_psrldqi512_byteshift">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, + llvm_i32_ty], [IntrNoMem]>; +} + +// Gather and Scatter ops let TargetPrefix = "x86" in { def int_x86_avx512_gather_dpd_mask_512 : GCCBuiltin<"__builtin_ia32_mask_gatherdpd512">, Intrinsic<[llvm_v8f64_ty], [llvm_v8f64_ty, llvm_i8_ty, @@ -2962,6 +2983,7 @@ let TargetPrefix = "x86" in { []>; } +// Misc. let TargetPrefix = "x86" in { def int_x86_avx512_mskblend_ps_512 : GCCBuiltin<"__builtin_ia32_mskblendps512">, Intrinsic<[llvm_v16f32_ty], -- cgit v1.1 From f853a034a1fdccd194da04ca1e2e1aa8bcbd16b4 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Wed, 30 Oct 2013 15:19:37 +0000 Subject: [AArch64] Add support for NEON scalar floating-point compare instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193691 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 944c144..76b9215 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -168,28 +168,35 @@ def int_aarch64_neon_vcvtf64_u64 : // Scalar Floating-point Reciprocal Exponent def int_aarch64_neon_vrecpx : Neon_1Arg_Intrinsic; -class Neon_ICmp_Intrinsic - : Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], [IntrNoMem]>; +class Neon_Cmp_Intrinsic + : Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty, llvm_anyvector_ty], + [IntrNoMem]>; -// Scalar Integer Compare Equal -def int_aarch64_neon_vceq : Neon_ICmp_Intrinsic; +// Scalar Compare Equal +def int_aarch64_neon_vceq : Neon_Cmp_Intrinsic; -// Scalar Integer Compare Greater-Than or Equal -def int_aarch64_neon_vcge : Neon_ICmp_Intrinsic; -def int_aarch64_neon_vchs : Neon_ICmp_Intrinsic; +// Scalar Compare Greater-Than or Equal +def int_aarch64_neon_vcge : Neon_Cmp_Intrinsic; +def int_aarch64_neon_vchs : Neon_Cmp_Intrinsic; -// Scalar Integer Compare Less-Than or Equal -def int_aarch64_neon_vclez : Neon_ICmp_Intrinsic; +// Scalar Compare Less-Than or Equal +def int_aarch64_neon_vclez : Neon_Cmp_Intrinsic; // Scalar Compare Less-Than -def int_aarch64_neon_vcltz : Neon_ICmp_Intrinsic; +def int_aarch64_neon_vcltz : Neon_Cmp_Intrinsic; // Scalar Compare Greater-Than -def int_aarch64_neon_vcgt : Neon_ICmp_Intrinsic; -def int_aarch64_neon_vchi : Neon_ICmp_Intrinsic; +def int_aarch64_neon_vcgt : Neon_Cmp_Intrinsic; +def int_aarch64_neon_vchi : Neon_Cmp_Intrinsic; // Scalar Compare Bitwise Test Bits -def int_aarch64_neon_vtstd : Neon_ICmp_Intrinsic; +def int_aarch64_neon_vtstd : Neon_Cmp_Intrinsic; + +// Scalar Floating-point Absolute Compare Greater Than Or Equal +def int_aarch64_neon_vcage : Neon_Cmp_Intrinsic; + +// Scalar Floating-point Absolute Compare Greater Than +def int_aarch64_neon_vcagt : Neon_Cmp_Intrinsic; // Scalar Signed Saturating Accumulated of Unsigned Value def int_aarch64_neon_vuqadd : Neon_2Arg_Intrinsic; -- cgit v1.1 From c385709d8397ca1535481c04564b67d07c66c619 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Wed, 30 Oct 2013 15:20:38 +0000 Subject: [mips][msa] Added support for matching bmnz, bmnzi, bmz, and bmzi from normal IR (i.e. not intrinsics) Also corrected the definition of the intrinsics for these instructions (the result register is also the first operand), and added intrinsics for bsel and bseli to clang (they already existed in the backend). These four operations are mostly equivalent to bsel, and bseli (the difference is which operand is tied to the result). As a result some of the tests changed as described below. bitwise.ll: - bsel.v test adapted so that the mask is unknown at compile-time. This stops it emitting bmnzi.b instead of the intended bsel.v. - The bseli.b test now tests the right thing. Namely the case when one of the values is an uimm8, rather than when the condition is a uimm8 (which is covered by bmnzi.b) compare.ll: - bsel.v tests now (correctly) emits bmnz.v instead of bsel.v because this is the same operation (see MSA.txt). i8.ll - CHECK-DAG-ized test. - bmzi.b test now (correctly) emits equivalent bmnzi.b with swapped operands because this is the same operation (see MSA.txt). - bseli.b still emits bseli.b though because the immediate makes it distinguishable from bmnzi.b. vec.ll: - CHECK-DAG-ized test. - bmz.v tests now (correctly) emits bmnz.v with swapped operands (see MSA.txt). - bsel.v tests now (correctly) emits bmnz.v with swapped operands (see MSA.txt). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193693 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 6276646..6c8aa4c 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -610,16 +610,20 @@ def int_mips_binsri_d : GCCBuiltin<"__builtin_msa_binsri_d">, [IntrNoMem]>; def int_mips_bmnz_v : GCCBuiltin<"__builtin_msa_bmnz_v">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty], + [IntrNoMem]>; def int_mips_bmnzi_b : GCCBuiltin<"__builtin_msa_bmnzi_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty], + [IntrNoMem]>; def int_mips_bmz_v : GCCBuiltin<"__builtin_msa_bmz_v">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty], + [IntrNoMem]>; def int_mips_bmzi_b : GCCBuiltin<"__builtin_msa_bmzi_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty], + [IntrNoMem]>; def int_mips_bneg_b : GCCBuiltin<"__builtin_msa_bneg_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; -- cgit v1.1 From 02fbffd4e8e1a28539b302e4de84203814898153 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Wed, 30 Oct 2013 15:45:42 +0000 Subject: [mips][msa] Correct definition of bins[lr] and CHECK-DAG-ize related tests git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193695 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsMips.td | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsMips.td b/include/llvm/IR/IntrinsicsMips.td index 6c8aa4c..42c5821 100644 --- a/include/llvm/IR/IntrinsicsMips.td +++ b/include/llvm/IR/IntrinsicsMips.td @@ -566,13 +566,17 @@ def int_mips_bclri_d : GCCBuiltin<"__builtin_msa_bclri_d">, Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_i32_ty], [IntrNoMem]>; def int_mips_binsl_b : GCCBuiltin<"__builtin_msa_binsl_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty], + [IntrNoMem]>; def int_mips_binsl_h : GCCBuiltin<"__builtin_msa_binsl_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], + [IntrNoMem]>; def int_mips_binsl_w : GCCBuiltin<"__builtin_msa_binsl_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], + [IntrNoMem]>; def int_mips_binsl_d : GCCBuiltin<"__builtin_msa_binsl_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty], + [IntrNoMem]>; def int_mips_binsli_b : GCCBuiltin<"__builtin_msa_binsli_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty], @@ -588,13 +592,17 @@ def int_mips_binsli_d : GCCBuiltin<"__builtin_msa_binsli_d">, [IntrNoMem]>; def int_mips_binsr_b : GCCBuiltin<"__builtin_msa_binsr_b">, - Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty], [IntrNoMem]>; + Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_v16i8_ty], + [IntrNoMem]>; def int_mips_binsr_h : GCCBuiltin<"__builtin_msa_binsr_h">, - Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty], [IntrNoMem]>; + Intrinsic<[llvm_v8i16_ty], [llvm_v8i16_ty, llvm_v8i16_ty, llvm_v8i16_ty], + [IntrNoMem]>; def int_mips_binsr_w : GCCBuiltin<"__builtin_msa_binsr_w">, - Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v4i32_ty, llvm_v4i32_ty], + [IntrNoMem]>; def int_mips_binsr_d : GCCBuiltin<"__builtin_msa_binsr_d">, - Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty], [IntrNoMem]>; + Intrinsic<[llvm_v2i64_ty], [llvm_v2i64_ty, llvm_v2i64_ty, llvm_v2i64_ty], + [IntrNoMem]>; def int_mips_binsri_b : GCCBuiltin<"__builtin_msa_binsri_b">, Intrinsic<[llvm_v16i8_ty], [llvm_v16i8_ty, llvm_v16i8_ty, llvm_i32_ty], -- cgit v1.1 From f34c3ca3046378bdb7e49b7366bafca0e0bafb9a Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Wed, 30 Oct 2013 18:32:26 +0000 Subject: Add {start,end}with_lower methods to StringRef. startswith_lower is ocassionally useful and I think worth adding. endwith_lower is added for completeness. Differential Revision: http://llvm-reviews.chandlerc.com/D2041 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193706 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/StringRef.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h index fd5b28e..ec0c284 100644 --- a/include/llvm/ADT/StringRef.h +++ b/include/llvm/ADT/StringRef.h @@ -210,12 +210,18 @@ namespace llvm { compareMemory(Data, Prefix.Data, Prefix.Length) == 0; } + /// Check if this string starts with the given \p Prefix, ignoring case. + bool startswith_lower(StringRef Prefix) const; + /// Check if this string ends with the given \p Suffix. bool endswith(StringRef Suffix) const { return Length >= Suffix.Length && compareMemory(end() - Suffix.Length, Suffix.Data, Suffix.Length) == 0; } + /// Check if this string ends with the given \p Suffix, ignoring case. + bool endswith_lower(StringRef Suffix) const; + /// @} /// @name String Searching /// @{ -- cgit v1.1 From f132bf39b95815ed899c78f0ff33d743a286b1ac Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Wed, 30 Oct 2013 20:41:45 +0000 Subject: [Mips] Add more SHF_MIPS_xxx ELF section flags. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193713 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/ELF.h | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/ELF.h b/include/llvm/Support/ELF.h index ae3b1d3..5034f8b 100644 --- a/include/llvm/Support/ELF.h +++ b/include/llvm/Support/ELF.h @@ -1242,8 +1242,30 @@ enum LLVM_ENUM_INT_TYPE(unsigned) { // for faster accesses SHF_HEX_GPREL = 0x10000000, - // Do not strip this section. FIXME: We need target specific SHF_ enums. - SHF_MIPS_NOSTRIP = 0x8000000 + // Section contains text/data which may be replicated in other sections. + // Linker must retain only one copy. + SHF_MIPS_NODUPES = 0x01000000, + + // Linker must generate implicit hidden weak names. + SHF_MIPS_NAMES = 0x02000000, + + // Section data local to process. + SHF_MIPS_LOCAL = 0x04000000, + + // Do not strip this section. + SHF_MIPS_NOSTRIP = 0x08000000, + + // Section must be part of global data area. + SHF_MIPS_GPREL = 0x10000000, + + // This section should be merged. + SHF_MIPS_MERGE = 0x20000000, + + // Address size to be inferred from section entry size. + SHF_MIPS_ADDR = 0x40000000, + + // Section data is string data by default. + SHF_MIPS_STRING = 0x80000000 }; // Section Group Flags -- cgit v1.1 From 2cc546db188d5e4d4537681cab3d52781125518c Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 30 Oct 2013 22:08:11 +0000 Subject: Produce .weak_def_can_be_hidden for some linkonce_odr values With this patch llvm produces a weak_def_can_be_hidden for linkonce_odr if they are also unnamed_addr or don't have their address taken. There is not a lot of documentation about .weak_def_can_be_hidden, but from the old discussion about linkonce_odr_auto_hide and the name of the directive this looks correct: these symbols can be hidden. Testing this with the ld64 in Xcode 5 linking clang reduces the number of exported symbols from 21053 to 19049. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193718 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/AsmPrinter.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/AsmPrinter.h b/include/llvm/CodeGen/AsmPrinter.h index d66665c..4bda0f1 100644 --- a/include/llvm/CodeGen/AsmPrinter.h +++ b/include/llvm/CodeGen/AsmPrinter.h @@ -486,7 +486,7 @@ namespace llvm { void EmitVisibility(MCSymbol *Sym, unsigned Visibility, bool IsDefinition = true) const; - void EmitLinkage(unsigned Linkage, MCSymbol *GVSym) const; + void EmitLinkage(const GlobalValue *GV, MCSymbol *GVSym) const; void EmitJumpTableEntry(const MachineJumpTableInfo *MJTI, const MachineBasicBlock *MBB, unsigned uid) const; -- cgit v1.1 From c143c7573bfd0d55cf283cc2676dbd852f939c87 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 31 Oct 2013 03:03:55 +0000 Subject: Merge CallGraph and BasicCallGraph. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193734 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/CallGraph.h | 73 ++++++++++++++++++++------------------- include/llvm/InitializePasses.h | 3 +- 2 files changed, 38 insertions(+), 38 deletions(-) (limited to 'include') diff --git a/include/llvm/Analysis/CallGraph.h b/include/llvm/Analysis/CallGraph.h index 926da76..d00c2ed 100644 --- a/include/llvm/Analysis/CallGraph.h +++ b/include/llvm/Analysis/CallGraph.h @@ -69,13 +69,36 @@ class CallGraphNode; //===----------------------------------------------------------------------===// // CallGraph class definition // -class CallGraph { -protected: +class CallGraph : public ModulePass { Module *Mod; // The module this call graph represents typedef std::map FunctionMapTy; FunctionMapTy FunctionMap; // Map from a function to its node + // Root is root of the call graph, or the external node if a 'main' function + // couldn't be found. + // + CallGraphNode *Root; + + // ExternalCallingNode - This node has edges to all external functions and + // those internal functions that have their address taken. + CallGraphNode *ExternalCallingNode; + + // CallsExternalNode - This node has edges to it from all functions making + // indirect calls or calling an external function. + CallGraphNode *CallsExternalNode; + + /// Replace the function represented by this node by another. + /// This does not rescan the body of the function, so it is suitable when + /// splicing the body of one function to another while also updating all + /// callers from the old function to the new. + /// + void spliceFunction(const Function *From, const Function *To); + + // Add a function to the call graph, and link the node to all of the functions + // that it calls. + void addToCallGraph(Function *F); + public: static char ID; // Class identification, replacement for typeinfo //===--------------------------------------------------------------------- @@ -107,15 +130,14 @@ public: } /// Returns the CallGraphNode which is used to represent undetermined calls - /// into the callgraph. Override this if you want behavioral inheritance. - virtual CallGraphNode* getExternalCallingNode() const { return 0; } - virtual CallGraphNode* getCallsExternalNode() const { return 0; } + /// into the callgraph. + CallGraphNode *getExternalCallingNode() const { return ExternalCallingNode; } + CallGraphNode *getCallsExternalNode() const { return CallsExternalNode; } /// Return the root/main method in the module, or some other root node, such - /// as the externalcallingnode. Overload these if you behavioral - /// inheritance. - virtual CallGraphNode* getRoot() { return 0; } - virtual const CallGraphNode* getRoot() const { return 0; } + /// as the externalcallingnode. + CallGraphNode *getRoot() { return Root; } + const CallGraphNode *getRoot() const { return Root; } //===--------------------------------------------------------------------- // Functions to keep a call graph up to date with a function that has been @@ -129,41 +151,20 @@ public: /// do this is to dropAllReferences before calling this. /// Function *removeFunctionFromModule(CallGraphNode *CGN); - Function *removeFunctionFromModule(Function *F) { - return removeFunctionFromModule((*this)[F]); - } /// getOrInsertFunction - This method is identical to calling operator[], but /// it will insert a new CallGraphNode for the specified function if one does /// not already exist. CallGraphNode *getOrInsertFunction(const Function *F); - /// spliceFunction - Replace the function represented by this node by another. - /// This does not rescan the body of the function, so it is suitable when - /// splicing the body of one function to another while also updating all - /// callers from the old function to the new. - /// - void spliceFunction(const Function *From, const Function *To); - - //===--------------------------------------------------------------------- - // Pass infrastructure interface glue code. - // -protected: - CallGraph() {} - -public: - virtual ~CallGraph() { } - - /// initialize - Call this method before calling other methods, - /// re/initializes the state of the CallGraph. - /// - void initialize(Module &M); + CallGraph(); + virtual ~CallGraph() { releaseMemory(); } + virtual void getAnalysisUsage(AnalysisUsage &AU) const; + virtual bool runOnModule(Module &M); + virtual void releaseMemory(); - void print(raw_ostream &o, Module *) const; + void print(raw_ostream &o, const Module *) const; void dump() const; -protected: - // destroy - Release memory for the call graph - virtual void destroy(); }; //===----------------------------------------------------------------------===// diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h index 6cb75cb..fe26c23 100644 --- a/include/llvm/InitializePasses.h +++ b/include/llvm/InitializePasses.h @@ -72,7 +72,7 @@ void initializeAlwaysInlinerPass(PassRegistry&); void initializeArgPromotionPass(PassRegistry&); void initializeBarrierNoopPass(PassRegistry&); void initializeBasicAliasAnalysisPass(PassRegistry&); -void initializeBasicCallGraphPass(PassRegistry&); +void initializeCallGraphPass(PassRegistry&); void initializeBasicTTIPass(PassRegistry&); void initializeBlockExtractorPassPass(PassRegistry&); void initializeBlockFrequencyInfoPass(PassRegistry&); @@ -90,7 +90,6 @@ void initializeFlattenCFGPassPass(PassRegistry&); void initializeStructurizeCFGPass(PassRegistry&); void initializeCFGViewerPass(PassRegistry&); void initializeCalculateSpillWeightsPass(PassRegistry&); -void initializeCallGraphAnalysisGroup(PassRegistry&); void initializeCodeGenPreparePass(PassRegistry&); void initializeConstantMergePass(PassRegistry&); void initializeConstantPropagationPass(PassRegistry&); -- cgit v1.1 From 424f19732e948a854b454c70722a4eca8957bc20 Mon Sep 17 00:00:00 2001 From: Cameron McInally Date: Thu, 31 Oct 2013 13:56:31 +0000 Subject: Add AVX512 unmasked integer broadcast intrinsics and support. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193748 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index 74df280..c24fb06 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -2690,6 +2690,18 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx512_vbroadcast_sd_pd_512 : GCCBuiltin<"__builtin_ia32_vbroadcastsd_pd512">, Intrinsic<[llvm_v8f64_ty], [llvm_v2f64_ty], [IntrNoMem]>; + + def int_x86_avx512_pbroadcastd_512 : + GCCBuiltin<"__builtin_ia32_pbroadcastd512">, + Intrinsic<[llvm_v16i32_ty], [llvm_v4i32_ty], [IntrNoMem]>; + def int_x86_avx512_pbroadcastd_i32_512 : + Intrinsic<[llvm_v16i32_ty], [llvm_i32_ty], [IntrNoMem]>; + + def int_x86_avx512_pbroadcastq_512 : + GCCBuiltin<"__builtin_ia32_pbroadcastq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v2i64_ty], [IntrNoMem]>; + def int_x86_avx512_pbroadcastq_i64_512 : + Intrinsic<[llvm_v8i64_ty], [llvm_i64_ty], [IntrNoMem]>; } // Vector sign and zero extend -- cgit v1.1 From b46bc1c91b3200d85c3d16e9da1de30259ec4172 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 31 Oct 2013 15:49:39 +0000 Subject: Remove unused flag. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193752 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAsmInfo.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h index bcf6fe8..16c0b54 100644 --- a/include/llvm/MC/MCAsmInfo.h +++ b/include/llvm/MC/MCAsmInfo.h @@ -283,10 +283,6 @@ namespace llvm { /// directive. bool HasNoDeadStrip; // Defaults to false. - /// HasSymbolResolver - True if this target supports the MachO - /// .symbol_resolver directive. - bool HasSymbolResolver; // Defaults to false. - /// WeakRefDirective - This directive, if non-null, is used to declare a /// global as being a weak undefined symbol. const char *WeakRefDirective; // Defaults to NULL. @@ -536,7 +532,6 @@ namespace llvm { bool hasSingleParameterDotFile() const { return HasSingleParameterDotFile; } bool hasIdentDirective() const { return HasIdentDirective; } bool hasNoDeadStrip() const { return HasNoDeadStrip; } - bool hasSymbolResolver() const { return HasSymbolResolver; } const char *getWeakRefDirective() const { return WeakRefDirective; } const char *getWeakDefDirective() const { return WeakDefDirective; } const char *getLinkOnceDirective() const { return LinkOnceDirective; } -- cgit v1.1 From d7ef09bc9a6dea29a4ac4a45e722d479e8c50f6d Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 31 Oct 2013 15:58:33 +0000 Subject: Remove another unused flag. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193756 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAsmInfo.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h index 16c0b54..0c2bc4c 100644 --- a/include/llvm/MC/MCAsmInfo.h +++ b/include/llvm/MC/MCAsmInfo.h @@ -244,11 +244,6 @@ namespace llvm { /// const char *GlobalDirective; // Defaults to NULL. - /// ExternDirective - This is the directive used to declare external - /// globals. - /// - const char *ExternDirective; // Defaults to NULL. - /// HasSetDirective - True if the assembler supports the .set directive. bool HasSetDirective; // Defaults to true. @@ -515,9 +510,6 @@ namespace llvm { const char *getGlobalDirective() const { return GlobalDirective; } - const char *getExternDirective() const { - return ExternDirective; - } bool hasSetDirective() const { return HasSetDirective; } bool hasAggressiveSymbolFolding() const { return HasAggressiveSymbolFolding; -- cgit v1.1 From 2e50b8a08d40ce72ae35c73528140d3ee25209e0 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Thu, 31 Oct 2013 17:18:11 +0000 Subject: Enable variable arguments support for intrinsics. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193766 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Intrinsics.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/IR/Intrinsics.h b/include/llvm/IR/Intrinsics.h index c81d110..473e525 100644 --- a/include/llvm/IR/Intrinsics.h +++ b/include/llvm/IR/Intrinsics.h @@ -77,7 +77,7 @@ namespace Intrinsic { /// getIntrinsicInfoTableEntries. struct IITDescriptor { enum IITDescriptorKind { - Void, MMX, Metadata, Half, Float, Double, + Void, VarArg, MMX, Metadata, Half, Float, Double, Integer, Vector, Pointer, Struct, Argument, ExtendVecArgument, TruncVecArgument } Kind; -- cgit v1.1 From ab7431b0d47926e804a4a07fdca12e575c976daf Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Thu, 31 Oct 2013 17:18:14 +0000 Subject: Add experimental stackmap intrinsics to definition file and documenation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193767 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Intrinsics.td | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/Intrinsics.td b/include/llvm/IR/Intrinsics.td index 53341b7..ded6cc1 100644 --- a/include/llvm/IR/Intrinsics.td +++ b/include/llvm/IR/Intrinsics.td @@ -455,6 +455,19 @@ def int_invariant_end : Intrinsic<[], llvm_ptr_ty], [IntrReadWriteArgMem, NoCapture<2>]>; +//===------------------------ Stackmap Intrinsics -------------------------===// +// +def int_experimental_stackmap : Intrinsic<[], + [llvm_i32_ty, llvm_i32_ty, llvm_vararg_ty]>; +def int_experimental_patchpoint_void : Intrinsic<[], + [llvm_i32_ty, llvm_i32_ty, + llvm_ptr_ty, llvm_i32_ty, + llvm_vararg_ty]>; +def int_experimental_patchpoint_i64 : Intrinsic<[llvm_i64_ty], + [llvm_i32_ty, llvm_i32_ty, + llvm_ptr_ty, llvm_i32_ty, + llvm_vararg_ty]>; + //===-------------------------- Other Intrinsics --------------------------===// // def int_flt_rounds : Intrinsic<[llvm_i32_ty]>, -- cgit v1.1 From 2343e3b228c02896f4779962a91aaa659356fe2a Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Thu, 31 Oct 2013 17:18:24 +0000 Subject: Lower stackmap intrinsics directly to their target opcode in the DAG builder. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193769 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/Target.td | 13 +++++++++++++ include/llvm/Target/TargetLowering.h | 2 ++ include/llvm/Target/TargetOpcodes.h | 14 +++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Target/Target.td b/include/llvm/Target/Target.td index c15a4ab..0c0b1ed 100644 --- a/include/llvm/Target/Target.td +++ b/include/llvm/Target/Target.td @@ -800,6 +800,19 @@ def LIFETIME_END : Instruction { let AsmString = "LIFETIME_END"; let neverHasSideEffects = 1; } +def STACKMAP : Instruction { + let OutOperandList = (outs); + let InOperandList = (ins i32imm:$id, i32imm:$nbytes, variable_ops); + let isCall = 1; + let mayLoad = 1; +} +def PATCHPOINT : Instruction { + let OutOperandList = (outs); + let InOperandList = (ins i32imm:$id, i32imm:$nbytes, unknown:$callee, + i32imm:$nargs, variable_ops); + let isCall = 1; + let mayLoad = 1; +} } //===----------------------------------------------------------------------===// diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 01b579b..43052e1 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -1920,6 +1920,8 @@ public: ArgListEntry() : isSExt(false), isZExt(false), isInReg(false), isSRet(false), isNest(false), isByVal(false), isReturned(false), Alignment(0) { } + + void setAttributes(ImmutableCallSite *CS, unsigned AttrIdx); }; typedef std::vector ArgListTy; diff --git a/include/llvm/Target/TargetOpcodes.h b/include/llvm/Target/TargetOpcodes.h index 86ac7df..bd74cb9 100644 --- a/include/llvm/Target/TargetOpcodes.h +++ b/include/llvm/Target/TargetOpcodes.h @@ -92,7 +92,19 @@ namespace TargetOpcode { /// Lifetime markers. LIFETIME_START = 15, - LIFETIME_END = 16 + LIFETIME_END = 16, + + /// A Stackmap instruction captures the location of live variables at its + /// position in the instruction stream. It is followed by a shadow of bytes + /// that must lie within the function and not contain another stackmap. + STACKMAP = 17, + + /// Patchable call instruction - this instruction represents a call to a + /// constant address, followed by a series of NOPs. It is intended to + /// support optimizations for dynamic languages (such as javascript) that + /// rewrite calls to runtimes with more efficient code sequences. + /// This also implies a stack map. + PATCHPOINT = 18 }; } // end namespace TargetOpcode } // end namespace llvm -- cgit v1.1 From aa8c95ec289bc14351bc7597d5c9251ce6f98c14 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Thu, 31 Oct 2013 17:25:22 +0000 Subject: Cleanup: update comments. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193773 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Instructions.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/IR/Instructions.h b/include/llvm/IR/Instructions.h index 4c21bc0..da260fb 100644 --- a/include/llvm/IR/Instructions.h +++ b/include/llvm/IR/Instructions.h @@ -2912,7 +2912,7 @@ public: /// removeAttribute - removes the attribute from the list of attributes. void removeAttribute(unsigned i, Attribute attr); - /// \brief Determine whether this call has the NoAlias attribute. + /// \brief Determine whether this call has the given attribute. bool hasFnAttr(Attribute::AttrKind A) const { assert(A != Attribute::NoBuiltin && "Use CallInst::isNoBuiltin() to check for Attribute::NoBuiltin"); -- cgit v1.1 From 1d28917dc39f38847f5c69c0a60cd1491430bdad Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Thu, 31 Oct 2013 19:28:44 +0000 Subject: [AArch64] Add support for NEON scalar shift immediate instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193790 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 40 ++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 76b9215..2dfe02a 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -220,4 +220,44 @@ def int_aarch64_neon_vqdmlsl : Neon_3Arg_Long_Intrinsic; // Signed Saturating Doubling Multiply Long def int_aarch64_neon_vqdmull : Neon_2Arg_Long_Intrinsic; + +class Neon_2Arg_ShiftImm_Intrinsic + : Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_i32_ty], [IntrNoMem]>; + +class Neon_3Arg_ShiftImm_Intrinsic + : Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty, llvm_i32_ty], + [IntrNoMem]>; + +// Scalar Shift Right (Immediate) +def int_aarch64_neon_vshrds_n : Neon_2Arg_ShiftImm_Intrinsic; +def int_aarch64_neon_vshrdu_n : Neon_2Arg_ShiftImm_Intrinsic; + +// Scalar Rounding Shift Right (Immediate) +def int_aarch64_neon_vrshrds_n : Neon_2Arg_ShiftImm_Intrinsic; +def int_aarch64_neon_vrshrdu_n : Neon_2Arg_ShiftImm_Intrinsic; + +// Scalar Shift Right and Accumulate (Immediate) +def int_aarch64_neon_vsrads_n : Neon_3Arg_ShiftImm_Intrinsic; +def int_aarch64_neon_vsradu_n : Neon_3Arg_ShiftImm_Intrinsic; + +// Scalar Rounding Shift Right and Accumulate (Immediate) +def int_aarch64_neon_vrsrads_n : Neon_3Arg_ShiftImm_Intrinsic; +def int_aarch64_neon_vrsradu_n : Neon_3Arg_ShiftImm_Intrinsic; + +// Scalar Shift Left (Immediate) +def int_aarch64_neon_vshld_n : Neon_2Arg_ShiftImm_Intrinsic; + +// Scalar Saturating Shift Left (Immediate) +def int_aarch64_neon_vqshls_n : Neon_N2V_Intrinsic; +def int_aarch64_neon_vqshlu_n : Neon_N2V_Intrinsic; + +// Scalar Signed Saturating Shift Left Unsigned (Immediate) +def int_aarch64_neon_vqshlus_n : Neon_N2V_Intrinsic; + +// Shift Right And Insert (Immediate) +def int_aarch64_neon_vsrid_n : Neon_2Arg_ShiftImm_Intrinsic; + +// Shift Left And Insert (Immediate) +def int_aarch64_neon_vslid_n : Neon_2Arg_ShiftImm_Intrinsic; + } -- cgit v1.1 From 7e667c56cf7e27ff521ceb86518beab32bfb630d Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 31 Oct 2013 20:51:58 +0000 Subject: Use LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN instead of the "dso list". There are two ways one could implement hiding of linkonce_odr symbols in LTO: * LLVM tells the linker which symbols can be hidden if not used from native files. * The linker tells LLVM which symbols are not used from other object files, but will be put in the dso symbol table if present. GOLD's API is the second option. It was implemented almost 1:1 in llvm by passing the list down to internalize. LLVM already had partial support for the first option. It is also very similar to how ld64 handles hiding these symbols when *not* doing LTO. This patch then * removes the APIs for the DSO list. * marks LTO_SYMBOL_SCOPE_DEFAULT_CAN_BE_HIDDEN all linkonce_odr unnamed_addr global values and other linkonce_odr whose address is not used. * makes the gold plugin responsible for handling the API mismatch. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193800 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/lto.h | 9 --------- include/llvm/LTO/LTOCodeGenerator.h | 6 ------ include/llvm/Transforms/IPO.h | 18 +----------------- 3 files changed, 1 insertion(+), 32 deletions(-) (limited to 'include') diff --git a/include/llvm-c/lto.h b/include/llvm-c/lto.h index a09db24..89f54b7 100644 --- a/include/llvm-c/lto.h +++ b/include/llvm-c/lto.h @@ -270,15 +270,6 @@ lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args, extern void lto_codegen_add_must_preserve_symbol(lto_code_gen_t cg, const char* symbol); - -/** - * Tells LTO optimization passes that a dynamic shared library is being - * built and this symbol may be exported. Unless IR semantics allow the symbol - * to be made local to the library, it should remain so it can be exported by - * the shared library. - */ -extern void lto_codegen_add_dso_symbol(lto_code_gen_t cg, const char *symbol); - /** * Writes a new object file at the specified path that contains the * merged contents of all modules added so far. diff --git a/include/llvm/LTO/LTOCodeGenerator.h b/include/llvm/LTO/LTOCodeGenerator.h index 9f50770..97a5066 100644 --- a/include/llvm/LTO/LTOCodeGenerator.h +++ b/include/llvm/LTO/LTOCodeGenerator.h @@ -73,10 +73,6 @@ struct LTOCodeGenerator { void addMustPreserveSymbol(const char *sym) { MustPreserveSymbols[sym] = 1; } - void addDSOSymbol(const char* Sym) { - DSOSymbols[Sym] = 1; - } - // To pass options to the driver and optimization passes. These options are // not necessarily for debugging purpose (The function name is misleading). // This function should be called before LTOCodeGenerator::compilexxx(), @@ -130,7 +126,6 @@ private: void applyScopeRestrictions(); void applyRestriction(llvm::GlobalValue &GV, std::vector &MustPreserveList, - std::vector &SymtabList, llvm::SmallPtrSet &AsmUsed, llvm::Mangler &Mangler); bool determineTarget(std::string &errMsg); @@ -143,7 +138,6 @@ private: bool EmitDwarfDebugInfo; bool ScopeRestrictionsDone; lto_codegen_model CodeModel; - StringSet DSOSymbols; StringSet MustPreserveSymbols; StringSet AsmUndefinedRefs; llvm::MemoryBuffer *NativeObjectFile; diff --git a/include/llvm/Transforms/IPO.h b/include/llvm/Transforms/IPO.h index ed28230..7f51c51 100644 --- a/include/llvm/Transforms/IPO.h +++ b/include/llvm/Transforms/IPO.h @@ -111,25 +111,9 @@ Pass *createPruneEHPass(); /// The symbol in DSOList are internalized if it is safe to drop them from /// the symbol table. /// -/// For example of the difference, consider a dynamic library being built from -/// two translation units. The first one compiled to a native object -/// (ELF/MachO/COFF) and second one compiled to IL. Translation unit A has a -/// copy of linkonce_odr unnamed_addr function F. The translation unit B has a -/// copy of the linkonce_odr unnamed_addr functions F and G. -/// -/// Assume the linker decides to keep the copy of F in B. This means that LLVM -/// must produce F in the object file it passes to the linker, otherwise we -/// will have an undefined reference. For G the situation is different. The -/// linker puts the function in the DSOList, since it is only wanted for the -/// symbol table. With this information internalize can now reason that since -/// the function is a linkonce_odr and its address is not important, it can be -/// omitted. Any other shared library needing this function will have a copy of -/// it. -/// /// Note that commandline options that are used with the above function are not /// used now! -ModulePass *createInternalizePass(ArrayRef ExportList, - ArrayRef DSOList); +ModulePass *createInternalizePass(ArrayRef ExportList); /// createInternalizePass - Same as above, but with an empty exportList. ModulePass *createInternalizePass(); -- cgit v1.1 From 3d74dea4bddc84d1881efc21eb5eefbddbfa9aed Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Thu, 31 Oct 2013 22:11:56 +0000 Subject: Add support for stack map generation in the X86 backend. Originally implemented by Lang Hames. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193811 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/StackMaps.h | 107 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 include/llvm/CodeGen/StackMaps.h (limited to 'include') diff --git a/include/llvm/CodeGen/StackMaps.h b/include/llvm/CodeGen/StackMaps.h new file mode 100644 index 0000000..40eeb2e --- /dev/null +++ b/include/llvm/CodeGen/StackMaps.h @@ -0,0 +1,107 @@ +//===------------------- StackMaps.h - StackMaps ----------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_STACKMAPS +#define LLVM_STACKMAPS + +#include "llvm/ADT/SmallVector.h" +#include "llvm/CodeGen/MachineInstr.h" +#include +#include + +namespace llvm { + +class AsmPrinter; +class MCExpr; + +class StackMaps { +public: + struct Location { + enum LocationType { Unprocessed, Register, Direct, Indirect, Constant, + ConstantIndex }; + LocationType LocType; + unsigned Reg; + int64_t Offset; + Location() : LocType(Unprocessed), Reg(0), Offset(0) {} + Location(LocationType LocType, unsigned Reg, int64_t Offset) + : LocType(LocType), Reg(Reg), Offset(Offset) {} + }; + + // Typedef a function pointer for functions that parse sequences of operands + // and return a Location, plus a new "next" operand iterator. + typedef std::pair + (*OperandParser)(MachineInstr::const_mop_iterator, + MachineInstr::const_mop_iterator); + + // OpTypes are used to encode information about the following logical + // operand (which may consist of several MachineOperands) for the + // OpParser. + typedef enum { DirectMemRefOp, IndirectMemRefOp, ConstantOp } OpType; + + StackMaps(AsmPrinter &AP, OperandParser OpParser) + : AP(AP), OpParser(OpParser) {} + + /// This should be called by the MC lowering code _immediately_ before + /// lowering the MI to an MCInst. It records where the operands for the + /// instruction are stored, and outputs a label to record the offset of + /// the call from the start of the text section. + void recordStackMap(const MachineInstr &MI, uint32_t ID, + MachineInstr::const_mop_iterator MOI, + MachineInstr::const_mop_iterator MOE); + + /// If there is any stack map data, create a stack map section and serialize + /// the map info into it. This clears the stack map data structures + /// afterwards. + void serializeToStackMapSection(); + +private: + + typedef SmallVector LocationVec; + + struct CallsiteInfo { + const MCExpr *CSOffsetExpr; + unsigned ID; + LocationVec Locations; + CallsiteInfo() : CSOffsetExpr(0), ID(0) {} + CallsiteInfo(const MCExpr *CSOffsetExpr, unsigned ID, + LocationVec Locations) + : CSOffsetExpr(CSOffsetExpr), ID(ID), Locations(Locations) {} + }; + + typedef std::vector CallsiteInfoList; + + struct ConstantPool { + private: + typedef std::map ConstantsMap; + std::vector ConstantsList; + ConstantsMap ConstantIndexes; + + public: + size_t getNumConstants() const { return ConstantsList.size(); } + int64_t getConstant(size_t Idx) const { return ConstantsList[Idx]; } + size_t getConstantIndex(int64_t ConstVal) { + size_t NextIdx = ConstantsList.size(); + ConstantsMap::const_iterator I = + ConstantIndexes.insert(ConstantIndexes.end(), + std::make_pair(ConstVal, NextIdx)); + if (I->second == NextIdx) + ConstantsList.push_back(ConstVal); + return I->second; + } + }; + + AsmPrinter &AP; + OperandParser OpParser; + CallsiteInfoList CSInfos; + ConstantPool ConstPool; +}; + +} + +#endif // LLVM_STACKMAPS -- cgit v1.1 From 2ddc56dec8e523cee56d36e2e4c9a1c469e72e1c Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Thu, 31 Oct 2013 22:12:01 +0000 Subject: Add new calling convention for WebKit Java Script. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193812 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/CallingConv.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/CallingConv.h b/include/llvm/IR/CallingConv.h index 585fc5e..35c7df9 100644 --- a/include/llvm/IR/CallingConv.h +++ b/include/llvm/IR/CallingConv.h @@ -51,6 +51,9 @@ namespace CallingConv { // (HiPE). HiPE = 11, + // WebKit JS - Calling convention for stack based JavaScript calls + WebKit_JS = 12, + // Target - This is the start of the target-specific calling conventions, // e.g. fastcall and thiscall on X86. FirstTargetCC = 64, -- cgit v1.1 From 1a035dd6df1d953af57656491eda28ceef9ad4a3 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Thu, 31 Oct 2013 22:36:59 +0000 Subject: [AArch64] Add support for NEON scalar fixed-point convert to floating-point instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193816 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 2dfe02a..8083b86 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -260,4 +260,15 @@ def int_aarch64_neon_vsrid_n : Neon_2Arg_ShiftImm_Intrinsic; // Shift Left And Insert (Immediate) def int_aarch64_neon_vslid_n : Neon_2Arg_ShiftImm_Intrinsic; +// Scalar Signed Fixed-point Convert To Floating-Point (Immediate) +def int_aarch64_neon_vcvtf32_n_s32 : + Intrinsic<[llvm_v1f32_ty], [llvm_v1i32_ty, llvm_i32_ty], [IntrNoMem]>; +def int_aarch64_neon_vcvtf64_n_s64 : + Intrinsic<[llvm_v1f64_ty], [llvm_v1i64_ty, llvm_i32_ty], [IntrNoMem]>; + +// Scalar Unsigned Fixed-point Convert To Floating-Point (Immediate) +def int_aarch64_neon_vcvtf32_n_u32 : + Intrinsic<[llvm_v1f32_ty], [llvm_v1i32_ty, llvm_i32_ty], [IntrNoMem]>; +def int_aarch64_neon_vcvtf64_n_u64 : + Intrinsic<[llvm_v1f64_ty], [llvm_v1i64_ty, llvm_i32_ty], [IntrNoMem]>; } -- cgit v1.1 From 6f45b1f0d689d2cafd3a64be9b548bb8bb0927b0 Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Fri, 1 Nov 2013 00:00:07 +0000 Subject: Add to the disassembler C API output reference types for Objective-C data structures. This is allows tools such as darwin's otool(1) that uses the LLVM disassembler take a pointer value being loaded by an instruction and add a comment to what it is being referenced to make following disassembly of Objective-C programs more readable. For example disassembling the Mac OS X TextEdit app one will see comments like the following: movq 0x20684(%rip), %rsi ## Objc selector ref: standardUserDefaults movq 0x21985(%rip), %rdi ## Objc class ref: _OBJC_CLASS_$_NSUserDefaults movq 0x1d156(%rip), %r14 ## Objc message: +[NSUserDefaults standardUserDefaults] leaq 0x23615(%rip), %rdx ## Objc cfstring ref: @"SelectLinePanel" callq 0x10001386c ## Objc message: -[[%rdi super] initWithWindowNibName:] These diffs also include putting quotes around C strings in literal pools and uses "symbol address" in the comment when adding a symbol name to the comment to tell these types of references apart: leaq 0x4f(%rip), %rax ## literal pool for: "Hello world" movq 0x1c3ea(%rip), %rax ## literal pool symbol address: ___stack_chk_guard Of course the easy changes are in the LLVM disassembler and the hard work is up to the implementer of the SymbolLookUp() call back. rdar://10602439 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193833 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Disassembler.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Disassembler.h b/include/llvm-c/Disassembler.h index 5e0b618..79bcfcd 100644 --- a/include/llvm-c/Disassembler.h +++ b/include/llvm-c/Disassembler.h @@ -130,6 +130,17 @@ typedef const char *(*LLVMSymbolLookupCallback)(void *DisInfo, /* The output reference is to a cstring address in a literal pool. */ #define LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr 3 +/* The output reference is to a Objective-C CoreFoundation string. */ +#define LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref 4 +/* The output reference is to a Objective-C message. */ +#define LLVMDisassembler_ReferenceType_Out_Objc_Message 5 +/* The output reference is to a Objective-C message ref. */ +#define LLVMDisassembler_ReferenceType_Out_Objc_Message_Ref 6 +/* The output reference is to a Objective-C selector ref. */ +#define LLVMDisassembler_ReferenceType_Out_Objc_Selector_Ref 7 +/* The output reference is to a Objective-C class ref. */ +#define LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref 8 + #ifdef __cplusplus extern "C" { #endif /* !defined(__cplusplus) */ -- cgit v1.1 From 19794da02cc48a772ae6f4756b14b111a627170e Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Fri, 1 Nov 2013 17:09:14 +0000 Subject: Remove linkonce_odr_auto_hide. linkonce_odr_auto_hide was in incomplete attempt to implement a way for the linker to hide symbols that are known to be available in every TU and whose addresses are not relevant for a particular DSO. It was redundant in that it all its uses are equivalent to linkonce_odr+unnamed_addr. Unlike those, it has never been connected to clang or llvm's optimizers, so it was effectively dead. Given that nothing produces it, this patch just nukes it (other than the llvm-c enum value). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193865 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 2 +- include/llvm/IR/GlobalValue.h | 12 +----------- 2 files changed, 2 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 004492b..690ffa9 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -274,7 +274,7 @@ typedef enum { LLVMLinkOnceAnyLinkage, /**< Keep one copy of function when linking (inline)*/ LLVMLinkOnceODRLinkage, /**< Same, but only replaced by something equivalent. */ - LLVMLinkOnceODRAutoHideLinkage, /**< Like LinkOnceODR, but possibly hidden. */ + LLVMLinkOnceODRAutoHideLinkage, /**< Obsolete */ LLVMWeakAnyLinkage, /**< Keep one copy of function when linking (weak) */ LLVMWeakODRLinkage, /**< Same, but only replaced by something equivalent. */ diff --git a/include/llvm/IR/GlobalValue.h b/include/llvm/IR/GlobalValue.h index 1dc99cf..4f20a31 100644 --- a/include/llvm/IR/GlobalValue.h +++ b/include/llvm/IR/GlobalValue.h @@ -35,7 +35,6 @@ public: AvailableExternallyLinkage, ///< Available for inspection, not emission. LinkOnceAnyLinkage, ///< Keep one copy of function when linking (inline) LinkOnceODRLinkage, ///< Same, but only replaced by something equivalent. - LinkOnceODRAutoHideLinkage, ///< Like LinkOnceODRLinkage but addr not taken. WeakAnyLinkage, ///< Keep one copy of named function when linking (weak) WeakODRLinkage, ///< Same, but only replaced by something equivalent. AppendingLinkage, ///< Special purpose, only applies to global arrays @@ -123,12 +122,7 @@ public: return Linkage == AvailableExternallyLinkage; } static bool isLinkOnceLinkage(LinkageTypes Linkage) { - return Linkage == LinkOnceAnyLinkage || - Linkage == LinkOnceODRLinkage || - Linkage == LinkOnceODRAutoHideLinkage; - } - static bool isLinkOnceODRAutoHideLinkage(LinkageTypes Linkage) { - return Linkage == LinkOnceODRAutoHideLinkage; + return Linkage == LinkOnceAnyLinkage || Linkage == LinkOnceODRLinkage; } static bool isWeakLinkage(LinkageTypes Linkage) { return Linkage == WeakAnyLinkage || Linkage == WeakODRLinkage; @@ -192,7 +186,6 @@ public: Linkage == WeakODRLinkage || Linkage == LinkOnceAnyLinkage || Linkage == LinkOnceODRLinkage || - Linkage == LinkOnceODRAutoHideLinkage || Linkage == CommonLinkage || Linkage == ExternalWeakLinkage || Linkage == LinkerPrivateWeakLinkage; @@ -205,9 +198,6 @@ public: bool hasLinkOnceLinkage() const { return isLinkOnceLinkage(Linkage); } - bool hasLinkOnceODRAutoHideLinkage() const { - return isLinkOnceODRAutoHideLinkage(Linkage); - } bool hasWeakLinkage() const { return isWeakLinkage(Linkage); } -- cgit v1.1 From daaa8b720b026c83bf6d4307042057665348b222 Mon Sep 17 00:00:00 2001 From: Yuchen Wu Date: Sat, 2 Nov 2013 00:09:17 +0000 Subject: Added command-line option to output llvm-cov to file. Added -o option to llvm-cov. If no output file is specified, it defaults to STDOUT. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193899 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/GCOV.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h index ef1a4eb..d8836e0 100644 --- a/include/llvm/Support/GCOV.h +++ b/include/llvm/Support/GCOV.h @@ -235,7 +235,7 @@ public: LineInfo[Filename][Line-1] += Count; } void setProgramCount(uint32_t PC) { ProgramCount = PC; } - void print(StringRef gcnoFile, StringRef gcdaFile); + void print(raw_fd_ostream &OS, StringRef gcnoFile, StringRef gcdaFile); private: StringMap LineInfo; uint32_t ProgramCount; -- cgit v1.1 From bc884fd9f7bdb64d250be639edc8dc85a20a1975 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Sat, 2 Nov 2013 21:16:09 +0000 Subject: move getSymbolNMTypeChar to the one program that needs it: nm. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193933 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/COFF.h | 1 - include/llvm/Object/ELFObjectFile.h | 77 +------------------------------------ include/llvm/Object/MachO.h | 1 - include/llvm/Object/ObjectFile.h | 9 ----- 4 files changed, 2 insertions(+), 86 deletions(-) (limited to 'include') diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h index 67cc7c6..ec8998c 100644 --- a/include/llvm/Object/COFF.h +++ b/include/llvm/Object/COFF.h @@ -246,7 +246,6 @@ protected: virtual error_code getSymbolFileOffset(DataRefImpl Symb, uint64_t &Res) const; virtual error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res) const; virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const; - virtual error_code getSymbolNMTypeChar(DataRefImpl Symb, char &Res) const; virtual error_code getSymbolFlags(DataRefImpl Symb, uint32_t &Res) const; virtual error_code getSymbolType(DataRefImpl Symb, SymbolRef::Type &Res) const; virtual error_code getSymbolSection(DataRefImpl Symb, diff --git a/include/llvm/Object/ELFObjectFile.h b/include/llvm/Object/ELFObjectFile.h index 31783d4..962a3e2 100644 --- a/include/llvm/Object/ELFObjectFile.h +++ b/include/llvm/Object/ELFObjectFile.h @@ -61,7 +61,6 @@ protected: virtual error_code getSymbolAddress(DataRefImpl Symb, uint64_t &Res) const; virtual error_code getSymbolAlignment(DataRefImpl Symb, uint32_t &Res) const; virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const; - virtual error_code getSymbolNMTypeChar(DataRefImpl Symb, char &Res) const; virtual error_code getSymbolFlags(DataRefImpl Symb, uint32_t &Res) const; virtual error_code getSymbolType(DataRefImpl Symb, SymbolRef::Type &Res) const; @@ -104,8 +103,6 @@ protected: getRelocationValueString(DataRefImpl Rel, SmallVectorImpl &Result) const; -protected: // ELF specific protected members. - const Elf_Sym *getSymbol(DataRefImpl Symb) const; uint64_t getROffset(DataRefImpl Rel) const; StringRef getRelocationTypeName(uint32_t Type) const; @@ -170,6 +167,8 @@ protected: // ELF specific protected members. public: ELFObjectFile(MemoryBuffer *Object, error_code &ec); + const Elf_Sym *getSymbol(DataRefImpl Symb) const; + virtual symbol_iterator begin_symbols() const; virtual symbol_iterator end_symbols() const; @@ -339,78 +338,6 @@ error_code ELFObjectFile::getSymbolSize(DataRefImpl Symb, } template -error_code ELFObjectFile::getSymbolNMTypeChar(DataRefImpl Symb, - char &Result) const { - const Elf_Sym *ESym = getSymbol(Symb); - const Elf_Shdr *ESec = EF.getSection(ESym); - - char ret = '?'; - - if (ESec) { - switch (ESec->sh_type) { - case ELF::SHT_PROGBITS: - case ELF::SHT_DYNAMIC: - switch (ESec->sh_flags) { - case (ELF::SHF_ALLOC | ELF::SHF_EXECINSTR): - ret = 't'; - break; - case (ELF::SHF_ALLOC | ELF::SHF_WRITE): - ret = 'd'; - break; - case ELF::SHF_ALLOC: - case (ELF::SHF_ALLOC | ELF::SHF_MERGE): - case (ELF::SHF_ALLOC | ELF::SHF_MERGE | ELF::SHF_STRINGS): - ret = 'r'; - break; - } - break; - case ELF::SHT_NOBITS: - ret = 'b'; - } - } - - switch (EF.getSymbolTableIndex(ESym)) { - case ELF::SHN_UNDEF: - if (ret == '?') - ret = 'U'; - break; - case ELF::SHN_ABS: - ret = 'a'; - break; - case ELF::SHN_COMMON: - ret = 'c'; - break; - } - - switch (ESym->getBinding()) { - case ELF::STB_GLOBAL: - ret = ::toupper(ret); - break; - case ELF::STB_WEAK: - if (EF.getSymbolTableIndex(ESym) == ELF::SHN_UNDEF) - ret = 'w'; - else if (ESym->getType() == ELF::STT_OBJECT) - ret = 'V'; - else - ret = 'W'; - } - - if (ret == '?' && ESym->getType() == ELF::STT_SECTION) { - ErrorOr Name = EF.getSymbolName(toELFSymIter(Symb)); - if (!Name) - return Name; - Result = StringSwitch(*Name) - .StartsWith(".debug", 'N') - .StartsWith(".note", 'n') - .Default('?'); - return object_error::success; - } - - Result = ret; - return object_error::success; -} - -template error_code ELFObjectFile::getSymbolType(DataRefImpl Symb, SymbolRef::Type &Result) const { const Elf_Sym *ESym = getSymbol(Symb); diff --git a/include/llvm/Object/MachO.h b/include/llvm/Object/MachO.h index e91c260..100613a 100644 --- a/include/llvm/Object/MachO.h +++ b/include/llvm/Object/MachO.h @@ -67,7 +67,6 @@ public: virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const; virtual error_code getSymbolType(DataRefImpl Symb, SymbolRef::Type &Res) const; - virtual error_code getSymbolNMTypeChar(DataRefImpl Symb, char &Res) const; virtual error_code getSymbolFlags(DataRefImpl Symb, uint32_t &Res) const; virtual error_code getSymbolSection(DataRefImpl Symb, section_iterator &Res) const; diff --git a/include/llvm/Object/ObjectFile.h b/include/llvm/Object/ObjectFile.h index 0ba4952..9aea639 100644 --- a/include/llvm/Object/ObjectFile.h +++ b/include/llvm/Object/ObjectFile.h @@ -221,10 +221,6 @@ public: error_code getSize(uint64_t &Result) const; error_code getType(SymbolRef::Type &Result) const; - /// Returns the ascii char that should be displayed in a symbol table dump via - /// nm for this symbol. - error_code getNMTypeChar(char &Result) const; - /// Get symbol flags (bitwise OR of SymbolRef::Flags) error_code getFlags(uint32_t &Result) const; @@ -296,7 +292,6 @@ protected: virtual error_code getSymbolSize(DataRefImpl Symb, uint64_t &Res) const = 0; virtual error_code getSymbolType(DataRefImpl Symb, SymbolRef::Type &Res) const = 0; - virtual error_code getSymbolNMTypeChar(DataRefImpl Symb, char &Res) const = 0; virtual error_code getSymbolFlags(DataRefImpl Symb, uint32_t &Res) const = 0; virtual error_code getSymbolSection(DataRefImpl Symb, @@ -431,10 +426,6 @@ inline error_code SymbolRef::getSize(uint64_t &Result) const { return OwningObject->getSymbolSize(SymbolPimpl, Result); } -inline error_code SymbolRef::getNMTypeChar(char &Result) const { - return OwningObject->getSymbolNMTypeChar(SymbolPimpl, Result); -} - inline error_code SymbolRef::getFlags(uint32_t &Result) const { return OwningObject->getSymbolFlags(SymbolPimpl, Result); } -- cgit v1.1 From 35a1e9414d48f52093679b4723578192cceeb3c5 Mon Sep 17 00:00:00 2001 From: Filip Pizlo Date: Sun, 3 Nov 2013 00:29:47 +0000 Subject: When LLVM is embedded in a larger application, it's not OK for LLVM to intercept crashes. LLVM already has the ability to disable this functionality. This patch exposes it via the C API. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193937 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 690ffa9..47d566c 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -434,6 +434,12 @@ void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler); void LLVMResetFatalErrorHandler(void); /** + * Disable LLVM's built-in stack trace code. This must be called before any + * other LLVM APIs; otherwise the results are undefined. + */ +void LLVMDisablePrettyStackTrace(void); + +/** * @defgroup LLVMCCoreContext Contexts * * Contexts are execution states for the core LLVM IR system. -- cgit v1.1 From 153d6191c9c5e15aa22bf2eae14463fd43454609 Mon Sep 17 00:00:00 2001 From: Filip Pizlo Date: Sun, 3 Nov 2013 04:38:31 +0000 Subject: Add a comment to note that LLVMDisablePrettyStackTrace() is likely not a good long-term solution. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193939 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 47d566c..88204ef 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -436,6 +436,9 @@ void LLVMResetFatalErrorHandler(void); /** * Disable LLVM's built-in stack trace code. This must be called before any * other LLVM APIs; otherwise the results are undefined. + * + * FIXME: This API should be replaced by a LLVMEnablePrettyStackTrace() + * function; the default should be that pretty stack traces are disabled. */ void LLVMDisablePrettyStackTrace(void); -- cgit v1.1 From 208130f11331eccab26c0a6f3146cd1891e53e33 Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Sun, 3 Nov 2013 06:48:38 +0000 Subject: Convert calls to __sinpi and __cospi into __sincospi_stret This adds an SimplifyLibCalls case which converts the special __sinpi and __cospi (float & double variants) into a __sincospi_stret where appropriate to remove duplicated work. Patch by Tim Northover git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193943 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLibraryInfo.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/llvm/Target/TargetLibraryInfo.h b/include/llvm/Target/TargetLibraryInfo.h index 9111cb1..46eaef2 100644 --- a/include/llvm/Target/TargetLibraryInfo.h +++ b/include/llvm/Target/TargetLibraryInfo.h @@ -46,6 +46,10 @@ namespace llvm { Znwm, /// void *new(unsigned long, nothrow); ZnwmRKSt9nothrow_t, + /// double __cospi(double x); + cospi, + /// float __cospif(float x); + cospif, /// int __cxa_atexit(void (*f)(void *), void *p, void *d); cxa_atexit, /// void __cxa_guard_abort(guard_t *guard); @@ -61,6 +65,14 @@ namespace llvm { dunder_isoc99_sscanf, /// void *__memcpy_chk(void *s1, const void *s2, size_t n, size_t s1size); memcpy_chk, + /// double __sincospi_stret(double x); + sincospi_stret, + /// float __sincospi_stretf(float x); + sincospi_stretf, + /// double __sinpi(double x); + sinpi, + /// float __sinpif(float x); + sinpif, /// double __sqrt_finite(double x); sqrt_finite, /// float __sqrt_finite(float x); -- cgit v1.1 From 633f98bdfa266871dcd17ab27af1594c6cc31d9e Mon Sep 17 00:00:00 2001 From: Elena Demikhovsky Date: Sun, 3 Nov 2013 13:46:31 +0000 Subject: AVX-512: added VPCONFLICT instruction and intrinsics, added EVEX_KZ to tablegen git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193959 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index c24fb06..07e4681 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -2995,6 +2995,34 @@ let TargetPrefix = "x86" in { []>; } +// AVX-512 conflict detection +let TargetPrefix = "x86" in { + def int_x86_avx512_conflict_d_512 : GCCBuiltin<"__builtin_ia32_condlictd512">, + Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty], + []>; + def int_x86_avx512_conflict_d_mask_512 : + GCCBuiltin<"__builtin_ia32_mask_condlictd512">, + Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, + llvm_v16i1_ty, llvm_v16i32_ty], + []>; + def int_x86_avx512_conflict_d_maskz_512: + GCCBuiltin<"__builtin_ia32_maskz_condlictd512">, + Intrinsic<[llvm_v16i32_ty], [llvm_v16i1_ty, llvm_v16i32_ty], + []>; + + def int_x86_avx512_conflict_q_512 : GCCBuiltin<"__builtin_ia32_condlictq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty], + []>; + def int_x86_avx512_conflict_q_mask_512 : + GCCBuiltin<"__builtin_ia32_mask_condlictq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, + llvm_v8i1_ty, llvm_v8i64_ty], + []>; + def int_x86_avx512_conflict_q_maskz_512: + GCCBuiltin<"__builtin_ia32_maskz_condlictq512">, + Intrinsic<[llvm_v8i64_ty], [llvm_v8i1_ty, llvm_v8i64_ty], + []>; +} // Misc. let TargetPrefix = "x86" in { def int_x86_avx512_mskblend_ps_512 : GCCBuiltin<"__builtin_ia32_mskblendps512">, -- cgit v1.1 From fa0da86a59c502bfbfa01d3d5f694f18f6e8a717 Mon Sep 17 00:00:00 2001 From: Filip Pizlo Date: Mon, 4 Nov 2013 02:22:25 +0000 Subject: Make the pretty stack trace be an opt-in, rather than opt-out, facility. Enable pretty stack traces by default if you use PrettyStackTraceProgram, so that existing LLVM-based tools will continue to get it without any changes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193971 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 10 ++++------ include/llvm/Support/PrettyStackTrace.h | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 88204ef..e18c77c 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -434,13 +434,11 @@ void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler); void LLVMResetFatalErrorHandler(void); /** - * Disable LLVM's built-in stack trace code. This must be called before any - * other LLVM APIs; otherwise the results are undefined. - * - * FIXME: This API should be replaced by a LLVMEnablePrettyStackTrace() - * function; the default should be that pretty stack traces are disabled. + * Enable LLVM's built-in stack trace code. This intercepts the OS's crash + * signals and prints which component of LLVM you were in at the time if the + * crash. */ -void LLVMDisablePrettyStackTrace(void); +void LLVMEnablePrettyStackTrace(void); /** * @defgroup LLVMCCoreContext Contexts diff --git a/include/llvm/Support/PrettyStackTrace.h b/include/llvm/Support/PrettyStackTrace.h index 2122e06..4f68fca 100644 --- a/include/llvm/Support/PrettyStackTrace.h +++ b/include/llvm/Support/PrettyStackTrace.h @@ -21,11 +21,7 @@ namespace llvm { class raw_ostream; - /// DisablePrettyStackTrace - Set this to true to disable this module. This - /// might be necessary if the host application installs its own signal - /// handlers which conflict with the ones installed by this module. - /// Defaults to false. - extern bool DisablePrettyStackTrace; + void EnablePrettyStackTrace(); /// PrettyStackTraceEntry - This class is used to represent a frame of the /// "pretty" stack trace that is dumped when a program crashes. You can define @@ -64,7 +60,9 @@ namespace llvm { const char *const *ArgV; public: PrettyStackTraceProgram(int argc, const char * const*argv) - : ArgC(argc), ArgV(argv) {} + : ArgC(argc), ArgV(argv) { + EnablePrettyStackTrace(); + } virtual void print(raw_ostream &OS) const LLVM_OVERRIDE; }; -- cgit v1.1 From 6a907f8c7d6b440bbadaa9aaafb03b489673ae1f Mon Sep 17 00:00:00 2001 From: Elena Demikhovsky Date: Mon, 4 Nov 2013 11:48:23 +0000 Subject: AVX-512: fixed a typo in builtin name git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193988 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index 07e4681..4eee0ac 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -2997,29 +2997,29 @@ let TargetPrefix = "x86" in { // AVX-512 conflict detection let TargetPrefix = "x86" in { - def int_x86_avx512_conflict_d_512 : GCCBuiltin<"__builtin_ia32_condlictd512">, + def int_x86_avx512_conflict_d_512 : GCCBuiltin<"__builtin_ia32_conflictd512">, Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty], []>; def int_x86_avx512_conflict_d_mask_512 : - GCCBuiltin<"__builtin_ia32_mask_condlictd512">, + GCCBuiltin<"__builtin_ia32_mask_conflictd512">, Intrinsic<[llvm_v16i32_ty], [llvm_v16i32_ty, llvm_v16i1_ty, llvm_v16i32_ty], []>; def int_x86_avx512_conflict_d_maskz_512: - GCCBuiltin<"__builtin_ia32_maskz_condlictd512">, + GCCBuiltin<"__builtin_ia32_maskz_conflictd512">, Intrinsic<[llvm_v16i32_ty], [llvm_v16i1_ty, llvm_v16i32_ty], []>; - def int_x86_avx512_conflict_q_512 : GCCBuiltin<"__builtin_ia32_condlictq512">, + def int_x86_avx512_conflict_q_512 : GCCBuiltin<"__builtin_ia32_conflictq512">, Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty], []>; def int_x86_avx512_conflict_q_mask_512 : - GCCBuiltin<"__builtin_ia32_mask_condlictq512">, + GCCBuiltin<"__builtin_ia32_mask_conflictq512">, Intrinsic<[llvm_v8i64_ty], [llvm_v8i64_ty, llvm_v8i1_ty, llvm_v8i64_ty], []>; def int_x86_avx512_conflict_q_maskz_512: - GCCBuiltin<"__builtin_ia32_maskz_condlictq512">, + GCCBuiltin<"__builtin_ia32_maskz_conflictq512">, Intrinsic<[llvm_v8i64_ty], [llvm_v8i1_ty, llvm_v8i64_ty], []>; } -- cgit v1.1 From 5c042162beb3c2dd556e00aab84c4278a69cd5b1 Mon Sep 17 00:00:00 2001 From: Zoran Jovanovic Date: Mon, 4 Nov 2013 14:53:22 +0000 Subject: Support for microMIPS branch instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193992 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/ELF.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/Support/ELF.h b/include/llvm/Support/ELF.h index 5034f8b..797c211 100644 --- a/include/llvm/Support/ELF.h +++ b/include/llvm/Support/ELF.h @@ -885,6 +885,7 @@ enum { 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, -- cgit v1.1 From 2e58f1d4cf95e44674cbc4975e713f9293255d5f Mon Sep 17 00:00:00 2001 From: Cameron McInally Date: Mon, 4 Nov 2013 19:14:56 +0000 Subject: Add support for AVX512 masked vector blend intrinsics. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194006 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index 4eee0ac..1fe1c91 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -3023,12 +3023,30 @@ let TargetPrefix = "x86" in { Intrinsic<[llvm_v8i64_ty], [llvm_v8i1_ty, llvm_v8i64_ty], []>; } -// Misc. -let TargetPrefix = "x86" in { + +// Vector blend +let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx512_mskblend_ps_512 : GCCBuiltin<"__builtin_ia32_mskblendps512">, Intrinsic<[llvm_v16f32_ty], - [llvm_i16_ty, llvm_v16f32_ty, llvm_v16f32_ty], + [llvm_v16i1_ty, llvm_v16f32_ty, llvm_v16f32_ty], + [IntrNoMem]>; + def int_x86_avx512_mskblend_pd_512 : GCCBuiltin<"__builtin_ia32_mskblendpd512">, + Intrinsic<[llvm_v8f64_ty], + [llvm_v8i1_ty, llvm_v8f64_ty, llvm_v8f64_ty], [IntrNoMem]>; + + def int_x86_avx512_mskblend_d_512 : GCCBuiltin<"__builtin_ia32_mskblendd512">, + Intrinsic<[llvm_v16i32_ty], + [llvm_v16i1_ty, llvm_v16i32_ty, llvm_v16i32_ty], + [IntrNoMem]>; + def int_x86_avx512_mskblend_q_512 : GCCBuiltin<"__builtin_ia32_mskblendq512">, + Intrinsic<[llvm_v8i64_ty], + [llvm_v8i1_ty, llvm_v8i64_ty, llvm_v8i64_ty], + [IntrNoMem]>; +} + +// Misc. +let TargetPrefix = "x86" in { def int_x86_avx512_cmpeq_pi_512 : GCCBuiltin<"__builtin_ia32_cmpeqpi512">, Intrinsic<[llvm_i16_ty], [llvm_v16i32_ty, llvm_v16i32_ty], [IntrNoMem]>; -- cgit v1.1 From c88eb08d02f0aa17352e06c4e235bc1f225b2266 Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Tue, 5 Nov 2013 00:08:03 +0000 Subject: Add a runtime unrolling parameter to the LoopUnroll pass constructor As with the other loop unrolling parameters (the unrolling threshold, partial unrolling, etc.) runtime unrolling can now also be controlled via the constructor. This will be necessary for moving non-trivial unrolling late in the pass manager (after loop vectorization). No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194027 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/Scalar.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Transforms/Scalar.h b/include/llvm/Transforms/Scalar.h index 51aeba4..65b8344 100644 --- a/include/llvm/Transforms/Scalar.h +++ b/include/llvm/Transforms/Scalar.h @@ -138,7 +138,8 @@ Pass *createLoopInstSimplifyPass(); // // LoopUnroll - This pass is a simple loop unrolling pass. // -Pass *createLoopUnrollPass(int Threshold = -1, int Count = -1, int AllowPartial = -1); +Pass *createLoopUnrollPass(int Threshold = -1, int Count = -1, + int AllowPartial = -1, int Runtime = -1); //===----------------------------------------------------------------------===// // -- cgit v1.1 From f94b3480fce38b376d02fb0775b9448bbda9313b Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 5 Nov 2013 00:28:01 +0000 Subject: Simplify ErrorOr. ErrorOr had quiet a bit of complexity and indirection to be able to hold a user type with the error. That feature is not used anymore. This patch removes it, it will live in svn history if we ever need it again. If we do need it again, IMHO there is one thing that should be done differently: Holding extra info in the error is not a property a function also returning a value or not. The ability to hold extra info should be in the error type and ErrorOr templated over it so that we don't need the funny looking ErrorOr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194030 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/ErrorOr.h | 219 +---------------------------------------- 1 file changed, 5 insertions(+), 214 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/ErrorOr.h b/include/llvm/Support/ErrorOr.h index 6832e3d..148494c 100644 --- a/include/llvm/Support/ErrorOr.h +++ b/include/llvm/Support/ErrorOr.h @@ -27,38 +27,6 @@ #endif namespace llvm { -struct ErrorHolderBase { - error_code Error; - uint16_t RefCount; - bool HasUserData; - - ErrorHolderBase() : RefCount(1) {} - - void acquire() { - ++RefCount; - } - - void release() { - if (--RefCount == 0) - delete this; - } - -protected: - virtual ~ErrorHolderBase() {} -}; - -template -struct ErrorHolder : ErrorHolderBase { -#if LLVM_HAS_RVALUE_REFERENCES - ErrorHolder(T &&UD) : UserData(llvm_move(UD)) {} -#else - ErrorHolder(T &UD) : UserData(UD) {} -#endif - T UserData; -}; - -template struct ErrorOrUserDataTraits : llvm::false_type {}; - #if LLVM_HAS_CXX11_TYPETRAITS && LLVM_HAS_RVALUE_REFERENCES template typename std::enable_if< std::is_constructible::value @@ -111,44 +79,6 @@ public: /// buffer->write("adena"); /// \endcode /// -/// ErrorOr also supports user defined data for specific error_codes. To use -/// this feature you must first add a template specialization of -/// ErrorOrUserDataTraits derived from std::true_type for your type in the lld -/// namespace. This specialization must have a static error_code error() -/// function that returns the error_code this data is used with. -/// -/// getError() may be called to get either the stored user data, or -/// a default constructed UserData if none was stored. -/// -/// Example: -/// \code -/// struct InvalidArgError { -/// InvalidArgError() {} -/// InvalidArgError(std::string S) : ArgName(S) {} -/// std::string ArgName; -/// }; -/// -/// namespace llvm { -/// template<> -/// struct ErrorOrUserDataTraits : std::true_type { -/// static error_code error() { -/// return make_error_code(errc::invalid_argument); -/// } -/// }; -/// } // end namespace llvm -/// -/// using namespace llvm; -/// -/// ErrorOr foo() { -/// return InvalidArgError("adena"); -/// } -/// -/// int main() { -/// auto a = foo(); -/// if (!a && error_code(a) == errc::invalid_argument) -/// llvm::errs() << a.getError().ArgName << "\n"; -/// } -/// \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 @@ -185,24 +115,11 @@ public: is_error_condition_enum::value, void *>::type = 0) : HasError(true), IsValid(true) { - Error = new ErrorHolderBase; - Error->Error = make_error_code(ErrorCode); - Error->HasUserData = false; + Error = make_error_code(ErrorCode); } ErrorOr(llvm::error_code EC) : HasError(true), IsValid(true) { - Error = new ErrorHolderBase; - Error->Error = EC; - Error->HasUserData = false; - } - - template - ErrorOr(UserDataT UD, typename - enable_if_c::value>::type* = 0) - : HasError(true), IsValid(true) { - Error = new ErrorHolder(llvm_move(UD)); - Error->Error = ErrorOrUserDataTraits::error(); - Error->HasUserData = true; + Error = EC; } ErrorOr(T Val) : HasError(false), IsValid(true) { @@ -254,23 +171,10 @@ public: ~ErrorOr() { if (!IsValid) return; - if (HasError) - Error->release(); - else + if (!HasError) get()->~storage_type(); } - template - ET getError() const { - assert(IsValid && "Cannot get the error of a default constructed ErrorOr!"); - assert(HasError && "Cannot get an error if none exists!"); - assert(ErrorOrUserDataTraits::error() == Error->Error && - "Incorrect user error data type for error!"); - if (!Error->HasUserData) - return ET(); - return reinterpret_cast*>(Error)->UserData; - } - typedef void (*unspecified_bool_type)(); static void unspecified_bool_true() {} @@ -282,7 +186,7 @@ public: operator llvm::error_code() const { assert(IsValid && "Can't do anything on a default constructed ErrorOr!"); - return HasError ? Error->Error : llvm::error_code::success(); + return HasError ? Error : llvm::error_code::success(); } pointer operator ->() { @@ -308,7 +212,6 @@ private: // Get other's error. Error = Other.Error; HasError = true; - Error->acquire(); } } @@ -385,124 +288,12 @@ private: union { AlignedCharArrayUnion TStorage; - ErrorHolderBase *Error; + error_code Error; }; bool HasError : 1; bool IsValid : 1; }; -// ErrorOr specialization for void. -template <> -class ErrorOr { -public: - ErrorOr() : Error(0, 0) {} - - template - ErrorOr(E ErrorCode, typename enable_if_c::value || - is_error_condition_enum::value, - void *> ::type = 0) - : Error(0, 0) { - error_code EC = make_error_code(ErrorCode); - if (EC == errc::success) { - Error.setInt(1); - return; - } - ErrorHolderBase *EHB = new ErrorHolderBase; - EHB->Error = EC; - EHB->HasUserData = false; - Error.setPointer(EHB); - } - - ErrorOr(llvm::error_code EC) : Error(0, 0) { - if (EC == errc::success) { - Error.setInt(1); - return; - } - ErrorHolderBase *E = new ErrorHolderBase; - E->Error = EC; - E->HasUserData = false; - Error.setPointer(E); - } - - template - ErrorOr(UserDataT UD, typename - enable_if_c::value>::type* = 0) - : Error(0, 0) { - ErrorHolderBase *E = new ErrorHolder(llvm_move(UD)); - E->Error = ErrorOrUserDataTraits::error(); - E->HasUserData = true; - Error.setPointer(E); - } - - ErrorOr(const ErrorOr &Other) : Error(0, 0) { - Error = Other.Error; - if (Other.Error.getPointer()->Error) { - Error.getPointer()->acquire(); - } - } - - ErrorOr &operator =(const ErrorOr &Other) { - if (this == &Other) - return *this; - - this->~ErrorOr(); - new (this) ErrorOr(Other); - - return *this; - } - -#if LLVM_HAS_RVALUE_REFERENCES - ErrorOr(ErrorOr &&Other) : Error(0) { - // Get other's error. - Error = Other.Error; - // Tell other not to do any destruction. - Other.Error.setPointer(0); - } - - ErrorOr &operator =(ErrorOr &&Other) { - if (this == &Other) - return *this; - - this->~ErrorOr(); - new (this) ErrorOr(std::move(Other)); - - return *this; - } -#endif - - ~ErrorOr() { - if (Error.getPointer()) - Error.getPointer()->release(); - } - - template - ET getError() const { - assert(ErrorOrUserDataTraits::error() == *this && - "Incorrect user error data type for error!"); - if (!Error.getPointer()->HasUserData) - return ET(); - return reinterpret_cast *>( - Error.getPointer())->UserData; - } - - typedef void (*unspecified_bool_type)(); - static void unspecified_bool_true() {} - - /// \brief Return false if there is an error. - operator unspecified_bool_type() const { - return Error.getInt() ? unspecified_bool_true : 0; - } - - operator llvm::error_code() const { - return Error.getInt() ? make_error_code(errc::success) - : Error.getPointer()->Error; - } - -private: - // If the bit is 1, the error is success. - llvm::PointerIntPair Error; -}; - template typename enable_if_c::value || is_error_condition_enum::value, bool>::type -- cgit v1.1 From 23c8d2bf861ac0984da0b214fa08090abcba1869 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 5 Nov 2013 01:07:06 +0000 Subject: Fix MSVC build by not putting an error_code directly in a union. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194032 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/ErrorOr.h | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/ErrorOr.h b/include/llvm/Support/ErrorOr.h index 148494c..0fdafa0 100644 --- a/include/llvm/Support/ErrorOr.h +++ b/include/llvm/Support/ErrorOr.h @@ -115,11 +115,11 @@ public: is_error_condition_enum::value, void *>::type = 0) : HasError(true), IsValid(true) { - Error = make_error_code(ErrorCode); + new (getError()) error_code(make_error_code(ErrorCode)); } ErrorOr(llvm::error_code EC) : HasError(true), IsValid(true) { - Error = EC; + new (getError()) error_code(EC); } ErrorOr(T Val) : HasError(false), IsValid(true) { @@ -186,7 +186,7 @@ public: operator llvm::error_code() const { assert(IsValid && "Can't do anything on a default constructed ErrorOr!"); - return HasError ? Error : llvm::error_code::success(); + return HasError ? *getError() : llvm::error_code::success(); } pointer operator ->() { @@ -210,8 +210,8 @@ private: new (get()) storage_type(*Other.get()); } else { // Get other's error. - Error = Other.Error; HasError = true; + new (getError()) error_code(Other); } } @@ -249,8 +249,8 @@ private: Other.IsValid = false; } else { // Get other's error. - Error = Other.Error; HasError = true; + new (getError()) error_code(Other); // Tell other not to do any destruction. Other.IsValid = false; } @@ -286,9 +286,20 @@ private: return reinterpret_cast(TStorage.buffer); } + error_code *getError() { + assert(IsValid && "Can't do anything on a default constructed ErrorOr!"); + assert(HasError && "Cannot get error when a value exists!"); + return reinterpret_cast(ErrorStorage.buffer); + } + + const error_code *getError() const { + return const_cast *>(this)->getError(); + } + + union { AlignedCharArrayUnion TStorage; - error_code Error; + AlignedCharArrayUnion ErrorStorage; }; bool HasError : 1; bool IsValid : 1; -- cgit v1.1 From e85959cb2cb6f82959b3cf1a9ef59c6d793a2556 Mon Sep 17 00:00:00 2001 From: Yuchen Wu Date: Tue, 5 Nov 2013 01:11:58 +0000 Subject: Support for reading run counts in llvm-cov. This patch enables llvm-cov to correctly output the run count stored in the GCDA file. GCOVProfiling currently does not generate this information, so the GCDA run data had to be hacked on from a GCDA file generated by gcc. This is corrected by a subsequent patch. With the run and program data included, both llvm-cov and gcov produced the same output. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194033 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/GCOV.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h index d8836e0..ccc7c6e 100644 --- a/include/llvm/Support/GCOV.h +++ b/include/llvm/Support/GCOV.h @@ -126,6 +126,19 @@ public: return true; } + /// readObjectTag - If cursor points to an object summary tag then increment + /// the cursor and return true otherwise return false. + bool readObjectTag() { + StringRef Tag = Buffer->getBuffer().slice(Cursor, Cursor+4); + if (Tag.empty() || + Tag[0] != '\0' || Tag[1] != '\0' || + Tag[2] != '\0' || Tag[3] != '\xa1') { + return false; + } + Cursor += 4; + return true; + } + /// readProgramTag - If cursor points to a program summary tag then increment /// the cursor and return true otherwise return false. bool readProgramTag() { @@ -163,6 +176,7 @@ public: } uint64_t getCursor() const { return Cursor; } + void advanceCursor(uint32_t n) { Cursor += n*4; } private: MemoryBuffer *Buffer; uint64_t Cursor; @@ -172,13 +186,14 @@ private: /// (.gcno and .gcda). class GCOVFile { public: - GCOVFile() : Functions(), ProgramCount(0) {} + GCOVFile() : Functions(), RunCount(0), ProgramCount(0) {} ~GCOVFile(); bool read(GCOVBuffer &Buffer); void dump(); void collectLineCounts(FileInfo &FI); private: SmallVector Functions; + uint32_t RunCount; uint32_t ProgramCount; }; @@ -234,10 +249,12 @@ public: void addLineCount(StringRef Filename, uint32_t Line, uint64_t Count) { LineInfo[Filename][Line-1] += Count; } - void setProgramCount(uint32_t PC) { ProgramCount = PC; } + void setRunCount(uint32_t Runs) { RunCount = Runs; } + void setProgramCount(uint32_t Programs) { ProgramCount = Programs; } void print(raw_fd_ostream &OS, StringRef gcnoFile, StringRef gcdaFile); private: StringMap LineInfo; + uint32_t RunCount; uint32_t ProgramCount; }; -- cgit v1.1 From ddfc20dea4dbd3e9fea354696f8ed50d4f01eef8 Mon Sep 17 00:00:00 2001 From: Alp Toker Date: Tue, 5 Nov 2013 07:27:18 +0000 Subject: Fix symbol defines in config.h.cmake These were incorrectly pointing to HAVE_LOG despite being checked for correctly in config-ix.cmake. Patch by James Lyon! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194051 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Config/config.h.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake index 4c49cbb..5c72ad8 100644 --- a/include/llvm/Config/config.h.cmake +++ b/include/llvm/Config/config.h.cmake @@ -129,13 +129,13 @@ #cmakedefine HAVE_LOG10 ${HAVE_LOG10} /* Define to 1 if you have the `exp' function. */ -#cmakedefine HAVE_EXP ${HAVE_LOG} +#cmakedefine HAVE_EXP ${HAVE_EXP} /* Define to 1 if you have the `exp2' function. */ -#cmakedefine HAVE_EXP2 ${HAVE_LOG2} +#cmakedefine HAVE_EXP2 ${HAVE_EXP2} /* Define to 1 if you have the `exp10' function. */ -#cmakedefine HAVE_EXP10 ${HAVE_LOG10} +#cmakedefine HAVE_EXP10 ${HAVE_EXP10} /* Define to 1 if you have the `fmodf' function. */ #cmakedefine HAVE_FMODF ${HAVE_FMODF} -- cgit v1.1 From 0fac3dfa4153dc6064d299fe0a0933630ae3f840 Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Tue, 5 Nov 2013 12:55:37 +0000 Subject: [llvm-c] (PR16190) Add LLVMIsA* functions for ConstantDataSequential and subclasses Original patch by David Monniaux git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194074 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index e18c77c..89ddf41 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -1110,6 +1110,9 @@ LLVMTypeRef LLVMX86MMXType(void); macro(BlockAddress) \ macro(ConstantAggregateZero) \ macro(ConstantArray) \ + macro(ConstantDataSequential) \ + macro(ConstantDataArray) \ + macro(ConstantDataVector) \ macro(ConstantExpr) \ macro(ConstantFP) \ macro(ConstantInt) \ -- cgit v1.1 From 3ff3a8aa7511bede13e836303a083af37fec4f4e Mon Sep 17 00:00:00 2001 From: Jiangning Liu Date: Tue, 5 Nov 2013 17:42:05 +0000 Subject: Implement AArch64 Neon Crypto instruction classes AES, SHA, and 3 SHA. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194085 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 8083b86..b66bdcc 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -271,4 +271,12 @@ def int_aarch64_neon_vcvtf32_n_u32 : Intrinsic<[llvm_v1f32_ty], [llvm_v1i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_aarch64_neon_vcvtf64_n_u64 : Intrinsic<[llvm_v1f64_ty], [llvm_v1i64_ty, llvm_i32_ty], [IntrNoMem]>; + +class Neon_SHA_Intrinsic + : Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v1i32_ty, llvm_v4i32_ty], + [IntrNoMem]>; + +def int_aarch64_neon_sha1c : Neon_SHA_Intrinsic; +def int_aarch64_neon_sha1m : Neon_SHA_Intrinsic; +def int_aarch64_neon_sha1p : Neon_SHA_Intrinsic; } -- cgit v1.1 From af9e8e60ae5118066e49730ae5a96aadf3a8f624 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 5 Nov 2013 19:36:34 +0000 Subject: Use error_code in GVMaterializer. They just propagate out the bitcode reader error, so we don't need a new enum. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194091 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/GVMaterializer.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/llvm/GVMaterializer.h b/include/llvm/GVMaterializer.h index 1e5c426..8efe50a 100644 --- a/include/llvm/GVMaterializer.h +++ b/include/llvm/GVMaterializer.h @@ -18,7 +18,7 @@ #ifndef LLVM_GVMATERIALIZER_H #define LLVM_GVMATERIALIZER_H -#include +#include "llvm/Support/system_error.h" namespace llvm { @@ -41,11 +41,9 @@ public: /// dematerialized back to whatever backing store this GVMaterializer uses. virtual bool isDematerializable(const GlobalValue *GV) const = 0; - /// Materialize - make sure the given GlobalValue is fully read. If the - /// module is corrupt, this returns true and fills in the optional string with - /// information about the problem. If successful, this returns false. + /// Materialize - make sure the given GlobalValue is fully read. /// - virtual bool Materialize(GlobalValue *GV, std::string *ErrInfo = 0) = 0; + virtual error_code Materialize(GlobalValue *GV) = 0; /// Dematerialize - If the given GlobalValue is read in, and if the /// GVMaterializer supports it, release the memory for the GV, and set it up @@ -55,10 +53,8 @@ public: virtual void Dematerialize(GlobalValue *) {} /// MaterializeModule - make sure the entire Module has been completely read. - /// On error, this returns true and fills in the optional string with - /// information about the problem. If successful, this returns false. /// - virtual bool MaterializeModule(Module *M, std::string *ErrInfo = 0) = 0; + virtual error_code MaterializeModule(Module *M) = 0; }; } // End llvm namespace -- cgit v1.1 From 5f5095e3dce0386658481353d93c11ca6123bb95 Mon Sep 17 00:00:00 2001 From: Dmitri Gribenko Date: Tue, 5 Nov 2013 21:28:42 +0000 Subject: Convert comments to documentation comments (// -> ///) Patch by MathOnNapkins git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194093 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLowering.h | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 43052e1..6944f73 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -148,9 +148,10 @@ public: bool isBigEndian() const { return !IsLittleEndian; } bool isLittleEndian() const { return IsLittleEndian; } - // Return the pointer type for the given address space, defaults to - // the pointer type from the data layout. - // FIXME: The default needs to be removed once all the code is updated. + + /// Return the pointer type for the given address space, defaults to + /// the pointer type from the data layout. + /// FIXME: The default needs to be removed once all the code is updated. virtual MVT getPointerTy(uint32_t /*AS*/ = 0) const; unsigned getPointerSizeInBits(uint32_t AS = 0) const; unsigned getPointerTypeSizeInBits(Type *Ty) const; @@ -2251,12 +2252,12 @@ public: // Instruction Emitting Hooks // - // This method should be implemented by targets that mark instructions with - // the 'usesCustomInserter' flag. These instructions are special in various - // ways, which require special support to insert. The specified MachineInstr - // is created but not inserted into any basic blocks, and this method is - // called to expand it into a sequence of instructions, potentially also - // creating new basic blocks and control flow. + /// This method should be implemented by targets that mark instructions with + /// the 'usesCustomInserter' flag. These instructions are special in various + /// ways, which require special support to insert. The specified MachineInstr + /// is created but not inserted into any basic blocks, and this method is + /// called to expand it into a sequence of instructions, potentially also + /// creating new basic blocks and control flow. virtual MachineBasicBlock * EmitInstrWithCustomInserter(MachineInstr *MI, MachineBasicBlock *MBB) const; -- cgit v1.1 From c86cf046501035b9b931bb2a86ed7b81b8fa9847 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 5 Nov 2013 23:41:57 +0000 Subject: Remove another unused, and IMHO, not very desirable feature of ErrorOr. One of the uses of the IsValid flag is to support default constructing a ErrorOr that is not a Error or a Value. There is not much value in doing that IMHO. If ErrorOr was to have a default constructor, it should be implemented by default constructing the value, but even that looks unnecessary. The other use is to avoid calling destructors on moved objects. This looks wrong. If the data being moved has non trivial treatment of moves (an std::vector for example), it is its destructor that should handle it, not ~ErrorOr. With this change ErrorOr becomes a fairly simple wrapper and should always be better than using an error_code + value in an API. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194109 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/ErrorOr.h | 36 +++++++----------------------------- 1 file changed, 7 insertions(+), 29 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/ErrorOr.h b/include/llvm/Support/ErrorOr.h index 0fdafa0..d5b11cb 100644 --- a/include/llvm/Support/ErrorOr.h +++ b/include/llvm/Support/ErrorOr.h @@ -108,30 +108,28 @@ private: typedef typename remove_reference::type *pointer; public: - ErrorOr() : IsValid(false) {} - template ErrorOr(E ErrorCode, typename enable_if_c::value || is_error_condition_enum::value, void *>::type = 0) - : HasError(true), IsValid(true) { + : HasError(true) { new (getError()) error_code(make_error_code(ErrorCode)); } - ErrorOr(llvm::error_code EC) : HasError(true), IsValid(true) { + ErrorOr(llvm::error_code EC) : HasError(true) { new (getError()) error_code(EC); } - ErrorOr(T Val) : HasError(false), IsValid(true) { + ErrorOr(T Val) : HasError(false) { new (get()) storage_type(moveIfMoveConstructible(Val)); } - ErrorOr(const ErrorOr &Other) : IsValid(false) { + ErrorOr(const ErrorOr &Other) { copyConstruct(Other); } template - ErrorOr(const ErrorOr &Other) : IsValid(false) { + ErrorOr(const ErrorOr &Other) { copyConstruct(Other); } @@ -147,12 +145,12 @@ public: } #if LLVM_HAS_RVALUE_REFERENCES - ErrorOr(ErrorOr &&Other) : IsValid(false) { + ErrorOr(ErrorOr &&Other) { moveConstruct(std::move(Other)); } template - ErrorOr(ErrorOr &&Other) : IsValid(false) { + ErrorOr(ErrorOr &&Other) { moveConstruct(std::move(Other)); } @@ -169,8 +167,6 @@ public: #endif ~ErrorOr() { - if (!IsValid) - return; if (!HasError) get()->~storage_type(); } @@ -180,12 +176,10 @@ public: /// \brief Return false if there is an error. operator unspecified_bool_type() const { - assert(IsValid && "Can't do anything on a default constructed ErrorOr!"); return HasError ? 0 : unspecified_bool_true; } operator llvm::error_code() const { - assert(IsValid && "Can't do anything on a default constructed ErrorOr!"); return HasError ? *getError() : llvm::error_code::success(); } @@ -200,10 +194,6 @@ public: private: template void copyConstruct(const ErrorOr &Other) { - // Construct an invalid ErrorOr if other is invalid. - if (!Other.IsValid) - return; - IsValid = true; if (!Other.HasError) { // Get the other value. HasError = false; @@ -237,22 +227,14 @@ private: #if LLVM_HAS_RVALUE_REFERENCES template void moveConstruct(ErrorOr &&Other) { - // Construct an invalid ErrorOr if other is invalid. - if (!Other.IsValid) - return; - IsValid = true; if (!Other.HasError) { // Get the other value. HasError = false; new (get()) storage_type(std::move(*Other.get())); - // Tell other not to do any destruction. - Other.IsValid = false; } else { // Get other's error. HasError = true; new (getError()) error_code(Other); - // Tell other not to do any destruction. - Other.IsValid = false; } } @@ -275,19 +257,16 @@ private: } storage_type *get() { - assert(IsValid && "Can't do anything on a default constructed ErrorOr!"); assert(!HasError && "Cannot get value when an error exists!"); return reinterpret_cast(TStorage.buffer); } const storage_type *get() const { - assert(IsValid && "Can't do anything on a default constructed ErrorOr!"); assert(!HasError && "Cannot get value when an error exists!"); return reinterpret_cast(TStorage.buffer); } error_code *getError() { - assert(IsValid && "Can't do anything on a default constructed ErrorOr!"); assert(HasError && "Cannot get error when a value exists!"); return reinterpret_cast(ErrorStorage.buffer); } @@ -302,7 +281,6 @@ private: AlignedCharArrayUnion ErrorStorage; }; bool HasError : 1; - bool IsValid : 1; }; template -- cgit v1.1 From 10bb82e54fc0608e6220581bda0405af8f12d32f Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Wed, 6 Nov 2013 02:08:26 +0000 Subject: Rewrite SCEV's backedge taken count computation. Patch by Michele Scandale! Rewrite of the functions used to compute the backedge taken count of a loop on LT and GT comparisons. I decided to split the handling of LT and GT cases becasue the trick "a > b == -a < -b" in some cases prevents the trip count computation due to the multiplication by -1 on the two operands of the comparison. This issue comes from the conservative computation of value range of SCEVs: taking the negative SCEV of an expression that have a small positive range (e.g. [0,31]), we would have a SCEV with a fullset as value range. Indeed, in the new rewritten function I tried to better handle the maximum backedge taken count computation when MAX/MIN expression are used to handle the cases where no entry guard is found. Some test have been modified in order to check the new value correctly (I manually check them and reasoning on possible overflow the new values seem correct). I finally added a new test case related to the multiplication by -1 issue on GT comparisons. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194116 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/ScalarEvolution.h | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h index 3d37651..4915bc6 100644 --- a/include/llvm/Analysis/ScalarEvolution.h +++ b/include/llvm/Analysis/ScalarEvolution.h @@ -426,14 +426,6 @@ namespace llvm { /// resolution. void ForgetSymbolicName(Instruction *I, const SCEV *SymName); - /// getBECount - Subtract the end and start values and divide by the step, - /// rounding up, to get the number of times the backedge is executed. Return - /// CouldNotCompute if an intermediate computation overflows. - const SCEV *getBECount(const SCEV *Start, - const SCEV *End, - const SCEV *Step, - bool NoWrap); - /// getBackedgeTakenInfo - Return the BackedgeTakenInfo for the given /// loop, lazily computing new values if the loop hasn't been analyzed /// yet. @@ -498,6 +490,8 @@ namespace llvm { /// less-than is signed. ExitLimit HowManyLessThans(const SCEV *LHS, const SCEV *RHS, const Loop *L, bool isSigned, bool IsSubExpr); + ExitLimit HowManyGreaterThans(const SCEV *LHS, const SCEV *RHS, + const Loop *L, bool isSigned, bool IsSubExpr); /// getPredecessorWithUniqueSuccessorForBB - Return a predecessor of BB /// (which may not be an immediate predecessor) which has exactly one @@ -880,6 +874,24 @@ namespace llvm { virtual void verifyAnalysis() const; private: + /// Compute the backedge taken count knowing the interval difference, the + /// stride and presence of the equality in the comparison. + const SCEV *computeBECount(const SCEV *Delta, const SCEV *Stride, + bool Equality); + + /// Verify if an linear IV with positive stride can overflow when in a + /// less-than comparison, knowing the invariant term of the comparison, + /// the stride and the knowledge of NSW/NUW flags on the recurrence. + bool doesIVOverflowOnLT(const SCEV *RHS, const SCEV *Stride, + bool IsSigned, bool NoWrap); + + /// Verify if an linear IV with negative stride can overflow when in a + /// greater-than comparison, knowing the invariant term of the comparison, + /// the stride and the knowledge of NSW/NUW flags on the recurrence. + bool doesIVOverflowOnGT(const SCEV *RHS, const SCEV *Stride, + bool IsSigned, bool NoWrap); + + private: FoldingSet UniqueSCEVs; BumpPtrAllocator SCEVAllocator; -- cgit v1.1 From 14bbb1d9b083c7935185e7c11ddf059f352aa3fc Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Wed, 6 Nov 2013 09:21:01 +0000 Subject: [llvm-c] Implement LLVMPrintValueToString Original patch by Chris Wailes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194135 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 89ddf41..30b1d82 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -1212,6 +1212,14 @@ void LLVMSetValueName(LLVMValueRef Val, const char *Name); void LLVMDumpValue(LLVMValueRef Val); /** + * Return a string representation of the value. Use + * LLVMDisposeMessage to free the string. + * + * @see llvm::Value::print() + */ +char *LLVMPrintValueToString(LLVMValueRef Val); + +/** * Replace all uses of a value with another one. * * @see llvm::Value::replaceAllUsesWith() -- cgit v1.1 From c6099db476ea863d0e897e3c311bfe490293e04f Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Wed, 6 Nov 2013 09:21:15 +0000 Subject: [llvm-c] Expose IRReader interface Original patch by Chris Wailes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194137 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/IRReader.h | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 include/llvm-c/IRReader.h (limited to 'include') diff --git a/include/llvm-c/IRReader.h b/include/llvm-c/IRReader.h new file mode 100644 index 0000000..d0a23be --- /dev/null +++ b/include/llvm-c/IRReader.h @@ -0,0 +1,40 @@ +/*===-- llvm-c/IRReader.h - IR Reader C Interface -----------------*- 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 C interface to the IR Reader. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_C_IRREADER_H +#define LLVM_C_IRREADER_H + +#include "llvm-c/Core.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Read LLVM IR from a memory buffer and convert it into an in-memory Module + * object. Returns 0 on success. + * Optionally returns a human-readable description of any errors that + * occured during parsing IR. OutMessage must be disposed with + * LLVMDisposeMessage. + * + * @see llvm::ParseIR() + */ +LLVMBool LLVMParseIRInContext(LLVMContextRef ContextRef, + LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutM, + char **OutMessage); + +#ifdef __cplusplus +} +#endif + +#endif -- cgit v1.1 From 87265f9792a59b7107bd30fb6f114f5ce5e1273c Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Wed, 6 Nov 2013 09:21:31 +0000 Subject: [llvm-c] Expose LLVMLoadLibraryPermanently Original patch by Chris Wailes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194139 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Support.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 include/llvm-c/Support.h (limited to 'include') diff --git a/include/llvm-c/Support.h b/include/llvm-c/Support.h new file mode 100644 index 0000000..72af4e4 --- /dev/null +++ b/include/llvm-c/Support.h @@ -0,0 +1,36 @@ +/*===-- llvm-c/Support.h - Support C Interface --------------------*- 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 C interface to the LLVM support library. *| +|* *| +\*===----------------------------------------------------------------------===*/ + +#ifndef LLVM_C_SUPPORT_H +#define LLVM_C_SUPPORT_H + +#include "llvm-c/Core.h" +#include "llvm/Support/DynamicLibrary.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * This function permanently loads the dynamic library at the given path. + * It is safe to call this function multiple times for the same library. + * + * @see sys::DynamicLibrary::LoadLibraryPermanently() + */ +LLVMBool LLVMLoadLibraryPermanently(const char* Filename); + +#ifdef __cplusplus +} +#endif + +#endif \ No newline at end of file -- cgit v1.1 From 43b255884a9ea4040c2c62dcbb957159cb7f31da Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Wed, 6 Nov 2013 09:21:35 +0000 Subject: [llvm-c] Add functions for initializing native AsmPrinter, AsmParser & Disassembler Original patch by Chris Wailes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194140 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Target.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Target.h b/include/llvm-c/Target.h index 71a2481..834b63a 100644 --- a/include/llvm-c/Target.h +++ b/include/llvm-c/Target.h @@ -146,6 +146,42 @@ static inline LLVMBool LLVMInitializeNativeTarget(void) { #endif } +/** LLVMInitializeNativeTargetAsmParser - The main program should call this + function to initialize the parser for the native target corresponding to the + host. */ +static inline LLVMBool LLVMInitializeNativeTargetAsmParser(void) { +#ifdef LLVM_NATIVE_TARGET + LLVM_NATIVE_ASMPARSER(); + return 0; +#else + return 1; +#endif +} + +/** LLVMInitializeNativeTargetAsmPrinter - The main program should call this + function to initialize the printer for the native target corresponding to + the host. */ +static inline LLVMBool LLVMInitializeNativeTargetAsmPrinter(void) { +#ifdef LLVM_NATIVE_TARGET + LLVM_NATIVE_ASMPRINTER(); + return 0; +#else + return 1; +#endif +} + +/** LLVMInitializeNativeTargetDisassembler - The main program should call this + function to initialize the disassembler for the native target corresponding + to the host. */ +static inline LLVMBool LLVMInitializeNativeTargetDisassembler(void) { +#ifdef LLVM_NATIVE_TARGET + LLVM_NATIVE_DISASSEMBLER(); + return 0; +#else + return 1; +#endif +} + /*===-- Target Data -------------------------------------------------------===*/ /** Creates target data from a target layout string. -- cgit v1.1 From e669e09d7d4245a88b10a772be3ba97aa5e14923 Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Wed, 6 Nov 2013 09:45:53 +0000 Subject: [llvm-c] Correctly check for existence of native AsmParser, AsmPrinter, Disassembler Also, properly name the functions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194141 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Target.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/llvm-c/Target.h b/include/llvm-c/Target.h index 834b63a..7261b0f 100644 --- a/include/llvm-c/Target.h +++ b/include/llvm-c/Target.h @@ -149,8 +149,8 @@ static inline LLVMBool LLVMInitializeNativeTarget(void) { /** LLVMInitializeNativeTargetAsmParser - The main program should call this function to initialize the parser for the native target corresponding to the host. */ -static inline LLVMBool LLVMInitializeNativeTargetAsmParser(void) { -#ifdef LLVM_NATIVE_TARGET +static inline LLVMBool LLVMInitializeNativeAsmParser(void) { +#ifdef LLVM_NATIVE_ASMPARSER LLVM_NATIVE_ASMPARSER(); return 0; #else @@ -161,8 +161,8 @@ static inline LLVMBool LLVMInitializeNativeTargetAsmParser(void) { /** LLVMInitializeNativeTargetAsmPrinter - The main program should call this function to initialize the printer for the native target corresponding to the host. */ -static inline LLVMBool LLVMInitializeNativeTargetAsmPrinter(void) { -#ifdef LLVM_NATIVE_TARGET +static inline LLVMBool LLVMInitializeNativeAsmPrinter(void) { +#ifdef LLVM_NATIVE_ASMPRINTER LLVM_NATIVE_ASMPRINTER(); return 0; #else @@ -173,8 +173,8 @@ static inline LLVMBool LLVMInitializeNativeTargetAsmPrinter(void) { /** LLVMInitializeNativeTargetDisassembler - The main program should call this function to initialize the disassembler for the native target corresponding to the host. */ -static inline LLVMBool LLVMInitializeNativeTargetDisassembler(void) { -#ifdef LLVM_NATIVE_TARGET +static inline LLVMBool LLVMInitializeNativeDisassembler(void) { +#ifdef LLVM_NATIVE_DISASSEMBLER LLVM_NATIVE_DISASSEMBLER(); return 0; #else -- cgit v1.1 From 1acb2127bad420af19a5929df54a892957ba3c13 Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Wed, 6 Nov 2013 10:25:18 +0000 Subject: [llvm-c] Improve TargetMachine bindings Original patch by Chris Wailes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194143 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/TargetMachine.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'include') diff --git a/include/llvm-c/TargetMachine.h b/include/llvm-c/TargetMachine.h index c2d198c..84f9144 100644 --- a/include/llvm-c/TargetMachine.h +++ b/include/llvm-c/TargetMachine.h @@ -62,6 +62,16 @@ LLVMTargetRef LLVMGetFirstTarget(void); LLVMTargetRef LLVMGetNextTarget(LLVMTargetRef T); /*===-- Target ------------------------------------------------------------===*/ +/** Finds the target corresponding to the given name and stores it in \p T. + Returns 0 on success. */ +LLVMBool LLVMGetTargetFromName(const char *Name, LLVMTargetRef *T); + +/** Finds the target corresponding to the given triple and stores it in \p T. + Returns 0 on success. Optionally returns any error in ErrorMessage. + Use LLVMDisposeMessage to dispose the message. */ +LLVMBool LLVMGetTargetFromTriple(const char* Triple, LLVMTargetRef *T, + char **ErrorMessage); + /** Returns the name of a target. See llvm::Target::getName */ const char *LLVMGetTargetName(LLVMTargetRef T); @@ -108,6 +118,10 @@ char *LLVMGetTargetMachineFeatureString(LLVMTargetMachineRef T); /** Returns the llvm::DataLayout used for this llvm:TargetMachine. */ LLVMTargetDataRef LLVMGetTargetMachineData(LLVMTargetMachineRef T); +/** Set the target machine's ASM verbosity. */ +void LLVMSetTargetMachineAsmVerbosity(LLVMTargetMachineRef T, + LLVMBool VerboseAsm); + /** Emits an asm or object file for the given module to the filename. This wraps several c++ only classes (among them a file stream). Returns any error in ErrorMessage. Use LLVMDisposeMessage to dispose the message. */ @@ -117,6 +131,12 @@ LLVMBool LLVMTargetMachineEmitToFile(LLVMTargetMachineRef T, LLVMModuleRef M, /** Compile the LLVM IR stored in \p M and store the result in \p OutMemBuf. */ LLVMBool LLVMTargetMachineEmitToMemoryBuffer(LLVMTargetMachineRef T, LLVMModuleRef M, LLVMCodeGenFileType codegen, char** ErrorMessage, LLVMMemoryBufferRef *OutMemBuf); + +/*===-- Triple ------------------------------------------------------------===*/ +/** Get a triple for the host machine as a string. The result needs to be + disposed with LLVMDisposeMessage. */ +char* LLVMGetDefaultTargetTriple(void); + #ifdef __cplusplus } #endif -- cgit v1.1 From 573a231a3102657faf846e588517d01801154100 Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Wed, 6 Nov 2013 11:52:40 +0000 Subject: [llvm-c] Add parameter names in Target.h for C99 compliance git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194146 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Target.h | 44 +++++++++++++++++++++++--------------------- 1 file changed, 23 insertions(+), 21 deletions(-) (limited to 'include') diff --git a/include/llvm-c/Target.h b/include/llvm-c/Target.h index 7261b0f..f5f2bc4 100644 --- a/include/llvm-c/Target.h +++ b/include/llvm-c/Target.h @@ -191,92 +191,94 @@ LLVMTargetDataRef LLVMCreateTargetData(const char *StringRep); /** Adds target data information to a pass manager. This does not take ownership of the target data. See the method llvm::PassManagerBase::add. */ -void LLVMAddTargetData(LLVMTargetDataRef, LLVMPassManagerRef); +void LLVMAddTargetData(LLVMTargetDataRef TD, LLVMPassManagerRef PM); /** Adds target library information to a pass manager. This does not take ownership of the target library info. See the method llvm::PassManagerBase::add. */ -void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef, LLVMPassManagerRef); +void LLVMAddTargetLibraryInfo(LLVMTargetLibraryInfoRef TLI, + LLVMPassManagerRef PM); /** Converts target data to a target layout string. The string must be disposed with LLVMDisposeMessage. See the constructor llvm::DataLayout::DataLayout. */ -char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef); +char *LLVMCopyStringRepOfTargetData(LLVMTargetDataRef TD); /** Returns the byte order of a target, either LLVMBigEndian or LLVMLittleEndian. See the method llvm::DataLayout::isLittleEndian. */ -enum LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef); +enum LLVMByteOrdering LLVMByteOrder(LLVMTargetDataRef TD); /** Returns the pointer size in bytes for a target. See the method llvm::DataLayout::getPointerSize. */ -unsigned LLVMPointerSize(LLVMTargetDataRef); +unsigned LLVMPointerSize(LLVMTargetDataRef TD); /** Returns the pointer size in bytes for a target for a specified address space. See the method llvm::DataLayout::getPointerSize. */ -unsigned LLVMPointerSizeForAS(LLVMTargetDataRef, unsigned AS); +unsigned LLVMPointerSizeForAS(LLVMTargetDataRef TD, unsigned AS); /** Returns the integer type that is the same size as a pointer on a target. See the method llvm::DataLayout::getIntPtrType. */ -LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef); +LLVMTypeRef LLVMIntPtrType(LLVMTargetDataRef TD); /** Returns the integer type that is the same size as a pointer on a target. This version allows the address space to be specified. See the method llvm::DataLayout::getIntPtrType. */ -LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef, unsigned AS); +LLVMTypeRef LLVMIntPtrTypeForAS(LLVMTargetDataRef TD, unsigned AS); /** Returns the integer type that is the same size as a pointer on a target. See the method llvm::DataLayout::getIntPtrType. */ -LLVMTypeRef LLVMIntPtrTypeInContext(LLVMContextRef, LLVMTargetDataRef); +LLVMTypeRef LLVMIntPtrTypeInContext(LLVMContextRef C, LLVMTargetDataRef TD); /** Returns the integer type that is the same size as a pointer on a target. This version allows the address space to be specified. See the method llvm::DataLayout::getIntPtrType. */ -LLVMTypeRef LLVMIntPtrTypeForASInContext(LLVMContextRef, LLVMTargetDataRef, unsigned AS); +LLVMTypeRef LLVMIntPtrTypeForASInContext(LLVMContextRef C, LLVMTargetDataRef TD, + unsigned AS); /** Computes the size of a type in bytes for a target. See the method llvm::DataLayout::getTypeSizeInBits. */ -unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef, LLVMTypeRef); +unsigned long long LLVMSizeOfTypeInBits(LLVMTargetDataRef TD, LLVMTypeRef Ty); /** Computes the storage size of a type in bytes for a target. See the method llvm::DataLayout::getTypeStoreSize. */ -unsigned long long LLVMStoreSizeOfType(LLVMTargetDataRef, LLVMTypeRef); +unsigned long long LLVMStoreSizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty); /** Computes the ABI size of a type in bytes for a target. See the method llvm::DataLayout::getTypeAllocSize. */ -unsigned long long LLVMABISizeOfType(LLVMTargetDataRef, LLVMTypeRef); +unsigned long long LLVMABISizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty); /** Computes the ABI alignment of a type in bytes for a target. See the method llvm::DataLayout::getTypeABISize. */ -unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef); +unsigned LLVMABIAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty); /** Computes the call frame alignment of a type in bytes for a target. See the method llvm::DataLayout::getTypeABISize. */ -unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef); +unsigned LLVMCallFrameAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty); /** Computes the preferred alignment of a type in bytes for a target. See the method llvm::DataLayout::getTypeABISize. */ -unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef, LLVMTypeRef); +unsigned LLVMPreferredAlignmentOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty); /** Computes the preferred alignment of a global variable in bytes for a target. See the method llvm::DataLayout::getPreferredAlignment. */ -unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef, +unsigned LLVMPreferredAlignmentOfGlobal(LLVMTargetDataRef TD, LLVMValueRef GlobalVar); /** Computes the structure element that contains the byte offset for a target. See the method llvm::StructLayout::getElementContainingOffset. */ -unsigned LLVMElementAtOffset(LLVMTargetDataRef, LLVMTypeRef StructTy, +unsigned LLVMElementAtOffset(LLVMTargetDataRef TD, LLVMTypeRef StructTy, unsigned long long Offset); /** Computes the byte offset of the indexed struct element for a target. See the method llvm::StructLayout::getElementContainingOffset. */ -unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef, LLVMTypeRef StructTy, - unsigned Element); +unsigned long long LLVMOffsetOfElement(LLVMTargetDataRef TD, + LLVMTypeRef StructTy, unsigned Element); /** Deallocates a TargetData. See the destructor llvm::DataLayout::~DataLayout. */ -void LLVMDisposeTargetData(LLVMTargetDataRef); +void LLVMDisposeTargetData(LLVMTargetDataRef TD); /** * @} -- cgit v1.1 From 4411ba06fc5777edf4dde239d6ac8289bfd488ce Mon Sep 17 00:00:00 2001 From: Simon Atanasyan Date: Wed, 6 Nov 2013 12:23:52 +0000 Subject: Add DT_VERSYM dynamic table entry tag definition. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194149 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/ELF.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/Support/ELF.h b/include/llvm/Support/ELF.h index 797c211..2868f35 100644 --- a/include/llvm/Support/ELF.h +++ b/include/llvm/Support/ELF.h @@ -1570,6 +1570,7 @@ enum { DT_RELCOUNT = 0x6FFFFFFA, // ELF32_Rel count. DT_FLAGS_1 = 0X6FFFFFFB, // Flags_1. + DT_VERSYM = 0x6FFFFFF0, // The address of .gnu.version section. DT_VERDEF = 0X6FFFFFFC, // The address of the version definition table. DT_VERDEFNUM = 0X6FFFFFFD, // The number of entries in DT_VERDEF. DT_VERNEED = 0X6FFFFFFE, // The address of the version Dependency table. -- cgit v1.1 From 0f0f1ac011627aa5f90d739b4e0ccffeeb721f50 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Thu, 7 Nov 2013 13:54:24 +0000 Subject: llvm-c/Support.h: Add a newline at eof. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194203 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Support.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm-c/Support.h b/include/llvm-c/Support.h index 72af4e4..705e5f2 100644 --- a/include/llvm-c/Support.h +++ b/include/llvm-c/Support.h @@ -33,4 +33,4 @@ LLVMBool LLVMLoadLibraryPermanently(const char* Filename); } #endif -#endif \ No newline at end of file +#endif -- cgit v1.1 From 62ab26548fee37422fb90daaac22fc1140be797d Mon Sep 17 00:00:00 2001 From: Artyom Skrobov Date: Fri, 8 Nov 2013 16:07:43 +0000 Subject: Export MCDisassembler's SubtargetInfo, to allow architecture-aware disassembly git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194260 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCDisassembler.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCDisassembler.h b/include/llvm/MC/MCDisassembler.h index e82b0c1..83f26ef 100644 --- a/include/llvm/MC/MCDisassembler.h +++ b/include/llvm/MC/MCDisassembler.h @@ -131,6 +131,8 @@ public: void *getDisInfoBlock() const { return DisInfo; } MCContext *getMCContext() const { return Ctx; } + const MCSubtargetInfo& getSubtargetInfo() const { return STI; } + // Marked mutable because we cache it inside the disassembler, rather than // having to pass it around as an argument through all the autogenerated code. mutable raw_ostream *CommentStream; -- cgit v1.1 From fffdcacff2de0c1eaf4dbd2884384d71d024776d Mon Sep 17 00:00:00 2001 From: Jordan Rose Date: Fri, 8 Nov 2013 17:23:49 +0000 Subject: Add ImmutableSet profiling info for 'bool'. Useful for tri-state maps: true, false, and "no data yet". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194266 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/ImmutableSet.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/llvm/ADT/ImmutableSet.h b/include/llvm/ADT/ImmutableSet.h index 2a0579e..ad34969 100644 --- a/include/llvm/ADT/ImmutableSet.h +++ b/include/llvm/ADT/ImmutableSet.h @@ -851,6 +851,18 @@ PROFILE_INTEGER_INFO(unsigned long long) #undef PROFILE_INTEGER_INFO +/// Profile traits for booleans. +template <> +struct ImutProfileInfo { + typedef const bool value_type; + typedef const bool& value_type_ref; + + static inline void Profile(FoldingSetNodeID& ID, value_type_ref X) { + ID.AddBoolean(X); + } +}; + + /// Generic profile trait for pointer types. We treat pointers as /// references to unique objects. template -- cgit v1.1 From 663fcde3d33e44a9b543a692ad29873bd1ddc403 Mon Sep 17 00:00:00 2001 From: "Arnaud A. de Grandmaison" Date: Fri, 8 Nov 2013 17:56:29 +0000 Subject: CalculateSpillWeights does not need to be a pass Based on discussions with Lang Hames and Jakob Stoklund Olesen at the hacker's lab, and in the light of upcoming work on the PBQP register allocator, it was though that CalcSpillWeights does not need to be a pass. This change will enable to customize / tune the spill weight computation depending on the allocator. Update the documentation style while there. No functionnal change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194269 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/CalcSpillWeights.h | 33 +++++++++++---------------------- include/llvm/InitializePasses.h | 1 - 2 files changed, 11 insertions(+), 23 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/CalcSpillWeights.h b/include/llvm/CodeGen/CalcSpillWeights.h index c8ec764..00d9c6a 100644 --- a/include/llvm/CodeGen/CalcSpillWeights.h +++ b/include/llvm/CodeGen/CalcSpillWeights.h @@ -21,7 +21,9 @@ namespace llvm { class MachineBlockFrequencyInfo; class MachineLoopInfo; - /// normalizeSpillWeight - The spill weight of a live interval is computed as: + /// \brief Normalize the spill weight of a live interval + /// + /// The spill weight of a live interval is computed as: /// /// (sum(use freq) + sum(def freq)) / (K + size) /// @@ -38,8 +40,8 @@ namespace llvm { return UseDefFreq / (Size + 25*SlotIndex::InstrDist); } - /// VirtRegAuxInfo - Calculate auxiliary information for a virtual - /// register such as its spill weight and allocation hint. + /// \brief Calculate auxiliary information for a virtual register such as its + /// spill weight and allocation hint. class VirtRegAuxInfo { MachineFunction &MF; LiveIntervals &LIS; @@ -52,29 +54,16 @@ namespace llvm { const MachineBlockFrequencyInfo &mbfi) : MF(mf), LIS(lis), Loops(loops), MBFI(mbfi) {} - /// CalculateWeightAndHint - (re)compute li's spill weight and allocation - /// hint. + /// \brief (re)compute li's spill weight and allocation hint. void CalculateWeightAndHint(LiveInterval &li); }; - /// CalculateSpillWeights - Compute spill weights for all virtual register + /// \brief Compute spill weights and allocation hints for all virtual register /// live intervals. - class CalculateSpillWeights : public MachineFunctionPass { - public: - static char ID; - - CalculateSpillWeights() : MachineFunctionPass(ID) { - initializeCalculateSpillWeightsPass(*PassRegistry::getPassRegistry()); - } - - virtual void getAnalysisUsage(AnalysisUsage &au) const; - - virtual bool runOnMachineFunction(MachineFunction &fn); - - private: - /// Returns true if the given live interval is zero length. - bool isZeroLengthInterval(LiveInterval *li) const; - }; + void calculateSpillWeights(LiveIntervals &LIS, + MachineFunction &MF, + const MachineLoopInfo &MLI, + const MachineBlockFrequencyInfo &MBFI); } diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h index fe26c23..68825a3 100644 --- a/include/llvm/InitializePasses.h +++ b/include/llvm/InitializePasses.h @@ -89,7 +89,6 @@ void initializeCFGSimplifyPassPass(PassRegistry&); void initializeFlattenCFGPassPass(PassRegistry&); void initializeStructurizeCFGPass(PassRegistry&); void initializeCFGViewerPass(PassRegistry&); -void initializeCalculateSpillWeightsPass(PassRegistry&); void initializeCodeGenPreparePass(PassRegistry&); void initializeConstantMergePass(PassRegistry&); void initializeConstantPropagationPass(PassRegistry&); -- cgit v1.1 From d241fa7a61682a15b753c52afee07dfbf1b3bd1f Mon Sep 17 00:00:00 2001 From: "Arnaud A. de Grandmaison" Date: Fri, 8 Nov 2013 18:19:19 +0000 Subject: Revert "CalculateSpillWeights does not need to be a pass" Temporarily revert my previous commit until I understand why it breaks 3 target tests. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194272 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/CalcSpillWeights.h | 33 ++++++++++++++++++++++----------- include/llvm/InitializePasses.h | 1 + 2 files changed, 23 insertions(+), 11 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/CalcSpillWeights.h b/include/llvm/CodeGen/CalcSpillWeights.h index 00d9c6a..c8ec764 100644 --- a/include/llvm/CodeGen/CalcSpillWeights.h +++ b/include/llvm/CodeGen/CalcSpillWeights.h @@ -21,9 +21,7 @@ namespace llvm { class MachineBlockFrequencyInfo; class MachineLoopInfo; - /// \brief Normalize the spill weight of a live interval - /// - /// The spill weight of a live interval is computed as: + /// normalizeSpillWeight - The spill weight of a live interval is computed as: /// /// (sum(use freq) + sum(def freq)) / (K + size) /// @@ -40,8 +38,8 @@ namespace llvm { return UseDefFreq / (Size + 25*SlotIndex::InstrDist); } - /// \brief Calculate auxiliary information for a virtual register such as its - /// spill weight and allocation hint. + /// VirtRegAuxInfo - Calculate auxiliary information for a virtual + /// register such as its spill weight and allocation hint. class VirtRegAuxInfo { MachineFunction &MF; LiveIntervals &LIS; @@ -54,16 +52,29 @@ namespace llvm { const MachineBlockFrequencyInfo &mbfi) : MF(mf), LIS(lis), Loops(loops), MBFI(mbfi) {} - /// \brief (re)compute li's spill weight and allocation hint. + /// CalculateWeightAndHint - (re)compute li's spill weight and allocation + /// hint. void CalculateWeightAndHint(LiveInterval &li); }; - /// \brief Compute spill weights and allocation hints for all virtual register + /// CalculateSpillWeights - Compute spill weights for all virtual register /// live intervals. - void calculateSpillWeights(LiveIntervals &LIS, - MachineFunction &MF, - const MachineLoopInfo &MLI, - const MachineBlockFrequencyInfo &MBFI); + class CalculateSpillWeights : public MachineFunctionPass { + public: + static char ID; + + CalculateSpillWeights() : MachineFunctionPass(ID) { + initializeCalculateSpillWeightsPass(*PassRegistry::getPassRegistry()); + } + + virtual void getAnalysisUsage(AnalysisUsage &au) const; + + virtual bool runOnMachineFunction(MachineFunction &fn); + + private: + /// Returns true if the given live interval is zero length. + bool isZeroLengthInterval(LiveInterval *li) const; + }; } diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h index 68825a3..fe26c23 100644 --- a/include/llvm/InitializePasses.h +++ b/include/llvm/InitializePasses.h @@ -89,6 +89,7 @@ void initializeCFGSimplifyPassPass(PassRegistry&); void initializeFlattenCFGPassPass(PassRegistry&); void initializeStructurizeCFGPass(PassRegistry&); void initializeCFGViewerPass(PassRegistry&); +void initializeCalculateSpillWeightsPass(PassRegistry&); void initializeCodeGenPreparePass(PassRegistry&); void initializeConstantMergePass(PassRegistry&); void initializeConstantPropagationPass(PassRegistry&); -- cgit v1.1 From c87e4380542c0e15cdaa480716da1434284feb93 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Fri, 8 Nov 2013 22:14:49 +0000 Subject: Add a method to get the object-file appropriate stack map section. Thanks to Eric Christopher for the tips on the appropriate way to do this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194282 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCObjectFileInfo.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/llvm/MC/MCObjectFileInfo.h b/include/llvm/MC/MCObjectFileInfo.h index 5e5debe..c48dcb0 100644 --- a/include/llvm/MC/MCObjectFileInfo.h +++ b/include/llvm/MC/MCObjectFileInfo.h @@ -142,6 +142,8 @@ protected: /// ELF and MachO only. const MCSection *TLSBSSSection; // Defaults to ".tbss". + /// StackMap section. + const MCSection *StackMapSection; /// EHFrameSection - EH frame section. It is initialized on demand so it /// can be overwritten (with uniquing). @@ -285,6 +287,8 @@ public: const MCSection *getTLSDataSection() const { return TLSDataSection; } const MCSection *getTLSBSSSection() const { return TLSBSSSection; } + const MCSection *getStackMapSection() const { return StackMapSection; } + /// ELF specific sections. /// const MCSection *getDataRelSection() const { return DataRelSection; } -- cgit v1.1 From 623d2e618f4e672c47edff9ec63ed6d733ac81d3 Mon Sep 17 00:00:00 2001 From: Juergen Ributzka Date: Fri, 8 Nov 2013 23:28:16 +0000 Subject: [Stackmap] Add AnyReg calling convention support for patchpoint intrinsic. The idea of the AnyReg Calling Convention is to provide the call arguments in registers, but not to force them to be placed in a paticular order into a specified set of registers. Instead it is up tp the register allocator to assign any register as it sees fit. The same applies to the return value (if applicable). Differential Revision: http://llvm-reviews.chandlerc.com/D2009 Reviewed by Andy git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194293 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/StackMaps.h | 6 ++++-- include/llvm/IR/CallingConv.h | 4 ++++ include/llvm/Target/Target.td | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/StackMaps.h b/include/llvm/CodeGen/StackMaps.h index 40eeb2e..c79c342 100644 --- a/include/llvm/CodeGen/StackMaps.h +++ b/include/llvm/CodeGen/StackMaps.h @@ -50,10 +50,12 @@ public: /// This should be called by the MC lowering code _immediately_ before /// lowering the MI to an MCInst. It records where the operands for the /// instruction are stored, and outputs a label to record the offset of - /// the call from the start of the text section. + /// the call from the start of the text section. In special cases (e.g. AnyReg + /// calling convention) the return register is also recorded if requested. void recordStackMap(const MachineInstr &MI, uint32_t ID, MachineInstr::const_mop_iterator MOI, - MachineInstr::const_mop_iterator MOE); + MachineInstr::const_mop_iterator MOE, + bool recordResult = false); /// If there is any stack map data, create a stack map section and serialize /// the map info into it. This clears the stack map data structures diff --git a/include/llvm/IR/CallingConv.h b/include/llvm/IR/CallingConv.h index 35c7df9..4437af2 100644 --- a/include/llvm/IR/CallingConv.h +++ b/include/llvm/IR/CallingConv.h @@ -54,6 +54,10 @@ namespace CallingConv { // WebKit JS - Calling convention for stack based JavaScript calls WebKit_JS = 12, + // AnyReg - Calling convention for dynamic register based calls (e.g. + // stackmap and patchpoint intrinsics). + AnyReg = 13, + // Target - This is the start of the target-specific calling conventions, // e.g. fastcall and thiscall on X86. FirstTargetCC = 64, diff --git a/include/llvm/Target/Target.td b/include/llvm/Target/Target.td index 0c0b1ed..3f6eae6 100644 --- a/include/llvm/Target/Target.td +++ b/include/llvm/Target/Target.td @@ -807,9 +807,9 @@ def STACKMAP : Instruction { let mayLoad = 1; } def PATCHPOINT : Instruction { - let OutOperandList = (outs); + let OutOperandList = (outs unknown:$dst); let InOperandList = (ins i32imm:$id, i32imm:$nbytes, unknown:$callee, - i32imm:$nargs, variable_ops); + i32imm:$nargs, i32imm:$cc, variable_ops); let isCall = 1; let mayLoad = 1; } -- cgit v1.1 From fc93ae629e49b00fc1cc536d93f1b106bcd0937d Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Sat, 9 Nov 2013 00:14:07 +0000 Subject: Rewrite the PBQP graph data structure. The new graph structure replaces the node and edge linked lists with vectors. Free lists (well, free vectors) are used for fast insertion/deletion. The ultimate aim is to make PBQP graphs cheap to clone. The motivation is that the PBQP solver destructively consumes input graphs while computing a solution, forcing the graph to be fully reconstructed for each round of PBQP. This imposes a high cost on large functions, which often require several rounds of solving/spilling to find a final register allocation. If we can cheaply clone the PBQP graph and incrementally update it between rounds then hopefully we can reduce this cost. Further, once we begin pooling matrix/vector values (future work), we can cache some PBQP solver metadata and share it between cloned graphs, allowing the PBQP solver to re-use some of the computation done in earlier rounds. For now this is just a data structure update. The allocator and solver still use the graph the same way as before, fully reconstructing it between each round. I expect no material change from this update, although it may change the iteration order of the nodes, causing ties in the solver to break in different directions, and this could perturb the generated allocations (hopefully in a completely benign way). Thanks very much to Arnaud Allard de Grandmaison for encouraging me to get back to work on this, and for a lot of discussion and many useful PBQP test cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194300 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/PBQP/Graph.h | 346 ++++++++++++++------------ include/llvm/CodeGen/PBQP/HeuristicBase.h | 40 +-- include/llvm/CodeGen/PBQP/HeuristicSolver.h | 248 +++++++++--------- include/llvm/CodeGen/PBQP/Heuristics/Briggs.h | 176 ++++++------- include/llvm/CodeGen/PBQP/Solution.h | 11 +- include/llvm/CodeGen/RegAllocPBQP.h | 17 +- 6 files changed, 434 insertions(+), 404 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/PBQP/Graph.h b/include/llvm/CodeGen/PBQP/Graph.h index b57abca..9f9a567 100644 --- a/include/llvm/CodeGen/PBQP/Graph.h +++ b/include/llvm/CodeGen/PBQP/Graph.h @@ -20,79 +20,63 @@ #include "llvm/ADT/ilist_node.h" #include #include +#include namespace PBQP { /// PBQP Graph class. /// Instances of this class describe PBQP problems. class Graph { - private: - - // ----- TYPEDEFS ----- - class NodeEntry; - class EdgeEntry; - - typedef llvm::ilist NodeList; - typedef llvm::ilist EdgeList; - public: - typedef NodeList::iterator NodeItr; - typedef NodeList::const_iterator ConstNodeItr; - - typedef EdgeList::iterator EdgeItr; - typedef EdgeList::const_iterator ConstEdgeItr; + typedef unsigned NodeId; + typedef unsigned EdgeId; private: - typedef std::list AdjEdgeList; - + typedef std::set AdjEdgeList; + public: typedef AdjEdgeList::iterator AdjEdgeItr; private: - class NodeEntry : public llvm::ilist_node { - friend struct llvm::ilist_sentinel_traits; + class NodeEntry { private: Vector costs; AdjEdgeList adjEdges; - unsigned degree; void *data; NodeEntry() : costs(0, 0) {} public: - NodeEntry(const Vector &costs) : costs(costs), degree(0) {} + NodeEntry(const Vector &costs) : costs(costs), data(0) {} Vector& getCosts() { return costs; } const Vector& getCosts() const { return costs; } - unsigned getDegree() const { return degree; } + unsigned getDegree() const { return adjEdges.size(); } AdjEdgeItr edgesBegin() { return adjEdges.begin(); } AdjEdgeItr edgesEnd() { return adjEdges.end(); } - AdjEdgeItr addEdge(EdgeItr e) { - ++degree; + AdjEdgeItr addEdge(EdgeId e) { return adjEdges.insert(adjEdges.end(), e); } void removeEdge(AdjEdgeItr ae) { - --degree; adjEdges.erase(ae); } void setData(void *data) { this->data = data; } void* getData() { return data; } }; - class EdgeEntry : public llvm::ilist_node { - friend struct llvm::ilist_sentinel_traits; + class EdgeEntry { private: - NodeItr node1, node2; + NodeId node1, node2; Matrix costs; AdjEdgeItr node1AEItr, node2AEItr; void *data; - EdgeEntry() : costs(0, 0, 0) {} + EdgeEntry() : costs(0, 0, 0), data(0) {} public: - EdgeEntry(NodeItr node1, NodeItr node2, const Matrix &costs) + EdgeEntry(NodeId node1, NodeId node2, const Matrix &costs) : node1(node1), node2(node2), costs(costs) {} - NodeItr getNode1() const { return node1; } - NodeItr getNode2() const { return node2; } + NodeId getNode1() const { return node1; } + NodeId getNode2() const { return node2; } Matrix& getCosts() { return costs; } const Matrix& getCosts() const { return costs; } void setNode1AEItr(AdjEdgeItr ae) { node1AEItr = ae; } @@ -105,52 +89,126 @@ namespace PBQP { // ----- MEMBERS ----- - NodeList nodes; - unsigned numNodes; + typedef std::vector NodeVector; + typedef std::vector FreeNodeVector; + NodeVector nodes; + FreeNodeVector freeNodes; - EdgeList edges; - unsigned numEdges; + typedef std::vector EdgeVector; + typedef std::vector FreeEdgeVector; + EdgeVector edges; + FreeEdgeVector freeEdges; // ----- INTERNAL METHODS ----- - NodeEntry& getNode(NodeItr nItr) { return *nItr; } - const NodeEntry& getNode(ConstNodeItr nItr) const { return *nItr; } - - EdgeEntry& getEdge(EdgeItr eItr) { return *eItr; } - const EdgeEntry& getEdge(ConstEdgeItr eItr) const { return *eItr; } - - NodeItr addConstructedNode(const NodeEntry &n) { - ++numNodes; - return nodes.insert(nodes.end(), n); + NodeEntry& getNode(NodeId nId) { return nodes[nId]; } + const NodeEntry& getNode(NodeId nId) const { return nodes[nId]; } + + EdgeEntry& getEdge(EdgeId eId) { return edges[eId]; } + const EdgeEntry& getEdge(EdgeId eId) const { return edges[eId]; } + + NodeId addConstructedNode(const NodeEntry &n) { + NodeId nodeId = 0; + if (!freeNodes.empty()) { + nodeId = freeNodes.back(); + freeNodes.pop_back(); + nodes[nodeId] = n; + } else { + nodeId = nodes.size(); + nodes.push_back(n); + } + return nodeId; } - EdgeItr addConstructedEdge(const EdgeEntry &e) { - assert(findEdge(e.getNode1(), e.getNode2()) == edges.end() && + EdgeId addConstructedEdge(const EdgeEntry &e) { + assert(findEdge(e.getNode1(), e.getNode2()) == invalidEdgeId() && "Attempt to add duplicate edge."); - ++numEdges; - EdgeItr edgeItr = edges.insert(edges.end(), e); - EdgeEntry &ne = getEdge(edgeItr); + EdgeId edgeId = 0; + if (!freeEdges.empty()) { + edgeId = freeEdges.back(); + freeEdges.pop_back(); + edges[edgeId] = e; + } else { + edgeId = edges.size(); + edges.push_back(e); + } + + EdgeEntry &ne = getEdge(edgeId); NodeEntry &n1 = getNode(ne.getNode1()); NodeEntry &n2 = getNode(ne.getNode2()); + // Sanity check on matrix dimensions: assert((n1.getCosts().getLength() == ne.getCosts().getRows()) && (n2.getCosts().getLength() == ne.getCosts().getCols()) && "Edge cost dimensions do not match node costs dimensions."); - ne.setNode1AEItr(n1.addEdge(edgeItr)); - ne.setNode2AEItr(n2.addEdge(edgeItr)); - return edgeItr; + + ne.setNode1AEItr(n1.addEdge(edgeId)); + ne.setNode2AEItr(n2.addEdge(edgeId)); + return edgeId; } inline void copyFrom(const Graph &other); public: + class NodeItr { + public: + NodeItr(NodeId nodeId, const Graph &g) + : nodeId(nodeId), endNodeId(g.nodes.size()), freeNodes(g.freeNodes) { + this->nodeId = findNextInUse(nodeId); // Move to the first in-use nodeId + } + + bool operator==(const NodeItr& n) const { return nodeId == n.nodeId; } + bool operator!=(const NodeItr& n) const { return !(*this == n); } + NodeItr& operator++() { nodeId = findNextInUse(++nodeId); return *this; } + NodeId operator*() const { return nodeId; } + + private: + NodeId findNextInUse(NodeId n) const { + while (n < endNodeId && + std::find(freeNodes.begin(), freeNodes.end(), n) != + freeNodes.end()) { + ++n; + } + return n; + } + + NodeId nodeId, endNodeId; + const FreeNodeVector& freeNodes; + }; + + class EdgeItr { + public: + EdgeItr(EdgeId edgeId, const Graph &g) + : edgeId(edgeId), endEdgeId(g.edges.size()), freeEdges(g.freeEdges) { + this->edgeId = findNextInUse(edgeId); // Move to the first in-use edgeId + } + + bool operator==(const EdgeItr& n) const { return edgeId == n.edgeId; } + bool operator!=(const EdgeItr& n) const { return !(*this == n); } + EdgeItr& operator++() { edgeId = findNextInUse(++edgeId); return *this; } + EdgeId operator*() const { return edgeId; } + + private: + EdgeId findNextInUse(EdgeId n) const { + while (n < endEdgeId && + std::find(freeEdges.begin(), freeEdges.end(), n) != + freeEdges.end()) { + ++n; + } + return n; + } + + EdgeId edgeId, endEdgeId; + const FreeEdgeVector& freeEdges; + }; + /// \brief Construct an empty PBQP graph. - Graph() : numNodes(0), numEdges(0) {} + Graph() {} /// \brief Copy construct this graph from "other". Note: Does not copy node /// and edge data, only graph structure and costs. /// @param other Source graph to copy from. - Graph(const Graph &other) : numNodes(0), numEdges(0) { + Graph(const Graph &other) { copyFrom(other); } @@ -170,7 +228,7 @@ namespace PBQP { /// \brief Add a node with the given costs. /// @param costs Cost vector for the new node. /// @return Node iterator for the added node. - NodeItr addNode(const Vector &costs) { + NodeId addNode(const Vector &costs) { return addConstructedNode(NodeEntry(costs)); } @@ -178,32 +236,31 @@ namespace PBQP { /// @param n1Itr First node. /// @param n2Itr Second node. /// @return Edge iterator for the added edge. - EdgeItr addEdge(Graph::NodeItr n1Itr, Graph::NodeItr n2Itr, - const Matrix &costs) { - assert(getNodeCosts(n1Itr).getLength() == costs.getRows() && - getNodeCosts(n2Itr).getLength() == costs.getCols() && + EdgeId addEdge(NodeId n1Id, NodeId n2Id, const Matrix &costs) { + assert(getNodeCosts(n1Id).getLength() == costs.getRows() && + getNodeCosts(n2Id).getLength() == costs.getCols() && "Matrix dimensions mismatch."); - return addConstructedEdge(EdgeEntry(n1Itr, n2Itr, costs)); + return addConstructedEdge(EdgeEntry(n1Id, n2Id, costs)); } /// \brief Get the number of nodes in the graph. /// @return Number of nodes in the graph. - unsigned getNumNodes() const { return numNodes; } + unsigned getNumNodes() const { return nodes.size() - freeNodes.size(); } /// \brief Get the number of edges in the graph. /// @return Number of edges in the graph. - unsigned getNumEdges() const { return numEdges; } + unsigned getNumEdges() const { return edges.size() - freeEdges.size(); } /// \brief Get a node's cost vector. /// @param nItr Node iterator. /// @return Node cost vector. - Vector& getNodeCosts(NodeItr nItr) { return getNode(nItr).getCosts(); } + Vector& getNodeCosts(NodeId nId) { return getNode(nId).getCosts(); } /// \brief Get a node's cost vector (const version). /// @param nItr Node iterator. /// @return Node cost vector. - const Vector& getNodeCosts(ConstNodeItr nItr) const { - return getNode(nItr).getCosts(); + const Vector& getNodeCosts(NodeId nId) const { + return getNode(nId).getCosts(); } /// \brief Set a node's data pointer. @@ -211,23 +268,23 @@ namespace PBQP { /// @param data Pointer to node data. /// /// Typically used by a PBQP solver to attach data to aid in solution. - void setNodeData(NodeItr nItr, void *data) { getNode(nItr).setData(data); } + void setNodeData(NodeId nId, void *data) { getNode(nId).setData(data); } /// \brief Get the node's data pointer. /// @param nItr Node iterator. /// @return Pointer to node data. - void* getNodeData(NodeItr nItr) { return getNode(nItr).getData(); } + void* getNodeData(NodeId nId) { return getNode(nId).getData(); } /// \brief Get an edge's cost matrix. /// @param eItr Edge iterator. /// @return Edge cost matrix. - Matrix& getEdgeCosts(EdgeItr eItr) { return getEdge(eItr).getCosts(); } + Matrix& getEdgeCosts(EdgeId eId) { return getEdge(eId).getCosts(); } /// \brief Get an edge's cost matrix (const version). /// @param eItr Edge iterator. /// @return Edge cost matrix. - const Matrix& getEdgeCosts(ConstEdgeItr eItr) const { - return getEdge(eItr).getCosts(); + const Matrix& getEdgeCosts(EdgeId eId) const { + return getEdge(eId).getCosts(); } /// \brief Set an edge's data pointer. @@ -235,124 +292,120 @@ namespace PBQP { /// @param data Pointer to edge data. /// /// Typically used by a PBQP solver to attach data to aid in solution. - void setEdgeData(EdgeItr eItr, void *data) { getEdge(eItr).setData(data); } + void setEdgeData(EdgeId eId, void *data) { getEdge(eId).setData(data); } /// \brief Get an edge's data pointer. /// @param eItr Edge iterator. /// @return Pointer to edge data. - void* getEdgeData(EdgeItr eItr) { return getEdge(eItr).getData(); } + void* getEdgeData(EdgeId eId) { return getEdge(eId).getData(); } /// \brief Get a node's degree. /// @param nItr Node iterator. /// @return The degree of the node. - unsigned getNodeDegree(NodeItr nItr) const { - return getNode(nItr).getDegree(); + unsigned getNodeDegree(NodeId nId) const { + return getNode(nId).getDegree(); } /// \brief Begin iterator for node set. - NodeItr nodesBegin() { return nodes.begin(); } - - /// \brief Begin const iterator for node set. - ConstNodeItr nodesBegin() const { return nodes.begin(); } + NodeItr nodesBegin() const { return NodeItr(0, *this); } /// \brief End iterator for node set. - NodeItr nodesEnd() { return nodes.end(); } - - /// \brief End const iterator for node set. - ConstNodeItr nodesEnd() const { return nodes.end(); } + NodeItr nodesEnd() const { return NodeItr(nodes.size(), *this); } /// \brief Begin iterator for edge set. - EdgeItr edgesBegin() { return edges.begin(); } + EdgeItr edgesBegin() const { return EdgeItr(0, *this); } /// \brief End iterator for edge set. - EdgeItr edgesEnd() { return edges.end(); } + EdgeItr edgesEnd() const { return EdgeItr(edges.size(), *this); } /// \brief Get begin iterator for adjacent edge set. /// @param nItr Node iterator. /// @return Begin iterator for the set of edges connected to the given node. - AdjEdgeItr adjEdgesBegin(NodeItr nItr) { - return getNode(nItr).edgesBegin(); + AdjEdgeItr adjEdgesBegin(NodeId nId) { + return getNode(nId).edgesBegin(); } /// \brief Get end iterator for adjacent edge set. /// @param nItr Node iterator. /// @return End iterator for the set of edges connected to the given node. - AdjEdgeItr adjEdgesEnd(NodeItr nItr) { - return getNode(nItr).edgesEnd(); + AdjEdgeItr adjEdgesEnd(NodeId nId) { + return getNode(nId).edgesEnd(); } /// \brief Get the first node connected to this edge. /// @param eItr Edge iterator. /// @return The first node connected to the given edge. - NodeItr getEdgeNode1(EdgeItr eItr) { - return getEdge(eItr).getNode1(); + NodeId getEdgeNode1(EdgeId eId) { + return getEdge(eId).getNode1(); } /// \brief Get the second node connected to this edge. /// @param eItr Edge iterator. /// @return The second node connected to the given edge. - NodeItr getEdgeNode2(EdgeItr eItr) { - return getEdge(eItr).getNode2(); + NodeId getEdgeNode2(EdgeId eId) { + return getEdge(eId).getNode2(); } /// \brief Get the "other" node connected to this edge. /// @param eItr Edge iterator. /// @param nItr Node iterator for the "given" node. /// @return The iterator for the "other" node connected to this edge. - NodeItr getEdgeOtherNode(EdgeItr eItr, NodeItr nItr) { - EdgeEntry &e = getEdge(eItr); - if (e.getNode1() == nItr) { + NodeId getEdgeOtherNode(EdgeId eId, NodeId nId) { + EdgeEntry &e = getEdge(eId); + if (e.getNode1() == nId) { return e.getNode2(); } // else return e.getNode1(); } + EdgeId invalidEdgeId() const { + return std::numeric_limits::max(); + } + /// \brief Get the edge connecting two nodes. - /// @param n1Itr First node iterator. - /// @param n2Itr Second node iterator. - /// @return An iterator for edge (n1Itr, n2Itr) if such an edge exists, - /// otherwise returns edgesEnd(). - EdgeItr findEdge(NodeItr n1Itr, NodeItr n2Itr) { - for (AdjEdgeItr aeItr = adjEdgesBegin(n1Itr), aeEnd = adjEdgesEnd(n1Itr); + /// @param n1Id First node id. + /// @param n2Id Second node id. + /// @return An id for edge (n1Id, n2Id) if such an edge exists, + /// otherwise returns an invalid edge id. + EdgeId findEdge(NodeId n1Id, NodeId n2Id) { + for (AdjEdgeItr aeItr = adjEdgesBegin(n1Id), aeEnd = adjEdgesEnd(n1Id); aeItr != aeEnd; ++aeItr) { - if ((getEdgeNode1(*aeItr) == n2Itr) || - (getEdgeNode2(*aeItr) == n2Itr)) { + if ((getEdgeNode1(*aeItr) == n2Id) || + (getEdgeNode2(*aeItr) == n2Id)) { return *aeItr; } } - return edges.end(); + return invalidEdgeId(); } /// \brief Remove a node from the graph. - /// @param nItr Node iterator. - void removeNode(NodeItr nItr) { - NodeEntry &n = getNode(nItr); - for (AdjEdgeItr itr = n.edgesBegin(), end = n.edgesEnd(); itr != end;) { - EdgeItr eItr = *itr; - ++itr; - removeEdge(eItr); + /// @param nItr Node id. + void removeNode(NodeId nId) { + NodeEntry &n = getNode(nId); + for (AdjEdgeItr itr = n.edgesBegin(), end = n.edgesEnd(); itr != end; ++itr) { + EdgeId eId = *itr; + removeEdge(eId); } - nodes.erase(nItr); - --numNodes; + freeNodes.push_back(nId); } /// \brief Remove an edge from the graph. /// @param eItr Edge iterator. - void removeEdge(EdgeItr eItr) { - EdgeEntry &e = getEdge(eItr); + void removeEdge(EdgeId eId) { + EdgeEntry &e = getEdge(eId); NodeEntry &n1 = getNode(e.getNode1()); NodeEntry &n2 = getNode(e.getNode2()); n1.removeEdge(e.getNode1AEItr()); n2.removeEdge(e.getNode2AEItr()); - edges.erase(eItr); - --numEdges; + freeEdges.push_back(eId); } /// \brief Remove all nodes and edges from the graph. void clear() { nodes.clear(); + freeNodes.clear(); edges.clear(); - numNodes = numEdges = 0; + freeEdges.clear(); } /// \brief Dump a graph to an output stream. @@ -362,7 +415,7 @@ namespace PBQP { for (NodeItr nodeItr = nodesBegin(), nodeEnd = nodesEnd(); nodeItr != nodeEnd; ++nodeItr) { - const Vector& v = getNodeCosts(nodeItr); + const Vector& v = getNodeCosts(*nodeItr); os << "\n" << v.getLength() << "\n"; assert(v.getLength() != 0 && "Empty vector in graph."); os << v[0]; @@ -374,10 +427,10 @@ namespace PBQP { for (EdgeItr edgeItr = edgesBegin(), edgeEnd = edgesEnd(); edgeItr != edgeEnd; ++edgeItr) { - unsigned n1 = std::distance(nodesBegin(), getEdgeNode1(edgeItr)); - unsigned n2 = std::distance(nodesBegin(), getEdgeNode2(edgeItr)); + NodeId n1 = getEdgeNode1(*edgeItr); + NodeId n2 = getEdgeNode2(*edgeItr); assert(n1 != n2 && "PBQP graphs shound not have self-edges."); - const Matrix& m = getEdgeCosts(edgeItr); + const Matrix& m = getEdgeCosts(*edgeItr); os << "\n" << n1 << " " << n2 << "\n" << m.getRows() << " " << m.getCols() << "\n"; assert(m.getRows() != 0 && "No rows in matrix."); @@ -403,7 +456,7 @@ namespace PBQP { nodeItr != nodeEnd; ++nodeItr) { os << " node" << nodeItr << " [ label=\"" - << nodeItr << ": " << getNodeCosts(nodeItr) << "\" ]\n"; + << nodeItr << ": " << getNodeCosts(*nodeItr) << "\" ]\n"; } os << " edge [ len=" << getNumNodes() << " ]\n"; @@ -411,11 +464,11 @@ namespace PBQP { for (EdgeItr edgeItr = edgesBegin(), edgeEnd = edgesEnd(); edgeItr != edgeEnd; ++edgeItr) { - os << " node" << getEdgeNode1(edgeItr) - << " -- node" << getEdgeNode2(edgeItr) + os << " node" << getEdgeNode1(*edgeItr) + << " -- node" << getEdgeNode2(*edgeItr) << " [ label=\""; - const Matrix &edgeCosts = getEdgeCosts(edgeItr); + const Matrix &edgeCosts = getEdgeCosts(*edgeItr); for (unsigned i = 0; i < edgeCosts.getRows(); ++i) { os << edgeCosts.getRowAsVector(i) << "\\n"; @@ -427,39 +480,16 @@ namespace PBQP { }; - class NodeItrComparator { - public: - bool operator()(Graph::NodeItr n1, Graph::NodeItr n2) const { - return &*n1 < &*n2; - } - - bool operator()(Graph::ConstNodeItr n1, Graph::ConstNodeItr n2) const { - return &*n1 < &*n2; - } - }; - - class EdgeItrCompartor { - public: - bool operator()(Graph::EdgeItr e1, Graph::EdgeItr e2) const { - return &*e1 < &*e2; - } - - bool operator()(Graph::ConstEdgeItr e1, Graph::ConstEdgeItr e2) const { - return &*e1 < &*e2; - } - }; - - void Graph::copyFrom(const Graph &other) { - std::map nodeMap; +// void Graph::copyFrom(const Graph &other) { +// std::map nodeMap; - for (Graph::ConstNodeItr nItr = other.nodesBegin(), - nEnd = other.nodesEnd(); - nItr != nEnd; ++nItr) { - nodeMap[nItr] = addNode(other.getNodeCosts(nItr)); - } - - } +// for (Graph::ConstNodeItr nItr = other.nodesBegin(), +// nEnd = other.nodesEnd(); +// nItr != nEnd; ++nItr) { +// nodeMap[nItr] = addNode(other.getNodeCosts(nItr)); +// } +// } } diff --git a/include/llvm/CodeGen/PBQP/HeuristicBase.h b/include/llvm/CodeGen/PBQP/HeuristicBase.h index 0c1fcb7..36d94d6 100644 --- a/include/llvm/CodeGen/PBQP/HeuristicBase.h +++ b/include/llvm/CodeGen/PBQP/HeuristicBase.h @@ -52,7 +52,7 @@ namespace PBQP { class HeuristicBase { private: - typedef std::list OptimalList; + typedef std::list OptimalList; HeuristicSolverImpl &s; Graph &g; @@ -63,8 +63,8 @@ namespace PBQP { // Add the given node to the optimal reductions list. Keep an iterator to // its location for fast removal. - void addToOptimalReductionList(Graph::NodeItr nItr) { - optimalList.insert(optimalList.end(), nItr); + void addToOptimalReductionList(Graph::NodeId nId) { + optimalList.insert(optimalList.end(), nId); } public: @@ -105,8 +105,8 @@ namespace PBQP { /// criteria. Note however that your criteria for selecting optimal nodes /// should be at least as strong as this. I.e. Nodes of degree 3 or /// higher should not be selected under any circumstances. - bool shouldOptimallyReduce(Graph::NodeItr nItr) { - if (g.getNodeDegree(nItr) < 3) + bool shouldOptimallyReduce(Graph::NodeId nId) { + if (g.getNodeDegree(nId) < 3) return true; // else return false; @@ -118,8 +118,8 @@ namespace PBQP { /// You probably don't want to over-ride this, except perhaps to record /// statistics before calling this implementation. HeuristicBase relies on /// its behaviour. - void addToOptimalReduceList(Graph::NodeItr nItr) { - optimalList.push_back(nItr); + void addToOptimalReduceList(Graph::NodeId nId) { + optimalList.push_back(nId); } /// \brief Initialise the heuristic. @@ -132,10 +132,10 @@ namespace PBQP { void setup() { for (Graph::NodeItr nItr = g.nodesBegin(), nEnd = g.nodesEnd(); nItr != nEnd; ++nItr) { - if (impl().shouldOptimallyReduce(nItr)) { - addToOptimalReduceList(nItr); + if (impl().shouldOptimallyReduce(*nItr)) { + addToOptimalReduceList(*nItr); } else { - impl().addToHeuristicReduceList(nItr); + impl().addToHeuristicReduceList(*nItr); } } } @@ -150,13 +150,13 @@ namespace PBQP { if (optimalList.empty()) return false; - Graph::NodeItr nItr = optimalList.front(); + Graph::NodeId nId = optimalList.front(); optimalList.pop_front(); - switch (s.getSolverDegree(nItr)) { - case 0: s.applyR0(nItr); break; - case 1: s.applyR1(nItr); break; - case 2: s.applyR2(nItr); break; + switch (s.getSolverDegree(nId)) { + case 0: s.applyR0(nId); break; + case 1: s.applyR1(nId); break; + case 2: s.applyR2(nId); break; default: llvm_unreachable( "Optimal reductions of degree > 2 nodes is invalid."); } @@ -185,7 +185,7 @@ namespace PBQP { /// \brief Add a node to the heuristic reduce list. /// @param nItr Node iterator to add to the heuristic reduce list. - void addToHeuristicList(Graph::NodeItr nItr) { + void addToHeuristicList(Graph::NodeId nId) { llvm_unreachable("Must be implemented in derived class."); } @@ -200,19 +200,19 @@ namespace PBQP { /// \brief Prepare a change in the costs on the given edge. /// @param eItr Edge iterator. - void preUpdateEdgeCosts(Graph::EdgeItr eItr) { + void preUpdateEdgeCosts(Graph::EdgeId eId) { llvm_unreachable("Must be implemented in derived class."); } /// \brief Handle the change in the costs on the given edge. /// @param eItr Edge iterator. - void postUpdateEdgeCostts(Graph::EdgeItr eItr) { + void postUpdateEdgeCostts(Graph::EdgeId eId) { llvm_unreachable("Must be implemented in derived class."); } /// \brief Handle the addition of a new edge into the PBQP graph. /// @param eItr Edge iterator for the added edge. - void handleAddEdge(Graph::EdgeItr eItr) { + void handleAddEdge(Graph::EdgeId eId) { llvm_unreachable("Must be implemented in derived class."); } @@ -223,7 +223,7 @@ namespace PBQP { /// Edges are frequently removed due to the removal of a node. This /// method allows for the effect to be computed only for the remaining /// node in the graph. - void handleRemoveEdge(Graph::EdgeItr eItr, Graph::NodeItr nItr) { + void handleRemoveEdge(Graph::EdgeId eId, Graph::NodeId nId) { llvm_unreachable("Must be implemented in derived class."); } diff --git a/include/llvm/CodeGen/PBQP/HeuristicSolver.h b/include/llvm/CodeGen/PBQP/HeuristicSolver.h index 47e15b2..7fa6386 100644 --- a/include/llvm/CodeGen/PBQP/HeuristicSolver.h +++ b/include/llvm/CodeGen/PBQP/HeuristicSolver.h @@ -40,7 +40,7 @@ namespace PBQP { typedef typename HImpl::NodeData HeuristicNodeData; typedef typename HImpl::EdgeData HeuristicEdgeData; - typedef std::list SolverEdges; + typedef std::list SolverEdges; public: @@ -55,9 +55,9 @@ namespace PBQP { HeuristicNodeData& getHeuristicData() { return hData; } - SolverEdgeItr addSolverEdge(Graph::EdgeItr eItr) { + SolverEdgeItr addSolverEdge(Graph::EdgeId eId) { ++solverDegree; - return solverEdges.insert(solverEdges.end(), eItr); + return solverEdges.insert(solverEdges.end(), eId); } void removeSolverEdge(SolverEdgeItr seItr) { @@ -104,7 +104,7 @@ namespace PBQP { Graph &g; HImpl h; Solution s; - std::vector stack; + std::vector stack; typedef std::list NodeDataList; NodeDataList nodeDataList; @@ -127,15 +127,15 @@ namespace PBQP { /// \brief Get the heuristic data attached to the given node. /// @param nItr Node iterator. /// @return The heuristic data attached to the given node. - HeuristicNodeData& getHeuristicNodeData(Graph::NodeItr nItr) { - return getSolverNodeData(nItr).getHeuristicData(); + HeuristicNodeData& getHeuristicNodeData(Graph::NodeId nId) { + return getSolverNodeData(nId).getHeuristicData(); } /// \brief Get the heuristic data attached to the given edge. /// @param eItr Edge iterator. /// @return The heuristic data attached to the given node. - HeuristicEdgeData& getHeuristicEdgeData(Graph::EdgeItr eItr) { - return getSolverEdgeData(eItr).getHeuristicData(); + HeuristicEdgeData& getHeuristicEdgeData(Graph::EdgeId eId) { + return getSolverEdgeData(eId).getHeuristicData(); } /// \brief Begin iterator for the set of edges adjacent to the given node in @@ -143,8 +143,8 @@ namespace PBQP { /// @param nItr Node iterator. /// @return Begin iterator for the set of edges adjacent to the given node /// in the solver graph. - SolverEdgeItr solverEdgesBegin(Graph::NodeItr nItr) { - return getSolverNodeData(nItr).solverEdgesBegin(); + SolverEdgeItr solverEdgesBegin(Graph::NodeId nId) { + return getSolverNodeData(nId).solverEdgesBegin(); } /// \brief End iterator for the set of edges adjacent to the given node in @@ -152,8 +152,8 @@ namespace PBQP { /// @param nItr Node iterator. /// @return End iterator for the set of edges adjacent to the given node in /// the solver graph. - SolverEdgeItr solverEdgesEnd(Graph::NodeItr nItr) { - return getSolverNodeData(nItr).solverEdgesEnd(); + SolverEdgeItr solverEdgesEnd(Graph::NodeId nId) { + return getSolverNodeData(nId).solverEdgesEnd(); } /// \brief Remove a node from the solver graph. @@ -161,10 +161,10 @@ namespace PBQP { /// /// Does not notify the heuristic of the removal. That should be /// done manually if necessary. - void removeSolverEdge(Graph::EdgeItr eItr) { - EdgeData &eData = getSolverEdgeData(eItr); - NodeData &n1Data = getSolverNodeData(g.getEdgeNode1(eItr)), - &n2Data = getSolverNodeData(g.getEdgeNode2(eItr)); + void removeSolverEdge(Graph::EdgeId eId) { + EdgeData &eData = getSolverEdgeData(eId); + NodeData &n1Data = getSolverNodeData(g.getEdgeNode1(eId)), + &n2Data = getSolverNodeData(g.getEdgeNode2(eId)); n1Data.removeSolverEdge(eData.getN1SolverEdgeItr()); n2Data.removeSolverEdge(eData.getN2SolverEdgeItr()); @@ -189,30 +189,30 @@ namespace PBQP { /// \brief Add to the end of the stack. /// @param nItr Node iterator to add to the reduction stack. - void pushToStack(Graph::NodeItr nItr) { - getSolverNodeData(nItr).clearSolverEdges(); - stack.push_back(nItr); + void pushToStack(Graph::NodeId nId) { + getSolverNodeData(nId).clearSolverEdges(); + stack.push_back(nId); } /// \brief Returns the solver degree of the given node. /// @param nItr Node iterator for which degree is requested. /// @return Node degree in the solver graph (not the original graph). - unsigned getSolverDegree(Graph::NodeItr nItr) { - return getSolverNodeData(nItr).getSolverDegree(); + unsigned getSolverDegree(Graph::NodeId nId) { + return getSolverNodeData(nId).getSolverDegree(); } /// \brief Set the solution of the given node. /// @param nItr Node iterator to set solution for. /// @param selection Selection for node. - void setSolution(const Graph::NodeItr &nItr, unsigned selection) { - s.setSelection(nItr, selection); + void setSolution(const Graph::NodeId &nId, unsigned selection) { + s.setSelection(nId, selection); - for (Graph::AdjEdgeItr aeItr = g.adjEdgesBegin(nItr), - aeEnd = g.adjEdgesEnd(nItr); + for (Graph::AdjEdgeItr aeItr = g.adjEdgesBegin(nId), + aeEnd = g.adjEdgesEnd(nId); aeItr != aeEnd; ++aeItr) { - Graph::EdgeItr eItr(*aeItr); - Graph::NodeItr anItr(g.getEdgeOtherNode(eItr, nItr)); - getSolverNodeData(anItr).addSolverEdge(eItr); + Graph::EdgeId eId(*aeItr); + Graph::NodeId anId(g.getEdgeOtherNode(eId, nId)); + getSolverNodeData(anId).addSolverEdge(eId); } } @@ -220,12 +220,12 @@ namespace PBQP { /// @param nItr Node iterator for node to apply R0 to. /// /// Node will be automatically pushed to the solver stack. - void applyR0(Graph::NodeItr nItr) { - assert(getSolverNodeData(nItr).getSolverDegree() == 0 && + void applyR0(Graph::NodeId nId) { + assert(getSolverNodeData(nId).getSolverDegree() == 0 && "R0 applied to node with degree != 0."); // Nothing to do. Just push the node onto the reduction stack. - pushToStack(nItr); + pushToStack(nId); s.recordR0(); } @@ -234,20 +234,20 @@ namespace PBQP { /// @param xnItr Node iterator for node to apply R1 to. /// /// Node will be automatically pushed to the solver stack. - void applyR1(Graph::NodeItr xnItr) { - NodeData &nd = getSolverNodeData(xnItr); + void applyR1(Graph::NodeId xnId) { + NodeData &nd = getSolverNodeData(xnId); assert(nd.getSolverDegree() == 1 && "R1 applied to node with degree != 1."); - Graph::EdgeItr eItr = *nd.solverEdgesBegin(); + Graph::EdgeId eId = *nd.solverEdgesBegin(); - const Matrix &eCosts = g.getEdgeCosts(eItr); - const Vector &xCosts = g.getNodeCosts(xnItr); + const Matrix &eCosts = g.getEdgeCosts(eId); + const Vector &xCosts = g.getNodeCosts(xnId); // Duplicate a little to avoid transposing matrices. - if (xnItr == g.getEdgeNode1(eItr)) { - Graph::NodeItr ynItr = g.getEdgeNode2(eItr); - Vector &yCosts = g.getNodeCosts(ynItr); + if (xnId == g.getEdgeNode1(eId)) { + Graph::NodeId ynId = g.getEdgeNode2(eId); + Vector &yCosts = g.getNodeCosts(ynId); for (unsigned j = 0; j < yCosts.getLength(); ++j) { PBQPNum min = eCosts[0][j] + xCosts[0]; for (unsigned i = 1; i < xCosts.getLength(); ++i) { @@ -257,10 +257,10 @@ namespace PBQP { } yCosts[j] += min; } - h.handleRemoveEdge(eItr, ynItr); + h.handleRemoveEdge(eId, ynId); } else { - Graph::NodeItr ynItr = g.getEdgeNode1(eItr); - Vector &yCosts = g.getNodeCosts(ynItr); + Graph::NodeId ynId = g.getEdgeNode1(eId); + Vector &yCosts = g.getNodeCosts(ynId); for (unsigned i = 0; i < yCosts.getLength(); ++i) { PBQPNum min = eCosts[i][0] + xCosts[0]; for (unsigned j = 1; j < xCosts.getLength(); ++j) { @@ -270,12 +270,12 @@ namespace PBQP { } yCosts[i] += min; } - h.handleRemoveEdge(eItr, ynItr); + h.handleRemoveEdge(eId, ynId); } - removeSolverEdge(eItr); + removeSolverEdge(eId); assert(nd.getSolverDegree() == 0 && "Degree 1 with edge removed should be 0."); - pushToStack(xnItr); + pushToStack(xnId); s.recordR1(); } @@ -283,30 +283,30 @@ namespace PBQP { /// @param xnItr Node iterator for node to apply R2 to. /// /// Node will be automatically pushed to the solver stack. - void applyR2(Graph::NodeItr xnItr) { - assert(getSolverNodeData(xnItr).getSolverDegree() == 2 && + void applyR2(Graph::NodeId xnId) { + assert(getSolverNodeData(xnId).getSolverDegree() == 2 && "R2 applied to node with degree != 2."); - NodeData &nd = getSolverNodeData(xnItr); - const Vector &xCosts = g.getNodeCosts(xnItr); + NodeData &nd = getSolverNodeData(xnId); + const Vector &xCosts = g.getNodeCosts(xnId); SolverEdgeItr aeItr = nd.solverEdgesBegin(); - Graph::EdgeItr yxeItr = *aeItr, - zxeItr = *(++aeItr); + Graph::EdgeId yxeId = *aeItr, + zxeId = *(++aeItr); - Graph::NodeItr ynItr = g.getEdgeOtherNode(yxeItr, xnItr), - znItr = g.getEdgeOtherNode(zxeItr, xnItr); + Graph::NodeId ynId = g.getEdgeOtherNode(yxeId, xnId), + znId = g.getEdgeOtherNode(zxeId, xnId); - bool flipEdge1 = (g.getEdgeNode1(yxeItr) == xnItr), - flipEdge2 = (g.getEdgeNode1(zxeItr) == xnItr); + bool flipEdge1 = (g.getEdgeNode1(yxeId) == xnId), + flipEdge2 = (g.getEdgeNode1(zxeId) == xnId); const Matrix *yxeCosts = flipEdge1 ? - new Matrix(g.getEdgeCosts(yxeItr).transpose()) : - &g.getEdgeCosts(yxeItr); + new Matrix(g.getEdgeCosts(yxeId).transpose()) : + &g.getEdgeCosts(yxeId); const Matrix *zxeCosts = flipEdge2 ? - new Matrix(g.getEdgeCosts(zxeItr).transpose()) : - &g.getEdgeCosts(zxeItr); + new Matrix(g.getEdgeCosts(zxeId).transpose()) : + &g.getEdgeCosts(zxeId); unsigned xLen = xCosts.getLength(), yLen = yxeCosts->getRows(), @@ -333,27 +333,27 @@ namespace PBQP { if (flipEdge2) delete zxeCosts; - Graph::EdgeItr yzeItr = g.findEdge(ynItr, znItr); + Graph::EdgeId yzeId = g.findEdge(ynId, znId); bool addedEdge = false; - if (yzeItr == g.edgesEnd()) { - yzeItr = g.addEdge(ynItr, znItr, delta); + if (yzeId == g.invalidEdgeId()) { + yzeId = g.addEdge(ynId, znId, delta); addedEdge = true; } else { - Matrix &yzeCosts = g.getEdgeCosts(yzeItr); - h.preUpdateEdgeCosts(yzeItr); - if (ynItr == g.getEdgeNode1(yzeItr)) { + Matrix &yzeCosts = g.getEdgeCosts(yzeId); + h.preUpdateEdgeCosts(yzeId); + if (ynId == g.getEdgeNode1(yzeId)) { yzeCosts += delta; } else { yzeCosts += delta.transpose(); } } - bool nullCostEdge = tryNormaliseEdgeMatrix(yzeItr); + bool nullCostEdge = tryNormaliseEdgeMatrix(yzeId); if (!addedEdge) { // If we modified the edge costs let the heuristic know. - h.postUpdateEdgeCosts(yzeItr); + h.postUpdateEdgeCosts(yzeId); } if (nullCostEdge) { @@ -361,26 +361,26 @@ namespace PBQP { if (!addedEdge) { // We didn't just add it, so we need to notify the heuristic // and remove it from the solver. - h.handleRemoveEdge(yzeItr, ynItr); - h.handleRemoveEdge(yzeItr, znItr); - removeSolverEdge(yzeItr); + h.handleRemoveEdge(yzeId, ynId); + h.handleRemoveEdge(yzeId, znId); + removeSolverEdge(yzeId); } - g.removeEdge(yzeItr); + g.removeEdge(yzeId); } else if (addedEdge) { // If the edge was added, and non-null, finish setting it up, add it to // the solver & notify heuristic. edgeDataList.push_back(EdgeData()); - g.setEdgeData(yzeItr, &edgeDataList.back()); - addSolverEdge(yzeItr); - h.handleAddEdge(yzeItr); + g.setEdgeData(yzeId, &edgeDataList.back()); + addSolverEdge(yzeId); + h.handleAddEdge(yzeId); } - h.handleRemoveEdge(yxeItr, ynItr); - removeSolverEdge(yxeItr); - h.handleRemoveEdge(zxeItr, znItr); - removeSolverEdge(zxeItr); + h.handleRemoveEdge(yxeId, ynId); + removeSolverEdge(yxeId); + h.handleRemoveEdge(zxeId, znId); + removeSolverEdge(zxeId); - pushToStack(xnItr); + pushToStack(xnId); s.recordR2(); } @@ -391,21 +391,21 @@ namespace PBQP { private: - NodeData& getSolverNodeData(Graph::NodeItr nItr) { - return *static_cast(g.getNodeData(nItr)); + NodeData& getSolverNodeData(Graph::NodeId nId) { + return *static_cast(g.getNodeData(nId)); } - EdgeData& getSolverEdgeData(Graph::EdgeItr eItr) { - return *static_cast(g.getEdgeData(eItr)); + EdgeData& getSolverEdgeData(Graph::EdgeId eId) { + return *static_cast(g.getEdgeData(eId)); } - void addSolverEdge(Graph::EdgeItr eItr) { - EdgeData &eData = getSolverEdgeData(eItr); - NodeData &n1Data = getSolverNodeData(g.getEdgeNode1(eItr)), - &n2Data = getSolverNodeData(g.getEdgeNode2(eItr)); + void addSolverEdge(Graph::EdgeId eId) { + EdgeData &eData = getSolverEdgeData(eId); + NodeData &n1Data = getSolverNodeData(g.getEdgeNode1(eId)), + &n2Data = getSolverNodeData(g.getEdgeNode2(eId)); - eData.setN1SolverEdgeItr(n1Data.addSolverEdge(eItr)); - eData.setN2SolverEdgeItr(n2Data.addSolverEdge(eItr)); + eData.setN1SolverEdgeItr(n1Data.addSolverEdge(eId)); + eData.setN2SolverEdgeItr(n2Data.addSolverEdge(eId)); } void setup() { @@ -417,15 +417,15 @@ namespace PBQP { for (Graph::NodeItr nItr = g.nodesBegin(), nEnd = g.nodesEnd(); nItr != nEnd; ++nItr) { nodeDataList.push_back(NodeData()); - g.setNodeData(nItr, &nodeDataList.back()); + g.setNodeData(*nItr, &nodeDataList.back()); } // Create edge data objects. for (Graph::EdgeItr eItr = g.edgesBegin(), eEnd = g.edgesEnd(); eItr != eEnd; ++eItr) { edgeDataList.push_back(EdgeData()); - g.setEdgeData(eItr, &edgeDataList.back()); - addSolverEdge(eItr); + g.setEdgeData(*eItr, &edgeDataList.back()); + addSolverEdge(*eItr); } } @@ -441,28 +441,30 @@ namespace PBQP { for (Graph::NodeItr nItr = g.nodesBegin(), nEnd = g.nodesEnd(); nItr != nEnd; ++nItr) { - if (g.getNodeCosts(nItr).getLength() == 1) { + Graph::NodeId nId = *nItr; - std::vector edgesToRemove; + if (g.getNodeCosts(nId).getLength() == 1) { - for (Graph::AdjEdgeItr aeItr = g.adjEdgesBegin(nItr), - aeEnd = g.adjEdgesEnd(nItr); + std::vector edgesToRemove; + + for (Graph::AdjEdgeItr aeItr = g.adjEdgesBegin(nId), + aeEnd = g.adjEdgesEnd(nId); aeItr != aeEnd; ++aeItr) { - Graph::EdgeItr eItr = *aeItr; + Graph::EdgeId eId = *aeItr; - if (g.getEdgeNode1(eItr) == nItr) { - Graph::NodeItr otherNodeItr = g.getEdgeNode2(eItr); - g.getNodeCosts(otherNodeItr) += - g.getEdgeCosts(eItr).getRowAsVector(0); + if (g.getEdgeNode1(eId) == nId) { + Graph::NodeId otherNodeId = g.getEdgeNode2(eId); + g.getNodeCosts(otherNodeId) += + g.getEdgeCosts(eId).getRowAsVector(0); } else { - Graph::NodeItr otherNodeItr = g.getEdgeNode1(eItr); - g.getNodeCosts(otherNodeItr) += - g.getEdgeCosts(eItr).getColAsVector(0); + Graph::NodeId otherNodeId = g.getEdgeNode1(eId); + g.getNodeCosts(otherNodeId) += + g.getEdgeCosts(eId).getColAsVector(0); } - edgesToRemove.push_back(eItr); + edgesToRemove.push_back(eId); } if (!edgesToRemove.empty()) @@ -477,12 +479,12 @@ namespace PBQP { } void eliminateIndependentEdges() { - std::vector edgesToProcess; + std::vector edgesToProcess; unsigned numEliminated = 0; for (Graph::EdgeItr eItr = g.edgesBegin(), eEnd = g.edgesEnd(); eItr != eEnd; ++eItr) { - edgesToProcess.push_back(eItr); + edgesToProcess.push_back(*eItr); } while (!edgesToProcess.empty()) { @@ -492,21 +494,21 @@ namespace PBQP { } } - bool tryToEliminateEdge(Graph::EdgeItr eItr) { - if (tryNormaliseEdgeMatrix(eItr)) { - g.removeEdge(eItr); + bool tryToEliminateEdge(Graph::EdgeId eId) { + if (tryNormaliseEdgeMatrix(eId)) { + g.removeEdge(eId); return true; } return false; } - bool tryNormaliseEdgeMatrix(Graph::EdgeItr &eItr) { + bool tryNormaliseEdgeMatrix(Graph::EdgeId &eId) { const PBQPNum infinity = std::numeric_limits::infinity(); - Matrix &edgeCosts = g.getEdgeCosts(eItr); - Vector &uCosts = g.getNodeCosts(g.getEdgeNode1(eItr)), - &vCosts = g.getNodeCosts(g.getEdgeNode2(eItr)); + Matrix &edgeCosts = g.getEdgeCosts(eId); + Vector &uCosts = g.getNodeCosts(g.getEdgeNode1(eId)), + &vCosts = g.getNodeCosts(g.getEdgeNode2(eId)); for (unsigned r = 0; r < edgeCosts.getRows(); ++r) { PBQPNum rowMin = infinity; @@ -554,34 +556,34 @@ namespace PBQP { } } - void computeSolution(Graph::NodeItr nItr) { + void computeSolution(Graph::NodeId nId) { - NodeData &nodeData = getSolverNodeData(nItr); + NodeData &nodeData = getSolverNodeData(nId); - Vector v(g.getNodeCosts(nItr)); + Vector v(g.getNodeCosts(nId)); // Solve based on existing solved edges. for (SolverEdgeItr solvedEdgeItr = nodeData.solverEdgesBegin(), solvedEdgeEnd = nodeData.solverEdgesEnd(); solvedEdgeItr != solvedEdgeEnd; ++solvedEdgeItr) { - Graph::EdgeItr eItr(*solvedEdgeItr); - Matrix &edgeCosts = g.getEdgeCosts(eItr); + Graph::EdgeId eId(*solvedEdgeItr); + Matrix &edgeCosts = g.getEdgeCosts(eId); - if (nItr == g.getEdgeNode1(eItr)) { - Graph::NodeItr adjNode(g.getEdgeNode2(eItr)); + if (nId == g.getEdgeNode1(eId)) { + Graph::NodeId adjNode(g.getEdgeNode2(eId)); unsigned adjSolution = s.getSelection(adjNode); v += edgeCosts.getColAsVector(adjSolution); } else { - Graph::NodeItr adjNode(g.getEdgeNode1(eItr)); + Graph::NodeId adjNode(g.getEdgeNode1(eId)); unsigned adjSolution = s.getSelection(adjNode); v += edgeCosts.getRowAsVector(adjSolution); } } - setSolution(nItr, v.minIndex()); + setSolution(nId, v.minIndex()); } void cleanup() { diff --git a/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h b/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h index 307d81e..9663b26 100644 --- a/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h +++ b/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h @@ -47,8 +47,8 @@ namespace PBQP { class LinkDegreeComparator { public: LinkDegreeComparator(HeuristicSolverImpl &s) : s(&s) {} - bool operator()(Graph::NodeItr n1Itr, Graph::NodeItr n2Itr) const { - if (s->getSolverDegree(n1Itr) > s->getSolverDegree(n2Itr)) + bool operator()(Graph::NodeId n1Id, Graph::NodeId n2Id) const { + if (s->getSolverDegree(n1Id) > s->getSolverDegree(n2Id)) return true; return false; } @@ -60,12 +60,12 @@ namespace PBQP { public: SpillCostComparator(HeuristicSolverImpl &s) : s(&s), g(&s.getGraph()) {} - bool operator()(Graph::NodeItr n1Itr, Graph::NodeItr n2Itr) const { - const PBQP::Vector &cv1 = g->getNodeCosts(n1Itr); - const PBQP::Vector &cv2 = g->getNodeCosts(n2Itr); + bool operator()(Graph::NodeId n1Id, Graph::NodeId n2Id) const { + const PBQP::Vector &cv1 = g->getNodeCosts(n1Id); + const PBQP::Vector &cv2 = g->getNodeCosts(n2Id); - PBQPNum cost1 = cv1[0] / s->getSolverDegree(n1Itr); - PBQPNum cost2 = cv2[0] / s->getSolverDegree(n2Itr); + PBQPNum cost1 = cv1[0] / s->getSolverDegree(n1Id); + PBQPNum cost2 = cv2[0] / s->getSolverDegree(n2Id); if (cost1 < cost2) return true; @@ -77,10 +77,10 @@ namespace PBQP { Graph *g; }; - typedef std::list RNAllocableList; + typedef std::list RNAllocableList; typedef RNAllocableList::iterator RNAllocableListItr; - typedef std::list RNUnallocableList; + typedef std::list RNUnallocableList; typedef RNUnallocableList::iterator RNUnallocableListItr; public: @@ -123,8 +123,8 @@ namespace PBQP { /// infinite are checked for allocability first. Allocable nodes may be /// optimally reduced, but nodes whose allocability cannot be proven are /// selected for heuristic reduction instead. - bool shouldOptimallyReduce(Graph::NodeItr nItr) { - if (getSolver().getSolverDegree(nItr) < 3) { + bool shouldOptimallyReduce(Graph::NodeId nId) { + if (getSolver().getSolverDegree(nId) < 3) { return true; } // else @@ -133,14 +133,14 @@ namespace PBQP { /// \brief Add a node to the heuristic reduce list. /// @param nItr Node iterator to add to the heuristic reduce list. - void addToHeuristicReduceList(Graph::NodeItr nItr) { - NodeData &nd = getHeuristicNodeData(nItr); - initializeNode(nItr); + void addToHeuristicReduceList(Graph::NodeId nId) { + NodeData &nd = getHeuristicNodeData(nId); + initializeNode(nId); nd.isHeuristic = true; if (nd.isAllocable) { - nd.rnaItr = rnAllocableList.insert(rnAllocableList.end(), nItr); + nd.rnaItr = rnAllocableList.insert(rnAllocableList.end(), nId); } else { - nd.rnuItr = rnUnallocableList.insert(rnUnallocableList.end(), nItr); + nd.rnuItr = rnUnallocableList.insert(rnUnallocableList.end(), nId); } } @@ -159,19 +159,19 @@ namespace PBQP { RNAllocableListItr rnaItr = min_element(rnAllocableList.begin(), rnAllocableList.end(), LinkDegreeComparator(getSolver())); - Graph::NodeItr nItr = *rnaItr; + Graph::NodeId nId = *rnaItr; rnAllocableList.erase(rnaItr); - handleRemoveNode(nItr); - getSolver().pushToStack(nItr); + handleRemoveNode(nId); + getSolver().pushToStack(nId); return true; } else if (!rnUnallocableList.empty()) { RNUnallocableListItr rnuItr = min_element(rnUnallocableList.begin(), rnUnallocableList.end(), SpillCostComparator(getSolver())); - Graph::NodeItr nItr = *rnuItr; + Graph::NodeId nId = *rnuItr; rnUnallocableList.erase(rnuItr); - handleRemoveNode(nItr); - getSolver().pushToStack(nItr); + handleRemoveNode(nId); + getSolver().pushToStack(nId); return true; } // else @@ -180,28 +180,28 @@ namespace PBQP { /// \brief Prepare a change in the costs on the given edge. /// @param eItr Edge iterator. - void preUpdateEdgeCosts(Graph::EdgeItr eItr) { + void preUpdateEdgeCosts(Graph::EdgeId eId) { Graph &g = getGraph(); - Graph::NodeItr n1Itr = g.getEdgeNode1(eItr), - n2Itr = g.getEdgeNode2(eItr); - NodeData &n1 = getHeuristicNodeData(n1Itr), - &n2 = getHeuristicNodeData(n2Itr); + Graph::NodeId n1Id = g.getEdgeNode1(eId), + n2Id = g.getEdgeNode2(eId); + NodeData &n1 = getHeuristicNodeData(n1Id), + &n2 = getHeuristicNodeData(n2Id); if (n1.isHeuristic) - subtractEdgeContributions(eItr, getGraph().getEdgeNode1(eItr)); + subtractEdgeContributions(eId, getGraph().getEdgeNode1(eId)); if (n2.isHeuristic) - subtractEdgeContributions(eItr, getGraph().getEdgeNode2(eItr)); + subtractEdgeContributions(eId, getGraph().getEdgeNode2(eId)); - EdgeData &ed = getHeuristicEdgeData(eItr); + EdgeData &ed = getHeuristicEdgeData(eId); ed.isUpToDate = false; } /// \brief Handle the change in the costs on the given edge. /// @param eItr Edge iterator. - void postUpdateEdgeCosts(Graph::EdgeItr eItr) { + void postUpdateEdgeCosts(Graph::EdgeId eId) { // This is effectively the same as adding a new edge now, since // we've factored out the costs of the old one. - handleAddEdge(eItr); + handleAddEdge(eId); } /// \brief Handle the addition of a new edge into the PBQP graph. @@ -210,12 +210,12 @@ namespace PBQP { /// Updates allocability of any nodes connected by this edge which are /// being managed by the heuristic. If allocability changes they are /// moved to the appropriate list. - void handleAddEdge(Graph::EdgeItr eItr) { + void handleAddEdge(Graph::EdgeId eId) { Graph &g = getGraph(); - Graph::NodeItr n1Itr = g.getEdgeNode1(eItr), - n2Itr = g.getEdgeNode2(eItr); - NodeData &n1 = getHeuristicNodeData(n1Itr), - &n2 = getHeuristicNodeData(n2Itr); + Graph::NodeId n1Id = g.getEdgeNode1(eId), + n2Id = g.getEdgeNode2(eId); + NodeData &n1 = getHeuristicNodeData(n1Id), + &n2 = getHeuristicNodeData(n2Id); // If neither node is managed by the heuristic there's nothing to be // done. @@ -223,29 +223,29 @@ namespace PBQP { return; // Ok - we need to update at least one node. - computeEdgeContributions(eItr); + computeEdgeContributions(eId); // Update node 1 if it's managed by the heuristic. if (n1.isHeuristic) { bool n1WasAllocable = n1.isAllocable; - addEdgeContributions(eItr, n1Itr); - updateAllocability(n1Itr); + addEdgeContributions(eId, n1Id); + updateAllocability(n1Id); if (n1WasAllocable && !n1.isAllocable) { rnAllocableList.erase(n1.rnaItr); n1.rnuItr = - rnUnallocableList.insert(rnUnallocableList.end(), n1Itr); + rnUnallocableList.insert(rnUnallocableList.end(), n1Id); } } // Likewise for node 2. if (n2.isHeuristic) { bool n2WasAllocable = n2.isAllocable; - addEdgeContributions(eItr, n2Itr); - updateAllocability(n2Itr); + addEdgeContributions(eId, n2Id); + updateAllocability(n2Id); if (n2WasAllocable && !n2.isAllocable) { rnAllocableList.erase(n2.rnaItr); n2.rnuItr = - rnUnallocableList.insert(rnUnallocableList.end(), n2Itr); + rnUnallocableList.insert(rnUnallocableList.end(), n2Id); } } } @@ -256,27 +256,27 @@ namespace PBQP { /// /// Updates allocability of the given node and, if appropriate, moves the /// node to a new list. - void handleRemoveEdge(Graph::EdgeItr eItr, Graph::NodeItr nItr) { - NodeData &nd = getHeuristicNodeData(nItr); + void handleRemoveEdge(Graph::EdgeId eId, Graph::NodeId nId) { + NodeData &nd =getHeuristicNodeData(nId); // If the node is not managed by the heuristic there's nothing to be // done. if (!nd.isHeuristic) return; - EdgeData &ed = getHeuristicEdgeData(eItr); + EdgeData &ed = getHeuristicEdgeData(eId); (void)ed; assert(ed.isUpToDate && "Edge data is not up to date."); // Update node. bool ndWasAllocable = nd.isAllocable; - subtractEdgeContributions(eItr, nItr); - updateAllocability(nItr); + subtractEdgeContributions(eId, nId); + updateAllocability(nId); // If the node has gone optimal... - if (shouldOptimallyReduce(nItr)) { + if (shouldOptimallyReduce(nId)) { nd.isHeuristic = false; - addToOptimalReduceList(nItr); + addToOptimalReduceList(nId); if (ndWasAllocable) { rnAllocableList.erase(nd.rnaItr); } else { @@ -287,30 +287,30 @@ namespace PBQP { // from "unallocable" to "allocable". if (!ndWasAllocable && nd.isAllocable) { rnUnallocableList.erase(nd.rnuItr); - nd.rnaItr = rnAllocableList.insert(rnAllocableList.end(), nItr); + nd.rnaItr = rnAllocableList.insert(rnAllocableList.end(), nId); } } } private: - NodeData& getHeuristicNodeData(Graph::NodeItr nItr) { - return getSolver().getHeuristicNodeData(nItr); + NodeData& getHeuristicNodeData(Graph::NodeId nId) { + return getSolver().getHeuristicNodeData(nId); } - EdgeData& getHeuristicEdgeData(Graph::EdgeItr eItr) { - return getSolver().getHeuristicEdgeData(eItr); + EdgeData& getHeuristicEdgeData(Graph::EdgeId eId) { + return getSolver().getHeuristicEdgeData(eId); } // Work out what this edge will contribute to the allocability of the // nodes connected to it. - void computeEdgeContributions(Graph::EdgeItr eItr) { - EdgeData &ed = getHeuristicEdgeData(eItr); + void computeEdgeContributions(Graph::EdgeId eId) { + EdgeData &ed = getHeuristicEdgeData(eId); if (ed.isUpToDate) return; // Edge data is already up to date. - Matrix &eCosts = getGraph().getEdgeCosts(eItr); + Matrix &eCosts = getGraph().getEdgeCosts(eId); unsigned numRegs = eCosts.getRows() - 1, numReverseRegs = eCosts.getCols() - 1; @@ -352,15 +352,15 @@ namespace PBQP { // numDenied and safe members. No action is taken other than to update // these member values. Once updated these numbers can be used by clients // to update the node's allocability. - void addEdgeContributions(Graph::EdgeItr eItr, Graph::NodeItr nItr) { - EdgeData &ed = getHeuristicEdgeData(eItr); + void addEdgeContributions(Graph::EdgeId eId, Graph::NodeId nId) { + EdgeData &ed = getHeuristicEdgeData(eId); assert(ed.isUpToDate && "Using out-of-date edge numbers."); - NodeData &nd = getHeuristicNodeData(nItr); - unsigned numRegs = getGraph().getNodeCosts(nItr).getLength() - 1; + NodeData &nd = getHeuristicNodeData(nId); + unsigned numRegs = getGraph().getNodeCosts(nId).getLength() - 1; - bool nIsNode1 = nItr == getGraph().getEdgeNode1(eItr); + bool nIsNode1 = nId == getGraph().getEdgeNode1(eId); EdgeData::UnsafeArray &unsafe = nIsNode1 ? ed.unsafe : ed.reverseUnsafe; nd.numDenied += nIsNode1 ? ed.worst : ed.reverseWorst; @@ -379,15 +379,15 @@ namespace PBQP { // numDenied and safe members. No action is taken other than to update // these member values. Once updated these numbers can be used by clients // to update the node's allocability. - void subtractEdgeContributions(Graph::EdgeItr eItr, Graph::NodeItr nItr) { - EdgeData &ed = getHeuristicEdgeData(eItr); + void subtractEdgeContributions(Graph::EdgeId eId, Graph::NodeId nId) { + EdgeData &ed = getHeuristicEdgeData(eId); assert(ed.isUpToDate && "Using out-of-date edge numbers."); - NodeData &nd = getHeuristicNodeData(nItr); - unsigned numRegs = getGraph().getNodeCosts(nItr).getLength() - 1; + NodeData &nd = getHeuristicNodeData(nId); + unsigned numRegs = getGraph().getNodeCosts(nId).getLength() - 1; - bool nIsNode1 = nItr == getGraph().getEdgeNode1(eItr); + bool nIsNode1 = nId == getGraph().getEdgeNode1(eId); EdgeData::UnsafeArray &unsafe = nIsNode1 ? ed.unsafe : ed.reverseUnsafe; nd.numDenied -= nIsNode1 ? ed.worst : ed.reverseWorst; @@ -402,22 +402,22 @@ namespace PBQP { } } - void updateAllocability(Graph::NodeItr nItr) { - NodeData &nd = getHeuristicNodeData(nItr); - unsigned numRegs = getGraph().getNodeCosts(nItr).getLength() - 1; + void updateAllocability(Graph::NodeId nId) { + NodeData &nd = getHeuristicNodeData(nId); + unsigned numRegs = getGraph().getNodeCosts(nId).getLength() - 1; nd.isAllocable = nd.numDenied < numRegs || nd.numSafe > 0; } - void initializeNode(Graph::NodeItr nItr) { - NodeData &nd = getHeuristicNodeData(nItr); + void initializeNode(Graph::NodeId nId) { + NodeData &nd = getHeuristicNodeData(nId); if (nd.isInitialized) return; // Node data is already up to date. - unsigned numRegs = getGraph().getNodeCosts(nItr).getLength() - 1; + unsigned numRegs = getGraph().getNodeCosts(nId).getLength() - 1; nd.numDenied = 0; - const Vector& nCosts = getGraph().getNodeCosts(nItr); + const Vector& nCosts = getGraph().getNodeCosts(nId); for (unsigned i = 1; i < nCosts.getLength(); ++i) { if (nCosts[i] == std::numeric_limits::infinity()) ++nd.numDenied; @@ -428,27 +428,27 @@ namespace PBQP { typedef HeuristicSolverImpl::SolverEdgeItr SolverEdgeItr; - for (SolverEdgeItr aeItr = getSolver().solverEdgesBegin(nItr), - aeEnd = getSolver().solverEdgesEnd(nItr); + for (SolverEdgeItr aeItr = getSolver().solverEdgesBegin(nId), + aeEnd = getSolver().solverEdgesEnd(nId); aeItr != aeEnd; ++aeItr) { - Graph::EdgeItr eItr = *aeItr; - computeEdgeContributions(eItr); - addEdgeContributions(eItr, nItr); + Graph::EdgeId eId = *aeItr; + computeEdgeContributions(eId); + addEdgeContributions(eId, nId); } - updateAllocability(nItr); + updateAllocability(nId); nd.isInitialized = true; } - void handleRemoveNode(Graph::NodeItr xnItr) { + void handleRemoveNode(Graph::NodeId xnId) { typedef HeuristicSolverImpl::SolverEdgeItr SolverEdgeItr; - std::vector edgesToRemove; - for (SolverEdgeItr aeItr = getSolver().solverEdgesBegin(xnItr), - aeEnd = getSolver().solverEdgesEnd(xnItr); + std::vector edgesToRemove; + for (SolverEdgeItr aeItr = getSolver().solverEdgesBegin(xnId), + aeEnd = getSolver().solverEdgesEnd(xnId); aeItr != aeEnd; ++aeItr) { - Graph::NodeItr ynItr = getGraph().getEdgeOtherNode(*aeItr, xnItr); - handleRemoveEdge(*aeItr, ynItr); + Graph::NodeId ynId = getGraph().getEdgeOtherNode(*aeItr, xnId); + handleRemoveEdge(*aeItr, ynId); edgesToRemove.push_back(*aeItr); } while (!edgesToRemove.empty()) { diff --git a/include/llvm/CodeGen/PBQP/Solution.h b/include/llvm/CodeGen/PBQP/Solution.h index b9f288b..98ba5a1 100644 --- a/include/llvm/CodeGen/PBQP/Solution.h +++ b/include/llvm/CodeGen/PBQP/Solution.h @@ -26,8 +26,7 @@ namespace PBQP { class Solution { private: - typedef std::map SelectionsMap; + typedef std::map SelectionsMap; SelectionsMap selections; unsigned r0Reductions, r1Reductions, r2Reductions, rNReductions; @@ -73,15 +72,15 @@ namespace PBQP { /// \brief Set the selection for a given node. /// @param nItr Node iterator. /// @param selection Selection for nItr. - void setSelection(Graph::NodeItr nItr, unsigned selection) { - selections[nItr] = selection; + void setSelection(Graph::NodeId nodeId, unsigned selection) { + selections[nodeId] = selection; } /// \brief Get a node's selection. /// @param nItr Node iterator. /// @return The selection for nItr; - unsigned getSelection(Graph::ConstNodeItr nItr) const { - SelectionsMap::const_iterator sItr = selections.find(nItr); + unsigned getSelection(Graph::NodeId nodeId) const { + SelectionsMap::const_iterator sItr = selections.find(nodeId); assert(sItr != selections.end() && "No selection for node."); return sItr->second; } diff --git a/include/llvm/CodeGen/RegAllocPBQP.h b/include/llvm/CodeGen/RegAllocPBQP.h index 6f2d139..7472e5a 100644 --- a/include/llvm/CodeGen/RegAllocPBQP.h +++ b/include/llvm/CodeGen/RegAllocPBQP.h @@ -52,22 +52,22 @@ namespace llvm { /// PBQPBuilder you are unlikely to need this: Nodes and options for all /// vregs will already have been set up for you by the base class. template - void recordVReg(unsigned vreg, PBQP::Graph::NodeItr node, + void recordVReg(unsigned vreg, PBQP::Graph::NodeId nodeId, AllowedRegsItr arBegin, AllowedRegsItr arEnd) { - assert(node2VReg.find(node) == node2VReg.end() && "Re-mapping node."); + assert(node2VReg.find(nodeId) == node2VReg.end() && "Re-mapping node."); assert(vreg2Node.find(vreg) == vreg2Node.end() && "Re-mapping vreg."); assert(allowedSets[vreg].empty() && "vreg already has pregs."); - node2VReg[node] = vreg; - vreg2Node[vreg] = node; + node2VReg[nodeId] = vreg; + vreg2Node[vreg] = nodeId; std::copy(arBegin, arEnd, std::back_inserter(allowedSets[vreg])); } /// Get the virtual register corresponding to the given PBQP node. - unsigned getVRegForNode(PBQP::Graph::ConstNodeItr node) const; + unsigned getVRegForNode(PBQP::Graph::NodeId nodeId) const; /// Get the PBQP node corresponding to the given virtual register. - PBQP::Graph::NodeItr getNodeForVReg(unsigned vreg) const; + PBQP::Graph::NodeId getNodeForVReg(unsigned vreg) const; /// Returns true if the given PBQP option represents a physical register, /// false otherwise. @@ -92,9 +92,8 @@ namespace llvm { private: - typedef std::map Node2VReg; - typedef DenseMap VReg2Node; + typedef std::map Node2VReg; + typedef DenseMap VReg2Node; typedef DenseMap AllowedSetMap; PBQP::Graph graph; -- cgit v1.1 From d4f5a615674aaabeee4e444e708d1fa00a41495e Mon Sep 17 00:00:00 2001 From: Juergen Ributzka Date: Sat, 9 Nov 2013 01:51:33 +0000 Subject: [Stackmap] Materialize the jump address within the patchpoint noop slide. This patch moves the jump address materialization inside the noop slide. This enables patching of the materialization itself or its complete removal. This patch also adds the ability to define scratch registers that can be used safely by the code called from the patchpoint intrinsic. At least one scratch register is required, because that one is used for the materialization of the jump address. This patch depends on D2009. Differential Revision: http://llvm-reviews.chandlerc.com/D2074 Reviewed by Andy git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194306 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLowering.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 6944f73..5d6d1d2 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -2056,6 +2056,12 @@ public: return VT.bitsLT(MinVT) ? MinVT : VT; } + /// Returns a 0 terminated array of registers that can be safely used as + /// scratch registers. + virtual const uint16_t *getScratchRegisters(CallingConv::ID CC) const { + return NULL; + } + /// This callback is invoked by the type legalizer to legalize nodes with an /// illegal operand type but legal result types. It replaces the /// LowerOperation callback in the type Legalizer. The reason we can not do -- cgit v1.1 From ceb0d9c085492151f8e4538119bf3de29ff935c0 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Sat, 9 Nov 2013 02:01:25 +0000 Subject: Revert r194300 which broke the build. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194308 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/PBQP/Graph.h | 346 ++++++++++++-------------- include/llvm/CodeGen/PBQP/HeuristicBase.h | 40 +-- include/llvm/CodeGen/PBQP/HeuristicSolver.h | 248 +++++++++--------- include/llvm/CodeGen/PBQP/Heuristics/Briggs.h | 176 ++++++------- include/llvm/CodeGen/PBQP/Solution.h | 11 +- include/llvm/CodeGen/RegAllocPBQP.h | 17 +- 6 files changed, 404 insertions(+), 434 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/PBQP/Graph.h b/include/llvm/CodeGen/PBQP/Graph.h index 9f9a567..b57abca 100644 --- a/include/llvm/CodeGen/PBQP/Graph.h +++ b/include/llvm/CodeGen/PBQP/Graph.h @@ -20,63 +20,79 @@ #include "llvm/ADT/ilist_node.h" #include #include -#include namespace PBQP { /// PBQP Graph class. /// Instances of this class describe PBQP problems. class Graph { + private: + + // ----- TYPEDEFS ----- + class NodeEntry; + class EdgeEntry; + + typedef llvm::ilist NodeList; + typedef llvm::ilist EdgeList; + public: - typedef unsigned NodeId; - typedef unsigned EdgeId; + typedef NodeList::iterator NodeItr; + typedef NodeList::const_iterator ConstNodeItr; - private: + typedef EdgeList::iterator EdgeItr; + typedef EdgeList::const_iterator ConstEdgeItr; - typedef std::set AdjEdgeList; + private: + typedef std::list AdjEdgeList; + public: typedef AdjEdgeList::iterator AdjEdgeItr; private: - class NodeEntry { + class NodeEntry : public llvm::ilist_node { + friend struct llvm::ilist_sentinel_traits; private: Vector costs; AdjEdgeList adjEdges; + unsigned degree; void *data; NodeEntry() : costs(0, 0) {} public: - NodeEntry(const Vector &costs) : costs(costs), data(0) {} + NodeEntry(const Vector &costs) : costs(costs), degree(0) {} Vector& getCosts() { return costs; } const Vector& getCosts() const { return costs; } - unsigned getDegree() const { return adjEdges.size(); } + unsigned getDegree() const { return degree; } AdjEdgeItr edgesBegin() { return adjEdges.begin(); } AdjEdgeItr edgesEnd() { return adjEdges.end(); } - AdjEdgeItr addEdge(EdgeId e) { + AdjEdgeItr addEdge(EdgeItr e) { + ++degree; return adjEdges.insert(adjEdges.end(), e); } void removeEdge(AdjEdgeItr ae) { + --degree; adjEdges.erase(ae); } void setData(void *data) { this->data = data; } void* getData() { return data; } }; - class EdgeEntry { + class EdgeEntry : public llvm::ilist_node { + friend struct llvm::ilist_sentinel_traits; private: - NodeId node1, node2; + NodeItr node1, node2; Matrix costs; AdjEdgeItr node1AEItr, node2AEItr; void *data; - EdgeEntry() : costs(0, 0, 0), data(0) {} + EdgeEntry() : costs(0, 0, 0) {} public: - EdgeEntry(NodeId node1, NodeId node2, const Matrix &costs) + EdgeEntry(NodeItr node1, NodeItr node2, const Matrix &costs) : node1(node1), node2(node2), costs(costs) {} - NodeId getNode1() const { return node1; } - NodeId getNode2() const { return node2; } + NodeItr getNode1() const { return node1; } + NodeItr getNode2() const { return node2; } Matrix& getCosts() { return costs; } const Matrix& getCosts() const { return costs; } void setNode1AEItr(AdjEdgeItr ae) { node1AEItr = ae; } @@ -89,126 +105,52 @@ namespace PBQP { // ----- MEMBERS ----- - typedef std::vector NodeVector; - typedef std::vector FreeNodeVector; - NodeVector nodes; - FreeNodeVector freeNodes; + NodeList nodes; + unsigned numNodes; - typedef std::vector EdgeVector; - typedef std::vector FreeEdgeVector; - EdgeVector edges; - FreeEdgeVector freeEdges; + EdgeList edges; + unsigned numEdges; // ----- INTERNAL METHODS ----- - NodeEntry& getNode(NodeId nId) { return nodes[nId]; } - const NodeEntry& getNode(NodeId nId) const { return nodes[nId]; } - - EdgeEntry& getEdge(EdgeId eId) { return edges[eId]; } - const EdgeEntry& getEdge(EdgeId eId) const { return edges[eId]; } - - NodeId addConstructedNode(const NodeEntry &n) { - NodeId nodeId = 0; - if (!freeNodes.empty()) { - nodeId = freeNodes.back(); - freeNodes.pop_back(); - nodes[nodeId] = n; - } else { - nodeId = nodes.size(); - nodes.push_back(n); - } - return nodeId; + NodeEntry& getNode(NodeItr nItr) { return *nItr; } + const NodeEntry& getNode(ConstNodeItr nItr) const { return *nItr; } + + EdgeEntry& getEdge(EdgeItr eItr) { return *eItr; } + const EdgeEntry& getEdge(ConstEdgeItr eItr) const { return *eItr; } + + NodeItr addConstructedNode(const NodeEntry &n) { + ++numNodes; + return nodes.insert(nodes.end(), n); } - EdgeId addConstructedEdge(const EdgeEntry &e) { - assert(findEdge(e.getNode1(), e.getNode2()) == invalidEdgeId() && + EdgeItr addConstructedEdge(const EdgeEntry &e) { + assert(findEdge(e.getNode1(), e.getNode2()) == edges.end() && "Attempt to add duplicate edge."); - EdgeId edgeId = 0; - if (!freeEdges.empty()) { - edgeId = freeEdges.back(); - freeEdges.pop_back(); - edges[edgeId] = e; - } else { - edgeId = edges.size(); - edges.push_back(e); - } - - EdgeEntry &ne = getEdge(edgeId); + ++numEdges; + EdgeItr edgeItr = edges.insert(edges.end(), e); + EdgeEntry &ne = getEdge(edgeItr); NodeEntry &n1 = getNode(ne.getNode1()); NodeEntry &n2 = getNode(ne.getNode2()); - // Sanity check on matrix dimensions: assert((n1.getCosts().getLength() == ne.getCosts().getRows()) && (n2.getCosts().getLength() == ne.getCosts().getCols()) && "Edge cost dimensions do not match node costs dimensions."); - - ne.setNode1AEItr(n1.addEdge(edgeId)); - ne.setNode2AEItr(n2.addEdge(edgeId)); - return edgeId; + ne.setNode1AEItr(n1.addEdge(edgeItr)); + ne.setNode2AEItr(n2.addEdge(edgeItr)); + return edgeItr; } inline void copyFrom(const Graph &other); public: - class NodeItr { - public: - NodeItr(NodeId nodeId, const Graph &g) - : nodeId(nodeId), endNodeId(g.nodes.size()), freeNodes(g.freeNodes) { - this->nodeId = findNextInUse(nodeId); // Move to the first in-use nodeId - } - - bool operator==(const NodeItr& n) const { return nodeId == n.nodeId; } - bool operator!=(const NodeItr& n) const { return !(*this == n); } - NodeItr& operator++() { nodeId = findNextInUse(++nodeId); return *this; } - NodeId operator*() const { return nodeId; } - - private: - NodeId findNextInUse(NodeId n) const { - while (n < endNodeId && - std::find(freeNodes.begin(), freeNodes.end(), n) != - freeNodes.end()) { - ++n; - } - return n; - } - - NodeId nodeId, endNodeId; - const FreeNodeVector& freeNodes; - }; - - class EdgeItr { - public: - EdgeItr(EdgeId edgeId, const Graph &g) - : edgeId(edgeId), endEdgeId(g.edges.size()), freeEdges(g.freeEdges) { - this->edgeId = findNextInUse(edgeId); // Move to the first in-use edgeId - } - - bool operator==(const EdgeItr& n) const { return edgeId == n.edgeId; } - bool operator!=(const EdgeItr& n) const { return !(*this == n); } - EdgeItr& operator++() { edgeId = findNextInUse(++edgeId); return *this; } - EdgeId operator*() const { return edgeId; } - - private: - EdgeId findNextInUse(EdgeId n) const { - while (n < endEdgeId && - std::find(freeEdges.begin(), freeEdges.end(), n) != - freeEdges.end()) { - ++n; - } - return n; - } - - EdgeId edgeId, endEdgeId; - const FreeEdgeVector& freeEdges; - }; - /// \brief Construct an empty PBQP graph. - Graph() {} + Graph() : numNodes(0), numEdges(0) {} /// \brief Copy construct this graph from "other". Note: Does not copy node /// and edge data, only graph structure and costs. /// @param other Source graph to copy from. - Graph(const Graph &other) { + Graph(const Graph &other) : numNodes(0), numEdges(0) { copyFrom(other); } @@ -228,7 +170,7 @@ namespace PBQP { /// \brief Add a node with the given costs. /// @param costs Cost vector for the new node. /// @return Node iterator for the added node. - NodeId addNode(const Vector &costs) { + NodeItr addNode(const Vector &costs) { return addConstructedNode(NodeEntry(costs)); } @@ -236,31 +178,32 @@ namespace PBQP { /// @param n1Itr First node. /// @param n2Itr Second node. /// @return Edge iterator for the added edge. - EdgeId addEdge(NodeId n1Id, NodeId n2Id, const Matrix &costs) { - assert(getNodeCosts(n1Id).getLength() == costs.getRows() && - getNodeCosts(n2Id).getLength() == costs.getCols() && + EdgeItr addEdge(Graph::NodeItr n1Itr, Graph::NodeItr n2Itr, + const Matrix &costs) { + assert(getNodeCosts(n1Itr).getLength() == costs.getRows() && + getNodeCosts(n2Itr).getLength() == costs.getCols() && "Matrix dimensions mismatch."); - return addConstructedEdge(EdgeEntry(n1Id, n2Id, costs)); + return addConstructedEdge(EdgeEntry(n1Itr, n2Itr, costs)); } /// \brief Get the number of nodes in the graph. /// @return Number of nodes in the graph. - unsigned getNumNodes() const { return nodes.size() - freeNodes.size(); } + unsigned getNumNodes() const { return numNodes; } /// \brief Get the number of edges in the graph. /// @return Number of edges in the graph. - unsigned getNumEdges() const { return edges.size() - freeEdges.size(); } + unsigned getNumEdges() const { return numEdges; } /// \brief Get a node's cost vector. /// @param nItr Node iterator. /// @return Node cost vector. - Vector& getNodeCosts(NodeId nId) { return getNode(nId).getCosts(); } + Vector& getNodeCosts(NodeItr nItr) { return getNode(nItr).getCosts(); } /// \brief Get a node's cost vector (const version). /// @param nItr Node iterator. /// @return Node cost vector. - const Vector& getNodeCosts(NodeId nId) const { - return getNode(nId).getCosts(); + const Vector& getNodeCosts(ConstNodeItr nItr) const { + return getNode(nItr).getCosts(); } /// \brief Set a node's data pointer. @@ -268,23 +211,23 @@ namespace PBQP { /// @param data Pointer to node data. /// /// Typically used by a PBQP solver to attach data to aid in solution. - void setNodeData(NodeId nId, void *data) { getNode(nId).setData(data); } + void setNodeData(NodeItr nItr, void *data) { getNode(nItr).setData(data); } /// \brief Get the node's data pointer. /// @param nItr Node iterator. /// @return Pointer to node data. - void* getNodeData(NodeId nId) { return getNode(nId).getData(); } + void* getNodeData(NodeItr nItr) { return getNode(nItr).getData(); } /// \brief Get an edge's cost matrix. /// @param eItr Edge iterator. /// @return Edge cost matrix. - Matrix& getEdgeCosts(EdgeId eId) { return getEdge(eId).getCosts(); } + Matrix& getEdgeCosts(EdgeItr eItr) { return getEdge(eItr).getCosts(); } /// \brief Get an edge's cost matrix (const version). /// @param eItr Edge iterator. /// @return Edge cost matrix. - const Matrix& getEdgeCosts(EdgeId eId) const { - return getEdge(eId).getCosts(); + const Matrix& getEdgeCosts(ConstEdgeItr eItr) const { + return getEdge(eItr).getCosts(); } /// \brief Set an edge's data pointer. @@ -292,120 +235,124 @@ namespace PBQP { /// @param data Pointer to edge data. /// /// Typically used by a PBQP solver to attach data to aid in solution. - void setEdgeData(EdgeId eId, void *data) { getEdge(eId).setData(data); } + void setEdgeData(EdgeItr eItr, void *data) { getEdge(eItr).setData(data); } /// \brief Get an edge's data pointer. /// @param eItr Edge iterator. /// @return Pointer to edge data. - void* getEdgeData(EdgeId eId) { return getEdge(eId).getData(); } + void* getEdgeData(EdgeItr eItr) { return getEdge(eItr).getData(); } /// \brief Get a node's degree. /// @param nItr Node iterator. /// @return The degree of the node. - unsigned getNodeDegree(NodeId nId) const { - return getNode(nId).getDegree(); + unsigned getNodeDegree(NodeItr nItr) const { + return getNode(nItr).getDegree(); } /// \brief Begin iterator for node set. - NodeItr nodesBegin() const { return NodeItr(0, *this); } + NodeItr nodesBegin() { return nodes.begin(); } + + /// \brief Begin const iterator for node set. + ConstNodeItr nodesBegin() const { return nodes.begin(); } /// \brief End iterator for node set. - NodeItr nodesEnd() const { return NodeItr(nodes.size(), *this); } + NodeItr nodesEnd() { return nodes.end(); } + + /// \brief End const iterator for node set. + ConstNodeItr nodesEnd() const { return nodes.end(); } /// \brief Begin iterator for edge set. - EdgeItr edgesBegin() const { return EdgeItr(0, *this); } + EdgeItr edgesBegin() { return edges.begin(); } /// \brief End iterator for edge set. - EdgeItr edgesEnd() const { return EdgeItr(edges.size(), *this); } + EdgeItr edgesEnd() { return edges.end(); } /// \brief Get begin iterator for adjacent edge set. /// @param nItr Node iterator. /// @return Begin iterator for the set of edges connected to the given node. - AdjEdgeItr adjEdgesBegin(NodeId nId) { - return getNode(nId).edgesBegin(); + AdjEdgeItr adjEdgesBegin(NodeItr nItr) { + return getNode(nItr).edgesBegin(); } /// \brief Get end iterator for adjacent edge set. /// @param nItr Node iterator. /// @return End iterator for the set of edges connected to the given node. - AdjEdgeItr adjEdgesEnd(NodeId nId) { - return getNode(nId).edgesEnd(); + AdjEdgeItr adjEdgesEnd(NodeItr nItr) { + return getNode(nItr).edgesEnd(); } /// \brief Get the first node connected to this edge. /// @param eItr Edge iterator. /// @return The first node connected to the given edge. - NodeId getEdgeNode1(EdgeId eId) { - return getEdge(eId).getNode1(); + NodeItr getEdgeNode1(EdgeItr eItr) { + return getEdge(eItr).getNode1(); } /// \brief Get the second node connected to this edge. /// @param eItr Edge iterator. /// @return The second node connected to the given edge. - NodeId getEdgeNode2(EdgeId eId) { - return getEdge(eId).getNode2(); + NodeItr getEdgeNode2(EdgeItr eItr) { + return getEdge(eItr).getNode2(); } /// \brief Get the "other" node connected to this edge. /// @param eItr Edge iterator. /// @param nItr Node iterator for the "given" node. /// @return The iterator for the "other" node connected to this edge. - NodeId getEdgeOtherNode(EdgeId eId, NodeId nId) { - EdgeEntry &e = getEdge(eId); - if (e.getNode1() == nId) { + NodeItr getEdgeOtherNode(EdgeItr eItr, NodeItr nItr) { + EdgeEntry &e = getEdge(eItr); + if (e.getNode1() == nItr) { return e.getNode2(); } // else return e.getNode1(); } - EdgeId invalidEdgeId() const { - return std::numeric_limits::max(); - } - /// \brief Get the edge connecting two nodes. - /// @param n1Id First node id. - /// @param n2Id Second node id. - /// @return An id for edge (n1Id, n2Id) if such an edge exists, - /// otherwise returns an invalid edge id. - EdgeId findEdge(NodeId n1Id, NodeId n2Id) { - for (AdjEdgeItr aeItr = adjEdgesBegin(n1Id), aeEnd = adjEdgesEnd(n1Id); + /// @param n1Itr First node iterator. + /// @param n2Itr Second node iterator. + /// @return An iterator for edge (n1Itr, n2Itr) if such an edge exists, + /// otherwise returns edgesEnd(). + EdgeItr findEdge(NodeItr n1Itr, NodeItr n2Itr) { + for (AdjEdgeItr aeItr = adjEdgesBegin(n1Itr), aeEnd = adjEdgesEnd(n1Itr); aeItr != aeEnd; ++aeItr) { - if ((getEdgeNode1(*aeItr) == n2Id) || - (getEdgeNode2(*aeItr) == n2Id)) { + if ((getEdgeNode1(*aeItr) == n2Itr) || + (getEdgeNode2(*aeItr) == n2Itr)) { return *aeItr; } } - return invalidEdgeId(); + return edges.end(); } /// \brief Remove a node from the graph. - /// @param nItr Node id. - void removeNode(NodeId nId) { - NodeEntry &n = getNode(nId); - for (AdjEdgeItr itr = n.edgesBegin(), end = n.edgesEnd(); itr != end; ++itr) { - EdgeId eId = *itr; - removeEdge(eId); + /// @param nItr Node iterator. + void removeNode(NodeItr nItr) { + NodeEntry &n = getNode(nItr); + for (AdjEdgeItr itr = n.edgesBegin(), end = n.edgesEnd(); itr != end;) { + EdgeItr eItr = *itr; + ++itr; + removeEdge(eItr); } - freeNodes.push_back(nId); + nodes.erase(nItr); + --numNodes; } /// \brief Remove an edge from the graph. /// @param eItr Edge iterator. - void removeEdge(EdgeId eId) { - EdgeEntry &e = getEdge(eId); + void removeEdge(EdgeItr eItr) { + EdgeEntry &e = getEdge(eItr); NodeEntry &n1 = getNode(e.getNode1()); NodeEntry &n2 = getNode(e.getNode2()); n1.removeEdge(e.getNode1AEItr()); n2.removeEdge(e.getNode2AEItr()); - freeEdges.push_back(eId); + edges.erase(eItr); + --numEdges; } /// \brief Remove all nodes and edges from the graph. void clear() { nodes.clear(); - freeNodes.clear(); edges.clear(); - freeEdges.clear(); + numNodes = numEdges = 0; } /// \brief Dump a graph to an output stream. @@ -415,7 +362,7 @@ namespace PBQP { for (NodeItr nodeItr = nodesBegin(), nodeEnd = nodesEnd(); nodeItr != nodeEnd; ++nodeItr) { - const Vector& v = getNodeCosts(*nodeItr); + const Vector& v = getNodeCosts(nodeItr); os << "\n" << v.getLength() << "\n"; assert(v.getLength() != 0 && "Empty vector in graph."); os << v[0]; @@ -427,10 +374,10 @@ namespace PBQP { for (EdgeItr edgeItr = edgesBegin(), edgeEnd = edgesEnd(); edgeItr != edgeEnd; ++edgeItr) { - NodeId n1 = getEdgeNode1(*edgeItr); - NodeId n2 = getEdgeNode2(*edgeItr); + unsigned n1 = std::distance(nodesBegin(), getEdgeNode1(edgeItr)); + unsigned n2 = std::distance(nodesBegin(), getEdgeNode2(edgeItr)); assert(n1 != n2 && "PBQP graphs shound not have self-edges."); - const Matrix& m = getEdgeCosts(*edgeItr); + const Matrix& m = getEdgeCosts(edgeItr); os << "\n" << n1 << " " << n2 << "\n" << m.getRows() << " " << m.getCols() << "\n"; assert(m.getRows() != 0 && "No rows in matrix."); @@ -456,7 +403,7 @@ namespace PBQP { nodeItr != nodeEnd; ++nodeItr) { os << " node" << nodeItr << " [ label=\"" - << nodeItr << ": " << getNodeCosts(*nodeItr) << "\" ]\n"; + << nodeItr << ": " << getNodeCosts(nodeItr) << "\" ]\n"; } os << " edge [ len=" << getNumNodes() << " ]\n"; @@ -464,11 +411,11 @@ namespace PBQP { for (EdgeItr edgeItr = edgesBegin(), edgeEnd = edgesEnd(); edgeItr != edgeEnd; ++edgeItr) { - os << " node" << getEdgeNode1(*edgeItr) - << " -- node" << getEdgeNode2(*edgeItr) + os << " node" << getEdgeNode1(edgeItr) + << " -- node" << getEdgeNode2(edgeItr) << " [ label=\""; - const Matrix &edgeCosts = getEdgeCosts(*edgeItr); + const Matrix &edgeCosts = getEdgeCosts(edgeItr); for (unsigned i = 0; i < edgeCosts.getRows(); ++i) { os << edgeCosts.getRowAsVector(i) << "\\n"; @@ -480,16 +427,39 @@ namespace PBQP { }; -// void Graph::copyFrom(const Graph &other) { -// std::map nodeMap; + class NodeItrComparator { + public: + bool operator()(Graph::NodeItr n1, Graph::NodeItr n2) const { + return &*n1 < &*n2; + } + + bool operator()(Graph::ConstNodeItr n1, Graph::ConstNodeItr n2) const { + return &*n1 < &*n2; + } + }; + + class EdgeItrCompartor { + public: + bool operator()(Graph::EdgeItr e1, Graph::EdgeItr e2) const { + return &*e1 < &*e2; + } + + bool operator()(Graph::ConstEdgeItr e1, Graph::ConstEdgeItr e2) const { + return &*e1 < &*e2; + } + }; + + void Graph::copyFrom(const Graph &other) { + std::map nodeMap; -// for (Graph::ConstNodeItr nItr = other.nodesBegin(), -// nEnd = other.nodesEnd(); -// nItr != nEnd; ++nItr) { -// nodeMap[nItr] = addNode(other.getNodeCosts(nItr)); -// } -// } + for (Graph::ConstNodeItr nItr = other.nodesBegin(), + nEnd = other.nodesEnd(); + nItr != nEnd; ++nItr) { + nodeMap[nItr] = addNode(other.getNodeCosts(nItr)); + } + + } } diff --git a/include/llvm/CodeGen/PBQP/HeuristicBase.h b/include/llvm/CodeGen/PBQP/HeuristicBase.h index 36d94d6..0c1fcb7 100644 --- a/include/llvm/CodeGen/PBQP/HeuristicBase.h +++ b/include/llvm/CodeGen/PBQP/HeuristicBase.h @@ -52,7 +52,7 @@ namespace PBQP { class HeuristicBase { private: - typedef std::list OptimalList; + typedef std::list OptimalList; HeuristicSolverImpl &s; Graph &g; @@ -63,8 +63,8 @@ namespace PBQP { // Add the given node to the optimal reductions list. Keep an iterator to // its location for fast removal. - void addToOptimalReductionList(Graph::NodeId nId) { - optimalList.insert(optimalList.end(), nId); + void addToOptimalReductionList(Graph::NodeItr nItr) { + optimalList.insert(optimalList.end(), nItr); } public: @@ -105,8 +105,8 @@ namespace PBQP { /// criteria. Note however that your criteria for selecting optimal nodes /// should be at least as strong as this. I.e. Nodes of degree 3 or /// higher should not be selected under any circumstances. - bool shouldOptimallyReduce(Graph::NodeId nId) { - if (g.getNodeDegree(nId) < 3) + bool shouldOptimallyReduce(Graph::NodeItr nItr) { + if (g.getNodeDegree(nItr) < 3) return true; // else return false; @@ -118,8 +118,8 @@ namespace PBQP { /// You probably don't want to over-ride this, except perhaps to record /// statistics before calling this implementation. HeuristicBase relies on /// its behaviour. - void addToOptimalReduceList(Graph::NodeId nId) { - optimalList.push_back(nId); + void addToOptimalReduceList(Graph::NodeItr nItr) { + optimalList.push_back(nItr); } /// \brief Initialise the heuristic. @@ -132,10 +132,10 @@ namespace PBQP { void setup() { for (Graph::NodeItr nItr = g.nodesBegin(), nEnd = g.nodesEnd(); nItr != nEnd; ++nItr) { - if (impl().shouldOptimallyReduce(*nItr)) { - addToOptimalReduceList(*nItr); + if (impl().shouldOptimallyReduce(nItr)) { + addToOptimalReduceList(nItr); } else { - impl().addToHeuristicReduceList(*nItr); + impl().addToHeuristicReduceList(nItr); } } } @@ -150,13 +150,13 @@ namespace PBQP { if (optimalList.empty()) return false; - Graph::NodeId nId = optimalList.front(); + Graph::NodeItr nItr = optimalList.front(); optimalList.pop_front(); - switch (s.getSolverDegree(nId)) { - case 0: s.applyR0(nId); break; - case 1: s.applyR1(nId); break; - case 2: s.applyR2(nId); break; + switch (s.getSolverDegree(nItr)) { + case 0: s.applyR0(nItr); break; + case 1: s.applyR1(nItr); break; + case 2: s.applyR2(nItr); break; default: llvm_unreachable( "Optimal reductions of degree > 2 nodes is invalid."); } @@ -185,7 +185,7 @@ namespace PBQP { /// \brief Add a node to the heuristic reduce list. /// @param nItr Node iterator to add to the heuristic reduce list. - void addToHeuristicList(Graph::NodeId nId) { + void addToHeuristicList(Graph::NodeItr nItr) { llvm_unreachable("Must be implemented in derived class."); } @@ -200,19 +200,19 @@ namespace PBQP { /// \brief Prepare a change in the costs on the given edge. /// @param eItr Edge iterator. - void preUpdateEdgeCosts(Graph::EdgeId eId) { + void preUpdateEdgeCosts(Graph::EdgeItr eItr) { llvm_unreachable("Must be implemented in derived class."); } /// \brief Handle the change in the costs on the given edge. /// @param eItr Edge iterator. - void postUpdateEdgeCostts(Graph::EdgeId eId) { + void postUpdateEdgeCostts(Graph::EdgeItr eItr) { llvm_unreachable("Must be implemented in derived class."); } /// \brief Handle the addition of a new edge into the PBQP graph. /// @param eItr Edge iterator for the added edge. - void handleAddEdge(Graph::EdgeId eId) { + void handleAddEdge(Graph::EdgeItr eItr) { llvm_unreachable("Must be implemented in derived class."); } @@ -223,7 +223,7 @@ namespace PBQP { /// Edges are frequently removed due to the removal of a node. This /// method allows for the effect to be computed only for the remaining /// node in the graph. - void handleRemoveEdge(Graph::EdgeId eId, Graph::NodeId nId) { + void handleRemoveEdge(Graph::EdgeItr eItr, Graph::NodeItr nItr) { llvm_unreachable("Must be implemented in derived class."); } diff --git a/include/llvm/CodeGen/PBQP/HeuristicSolver.h b/include/llvm/CodeGen/PBQP/HeuristicSolver.h index 7fa6386..47e15b2 100644 --- a/include/llvm/CodeGen/PBQP/HeuristicSolver.h +++ b/include/llvm/CodeGen/PBQP/HeuristicSolver.h @@ -40,7 +40,7 @@ namespace PBQP { typedef typename HImpl::NodeData HeuristicNodeData; typedef typename HImpl::EdgeData HeuristicEdgeData; - typedef std::list SolverEdges; + typedef std::list SolverEdges; public: @@ -55,9 +55,9 @@ namespace PBQP { HeuristicNodeData& getHeuristicData() { return hData; } - SolverEdgeItr addSolverEdge(Graph::EdgeId eId) { + SolverEdgeItr addSolverEdge(Graph::EdgeItr eItr) { ++solverDegree; - return solverEdges.insert(solverEdges.end(), eId); + return solverEdges.insert(solverEdges.end(), eItr); } void removeSolverEdge(SolverEdgeItr seItr) { @@ -104,7 +104,7 @@ namespace PBQP { Graph &g; HImpl h; Solution s; - std::vector stack; + std::vector stack; typedef std::list NodeDataList; NodeDataList nodeDataList; @@ -127,15 +127,15 @@ namespace PBQP { /// \brief Get the heuristic data attached to the given node. /// @param nItr Node iterator. /// @return The heuristic data attached to the given node. - HeuristicNodeData& getHeuristicNodeData(Graph::NodeId nId) { - return getSolverNodeData(nId).getHeuristicData(); + HeuristicNodeData& getHeuristicNodeData(Graph::NodeItr nItr) { + return getSolverNodeData(nItr).getHeuristicData(); } /// \brief Get the heuristic data attached to the given edge. /// @param eItr Edge iterator. /// @return The heuristic data attached to the given node. - HeuristicEdgeData& getHeuristicEdgeData(Graph::EdgeId eId) { - return getSolverEdgeData(eId).getHeuristicData(); + HeuristicEdgeData& getHeuristicEdgeData(Graph::EdgeItr eItr) { + return getSolverEdgeData(eItr).getHeuristicData(); } /// \brief Begin iterator for the set of edges adjacent to the given node in @@ -143,8 +143,8 @@ namespace PBQP { /// @param nItr Node iterator. /// @return Begin iterator for the set of edges adjacent to the given node /// in the solver graph. - SolverEdgeItr solverEdgesBegin(Graph::NodeId nId) { - return getSolverNodeData(nId).solverEdgesBegin(); + SolverEdgeItr solverEdgesBegin(Graph::NodeItr nItr) { + return getSolverNodeData(nItr).solverEdgesBegin(); } /// \brief End iterator for the set of edges adjacent to the given node in @@ -152,8 +152,8 @@ namespace PBQP { /// @param nItr Node iterator. /// @return End iterator for the set of edges adjacent to the given node in /// the solver graph. - SolverEdgeItr solverEdgesEnd(Graph::NodeId nId) { - return getSolverNodeData(nId).solverEdgesEnd(); + SolverEdgeItr solverEdgesEnd(Graph::NodeItr nItr) { + return getSolverNodeData(nItr).solverEdgesEnd(); } /// \brief Remove a node from the solver graph. @@ -161,10 +161,10 @@ namespace PBQP { /// /// Does not notify the heuristic of the removal. That should be /// done manually if necessary. - void removeSolverEdge(Graph::EdgeId eId) { - EdgeData &eData = getSolverEdgeData(eId); - NodeData &n1Data = getSolverNodeData(g.getEdgeNode1(eId)), - &n2Data = getSolverNodeData(g.getEdgeNode2(eId)); + void removeSolverEdge(Graph::EdgeItr eItr) { + EdgeData &eData = getSolverEdgeData(eItr); + NodeData &n1Data = getSolverNodeData(g.getEdgeNode1(eItr)), + &n2Data = getSolverNodeData(g.getEdgeNode2(eItr)); n1Data.removeSolverEdge(eData.getN1SolverEdgeItr()); n2Data.removeSolverEdge(eData.getN2SolverEdgeItr()); @@ -189,30 +189,30 @@ namespace PBQP { /// \brief Add to the end of the stack. /// @param nItr Node iterator to add to the reduction stack. - void pushToStack(Graph::NodeId nId) { - getSolverNodeData(nId).clearSolverEdges(); - stack.push_back(nId); + void pushToStack(Graph::NodeItr nItr) { + getSolverNodeData(nItr).clearSolverEdges(); + stack.push_back(nItr); } /// \brief Returns the solver degree of the given node. /// @param nItr Node iterator for which degree is requested. /// @return Node degree in the solver graph (not the original graph). - unsigned getSolverDegree(Graph::NodeId nId) { - return getSolverNodeData(nId).getSolverDegree(); + unsigned getSolverDegree(Graph::NodeItr nItr) { + return getSolverNodeData(nItr).getSolverDegree(); } /// \brief Set the solution of the given node. /// @param nItr Node iterator to set solution for. /// @param selection Selection for node. - void setSolution(const Graph::NodeId &nId, unsigned selection) { - s.setSelection(nId, selection); + void setSolution(const Graph::NodeItr &nItr, unsigned selection) { + s.setSelection(nItr, selection); - for (Graph::AdjEdgeItr aeItr = g.adjEdgesBegin(nId), - aeEnd = g.adjEdgesEnd(nId); + for (Graph::AdjEdgeItr aeItr = g.adjEdgesBegin(nItr), + aeEnd = g.adjEdgesEnd(nItr); aeItr != aeEnd; ++aeItr) { - Graph::EdgeId eId(*aeItr); - Graph::NodeId anId(g.getEdgeOtherNode(eId, nId)); - getSolverNodeData(anId).addSolverEdge(eId); + Graph::EdgeItr eItr(*aeItr); + Graph::NodeItr anItr(g.getEdgeOtherNode(eItr, nItr)); + getSolverNodeData(anItr).addSolverEdge(eItr); } } @@ -220,12 +220,12 @@ namespace PBQP { /// @param nItr Node iterator for node to apply R0 to. /// /// Node will be automatically pushed to the solver stack. - void applyR0(Graph::NodeId nId) { - assert(getSolverNodeData(nId).getSolverDegree() == 0 && + void applyR0(Graph::NodeItr nItr) { + assert(getSolverNodeData(nItr).getSolverDegree() == 0 && "R0 applied to node with degree != 0."); // Nothing to do. Just push the node onto the reduction stack. - pushToStack(nId); + pushToStack(nItr); s.recordR0(); } @@ -234,20 +234,20 @@ namespace PBQP { /// @param xnItr Node iterator for node to apply R1 to. /// /// Node will be automatically pushed to the solver stack. - void applyR1(Graph::NodeId xnId) { - NodeData &nd = getSolverNodeData(xnId); + void applyR1(Graph::NodeItr xnItr) { + NodeData &nd = getSolverNodeData(xnItr); assert(nd.getSolverDegree() == 1 && "R1 applied to node with degree != 1."); - Graph::EdgeId eId = *nd.solverEdgesBegin(); + Graph::EdgeItr eItr = *nd.solverEdgesBegin(); - const Matrix &eCosts = g.getEdgeCosts(eId); - const Vector &xCosts = g.getNodeCosts(xnId); + const Matrix &eCosts = g.getEdgeCosts(eItr); + const Vector &xCosts = g.getNodeCosts(xnItr); // Duplicate a little to avoid transposing matrices. - if (xnId == g.getEdgeNode1(eId)) { - Graph::NodeId ynId = g.getEdgeNode2(eId); - Vector &yCosts = g.getNodeCosts(ynId); + if (xnItr == g.getEdgeNode1(eItr)) { + Graph::NodeItr ynItr = g.getEdgeNode2(eItr); + Vector &yCosts = g.getNodeCosts(ynItr); for (unsigned j = 0; j < yCosts.getLength(); ++j) { PBQPNum min = eCosts[0][j] + xCosts[0]; for (unsigned i = 1; i < xCosts.getLength(); ++i) { @@ -257,10 +257,10 @@ namespace PBQP { } yCosts[j] += min; } - h.handleRemoveEdge(eId, ynId); + h.handleRemoveEdge(eItr, ynItr); } else { - Graph::NodeId ynId = g.getEdgeNode1(eId); - Vector &yCosts = g.getNodeCosts(ynId); + Graph::NodeItr ynItr = g.getEdgeNode1(eItr); + Vector &yCosts = g.getNodeCosts(ynItr); for (unsigned i = 0; i < yCosts.getLength(); ++i) { PBQPNum min = eCosts[i][0] + xCosts[0]; for (unsigned j = 1; j < xCosts.getLength(); ++j) { @@ -270,12 +270,12 @@ namespace PBQP { } yCosts[i] += min; } - h.handleRemoveEdge(eId, ynId); + h.handleRemoveEdge(eItr, ynItr); } - removeSolverEdge(eId); + removeSolverEdge(eItr); assert(nd.getSolverDegree() == 0 && "Degree 1 with edge removed should be 0."); - pushToStack(xnId); + pushToStack(xnItr); s.recordR1(); } @@ -283,30 +283,30 @@ namespace PBQP { /// @param xnItr Node iterator for node to apply R2 to. /// /// Node will be automatically pushed to the solver stack. - void applyR2(Graph::NodeId xnId) { - assert(getSolverNodeData(xnId).getSolverDegree() == 2 && + void applyR2(Graph::NodeItr xnItr) { + assert(getSolverNodeData(xnItr).getSolverDegree() == 2 && "R2 applied to node with degree != 2."); - NodeData &nd = getSolverNodeData(xnId); - const Vector &xCosts = g.getNodeCosts(xnId); + NodeData &nd = getSolverNodeData(xnItr); + const Vector &xCosts = g.getNodeCosts(xnItr); SolverEdgeItr aeItr = nd.solverEdgesBegin(); - Graph::EdgeId yxeId = *aeItr, - zxeId = *(++aeItr); + Graph::EdgeItr yxeItr = *aeItr, + zxeItr = *(++aeItr); - Graph::NodeId ynId = g.getEdgeOtherNode(yxeId, xnId), - znId = g.getEdgeOtherNode(zxeId, xnId); + Graph::NodeItr ynItr = g.getEdgeOtherNode(yxeItr, xnItr), + znItr = g.getEdgeOtherNode(zxeItr, xnItr); - bool flipEdge1 = (g.getEdgeNode1(yxeId) == xnId), - flipEdge2 = (g.getEdgeNode1(zxeId) == xnId); + bool flipEdge1 = (g.getEdgeNode1(yxeItr) == xnItr), + flipEdge2 = (g.getEdgeNode1(zxeItr) == xnItr); const Matrix *yxeCosts = flipEdge1 ? - new Matrix(g.getEdgeCosts(yxeId).transpose()) : - &g.getEdgeCosts(yxeId); + new Matrix(g.getEdgeCosts(yxeItr).transpose()) : + &g.getEdgeCosts(yxeItr); const Matrix *zxeCosts = flipEdge2 ? - new Matrix(g.getEdgeCosts(zxeId).transpose()) : - &g.getEdgeCosts(zxeId); + new Matrix(g.getEdgeCosts(zxeItr).transpose()) : + &g.getEdgeCosts(zxeItr); unsigned xLen = xCosts.getLength(), yLen = yxeCosts->getRows(), @@ -333,27 +333,27 @@ namespace PBQP { if (flipEdge2) delete zxeCosts; - Graph::EdgeId yzeId = g.findEdge(ynId, znId); + Graph::EdgeItr yzeItr = g.findEdge(ynItr, znItr); bool addedEdge = false; - if (yzeId == g.invalidEdgeId()) { - yzeId = g.addEdge(ynId, znId, delta); + if (yzeItr == g.edgesEnd()) { + yzeItr = g.addEdge(ynItr, znItr, delta); addedEdge = true; } else { - Matrix &yzeCosts = g.getEdgeCosts(yzeId); - h.preUpdateEdgeCosts(yzeId); - if (ynId == g.getEdgeNode1(yzeId)) { + Matrix &yzeCosts = g.getEdgeCosts(yzeItr); + h.preUpdateEdgeCosts(yzeItr); + if (ynItr == g.getEdgeNode1(yzeItr)) { yzeCosts += delta; } else { yzeCosts += delta.transpose(); } } - bool nullCostEdge = tryNormaliseEdgeMatrix(yzeId); + bool nullCostEdge = tryNormaliseEdgeMatrix(yzeItr); if (!addedEdge) { // If we modified the edge costs let the heuristic know. - h.postUpdateEdgeCosts(yzeId); + h.postUpdateEdgeCosts(yzeItr); } if (nullCostEdge) { @@ -361,26 +361,26 @@ namespace PBQP { if (!addedEdge) { // We didn't just add it, so we need to notify the heuristic // and remove it from the solver. - h.handleRemoveEdge(yzeId, ynId); - h.handleRemoveEdge(yzeId, znId); - removeSolverEdge(yzeId); + h.handleRemoveEdge(yzeItr, ynItr); + h.handleRemoveEdge(yzeItr, znItr); + removeSolverEdge(yzeItr); } - g.removeEdge(yzeId); + g.removeEdge(yzeItr); } else if (addedEdge) { // If the edge was added, and non-null, finish setting it up, add it to // the solver & notify heuristic. edgeDataList.push_back(EdgeData()); - g.setEdgeData(yzeId, &edgeDataList.back()); - addSolverEdge(yzeId); - h.handleAddEdge(yzeId); + g.setEdgeData(yzeItr, &edgeDataList.back()); + addSolverEdge(yzeItr); + h.handleAddEdge(yzeItr); } - h.handleRemoveEdge(yxeId, ynId); - removeSolverEdge(yxeId); - h.handleRemoveEdge(zxeId, znId); - removeSolverEdge(zxeId); + h.handleRemoveEdge(yxeItr, ynItr); + removeSolverEdge(yxeItr); + h.handleRemoveEdge(zxeItr, znItr); + removeSolverEdge(zxeItr); - pushToStack(xnId); + pushToStack(xnItr); s.recordR2(); } @@ -391,21 +391,21 @@ namespace PBQP { private: - NodeData& getSolverNodeData(Graph::NodeId nId) { - return *static_cast(g.getNodeData(nId)); + NodeData& getSolverNodeData(Graph::NodeItr nItr) { + return *static_cast(g.getNodeData(nItr)); } - EdgeData& getSolverEdgeData(Graph::EdgeId eId) { - return *static_cast(g.getEdgeData(eId)); + EdgeData& getSolverEdgeData(Graph::EdgeItr eItr) { + return *static_cast(g.getEdgeData(eItr)); } - void addSolverEdge(Graph::EdgeId eId) { - EdgeData &eData = getSolverEdgeData(eId); - NodeData &n1Data = getSolverNodeData(g.getEdgeNode1(eId)), - &n2Data = getSolverNodeData(g.getEdgeNode2(eId)); + void addSolverEdge(Graph::EdgeItr eItr) { + EdgeData &eData = getSolverEdgeData(eItr); + NodeData &n1Data = getSolverNodeData(g.getEdgeNode1(eItr)), + &n2Data = getSolverNodeData(g.getEdgeNode2(eItr)); - eData.setN1SolverEdgeItr(n1Data.addSolverEdge(eId)); - eData.setN2SolverEdgeItr(n2Data.addSolverEdge(eId)); + eData.setN1SolverEdgeItr(n1Data.addSolverEdge(eItr)); + eData.setN2SolverEdgeItr(n2Data.addSolverEdge(eItr)); } void setup() { @@ -417,15 +417,15 @@ namespace PBQP { for (Graph::NodeItr nItr = g.nodesBegin(), nEnd = g.nodesEnd(); nItr != nEnd; ++nItr) { nodeDataList.push_back(NodeData()); - g.setNodeData(*nItr, &nodeDataList.back()); + g.setNodeData(nItr, &nodeDataList.back()); } // Create edge data objects. for (Graph::EdgeItr eItr = g.edgesBegin(), eEnd = g.edgesEnd(); eItr != eEnd; ++eItr) { edgeDataList.push_back(EdgeData()); - g.setEdgeData(*eItr, &edgeDataList.back()); - addSolverEdge(*eItr); + g.setEdgeData(eItr, &edgeDataList.back()); + addSolverEdge(eItr); } } @@ -441,30 +441,28 @@ namespace PBQP { for (Graph::NodeItr nItr = g.nodesBegin(), nEnd = g.nodesEnd(); nItr != nEnd; ++nItr) { - Graph::NodeId nId = *nItr; + if (g.getNodeCosts(nItr).getLength() == 1) { - if (g.getNodeCosts(nId).getLength() == 1) { + std::vector edgesToRemove; - std::vector edgesToRemove; - - for (Graph::AdjEdgeItr aeItr = g.adjEdgesBegin(nId), - aeEnd = g.adjEdgesEnd(nId); + for (Graph::AdjEdgeItr aeItr = g.adjEdgesBegin(nItr), + aeEnd = g.adjEdgesEnd(nItr); aeItr != aeEnd; ++aeItr) { - Graph::EdgeId eId = *aeItr; + Graph::EdgeItr eItr = *aeItr; - if (g.getEdgeNode1(eId) == nId) { - Graph::NodeId otherNodeId = g.getEdgeNode2(eId); - g.getNodeCosts(otherNodeId) += - g.getEdgeCosts(eId).getRowAsVector(0); + if (g.getEdgeNode1(eItr) == nItr) { + Graph::NodeItr otherNodeItr = g.getEdgeNode2(eItr); + g.getNodeCosts(otherNodeItr) += + g.getEdgeCosts(eItr).getRowAsVector(0); } else { - Graph::NodeId otherNodeId = g.getEdgeNode1(eId); - g.getNodeCosts(otherNodeId) += - g.getEdgeCosts(eId).getColAsVector(0); + Graph::NodeItr otherNodeItr = g.getEdgeNode1(eItr); + g.getNodeCosts(otherNodeItr) += + g.getEdgeCosts(eItr).getColAsVector(0); } - edgesToRemove.push_back(eId); + edgesToRemove.push_back(eItr); } if (!edgesToRemove.empty()) @@ -479,12 +477,12 @@ namespace PBQP { } void eliminateIndependentEdges() { - std::vector edgesToProcess; + std::vector edgesToProcess; unsigned numEliminated = 0; for (Graph::EdgeItr eItr = g.edgesBegin(), eEnd = g.edgesEnd(); eItr != eEnd; ++eItr) { - edgesToProcess.push_back(*eItr); + edgesToProcess.push_back(eItr); } while (!edgesToProcess.empty()) { @@ -494,21 +492,21 @@ namespace PBQP { } } - bool tryToEliminateEdge(Graph::EdgeId eId) { - if (tryNormaliseEdgeMatrix(eId)) { - g.removeEdge(eId); + bool tryToEliminateEdge(Graph::EdgeItr eItr) { + if (tryNormaliseEdgeMatrix(eItr)) { + g.removeEdge(eItr); return true; } return false; } - bool tryNormaliseEdgeMatrix(Graph::EdgeId &eId) { + bool tryNormaliseEdgeMatrix(Graph::EdgeItr &eItr) { const PBQPNum infinity = std::numeric_limits::infinity(); - Matrix &edgeCosts = g.getEdgeCosts(eId); - Vector &uCosts = g.getNodeCosts(g.getEdgeNode1(eId)), - &vCosts = g.getNodeCosts(g.getEdgeNode2(eId)); + Matrix &edgeCosts = g.getEdgeCosts(eItr); + Vector &uCosts = g.getNodeCosts(g.getEdgeNode1(eItr)), + &vCosts = g.getNodeCosts(g.getEdgeNode2(eItr)); for (unsigned r = 0; r < edgeCosts.getRows(); ++r) { PBQPNum rowMin = infinity; @@ -556,34 +554,34 @@ namespace PBQP { } } - void computeSolution(Graph::NodeId nId) { + void computeSolution(Graph::NodeItr nItr) { - NodeData &nodeData = getSolverNodeData(nId); + NodeData &nodeData = getSolverNodeData(nItr); - Vector v(g.getNodeCosts(nId)); + Vector v(g.getNodeCosts(nItr)); // Solve based on existing solved edges. for (SolverEdgeItr solvedEdgeItr = nodeData.solverEdgesBegin(), solvedEdgeEnd = nodeData.solverEdgesEnd(); solvedEdgeItr != solvedEdgeEnd; ++solvedEdgeItr) { - Graph::EdgeId eId(*solvedEdgeItr); - Matrix &edgeCosts = g.getEdgeCosts(eId); + Graph::EdgeItr eItr(*solvedEdgeItr); + Matrix &edgeCosts = g.getEdgeCosts(eItr); - if (nId == g.getEdgeNode1(eId)) { - Graph::NodeId adjNode(g.getEdgeNode2(eId)); + if (nItr == g.getEdgeNode1(eItr)) { + Graph::NodeItr adjNode(g.getEdgeNode2(eItr)); unsigned adjSolution = s.getSelection(adjNode); v += edgeCosts.getColAsVector(adjSolution); } else { - Graph::NodeId adjNode(g.getEdgeNode1(eId)); + Graph::NodeItr adjNode(g.getEdgeNode1(eItr)); unsigned adjSolution = s.getSelection(adjNode); v += edgeCosts.getRowAsVector(adjSolution); } } - setSolution(nId, v.minIndex()); + setSolution(nItr, v.minIndex()); } void cleanup() { diff --git a/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h b/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h index 9663b26..307d81e 100644 --- a/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h +++ b/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h @@ -47,8 +47,8 @@ namespace PBQP { class LinkDegreeComparator { public: LinkDegreeComparator(HeuristicSolverImpl &s) : s(&s) {} - bool operator()(Graph::NodeId n1Id, Graph::NodeId n2Id) const { - if (s->getSolverDegree(n1Id) > s->getSolverDegree(n2Id)) + bool operator()(Graph::NodeItr n1Itr, Graph::NodeItr n2Itr) const { + if (s->getSolverDegree(n1Itr) > s->getSolverDegree(n2Itr)) return true; return false; } @@ -60,12 +60,12 @@ namespace PBQP { public: SpillCostComparator(HeuristicSolverImpl &s) : s(&s), g(&s.getGraph()) {} - bool operator()(Graph::NodeId n1Id, Graph::NodeId n2Id) const { - const PBQP::Vector &cv1 = g->getNodeCosts(n1Id); - const PBQP::Vector &cv2 = g->getNodeCosts(n2Id); + bool operator()(Graph::NodeItr n1Itr, Graph::NodeItr n2Itr) const { + const PBQP::Vector &cv1 = g->getNodeCosts(n1Itr); + const PBQP::Vector &cv2 = g->getNodeCosts(n2Itr); - PBQPNum cost1 = cv1[0] / s->getSolverDegree(n1Id); - PBQPNum cost2 = cv2[0] / s->getSolverDegree(n2Id); + PBQPNum cost1 = cv1[0] / s->getSolverDegree(n1Itr); + PBQPNum cost2 = cv2[0] / s->getSolverDegree(n2Itr); if (cost1 < cost2) return true; @@ -77,10 +77,10 @@ namespace PBQP { Graph *g; }; - typedef std::list RNAllocableList; + typedef std::list RNAllocableList; typedef RNAllocableList::iterator RNAllocableListItr; - typedef std::list RNUnallocableList; + typedef std::list RNUnallocableList; typedef RNUnallocableList::iterator RNUnallocableListItr; public: @@ -123,8 +123,8 @@ namespace PBQP { /// infinite are checked for allocability first. Allocable nodes may be /// optimally reduced, but nodes whose allocability cannot be proven are /// selected for heuristic reduction instead. - bool shouldOptimallyReduce(Graph::NodeId nId) { - if (getSolver().getSolverDegree(nId) < 3) { + bool shouldOptimallyReduce(Graph::NodeItr nItr) { + if (getSolver().getSolverDegree(nItr) < 3) { return true; } // else @@ -133,14 +133,14 @@ namespace PBQP { /// \brief Add a node to the heuristic reduce list. /// @param nItr Node iterator to add to the heuristic reduce list. - void addToHeuristicReduceList(Graph::NodeId nId) { - NodeData &nd = getHeuristicNodeData(nId); - initializeNode(nId); + void addToHeuristicReduceList(Graph::NodeItr nItr) { + NodeData &nd = getHeuristicNodeData(nItr); + initializeNode(nItr); nd.isHeuristic = true; if (nd.isAllocable) { - nd.rnaItr = rnAllocableList.insert(rnAllocableList.end(), nId); + nd.rnaItr = rnAllocableList.insert(rnAllocableList.end(), nItr); } else { - nd.rnuItr = rnUnallocableList.insert(rnUnallocableList.end(), nId); + nd.rnuItr = rnUnallocableList.insert(rnUnallocableList.end(), nItr); } } @@ -159,19 +159,19 @@ namespace PBQP { RNAllocableListItr rnaItr = min_element(rnAllocableList.begin(), rnAllocableList.end(), LinkDegreeComparator(getSolver())); - Graph::NodeId nId = *rnaItr; + Graph::NodeItr nItr = *rnaItr; rnAllocableList.erase(rnaItr); - handleRemoveNode(nId); - getSolver().pushToStack(nId); + handleRemoveNode(nItr); + getSolver().pushToStack(nItr); return true; } else if (!rnUnallocableList.empty()) { RNUnallocableListItr rnuItr = min_element(rnUnallocableList.begin(), rnUnallocableList.end(), SpillCostComparator(getSolver())); - Graph::NodeId nId = *rnuItr; + Graph::NodeItr nItr = *rnuItr; rnUnallocableList.erase(rnuItr); - handleRemoveNode(nId); - getSolver().pushToStack(nId); + handleRemoveNode(nItr); + getSolver().pushToStack(nItr); return true; } // else @@ -180,28 +180,28 @@ namespace PBQP { /// \brief Prepare a change in the costs on the given edge. /// @param eItr Edge iterator. - void preUpdateEdgeCosts(Graph::EdgeId eId) { + void preUpdateEdgeCosts(Graph::EdgeItr eItr) { Graph &g = getGraph(); - Graph::NodeId n1Id = g.getEdgeNode1(eId), - n2Id = g.getEdgeNode2(eId); - NodeData &n1 = getHeuristicNodeData(n1Id), - &n2 = getHeuristicNodeData(n2Id); + Graph::NodeItr n1Itr = g.getEdgeNode1(eItr), + n2Itr = g.getEdgeNode2(eItr); + NodeData &n1 = getHeuristicNodeData(n1Itr), + &n2 = getHeuristicNodeData(n2Itr); if (n1.isHeuristic) - subtractEdgeContributions(eId, getGraph().getEdgeNode1(eId)); + subtractEdgeContributions(eItr, getGraph().getEdgeNode1(eItr)); if (n2.isHeuristic) - subtractEdgeContributions(eId, getGraph().getEdgeNode2(eId)); + subtractEdgeContributions(eItr, getGraph().getEdgeNode2(eItr)); - EdgeData &ed = getHeuristicEdgeData(eId); + EdgeData &ed = getHeuristicEdgeData(eItr); ed.isUpToDate = false; } /// \brief Handle the change in the costs on the given edge. /// @param eItr Edge iterator. - void postUpdateEdgeCosts(Graph::EdgeId eId) { + void postUpdateEdgeCosts(Graph::EdgeItr eItr) { // This is effectively the same as adding a new edge now, since // we've factored out the costs of the old one. - handleAddEdge(eId); + handleAddEdge(eItr); } /// \brief Handle the addition of a new edge into the PBQP graph. @@ -210,12 +210,12 @@ namespace PBQP { /// Updates allocability of any nodes connected by this edge which are /// being managed by the heuristic. If allocability changes they are /// moved to the appropriate list. - void handleAddEdge(Graph::EdgeId eId) { + void handleAddEdge(Graph::EdgeItr eItr) { Graph &g = getGraph(); - Graph::NodeId n1Id = g.getEdgeNode1(eId), - n2Id = g.getEdgeNode2(eId); - NodeData &n1 = getHeuristicNodeData(n1Id), - &n2 = getHeuristicNodeData(n2Id); + Graph::NodeItr n1Itr = g.getEdgeNode1(eItr), + n2Itr = g.getEdgeNode2(eItr); + NodeData &n1 = getHeuristicNodeData(n1Itr), + &n2 = getHeuristicNodeData(n2Itr); // If neither node is managed by the heuristic there's nothing to be // done. @@ -223,29 +223,29 @@ namespace PBQP { return; // Ok - we need to update at least one node. - computeEdgeContributions(eId); + computeEdgeContributions(eItr); // Update node 1 if it's managed by the heuristic. if (n1.isHeuristic) { bool n1WasAllocable = n1.isAllocable; - addEdgeContributions(eId, n1Id); - updateAllocability(n1Id); + addEdgeContributions(eItr, n1Itr); + updateAllocability(n1Itr); if (n1WasAllocable && !n1.isAllocable) { rnAllocableList.erase(n1.rnaItr); n1.rnuItr = - rnUnallocableList.insert(rnUnallocableList.end(), n1Id); + rnUnallocableList.insert(rnUnallocableList.end(), n1Itr); } } // Likewise for node 2. if (n2.isHeuristic) { bool n2WasAllocable = n2.isAllocable; - addEdgeContributions(eId, n2Id); - updateAllocability(n2Id); + addEdgeContributions(eItr, n2Itr); + updateAllocability(n2Itr); if (n2WasAllocable && !n2.isAllocable) { rnAllocableList.erase(n2.rnaItr); n2.rnuItr = - rnUnallocableList.insert(rnUnallocableList.end(), n2Id); + rnUnallocableList.insert(rnUnallocableList.end(), n2Itr); } } } @@ -256,27 +256,27 @@ namespace PBQP { /// /// Updates allocability of the given node and, if appropriate, moves the /// node to a new list. - void handleRemoveEdge(Graph::EdgeId eId, Graph::NodeId nId) { - NodeData &nd =getHeuristicNodeData(nId); + void handleRemoveEdge(Graph::EdgeItr eItr, Graph::NodeItr nItr) { + NodeData &nd = getHeuristicNodeData(nItr); // If the node is not managed by the heuristic there's nothing to be // done. if (!nd.isHeuristic) return; - EdgeData &ed = getHeuristicEdgeData(eId); + EdgeData &ed = getHeuristicEdgeData(eItr); (void)ed; assert(ed.isUpToDate && "Edge data is not up to date."); // Update node. bool ndWasAllocable = nd.isAllocable; - subtractEdgeContributions(eId, nId); - updateAllocability(nId); + subtractEdgeContributions(eItr, nItr); + updateAllocability(nItr); // If the node has gone optimal... - if (shouldOptimallyReduce(nId)) { + if (shouldOptimallyReduce(nItr)) { nd.isHeuristic = false; - addToOptimalReduceList(nId); + addToOptimalReduceList(nItr); if (ndWasAllocable) { rnAllocableList.erase(nd.rnaItr); } else { @@ -287,30 +287,30 @@ namespace PBQP { // from "unallocable" to "allocable". if (!ndWasAllocable && nd.isAllocable) { rnUnallocableList.erase(nd.rnuItr); - nd.rnaItr = rnAllocableList.insert(rnAllocableList.end(), nId); + nd.rnaItr = rnAllocableList.insert(rnAllocableList.end(), nItr); } } } private: - NodeData& getHeuristicNodeData(Graph::NodeId nId) { - return getSolver().getHeuristicNodeData(nId); + NodeData& getHeuristicNodeData(Graph::NodeItr nItr) { + return getSolver().getHeuristicNodeData(nItr); } - EdgeData& getHeuristicEdgeData(Graph::EdgeId eId) { - return getSolver().getHeuristicEdgeData(eId); + EdgeData& getHeuristicEdgeData(Graph::EdgeItr eItr) { + return getSolver().getHeuristicEdgeData(eItr); } // Work out what this edge will contribute to the allocability of the // nodes connected to it. - void computeEdgeContributions(Graph::EdgeId eId) { - EdgeData &ed = getHeuristicEdgeData(eId); + void computeEdgeContributions(Graph::EdgeItr eItr) { + EdgeData &ed = getHeuristicEdgeData(eItr); if (ed.isUpToDate) return; // Edge data is already up to date. - Matrix &eCosts = getGraph().getEdgeCosts(eId); + Matrix &eCosts = getGraph().getEdgeCosts(eItr); unsigned numRegs = eCosts.getRows() - 1, numReverseRegs = eCosts.getCols() - 1; @@ -352,15 +352,15 @@ namespace PBQP { // numDenied and safe members. No action is taken other than to update // these member values. Once updated these numbers can be used by clients // to update the node's allocability. - void addEdgeContributions(Graph::EdgeId eId, Graph::NodeId nId) { - EdgeData &ed = getHeuristicEdgeData(eId); + void addEdgeContributions(Graph::EdgeItr eItr, Graph::NodeItr nItr) { + EdgeData &ed = getHeuristicEdgeData(eItr); assert(ed.isUpToDate && "Using out-of-date edge numbers."); - NodeData &nd = getHeuristicNodeData(nId); - unsigned numRegs = getGraph().getNodeCosts(nId).getLength() - 1; + NodeData &nd = getHeuristicNodeData(nItr); + unsigned numRegs = getGraph().getNodeCosts(nItr).getLength() - 1; - bool nIsNode1 = nId == getGraph().getEdgeNode1(eId); + bool nIsNode1 = nItr == getGraph().getEdgeNode1(eItr); EdgeData::UnsafeArray &unsafe = nIsNode1 ? ed.unsafe : ed.reverseUnsafe; nd.numDenied += nIsNode1 ? ed.worst : ed.reverseWorst; @@ -379,15 +379,15 @@ namespace PBQP { // numDenied and safe members. No action is taken other than to update // these member values. Once updated these numbers can be used by clients // to update the node's allocability. - void subtractEdgeContributions(Graph::EdgeId eId, Graph::NodeId nId) { - EdgeData &ed = getHeuristicEdgeData(eId); + void subtractEdgeContributions(Graph::EdgeItr eItr, Graph::NodeItr nItr) { + EdgeData &ed = getHeuristicEdgeData(eItr); assert(ed.isUpToDate && "Using out-of-date edge numbers."); - NodeData &nd = getHeuristicNodeData(nId); - unsigned numRegs = getGraph().getNodeCosts(nId).getLength() - 1; + NodeData &nd = getHeuristicNodeData(nItr); + unsigned numRegs = getGraph().getNodeCosts(nItr).getLength() - 1; - bool nIsNode1 = nId == getGraph().getEdgeNode1(eId); + bool nIsNode1 = nItr == getGraph().getEdgeNode1(eItr); EdgeData::UnsafeArray &unsafe = nIsNode1 ? ed.unsafe : ed.reverseUnsafe; nd.numDenied -= nIsNode1 ? ed.worst : ed.reverseWorst; @@ -402,22 +402,22 @@ namespace PBQP { } } - void updateAllocability(Graph::NodeId nId) { - NodeData &nd = getHeuristicNodeData(nId); - unsigned numRegs = getGraph().getNodeCosts(nId).getLength() - 1; + void updateAllocability(Graph::NodeItr nItr) { + NodeData &nd = getHeuristicNodeData(nItr); + unsigned numRegs = getGraph().getNodeCosts(nItr).getLength() - 1; nd.isAllocable = nd.numDenied < numRegs || nd.numSafe > 0; } - void initializeNode(Graph::NodeId nId) { - NodeData &nd = getHeuristicNodeData(nId); + void initializeNode(Graph::NodeItr nItr) { + NodeData &nd = getHeuristicNodeData(nItr); if (nd.isInitialized) return; // Node data is already up to date. - unsigned numRegs = getGraph().getNodeCosts(nId).getLength() - 1; + unsigned numRegs = getGraph().getNodeCosts(nItr).getLength() - 1; nd.numDenied = 0; - const Vector& nCosts = getGraph().getNodeCosts(nId); + const Vector& nCosts = getGraph().getNodeCosts(nItr); for (unsigned i = 1; i < nCosts.getLength(); ++i) { if (nCosts[i] == std::numeric_limits::infinity()) ++nd.numDenied; @@ -428,27 +428,27 @@ namespace PBQP { typedef HeuristicSolverImpl::SolverEdgeItr SolverEdgeItr; - for (SolverEdgeItr aeItr = getSolver().solverEdgesBegin(nId), - aeEnd = getSolver().solverEdgesEnd(nId); + for (SolverEdgeItr aeItr = getSolver().solverEdgesBegin(nItr), + aeEnd = getSolver().solverEdgesEnd(nItr); aeItr != aeEnd; ++aeItr) { - Graph::EdgeId eId = *aeItr; - computeEdgeContributions(eId); - addEdgeContributions(eId, nId); + Graph::EdgeItr eItr = *aeItr; + computeEdgeContributions(eItr); + addEdgeContributions(eItr, nItr); } - updateAllocability(nId); + updateAllocability(nItr); nd.isInitialized = true; } - void handleRemoveNode(Graph::NodeId xnId) { + void handleRemoveNode(Graph::NodeItr xnItr) { typedef HeuristicSolverImpl::SolverEdgeItr SolverEdgeItr; - std::vector edgesToRemove; - for (SolverEdgeItr aeItr = getSolver().solverEdgesBegin(xnId), - aeEnd = getSolver().solverEdgesEnd(xnId); + std::vector edgesToRemove; + for (SolverEdgeItr aeItr = getSolver().solverEdgesBegin(xnItr), + aeEnd = getSolver().solverEdgesEnd(xnItr); aeItr != aeEnd; ++aeItr) { - Graph::NodeId ynId = getGraph().getEdgeOtherNode(*aeItr, xnId); - handleRemoveEdge(*aeItr, ynId); + Graph::NodeItr ynItr = getGraph().getEdgeOtherNode(*aeItr, xnItr); + handleRemoveEdge(*aeItr, ynItr); edgesToRemove.push_back(*aeItr); } while (!edgesToRemove.empty()) { diff --git a/include/llvm/CodeGen/PBQP/Solution.h b/include/llvm/CodeGen/PBQP/Solution.h index 98ba5a1..b9f288b 100644 --- a/include/llvm/CodeGen/PBQP/Solution.h +++ b/include/llvm/CodeGen/PBQP/Solution.h @@ -26,7 +26,8 @@ namespace PBQP { class Solution { private: - typedef std::map SelectionsMap; + typedef std::map SelectionsMap; SelectionsMap selections; unsigned r0Reductions, r1Reductions, r2Reductions, rNReductions; @@ -72,15 +73,15 @@ namespace PBQP { /// \brief Set the selection for a given node. /// @param nItr Node iterator. /// @param selection Selection for nItr. - void setSelection(Graph::NodeId nodeId, unsigned selection) { - selections[nodeId] = selection; + void setSelection(Graph::NodeItr nItr, unsigned selection) { + selections[nItr] = selection; } /// \brief Get a node's selection. /// @param nItr Node iterator. /// @return The selection for nItr; - unsigned getSelection(Graph::NodeId nodeId) const { - SelectionsMap::const_iterator sItr = selections.find(nodeId); + unsigned getSelection(Graph::ConstNodeItr nItr) const { + SelectionsMap::const_iterator sItr = selections.find(nItr); assert(sItr != selections.end() && "No selection for node."); return sItr->second; } diff --git a/include/llvm/CodeGen/RegAllocPBQP.h b/include/llvm/CodeGen/RegAllocPBQP.h index 7472e5a..6f2d139 100644 --- a/include/llvm/CodeGen/RegAllocPBQP.h +++ b/include/llvm/CodeGen/RegAllocPBQP.h @@ -52,22 +52,22 @@ namespace llvm { /// PBQPBuilder you are unlikely to need this: Nodes and options for all /// vregs will already have been set up for you by the base class. template - void recordVReg(unsigned vreg, PBQP::Graph::NodeId nodeId, + void recordVReg(unsigned vreg, PBQP::Graph::NodeItr node, AllowedRegsItr arBegin, AllowedRegsItr arEnd) { - assert(node2VReg.find(nodeId) == node2VReg.end() && "Re-mapping node."); + assert(node2VReg.find(node) == node2VReg.end() && "Re-mapping node."); assert(vreg2Node.find(vreg) == vreg2Node.end() && "Re-mapping vreg."); assert(allowedSets[vreg].empty() && "vreg already has pregs."); - node2VReg[nodeId] = vreg; - vreg2Node[vreg] = nodeId; + node2VReg[node] = vreg; + vreg2Node[vreg] = node; std::copy(arBegin, arEnd, std::back_inserter(allowedSets[vreg])); } /// Get the virtual register corresponding to the given PBQP node. - unsigned getVRegForNode(PBQP::Graph::NodeId nodeId) const; + unsigned getVRegForNode(PBQP::Graph::ConstNodeItr node) const; /// Get the PBQP node corresponding to the given virtual register. - PBQP::Graph::NodeId getNodeForVReg(unsigned vreg) const; + PBQP::Graph::NodeItr getNodeForVReg(unsigned vreg) const; /// Returns true if the given PBQP option represents a physical register, /// false otherwise. @@ -92,8 +92,9 @@ namespace llvm { private: - typedef std::map Node2VReg; - typedef DenseMap VReg2Node; + typedef std::map Node2VReg; + typedef DenseMap VReg2Node; typedef DenseMap AllowedSetMap; PBQP::Graph graph; -- cgit v1.1 From a91d7b170b57e3ccb715e331575ef198e51cd304 Mon Sep 17 00:00:00 2001 From: Lang Hames Date: Sat, 9 Nov 2013 03:08:56 +0000 Subject: Re-apply r194300 with fixes for warnings. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194311 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/PBQP/Graph.h | 366 +++++++++++++------------- include/llvm/CodeGen/PBQP/HeuristicBase.h | 40 +-- include/llvm/CodeGen/PBQP/HeuristicSolver.h | 248 ++++++++--------- include/llvm/CodeGen/PBQP/Heuristics/Briggs.h | 176 ++++++------- include/llvm/CodeGen/PBQP/Solution.h | 11 +- include/llvm/CodeGen/RegAllocPBQP.h | 17 +- 6 files changed, 435 insertions(+), 423 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/PBQP/Graph.h b/include/llvm/CodeGen/PBQP/Graph.h index b57abca..f83190e 100644 --- a/include/llvm/CodeGen/PBQP/Graph.h +++ b/include/llvm/CodeGen/PBQP/Graph.h @@ -20,79 +20,63 @@ #include "llvm/ADT/ilist_node.h" #include #include +#include namespace PBQP { /// PBQP Graph class. /// Instances of this class describe PBQP problems. class Graph { - private: - - // ----- TYPEDEFS ----- - class NodeEntry; - class EdgeEntry; - - typedef llvm::ilist NodeList; - typedef llvm::ilist EdgeList; - public: - typedef NodeList::iterator NodeItr; - typedef NodeList::const_iterator ConstNodeItr; - - typedef EdgeList::iterator EdgeItr; - typedef EdgeList::const_iterator ConstEdgeItr; + typedef unsigned NodeId; + typedef unsigned EdgeId; private: - typedef std::list AdjEdgeList; - + typedef std::set AdjEdgeList; + public: typedef AdjEdgeList::iterator AdjEdgeItr; private: - class NodeEntry : public llvm::ilist_node { - friend struct llvm::ilist_sentinel_traits; + class NodeEntry { private: Vector costs; AdjEdgeList adjEdges; - unsigned degree; void *data; NodeEntry() : costs(0, 0) {} public: - NodeEntry(const Vector &costs) : costs(costs), degree(0) {} + NodeEntry(const Vector &costs) : costs(costs), data(0) {} Vector& getCosts() { return costs; } const Vector& getCosts() const { return costs; } - unsigned getDegree() const { return degree; } + unsigned getDegree() const { return adjEdges.size(); } AdjEdgeItr edgesBegin() { return adjEdges.begin(); } AdjEdgeItr edgesEnd() { return adjEdges.end(); } - AdjEdgeItr addEdge(EdgeItr e) { - ++degree; + AdjEdgeItr addEdge(EdgeId e) { return adjEdges.insert(adjEdges.end(), e); } void removeEdge(AdjEdgeItr ae) { - --degree; adjEdges.erase(ae); } void setData(void *data) { this->data = data; } void* getData() { return data; } }; - class EdgeEntry : public llvm::ilist_node { - friend struct llvm::ilist_sentinel_traits; + class EdgeEntry { private: - NodeItr node1, node2; + NodeId node1, node2; Matrix costs; AdjEdgeItr node1AEItr, node2AEItr; void *data; - EdgeEntry() : costs(0, 0, 0) {} + EdgeEntry() : costs(0, 0, 0), data(0) {} public: - EdgeEntry(NodeItr node1, NodeItr node2, const Matrix &costs) + EdgeEntry(NodeId node1, NodeId node2, const Matrix &costs) : node1(node1), node2(node2), costs(costs) {} - NodeItr getNode1() const { return node1; } - NodeItr getNode2() const { return node2; } + NodeId getNode1() const { return node1; } + NodeId getNode2() const { return node2; } Matrix& getCosts() { return costs; } const Matrix& getCosts() const { return costs; } void setNode1AEItr(AdjEdgeItr ae) { node1AEItr = ae; } @@ -105,72 +89,128 @@ namespace PBQP { // ----- MEMBERS ----- - NodeList nodes; - unsigned numNodes; + typedef std::vector NodeVector; + typedef std::vector FreeNodeVector; + NodeVector nodes; + FreeNodeVector freeNodes; - EdgeList edges; - unsigned numEdges; + typedef std::vector EdgeVector; + typedef std::vector FreeEdgeVector; + EdgeVector edges; + FreeEdgeVector freeEdges; // ----- INTERNAL METHODS ----- - NodeEntry& getNode(NodeItr nItr) { return *nItr; } - const NodeEntry& getNode(ConstNodeItr nItr) const { return *nItr; } - - EdgeEntry& getEdge(EdgeItr eItr) { return *eItr; } - const EdgeEntry& getEdge(ConstEdgeItr eItr) const { return *eItr; } - - NodeItr addConstructedNode(const NodeEntry &n) { - ++numNodes; - return nodes.insert(nodes.end(), n); + NodeEntry& getNode(NodeId nId) { return nodes[nId]; } + const NodeEntry& getNode(NodeId nId) const { return nodes[nId]; } + + EdgeEntry& getEdge(EdgeId eId) { return edges[eId]; } + const EdgeEntry& getEdge(EdgeId eId) const { return edges[eId]; } + + NodeId addConstructedNode(const NodeEntry &n) { + NodeId nodeId = 0; + if (!freeNodes.empty()) { + nodeId = freeNodes.back(); + freeNodes.pop_back(); + nodes[nodeId] = n; + } else { + nodeId = nodes.size(); + nodes.push_back(n); + } + return nodeId; } - EdgeItr addConstructedEdge(const EdgeEntry &e) { - assert(findEdge(e.getNode1(), e.getNode2()) == edges.end() && + EdgeId addConstructedEdge(const EdgeEntry &e) { + assert(findEdge(e.getNode1(), e.getNode2()) == invalidEdgeId() && "Attempt to add duplicate edge."); - ++numEdges; - EdgeItr edgeItr = edges.insert(edges.end(), e); - EdgeEntry &ne = getEdge(edgeItr); + EdgeId edgeId = 0; + if (!freeEdges.empty()) { + edgeId = freeEdges.back(); + freeEdges.pop_back(); + edges[edgeId] = e; + } else { + edgeId = edges.size(); + edges.push_back(e); + } + + EdgeEntry &ne = getEdge(edgeId); NodeEntry &n1 = getNode(ne.getNode1()); NodeEntry &n2 = getNode(ne.getNode2()); + // Sanity check on matrix dimensions: assert((n1.getCosts().getLength() == ne.getCosts().getRows()) && (n2.getCosts().getLength() == ne.getCosts().getCols()) && "Edge cost dimensions do not match node costs dimensions."); - ne.setNode1AEItr(n1.addEdge(edgeItr)); - ne.setNode2AEItr(n2.addEdge(edgeItr)); - return edgeItr; + + ne.setNode1AEItr(n1.addEdge(edgeId)); + ne.setNode2AEItr(n2.addEdge(edgeId)); + return edgeId; } - inline void copyFrom(const Graph &other); + Graph(const Graph &other) {} + void operator=(const Graph &other) {} + public: - /// \brief Construct an empty PBQP graph. - Graph() : numNodes(0), numEdges(0) {} + class NodeItr { + public: + NodeItr(NodeId nodeId, const Graph &g) + : nodeId(nodeId), endNodeId(g.nodes.size()), freeNodes(g.freeNodes) { + this->nodeId = findNextInUse(nodeId); // Move to the first in-use nodeId + } - /// \brief Copy construct this graph from "other". Note: Does not copy node - /// and edge data, only graph structure and costs. - /// @param other Source graph to copy from. - Graph(const Graph &other) : numNodes(0), numEdges(0) { - copyFrom(other); - } + bool operator==(const NodeItr& n) const { return nodeId == n.nodeId; } + bool operator!=(const NodeItr& n) const { return !(*this == n); } + NodeItr& operator++() { nodeId = findNextInUse(++nodeId); return *this; } + NodeId operator*() const { return nodeId; } - /// \brief Make this graph a copy of "other". Note: Does not copy node and - /// edge data, only graph structure and costs. - /// @param other The graph to copy from. - /// @return A reference to this graph. - /// - /// This will clear the current graph, erasing any nodes and edges added, - /// before copying from other. - Graph& operator=(const Graph &other) { - clear(); - copyFrom(other); - return *this; - } + private: + NodeId findNextInUse(NodeId n) const { + while (n < endNodeId && + std::find(freeNodes.begin(), freeNodes.end(), n) != + freeNodes.end()) { + ++n; + } + return n; + } + + NodeId nodeId, endNodeId; + const FreeNodeVector& freeNodes; + }; + + class EdgeItr { + public: + EdgeItr(EdgeId edgeId, const Graph &g) + : edgeId(edgeId), endEdgeId(g.edges.size()), freeEdges(g.freeEdges) { + this->edgeId = findNextInUse(edgeId); // Move to the first in-use edgeId + } + + bool operator==(const EdgeItr& n) const { return edgeId == n.edgeId; } + bool operator!=(const EdgeItr& n) const { return !(*this == n); } + EdgeItr& operator++() { edgeId = findNextInUse(++edgeId); return *this; } + EdgeId operator*() const { return edgeId; } + + private: + EdgeId findNextInUse(EdgeId n) const { + while (n < endEdgeId && + std::find(freeEdges.begin(), freeEdges.end(), n) != + freeEdges.end()) { + ++n; + } + return n; + } + + EdgeId edgeId, endEdgeId; + const FreeEdgeVector& freeEdges; + }; + + /// \brief Construct an empty PBQP graph. + Graph() {} /// \brief Add a node with the given costs. /// @param costs Cost vector for the new node. /// @return Node iterator for the added node. - NodeItr addNode(const Vector &costs) { + NodeId addNode(const Vector &costs) { return addConstructedNode(NodeEntry(costs)); } @@ -178,32 +218,31 @@ namespace PBQP { /// @param n1Itr First node. /// @param n2Itr Second node. /// @return Edge iterator for the added edge. - EdgeItr addEdge(Graph::NodeItr n1Itr, Graph::NodeItr n2Itr, - const Matrix &costs) { - assert(getNodeCosts(n1Itr).getLength() == costs.getRows() && - getNodeCosts(n2Itr).getLength() == costs.getCols() && + EdgeId addEdge(NodeId n1Id, NodeId n2Id, const Matrix &costs) { + assert(getNodeCosts(n1Id).getLength() == costs.getRows() && + getNodeCosts(n2Id).getLength() == costs.getCols() && "Matrix dimensions mismatch."); - return addConstructedEdge(EdgeEntry(n1Itr, n2Itr, costs)); + return addConstructedEdge(EdgeEntry(n1Id, n2Id, costs)); } /// \brief Get the number of nodes in the graph. /// @return Number of nodes in the graph. - unsigned getNumNodes() const { return numNodes; } + unsigned getNumNodes() const { return nodes.size() - freeNodes.size(); } /// \brief Get the number of edges in the graph. /// @return Number of edges in the graph. - unsigned getNumEdges() const { return numEdges; } + unsigned getNumEdges() const { return edges.size() - freeEdges.size(); } /// \brief Get a node's cost vector. /// @param nItr Node iterator. /// @return Node cost vector. - Vector& getNodeCosts(NodeItr nItr) { return getNode(nItr).getCosts(); } + Vector& getNodeCosts(NodeId nId) { return getNode(nId).getCosts(); } /// \brief Get a node's cost vector (const version). /// @param nItr Node iterator. /// @return Node cost vector. - const Vector& getNodeCosts(ConstNodeItr nItr) const { - return getNode(nItr).getCosts(); + const Vector& getNodeCosts(NodeId nId) const { + return getNode(nId).getCosts(); } /// \brief Set a node's data pointer. @@ -211,23 +250,23 @@ namespace PBQP { /// @param data Pointer to node data. /// /// Typically used by a PBQP solver to attach data to aid in solution. - void setNodeData(NodeItr nItr, void *data) { getNode(nItr).setData(data); } + void setNodeData(NodeId nId, void *data) { getNode(nId).setData(data); } /// \brief Get the node's data pointer. /// @param nItr Node iterator. /// @return Pointer to node data. - void* getNodeData(NodeItr nItr) { return getNode(nItr).getData(); } + void* getNodeData(NodeId nId) { return getNode(nId).getData(); } /// \brief Get an edge's cost matrix. /// @param eItr Edge iterator. /// @return Edge cost matrix. - Matrix& getEdgeCosts(EdgeItr eItr) { return getEdge(eItr).getCosts(); } + Matrix& getEdgeCosts(EdgeId eId) { return getEdge(eId).getCosts(); } /// \brief Get an edge's cost matrix (const version). /// @param eItr Edge iterator. /// @return Edge cost matrix. - const Matrix& getEdgeCosts(ConstEdgeItr eItr) const { - return getEdge(eItr).getCosts(); + const Matrix& getEdgeCosts(EdgeId eId) const { + return getEdge(eId).getCosts(); } /// \brief Set an edge's data pointer. @@ -235,124 +274,120 @@ namespace PBQP { /// @param data Pointer to edge data. /// /// Typically used by a PBQP solver to attach data to aid in solution. - void setEdgeData(EdgeItr eItr, void *data) { getEdge(eItr).setData(data); } + void setEdgeData(EdgeId eId, void *data) { getEdge(eId).setData(data); } /// \brief Get an edge's data pointer. /// @param eItr Edge iterator. /// @return Pointer to edge data. - void* getEdgeData(EdgeItr eItr) { return getEdge(eItr).getData(); } + void* getEdgeData(EdgeId eId) { return getEdge(eId).getData(); } /// \brief Get a node's degree. /// @param nItr Node iterator. /// @return The degree of the node. - unsigned getNodeDegree(NodeItr nItr) const { - return getNode(nItr).getDegree(); + unsigned getNodeDegree(NodeId nId) const { + return getNode(nId).getDegree(); } /// \brief Begin iterator for node set. - NodeItr nodesBegin() { return nodes.begin(); } - - /// \brief Begin const iterator for node set. - ConstNodeItr nodesBegin() const { return nodes.begin(); } + NodeItr nodesBegin() const { return NodeItr(0, *this); } /// \brief End iterator for node set. - NodeItr nodesEnd() { return nodes.end(); } - - /// \brief End const iterator for node set. - ConstNodeItr nodesEnd() const { return nodes.end(); } + NodeItr nodesEnd() const { return NodeItr(nodes.size(), *this); } /// \brief Begin iterator for edge set. - EdgeItr edgesBegin() { return edges.begin(); } + EdgeItr edgesBegin() const { return EdgeItr(0, *this); } /// \brief End iterator for edge set. - EdgeItr edgesEnd() { return edges.end(); } + EdgeItr edgesEnd() const { return EdgeItr(edges.size(), *this); } /// \brief Get begin iterator for adjacent edge set. /// @param nItr Node iterator. /// @return Begin iterator for the set of edges connected to the given node. - AdjEdgeItr adjEdgesBegin(NodeItr nItr) { - return getNode(nItr).edgesBegin(); + AdjEdgeItr adjEdgesBegin(NodeId nId) { + return getNode(nId).edgesBegin(); } /// \brief Get end iterator for adjacent edge set. /// @param nItr Node iterator. /// @return End iterator for the set of edges connected to the given node. - AdjEdgeItr adjEdgesEnd(NodeItr nItr) { - return getNode(nItr).edgesEnd(); + AdjEdgeItr adjEdgesEnd(NodeId nId) { + return getNode(nId).edgesEnd(); } /// \brief Get the first node connected to this edge. /// @param eItr Edge iterator. /// @return The first node connected to the given edge. - NodeItr getEdgeNode1(EdgeItr eItr) { - return getEdge(eItr).getNode1(); + NodeId getEdgeNode1(EdgeId eId) { + return getEdge(eId).getNode1(); } /// \brief Get the second node connected to this edge. /// @param eItr Edge iterator. /// @return The second node connected to the given edge. - NodeItr getEdgeNode2(EdgeItr eItr) { - return getEdge(eItr).getNode2(); + NodeId getEdgeNode2(EdgeId eId) { + return getEdge(eId).getNode2(); } /// \brief Get the "other" node connected to this edge. /// @param eItr Edge iterator. /// @param nItr Node iterator for the "given" node. /// @return The iterator for the "other" node connected to this edge. - NodeItr getEdgeOtherNode(EdgeItr eItr, NodeItr nItr) { - EdgeEntry &e = getEdge(eItr); - if (e.getNode1() == nItr) { + NodeId getEdgeOtherNode(EdgeId eId, NodeId nId) { + EdgeEntry &e = getEdge(eId); + if (e.getNode1() == nId) { return e.getNode2(); } // else return e.getNode1(); } + EdgeId invalidEdgeId() const { + return std::numeric_limits::max(); + } + /// \brief Get the edge connecting two nodes. - /// @param n1Itr First node iterator. - /// @param n2Itr Second node iterator. - /// @return An iterator for edge (n1Itr, n2Itr) if such an edge exists, - /// otherwise returns edgesEnd(). - EdgeItr findEdge(NodeItr n1Itr, NodeItr n2Itr) { - for (AdjEdgeItr aeItr = adjEdgesBegin(n1Itr), aeEnd = adjEdgesEnd(n1Itr); + /// @param n1Id First node id. + /// @param n2Id Second node id. + /// @return An id for edge (n1Id, n2Id) if such an edge exists, + /// otherwise returns an invalid edge id. + EdgeId findEdge(NodeId n1Id, NodeId n2Id) { + for (AdjEdgeItr aeItr = adjEdgesBegin(n1Id), aeEnd = adjEdgesEnd(n1Id); aeItr != aeEnd; ++aeItr) { - if ((getEdgeNode1(*aeItr) == n2Itr) || - (getEdgeNode2(*aeItr) == n2Itr)) { + if ((getEdgeNode1(*aeItr) == n2Id) || + (getEdgeNode2(*aeItr) == n2Id)) { return *aeItr; } } - return edges.end(); + return invalidEdgeId(); } /// \brief Remove a node from the graph. - /// @param nItr Node iterator. - void removeNode(NodeItr nItr) { - NodeEntry &n = getNode(nItr); - for (AdjEdgeItr itr = n.edgesBegin(), end = n.edgesEnd(); itr != end;) { - EdgeItr eItr = *itr; - ++itr; - removeEdge(eItr); + /// @param nItr Node id. + void removeNode(NodeId nId) { + NodeEntry &n = getNode(nId); + for (AdjEdgeItr itr = n.edgesBegin(), end = n.edgesEnd(); itr != end; ++itr) { + EdgeId eId = *itr; + removeEdge(eId); } - nodes.erase(nItr); - --numNodes; + freeNodes.push_back(nId); } /// \brief Remove an edge from the graph. /// @param eItr Edge iterator. - void removeEdge(EdgeItr eItr) { - EdgeEntry &e = getEdge(eItr); + void removeEdge(EdgeId eId) { + EdgeEntry &e = getEdge(eId); NodeEntry &n1 = getNode(e.getNode1()); NodeEntry &n2 = getNode(e.getNode2()); n1.removeEdge(e.getNode1AEItr()); n2.removeEdge(e.getNode2AEItr()); - edges.erase(eItr); - --numEdges; + freeEdges.push_back(eId); } /// \brief Remove all nodes and edges from the graph. void clear() { nodes.clear(); + freeNodes.clear(); edges.clear(); - numNodes = numEdges = 0; + freeEdges.clear(); } /// \brief Dump a graph to an output stream. @@ -362,7 +397,7 @@ namespace PBQP { for (NodeItr nodeItr = nodesBegin(), nodeEnd = nodesEnd(); nodeItr != nodeEnd; ++nodeItr) { - const Vector& v = getNodeCosts(nodeItr); + const Vector& v = getNodeCosts(*nodeItr); os << "\n" << v.getLength() << "\n"; assert(v.getLength() != 0 && "Empty vector in graph."); os << v[0]; @@ -374,10 +409,10 @@ namespace PBQP { for (EdgeItr edgeItr = edgesBegin(), edgeEnd = edgesEnd(); edgeItr != edgeEnd; ++edgeItr) { - unsigned n1 = std::distance(nodesBegin(), getEdgeNode1(edgeItr)); - unsigned n2 = std::distance(nodesBegin(), getEdgeNode2(edgeItr)); + NodeId n1 = getEdgeNode1(*edgeItr); + NodeId n2 = getEdgeNode2(*edgeItr); assert(n1 != n2 && "PBQP graphs shound not have self-edges."); - const Matrix& m = getEdgeCosts(edgeItr); + const Matrix& m = getEdgeCosts(*edgeItr); os << "\n" << n1 << " " << n2 << "\n" << m.getRows() << " " << m.getCols() << "\n"; assert(m.getRows() != 0 && "No rows in matrix."); @@ -403,7 +438,7 @@ namespace PBQP { nodeItr != nodeEnd; ++nodeItr) { os << " node" << nodeItr << " [ label=\"" - << nodeItr << ": " << getNodeCosts(nodeItr) << "\" ]\n"; + << nodeItr << ": " << getNodeCosts(*nodeItr) << "\" ]\n"; } os << " edge [ len=" << getNumNodes() << " ]\n"; @@ -411,11 +446,11 @@ namespace PBQP { for (EdgeItr edgeItr = edgesBegin(), edgeEnd = edgesEnd(); edgeItr != edgeEnd; ++edgeItr) { - os << " node" << getEdgeNode1(edgeItr) - << " -- node" << getEdgeNode2(edgeItr) + os << " node" << getEdgeNode1(*edgeItr) + << " -- node" << getEdgeNode2(*edgeItr) << " [ label=\""; - const Matrix &edgeCosts = getEdgeCosts(edgeItr); + const Matrix &edgeCosts = getEdgeCosts(*edgeItr); for (unsigned i = 0; i < edgeCosts.getRows(); ++i) { os << edgeCosts.getRowAsVector(i) << "\\n"; @@ -427,39 +462,16 @@ namespace PBQP { }; - class NodeItrComparator { - public: - bool operator()(Graph::NodeItr n1, Graph::NodeItr n2) const { - return &*n1 < &*n2; - } +// void Graph::copyFrom(const Graph &other) { +// std::map nodeMap; - bool operator()(Graph::ConstNodeItr n1, Graph::ConstNodeItr n2) const { - return &*n1 < &*n2; - } - }; - - class EdgeItrCompartor { - public: - bool operator()(Graph::EdgeItr e1, Graph::EdgeItr e2) const { - return &*e1 < &*e2; - } - - bool operator()(Graph::ConstEdgeItr e1, Graph::ConstEdgeItr e2) const { - return &*e1 < &*e2; - } - }; - - void Graph::copyFrom(const Graph &other) { - std::map nodeMap; - - for (Graph::ConstNodeItr nItr = other.nodesBegin(), - nEnd = other.nodesEnd(); - nItr != nEnd; ++nItr) { - nodeMap[nItr] = addNode(other.getNodeCosts(nItr)); - } - - } +// for (Graph::ConstNodeItr nItr = other.nodesBegin(), +// nEnd = other.nodesEnd(); +// nItr != nEnd; ++nItr) { +// nodeMap[nItr] = addNode(other.getNodeCosts(nItr)); +// } +// } } diff --git a/include/llvm/CodeGen/PBQP/HeuristicBase.h b/include/llvm/CodeGen/PBQP/HeuristicBase.h index 0c1fcb7..36d94d6 100644 --- a/include/llvm/CodeGen/PBQP/HeuristicBase.h +++ b/include/llvm/CodeGen/PBQP/HeuristicBase.h @@ -52,7 +52,7 @@ namespace PBQP { class HeuristicBase { private: - typedef std::list OptimalList; + typedef std::list OptimalList; HeuristicSolverImpl &s; Graph &g; @@ -63,8 +63,8 @@ namespace PBQP { // Add the given node to the optimal reductions list. Keep an iterator to // its location for fast removal. - void addToOptimalReductionList(Graph::NodeItr nItr) { - optimalList.insert(optimalList.end(), nItr); + void addToOptimalReductionList(Graph::NodeId nId) { + optimalList.insert(optimalList.end(), nId); } public: @@ -105,8 +105,8 @@ namespace PBQP { /// criteria. Note however that your criteria for selecting optimal nodes /// should be at least as strong as this. I.e. Nodes of degree 3 or /// higher should not be selected under any circumstances. - bool shouldOptimallyReduce(Graph::NodeItr nItr) { - if (g.getNodeDegree(nItr) < 3) + bool shouldOptimallyReduce(Graph::NodeId nId) { + if (g.getNodeDegree(nId) < 3) return true; // else return false; @@ -118,8 +118,8 @@ namespace PBQP { /// You probably don't want to over-ride this, except perhaps to record /// statistics before calling this implementation. HeuristicBase relies on /// its behaviour. - void addToOptimalReduceList(Graph::NodeItr nItr) { - optimalList.push_back(nItr); + void addToOptimalReduceList(Graph::NodeId nId) { + optimalList.push_back(nId); } /// \brief Initialise the heuristic. @@ -132,10 +132,10 @@ namespace PBQP { void setup() { for (Graph::NodeItr nItr = g.nodesBegin(), nEnd = g.nodesEnd(); nItr != nEnd; ++nItr) { - if (impl().shouldOptimallyReduce(nItr)) { - addToOptimalReduceList(nItr); + if (impl().shouldOptimallyReduce(*nItr)) { + addToOptimalReduceList(*nItr); } else { - impl().addToHeuristicReduceList(nItr); + impl().addToHeuristicReduceList(*nItr); } } } @@ -150,13 +150,13 @@ namespace PBQP { if (optimalList.empty()) return false; - Graph::NodeItr nItr = optimalList.front(); + Graph::NodeId nId = optimalList.front(); optimalList.pop_front(); - switch (s.getSolverDegree(nItr)) { - case 0: s.applyR0(nItr); break; - case 1: s.applyR1(nItr); break; - case 2: s.applyR2(nItr); break; + switch (s.getSolverDegree(nId)) { + case 0: s.applyR0(nId); break; + case 1: s.applyR1(nId); break; + case 2: s.applyR2(nId); break; default: llvm_unreachable( "Optimal reductions of degree > 2 nodes is invalid."); } @@ -185,7 +185,7 @@ namespace PBQP { /// \brief Add a node to the heuristic reduce list. /// @param nItr Node iterator to add to the heuristic reduce list. - void addToHeuristicList(Graph::NodeItr nItr) { + void addToHeuristicList(Graph::NodeId nId) { llvm_unreachable("Must be implemented in derived class."); } @@ -200,19 +200,19 @@ namespace PBQP { /// \brief Prepare a change in the costs on the given edge. /// @param eItr Edge iterator. - void preUpdateEdgeCosts(Graph::EdgeItr eItr) { + void preUpdateEdgeCosts(Graph::EdgeId eId) { llvm_unreachable("Must be implemented in derived class."); } /// \brief Handle the change in the costs on the given edge. /// @param eItr Edge iterator. - void postUpdateEdgeCostts(Graph::EdgeItr eItr) { + void postUpdateEdgeCostts(Graph::EdgeId eId) { llvm_unreachable("Must be implemented in derived class."); } /// \brief Handle the addition of a new edge into the PBQP graph. /// @param eItr Edge iterator for the added edge. - void handleAddEdge(Graph::EdgeItr eItr) { + void handleAddEdge(Graph::EdgeId eId) { llvm_unreachable("Must be implemented in derived class."); } @@ -223,7 +223,7 @@ namespace PBQP { /// Edges are frequently removed due to the removal of a node. This /// method allows for the effect to be computed only for the remaining /// node in the graph. - void handleRemoveEdge(Graph::EdgeItr eItr, Graph::NodeItr nItr) { + void handleRemoveEdge(Graph::EdgeId eId, Graph::NodeId nId) { llvm_unreachable("Must be implemented in derived class."); } diff --git a/include/llvm/CodeGen/PBQP/HeuristicSolver.h b/include/llvm/CodeGen/PBQP/HeuristicSolver.h index 47e15b2..7fa6386 100644 --- a/include/llvm/CodeGen/PBQP/HeuristicSolver.h +++ b/include/llvm/CodeGen/PBQP/HeuristicSolver.h @@ -40,7 +40,7 @@ namespace PBQP { typedef typename HImpl::NodeData HeuristicNodeData; typedef typename HImpl::EdgeData HeuristicEdgeData; - typedef std::list SolverEdges; + typedef std::list SolverEdges; public: @@ -55,9 +55,9 @@ namespace PBQP { HeuristicNodeData& getHeuristicData() { return hData; } - SolverEdgeItr addSolverEdge(Graph::EdgeItr eItr) { + SolverEdgeItr addSolverEdge(Graph::EdgeId eId) { ++solverDegree; - return solverEdges.insert(solverEdges.end(), eItr); + return solverEdges.insert(solverEdges.end(), eId); } void removeSolverEdge(SolverEdgeItr seItr) { @@ -104,7 +104,7 @@ namespace PBQP { Graph &g; HImpl h; Solution s; - std::vector stack; + std::vector stack; typedef std::list NodeDataList; NodeDataList nodeDataList; @@ -127,15 +127,15 @@ namespace PBQP { /// \brief Get the heuristic data attached to the given node. /// @param nItr Node iterator. /// @return The heuristic data attached to the given node. - HeuristicNodeData& getHeuristicNodeData(Graph::NodeItr nItr) { - return getSolverNodeData(nItr).getHeuristicData(); + HeuristicNodeData& getHeuristicNodeData(Graph::NodeId nId) { + return getSolverNodeData(nId).getHeuristicData(); } /// \brief Get the heuristic data attached to the given edge. /// @param eItr Edge iterator. /// @return The heuristic data attached to the given node. - HeuristicEdgeData& getHeuristicEdgeData(Graph::EdgeItr eItr) { - return getSolverEdgeData(eItr).getHeuristicData(); + HeuristicEdgeData& getHeuristicEdgeData(Graph::EdgeId eId) { + return getSolverEdgeData(eId).getHeuristicData(); } /// \brief Begin iterator for the set of edges adjacent to the given node in @@ -143,8 +143,8 @@ namespace PBQP { /// @param nItr Node iterator. /// @return Begin iterator for the set of edges adjacent to the given node /// in the solver graph. - SolverEdgeItr solverEdgesBegin(Graph::NodeItr nItr) { - return getSolverNodeData(nItr).solverEdgesBegin(); + SolverEdgeItr solverEdgesBegin(Graph::NodeId nId) { + return getSolverNodeData(nId).solverEdgesBegin(); } /// \brief End iterator for the set of edges adjacent to the given node in @@ -152,8 +152,8 @@ namespace PBQP { /// @param nItr Node iterator. /// @return End iterator for the set of edges adjacent to the given node in /// the solver graph. - SolverEdgeItr solverEdgesEnd(Graph::NodeItr nItr) { - return getSolverNodeData(nItr).solverEdgesEnd(); + SolverEdgeItr solverEdgesEnd(Graph::NodeId nId) { + return getSolverNodeData(nId).solverEdgesEnd(); } /// \brief Remove a node from the solver graph. @@ -161,10 +161,10 @@ namespace PBQP { /// /// Does not notify the heuristic of the removal. That should be /// done manually if necessary. - void removeSolverEdge(Graph::EdgeItr eItr) { - EdgeData &eData = getSolverEdgeData(eItr); - NodeData &n1Data = getSolverNodeData(g.getEdgeNode1(eItr)), - &n2Data = getSolverNodeData(g.getEdgeNode2(eItr)); + void removeSolverEdge(Graph::EdgeId eId) { + EdgeData &eData = getSolverEdgeData(eId); + NodeData &n1Data = getSolverNodeData(g.getEdgeNode1(eId)), + &n2Data = getSolverNodeData(g.getEdgeNode2(eId)); n1Data.removeSolverEdge(eData.getN1SolverEdgeItr()); n2Data.removeSolverEdge(eData.getN2SolverEdgeItr()); @@ -189,30 +189,30 @@ namespace PBQP { /// \brief Add to the end of the stack. /// @param nItr Node iterator to add to the reduction stack. - void pushToStack(Graph::NodeItr nItr) { - getSolverNodeData(nItr).clearSolverEdges(); - stack.push_back(nItr); + void pushToStack(Graph::NodeId nId) { + getSolverNodeData(nId).clearSolverEdges(); + stack.push_back(nId); } /// \brief Returns the solver degree of the given node. /// @param nItr Node iterator for which degree is requested. /// @return Node degree in the solver graph (not the original graph). - unsigned getSolverDegree(Graph::NodeItr nItr) { - return getSolverNodeData(nItr).getSolverDegree(); + unsigned getSolverDegree(Graph::NodeId nId) { + return getSolverNodeData(nId).getSolverDegree(); } /// \brief Set the solution of the given node. /// @param nItr Node iterator to set solution for. /// @param selection Selection for node. - void setSolution(const Graph::NodeItr &nItr, unsigned selection) { - s.setSelection(nItr, selection); + void setSolution(const Graph::NodeId &nId, unsigned selection) { + s.setSelection(nId, selection); - for (Graph::AdjEdgeItr aeItr = g.adjEdgesBegin(nItr), - aeEnd = g.adjEdgesEnd(nItr); + for (Graph::AdjEdgeItr aeItr = g.adjEdgesBegin(nId), + aeEnd = g.adjEdgesEnd(nId); aeItr != aeEnd; ++aeItr) { - Graph::EdgeItr eItr(*aeItr); - Graph::NodeItr anItr(g.getEdgeOtherNode(eItr, nItr)); - getSolverNodeData(anItr).addSolverEdge(eItr); + Graph::EdgeId eId(*aeItr); + Graph::NodeId anId(g.getEdgeOtherNode(eId, nId)); + getSolverNodeData(anId).addSolverEdge(eId); } } @@ -220,12 +220,12 @@ namespace PBQP { /// @param nItr Node iterator for node to apply R0 to. /// /// Node will be automatically pushed to the solver stack. - void applyR0(Graph::NodeItr nItr) { - assert(getSolverNodeData(nItr).getSolverDegree() == 0 && + void applyR0(Graph::NodeId nId) { + assert(getSolverNodeData(nId).getSolverDegree() == 0 && "R0 applied to node with degree != 0."); // Nothing to do. Just push the node onto the reduction stack. - pushToStack(nItr); + pushToStack(nId); s.recordR0(); } @@ -234,20 +234,20 @@ namespace PBQP { /// @param xnItr Node iterator for node to apply R1 to. /// /// Node will be automatically pushed to the solver stack. - void applyR1(Graph::NodeItr xnItr) { - NodeData &nd = getSolverNodeData(xnItr); + void applyR1(Graph::NodeId xnId) { + NodeData &nd = getSolverNodeData(xnId); assert(nd.getSolverDegree() == 1 && "R1 applied to node with degree != 1."); - Graph::EdgeItr eItr = *nd.solverEdgesBegin(); + Graph::EdgeId eId = *nd.solverEdgesBegin(); - const Matrix &eCosts = g.getEdgeCosts(eItr); - const Vector &xCosts = g.getNodeCosts(xnItr); + const Matrix &eCosts = g.getEdgeCosts(eId); + const Vector &xCosts = g.getNodeCosts(xnId); // Duplicate a little to avoid transposing matrices. - if (xnItr == g.getEdgeNode1(eItr)) { - Graph::NodeItr ynItr = g.getEdgeNode2(eItr); - Vector &yCosts = g.getNodeCosts(ynItr); + if (xnId == g.getEdgeNode1(eId)) { + Graph::NodeId ynId = g.getEdgeNode2(eId); + Vector &yCosts = g.getNodeCosts(ynId); for (unsigned j = 0; j < yCosts.getLength(); ++j) { PBQPNum min = eCosts[0][j] + xCosts[0]; for (unsigned i = 1; i < xCosts.getLength(); ++i) { @@ -257,10 +257,10 @@ namespace PBQP { } yCosts[j] += min; } - h.handleRemoveEdge(eItr, ynItr); + h.handleRemoveEdge(eId, ynId); } else { - Graph::NodeItr ynItr = g.getEdgeNode1(eItr); - Vector &yCosts = g.getNodeCosts(ynItr); + Graph::NodeId ynId = g.getEdgeNode1(eId); + Vector &yCosts = g.getNodeCosts(ynId); for (unsigned i = 0; i < yCosts.getLength(); ++i) { PBQPNum min = eCosts[i][0] + xCosts[0]; for (unsigned j = 1; j < xCosts.getLength(); ++j) { @@ -270,12 +270,12 @@ namespace PBQP { } yCosts[i] += min; } - h.handleRemoveEdge(eItr, ynItr); + h.handleRemoveEdge(eId, ynId); } - removeSolverEdge(eItr); + removeSolverEdge(eId); assert(nd.getSolverDegree() == 0 && "Degree 1 with edge removed should be 0."); - pushToStack(xnItr); + pushToStack(xnId); s.recordR1(); } @@ -283,30 +283,30 @@ namespace PBQP { /// @param xnItr Node iterator for node to apply R2 to. /// /// Node will be automatically pushed to the solver stack. - void applyR2(Graph::NodeItr xnItr) { - assert(getSolverNodeData(xnItr).getSolverDegree() == 2 && + void applyR2(Graph::NodeId xnId) { + assert(getSolverNodeData(xnId).getSolverDegree() == 2 && "R2 applied to node with degree != 2."); - NodeData &nd = getSolverNodeData(xnItr); - const Vector &xCosts = g.getNodeCosts(xnItr); + NodeData &nd = getSolverNodeData(xnId); + const Vector &xCosts = g.getNodeCosts(xnId); SolverEdgeItr aeItr = nd.solverEdgesBegin(); - Graph::EdgeItr yxeItr = *aeItr, - zxeItr = *(++aeItr); + Graph::EdgeId yxeId = *aeItr, + zxeId = *(++aeItr); - Graph::NodeItr ynItr = g.getEdgeOtherNode(yxeItr, xnItr), - znItr = g.getEdgeOtherNode(zxeItr, xnItr); + Graph::NodeId ynId = g.getEdgeOtherNode(yxeId, xnId), + znId = g.getEdgeOtherNode(zxeId, xnId); - bool flipEdge1 = (g.getEdgeNode1(yxeItr) == xnItr), - flipEdge2 = (g.getEdgeNode1(zxeItr) == xnItr); + bool flipEdge1 = (g.getEdgeNode1(yxeId) == xnId), + flipEdge2 = (g.getEdgeNode1(zxeId) == xnId); const Matrix *yxeCosts = flipEdge1 ? - new Matrix(g.getEdgeCosts(yxeItr).transpose()) : - &g.getEdgeCosts(yxeItr); + new Matrix(g.getEdgeCosts(yxeId).transpose()) : + &g.getEdgeCosts(yxeId); const Matrix *zxeCosts = flipEdge2 ? - new Matrix(g.getEdgeCosts(zxeItr).transpose()) : - &g.getEdgeCosts(zxeItr); + new Matrix(g.getEdgeCosts(zxeId).transpose()) : + &g.getEdgeCosts(zxeId); unsigned xLen = xCosts.getLength(), yLen = yxeCosts->getRows(), @@ -333,27 +333,27 @@ namespace PBQP { if (flipEdge2) delete zxeCosts; - Graph::EdgeItr yzeItr = g.findEdge(ynItr, znItr); + Graph::EdgeId yzeId = g.findEdge(ynId, znId); bool addedEdge = false; - if (yzeItr == g.edgesEnd()) { - yzeItr = g.addEdge(ynItr, znItr, delta); + if (yzeId == g.invalidEdgeId()) { + yzeId = g.addEdge(ynId, znId, delta); addedEdge = true; } else { - Matrix &yzeCosts = g.getEdgeCosts(yzeItr); - h.preUpdateEdgeCosts(yzeItr); - if (ynItr == g.getEdgeNode1(yzeItr)) { + Matrix &yzeCosts = g.getEdgeCosts(yzeId); + h.preUpdateEdgeCosts(yzeId); + if (ynId == g.getEdgeNode1(yzeId)) { yzeCosts += delta; } else { yzeCosts += delta.transpose(); } } - bool nullCostEdge = tryNormaliseEdgeMatrix(yzeItr); + bool nullCostEdge = tryNormaliseEdgeMatrix(yzeId); if (!addedEdge) { // If we modified the edge costs let the heuristic know. - h.postUpdateEdgeCosts(yzeItr); + h.postUpdateEdgeCosts(yzeId); } if (nullCostEdge) { @@ -361,26 +361,26 @@ namespace PBQP { if (!addedEdge) { // We didn't just add it, so we need to notify the heuristic // and remove it from the solver. - h.handleRemoveEdge(yzeItr, ynItr); - h.handleRemoveEdge(yzeItr, znItr); - removeSolverEdge(yzeItr); + h.handleRemoveEdge(yzeId, ynId); + h.handleRemoveEdge(yzeId, znId); + removeSolverEdge(yzeId); } - g.removeEdge(yzeItr); + g.removeEdge(yzeId); } else if (addedEdge) { // If the edge was added, and non-null, finish setting it up, add it to // the solver & notify heuristic. edgeDataList.push_back(EdgeData()); - g.setEdgeData(yzeItr, &edgeDataList.back()); - addSolverEdge(yzeItr); - h.handleAddEdge(yzeItr); + g.setEdgeData(yzeId, &edgeDataList.back()); + addSolverEdge(yzeId); + h.handleAddEdge(yzeId); } - h.handleRemoveEdge(yxeItr, ynItr); - removeSolverEdge(yxeItr); - h.handleRemoveEdge(zxeItr, znItr); - removeSolverEdge(zxeItr); + h.handleRemoveEdge(yxeId, ynId); + removeSolverEdge(yxeId); + h.handleRemoveEdge(zxeId, znId); + removeSolverEdge(zxeId); - pushToStack(xnItr); + pushToStack(xnId); s.recordR2(); } @@ -391,21 +391,21 @@ namespace PBQP { private: - NodeData& getSolverNodeData(Graph::NodeItr nItr) { - return *static_cast(g.getNodeData(nItr)); + NodeData& getSolverNodeData(Graph::NodeId nId) { + return *static_cast(g.getNodeData(nId)); } - EdgeData& getSolverEdgeData(Graph::EdgeItr eItr) { - return *static_cast(g.getEdgeData(eItr)); + EdgeData& getSolverEdgeData(Graph::EdgeId eId) { + return *static_cast(g.getEdgeData(eId)); } - void addSolverEdge(Graph::EdgeItr eItr) { - EdgeData &eData = getSolverEdgeData(eItr); - NodeData &n1Data = getSolverNodeData(g.getEdgeNode1(eItr)), - &n2Data = getSolverNodeData(g.getEdgeNode2(eItr)); + void addSolverEdge(Graph::EdgeId eId) { + EdgeData &eData = getSolverEdgeData(eId); + NodeData &n1Data = getSolverNodeData(g.getEdgeNode1(eId)), + &n2Data = getSolverNodeData(g.getEdgeNode2(eId)); - eData.setN1SolverEdgeItr(n1Data.addSolverEdge(eItr)); - eData.setN2SolverEdgeItr(n2Data.addSolverEdge(eItr)); + eData.setN1SolverEdgeItr(n1Data.addSolverEdge(eId)); + eData.setN2SolverEdgeItr(n2Data.addSolverEdge(eId)); } void setup() { @@ -417,15 +417,15 @@ namespace PBQP { for (Graph::NodeItr nItr = g.nodesBegin(), nEnd = g.nodesEnd(); nItr != nEnd; ++nItr) { nodeDataList.push_back(NodeData()); - g.setNodeData(nItr, &nodeDataList.back()); + g.setNodeData(*nItr, &nodeDataList.back()); } // Create edge data objects. for (Graph::EdgeItr eItr = g.edgesBegin(), eEnd = g.edgesEnd(); eItr != eEnd; ++eItr) { edgeDataList.push_back(EdgeData()); - g.setEdgeData(eItr, &edgeDataList.back()); - addSolverEdge(eItr); + g.setEdgeData(*eItr, &edgeDataList.back()); + addSolverEdge(*eItr); } } @@ -441,28 +441,30 @@ namespace PBQP { for (Graph::NodeItr nItr = g.nodesBegin(), nEnd = g.nodesEnd(); nItr != nEnd; ++nItr) { - if (g.getNodeCosts(nItr).getLength() == 1) { + Graph::NodeId nId = *nItr; - std::vector edgesToRemove; + if (g.getNodeCosts(nId).getLength() == 1) { - for (Graph::AdjEdgeItr aeItr = g.adjEdgesBegin(nItr), - aeEnd = g.adjEdgesEnd(nItr); + std::vector edgesToRemove; + + for (Graph::AdjEdgeItr aeItr = g.adjEdgesBegin(nId), + aeEnd = g.adjEdgesEnd(nId); aeItr != aeEnd; ++aeItr) { - Graph::EdgeItr eItr = *aeItr; + Graph::EdgeId eId = *aeItr; - if (g.getEdgeNode1(eItr) == nItr) { - Graph::NodeItr otherNodeItr = g.getEdgeNode2(eItr); - g.getNodeCosts(otherNodeItr) += - g.getEdgeCosts(eItr).getRowAsVector(0); + if (g.getEdgeNode1(eId) == nId) { + Graph::NodeId otherNodeId = g.getEdgeNode2(eId); + g.getNodeCosts(otherNodeId) += + g.getEdgeCosts(eId).getRowAsVector(0); } else { - Graph::NodeItr otherNodeItr = g.getEdgeNode1(eItr); - g.getNodeCosts(otherNodeItr) += - g.getEdgeCosts(eItr).getColAsVector(0); + Graph::NodeId otherNodeId = g.getEdgeNode1(eId); + g.getNodeCosts(otherNodeId) += + g.getEdgeCosts(eId).getColAsVector(0); } - edgesToRemove.push_back(eItr); + edgesToRemove.push_back(eId); } if (!edgesToRemove.empty()) @@ -477,12 +479,12 @@ namespace PBQP { } void eliminateIndependentEdges() { - std::vector edgesToProcess; + std::vector edgesToProcess; unsigned numEliminated = 0; for (Graph::EdgeItr eItr = g.edgesBegin(), eEnd = g.edgesEnd(); eItr != eEnd; ++eItr) { - edgesToProcess.push_back(eItr); + edgesToProcess.push_back(*eItr); } while (!edgesToProcess.empty()) { @@ -492,21 +494,21 @@ namespace PBQP { } } - bool tryToEliminateEdge(Graph::EdgeItr eItr) { - if (tryNormaliseEdgeMatrix(eItr)) { - g.removeEdge(eItr); + bool tryToEliminateEdge(Graph::EdgeId eId) { + if (tryNormaliseEdgeMatrix(eId)) { + g.removeEdge(eId); return true; } return false; } - bool tryNormaliseEdgeMatrix(Graph::EdgeItr &eItr) { + bool tryNormaliseEdgeMatrix(Graph::EdgeId &eId) { const PBQPNum infinity = std::numeric_limits::infinity(); - Matrix &edgeCosts = g.getEdgeCosts(eItr); - Vector &uCosts = g.getNodeCosts(g.getEdgeNode1(eItr)), - &vCosts = g.getNodeCosts(g.getEdgeNode2(eItr)); + Matrix &edgeCosts = g.getEdgeCosts(eId); + Vector &uCosts = g.getNodeCosts(g.getEdgeNode1(eId)), + &vCosts = g.getNodeCosts(g.getEdgeNode2(eId)); for (unsigned r = 0; r < edgeCosts.getRows(); ++r) { PBQPNum rowMin = infinity; @@ -554,34 +556,34 @@ namespace PBQP { } } - void computeSolution(Graph::NodeItr nItr) { + void computeSolution(Graph::NodeId nId) { - NodeData &nodeData = getSolverNodeData(nItr); + NodeData &nodeData = getSolverNodeData(nId); - Vector v(g.getNodeCosts(nItr)); + Vector v(g.getNodeCosts(nId)); // Solve based on existing solved edges. for (SolverEdgeItr solvedEdgeItr = nodeData.solverEdgesBegin(), solvedEdgeEnd = nodeData.solverEdgesEnd(); solvedEdgeItr != solvedEdgeEnd; ++solvedEdgeItr) { - Graph::EdgeItr eItr(*solvedEdgeItr); - Matrix &edgeCosts = g.getEdgeCosts(eItr); + Graph::EdgeId eId(*solvedEdgeItr); + Matrix &edgeCosts = g.getEdgeCosts(eId); - if (nItr == g.getEdgeNode1(eItr)) { - Graph::NodeItr adjNode(g.getEdgeNode2(eItr)); + if (nId == g.getEdgeNode1(eId)) { + Graph::NodeId adjNode(g.getEdgeNode2(eId)); unsigned adjSolution = s.getSelection(adjNode); v += edgeCosts.getColAsVector(adjSolution); } else { - Graph::NodeItr adjNode(g.getEdgeNode1(eItr)); + Graph::NodeId adjNode(g.getEdgeNode1(eId)); unsigned adjSolution = s.getSelection(adjNode); v += edgeCosts.getRowAsVector(adjSolution); } } - setSolution(nItr, v.minIndex()); + setSolution(nId, v.minIndex()); } void cleanup() { diff --git a/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h b/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h index 307d81e..9663b26 100644 --- a/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h +++ b/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h @@ -47,8 +47,8 @@ namespace PBQP { class LinkDegreeComparator { public: LinkDegreeComparator(HeuristicSolverImpl &s) : s(&s) {} - bool operator()(Graph::NodeItr n1Itr, Graph::NodeItr n2Itr) const { - if (s->getSolverDegree(n1Itr) > s->getSolverDegree(n2Itr)) + bool operator()(Graph::NodeId n1Id, Graph::NodeId n2Id) const { + if (s->getSolverDegree(n1Id) > s->getSolverDegree(n2Id)) return true; return false; } @@ -60,12 +60,12 @@ namespace PBQP { public: SpillCostComparator(HeuristicSolverImpl &s) : s(&s), g(&s.getGraph()) {} - bool operator()(Graph::NodeItr n1Itr, Graph::NodeItr n2Itr) const { - const PBQP::Vector &cv1 = g->getNodeCosts(n1Itr); - const PBQP::Vector &cv2 = g->getNodeCosts(n2Itr); + bool operator()(Graph::NodeId n1Id, Graph::NodeId n2Id) const { + const PBQP::Vector &cv1 = g->getNodeCosts(n1Id); + const PBQP::Vector &cv2 = g->getNodeCosts(n2Id); - PBQPNum cost1 = cv1[0] / s->getSolverDegree(n1Itr); - PBQPNum cost2 = cv2[0] / s->getSolverDegree(n2Itr); + PBQPNum cost1 = cv1[0] / s->getSolverDegree(n1Id); + PBQPNum cost2 = cv2[0] / s->getSolverDegree(n2Id); if (cost1 < cost2) return true; @@ -77,10 +77,10 @@ namespace PBQP { Graph *g; }; - typedef std::list RNAllocableList; + typedef std::list RNAllocableList; typedef RNAllocableList::iterator RNAllocableListItr; - typedef std::list RNUnallocableList; + typedef std::list RNUnallocableList; typedef RNUnallocableList::iterator RNUnallocableListItr; public: @@ -123,8 +123,8 @@ namespace PBQP { /// infinite are checked for allocability first. Allocable nodes may be /// optimally reduced, but nodes whose allocability cannot be proven are /// selected for heuristic reduction instead. - bool shouldOptimallyReduce(Graph::NodeItr nItr) { - if (getSolver().getSolverDegree(nItr) < 3) { + bool shouldOptimallyReduce(Graph::NodeId nId) { + if (getSolver().getSolverDegree(nId) < 3) { return true; } // else @@ -133,14 +133,14 @@ namespace PBQP { /// \brief Add a node to the heuristic reduce list. /// @param nItr Node iterator to add to the heuristic reduce list. - void addToHeuristicReduceList(Graph::NodeItr nItr) { - NodeData &nd = getHeuristicNodeData(nItr); - initializeNode(nItr); + void addToHeuristicReduceList(Graph::NodeId nId) { + NodeData &nd = getHeuristicNodeData(nId); + initializeNode(nId); nd.isHeuristic = true; if (nd.isAllocable) { - nd.rnaItr = rnAllocableList.insert(rnAllocableList.end(), nItr); + nd.rnaItr = rnAllocableList.insert(rnAllocableList.end(), nId); } else { - nd.rnuItr = rnUnallocableList.insert(rnUnallocableList.end(), nItr); + nd.rnuItr = rnUnallocableList.insert(rnUnallocableList.end(), nId); } } @@ -159,19 +159,19 @@ namespace PBQP { RNAllocableListItr rnaItr = min_element(rnAllocableList.begin(), rnAllocableList.end(), LinkDegreeComparator(getSolver())); - Graph::NodeItr nItr = *rnaItr; + Graph::NodeId nId = *rnaItr; rnAllocableList.erase(rnaItr); - handleRemoveNode(nItr); - getSolver().pushToStack(nItr); + handleRemoveNode(nId); + getSolver().pushToStack(nId); return true; } else if (!rnUnallocableList.empty()) { RNUnallocableListItr rnuItr = min_element(rnUnallocableList.begin(), rnUnallocableList.end(), SpillCostComparator(getSolver())); - Graph::NodeItr nItr = *rnuItr; + Graph::NodeId nId = *rnuItr; rnUnallocableList.erase(rnuItr); - handleRemoveNode(nItr); - getSolver().pushToStack(nItr); + handleRemoveNode(nId); + getSolver().pushToStack(nId); return true; } // else @@ -180,28 +180,28 @@ namespace PBQP { /// \brief Prepare a change in the costs on the given edge. /// @param eItr Edge iterator. - void preUpdateEdgeCosts(Graph::EdgeItr eItr) { + void preUpdateEdgeCosts(Graph::EdgeId eId) { Graph &g = getGraph(); - Graph::NodeItr n1Itr = g.getEdgeNode1(eItr), - n2Itr = g.getEdgeNode2(eItr); - NodeData &n1 = getHeuristicNodeData(n1Itr), - &n2 = getHeuristicNodeData(n2Itr); + Graph::NodeId n1Id = g.getEdgeNode1(eId), + n2Id = g.getEdgeNode2(eId); + NodeData &n1 = getHeuristicNodeData(n1Id), + &n2 = getHeuristicNodeData(n2Id); if (n1.isHeuristic) - subtractEdgeContributions(eItr, getGraph().getEdgeNode1(eItr)); + subtractEdgeContributions(eId, getGraph().getEdgeNode1(eId)); if (n2.isHeuristic) - subtractEdgeContributions(eItr, getGraph().getEdgeNode2(eItr)); + subtractEdgeContributions(eId, getGraph().getEdgeNode2(eId)); - EdgeData &ed = getHeuristicEdgeData(eItr); + EdgeData &ed = getHeuristicEdgeData(eId); ed.isUpToDate = false; } /// \brief Handle the change in the costs on the given edge. /// @param eItr Edge iterator. - void postUpdateEdgeCosts(Graph::EdgeItr eItr) { + void postUpdateEdgeCosts(Graph::EdgeId eId) { // This is effectively the same as adding a new edge now, since // we've factored out the costs of the old one. - handleAddEdge(eItr); + handleAddEdge(eId); } /// \brief Handle the addition of a new edge into the PBQP graph. @@ -210,12 +210,12 @@ namespace PBQP { /// Updates allocability of any nodes connected by this edge which are /// being managed by the heuristic. If allocability changes they are /// moved to the appropriate list. - void handleAddEdge(Graph::EdgeItr eItr) { + void handleAddEdge(Graph::EdgeId eId) { Graph &g = getGraph(); - Graph::NodeItr n1Itr = g.getEdgeNode1(eItr), - n2Itr = g.getEdgeNode2(eItr); - NodeData &n1 = getHeuristicNodeData(n1Itr), - &n2 = getHeuristicNodeData(n2Itr); + Graph::NodeId n1Id = g.getEdgeNode1(eId), + n2Id = g.getEdgeNode2(eId); + NodeData &n1 = getHeuristicNodeData(n1Id), + &n2 = getHeuristicNodeData(n2Id); // If neither node is managed by the heuristic there's nothing to be // done. @@ -223,29 +223,29 @@ namespace PBQP { return; // Ok - we need to update at least one node. - computeEdgeContributions(eItr); + computeEdgeContributions(eId); // Update node 1 if it's managed by the heuristic. if (n1.isHeuristic) { bool n1WasAllocable = n1.isAllocable; - addEdgeContributions(eItr, n1Itr); - updateAllocability(n1Itr); + addEdgeContributions(eId, n1Id); + updateAllocability(n1Id); if (n1WasAllocable && !n1.isAllocable) { rnAllocableList.erase(n1.rnaItr); n1.rnuItr = - rnUnallocableList.insert(rnUnallocableList.end(), n1Itr); + rnUnallocableList.insert(rnUnallocableList.end(), n1Id); } } // Likewise for node 2. if (n2.isHeuristic) { bool n2WasAllocable = n2.isAllocable; - addEdgeContributions(eItr, n2Itr); - updateAllocability(n2Itr); + addEdgeContributions(eId, n2Id); + updateAllocability(n2Id); if (n2WasAllocable && !n2.isAllocable) { rnAllocableList.erase(n2.rnaItr); n2.rnuItr = - rnUnallocableList.insert(rnUnallocableList.end(), n2Itr); + rnUnallocableList.insert(rnUnallocableList.end(), n2Id); } } } @@ -256,27 +256,27 @@ namespace PBQP { /// /// Updates allocability of the given node and, if appropriate, moves the /// node to a new list. - void handleRemoveEdge(Graph::EdgeItr eItr, Graph::NodeItr nItr) { - NodeData &nd = getHeuristicNodeData(nItr); + void handleRemoveEdge(Graph::EdgeId eId, Graph::NodeId nId) { + NodeData &nd =getHeuristicNodeData(nId); // If the node is not managed by the heuristic there's nothing to be // done. if (!nd.isHeuristic) return; - EdgeData &ed = getHeuristicEdgeData(eItr); + EdgeData &ed = getHeuristicEdgeData(eId); (void)ed; assert(ed.isUpToDate && "Edge data is not up to date."); // Update node. bool ndWasAllocable = nd.isAllocable; - subtractEdgeContributions(eItr, nItr); - updateAllocability(nItr); + subtractEdgeContributions(eId, nId); + updateAllocability(nId); // If the node has gone optimal... - if (shouldOptimallyReduce(nItr)) { + if (shouldOptimallyReduce(nId)) { nd.isHeuristic = false; - addToOptimalReduceList(nItr); + addToOptimalReduceList(nId); if (ndWasAllocable) { rnAllocableList.erase(nd.rnaItr); } else { @@ -287,30 +287,30 @@ namespace PBQP { // from "unallocable" to "allocable". if (!ndWasAllocable && nd.isAllocable) { rnUnallocableList.erase(nd.rnuItr); - nd.rnaItr = rnAllocableList.insert(rnAllocableList.end(), nItr); + nd.rnaItr = rnAllocableList.insert(rnAllocableList.end(), nId); } } } private: - NodeData& getHeuristicNodeData(Graph::NodeItr nItr) { - return getSolver().getHeuristicNodeData(nItr); + NodeData& getHeuristicNodeData(Graph::NodeId nId) { + return getSolver().getHeuristicNodeData(nId); } - EdgeData& getHeuristicEdgeData(Graph::EdgeItr eItr) { - return getSolver().getHeuristicEdgeData(eItr); + EdgeData& getHeuristicEdgeData(Graph::EdgeId eId) { + return getSolver().getHeuristicEdgeData(eId); } // Work out what this edge will contribute to the allocability of the // nodes connected to it. - void computeEdgeContributions(Graph::EdgeItr eItr) { - EdgeData &ed = getHeuristicEdgeData(eItr); + void computeEdgeContributions(Graph::EdgeId eId) { + EdgeData &ed = getHeuristicEdgeData(eId); if (ed.isUpToDate) return; // Edge data is already up to date. - Matrix &eCosts = getGraph().getEdgeCosts(eItr); + Matrix &eCosts = getGraph().getEdgeCosts(eId); unsigned numRegs = eCosts.getRows() - 1, numReverseRegs = eCosts.getCols() - 1; @@ -352,15 +352,15 @@ namespace PBQP { // numDenied and safe members. No action is taken other than to update // these member values. Once updated these numbers can be used by clients // to update the node's allocability. - void addEdgeContributions(Graph::EdgeItr eItr, Graph::NodeItr nItr) { - EdgeData &ed = getHeuristicEdgeData(eItr); + void addEdgeContributions(Graph::EdgeId eId, Graph::NodeId nId) { + EdgeData &ed = getHeuristicEdgeData(eId); assert(ed.isUpToDate && "Using out-of-date edge numbers."); - NodeData &nd = getHeuristicNodeData(nItr); - unsigned numRegs = getGraph().getNodeCosts(nItr).getLength() - 1; + NodeData &nd = getHeuristicNodeData(nId); + unsigned numRegs = getGraph().getNodeCosts(nId).getLength() - 1; - bool nIsNode1 = nItr == getGraph().getEdgeNode1(eItr); + bool nIsNode1 = nId == getGraph().getEdgeNode1(eId); EdgeData::UnsafeArray &unsafe = nIsNode1 ? ed.unsafe : ed.reverseUnsafe; nd.numDenied += nIsNode1 ? ed.worst : ed.reverseWorst; @@ -379,15 +379,15 @@ namespace PBQP { // numDenied and safe members. No action is taken other than to update // these member values. Once updated these numbers can be used by clients // to update the node's allocability. - void subtractEdgeContributions(Graph::EdgeItr eItr, Graph::NodeItr nItr) { - EdgeData &ed = getHeuristicEdgeData(eItr); + void subtractEdgeContributions(Graph::EdgeId eId, Graph::NodeId nId) { + EdgeData &ed = getHeuristicEdgeData(eId); assert(ed.isUpToDate && "Using out-of-date edge numbers."); - NodeData &nd = getHeuristicNodeData(nItr); - unsigned numRegs = getGraph().getNodeCosts(nItr).getLength() - 1; + NodeData &nd = getHeuristicNodeData(nId); + unsigned numRegs = getGraph().getNodeCosts(nId).getLength() - 1; - bool nIsNode1 = nItr == getGraph().getEdgeNode1(eItr); + bool nIsNode1 = nId == getGraph().getEdgeNode1(eId); EdgeData::UnsafeArray &unsafe = nIsNode1 ? ed.unsafe : ed.reverseUnsafe; nd.numDenied -= nIsNode1 ? ed.worst : ed.reverseWorst; @@ -402,22 +402,22 @@ namespace PBQP { } } - void updateAllocability(Graph::NodeItr nItr) { - NodeData &nd = getHeuristicNodeData(nItr); - unsigned numRegs = getGraph().getNodeCosts(nItr).getLength() - 1; + void updateAllocability(Graph::NodeId nId) { + NodeData &nd = getHeuristicNodeData(nId); + unsigned numRegs = getGraph().getNodeCosts(nId).getLength() - 1; nd.isAllocable = nd.numDenied < numRegs || nd.numSafe > 0; } - void initializeNode(Graph::NodeItr nItr) { - NodeData &nd = getHeuristicNodeData(nItr); + void initializeNode(Graph::NodeId nId) { + NodeData &nd = getHeuristicNodeData(nId); if (nd.isInitialized) return; // Node data is already up to date. - unsigned numRegs = getGraph().getNodeCosts(nItr).getLength() - 1; + unsigned numRegs = getGraph().getNodeCosts(nId).getLength() - 1; nd.numDenied = 0; - const Vector& nCosts = getGraph().getNodeCosts(nItr); + const Vector& nCosts = getGraph().getNodeCosts(nId); for (unsigned i = 1; i < nCosts.getLength(); ++i) { if (nCosts[i] == std::numeric_limits::infinity()) ++nd.numDenied; @@ -428,27 +428,27 @@ namespace PBQP { typedef HeuristicSolverImpl::SolverEdgeItr SolverEdgeItr; - for (SolverEdgeItr aeItr = getSolver().solverEdgesBegin(nItr), - aeEnd = getSolver().solverEdgesEnd(nItr); + for (SolverEdgeItr aeItr = getSolver().solverEdgesBegin(nId), + aeEnd = getSolver().solverEdgesEnd(nId); aeItr != aeEnd; ++aeItr) { - Graph::EdgeItr eItr = *aeItr; - computeEdgeContributions(eItr); - addEdgeContributions(eItr, nItr); + Graph::EdgeId eId = *aeItr; + computeEdgeContributions(eId); + addEdgeContributions(eId, nId); } - updateAllocability(nItr); + updateAllocability(nId); nd.isInitialized = true; } - void handleRemoveNode(Graph::NodeItr xnItr) { + void handleRemoveNode(Graph::NodeId xnId) { typedef HeuristicSolverImpl::SolverEdgeItr SolverEdgeItr; - std::vector edgesToRemove; - for (SolverEdgeItr aeItr = getSolver().solverEdgesBegin(xnItr), - aeEnd = getSolver().solverEdgesEnd(xnItr); + std::vector edgesToRemove; + for (SolverEdgeItr aeItr = getSolver().solverEdgesBegin(xnId), + aeEnd = getSolver().solverEdgesEnd(xnId); aeItr != aeEnd; ++aeItr) { - Graph::NodeItr ynItr = getGraph().getEdgeOtherNode(*aeItr, xnItr); - handleRemoveEdge(*aeItr, ynItr); + Graph::NodeId ynId = getGraph().getEdgeOtherNode(*aeItr, xnId); + handleRemoveEdge(*aeItr, ynId); edgesToRemove.push_back(*aeItr); } while (!edgesToRemove.empty()) { diff --git a/include/llvm/CodeGen/PBQP/Solution.h b/include/llvm/CodeGen/PBQP/Solution.h index b9f288b..98ba5a1 100644 --- a/include/llvm/CodeGen/PBQP/Solution.h +++ b/include/llvm/CodeGen/PBQP/Solution.h @@ -26,8 +26,7 @@ namespace PBQP { class Solution { private: - typedef std::map SelectionsMap; + typedef std::map SelectionsMap; SelectionsMap selections; unsigned r0Reductions, r1Reductions, r2Reductions, rNReductions; @@ -73,15 +72,15 @@ namespace PBQP { /// \brief Set the selection for a given node. /// @param nItr Node iterator. /// @param selection Selection for nItr. - void setSelection(Graph::NodeItr nItr, unsigned selection) { - selections[nItr] = selection; + void setSelection(Graph::NodeId nodeId, unsigned selection) { + selections[nodeId] = selection; } /// \brief Get a node's selection. /// @param nItr Node iterator. /// @return The selection for nItr; - unsigned getSelection(Graph::ConstNodeItr nItr) const { - SelectionsMap::const_iterator sItr = selections.find(nItr); + unsigned getSelection(Graph::NodeId nodeId) const { + SelectionsMap::const_iterator sItr = selections.find(nodeId); assert(sItr != selections.end() && "No selection for node."); return sItr->second; } diff --git a/include/llvm/CodeGen/RegAllocPBQP.h b/include/llvm/CodeGen/RegAllocPBQP.h index 6f2d139..7472e5a 100644 --- a/include/llvm/CodeGen/RegAllocPBQP.h +++ b/include/llvm/CodeGen/RegAllocPBQP.h @@ -52,22 +52,22 @@ namespace llvm { /// PBQPBuilder you are unlikely to need this: Nodes and options for all /// vregs will already have been set up for you by the base class. template - void recordVReg(unsigned vreg, PBQP::Graph::NodeItr node, + void recordVReg(unsigned vreg, PBQP::Graph::NodeId nodeId, AllowedRegsItr arBegin, AllowedRegsItr arEnd) { - assert(node2VReg.find(node) == node2VReg.end() && "Re-mapping node."); + assert(node2VReg.find(nodeId) == node2VReg.end() && "Re-mapping node."); assert(vreg2Node.find(vreg) == vreg2Node.end() && "Re-mapping vreg."); assert(allowedSets[vreg].empty() && "vreg already has pregs."); - node2VReg[node] = vreg; - vreg2Node[vreg] = node; + node2VReg[nodeId] = vreg; + vreg2Node[vreg] = nodeId; std::copy(arBegin, arEnd, std::back_inserter(allowedSets[vreg])); } /// Get the virtual register corresponding to the given PBQP node. - unsigned getVRegForNode(PBQP::Graph::ConstNodeItr node) const; + unsigned getVRegForNode(PBQP::Graph::NodeId nodeId) const; /// Get the PBQP node corresponding to the given virtual register. - PBQP::Graph::NodeItr getNodeForVReg(unsigned vreg) const; + PBQP::Graph::NodeId getNodeForVReg(unsigned vreg) const; /// Returns true if the given PBQP option represents a physical register, /// false otherwise. @@ -92,9 +92,8 @@ namespace llvm { private: - typedef std::map Node2VReg; - typedef DenseMap VReg2Node; + typedef std::map Node2VReg; + typedef DenseMap VReg2Node; typedef DenseMap AllowedSetMap; PBQP::Graph graph; -- cgit v1.1 From 91935b8d4c027b6a1b884a433c9a20404cf05516 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Sat, 9 Nov 2013 03:53:55 +0000 Subject: Fix whitespace. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194313 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/PBQP/Graph.h | 22 +++++++++++----------- include/llvm/CodeGen/PBQP/HeuristicBase.h | 10 +++++----- include/llvm/CodeGen/PBQP/HeuristicSolver.h | 26 +++++++++++++------------- include/llvm/CodeGen/PBQP/Heuristics/Briggs.h | 24 ++++++++++++------------ 4 files changed, 41 insertions(+), 41 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/PBQP/Graph.h b/include/llvm/CodeGen/PBQP/Graph.h index f83190e..d016a3e 100644 --- a/include/llvm/CodeGen/PBQP/Graph.h +++ b/include/llvm/CodeGen/PBQP/Graph.h @@ -44,7 +44,7 @@ namespace PBQP { class NodeEntry { private: - Vector costs; + Vector costs; AdjEdgeList adjEdges; void *data; NodeEntry() : costs(0, 0) {} @@ -222,7 +222,7 @@ namespace PBQP { assert(getNodeCosts(n1Id).getLength() == costs.getRows() && getNodeCosts(n2Id).getLength() == costs.getCols() && "Matrix dimensions mismatch."); - return addConstructedEdge(EdgeEntry(n1Id, n2Id, costs)); + return addConstructedEdge(EdgeEntry(n1Id, n2Id, costs)); } /// \brief Get the number of nodes in the graph. @@ -256,7 +256,7 @@ namespace PBQP { /// @param nItr Node iterator. /// @return Pointer to node data. void* getNodeData(NodeId nId) { return getNode(nId).getData(); } - + /// \brief Get an edge's cost matrix. /// @param eItr Edge iterator. /// @return Edge cost matrix. @@ -278,7 +278,7 @@ namespace PBQP { /// \brief Get an edge's data pointer. /// @param eItr Edge iterator. - /// @return Pointer to edge data. + /// @return Pointer to edge data. void* getEdgeData(EdgeId eId) { return getEdge(eId).getData(); } /// \brief Get a node's degree. @@ -316,22 +316,22 @@ namespace PBQP { /// \brief Get the first node connected to this edge. /// @param eItr Edge iterator. - /// @return The first node connected to the given edge. + /// @return The first node connected to the given edge. NodeId getEdgeNode1(EdgeId eId) { return getEdge(eId).getNode1(); } /// \brief Get the second node connected to this edge. /// @param eItr Edge iterator. - /// @return The second node connected to the given edge. + /// @return The second node connected to the given edge. NodeId getEdgeNode2(EdgeId eId) { return getEdge(eId).getNode2(); - } + } /// \brief Get the "other" node connected to this edge. /// @param eItr Edge iterator. /// @param nItr Node iterator for the "given" node. - /// @return The iterator for the "other" node connected to this edge. + /// @return The iterator for the "other" node connected to this edge. NodeId getEdgeOtherNode(EdgeId eId, NodeId nId) { EdgeEntry &e = getEdge(eId); if (e.getNode1() == nId) { @@ -366,7 +366,7 @@ namespace PBQP { NodeEntry &n = getNode(nId); for (AdjEdgeItr itr = n.edgesBegin(), end = n.edgesEnd(); itr != end; ++itr) { EdgeId eId = *itr; - removeEdge(eId); + removeEdge(eId); } freeNodes.push_back(nId); } @@ -431,7 +431,7 @@ namespace PBQP { /// @param os Output stream to print on. template void printDot(OStream &os) { - + os << "graph {\n"; for (NodeItr nodeItr = nodesBegin(), nodeEnd = nodesEnd(); @@ -470,7 +470,7 @@ namespace PBQP { // nEnd = other.nodesEnd(); // nItr != nEnd; ++nItr) { // nodeMap[nItr] = addNode(other.getNodeCosts(nItr)); -// } +// } // } } diff --git a/include/llvm/CodeGen/PBQP/HeuristicBase.h b/include/llvm/CodeGen/PBQP/HeuristicBase.h index 36d94d6..650136f 100644 --- a/include/llvm/CodeGen/PBQP/HeuristicBase.h +++ b/include/llvm/CodeGen/PBQP/HeuristicBase.h @@ -27,7 +27,7 @@ namespace PBQP { ///
  • void heuristicReduce() : Perform a single heuristic reduction. ///
  • void preUpdateEdgeCosts(Graph::EdgeItr) : Handle the (imminent) /// change to the cost matrix on the given edge (by R2). - ///
  • void postUpdateEdgeCostts(Graph::EdgeItr) : Handle the new + ///
  • void postUpdateEdgeCostts(Graph::EdgeItr) : Handle the new /// costs on the given edge. ///
  • void handleAddEdge(Graph::EdgeItr) : Handle the addition of a new /// edge into the PBQP graph (by R2). @@ -39,7 +39,7 @@ namespace PBQP { /// /// These methods are implemented in this class for documentation purposes, /// but will assert if called. - /// + /// /// Note that this class uses the curiously recursive template idiom to /// forward calls to the derived class. These methods need not be made /// virtual, and indeed probably shouldn't for performance reasons. @@ -62,7 +62,7 @@ namespace PBQP { HImpl& impl() { return static_cast(*this); } // Add the given node to the optimal reductions list. Keep an iterator to - // its location for fast removal. + // its location for fast removal. void addToOptimalReductionList(Graph::NodeId nId) { optimalList.insert(optimalList.end(), nId); } @@ -94,7 +94,7 @@ namespace PBQP { /// behaviour. bool solverRunSimplify() const { return true; } - /// \brief Decide whether a node should be optimally or heuristically + /// \brief Decide whether a node should be optimally or heuristically /// reduced. /// @return Whether or not the given node should be listed for optimal /// reduction (via R0, R1 or R2). @@ -199,7 +199,7 @@ namespace PBQP { } /// \brief Prepare a change in the costs on the given edge. - /// @param eItr Edge iterator. + /// @param eItr Edge iterator. void preUpdateEdgeCosts(Graph::EdgeId eId) { llvm_unreachable("Must be implemented in derived class."); } diff --git a/include/llvm/CodeGen/PBQP/HeuristicSolver.h b/include/llvm/CodeGen/PBQP/HeuristicSolver.h index 7fa6386..3e707f1 100644 --- a/include/llvm/CodeGen/PBQP/HeuristicSolver.h +++ b/include/llvm/CodeGen/PBQP/HeuristicSolver.h @@ -9,7 +9,7 @@ // // Heuristic PBQP solver. This solver is able to perform optimal reductions for // nodes of degree 0, 1 or 2. For nodes of degree >2 a plugable heuristic is -// used to select a node for reduction. +// used to select a node for reduction. // //===----------------------------------------------------------------------===// @@ -43,7 +43,7 @@ namespace PBQP { typedef std::list SolverEdges; public: - + /// \brief Iterator type for edges in the solver graph. typedef SolverEdges::iterator SolverEdgeItr; @@ -70,15 +70,15 @@ namespace PBQP { unsigned getSolverDegree() const { return solverDegree; } void clearSolverEdges() { solverDegree = 0; - solverEdges.clear(); + solverEdges.clear(); } - + private: HeuristicNodeData hData; unsigned solverDegree; SolverEdges solverEdges; }; - + class EdgeData { public: HeuristicEdgeData& getHeuristicData() { return hData; } @@ -117,7 +117,7 @@ namespace PBQP { /// \brief Construct a heuristic solver implementation to solve the given /// graph. /// @param g The graph representing the problem instance to be solved. - HeuristicSolverImpl(Graph &g) : g(g), h(*this) {} + HeuristicSolverImpl(Graph &g) : g(g), h(*this) {} /// \brief Get the graph being solved by this solver. /// @return The graph representing the problem instance being solved by this @@ -142,7 +142,7 @@ namespace PBQP { /// the solver graph. /// @param nItr Node iterator. /// @return Begin iterator for the set of edges adjacent to the given node - /// in the solver graph. + /// in the solver graph. SolverEdgeItr solverEdgesBegin(Graph::NodeId nId) { return getSolverNodeData(nId).solverEdgesBegin(); } @@ -151,7 +151,7 @@ namespace PBQP { /// the solver graph. /// @param nItr Node iterator. /// @return End iterator for the set of edges adjacent to the given node in - /// the solver graph. + /// the solver graph. SolverEdgeItr solverEdgesEnd(Graph::NodeId nId) { return getSolverNodeData(nId).solverEdgesEnd(); } @@ -243,7 +243,7 @@ namespace PBQP { const Matrix &eCosts = g.getEdgeCosts(eId); const Vector &xCosts = g.getNodeCosts(xnId); - + // Duplicate a little to avoid transposing matrices. if (xnId == g.getEdgeNode1(eId)) { Graph::NodeId ynId = g.getEdgeNode2(eId); @@ -311,7 +311,7 @@ namespace PBQP { unsigned xLen = xCosts.getLength(), yLen = yxeCosts->getRows(), zLen = zxeCosts->getRows(); - + Matrix delta(yLen, zLen); for (unsigned i = 0; i < yLen; ++i) { @@ -355,7 +355,7 @@ namespace PBQP { // If we modified the edge costs let the heuristic know. h.postUpdateEdgeCosts(yzeId); } - + if (nullCostEdge) { // If this edge ended up null remove it. if (!addedEdge) { @@ -387,7 +387,7 @@ namespace PBQP { /// \brief Record an application of the RN rule. /// /// For use by the HeuristicBase. - void recordRN() { s.recordRN(); } + void recordRN() { s.recordRN(); } private: @@ -497,7 +497,7 @@ namespace PBQP { bool tryToEliminateEdge(Graph::EdgeId eId) { if (tryNormaliseEdgeMatrix(eId)) { g.removeEdge(eId); - return true; + return true; } return false; } diff --git a/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h b/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h index 9663b26..9e1d999 100644 --- a/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h +++ b/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h @@ -27,7 +27,7 @@ namespace PBQP { /// \brief PBQP Heuristic which applies an allocability test based on /// Briggs. - /// + /// /// This heuristic assumes that the elements of cost vectors in the PBQP /// problem represent storage options, with the first being the spill /// option and subsequent elements representing legal registers for the @@ -39,8 +39,8 @@ namespace PBQP { /// solver stack. If no nodes can be proven allocable then the node with /// the lowest estimated spill cost is selected and push to the solver stack /// instead. - /// - /// This implementation is built on top of HeuristicBase. + /// + /// This implementation is built on top of HeuristicBase. class Briggs : public HeuristicBase { private: @@ -80,7 +80,7 @@ namespace PBQP { typedef std::list RNAllocableList; typedef RNAllocableList::iterator RNAllocableListItr; - typedef std::list RNUnallocableList; + typedef std::list RNUnallocableList; typedef RNUnallocableList::iterator RNUnallocableListItr; public: @@ -179,7 +179,7 @@ namespace PBQP { } /// \brief Prepare a change in the costs on the given edge. - /// @param eItr Edge iterator. + /// @param eItr Edge iterator. void preUpdateEdgeCosts(Graph::EdgeId eId) { Graph &g = getGraph(); Graph::NodeId n1Id = g.getEdgeNode1(eId), @@ -316,7 +316,7 @@ namespace PBQP { numReverseRegs = eCosts.getCols() - 1; std::vector rowInfCounts(numRegs, 0), - colInfCounts(numReverseRegs, 0); + colInfCounts(numReverseRegs, 0); ed.worst = 0; ed.reverseWorst = 0; @@ -348,7 +348,7 @@ namespace PBQP { ed.isUpToDate = true; } - // Add the contributions of the given edge to the given node's + // Add the contributions of the given edge to the given node's // numDenied and safe members. No action is taken other than to update // these member values. Once updated these numbers can be used by clients // to update the node's allocability. @@ -359,7 +359,7 @@ namespace PBQP { NodeData &nd = getHeuristicNodeData(nId); unsigned numRegs = getGraph().getNodeCosts(nId).getLength() - 1; - + bool nIsNode1 = nId == getGraph().getEdgeNode1(eId); EdgeData::UnsafeArray &unsafe = nIsNode1 ? ed.unsafe : ed.reverseUnsafe; @@ -375,7 +375,7 @@ namespace PBQP { } } - // Subtract the contributions of the given edge to the given node's + // Subtract the contributions of the given edge to the given node's // numDenied and safe members. No action is taken other than to update // these member values. Once updated these numbers can be used by clients // to update the node's allocability. @@ -386,14 +386,14 @@ namespace PBQP { NodeData &nd = getHeuristicNodeData(nId); unsigned numRegs = getGraph().getNodeCosts(nId).getLength() - 1; - + bool nIsNode1 = nId == getGraph().getEdgeNode1(eId); EdgeData::UnsafeArray &unsafe = nIsNode1 ? ed.unsafe : ed.reverseUnsafe; nd.numDenied -= nIsNode1 ? ed.worst : ed.reverseWorst; for (unsigned r = 0; r < numRegs; ++r) { - if (unsafe[r]) { + if (unsafe[r]) { if (nd.unsafeDegrees[r] == 1) { ++nd.numSafe; } @@ -431,7 +431,7 @@ namespace PBQP { for (SolverEdgeItr aeItr = getSolver().solverEdgesBegin(nId), aeEnd = getSolver().solverEdgesEnd(nId); aeItr != aeEnd; ++aeItr) { - + Graph::EdgeId eId = *aeItr; computeEdgeContributions(eId); addEdgeContributions(eId, nId); -- cgit v1.1 From 332cbf1d4503fcad3b5f3bf6ff73889feff03ad7 Mon Sep 17 00:00:00 2001 From: NAKAMURA Takumi Date: Sat, 9 Nov 2013 03:54:05 +0000 Subject: include/llvm/CodeGen/PBQP: Update @param(s) in comments. [-Wdocumentation] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194314 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/PBQP/Graph.h | 38 +++++++++++++-------------- include/llvm/CodeGen/PBQP/HeuristicBase.h | 14 +++++----- include/llvm/CodeGen/PBQP/HeuristicSolver.h | 22 ++++++++-------- include/llvm/CodeGen/PBQP/Heuristics/Briggs.h | 14 +++++----- include/llvm/CodeGen/PBQP/Solution.h | 8 +++--- 5 files changed, 48 insertions(+), 48 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/PBQP/Graph.h b/include/llvm/CodeGen/PBQP/Graph.h index d016a3e..aca0a91 100644 --- a/include/llvm/CodeGen/PBQP/Graph.h +++ b/include/llvm/CodeGen/PBQP/Graph.h @@ -215,8 +215,8 @@ namespace PBQP { } /// \brief Add an edge between the given nodes with the given costs. - /// @param n1Itr First node. - /// @param n2Itr Second node. + /// @param n1Id First node. + /// @param n2Id Second node. /// @return Edge iterator for the added edge. EdgeId addEdge(NodeId n1Id, NodeId n2Id, const Matrix &costs) { assert(getNodeCosts(n1Id).getLength() == costs.getRows() && @@ -234,55 +234,55 @@ namespace PBQP { unsigned getNumEdges() const { return edges.size() - freeEdges.size(); } /// \brief Get a node's cost vector. - /// @param nItr Node iterator. + /// @param nId Node id. /// @return Node cost vector. Vector& getNodeCosts(NodeId nId) { return getNode(nId).getCosts(); } /// \brief Get a node's cost vector (const version). - /// @param nItr Node iterator. + /// @param nId Node id. /// @return Node cost vector. const Vector& getNodeCosts(NodeId nId) const { return getNode(nId).getCosts(); } /// \brief Set a node's data pointer. - /// @param nItr Node iterator. + /// @param nId Node id. /// @param data Pointer to node data. /// /// Typically used by a PBQP solver to attach data to aid in solution. void setNodeData(NodeId nId, void *data) { getNode(nId).setData(data); } /// \brief Get the node's data pointer. - /// @param nItr Node iterator. + /// @param nId Node id. /// @return Pointer to node data. void* getNodeData(NodeId nId) { return getNode(nId).getData(); } /// \brief Get an edge's cost matrix. - /// @param eItr Edge iterator. + /// @param eId Edge id. /// @return Edge cost matrix. Matrix& getEdgeCosts(EdgeId eId) { return getEdge(eId).getCosts(); } /// \brief Get an edge's cost matrix (const version). - /// @param eItr Edge iterator. + /// @param eId Edge id. /// @return Edge cost matrix. const Matrix& getEdgeCosts(EdgeId eId) const { return getEdge(eId).getCosts(); } /// \brief Set an edge's data pointer. - /// @param eItr Edge iterator. + /// @param eId Edge id. /// @param data Pointer to edge data. /// /// Typically used by a PBQP solver to attach data to aid in solution. void setEdgeData(EdgeId eId, void *data) { getEdge(eId).setData(data); } /// \brief Get an edge's data pointer. - /// @param eItr Edge iterator. + /// @param eId Edge id. /// @return Pointer to edge data. void* getEdgeData(EdgeId eId) { return getEdge(eId).getData(); } /// \brief Get a node's degree. - /// @param nItr Node iterator. + /// @param nId Node id. /// @return The degree of the node. unsigned getNodeDegree(NodeId nId) const { return getNode(nId).getDegree(); @@ -301,36 +301,36 @@ namespace PBQP { EdgeItr edgesEnd() const { return EdgeItr(edges.size(), *this); } /// \brief Get begin iterator for adjacent edge set. - /// @param nItr Node iterator. + /// @param nId Node id. /// @return Begin iterator for the set of edges connected to the given node. AdjEdgeItr adjEdgesBegin(NodeId nId) { return getNode(nId).edgesBegin(); } /// \brief Get end iterator for adjacent edge set. - /// @param nItr Node iterator. + /// @param nId Node id. /// @return End iterator for the set of edges connected to the given node. AdjEdgeItr adjEdgesEnd(NodeId nId) { return getNode(nId).edgesEnd(); } /// \brief Get the first node connected to this edge. - /// @param eItr Edge iterator. + /// @param eId Edge id. /// @return The first node connected to the given edge. NodeId getEdgeNode1(EdgeId eId) { return getEdge(eId).getNode1(); } /// \brief Get the second node connected to this edge. - /// @param eItr Edge iterator. + /// @param eId Edge id. /// @return The second node connected to the given edge. NodeId getEdgeNode2(EdgeId eId) { return getEdge(eId).getNode2(); } /// \brief Get the "other" node connected to this edge. - /// @param eItr Edge iterator. - /// @param nItr Node iterator for the "given" node. + /// @param eId Edge id. + /// @param nId Node id for the "given" node. /// @return The iterator for the "other" node connected to this edge. NodeId getEdgeOtherNode(EdgeId eId, NodeId nId) { EdgeEntry &e = getEdge(eId); @@ -361,7 +361,7 @@ namespace PBQP { } /// \brief Remove a node from the graph. - /// @param nItr Node id. + /// @param nId Node id. void removeNode(NodeId nId) { NodeEntry &n = getNode(nId); for (AdjEdgeItr itr = n.edgesBegin(), end = n.edgesEnd(); itr != end; ++itr) { @@ -372,7 +372,7 @@ namespace PBQP { } /// \brief Remove an edge from the graph. - /// @param eItr Edge iterator. + /// @param eId Edge id. void removeEdge(EdgeId eId) { EdgeEntry &e = getEdge(eId); NodeEntry &n1 = getNode(e.getNode1()); diff --git a/include/llvm/CodeGen/PBQP/HeuristicBase.h b/include/llvm/CodeGen/PBQP/HeuristicBase.h index 650136f..8bcbb9e 100644 --- a/include/llvm/CodeGen/PBQP/HeuristicBase.h +++ b/include/llvm/CodeGen/PBQP/HeuristicBase.h @@ -113,7 +113,7 @@ namespace PBQP { } /// \brief Add the given node to the list of nodes to be optimally reduced. - /// @param nItr Node iterator to be added. + /// @param nId Node id to be added. /// /// You probably don't want to over-ride this, except perhaps to record /// statistics before calling this implementation. HeuristicBase relies on @@ -184,7 +184,7 @@ namespace PBQP { } /// \brief Add a node to the heuristic reduce list. - /// @param nItr Node iterator to add to the heuristic reduce list. + /// @param nId Node id to add to the heuristic reduce list. void addToHeuristicList(Graph::NodeId nId) { llvm_unreachable("Must be implemented in derived class."); } @@ -199,26 +199,26 @@ namespace PBQP { } /// \brief Prepare a change in the costs on the given edge. - /// @param eItr Edge iterator. + /// @param eId Edge id. void preUpdateEdgeCosts(Graph::EdgeId eId) { llvm_unreachable("Must be implemented in derived class."); } /// \brief Handle the change in the costs on the given edge. - /// @param eItr Edge iterator. + /// @param eId Edge id. void postUpdateEdgeCostts(Graph::EdgeId eId) { llvm_unreachable("Must be implemented in derived class."); } /// \brief Handle the addition of a new edge into the PBQP graph. - /// @param eItr Edge iterator for the added edge. + /// @param eId Edge id for the added edge. void handleAddEdge(Graph::EdgeId eId) { llvm_unreachable("Must be implemented in derived class."); } /// \brief Handle disconnection of an edge from a node. - /// @param eItr Edge iterator for edge being disconnected. - /// @param nItr Node iterator for the node being disconnected from. + /// @param eId Edge id for edge being disconnected. + /// @param nId Node id for the node being disconnected from. /// /// Edges are frequently removed due to the removal of a node. This /// method allows for the effect to be computed only for the remaining diff --git a/include/llvm/CodeGen/PBQP/HeuristicSolver.h b/include/llvm/CodeGen/PBQP/HeuristicSolver.h index 3e707f1..e26ca02 100644 --- a/include/llvm/CodeGen/PBQP/HeuristicSolver.h +++ b/include/llvm/CodeGen/PBQP/HeuristicSolver.h @@ -125,14 +125,14 @@ namespace PBQP { Graph& getGraph() { return g; } /// \brief Get the heuristic data attached to the given node. - /// @param nItr Node iterator. + /// @param nId Node id. /// @return The heuristic data attached to the given node. HeuristicNodeData& getHeuristicNodeData(Graph::NodeId nId) { return getSolverNodeData(nId).getHeuristicData(); } /// \brief Get the heuristic data attached to the given edge. - /// @param eItr Edge iterator. + /// @param eId Edge id. /// @return The heuristic data attached to the given node. HeuristicEdgeData& getHeuristicEdgeData(Graph::EdgeId eId) { return getSolverEdgeData(eId).getHeuristicData(); @@ -140,7 +140,7 @@ namespace PBQP { /// \brief Begin iterator for the set of edges adjacent to the given node in /// the solver graph. - /// @param nItr Node iterator. + /// @param nId Node id. /// @return Begin iterator for the set of edges adjacent to the given node /// in the solver graph. SolverEdgeItr solverEdgesBegin(Graph::NodeId nId) { @@ -149,7 +149,7 @@ namespace PBQP { /// \brief End iterator for the set of edges adjacent to the given node in /// the solver graph. - /// @param nItr Node iterator. + /// @param nId Node id. /// @return End iterator for the set of edges adjacent to the given node in /// the solver graph. SolverEdgeItr solverEdgesEnd(Graph::NodeId nId) { @@ -157,7 +157,7 @@ namespace PBQP { } /// \brief Remove a node from the solver graph. - /// @param eItr Edge iterator for edge to be removed. + /// @param eId Edge id for edge to be removed. /// /// Does not notify the heuristic of the removal. That should be /// done manually if necessary. @@ -188,21 +188,21 @@ namespace PBQP { } /// \brief Add to the end of the stack. - /// @param nItr Node iterator to add to the reduction stack. + /// @param nId Node id to add to the reduction stack. void pushToStack(Graph::NodeId nId) { getSolverNodeData(nId).clearSolverEdges(); stack.push_back(nId); } /// \brief Returns the solver degree of the given node. - /// @param nItr Node iterator for which degree is requested. + /// @param nId Node id for which degree is requested. /// @return Node degree in the solver graph (not the original graph). unsigned getSolverDegree(Graph::NodeId nId) { return getSolverNodeData(nId).getSolverDegree(); } /// \brief Set the solution of the given node. - /// @param nItr Node iterator to set solution for. + /// @param nId Node id to set solution for. /// @param selection Selection for node. void setSolution(const Graph::NodeId &nId, unsigned selection) { s.setSelection(nId, selection); @@ -217,7 +217,7 @@ namespace PBQP { } /// \brief Apply rule R0. - /// @param nItr Node iterator for node to apply R0 to. + /// @param nId Node id for node to apply R0 to. /// /// Node will be automatically pushed to the solver stack. void applyR0(Graph::NodeId nId) { @@ -231,7 +231,7 @@ namespace PBQP { } /// \brief Apply rule R1. - /// @param xnItr Node iterator for node to apply R1 to. + /// @param xnId Node id for node to apply R1 to. /// /// Node will be automatically pushed to the solver stack. void applyR1(Graph::NodeId xnId) { @@ -280,7 +280,7 @@ namespace PBQP { } /// \brief Apply rule R2. - /// @param xnItr Node iterator for node to apply R2 to. + /// @param xnId Node id for node to apply R2 to. /// /// Node will be automatically pushed to the solver stack. void applyR2(Graph::NodeId xnId) { diff --git a/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h b/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h index 9e1d999..c355c2c 100644 --- a/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h +++ b/include/llvm/CodeGen/PBQP/Heuristics/Briggs.h @@ -114,7 +114,7 @@ namespace PBQP { /// \brief Determine whether a node should be reduced using optimal /// reduction. - /// @param nItr Node iterator to be considered. + /// @param nId Node id to be considered. /// @return True if the given node should be optimally reduced, false /// otherwise. /// @@ -132,7 +132,7 @@ namespace PBQP { } /// \brief Add a node to the heuristic reduce list. - /// @param nItr Node iterator to add to the heuristic reduce list. + /// @param nId Node id to add to the heuristic reduce list. void addToHeuristicReduceList(Graph::NodeId nId) { NodeData &nd = getHeuristicNodeData(nId); initializeNode(nId); @@ -179,7 +179,7 @@ namespace PBQP { } /// \brief Prepare a change in the costs on the given edge. - /// @param eItr Edge iterator. + /// @param eId Edge id. void preUpdateEdgeCosts(Graph::EdgeId eId) { Graph &g = getGraph(); Graph::NodeId n1Id = g.getEdgeNode1(eId), @@ -197,7 +197,7 @@ namespace PBQP { } /// \brief Handle the change in the costs on the given edge. - /// @param eItr Edge iterator. + /// @param eId Edge id. void postUpdateEdgeCosts(Graph::EdgeId eId) { // This is effectively the same as adding a new edge now, since // we've factored out the costs of the old one. @@ -205,7 +205,7 @@ namespace PBQP { } /// \brief Handle the addition of a new edge into the PBQP graph. - /// @param eItr Edge iterator for the added edge. + /// @param eId Edge id for the added edge. /// /// Updates allocability of any nodes connected by this edge which are /// being managed by the heuristic. If allocability changes they are @@ -251,8 +251,8 @@ namespace PBQP { } /// \brief Handle disconnection of an edge from a node. - /// @param eItr Edge iterator for edge being disconnected. - /// @param nItr Node iterator for the node being disconnected from. + /// @param eId Edge id for edge being disconnected. + /// @param nId Node id for the node being disconnected from. /// /// Updates allocability of the given node and, if appropriate, moves the /// node to a new list. diff --git a/include/llvm/CodeGen/PBQP/Solution.h b/include/llvm/CodeGen/PBQP/Solution.h index 98ba5a1..091805d 100644 --- a/include/llvm/CodeGen/PBQP/Solution.h +++ b/include/llvm/CodeGen/PBQP/Solution.h @@ -70,15 +70,15 @@ namespace PBQP { unsigned numRNReductions() const { return rNReductions; } /// \brief Set the selection for a given node. - /// @param nItr Node iterator. - /// @param selection Selection for nItr. + /// @param nodeId Node id. + /// @param selection Selection for nodeId. void setSelection(Graph::NodeId nodeId, unsigned selection) { selections[nodeId] = selection; } /// \brief Get a node's selection. - /// @param nItr Node iterator. - /// @return The selection for nItr; + /// @param nodeId Node id. + /// @return The selection for nodeId; unsigned getSelection(Graph::NodeId nodeId) const { SelectionsMap::const_iterator sItr = selections.find(nodeId); assert(sItr != selections.end() && "No selection for node."); -- cgit v1.1 From aec427786be4f4dd0c8ecc0aa17899e6c836e45d Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 9 Nov 2013 04:06:02 +0000 Subject: Add a polymorphic_ptr smart pointer data type. It's a somewhat silly unique ownership smart pointer which is *deep* copyable by assuming it can call a T::clone() method to allocate a copy of the owned data. This is mostly useful with containers or other collections of uniquely owned data in C++98 where they *might* copy. With C++11 we can likely remove this in favor of move-only types and containers wrapped around those types. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194315 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/polymorphic_ptr.h | 117 +++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 include/llvm/ADT/polymorphic_ptr.h (limited to 'include') diff --git a/include/llvm/ADT/polymorphic_ptr.h b/include/llvm/ADT/polymorphic_ptr.h new file mode 100644 index 0000000..6114b65 --- /dev/null +++ b/include/llvm/ADT/polymorphic_ptr.h @@ -0,0 +1,117 @@ +//===- llvm/ADT/polymorphic_ptr.h - Smart copyable owned ptr ----*- 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 provides a polymorphic_ptr class template. See the class comments +/// for details about this API, its intended use cases, etc. +/// +/// The primary motivation here is to work around the necessity of copy +/// semantics in C++98. This is typically used where any actual copies are +/// incidental or unnecessary. As a consequence, it is expected to cease to be +/// useful and be removed when we can directly rely on move-only types. +/// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_ADT_POLYMORPHIC_PTR_H +#define LLVM_ADT_POLYMORPHIC_PTR_H + +#include "llvm/Support/Compiler.h" + +namespace llvm { + +/// \brief An owning, copyable polymorphic smart pointer. +/// +/// This pointer exists to provide copyable owned smart pointer. Rather than +/// shared ownership semantics, it has unique ownership semantics and deep copy +/// semantics. It is copyable by requiring that the underlying type exposes +/// a method which can produce a (heap allocated) clone. +/// +/// Note that in almost all scenarios use of this could be avoided if we could +/// build move-only containers of a std::unique_ptr, but until then this +/// provides an effective way to place polymorphic objects in a container. +template class polymorphic_ptr { + T *ptr; + +public: + explicit polymorphic_ptr(T *ptr = 0) : ptr(ptr) {} + polymorphic_ptr(const polymorphic_ptr &arg) : ptr(arg->clone()) {} +#if LLVM_HAS_RVALUE_REFERENCES + polymorphic_ptr(polymorphic_ptr &&arg) : ptr(arg.take()) {} +#endif + ~polymorphic_ptr() { delete ptr; } + + polymorphic_ptr &operator=(polymorphic_ptr arg) { + swap(arg); + return *this; + } + polymorphic_ptr &operator=(T *arg) { + if (arg != ptr) { + delete ptr; + ptr = arg; + } + return *this; + } + + T &operator*() const { return *ptr; } + T *operator->() const { return ptr; } + LLVM_EXPLICIT operator bool() const { return ptr != 0; } + bool operator!() const { return ptr == 0; } + + T *get() const { return ptr; } + + T *take() { + T *tmp = ptr; + ptr = 0; + return tmp; + } + + void swap(polymorphic_ptr &arg) { + T *tmp = ptr; + ptr = arg.ptr; + arg.ptr = tmp; + } +}; + +template +void swap(polymorphic_ptr &lhs, polymorphic_ptr &rhs) { + lhs.swap(rhs); +} + +template +bool operator==(const polymorphic_ptr &lhs, const polymorphic_ptr &rhs) { + return lhs.get() == rhs.get(); +} + +template +bool operator!=(const polymorphic_ptr &lhs, const polymorphic_ptr &rhs) { + return lhs.get() != rhs.get(); +} + +template +bool operator==(const polymorphic_ptr &lhs, U *rhs) { + return lhs.get() == rhs; +} + +template +bool operator!=(const polymorphic_ptr &lhs, U *rhs) { + return lhs.get() != rhs; +} + +template +bool operator==(T *lhs, const polymorphic_ptr &rhs) { + return lhs == rhs.get(); +} + +template +bool operator!=(T *lhs, const polymorphic_ptr &rhs) { + return lhs != rhs.get(); +} + +} + +#endif -- cgit v1.1 From 3481cdc57382b315c96ad82a6e166f9914dadddb Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 9 Nov 2013 05:55:03 +0000 Subject: Switch to allow implicit construction. In many cases, we're wrapping a derived type and this makes it *much* easier to write this code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194321 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/polymorphic_ptr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/ADT/polymorphic_ptr.h b/include/llvm/ADT/polymorphic_ptr.h index 6114b65..a168747 100644 --- a/include/llvm/ADT/polymorphic_ptr.h +++ b/include/llvm/ADT/polymorphic_ptr.h @@ -38,7 +38,7 @@ template class polymorphic_ptr { T *ptr; public: - explicit polymorphic_ptr(T *ptr = 0) : ptr(ptr) {} + polymorphic_ptr(T *ptr = 0) : ptr(ptr) {} polymorphic_ptr(const polymorphic_ptr &arg) : ptr(arg->clone()) {} #if LLVM_HAS_RVALUE_REFERENCES polymorphic_ptr(polymorphic_ptr &&arg) : ptr(arg.take()) {} -- cgit v1.1 From 9defe9a7ccb29b02ed78bede5892fd4e3e64307b Mon Sep 17 00:00:00 2001 From: Filip Pizlo Date: Sat, 9 Nov 2013 06:00:03 +0000 Subject: This exposes the new calling conventions (WebKit_JS and AnyReg) via the C API by adding them to the enumeration in Core.h. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194323 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 30b1d82..d4de523 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -301,6 +301,8 @@ typedef enum { LLVMCCallConv = 0, LLVMFastCallConv = 8, LLVMColdCallConv = 9, + LLVMWebKitJSCallConv = 12, + LLVMAnyRegCallConv = 13, LLVMX86StdcallCallConv = 64, LLVMX86FastcallCallConv = 65 } LLVMCallConv; -- cgit v1.1 From 49837ef8111fbeace7ae6379ca733c8f8fa94cfe Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 9 Nov 2013 12:26:54 +0000 Subject: Move the old pass manager infrastructure into a legacy namespace and give the files a legacy prefix in the right directory. Use forwarding headers in the old locations to paper over the name change for most clients during the transitional period. No functionality changed here! This is just clearing some space to reduce renaming churn later on with a new system. Even when the new stuff starts to go in, it is going to be hidden behind a flag and off-by-default as it is still WIP and under development. This patch is specifically designed so that very little out-of-tree code has to change. I'm going to work as hard as I can to keep that the case. Only direct forward declarations of the PassManager class are impacted by this change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194324 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/LoopPass.h | 2 +- include/llvm/Analysis/RegionPass.h | 2 +- include/llvm/CodeGen/Passes.h | 7 +- include/llvm/IR/LegacyPassManager.h | 111 ++++++ include/llvm/IR/LegacyPassManagers.h | 470 +++++++++++++++++++++++ include/llvm/PassManager.h | 104 +---- include/llvm/PassManagers.h | 470 ----------------------- include/llvm/Target/TargetMachine.h | 7 +- include/llvm/Transforms/IPO/PassManagerBuilder.h | 14 +- 9 files changed, 623 insertions(+), 564 deletions(-) create mode 100644 include/llvm/IR/LegacyPassManager.h create mode 100644 include/llvm/IR/LegacyPassManagers.h delete mode 100644 include/llvm/PassManagers.h (limited to 'include') diff --git a/include/llvm/Analysis/LoopPass.h b/include/llvm/Analysis/LoopPass.h index 5767c19..5926610 100644 --- a/include/llvm/Analysis/LoopPass.h +++ b/include/llvm/Analysis/LoopPass.h @@ -16,8 +16,8 @@ #define LLVM_ANALYSIS_LOOPPASS_H #include "llvm/Analysis/LoopInfo.h" +#include "llvm/IR/LegacyPassManagers.h" #include "llvm/Pass.h" -#include "llvm/PassManagers.h" #include namespace llvm { diff --git a/include/llvm/Analysis/RegionPass.h b/include/llvm/Analysis/RegionPass.h index 6ae3191..3907ad9 100644 --- a/include/llvm/Analysis/RegionPass.h +++ b/include/llvm/Analysis/RegionPass.h @@ -18,8 +18,8 @@ #include "llvm/Analysis/RegionInfo.h" #include "llvm/IR/Function.h" +#include "llvm/IR/LegacyPassManagers.h" #include "llvm/Pass.h" -#include "llvm/PassManagers.h" #include namespace llvm { diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h index 7df4cbf..ae4a2fa 100644 --- a/include/llvm/CodeGen/Passes.h +++ b/include/llvm/CodeGen/Passes.h @@ -25,7 +25,6 @@ class FunctionPass; class MachineFunctionPass; class PassConfigImpl; class PassInfo; -class PassManagerBase; class ScheduleDAGInstrs; class TargetLowering; class TargetLoweringBase; @@ -33,6 +32,12 @@ class TargetRegisterClass; class raw_ostream; struct MachineSchedContext; +// The old pass manager infrastructure is hidden in a legacy namespace now. +namespace legacy { +class PassManagerBase; +} +using legacy::PassManagerBase; + /// Discriminated union of Pass ID types. /// /// The PassConfig API prefers dealing with IDs because they are safer and more diff --git a/include/llvm/IR/LegacyPassManager.h b/include/llvm/IR/LegacyPassManager.h new file mode 100644 index 0000000..fa1436e --- /dev/null +++ b/include/llvm/IR/LegacyPassManager.h @@ -0,0 +1,111 @@ +//===- LegacyPassManager.h - Legacy Container for Passes --------*- 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 legacy PassManager class. This class is used to hold, +// maintain, and optimize execution of Passes. The PassManager class ensures +// that analysis results are available before a pass runs, and that Pass's are +// destroyed when the PassManager is destroyed. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_IR_LEGACYPASSMANAGER_H +#define LLVM_IR_LEGACYPASSMANAGER_H + +#include "llvm/Pass.h" +#include "llvm/Support/CBindingWrapping.h" + +namespace llvm { + +class Pass; +class Module; + +namespace legacy { + +class PassManagerImpl; +class FunctionPassManagerImpl; + +/// PassManagerBase - An abstract interface to allow code to add passes to +/// a pass manager without having to hard-code what kind of pass manager +/// it is. +class PassManagerBase { +public: + virtual ~PassManagerBase(); + + /// add - Add a pass to the queue of passes to run. This passes ownership of + /// the Pass to the PassManager. When the PassManager is destroyed, the pass + /// will be destroyed as well, so there is no need to delete the pass. This + /// implies that all passes MUST be allocated with 'new'. + virtual void add(Pass *P) = 0; +}; + +/// PassManager manages ModulePassManagers +class PassManager : public PassManagerBase { +public: + + PassManager(); + ~PassManager(); + + /// add - Add a pass to the queue of passes to run. This passes ownership of + /// the Pass to the PassManager. When the PassManager is destroyed, the pass + /// will be destroyed as well, so there is no need to delete the pass. This + /// implies that all passes MUST be allocated with 'new'. + void add(Pass *P); + + /// run - Execute all of the passes scheduled for execution. Keep track of + /// whether any of the passes modifies the module, and if so, return true. + bool run(Module &M); + +private: + /// PassManagerImpl_New is the actual class. PassManager is just the + /// wraper to publish simple pass manager interface + PassManagerImpl *PM; +}; + +/// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers. +class FunctionPassManager : public PassManagerBase { +public: + /// FunctionPassManager ctor - This initializes the pass manager. It needs, + /// but does not take ownership of, the specified Module. + explicit FunctionPassManager(Module *M); + ~FunctionPassManager(); + + /// add - Add a pass to the queue of passes to run. This passes + /// ownership of the Pass to the PassManager. When the + /// PassManager_X is destroyed, the pass will be destroyed as well, so + /// there is no need to delete the pass. + /// This implies that all passes MUST be allocated with 'new'. + void add(Pass *P); + + /// run - Execute all of the passes scheduled for execution. Keep + /// track of whether any of the passes modifies the function, and if + /// so, return true. + /// + bool run(Function &F); + + /// doInitialization - Run all of the initializers for the function passes. + /// + bool doInitialization(); + + /// doFinalization - Run all of the finalizers for the function passes. + /// + bool doFinalization(); + +private: + FunctionPassManagerImpl *FPM; + Module *M; +}; + +} // End legacy namespace + +// Create wrappers for C Binding types (see CBindingWrapping.h). +DEFINE_STDCXX_CONVERSION_FUNCTIONS(legacy::PassManagerBase, LLVMPassManagerRef) + +} // End llvm namespace + +#endif diff --git a/include/llvm/IR/LegacyPassManagers.h b/include/llvm/IR/LegacyPassManagers.h new file mode 100644 index 0000000..d256a3e --- /dev/null +++ b/include/llvm/IR/LegacyPassManagers.h @@ -0,0 +1,470 @@ +//===- LegacyPassManagers.h - Legacy Pass Infrastructure --------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file declares the LLVM Pass Manager infrastructure. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_PASSMANAGERS_H +#define LLVM_PASSMANAGERS_H + +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/SmallPtrSet.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/Pass.h" +#include +#include + +//===----------------------------------------------------------------------===// +// Overview: +// The Pass Manager Infrastructure manages passes. It's responsibilities are: +// +// o Manage optimization pass execution order +// o Make required Analysis information available before pass P is run +// o Release memory occupied by dead passes +// o If Analysis information is dirtied by a pass then regenerate Analysis +// information before it is consumed by another pass. +// +// Pass Manager Infrastructure uses multiple pass managers. They are +// PassManager, FunctionPassManager, MPPassManager, FPPassManager, BBPassManager. +// This class hierarchy uses multiple inheritance but pass managers do not +// derive from another pass manager. +// +// PassManager and FunctionPassManager are two top-level pass manager that +// represents the external interface of this entire pass manager infrastucture. +// +// Important classes : +// +// [o] class PMTopLevelManager; +// +// Two top level managers, PassManager and FunctionPassManager, derive from +// PMTopLevelManager. PMTopLevelManager manages information used by top level +// managers such as last user info. +// +// [o] class PMDataManager; +// +// PMDataManager manages information, e.g. list of available analysis info, +// used by a pass manager to manage execution order of passes. It also provides +// a place to implement common pass manager APIs. All pass managers derive from +// PMDataManager. +// +// [o] class BBPassManager : public FunctionPass, public PMDataManager; +// +// BBPassManager manages BasicBlockPasses. +// +// [o] class FunctionPassManager; +// +// This is a external interface used by JIT to manage FunctionPasses. This +// interface relies on FunctionPassManagerImpl to do all the tasks. +// +// [o] class FunctionPassManagerImpl : public ModulePass, PMDataManager, +// public PMTopLevelManager; +// +// FunctionPassManagerImpl is a top level manager. It manages FPPassManagers +// +// [o] class FPPassManager : public ModulePass, public PMDataManager; +// +// FPPassManager manages FunctionPasses and BBPassManagers +// +// [o] class MPPassManager : public Pass, public PMDataManager; +// +// MPPassManager manages ModulePasses and FPPassManagers +// +// [o] class PassManager; +// +// This is a external interface used by various tools to manages passes. It +// relies on PassManagerImpl to do all the tasks. +// +// [o] class PassManagerImpl : public Pass, public PMDataManager, +// public PMTopLevelManager +// +// PassManagerImpl is a top level pass manager responsible for managing +// MPPassManagers. +//===----------------------------------------------------------------------===// + +#include "llvm/Support/PrettyStackTrace.h" + +namespace llvm { + class Module; + class Pass; + class StringRef; + class Value; + class Timer; + class PMDataManager; + +// enums for debugging strings +enum PassDebuggingString { + EXECUTION_MSG, // "Executing Pass '" + MODIFICATION_MSG, // "' Made Modification '" + FREEING_MSG, // " Freeing Pass '" + ON_BASICBLOCK_MSG, // "' on BasicBlock '" + PassName + "'...\n" + ON_FUNCTION_MSG, // "' on Function '" + FunctionName + "'...\n" + ON_MODULE_MSG, // "' on Module '" + ModuleName + "'...\n" + ON_REGION_MSG, // " 'on Region ...\n'" + ON_LOOP_MSG, // " 'on Loop ...\n'" + ON_CG_MSG // "' on Call Graph ...\n'" +}; + +/// PassManagerPrettyStackEntry - This is used to print informative information +/// about what pass is running when/if a stack trace is generated. +class PassManagerPrettyStackEntry : public PrettyStackTraceEntry { + Pass *P; + Value *V; + Module *M; +public: + explicit PassManagerPrettyStackEntry(Pass *p) + : P(p), V(0), M(0) {} // When P is releaseMemory'd. + PassManagerPrettyStackEntry(Pass *p, Value &v) + : P(p), V(&v), M(0) {} // When P is run on V + PassManagerPrettyStackEntry(Pass *p, Module &m) + : P(p), V(0), M(&m) {} // When P is run on M + + /// print - Emit information about this stack frame to OS. + virtual void print(raw_ostream &OS) const; +}; + + +//===----------------------------------------------------------------------===// +// PMStack +// +/// PMStack - This class implements a stack data structure of PMDataManager +/// pointers. +/// +/// Top level pass managers (see PassManager.cpp) maintain active Pass Managers +/// using PMStack. Each Pass implements assignPassManager() to connect itself +/// with appropriate manager. assignPassManager() walks PMStack to find +/// suitable manager. +class PMStack { +public: + typedef std::vector::const_reverse_iterator iterator; + iterator begin() const { return S.rbegin(); } + iterator end() const { return S.rend(); } + + void pop(); + PMDataManager *top() const { return S.back(); } + void push(PMDataManager *PM); + bool empty() const { return S.empty(); } + + void dump() const; + +private: + std::vector S; +}; + + +//===----------------------------------------------------------------------===// +// PMTopLevelManager +// +/// PMTopLevelManager manages LastUser info and collects common APIs used by +/// top level pass managers. +class PMTopLevelManager { +protected: + explicit PMTopLevelManager(PMDataManager *PMDM); + + unsigned getNumContainedManagers() const { + return (unsigned)PassManagers.size(); + } + + void initializeAllAnalysisInfo(); + +private: + virtual PMDataManager *getAsPMDataManager() = 0; + virtual PassManagerType getTopLevelPassManagerType() = 0; + +public: + /// Schedule pass P for execution. Make sure that passes required by + /// P are run before P is run. Update analysis info maintained by + /// the manager. Remove dead passes. This is a recursive function. + void schedulePass(Pass *P); + + /// Set pass P as the last user of the given analysis passes. + void setLastUser(ArrayRef AnalysisPasses, Pass *P); + + /// Collect passes whose last user is P + void collectLastUses(SmallVectorImpl &LastUses, Pass *P); + + /// Find the pass that implements Analysis AID. Search immutable + /// passes and all pass managers. If desired pass is not found + /// then return NULL. + Pass *findAnalysisPass(AnalysisID AID); + + /// Find analysis usage information for the pass P. + AnalysisUsage *findAnalysisUsage(Pass *P); + + virtual ~PMTopLevelManager(); + + /// Add immutable pass and initialize it. + inline void addImmutablePass(ImmutablePass *P) { + P->initializePass(); + ImmutablePasses.push_back(P); + } + + inline SmallVectorImpl& getImmutablePasses() { + return ImmutablePasses; + } + + void addPassManager(PMDataManager *Manager) { + PassManagers.push_back(Manager); + } + + // Add Manager into the list of managers that are not directly + // maintained by this top level pass manager + inline void addIndirectPassManager(PMDataManager *Manager) { + IndirectPassManagers.push_back(Manager); + } + + // Print passes managed by this top level manager. + void dumpPasses() const; + void dumpArguments() const; + + // Active Pass Managers + PMStack activeStack; + +protected: + + /// Collection of pass managers + SmallVector PassManagers; + +private: + + /// Collection of pass managers that are not directly maintained + /// by this pass manager + SmallVector IndirectPassManagers; + + // Map to keep track of last user of the analysis pass. + // LastUser->second is the last user of Lastuser->first. + DenseMap LastUser; + + // Map to keep track of passes that are last used by a pass. + // This inverse map is initialized at PM->run() based on + // LastUser map. + DenseMap > InversedLastUser; + + /// Immutable passes are managed by top level manager. + SmallVector ImmutablePasses; + + DenseMap AnUsageMap; +}; + + + +//===----------------------------------------------------------------------===// +// PMDataManager + +/// PMDataManager provides the common place to manage the analysis data +/// used by pass managers. +class PMDataManager { +public: + + explicit PMDataManager() : TPM(NULL), Depth(0) { + initializeAnalysisInfo(); + } + + virtual ~PMDataManager(); + + virtual Pass *getAsPass() = 0; + + /// Augment AvailableAnalysis by adding analysis made available by pass P. + void recordAvailableAnalysis(Pass *P); + + /// verifyPreservedAnalysis -- Verify analysis presreved by pass P. + void verifyPreservedAnalysis(Pass *P); + + /// Remove Analysis that is not preserved by the pass + void removeNotPreservedAnalysis(Pass *P); + + /// Remove dead passes used by P. + void removeDeadPasses(Pass *P, StringRef Msg, + enum PassDebuggingString); + + /// Remove P. + void freePass(Pass *P, StringRef Msg, + enum PassDebuggingString); + + /// Add pass P into the PassVector. Update + /// AvailableAnalysis appropriately if ProcessAnalysis is true. + void add(Pass *P, bool ProcessAnalysis = true); + + /// Add RequiredPass into list of lower level passes required by pass P. + /// RequiredPass is run on the fly by Pass Manager when P requests it + /// through getAnalysis interface. + virtual void addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass); + + virtual Pass *getOnTheFlyPass(Pass *P, AnalysisID PI, Function &F); + + /// Initialize available analysis information. + void initializeAnalysisInfo() { + AvailableAnalysis.clear(); + for (unsigned i = 0; i < PMT_Last; ++i) + InheritedAnalysis[i] = NULL; + } + + // Return true if P preserves high level analysis used by other + // passes that are managed by this manager. + bool preserveHigherLevelAnalysis(Pass *P); + + + /// Populate RequiredPasses with analysis pass that are required by + /// pass P and are available. Populate ReqPassNotAvailable with analysis + /// pass that are required by pass P but are not available. + void collectRequiredAnalysis(SmallVectorImpl &RequiredPasses, + SmallVectorImpl &ReqPassNotAvailable, + Pass *P); + + /// All Required analyses should be available to the pass as it runs! Here + /// we fill in the AnalysisImpls member of the pass so that it can + /// successfully use the getAnalysis() method to retrieve the + /// implementations it needs. + void initializeAnalysisImpl(Pass *P); + + /// Find the pass that implements Analysis AID. If desired pass is not found + /// then return NULL. + Pass *findAnalysisPass(AnalysisID AID, bool Direction); + + // Access toplevel manager + PMTopLevelManager *getTopLevelManager() { return TPM; } + void setTopLevelManager(PMTopLevelManager *T) { TPM = T; } + + unsigned getDepth() const { return Depth; } + void setDepth(unsigned newDepth) { Depth = newDepth; } + + // Print routines used by debug-pass + void dumpLastUses(Pass *P, unsigned Offset) const; + void dumpPassArguments() const; + void dumpPassInfo(Pass *P, enum PassDebuggingString S1, + enum PassDebuggingString S2, StringRef Msg); + void dumpRequiredSet(const Pass *P) const; + void dumpPreservedSet(const Pass *P) const; + + unsigned getNumContainedPasses() const { + return (unsigned)PassVector.size(); + } + + virtual PassManagerType getPassManagerType() const { + assert ( 0 && "Invalid use of getPassManagerType"); + return PMT_Unknown; + } + + DenseMap *getAvailableAnalysis() { + return &AvailableAnalysis; + } + + // Collect AvailableAnalysis from all the active Pass Managers. + void populateInheritedAnalysis(PMStack &PMS) { + unsigned Index = 0; + for (PMStack::iterator I = PMS.begin(), E = PMS.end(); + I != E; ++I) + InheritedAnalysis[Index++] = (*I)->getAvailableAnalysis(); + } + +protected: + + // Top level manager. + PMTopLevelManager *TPM; + + // Collection of pass that are managed by this manager + SmallVector PassVector; + + // Collection of Analysis provided by Parent pass manager and + // used by current pass manager. At at time there can not be more + // then PMT_Last active pass mangers. + DenseMap *InheritedAnalysis[PMT_Last]; + + /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions + /// or higher is specified. + bool isPassDebuggingExecutionsOrMore() const; + +private: + void dumpAnalysisUsage(StringRef Msg, const Pass *P, + const AnalysisUsage::VectorType &Set) const; + + // Set of available Analysis. This information is used while scheduling + // pass. If a pass requires an analysis which is not available then + // the required analysis pass is scheduled to run before the pass itself is + // scheduled to run. + DenseMap AvailableAnalysis; + + // Collection of higher level analysis used by the pass managed by + // this manager. + SmallVector HigherLevelAnalysis; + + unsigned Depth; +}; + +//===----------------------------------------------------------------------===// +// FPPassManager +// +/// FPPassManager manages BBPassManagers and FunctionPasses. +/// It batches all function passes and basic block pass managers together and +/// sequence them to process one function at a time before processing next +/// function. +class FPPassManager : public ModulePass, public PMDataManager { +public: + static char ID; + explicit FPPassManager() + : ModulePass(ID), PMDataManager() { } + + /// run - Execute all of the passes scheduled for execution. Keep track of + /// whether any of the passes modifies the module, and if so, return true. + bool runOnFunction(Function &F); + bool runOnModule(Module &M); + + /// cleanup - After running all passes, clean up pass manager cache. + void cleanup(); + + /// doInitialization - Overrides ModulePass doInitialization for global + /// initialization tasks + /// + using ModulePass::doInitialization; + + /// doInitialization - Run all of the initializers for the function passes. + /// + bool doInitialization(Module &M); + + /// doFinalization - Overrides ModulePass doFinalization for global + /// finalization tasks + /// + using ModulePass::doFinalization; + + /// doFinalization - Run all of the finalizers for the function passes. + /// + bool doFinalization(Module &M); + + virtual PMDataManager *getAsPMDataManager() { return this; } + virtual Pass *getAsPass() { return this; } + + /// Pass Manager itself does not invalidate any analysis info. + void getAnalysisUsage(AnalysisUsage &Info) const { + Info.setPreservesAll(); + } + + // Print passes managed by this manager + void dumpPassStructure(unsigned Offset); + + virtual const char *getPassName() const { + return "Function Pass Manager"; + } + + FunctionPass *getContainedPass(unsigned N) { + assert ( N < PassVector.size() && "Pass number out of range!"); + FunctionPass *FP = static_cast(PassVector[N]); + return FP; + } + + virtual PassManagerType getPassManagerType() const { + return PMT_FunctionPassManager; + } +}; + +Timer *getPassTimer(Pass *); + +} + +#endif diff --git a/include/llvm/PassManager.h b/include/llvm/PassManager.h index b6a8186..2a191b3 100644 --- a/include/llvm/PassManager.h +++ b/include/llvm/PassManager.h @@ -7,101 +7,33 @@ // //===----------------------------------------------------------------------===// // -// This file defines the PassManager class. This class is used to hold, -// maintain, and optimize execution of Passes. The PassManager class ensures -// that analysis results are available before a pass runs, and that Pass's are -// destroyed when the PassManager is destroyed. +// This is a legacy redirect header for the old PassManager. It is intended to +// be used by clients that have not been converted to be aware of the new pass +// management infrastructure being built for LLVM, which is every client +// initially. Eventually this header (and the legacy management layer) will go +// away, but we want to minimize changes to out-of-tree users of LLVM in the +// interim. +// +// Note that this header *must not* be included into the same file as the new +// pass management infrastructure is included. Things will break spectacularly. +// If you are starting that conversion, you should switch to explicitly +// including LegacyPassManager.h and using the legacy namespace. // //===----------------------------------------------------------------------===// #ifndef LLVM_PASSMANAGER_H #define LLVM_PASSMANAGER_H -#include "llvm/Pass.h" -#include "llvm/Support/CBindingWrapping.h" +#include "llvm/IR/LegacyPassManager.h" namespace llvm { -class Pass; -class Module; - -class PassManagerImpl; -class FunctionPassManagerImpl; - -/// PassManagerBase - An abstract interface to allow code to add passes to -/// a pass manager without having to hard-code what kind of pass manager -/// it is. -class PassManagerBase { -public: - virtual ~PassManagerBase(); - - /// add - Add a pass to the queue of passes to run. This passes ownership of - /// the Pass to the PassManager. When the PassManager is destroyed, the pass - /// will be destroyed as well, so there is no need to delete the pass. This - /// implies that all passes MUST be allocated with 'new'. - virtual void add(Pass *P) = 0; -}; - -/// PassManager manages ModulePassManagers -class PassManager : public PassManagerBase { -public: - - PassManager(); - ~PassManager(); - - /// add - Add a pass to the queue of passes to run. This passes ownership of - /// the Pass to the PassManager. When the PassManager is destroyed, the pass - /// will be destroyed as well, so there is no need to delete the pass. This - /// implies that all passes MUST be allocated with 'new'. - void add(Pass *P); - - /// run - Execute all of the passes scheduled for execution. Keep track of - /// whether any of the passes modifies the module, and if so, return true. - bool run(Module &M); - -private: - /// PassManagerImpl_New is the actual class. PassManager is just the - /// wraper to publish simple pass manager interface - PassManagerImpl *PM; -}; - -/// FunctionPassManager manages FunctionPasses and BasicBlockPassManagers. -class FunctionPassManager : public PassManagerBase { -public: - /// FunctionPassManager ctor - This initializes the pass manager. It needs, - /// but does not take ownership of, the specified Module. - explicit FunctionPassManager(Module *M); - ~FunctionPassManager(); - - /// add - Add a pass to the queue of passes to run. This passes - /// ownership of the Pass to the PassManager. When the - /// PassManager_X is destroyed, the pass will be destroyed as well, so - /// there is no need to delete the pass. - /// This implies that all passes MUST be allocated with 'new'. - void add(Pass *P); - - /// run - Execute all of the passes scheduled for execution. Keep - /// track of whether any of the passes modifies the function, and if - /// so, return true. - /// - bool run(Function &F); - - /// doInitialization - Run all of the initializers for the function passes. - /// - bool doInitialization(); - - /// doFinalization - Run all of the finalizers for the function passes. - /// - bool doFinalization(); - -private: - FunctionPassManagerImpl *FPM; - Module *M; -}; - -// Create wrappers for C Binding types (see CBindingWrapping.h). -DEFINE_STDCXX_CONVERSION_FUNCTIONS(PassManagerBase, LLVMPassManagerRef) +// Pull these into the llvm namespace so that existing code that expects it +// there can find it. +using legacy::PassManagerBase; +using legacy::PassManager; +using legacy::FunctionPassManager; -} // End llvm namespace +} #endif diff --git a/include/llvm/PassManagers.h b/include/llvm/PassManagers.h deleted file mode 100644 index 7afb0a0..0000000 --- a/include/llvm/PassManagers.h +++ /dev/null @@ -1,470 +0,0 @@ -//===- llvm/PassManagers.h - Pass Infrastructure classes -------*- C++ -*-===// -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source -// License. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// -// -// This file declares the LLVM Pass Manager infrastructure. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_PASSMANAGERS_H -#define LLVM_PASSMANAGERS_H - -#include "llvm/ADT/ArrayRef.h" -#include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/SmallPtrSet.h" -#include "llvm/ADT/SmallVector.h" -#include "llvm/Pass.h" -#include -#include - -//===----------------------------------------------------------------------===// -// Overview: -// The Pass Manager Infrastructure manages passes. It's responsibilities are: -// -// o Manage optimization pass execution order -// o Make required Analysis information available before pass P is run -// o Release memory occupied by dead passes -// o If Analysis information is dirtied by a pass then regenerate Analysis -// information before it is consumed by another pass. -// -// Pass Manager Infrastructure uses multiple pass managers. They are -// PassManager, FunctionPassManager, MPPassManager, FPPassManager, BBPassManager. -// This class hierarchy uses multiple inheritance but pass managers do not -// derive from another pass manager. -// -// PassManager and FunctionPassManager are two top-level pass manager that -// represents the external interface of this entire pass manager infrastucture. -// -// Important classes : -// -// [o] class PMTopLevelManager; -// -// Two top level managers, PassManager and FunctionPassManager, derive from -// PMTopLevelManager. PMTopLevelManager manages information used by top level -// managers such as last user info. -// -// [o] class PMDataManager; -// -// PMDataManager manages information, e.g. list of available analysis info, -// used by a pass manager to manage execution order of passes. It also provides -// a place to implement common pass manager APIs. All pass managers derive from -// PMDataManager. -// -// [o] class BBPassManager : public FunctionPass, public PMDataManager; -// -// BBPassManager manages BasicBlockPasses. -// -// [o] class FunctionPassManager; -// -// This is a external interface used by JIT to manage FunctionPasses. This -// interface relies on FunctionPassManagerImpl to do all the tasks. -// -// [o] class FunctionPassManagerImpl : public ModulePass, PMDataManager, -// public PMTopLevelManager; -// -// FunctionPassManagerImpl is a top level manager. It manages FPPassManagers -// -// [o] class FPPassManager : public ModulePass, public PMDataManager; -// -// FPPassManager manages FunctionPasses and BBPassManagers -// -// [o] class MPPassManager : public Pass, public PMDataManager; -// -// MPPassManager manages ModulePasses and FPPassManagers -// -// [o] class PassManager; -// -// This is a external interface used by various tools to manages passes. It -// relies on PassManagerImpl to do all the tasks. -// -// [o] class PassManagerImpl : public Pass, public PMDataManager, -// public PMTopLevelManager -// -// PassManagerImpl is a top level pass manager responsible for managing -// MPPassManagers. -//===----------------------------------------------------------------------===// - -#include "llvm/Support/PrettyStackTrace.h" - -namespace llvm { - class Module; - class Pass; - class StringRef; - class Value; - class Timer; - class PMDataManager; - -// enums for debugging strings -enum PassDebuggingString { - EXECUTION_MSG, // "Executing Pass '" - MODIFICATION_MSG, // "' Made Modification '" - FREEING_MSG, // " Freeing Pass '" - ON_BASICBLOCK_MSG, // "' on BasicBlock '" + PassName + "'...\n" - ON_FUNCTION_MSG, // "' on Function '" + FunctionName + "'...\n" - ON_MODULE_MSG, // "' on Module '" + ModuleName + "'...\n" - ON_REGION_MSG, // " 'on Region ...\n'" - ON_LOOP_MSG, // " 'on Loop ...\n'" - ON_CG_MSG // "' on Call Graph ...\n'" -}; - -/// PassManagerPrettyStackEntry - This is used to print informative information -/// about what pass is running when/if a stack trace is generated. -class PassManagerPrettyStackEntry : public PrettyStackTraceEntry { - Pass *P; - Value *V; - Module *M; -public: - explicit PassManagerPrettyStackEntry(Pass *p) - : P(p), V(0), M(0) {} // When P is releaseMemory'd. - PassManagerPrettyStackEntry(Pass *p, Value &v) - : P(p), V(&v), M(0) {} // When P is run on V - PassManagerPrettyStackEntry(Pass *p, Module &m) - : P(p), V(0), M(&m) {} // When P is run on M - - /// print - Emit information about this stack frame to OS. - virtual void print(raw_ostream &OS) const; -}; - - -//===----------------------------------------------------------------------===// -// PMStack -// -/// PMStack - This class implements a stack data structure of PMDataManager -/// pointers. -/// -/// Top level pass managers (see PassManager.cpp) maintain active Pass Managers -/// using PMStack. Each Pass implements assignPassManager() to connect itself -/// with appropriate manager. assignPassManager() walks PMStack to find -/// suitable manager. -class PMStack { -public: - typedef std::vector::const_reverse_iterator iterator; - iterator begin() const { return S.rbegin(); } - iterator end() const { return S.rend(); } - - void pop(); - PMDataManager *top() const { return S.back(); } - void push(PMDataManager *PM); - bool empty() const { return S.empty(); } - - void dump() const; - -private: - std::vector S; -}; - - -//===----------------------------------------------------------------------===// -// PMTopLevelManager -// -/// PMTopLevelManager manages LastUser info and collects common APIs used by -/// top level pass managers. -class PMTopLevelManager { -protected: - explicit PMTopLevelManager(PMDataManager *PMDM); - - unsigned getNumContainedManagers() const { - return (unsigned)PassManagers.size(); - } - - void initializeAllAnalysisInfo(); - -private: - virtual PMDataManager *getAsPMDataManager() = 0; - virtual PassManagerType getTopLevelPassManagerType() = 0; - -public: - /// Schedule pass P for execution. Make sure that passes required by - /// P are run before P is run. Update analysis info maintained by - /// the manager. Remove dead passes. This is a recursive function. - void schedulePass(Pass *P); - - /// Set pass P as the last user of the given analysis passes. - void setLastUser(ArrayRef AnalysisPasses, Pass *P); - - /// Collect passes whose last user is P - void collectLastUses(SmallVectorImpl &LastUses, Pass *P); - - /// Find the pass that implements Analysis AID. Search immutable - /// passes and all pass managers. If desired pass is not found - /// then return NULL. - Pass *findAnalysisPass(AnalysisID AID); - - /// Find analysis usage information for the pass P. - AnalysisUsage *findAnalysisUsage(Pass *P); - - virtual ~PMTopLevelManager(); - - /// Add immutable pass and initialize it. - inline void addImmutablePass(ImmutablePass *P) { - P->initializePass(); - ImmutablePasses.push_back(P); - } - - inline SmallVectorImpl& getImmutablePasses() { - return ImmutablePasses; - } - - void addPassManager(PMDataManager *Manager) { - PassManagers.push_back(Manager); - } - - // Add Manager into the list of managers that are not directly - // maintained by this top level pass manager - inline void addIndirectPassManager(PMDataManager *Manager) { - IndirectPassManagers.push_back(Manager); - } - - // Print passes managed by this top level manager. - void dumpPasses() const; - void dumpArguments() const; - - // Active Pass Managers - PMStack activeStack; - -protected: - - /// Collection of pass managers - SmallVector PassManagers; - -private: - - /// Collection of pass managers that are not directly maintained - /// by this pass manager - SmallVector IndirectPassManagers; - - // Map to keep track of last user of the analysis pass. - // LastUser->second is the last user of Lastuser->first. - DenseMap LastUser; - - // Map to keep track of passes that are last used by a pass. - // This inverse map is initialized at PM->run() based on - // LastUser map. - DenseMap > InversedLastUser; - - /// Immutable passes are managed by top level manager. - SmallVector ImmutablePasses; - - DenseMap AnUsageMap; -}; - - - -//===----------------------------------------------------------------------===// -// PMDataManager - -/// PMDataManager provides the common place to manage the analysis data -/// used by pass managers. -class PMDataManager { -public: - - explicit PMDataManager() : TPM(NULL), Depth(0) { - initializeAnalysisInfo(); - } - - virtual ~PMDataManager(); - - virtual Pass *getAsPass() = 0; - - /// Augment AvailableAnalysis by adding analysis made available by pass P. - void recordAvailableAnalysis(Pass *P); - - /// verifyPreservedAnalysis -- Verify analysis presreved by pass P. - void verifyPreservedAnalysis(Pass *P); - - /// Remove Analysis that is not preserved by the pass - void removeNotPreservedAnalysis(Pass *P); - - /// Remove dead passes used by P. - void removeDeadPasses(Pass *P, StringRef Msg, - enum PassDebuggingString); - - /// Remove P. - void freePass(Pass *P, StringRef Msg, - enum PassDebuggingString); - - /// Add pass P into the PassVector. Update - /// AvailableAnalysis appropriately if ProcessAnalysis is true. - void add(Pass *P, bool ProcessAnalysis = true); - - /// Add RequiredPass into list of lower level passes required by pass P. - /// RequiredPass is run on the fly by Pass Manager when P requests it - /// through getAnalysis interface. - virtual void addLowerLevelRequiredPass(Pass *P, Pass *RequiredPass); - - virtual Pass *getOnTheFlyPass(Pass *P, AnalysisID PI, Function &F); - - /// Initialize available analysis information. - void initializeAnalysisInfo() { - AvailableAnalysis.clear(); - for (unsigned i = 0; i < PMT_Last; ++i) - InheritedAnalysis[i] = NULL; - } - - // Return true if P preserves high level analysis used by other - // passes that are managed by this manager. - bool preserveHigherLevelAnalysis(Pass *P); - - - /// Populate RequiredPasses with analysis pass that are required by - /// pass P and are available. Populate ReqPassNotAvailable with analysis - /// pass that are required by pass P but are not available. - void collectRequiredAnalysis(SmallVectorImpl &RequiredPasses, - SmallVectorImpl &ReqPassNotAvailable, - Pass *P); - - /// All Required analyses should be available to the pass as it runs! Here - /// we fill in the AnalysisImpls member of the pass so that it can - /// successfully use the getAnalysis() method to retrieve the - /// implementations it needs. - void initializeAnalysisImpl(Pass *P); - - /// Find the pass that implements Analysis AID. If desired pass is not found - /// then return NULL. - Pass *findAnalysisPass(AnalysisID AID, bool Direction); - - // Access toplevel manager - PMTopLevelManager *getTopLevelManager() { return TPM; } - void setTopLevelManager(PMTopLevelManager *T) { TPM = T; } - - unsigned getDepth() const { return Depth; } - void setDepth(unsigned newDepth) { Depth = newDepth; } - - // Print routines used by debug-pass - void dumpLastUses(Pass *P, unsigned Offset) const; - void dumpPassArguments() const; - void dumpPassInfo(Pass *P, enum PassDebuggingString S1, - enum PassDebuggingString S2, StringRef Msg); - void dumpRequiredSet(const Pass *P) const; - void dumpPreservedSet(const Pass *P) const; - - unsigned getNumContainedPasses() const { - return (unsigned)PassVector.size(); - } - - virtual PassManagerType getPassManagerType() const { - assert ( 0 && "Invalid use of getPassManagerType"); - return PMT_Unknown; - } - - DenseMap *getAvailableAnalysis() { - return &AvailableAnalysis; - } - - // Collect AvailableAnalysis from all the active Pass Managers. - void populateInheritedAnalysis(PMStack &PMS) { - unsigned Index = 0; - for (PMStack::iterator I = PMS.begin(), E = PMS.end(); - I != E; ++I) - InheritedAnalysis[Index++] = (*I)->getAvailableAnalysis(); - } - -protected: - - // Top level manager. - PMTopLevelManager *TPM; - - // Collection of pass that are managed by this manager - SmallVector PassVector; - - // Collection of Analysis provided by Parent pass manager and - // used by current pass manager. At at time there can not be more - // then PMT_Last active pass mangers. - DenseMap *InheritedAnalysis[PMT_Last]; - - /// isPassDebuggingExecutionsOrMore - Return true if -debug-pass=Executions - /// or higher is specified. - bool isPassDebuggingExecutionsOrMore() const; - -private: - void dumpAnalysisUsage(StringRef Msg, const Pass *P, - const AnalysisUsage::VectorType &Set) const; - - // Set of available Analysis. This information is used while scheduling - // pass. If a pass requires an analysis which is not available then - // the required analysis pass is scheduled to run before the pass itself is - // scheduled to run. - DenseMap AvailableAnalysis; - - // Collection of higher level analysis used by the pass managed by - // this manager. - SmallVector HigherLevelAnalysis; - - unsigned Depth; -}; - -//===----------------------------------------------------------------------===// -// FPPassManager -// -/// FPPassManager manages BBPassManagers and FunctionPasses. -/// It batches all function passes and basic block pass managers together and -/// sequence them to process one function at a time before processing next -/// function. -class FPPassManager : public ModulePass, public PMDataManager { -public: - static char ID; - explicit FPPassManager() - : ModulePass(ID), PMDataManager() { } - - /// run - Execute all of the passes scheduled for execution. Keep track of - /// whether any of the passes modifies the module, and if so, return true. - bool runOnFunction(Function &F); - bool runOnModule(Module &M); - - /// cleanup - After running all passes, clean up pass manager cache. - void cleanup(); - - /// doInitialization - Overrides ModulePass doInitialization for global - /// initialization tasks - /// - using ModulePass::doInitialization; - - /// doInitialization - Run all of the initializers for the function passes. - /// - bool doInitialization(Module &M); - - /// doFinalization - Overrides ModulePass doFinalization for global - /// finalization tasks - /// - using ModulePass::doFinalization; - - /// doFinalization - Run all of the finalizers for the function passes. - /// - bool doFinalization(Module &M); - - virtual PMDataManager *getAsPMDataManager() { return this; } - virtual Pass *getAsPass() { return this; } - - /// Pass Manager itself does not invalidate any analysis info. - void getAnalysisUsage(AnalysisUsage &Info) const { - Info.setPreservesAll(); - } - - // Print passes managed by this manager - void dumpPassStructure(unsigned Offset); - - virtual const char *getPassName() const { - return "Function Pass Manager"; - } - - FunctionPass *getContainedPass(unsigned N) { - assert ( N < PassVector.size() && "Pass number out of range!"); - FunctionPass *FP = static_cast(PassVector[N]); - return FP; - } - - virtual PassManagerType getPassManagerType() const { - return PMT_FunctionPassManager; - } -}; - -Timer *getPassTimer(Pass *); - -} - -#endif diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index fd7228a..91e4715 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -29,7 +29,6 @@ class GlobalValue; class MCAsmInfo; class MCCodeGenInfo; class MCContext; -class PassManagerBase; class Target; class DataLayout; class TargetLibraryInfo; @@ -47,6 +46,12 @@ class VectorTargetTransformInfo; class formatted_raw_ostream; class raw_ostream; +// The old pass manager infrastructure is hidden in a legacy namespace now. +namespace legacy { +class PassManagerBase; +} +using legacy::PassManagerBase; + //===----------------------------------------------------------------------===// /// /// TargetMachine - Primary interface to the complete machine description for diff --git a/include/llvm/Transforms/IPO/PassManagerBuilder.h b/include/llvm/Transforms/IPO/PassManagerBuilder.h index 75631b3..3648a3d 100644 --- a/include/llvm/Transforms/IPO/PassManagerBuilder.h +++ b/include/llvm/Transforms/IPO/PassManagerBuilder.h @@ -18,10 +18,16 @@ #include namespace llvm { - class TargetLibraryInfo; - class PassManagerBase; - class Pass; - class FunctionPassManager; +class TargetLibraryInfo; +class Pass; + +// The old pass manager infrastructure is hidden in a legacy namespace now. +namespace legacy { +class PassManagerBase; +class FunctionPassManager; +} +using legacy::PassManagerBase; +using legacy::FunctionPassManager; /// PassManagerBuilder - This class is used to set up a standard optimization /// sequence for languages like C and C++, allowing some APIs to customize the -- cgit v1.1 From ea9988447c5bd59827baf1b45dd5b62b4065d553 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sat, 9 Nov 2013 13:09:08 +0000 Subject: [PM] Start sketching out the new module and function pass manager. This is still just a skeleton. I'm trying to pull together the experimentation I've done into committable chunks, and this is the first coherent one. Others will follow in hopefully short order that move this more toward a useful initial implementation. I still expect the design to continue evolving in small ways as I work through the different requirements and features needed here though. Keep in mind, all of this is off by default. Currently, this mostly exercises the use of a polymorphic smart pointer and templates to hide the polymorphism for the pass manager from the pass implementation. The next step will be more significant, adding the first framework of analysis support. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194325 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/PassManager.h | 118 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 include/llvm/IR/PassManager.h (limited to 'include') diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h new file mode 100644 index 0000000..aeadd41 --- /dev/null +++ b/include/llvm/IR/PassManager.h @@ -0,0 +1,118 @@ +//===- PassManager.h - LegacyContainer for Passes --------------*- C++ -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +/// \file +/// +/// This header defines various interfaces for pass management in LLVM. There +/// is no "pass" interface in LLVM per se. Instead, an instance of any class +/// which supports a method to 'run' it over a unit of IR can be used as +/// a pass. A pass manager is generally a tool to collect a sequence of passes +/// which run over a particular IR construct, and run each of them in sequence +/// over each such construct in the containing IR construct. As there is no +/// containing IR construct for a Module, a manager for passes over modules +/// forms the base case which runs its managed passes in sequence over the +/// single module provided. +/// +/// The core IR library provides managers for running passes over +/// modules and functions. +/// +/// * FunctionPassManager can run over a Module, runs each pass over +/// a Function. +/// * ModulePassManager must be directly run, runs each pass over the Module. +/// +//===----------------------------------------------------------------------===// + +#include "llvm/ADT/polymorphic_ptr.h" +#include "llvm/IR/Module.h" +#include + +namespace llvm { + +class Module; +class Function; + +/// \brief Implementation details of the pass manager interfaces. +namespace detail { + +/// \brief Template for the abstract base class used to dispatch +/// polymorphically over pass objects. +template struct PassConcept { + // Boiler plate necessary for the container of derived classes. + virtual ~PassConcept() {} + virtual PassConcept *clone() = 0; + + /// \brief The polymorphic API which runs the pass over a given IR entity. + virtual bool run(T Arg) = 0; +}; + +/// \brief A template wrapper used to implement the polymorphic API. +/// +/// Can be instantiated for any object which provides a \c run method +/// accepting a \c T. It requires the pass to be a copyable +/// object. +template struct PassModel : PassConcept { + PassModel(PassT Pass) : Pass(llvm_move(Pass)) {} + virtual PassModel *clone() { return new PassModel(Pass); } + virtual bool run(T Arg) { return Pass.run(Arg); } + PassT Pass; +}; + +} + +class ModulePassManager { +public: + ModulePassManager(Module *M) : M(M) {} + + template void addPass(ModulePassT Pass) { + Passes.push_back(new ModulePassModel(llvm_move(Pass))); + } + + void run() { + for (unsigned Idx = 0, Size = Passes.size(); Idx != Size; ++Idx) + Passes[Idx]->run(M); + } + +private: + // Pull in the concept type and model template specialized for modules. + typedef detail::PassConcept ModulePassConcept; + template + struct ModulePassModel : detail::PassModel { + ModulePassModel(PassT Pass) : detail::PassModel(Pass) {} + }; + + Module *M; + std::vector > Passes; +}; + +class FunctionPassManager { +public: + template void addPass(FunctionPassT Pass) { + Passes.push_back(new FunctionPassModel(llvm_move(Pass))); + } + + bool run(Module *M) { + bool Changed = false; + for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) + for (unsigned Idx = 0, Size = Passes.size(); Idx != Size; ++Idx) + Changed |= Passes[Idx]->run(I); + return Changed; + } + +private: + // Pull in the concept type and model template specialized for functions. + typedef detail::PassConcept FunctionPassConcept; + template + struct FunctionPassModel : detail::PassModel { + FunctionPassModel(PassT Pass) + : detail::PassModel(Pass) {} + }; + + std::vector > Passes; +}; + +} -- cgit v1.1 From a77da0579bc141eba62760e21a216e5d3eafd792 Mon Sep 17 00:00:00 2001 From: "Arnaud A. de Grandmaison" Date: Sun, 10 Nov 2013 17:46:31 +0000 Subject: CalculateSpillWeights does not need to be a pass Based on discussions with Lang Hames and Jakob Stoklund Olesen at the hacker's lab, and in the light of upcoming work on the PBQP register allocator, it was though that CalcSpillWeights does not need to be a pass. This change will enable to customize / tune the spill weight computation depending on the allocator. Update the documentation style while there. No functionnal change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194356 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/CalcSpillWeights.h | 33 +++++++++++---------------------- include/llvm/InitializePasses.h | 1 - 2 files changed, 11 insertions(+), 23 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/CalcSpillWeights.h b/include/llvm/CodeGen/CalcSpillWeights.h index c8ec764..00d9c6a 100644 --- a/include/llvm/CodeGen/CalcSpillWeights.h +++ b/include/llvm/CodeGen/CalcSpillWeights.h @@ -21,7 +21,9 @@ namespace llvm { class MachineBlockFrequencyInfo; class MachineLoopInfo; - /// normalizeSpillWeight - The spill weight of a live interval is computed as: + /// \brief Normalize the spill weight of a live interval + /// + /// The spill weight of a live interval is computed as: /// /// (sum(use freq) + sum(def freq)) / (K + size) /// @@ -38,8 +40,8 @@ namespace llvm { return UseDefFreq / (Size + 25*SlotIndex::InstrDist); } - /// VirtRegAuxInfo - Calculate auxiliary information for a virtual - /// register such as its spill weight and allocation hint. + /// \brief Calculate auxiliary information for a virtual register such as its + /// spill weight and allocation hint. class VirtRegAuxInfo { MachineFunction &MF; LiveIntervals &LIS; @@ -52,29 +54,16 @@ namespace llvm { const MachineBlockFrequencyInfo &mbfi) : MF(mf), LIS(lis), Loops(loops), MBFI(mbfi) {} - /// CalculateWeightAndHint - (re)compute li's spill weight and allocation - /// hint. + /// \brief (re)compute li's spill weight and allocation hint. void CalculateWeightAndHint(LiveInterval &li); }; - /// CalculateSpillWeights - Compute spill weights for all virtual register + /// \brief Compute spill weights and allocation hints for all virtual register /// live intervals. - class CalculateSpillWeights : public MachineFunctionPass { - public: - static char ID; - - CalculateSpillWeights() : MachineFunctionPass(ID) { - initializeCalculateSpillWeightsPass(*PassRegistry::getPassRegistry()); - } - - virtual void getAnalysisUsage(AnalysisUsage &au) const; - - virtual bool runOnMachineFunction(MachineFunction &fn); - - private: - /// Returns true if the given live interval is zero length. - bool isZeroLengthInterval(LiveInterval *li) const; - }; + void calculateSpillWeights(LiveIntervals &LIS, + MachineFunction &MF, + const MachineLoopInfo &MLI, + const MachineBlockFrequencyInfo &MBFI); } diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h index fe26c23..68825a3 100644 --- a/include/llvm/InitializePasses.h +++ b/include/llvm/InitializePasses.h @@ -89,7 +89,6 @@ void initializeCFGSimplifyPassPass(PassRegistry&); void initializeFlattenCFGPassPass(PassRegistry&); void initializeStructurizeCFGPass(PassRegistry&); void initializeCFGViewerPass(PassRegistry&); -void initializeCalculateSpillWeightsPass(PassRegistry&); void initializeCodeGenPreparePass(PassRegistry&); void initializeConstantMergePass(PassRegistry&); void initializeConstantPropagationPass(PassRegistry&); -- cgit v1.1 From 43ed63bc8310758d2a80deecb2e470f383ca5691 Mon Sep 17 00:00:00 2001 From: Pete Cooper Date: Mon, 11 Nov 2013 03:58:00 +0000 Subject: Add LLVM_HAS_INITIALIZER_LISTS for upcoming C++11 support. Use it in ArrayRef git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194362 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/ArrayRef.h | 7 +++++++ include/llvm/Support/Compiler.h | 9 +++++++++ 2 files changed, 16 insertions(+) (limited to 'include') diff --git a/include/llvm/ADT/ArrayRef.h b/include/llvm/ADT/ArrayRef.h index a0b6eff..61467e9 100644 --- a/include/llvm/ADT/ArrayRef.h +++ b/include/llvm/ADT/ArrayRef.h @@ -83,6 +83,13 @@ namespace llvm { /*implicit*/ LLVM_CONSTEXPR ArrayRef(const T (&Arr)[N]) : Data(Arr), Length(N) {} +#if LLVM_HAS_INITIALIZER_LISTS + /// Construct an ArrayRef from a std::initializer_list. + /*implicit*/ ArrayRef(const std::initializer_list &Vec) + : Data(Vec.begin() == Vec.end() ? (T*)0 : Vec.begin()), + Length(Vec.size()) {} +#endif + /// @} /// @name Simple Operations /// @{ diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index 13920fc..5ce9abc 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -403,4 +403,13 @@ # define LLVM_ENUM_INT_TYPE(intty) #endif +/// \brief Does the compiler support generalized initializers (using braced +/// lists and std::initializer_list). +#if (__has_feature(cxx_generalized_initializers) \ +|| defined(__GXX_EXPERIMENTAL_CXX0X__)) +#define LLVM_HAS_INITIALIZER_LISTS 1 +#else +#define LLVM_HAS_INITIALIZER_LISTS 0 +#endif + #endif -- cgit v1.1 From 38fb3fae3445716686b14e771e08a7ef7b27dec1 Mon Sep 17 00:00:00 2001 From: Pete Cooper Date: Mon, 11 Nov 2013 05:14:42 +0000 Subject: Don't universally enable initialiser lists on GCC. Thanks for catching this Chandler git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194365 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Compiler.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/Compiler.h b/include/llvm/Support/Compiler.h index 5ce9abc..860f43e 100644 --- a/include/llvm/Support/Compiler.h +++ b/include/llvm/Support/Compiler.h @@ -405,8 +405,7 @@ /// \brief Does the compiler support generalized initializers (using braced /// lists and std::initializer_list). -#if (__has_feature(cxx_generalized_initializers) \ -|| defined(__GXX_EXPERIMENTAL_CXX0X__)) +#if __has_feature(cxx_generalized_initializers) #define LLVM_HAS_INITIALIZER_LISTS 1 #else #define LLVM_HAS_INITIALIZER_LISTS 0 -- cgit v1.1 From 9683888db61498edc05f37cf8f3a8253e47ba016 Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Mon, 11 Nov 2013 14:47:01 +0000 Subject: [llvm-c] Remove dead typedef git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194379 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Target.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/llvm-c/Target.h b/include/llvm-c/Target.h index f5f2bc4..b465b4b 100644 --- a/include/llvm-c/Target.h +++ b/include/llvm-c/Target.h @@ -41,7 +41,6 @@ enum LLVMByteOrdering { LLVMBigEndian, LLVMLittleEndian }; typedef struct LLVMOpaqueTargetData *LLVMTargetDataRef; typedef struct LLVMOpaqueTargetLibraryInfotData *LLVMTargetLibraryInfoRef; -typedef struct LLVMStructLayout *LLVMStructLayoutRef; /* Declare all of the target-initialization functions that are available. */ #define LLVM_TARGET(TargetName) \ -- cgit v1.1 From 30b2a19f3be840da1bc4aefcaabcbddd2e0130fc Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Mon, 11 Nov 2013 18:04:07 +0000 Subject: [AArch64] Add support for NEON scalar floating-point convert to fixed-point instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194394 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index b66bdcc..0bff987 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -272,6 +272,18 @@ def int_aarch64_neon_vcvtf32_n_u32 : def int_aarch64_neon_vcvtf64_n_u64 : Intrinsic<[llvm_v1f64_ty], [llvm_v1i64_ty, llvm_i32_ty], [IntrNoMem]>; +// Scalar Floating-point Convert To Signed Fixed-point (Immediate) +def int_aarch64_neon_vcvts_n_s32_f32 : + Intrinsic<[llvm_v1i32_ty], [llvm_v1f32_ty, llvm_i32_ty], [IntrNoMem]>; +def int_aarch64_neon_vcvtd_n_s64_f64 : + Intrinsic<[llvm_v1i64_ty], [llvm_v1f64_ty, llvm_i32_ty], [IntrNoMem]>; + +// Scalar Floating-point Convert To Unsigned Fixed-point (Immediate) +def int_aarch64_neon_vcvts_n_u32_f32 : + Intrinsic<[llvm_v1i32_ty], [llvm_v1f32_ty, llvm_i32_ty], [IntrNoMem]>; +def int_aarch64_neon_vcvtd_n_u64_f64 : + Intrinsic<[llvm_v1i64_ty], [llvm_v1f64_ty, llvm_i32_ty], [IntrNoMem]>; + class Neon_SHA_Intrinsic : Intrinsic<[llvm_v4i32_ty], [llvm_v4i32_ty, llvm_v1i32_ty, llvm_v4i32_ty], [IntrNoMem]>; -- cgit v1.1 From 095f994ba63994e8eb4b77127f9b872429496dba Mon Sep 17 00:00:00 2001 From: "Arnaud A. de Grandmaison" Date: Mon, 11 Nov 2013 19:04:45 +0000 Subject: CalcSpillWeights: give a better describing name to calculateSpillWeights Besides, this relates it more obviously to the VirtRegAuxInfo::calculateSpillWeightAndHint. No functionnal change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194404 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/CalcSpillWeights.h | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/CalcSpillWeights.h b/include/llvm/CodeGen/CalcSpillWeights.h index 00d9c6a..60be611 100644 --- a/include/llvm/CodeGen/CalcSpillWeights.h +++ b/include/llvm/CodeGen/CalcSpillWeights.h @@ -55,16 +55,14 @@ namespace llvm { : MF(mf), LIS(lis), Loops(loops), MBFI(mbfi) {} /// \brief (re)compute li's spill weight and allocation hint. - void CalculateWeightAndHint(LiveInterval &li); + void calculateSpillWeightAndHint(LiveInterval &li); }; /// \brief Compute spill weights and allocation hints for all virtual register /// live intervals. - void calculateSpillWeights(LiveIntervals &LIS, - MachineFunction &MF, - const MachineLoopInfo &MLI, - const MachineBlockFrequencyInfo &MBFI); - + void calculateSpillWeightsAndHints(LiveIntervals &LIS, MachineFunction &MF, + const MachineLoopInfo &MLI, + const MachineBlockFrequencyInfo &MBFI); } #endif // LLVM_CODEGEN_CALCSPILLWEIGHTS_H -- cgit v1.1 From 4c433cf673199528b601f664be3d4c121991a7e2 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Mon, 11 Nov 2013 19:11:11 +0000 Subject: [AArch64] The shift right/left and insert immediate builtins expect 3 source operands, a vector, an element to insert, and a shift amount. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194406 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 0bff987..4d54a23 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -255,10 +255,10 @@ def int_aarch64_neon_vqshlu_n : Neon_N2V_Intrinsic; def int_aarch64_neon_vqshlus_n : Neon_N2V_Intrinsic; // Shift Right And Insert (Immediate) -def int_aarch64_neon_vsrid_n : Neon_2Arg_ShiftImm_Intrinsic; +def int_aarch64_neon_vsrid_n : Neon_3Arg_ShiftImm_Intrinsic; // Shift Left And Insert (Immediate) -def int_aarch64_neon_vslid_n : Neon_2Arg_ShiftImm_Intrinsic; +def int_aarch64_neon_vslid_n : Neon_3Arg_ShiftImm_Intrinsic; // Scalar Signed Fixed-point Convert To Floating-Point (Immediate) def int_aarch64_neon_vcvtf32_n_s32 : -- cgit v1.1 From d736763847cee94c40a7f4d106cad91445834b7c Mon Sep 17 00:00:00 2001 From: "Arnaud A. de Grandmaison" Date: Mon, 11 Nov 2013 19:56:14 +0000 Subject: CalcSpillWeights: allow overidding the spill weight normalizing function This will enable the PBQP register allocator to provide its own normalizing function. No functionnal change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194417 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/CalcSpillWeights.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/CalcSpillWeights.h b/include/llvm/CodeGen/CalcSpillWeights.h index 60be611..0d79b1d 100644 --- a/include/llvm/CodeGen/CalcSpillWeights.h +++ b/include/llvm/CodeGen/CalcSpillWeights.h @@ -43,16 +43,23 @@ namespace llvm { /// \brief Calculate auxiliary information for a virtual register such as its /// spill weight and allocation hint. class VirtRegAuxInfo { + public: + typedef float (*NormalizingFn)(float, unsigned); + + private: MachineFunction &MF; LiveIntervals &LIS; const MachineLoopInfo &Loops; const MachineBlockFrequencyInfo &MBFI; DenseMap Hint; + NormalizingFn normalize; + public: VirtRegAuxInfo(MachineFunction &mf, LiveIntervals &lis, const MachineLoopInfo &loops, - const MachineBlockFrequencyInfo &mbfi) - : MF(mf), LIS(lis), Loops(loops), MBFI(mbfi) {} + const MachineBlockFrequencyInfo &mbfi, + NormalizingFn norm = normalizeSpillWeight) + : MF(mf), LIS(lis), Loops(loops), MBFI(mbfi), normalize(norm) {} /// \brief (re)compute li's spill weight and allocation hint. void calculateSpillWeightAndHint(LiveInterval &li); @@ -62,7 +69,9 @@ namespace llvm { /// live intervals. void calculateSpillWeightsAndHints(LiveIntervals &LIS, MachineFunction &MF, const MachineLoopInfo &MLI, - const MachineBlockFrequencyInfo &MBFI); + const MachineBlockFrequencyInfo &MBFI, + VirtRegAuxInfo::NormalizingFn norm = + normalizeSpillWeight); } #endif // LLVM_CODEGEN_CALCSPILLWEIGHTS_H -- cgit v1.1 From 3cda2d38851d73eec38d38a46462aaa65de4ef8e Mon Sep 17 00:00:00 2001 From: Wan Xiaofei Date: Tue, 12 Nov 2013 09:40:41 +0000 Subject: Change data structure to memorize computed result in ScalarEvolution Replace std::map with SmallVector to memorize the cached result since SCEV usually belongs to little Loop/BB Linear scan on SmallVector is faster than std::map. Code reviewer : Andrew Trick. Test result : Pass Unit Test & LLVM Test Suite 401.bzip2 0.425721 0.419981 101.37% 403.gcc 24.53855 24.2667 101.12% 429.mcf 0.060847 0.059944 101.51% 433.milc 0.646009 0.636119 101.55% 444.namd 1.383928 1.370614 100.97% 445.gobmk 5.836575 5.800225 100.63% 450.soplex 1.911257 1.895963 100.81% 456.hmmer 1.039565 1.032534 100.68% 458.sjeng 0.897401 0.885567 101.34% 464.h264ref 3.645908 3.577991 101.90% 470.lbm 0.049456 0.048398 102.19% 471.omnetpp 5.638575 5.60435 100.61% bitmnp01 0.045738 0.045291 100.99% cjpegv2data 0.304359 0.302833 100.50% idctrn01 0.046433 0.045763 101.46% quake2 4.534416 4.4952 100.87% quake 2.688566 2.659208 101.10% xcsoar 12.42545 12.30385 100.99% linpack 0.038739 0.03803 101.86% matrix01 0.053564 0.0528 101.45% nbench 0.402867 0.395803 101.78% tblook01 0.021265 0.021015 101.19% ttsprk01 0.066384 0.065566 101.25% git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194459 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/ScalarEvolution.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h index 4915bc6..944b144 100644 --- a/include/llvm/Analysis/ScalarEvolution.h +++ b/include/llvm/Analysis/ScalarEvolution.h @@ -361,18 +361,18 @@ namespace llvm { /// that we attempt to compute getSCEVAtScope information for, which can /// be expensive in extreme cases. DenseMap > ValuesAtScopes; + SmallVector, 2> > ValuesAtScopes; /// LoopDispositions - Memoized computeLoopDisposition results. DenseMap > LoopDispositions; + SmallVector, 2> > LoopDispositions; /// computeLoopDisposition - Compute a LoopDisposition value. LoopDisposition computeLoopDisposition(const SCEV *S, const Loop *L); /// BlockDispositions - Memoized computeBlockDisposition results. DenseMap > BlockDispositions; + SmallVector, 2> > BlockDispositions; /// computeBlockDisposition - Compute a BlockDisposition value. BlockDisposition computeBlockDisposition(const SCEV *S, const BasicBlock *BB); -- cgit v1.1 From 67a404dc26ce29338375ad627333a1af082d70d6 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 12 Nov 2013 16:31:59 +0000 Subject: Remove unused variable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194485 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/YAMLTraits.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h index 98964fc..a8319a6 100644 --- a/include/llvm/Support/YAMLTraits.h +++ b/include/llvm/Support/YAMLTraits.h @@ -1069,7 +1069,6 @@ operator<<(Output &yout, T &seq) { seq.resize(index+1); \ return seq[index]; \ } \ - static const bool flow = true; \ }; \ } \ } -- cgit v1.1 From c47adf8db2cbe21f5de0a955b8ef89f177c9ad16 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 12 Nov 2013 16:37:31 +0000 Subject: Revert "Remove unused variable." This reverts commit r194485. The variable is unused in some macro instantiations, but not others. We should probably fix clang to not warn on this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194486 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/YAMLTraits.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h index a8319a6..98964fc 100644 --- a/include/llvm/Support/YAMLTraits.h +++ b/include/llvm/Support/YAMLTraits.h @@ -1069,6 +1069,7 @@ operator<<(Output &yout, T &seq) { seq.resize(index+1); \ return seq[index]; \ } \ + static const bool flow = true; \ }; \ } \ } -- cgit v1.1 From 4be0c592c42739b1927aaf2a20b3fabbf6adf335 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Tue, 12 Nov 2013 18:06:06 +0000 Subject: whitespace git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194495 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/CFGPrinter.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/llvm/Analysis/CFGPrinter.h b/include/llvm/Analysis/CFGPrinter.h index fa596c3..6977374 100644 --- a/include/llvm/Analysis/CFGPrinter.h +++ b/include/llvm/Analysis/CFGPrinter.h @@ -44,7 +44,7 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { return OS.str(); } - static std::string getCompleteNodeLabel(const BasicBlock *Node, + static std::string getCompleteNodeLabel(const BasicBlock *Node, const Function *) { std::string Str; raw_string_ostream OS(Str); @@ -86,20 +86,20 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { if (const BranchInst *BI = dyn_cast(Node->getTerminator())) if (BI->isConditional()) return (I == succ_begin(Node)) ? "T" : "F"; - + // Label source of switch edges with the associated value. if (const SwitchInst *SI = dyn_cast(Node->getTerminator())) { unsigned SuccNo = I.getSuccessorIndex(); if (SuccNo == 0) return "def"; - + std::string Str; raw_string_ostream OS(Str); SwitchInst::ConstCaseIt Case = - SwitchInst::ConstCaseIt::fromSuccessorIndex(SI, SuccNo); + SwitchInst::ConstCaseIt::fromSuccessorIndex(SI, SuccNo); OS << Case.getCaseValue()->getValue(); return OS.str(); - } + } return ""; } }; -- cgit v1.1 From 2f08e75a45b9fa698a49277f6cc11e041bf5fa51 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Tue, 12 Nov 2013 18:06:09 +0000 Subject: GraphViz CFGPrinter: wrap long lines. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194496 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/CFGPrinter.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Analysis/CFGPrinter.h b/include/llvm/Analysis/CFGPrinter.h index 6977374..39e90eb 100644 --- a/include/llvm/Analysis/CFGPrinter.h +++ b/include/llvm/Analysis/CFGPrinter.h @@ -46,6 +46,7 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { static std::string getCompleteNodeLabel(const BasicBlock *Node, const Function *) { + enum { MaxColumns = 80 }; std::string Str; raw_string_ostream OS(Str); @@ -59,16 +60,32 @@ struct DOTGraphTraits : public DefaultDOTGraphTraits { if (OutStr[0] == '\n') OutStr.erase(OutStr.begin()); // Process string output to make it nicer... - for (unsigned i = 0; i != OutStr.length(); ++i) + unsigned ColNum = 0; + unsigned LastSpace = 0; + for (unsigned i = 0; i != OutStr.length(); ++i) { if (OutStr[i] == '\n') { // Left justify OutStr[i] = '\\'; OutStr.insert(OutStr.begin()+i+1, 'l'); + ColNum = 0; + LastSpace = 0; } else if (OutStr[i] == ';') { // Delete comments! unsigned Idx = OutStr.find('\n', i+1); // Find end of line OutStr.erase(OutStr.begin()+i, OutStr.begin()+Idx); --i; + } else if (ColNum == MaxColumns) { // Wrap lines. + if (LastSpace) { + OutStr.insert(LastSpace, "\\l..."); + ColNum = i - LastSpace; + LastSpace = 0; + i += 3; // The loop will advance 'i' again. + } + // Else keep trying to find a space. } - + else + ++ColNum; + if (OutStr[i] == ' ') + LastSpace = i; + } return OutStr; } -- cgit v1.1 From 72c84a8294a061208d2dc76caf282d83b0f84549 Mon Sep 17 00:00:00 2001 From: Weiming Zhao Date: Tue, 12 Nov 2013 19:57:43 +0000 Subject: Export intrinsics:__builtin_arm_{dmb,dsb} to frontend git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194505 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsARM.td | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsARM.td b/include/llvm/IR/IntrinsicsARM.td index 2d82735..0b50d64 100644 --- a/include/llvm/IR/IntrinsicsARM.td +++ b/include/llvm/IR/IntrinsicsARM.td @@ -46,8 +46,8 @@ def int_arm_ldrexd : Intrinsic<[llvm_i32_ty, llvm_i32_ty], [llvm_ptr_ty]>; //===----------------------------------------------------------------------===// // Data barrier instructions -def int_arm_dmb : Intrinsic<[], [llvm_i32_ty]>; -def int_arm_dsb : Intrinsic<[], [llvm_i32_ty]>; +def int_arm_dmb : GCCBuiltin<"__builtin_arm_dmb">, Intrinsic<[], [llvm_i32_ty]>; +def int_arm_dsb : GCCBuiltin<"__builtin_arm_dsb">, Intrinsic<[], [llvm_i32_ty]>; //===----------------------------------------------------------------------===// // VFP -- cgit v1.1 From dc6b4b4fc2665eea17684d29e4dae219b258b5ef Mon Sep 17 00:00:00 2001 From: Justin Bogner Date: Tue, 12 Nov 2013 21:44:01 +0000 Subject: Protect user-supplied runtime library functions in LTO Add user-supplied C runtime and compiler-rt library functions to llvm.compiler.used to protect them from premature optimization by passes like -globalopt and -ipsccp. Calls to (seemingly unused) runtime library functions can be added by -instcombine and instruction lowering. Patch by Duncan Exon Smith, thanks! Fixes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194514 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/LTO/LTOCodeGenerator.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm/LTO/LTOCodeGenerator.h b/include/llvm/LTO/LTOCodeGenerator.h index 97a5066..c478bd9 100644 --- a/include/llvm/LTO/LTOCodeGenerator.h +++ b/include/llvm/LTO/LTOCodeGenerator.h @@ -38,6 +38,7 @@ #include "llvm-c/lto.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/StringMap.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/Linker.h" #include "llvm/Target/TargetOptions.h" #include @@ -48,6 +49,7 @@ namespace llvm { class GlobalValue; class Mangler; class MemoryBuffer; + class TargetLibraryInfo; class TargetMachine; class raw_ostream; } @@ -125,6 +127,7 @@ private: std::string &errMsg); void applyScopeRestrictions(); void applyRestriction(llvm::GlobalValue &GV, + const llvm::ArrayRef &Libcalls, std::vector &MustPreserveList, llvm::SmallPtrSet &AsmUsed, llvm::Mangler &Mangler); -- cgit v1.1 From b8fc659c8eb36796531d55fa78cbb1957895aa9b Mon Sep 17 00:00:00 2001 From: Sebastian Pop Date: Tue, 12 Nov 2013 22:47:05 +0000 Subject: remove virtual methods in SCEVApplyRewriter and SCEVParameterRewriter git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194526 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/ScalarEvolutionExpressions.h | 140 ++++++++++++++------- 1 file changed, 94 insertions(+), 46 deletions(-) (limited to 'include') diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h index eac9113..1fc03be 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -549,53 +549,60 @@ namespace llvm { T.visitAll(Root); } - /// The SCEVRewriter takes a scalar evolution expression and copies all its - /// components. The result after a rewrite is an identical SCEV. - struct SCEVRewriter - : public SCEVVisitor { + typedef DenseMap ValueToValueMap; + + /// The SCEVParameterRewriter takes a scalar evolution expression and updates + /// the SCEVUnknown components following the Map (Value -> Value). + struct SCEVParameterRewriter + : public SCEVVisitor { public: - SCEVRewriter(ScalarEvolution &S) : SE(S) {} + static const SCEV *rewrite(const SCEV *Scev, ScalarEvolution &SE, + ValueToValueMap &Map) { + SCEVParameterRewriter Rewriter(SE, Map); + return Rewriter.visit(Scev); + } - virtual ~SCEVRewriter() {} + SCEVParameterRewriter(ScalarEvolution &S, ValueToValueMap &M) + : SE(S), Map(M) {} - virtual const SCEV *visitConstant(const SCEVConstant *Constant) { + const SCEV *visitConstant(const SCEVConstant *Constant) { return Constant; } - virtual const SCEV *visitTruncateExpr(const SCEVTruncateExpr *Expr) { + const SCEV *visitTruncateExpr(const SCEVTruncateExpr *Expr) { const SCEV *Operand = visit(Expr->getOperand()); return SE.getTruncateExpr(Operand, Expr->getType()); } - virtual const SCEV *visitZeroExtendExpr(const SCEVZeroExtendExpr *Expr) { + const SCEV *visitZeroExtendExpr(const SCEVZeroExtendExpr *Expr) { const SCEV *Operand = visit(Expr->getOperand()); return SE.getZeroExtendExpr(Operand, Expr->getType()); } - virtual const SCEV *visitSignExtendExpr(const SCEVSignExtendExpr *Expr) { + const SCEV *visitSignExtendExpr(const SCEVSignExtendExpr *Expr) { const SCEV *Operand = visit(Expr->getOperand()); return SE.getSignExtendExpr(Operand, Expr->getType()); } - virtual const SCEV *visitAddExpr(const SCEVAddExpr *Expr) { + const SCEV *visitAddExpr(const SCEVAddExpr *Expr) { SmallVector Operands; for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) Operands.push_back(visit(Expr->getOperand(i))); return SE.getAddExpr(Operands); } - virtual const SCEV *visitMulExpr(const SCEVMulExpr *Expr) { + const SCEV *visitMulExpr(const SCEVMulExpr *Expr) { SmallVector Operands; for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) Operands.push_back(visit(Expr->getOperand(i))); return SE.getMulExpr(Operands); } - virtual const SCEV *visitUDivExpr(const SCEVUDivExpr *Expr) { + const SCEV *visitUDivExpr(const SCEVUDivExpr *Expr) { return SE.getUDivExpr(visit(Expr->getLHS()), visit(Expr->getRHS())); } - virtual const SCEV *visitAddRecExpr(const SCEVAddRecExpr *Expr) { + const SCEV *visitAddRecExpr(const SCEVAddRecExpr *Expr) { SmallVector Operands; for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) Operands.push_back(visit(Expr->getOperand(i))); @@ -603,54 +610,33 @@ namespace llvm { Expr->getNoWrapFlags()); } - virtual const SCEV *visitSMaxExpr(const SCEVSMaxExpr *Expr) { + const SCEV *visitSMaxExpr(const SCEVSMaxExpr *Expr) { SmallVector Operands; for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) Operands.push_back(visit(Expr->getOperand(i))); return SE.getSMaxExpr(Operands); } - virtual const SCEV *visitUMaxExpr(const SCEVUMaxExpr *Expr) { + const SCEV *visitUMaxExpr(const SCEVUMaxExpr *Expr) { SmallVector Operands; for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) Operands.push_back(visit(Expr->getOperand(i))); return SE.getUMaxExpr(Operands); } - virtual const SCEV *visitUnknown(const SCEVUnknown *Expr) { - return Expr; - } - - virtual const SCEV *visitCouldNotCompute(const SCEVCouldNotCompute *Expr) { - return Expr; - } - - protected: - ScalarEvolution &SE; - }; - - typedef DenseMap ValueToValueMap; - - /// The SCEVParameterRewriter takes a scalar evolution expression and updates - /// the SCEVUnknown components following the Map (Value -> Value). - struct SCEVParameterRewriter: public SCEVRewriter { - public: - static const SCEV *rewrite(const SCEV *Scev, ScalarEvolution &SE, - ValueToValueMap &Map) { - SCEVParameterRewriter Rewriter(SE, Map); - return Rewriter.visit(Scev); - } - SCEVParameterRewriter(ScalarEvolution &S, ValueToValueMap &M) - : SCEVRewriter(S), Map(M) {} - - virtual const SCEV *visitUnknown(const SCEVUnknown *Expr) { + const SCEV *visitUnknown(const SCEVUnknown *Expr) { Value *V = Expr->getValue(); if (Map.count(V)) return SE.getUnknown(Map[V]); return Expr; } + const SCEV *visitCouldNotCompute(const SCEVCouldNotCompute *Expr) { + return Expr; + } + private: + ScalarEvolution &SE; ValueToValueMap ⤅ }; @@ -658,17 +644,56 @@ namespace llvm { /// The SCEVApplyRewriter takes a scalar evolution expression and applies /// the Map (Loop -> SCEV) to all AddRecExprs. - struct SCEVApplyRewriter: public SCEVRewriter { + struct SCEVApplyRewriter + : public SCEVVisitor { public: static const SCEV *rewrite(const SCEV *Scev, LoopToScevMapT &Map, ScalarEvolution &SE) { SCEVApplyRewriter Rewriter(SE, Map); return Rewriter.visit(Scev); } + SCEVApplyRewriter(ScalarEvolution &S, LoopToScevMapT &M) - : SCEVRewriter(S), Map(M) {} + : SE(S), Map(M) {} + + const SCEV *visitConstant(const SCEVConstant *Constant) { + return Constant; + } + + const SCEV *visitTruncateExpr(const SCEVTruncateExpr *Expr) { + const SCEV *Operand = visit(Expr->getOperand()); + return SE.getTruncateExpr(Operand, Expr->getType()); + } + + const SCEV *visitZeroExtendExpr(const SCEVZeroExtendExpr *Expr) { + const SCEV *Operand = visit(Expr->getOperand()); + return SE.getZeroExtendExpr(Operand, Expr->getType()); + } + + const SCEV *visitSignExtendExpr(const SCEVSignExtendExpr *Expr) { + const SCEV *Operand = visit(Expr->getOperand()); + return SE.getSignExtendExpr(Operand, Expr->getType()); + } + + const SCEV *visitAddExpr(const SCEVAddExpr *Expr) { + SmallVector Operands; + for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) + Operands.push_back(visit(Expr->getOperand(i))); + return SE.getAddExpr(Operands); + } - virtual const SCEV *visitAddRecExpr(const SCEVAddRecExpr *Expr) { + const SCEV *visitMulExpr(const SCEVMulExpr *Expr) { + SmallVector Operands; + for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) + Operands.push_back(visit(Expr->getOperand(i))); + return SE.getMulExpr(Operands); + } + + const SCEV *visitUDivExpr(const SCEVUDivExpr *Expr) { + return SE.getUDivExpr(visit(Expr->getLHS()), visit(Expr->getRHS())); + } + + const SCEV *visitAddRecExpr(const SCEVAddRecExpr *Expr) { SmallVector Operands; for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) Operands.push_back(visit(Expr->getOperand(i))); @@ -683,7 +708,30 @@ namespace llvm { return Rec->evaluateAtIteration(Map[L], SE); } + const SCEV *visitSMaxExpr(const SCEVSMaxExpr *Expr) { + SmallVector Operands; + for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) + Operands.push_back(visit(Expr->getOperand(i))); + return SE.getSMaxExpr(Operands); + } + + const SCEV *visitUMaxExpr(const SCEVUMaxExpr *Expr) { + SmallVector Operands; + for (int i = 0, e = Expr->getNumOperands(); i < e; ++i) + Operands.push_back(visit(Expr->getOperand(i))); + return SE.getUMaxExpr(Operands); + } + + const SCEV *visitUnknown(const SCEVUnknown *Expr) { + return Expr; + } + + const SCEV *visitCouldNotCompute(const SCEVCouldNotCompute *Expr) { + return Expr; + } + private: + ScalarEvolution &SE; LoopToScevMapT ⤅ }; -- cgit v1.1 From 5230ad61fd35d3006e7764c3152d28e2e68c288f Mon Sep 17 00:00:00 2001 From: Sebastian Pop Date: Tue, 12 Nov 2013 22:47:20 +0000 Subject: delinearization of arrays git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194527 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/DependenceAnalysis.h | 4 ++++ include/llvm/Analysis/Passes.h | 7 +++++++ include/llvm/Analysis/ScalarEvolutionExpressions.h | 8 +++++++- include/llvm/InitializePasses.h | 1 + 4 files changed, 19 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Analysis/DependenceAnalysis.h b/include/llvm/Analysis/DependenceAnalysis.h index 8fce2f6..ea8cecf 100644 --- a/include/llvm/Analysis/DependenceAnalysis.h +++ b/include/llvm/Analysis/DependenceAnalysis.h @@ -908,6 +908,10 @@ namespace llvm { /// based on the current constraint. void updateDirection(Dependence::DVEntry &Level, const Constraint &CurConstraint) const; + + bool tryDelinearize(const SCEV *SrcSCEV, const SCEV *DstSCEV, + SmallVectorImpl &Pair) const; + public: static char ID; // Class identification, replacement for typeinfo DependenceAnalysis() : FunctionPass(ID) { diff --git a/include/llvm/Analysis/Passes.h b/include/llvm/Analysis/Passes.h index 0b4e96f..a5d098e 100644 --- a/include/llvm/Analysis/Passes.h +++ b/include/llvm/Analysis/Passes.h @@ -136,6 +136,13 @@ namespace llvm { //===--------------------------------------------------------------------===// // + // createDelinearizationPass - This pass implements attempts to restore + // multidimensional array indices from linearized expressions. + // + FunctionPass *createDelinearizationPass(); + + //===--------------------------------------------------------------------===// + // // Minor pass prototypes, allowing us to expose them through bugpoint and // analyze. FunctionPass *createInstCountPass(); diff --git a/include/llvm/Analysis/ScalarEvolutionExpressions.h b/include/llvm/Analysis/ScalarEvolutionExpressions.h index 1fc03be..9cd902a 100644 --- a/include/llvm/Analysis/ScalarEvolutionExpressions.h +++ b/include/llvm/Analysis/ScalarEvolutionExpressions.h @@ -351,8 +351,14 @@ namespace llvm { static inline bool classof(const SCEV *S) { return S->getSCEVType() == scAddRecExpr; } - }; + /// Splits the SCEV into two vectors of SCEVs representing the subscripts + /// and sizes of an array access. Returns the remainder of the + /// delinearization that is the offset start of the array. + const SCEV *delinearize(ScalarEvolution &SE, + SmallVectorImpl &Subscripts, + SmallVectorImpl &Sizes) const; + }; //===--------------------------------------------------------------------===// /// SCEVSMaxExpr - This class represents a signed maximum selection. diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h index 68825a3..c650a6d 100644 --- a/include/llvm/InitializePasses.h +++ b/include/llvm/InitializePasses.h @@ -102,6 +102,7 @@ void initializeDSEPass(PassRegistry&); void initializeDebugIRPass(PassRegistry&); void initializeDeadInstEliminationPass(PassRegistry&); void initializeDeadMachineInstructionElimPass(PassRegistry&); +void initializeDelinearizationPass(PassRegistry &); void initializeDependenceAnalysisPass(PassRegistry&); void initializeDomOnlyPrinterPass(PassRegistry&); void initializeDomOnlyViewerPass(PassRegistry&); -- cgit v1.1 From 328066513d18acd4e44ad57172c73f1a2a026022 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Tue, 12 Nov 2013 23:27:08 +0000 Subject: Remove always true flag. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194530 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAsmInfo.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h index 0c2bc4c..3da3a31 100644 --- a/include/llvm/MC/MCAsmInfo.h +++ b/include/llvm/MC/MCAsmInfo.h @@ -160,10 +160,6 @@ namespace llvm { /// names. Defaults to false. bool AllowAtInName; - /// AllowUTF8 - This is true if the assembler accepts UTF-8 input. - // FIXME: Make this a more general encoding setting? - bool AllowUTF8; - /// UseDataRegionDirectives - This is true if data region markers should /// be printed as ".data_region/.end_data_region" directives. If false, /// use "$d/$a" labels instead. @@ -483,9 +479,6 @@ namespace llvm { bool doesAllowAtInName() const { return AllowAtInName; } - bool doesAllowUTF8() const { - return AllowUTF8; - } bool doesSupportDataRegionDirectives() const { return UseDataRegionDirectives; } -- cgit v1.1 From eb3602472026dc029beb45ccbe09bc84162ba949 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 13 Nov 2013 00:15:44 +0000 Subject: Replacing HUGE_VALF with llvm::huge_valf in order to work around a warning triggered in MSVC 12. Patch reviewed by Reid Kleckner and Jim Grosbach. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194533 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/LiveInterval.h | 4 ++-- include/llvm/Support/MathExtras.h | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/LiveInterval.h b/include/llvm/CodeGen/LiveInterval.h index 1b30bf5..3a9fef6 100644 --- a/include/llvm/CodeGen/LiveInterval.h +++ b/include/llvm/CodeGen/LiveInterval.h @@ -541,12 +541,12 @@ namespace llvm { /// isSpillable - Can this interval be spilled? bool isSpillable() const { - return weight != HUGE_VALF; + return weight != llvm::huge_valf; } /// markNotSpillable - Mark interval as not spillable void markNotSpillable() { - weight = HUGE_VALF; + weight = llvm::huge_valf; } bool operator<(const LiveInterval& other) const { diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h index 00c6ad7..17cf475 100644 --- a/include/llvm/Support/MathExtras.h +++ b/include/llvm/Support/MathExtras.h @@ -21,7 +21,8 @@ #include #ifdef _MSC_VER -# include +#include +#include #endif namespace llvm { @@ -603,6 +604,17 @@ 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::infinity(); + const double huge_vald = std::numeric_limits::infinity(); + const long double huge_vall = std::numeric_limits::infinity(); +#else + const float huge_valf = HUGE_VALF; + const double huge_vald = HUGE_VALD; + const long double huge_vall = HUGE_VALL; +#endif } // End llvm namespace #endif -- cgit v1.1 From 20d7ed198978f871e91fde66e3b9a4a73a7c5396 Mon Sep 17 00:00:00 2001 From: Aaron Ballman Date: Wed, 13 Nov 2013 00:20:43 +0000 Subject: Removing llvm::huge_vald and llvm::huge_vall because they are not currently used, and HUGE_VALD does not appear to be supported everywhere anyways. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194535 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/MathExtras.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/MathExtras.h b/include/llvm/Support/MathExtras.h index 17cf475..ff41608 100644 --- a/include/llvm/Support/MathExtras.h +++ b/include/llvm/Support/MathExtras.h @@ -608,12 +608,8 @@ inline int64_t SignExtend64(uint64_t X, unsigned B) { // 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::infinity(); - const double huge_vald = std::numeric_limits::infinity(); - const long double huge_vall = std::numeric_limits::infinity(); #else const float huge_valf = HUGE_VALF; - const double huge_vald = HUGE_VALD; - const long double huge_vall = HUGE_VALL; #endif } // End llvm namespace -- cgit v1.1 From f348c9782c5c31309dfd2d04e3dbee21fefe07ff Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Wed, 13 Nov 2013 01:12:08 +0000 Subject: Introduce an AnalysisManager which is like a pass manager but with a lot more smarts in it. This is where most of the interesting logic that used to live in the implicit-scheduling-hackery of the old pass manager will live. Like the previous commits, note that this is a very early prototype! I expect substantial changes before this is ready to use. The core of the design is the following: - We have an AnalysisManager which can be used across a series of passes over a module. - The code setting up a pass pipeline registers the analyses available with the manager. - Individual transform passes can check than an analysis manager provides the analyses they require in order to fail-fast. - There is *no* implicit registration or scheduling. - Analysis passes are different from other passes: they produce an analysis result that is cached and made available via the analysis manager. - Cached results are invalidated automatically by the pass managers. - When a transform pass requests an analysis result, either the analysis is run to produce the result or a cached result is provided. There are a few aspects of this design that I *know* will change in subsequent commits: - Currently there is no "preservation" system, that needs to be added. - All of the analysis management should move up to the analysis library. - The analysis management needs to support at least SCC passes. Maybe loop passes. Living in the analysis library will facilitate this. - Need support for analyses which are *both* module and function passes. - Need support for pro-actively running module analyses to have cached results within a function pass manager. - Need a clear design for "immutable" passes. - Need support for requesting cached results when available and not re-running the pass even if that would be necessary. - Need more thorough testing of all of this infrastructure. There are other aspects that I view as open questions I'm hoping to resolve as I iterate a bit on the infrastructure, and especially as I start writing actual passes against this. - Should we have separate management layers for function, module, and SCC analyses? I think "yes", but I'm not yet ready to switch the code. Adding SCC support will likely resolve this definitively. - How should the 'require' functionality work? Should *that* be the only way to request results to ensure that passes always require things? - How should preservation work? - Probably some other things I'm forgetting. =] Look forward to more patches in shorter order now that this is in place. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194538 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/PassManager.h | 306 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 294 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h index aeadd41..5800e35 100644 --- a/include/llvm/IR/PassManager.h +++ b/include/llvm/IR/PassManager.h @@ -27,8 +27,12 @@ /// //===----------------------------------------------------------------------===// +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/polymorphic_ptr.h" +#include "llvm/Support/type_traits.h" +#include "llvm/IR/Function.h" #include "llvm/IR/Module.h" +#include #include namespace llvm { @@ -64,18 +68,17 @@ template struct PassModel : PassConcept { } +class AnalysisManager; + class ModulePassManager { public: - ModulePassManager(Module *M) : M(M) {} + ModulePassManager(Module *M, AnalysisManager *AM = 0) : M(M), AM(AM) {} template void addPass(ModulePassT Pass) { Passes.push_back(new ModulePassModel(llvm_move(Pass))); } - void run() { - for (unsigned Idx = 0, Size = Passes.size(); Idx != Size; ++Idx) - Passes[Idx]->run(M); - } + void run(); private: // Pull in the concept type and model template specialized for modules. @@ -86,22 +89,19 @@ private: }; Module *M; + AnalysisManager *AM; std::vector > Passes; }; class FunctionPassManager { public: + FunctionPassManager(AnalysisManager *AM = 0) : AM(AM) {} + template void addPass(FunctionPassT Pass) { Passes.push_back(new FunctionPassModel(llvm_move(Pass))); } - bool run(Module *M) { - bool Changed = false; - for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) - for (unsigned Idx = 0, Size = Passes.size(); Idx != Size; ++Idx) - Changed |= Passes[Idx]->run(I); - return Changed; - } + bool run(Module *M); private: // Pull in the concept type and model template specialized for functions. @@ -112,7 +112,289 @@ private: : detail::PassModel(Pass) {} }; + AnalysisManager *AM; std::vector > Passes; }; + +/// \brief An analysis manager to coordinate and cache analyses run over +/// a module. +/// +/// The analysis manager is typically used by passes in a pass pipeline +/// (consisting potentially of several individual pass managers) over a module +/// of IR. It provides registration of available analyses, declaring +/// requirements on support for specific analyses, running of an specific +/// analysis over a specific unit of IR to compute an analysis result, and +/// caching of the analysis results to reuse them across multiple passes. +/// +/// It is the responsibility of callers to use the invalidation API to +/// invalidate analysis results when the IR they correspond to changes. The +/// \c ModulePassManager and \c FunctionPassManager do this automatically. +class AnalysisManager { +public: + AnalysisManager(Module *M) : M(M) {} + + /// \brief Get the result of an analysis pass for this module. + /// + /// If there is not a valid cached result in the manager already, this will + /// re-run the analysis to produce a valid result. + /// + /// The module passed in must be the same module as the analysis manager was + /// constructed around. + template + const typename PassT::Result &getResult(Module *M) { + const AnalysisResultConcept &ResultConcept = + getResultImpl(PassT::ID(), M); + typedef AnalysisResultModel ResultModelT; + return static_cast(ResultConcept).Result; + } + + /// \brief Get the result of an analysis pass for a function. + /// + /// If there is not a valid cached result in the manager already, this will + /// re-run the analysis to produce a valid result. + template + const typename PassT::Result &getResult(Function *F) { + const AnalysisResultConcept &ResultConcept = + getResultImpl(PassT::ID(), F); + typedef AnalysisResultModel ResultModelT; + return static_cast(ResultConcept).Result; + } + + /// \brief Register an analysis pass with the manager. + /// + /// This provides an initialized and set-up analysis pass to the + /// analysis + /// manager. Whomever is setting up analysis passes must use this to + /// populate + /// the manager with all of the analysis passes available. + template void registerAnalysisPass(PassT Pass) { + registerAnalysisPassImpl(llvm_move(Pass)); + } + + /// \brief Require that a particular analysis pass is provided by the manager. + /// + /// This allows transform passes to assert ther requirements during + /// construction and fail fast if the analysis manager doesn't provide the + /// needed facilities. + /// + /// We force the analysis manager to have these passes explicitly registered + /// first to ensure that there is exactly one place in the code responsible + /// for adding an analysis pass to the manager as all transforms will share + /// a single pass within the manager and each may not be the canonical place + /// to initialize such a pass. + template void requireAnalysisPass() { + requireAnalysisPassImpl(); + } + + /// \brief Invalidate a specific analysis pass for an IR module. + /// + /// Note that the analysis result can disregard invalidation. + template void invalidate(Module *M) { + invalidateImpl(PassT::ID(), M); + } + + /// \brief Invalidate a specific analysis pass for an IR function. + /// + /// Note that the analysis result can disregard invalidation. + template void invalidate(Function *F) { + invalidateImpl(PassT::ID(), F); + } + + /// \brief Invalidate analyses cached for an IR Module. + /// + /// Note that specific analysis results can disregard invalidation by + /// overriding their invalidate method. + /// + /// The module must be the module this analysis manager was constructed + /// around. + void invalidateAll(Module *M); + + /// \brief Invalidate analyses cached for an IR Function. + /// + /// Note that specific analysis results can disregard invalidation by + /// overriding the invalidate method. + void invalidateAll(Function *F); + +private: + /// \brief Abstract concept of an analysis result. + /// + /// This concept is parameterized over the IR unit that this result pertains + /// to. + template struct AnalysisResultConcept { + virtual ~AnalysisResultConcept() {} + virtual AnalysisResultConcept *clone() = 0; + + /// \brief Method to try and mark a result as invalid. + /// + /// When the outer \c AnalysisManager detects a change in some underlying + /// unit of the IR, it will call this method on all of the results cached. + /// + /// \returns true if the result should indeed be invalidated (the default). + virtual bool invalidate(IRUnitT *IR) = 0; + }; + + /// \brief Wrapper to model the analysis result concept. + /// + /// Can wrap any type which implements a suitable invalidate member and model + /// the AnalysisResultConcept for the AnalysisManager. + template + struct AnalysisResultModel : AnalysisResultConcept { + AnalysisResultModel(ResultT Result) : Result(llvm_move(Result)) {} + virtual AnalysisResultModel *clone() { + return new AnalysisResultModel(Result); + } + + /// \brief The model delegates to the \c ResultT method. + virtual bool invalidate(IRUnitT *IR) { return Result.invalidate(IR); } + + ResultT Result; + }; + + /// \brief Abstract concept of an analysis pass. + /// + /// This concept is parameterized over the IR unit that it can run over and + /// produce an analysis result. + template struct AnalysisPassConcept { + virtual ~AnalysisPassConcept() {} + virtual AnalysisPassConcept *clone() = 0; + + /// \brief Method to run this analysis over a unit of IR. + /// \returns The analysis result object to be queried by users, the caller + /// takes ownership. + virtual AnalysisResultConcept *run(IRUnitT *IR) = 0; + }; + + /// \brief Wrapper to model the analysis pass concept. + /// + /// Can wrap any type which implements a suitable \c run method. The method + /// must accept the IRUnitT as an argument and produce an object which can be + /// wrapped in a \c AnalysisResultModel. + template + struct AnalysisPassModel : AnalysisPassConcept { + AnalysisPassModel(PassT Pass) : Pass(llvm_move(Pass)) {} + virtual AnalysisPassModel *clone() { return new AnalysisPassModel(Pass); } + + // FIXME: Replace PassT::IRUnitT with type traits when we use C++11. + typedef typename PassT::IRUnitT IRUnitT; + + // FIXME: Replace PassT::Result with type traits when we use C++11. + typedef AnalysisResultModel ResultModelT; + + /// \brief The model delegates to the \c PassT::run method. + /// + /// The return is wrapped in an \c AnalysisResultModel. + virtual ResultModelT *run(IRUnitT *IR) { + return new ResultModelT(Pass.run(IR)); + } + + PassT Pass; + }; + + + /// \brief Get a module pass result, running the pass if necessary. + const AnalysisResultConcept &getResultImpl(void *PassID, Module *M); + + /// \brief Get a function pass result, running the pass if necessary. + const AnalysisResultConcept &getResultImpl(void *PassID, + Function *F); + + /// \brief Invalidate a module pass result. + void invalidateImpl(void *PassID, Module *M); + + /// \brief Invalidate a function pass result. + void invalidateImpl(void *PassID, Function *F); + + + /// \brief Module pass specific implementation of registration. + template + typename enable_if >::type + registerAnalysisPassImpl(PassT Pass) { + assert(!ModuleAnalysisPasses.count(PassT::ID()) && + "Registered the same analysis pass twice!"); + ModuleAnalysisPasses[PassT::ID()] = + new AnalysisPassModel(llvm_move(Pass)); + } + + /// \brief Function pass specific implementation of registration. + template + typename enable_if >::type + registerAnalysisPassImpl(PassT Pass) { + assert(!FunctionAnalysisPasses.count(PassT::ID()) && + "Registered the same analysis pass twice!"); + FunctionAnalysisPasses[PassT::ID()] = + new AnalysisPassModel(llvm_move(Pass)); + } + + /// \brief Module pass specific implementation of requirement declaration. + template + typename enable_if >::type + requireAnalysisPassImpl() { + assert(ModuleAnalysisPasses.count(PassT::ID()) && + "This analysis pass was not registered prior to being required"); + } + + /// \brief Function pass specific implementation of requirement declaration. + template + typename enable_if >::type + requireAnalysisPassImpl() { + assert(FunctionAnalysisPasses.count(PassT::ID()) && + "This analysis pass was not registered prior to being required"); + } + + + /// \brief Map type from module analysis pass ID to pass concept pointer. + typedef DenseMap > > + ModuleAnalysisPassMapT; + + /// \brief Collection of module analysis passes, indexed by ID. + ModuleAnalysisPassMapT ModuleAnalysisPasses; + + /// \brief Map type from module analysis pass ID to pass result concept pointer. + typedef DenseMap > > + ModuleAnalysisResultMapT; + + /// \brief Cache of computed module analysis results for this module. + ModuleAnalysisResultMapT ModuleAnalysisResults; + + + /// \brief Map type from function analysis pass ID to pass concept pointer. + typedef DenseMap > > + FunctionAnalysisPassMapT; + + /// \brief Collection of function analysis passes, indexed by ID. + FunctionAnalysisPassMapT FunctionAnalysisPasses; + + /// \brief List of function analysis pass IDs and associated concept pointers. + /// + /// Requires iterators to be valid across appending new entries and arbitrary + /// erases. Provides both the pass ID and concept pointer such that it is + /// half of a bijection and provides storage for the actual result concept. + typedef std::list< + std::pair > > > + FunctionAnalysisResultListT; + + /// \brief Map type from function pointer to our custom list type. + typedef DenseMap FunctionAnalysisResultListMapT; + + /// \brief Map from function to a list of function analysis results. + /// + /// Provides linear time removal of all analysis results for a function and + /// the ultimate storage for a particular cached analysis result. + FunctionAnalysisResultListMapT FunctionAnalysisResultLists; + + /// \brief Map type from a pair of analysis ID and function pointer to an + /// iterator into a particular result list. + typedef DenseMap, + FunctionAnalysisResultListT::iterator> + FunctionAnalysisResultMapT; + + /// \brief Map from an analysis ID and function to a particular cached + /// analysis result. + FunctionAnalysisResultMapT FunctionAnalysisResults; + + /// \brief Module handle for the \c AnalysisManager. + Module *M; +}; + } -- cgit v1.1 From cfe36cb02a4c2d99fd2ea0892e7b2668f2df2b8b Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Wed, 13 Nov 2013 01:51:36 +0000 Subject: Give folks a reference to some material on the fundamental design pattern in use here. Addresses review feedback from Sean (thanks!) and others. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194541 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/PassManager.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h index 5800e35..7e77120 100644 --- a/include/llvm/IR/PassManager.h +++ b/include/llvm/IR/PassManager.h @@ -25,6 +25,13 @@ /// a Function. /// * ModulePassManager must be directly run, runs each pass over the Module. /// +/// Note that the implementations of the pass managers use concept-based +/// polymorphism as outlined in the "Value Semantics and Concept-based +/// Polymorphism" talk (or its abbreviated sibling "Inheritance Is The Base +/// Class of Evil") by Sean Parent: +/// * http://github.com/sean-parent/sean-parent.github.com/wiki/Papers-and-Presentations +/// * http://channel9.msdn.com/Events/GoingNative/2013/Inheritance-Is-The-Base-Class-of-Evil +/// //===----------------------------------------------------------------------===// #include "llvm/ADT/DenseMap.h" -- cgit v1.1 From 3c3f6be0c8b8d6b38e219652580e2edef0f0a757 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Wed, 13 Nov 2013 02:48:20 +0000 Subject: Fix a null pointer dereference when copying a null polymorphic pointer. This bug only bit the C++98 build bots because all of the actual uses really do move. ;] But not *quite* ready to do the whole C++11 switch yet, so clean it up. Also add a unit test that catches this immediately. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194548 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/polymorphic_ptr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/ADT/polymorphic_ptr.h b/include/llvm/ADT/polymorphic_ptr.h index a168747..b8d8d71 100644 --- a/include/llvm/ADT/polymorphic_ptr.h +++ b/include/llvm/ADT/polymorphic_ptr.h @@ -39,7 +39,7 @@ template class polymorphic_ptr { public: polymorphic_ptr(T *ptr = 0) : ptr(ptr) {} - polymorphic_ptr(const polymorphic_ptr &arg) : ptr(arg->clone()) {} + polymorphic_ptr(const polymorphic_ptr &arg) : ptr(arg ? arg->clone() : 0) {} #if LLVM_HAS_RVALUE_REFERENCES polymorphic_ptr(polymorphic_ptr &&arg) : ptr(arg.take()) {} #endif -- cgit v1.1 From 429af0e0a790f915595726cec47154f670cf7f87 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Wed, 13 Nov 2013 02:49:38 +0000 Subject: Add another (perhaps better) video for Sean's talk. (Thanks Marshall!) git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194549 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/PassManager.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h index 7e77120..55c653c 100644 --- a/include/llvm/IR/PassManager.h +++ b/include/llvm/IR/PassManager.h @@ -30,6 +30,7 @@ /// Polymorphism" talk (or its abbreviated sibling "Inheritance Is The Base /// Class of Evil") by Sean Parent: /// * http://github.com/sean-parent/sean-parent.github.com/wiki/Papers-and-Presentations +/// * http://www.youtube.com/watch?v=_BpMYeUFXv8 /// * http://channel9.msdn.com/Events/GoingNative/2013/Inheritance-Is-The-Base-Class-of-Evil /// //===----------------------------------------------------------------------===// -- cgit v1.1 From 563b29f8db68275407ffcd2a9a5f0ba77ee5e899 Mon Sep 17 00:00:00 2001 From: Diego Novillo Date: Wed, 13 Nov 2013 12:22:21 +0000 Subject: SampleProfileLoader pass. Initial setup. This adds a new scalar pass that reads a file with samples generated by 'perf' during runtime. The samples read from the profile are incorporated and emmited as IR metadata reflecting that profile. The profile file is assumed to have been generated by an external profile source. The profile information is converted into IR metadata, which is later used by the analysis routines to estimate block frequencies, edge weights and other related data. External profile information files have no fixed format, each profiler is free to define its own. This includes both the on-disk representation of the profile and the kind of profile information stored in the file. A common kind of profile is based on sampling (e.g., perf), which essentially counts how many times each line of the program has been executed during the run. The SampleProfileLoader pass is organized as a scalar transformation. On startup, it reads the file given in -sample-profile-file to determine what kind of profile it contains. This file is assumed to contain profile information for the whole application. The profile data in the file is read and incorporated into the internal state of the corresponding profiler. To facilitate testing, I've organized the profilers to support two file formats: text and native. The native format is whatever on-disk representation the profiler wants to support, I think this will mostly be bitcode files, but it could be anything the profiler wants to support. To do this, every profiler must implement the SampleProfile::loadNative() function. The text format is mostly meant for debugging. Records are separated by newlines, but each profiler is free to interpret records as it sees fit. Profilers must implement the SampleProfile::loadText() function. Finally, the pass will call SampleProfile::emitAnnotations() for each function in the current translation unit. This function needs to translate the loaded profile into IR metadata, which the analyzer will later be able to use. This patch implements the first steps towards the above design. I've implemented a sample-based flat profiler. The format of the profile is fairly simplistic. Each sampled function contains a list of relative line locations (from the start of the function) together with a count representing how many samples were collected at that line during execution. I generate this profile using perf and a separate converter tool. Currently, I have only implemented a text format for these profiles. I am interested in initial feedback to the whole approach before I send the other parts of the implementation for review. This patch implements: - The SampleProfileLoader pass. - The base ExternalProfile class with the core interface. - A SampleProfile sub-class using the above interface. The profiler generates branch weight metadata on every branch instructions that matches the profiles. - A text loader class to assist the implementation of SampleProfile::loadText(). - Basic unit tests for the pass. Additionally, the patch uses profile information to compute branch weights based on instruction samples. This patch converts instruction samples into branch weights. It does a fairly simplistic conversion: Given a multi-way branch instruction, it calculates the weight of each branch based on the maximum sample count gathered from each target basic block. Note that this assignment of branch weights is somewhat lossy and can be misleading. If a basic block has more than one incoming branch, all the incoming branches will get the same weight. In reality, it may be that only one of them is the most heavily taken branch. I will adjust this assignment in subsequent patches. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194566 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/InitializePasses.h | 1 + include/llvm/Transforms/Scalar.h | 9 +++++++++ 2 files changed, 10 insertions(+) (limited to 'include') diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h index c650a6d..acfe3bd 100644 --- a/include/llvm/InitializePasses.h +++ b/include/llvm/InitializePasses.h @@ -70,6 +70,7 @@ void initializeAliasDebuggerPass(PassRegistry&); void initializeAliasSetPrinterPass(PassRegistry&); void initializeAlwaysInlinerPass(PassRegistry&); void initializeArgPromotionPass(PassRegistry&); +void initializeSampleProfileLoaderPass(PassRegistry&); void initializeBarrierNoopPass(PassRegistry&); void initializeBasicAliasAnalysisPass(PassRegistry&); void initializeCallGraphPass(PassRegistry&); diff --git a/include/llvm/Transforms/Scalar.h b/include/llvm/Transforms/Scalar.h index 65b8344..5d06157 100644 --- a/include/llvm/Transforms/Scalar.h +++ b/include/llvm/Transforms/Scalar.h @@ -15,6 +15,8 @@ #ifndef LLVM_TRANSFORMS_SCALAR_H #define LLVM_TRANSFORMS_SCALAR_H +#include "llvm/ADT/StringRef.h" + namespace llvm { class FunctionPass; @@ -355,6 +357,13 @@ FunctionPass *createLowerExpectIntrinsicPass(); // FunctionPass *createPartiallyInlineLibCallsPass(); +//===----------------------------------------------------------------------===// +// +// SampleProfilePass - Loads sample profile data from disk and generates +// IR metadata to reflect the profile. +FunctionPass *createSampleProfileLoaderPass(); +FunctionPass *createSampleProfileLoaderPass(StringRef Name); + } // End llvm namespace #endif -- cgit v1.1 From de9a1a2055851a0f0a88e459cd23a246a90efd45 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 13 Nov 2013 14:01:59 +0000 Subject: Remove AllowQuotesInName and friends from MCAsmInfo. Accepting quotes is a property of an assembler, not of an object file. For example, ELF can support any names for sections and symbols, but the gnu assembler only accepts quotes in some contexts and llvm-mc in a few more. LLVM should not produce different symbols based on a guess about which assembler will be reading the code it is printing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194575 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCAsmInfo.h | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCAsmInfo.h b/include/llvm/MC/MCAsmInfo.h index 3da3a31..7a99394 100644 --- a/include/llvm/MC/MCAsmInfo.h +++ b/include/llvm/MC/MCAsmInfo.h @@ -144,18 +144,6 @@ namespace llvm { /// AssemblerDialect - Which dialect of an assembler variant to use. unsigned AssemblerDialect; // Defaults to 0 - /// AllowQuotesInName - This is true if the assembler allows for complex - /// symbol names to be surrounded in quotes. This defaults to false. - bool AllowQuotesInName; - - /// AllowNameToStartWithDigit - This is true if the assembler allows symbol - /// names to start with a digit (e.g., "0x0021"). This defaults to false. - bool AllowNameToStartWithDigit; - - /// AllowPeriodsInName - This is true if the assembler allows periods in - /// symbol names. This defaults to true. - bool AllowPeriodsInName; - /// \brief This is true if the assembler allows @ characters in symbol /// names. Defaults to false. bool AllowAtInName; @@ -467,15 +455,6 @@ namespace llvm { unsigned getAssemblerDialect() const { return AssemblerDialect; } - bool doesAllowQuotesInName() const { - return AllowQuotesInName; - } - bool doesAllowNameToStartWithDigit() const { - return AllowNameToStartWithDigit; - } - bool doesAllowPeriodsInName() const { - return AllowPeriodsInName; - } bool doesAllowAtInName() const { return AllowAtInName; } -- cgit v1.1 From 43a0f3959e00ad8ab455d1e32a54a45c39a7ee8a Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Wed, 13 Nov 2013 15:35:13 +0000 Subject: Make sure LLVMLoadLibraryPermanently gets an extern "C" symbol. Otherwise it's impossible to use it. Also don't include C++ headers in a C header. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194581 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Support.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include') diff --git a/include/llvm-c/Support.h b/include/llvm-c/Support.h index 705e5f2..7f03ede 100644 --- a/include/llvm-c/Support.h +++ b/include/llvm-c/Support.h @@ -15,7 +15,6 @@ #define LLVM_C_SUPPORT_H #include "llvm-c/Core.h" -#include "llvm/Support/DynamicLibrary.h" #ifdef __cplusplus extern "C" { -- cgit v1.1 From 11966d7c984c3e32b102ecd26083c6f274973d96 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Wed, 13 Nov 2013 20:05:37 +0000 Subject: [AArch64] Add support for legacy AArch32 NEON scalar shift by immediate instructions. This patch does not include the shift right and accumulate instructions. A number of non-overloaded intrinsics have been remove in favor of their overloaded counterparts. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194598 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 4d54a23..782fea2 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -232,10 +232,6 @@ class Neon_3Arg_ShiftImm_Intrinsic def int_aarch64_neon_vshrds_n : Neon_2Arg_ShiftImm_Intrinsic; def int_aarch64_neon_vshrdu_n : Neon_2Arg_ShiftImm_Intrinsic; -// Scalar Rounding Shift Right (Immediate) -def int_aarch64_neon_vrshrds_n : Neon_2Arg_ShiftImm_Intrinsic; -def int_aarch64_neon_vrshrdu_n : Neon_2Arg_ShiftImm_Intrinsic; - // Scalar Shift Right and Accumulate (Immediate) def int_aarch64_neon_vsrads_n : Neon_3Arg_ShiftImm_Intrinsic; def int_aarch64_neon_vsradu_n : Neon_3Arg_ShiftImm_Intrinsic; @@ -251,15 +247,6 @@ def int_aarch64_neon_vshld_n : Neon_2Arg_ShiftImm_Intrinsic; def int_aarch64_neon_vqshls_n : Neon_N2V_Intrinsic; def int_aarch64_neon_vqshlu_n : Neon_N2V_Intrinsic; -// Scalar Signed Saturating Shift Left Unsigned (Immediate) -def int_aarch64_neon_vqshlus_n : Neon_N2V_Intrinsic; - -// Shift Right And Insert (Immediate) -def int_aarch64_neon_vsrid_n : Neon_3Arg_ShiftImm_Intrinsic; - -// Shift Left And Insert (Immediate) -def int_aarch64_neon_vslid_n : Neon_3Arg_ShiftImm_Intrinsic; - // Scalar Signed Fixed-point Convert To Floating-Point (Immediate) def int_aarch64_neon_vcvtf32_n_s32 : Intrinsic<[llvm_v1f32_ty], [llvm_v1i32_ty, llvm_i32_ty], [IntrNoMem]>; -- cgit v1.1 From dbb51ff01fd08df39e5040c1cd9edacdc3e4308a Mon Sep 17 00:00:00 2001 From: Yuchen Wu Date: Thu, 14 Nov 2013 00:07:15 +0000 Subject: llvm-cov: Replaced asserts with proper error handling. Unified the interface for read functions. They all return a boolean indicating if the read from file succeeded. Functions that previously returned the read value now store it into a variable that is passed in by reference instead. Callers will need to check the return value to detect if an error occurred. Also added a new test which ensures that no assertions occur when file contains invalid data. llvm-cov should return with error code 1 upon failure. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194635 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/GCOV.h | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h index ccc7c6e..d79c0f9 100644 --- a/include/llvm/Support/GCOV.h +++ b/include/llvm/Support/GCOV.h @@ -152,27 +152,35 @@ public: return true; } - uint32_t readInt() { - uint32_t Result; + bool readInt(uint32_t &Val) { StringRef Str = Buffer->getBuffer().slice(Cursor, Cursor+4); - assert (Str.empty() == false && "Unexpected memory buffer end!"); + if (Str.empty()) { + errs() << "Unexpected end of memory buffer: " << Cursor+4 << ".\n"; + return false; + } Cursor += 4; - Result = *(const uint32_t *)(Str.data()); - return Result; + Val = *(const uint32_t *)(Str.data()); + return true; } - uint64_t readInt64() { - uint64_t Lo = readInt(); - uint64_t Hi = readInt(); - uint64_t Result = Lo | (Hi << 32); - return Result; + bool readInt64(uint64_t &Val) { + uint32_t Lo, Hi; + if (!readInt(Lo) || !readInt(Hi)) return false; + Val = ((uint64_t)Hi << 32) | Lo; + return true; } - StringRef readString() { - uint32_t Len = readInt() * 4; - StringRef Str = Buffer->getBuffer().slice(Cursor, Cursor+Len); + bool readString(StringRef &Str) { + uint32_t Len; + if (!readInt(Len)) return false; + Len *= 4; + if (Buffer->getBuffer().size() < Cursor+Len) { + errs() << "Unexpected end of memory buffer: " << Cursor+Len << ".\n"; + return false; + } + Str = Buffer->getBuffer().slice(Cursor, Cursor+Len).split('\0').first; Cursor += Len; - return Str.split('\0').first; + return true; } uint64_t getCursor() const { return Cursor; } -- cgit v1.1 From 131a764e0e7abc90b322fd568e042d3c5a0633af Mon Sep 17 00:00:00 2001 From: Yuchen Wu Date: Thu, 14 Nov 2013 00:32:00 +0000 Subject: llvm-cov: Removed StringMap holding GCOVLines. According to the hazy gcov documentation, it appeared to be technically possible for lines within a block to belong to different source files. However, upon further investigation, gcov does not actually support multiple source files for a single block. This change removes a level of separation between blocks and lines by replacing the StringMap of GCOVLines with a SmallVector of ints representing line numbers. This also means that the GCOVLines class is no longer needed. This paves the way for supporting the "-a" option, which will output block information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194637 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/GCOV.h | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h index d79c0f9..469a9e3 100644 --- a/include/llvm/Support/GCOV.h +++ b/include/llvm/Support/GCOV.h @@ -25,7 +25,6 @@ namespace llvm { class GCOVFunction; class GCOVBlock; -class GCOVLines; class FileInfo; namespace GCOV { @@ -211,6 +210,7 @@ public: GCOVFunction() : Ident(0), LineNumber(0) {} ~GCOVFunction(); bool read(GCOVBuffer &Buffer, GCOV::GCOVFormat Format); + StringRef getFilename() const { return Filename; } void dump(); void collectLineCounts(FileInfo &FI); private: @@ -224,31 +224,21 @@ private: /// GCOVBlock - Collects block information. class GCOVBlock { public: - GCOVBlock(uint32_t N) : Number(N), Counter(0) {} + GCOVBlock(GCOVFunction &P, uint32_t N) : + Parent(P), Number(N), Counter(0), Edges(), Lines() {} ~GCOVBlock(); void addEdge(uint32_t N) { Edges.push_back(N); } - void addLine(StringRef Filename, uint32_t LineNo); + void addLine(uint32_t N) { Lines.push_back(N); } void addCount(uint64_t N) { Counter += N; } size_t getNumEdges() { return Edges.size(); } void dump(); void collectLineCounts(FileInfo &FI); private: + GCOVFunction &Parent; uint32_t Number; uint64_t Counter; SmallVector Edges; - StringMap Lines; -}; - -/// GCOVLines - A wrapper around a vector of int to keep track of line nos. -class GCOVLines { -public: - ~GCOVLines() { Lines.clear(); } - void add(uint32_t N) { Lines.push_back(N); } - void collectLineCounts(FileInfo &FI, StringRef Filename, uint64_t Count); - void dump(); - -private: - SmallVector Lines; + SmallVector Lines; }; typedef DenseMap LineCounts; -- cgit v1.1 From 4bd0224887a8de1434186cad2f618c18dea06c0b Mon Sep 17 00:00:00 2001 From: Yuchen Wu Date: Thu, 14 Nov 2013 00:38:41 +0000 Subject: llvm-cov: Slightly improved error checking. - readInt() should check all 4 bytes can be read, not just 1. - In the event of false data in the gcno file, it was possible to index into a non-existent index of SmallVector, causing assertion error. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194639 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/GCOV.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/GCOV.h b/include/llvm/Support/GCOV.h index 469a9e3..0aa716a 100644 --- a/include/llvm/Support/GCOV.h +++ b/include/llvm/Support/GCOV.h @@ -152,11 +152,11 @@ public: } bool readInt(uint32_t &Val) { - StringRef Str = Buffer->getBuffer().slice(Cursor, Cursor+4); - if (Str.empty()) { + if (Buffer->getBuffer().size() < Cursor+4) { errs() << "Unexpected end of memory buffer: " << Cursor+4 << ".\n"; return false; } + StringRef Str = Buffer->getBuffer().slice(Cursor, Cursor+4); Cursor += 4; Val = *(const uint32_t *)(Str.data()); return true; -- cgit v1.1 From 4e7c22a90b28828e4a28751b65ae24091f7df4ec Mon Sep 17 00:00:00 2001 From: Nick Kledzik Date: Thu, 14 Nov 2013 00:59:59 +0000 Subject: Add simple support for tags in YAML I/O git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194644 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/YAMLTraits.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h index 98964fc..6b6a8b7 100644 --- a/include/llvm/Support/YAMLTraits.h +++ b/include/llvm/Support/YAMLTraits.h @@ -330,6 +330,7 @@ public: virtual void postflightFlowElement(void*) = 0; virtual void endFlowSequence() = 0; + virtual bool mapTag(StringRef Tag, bool Default=false) = 0; virtual void beginMapping() = 0; virtual void endMapping() = 0; virtual bool preflightKey(const char*, bool, bool, bool &, void *&) = 0; @@ -404,8 +405,7 @@ public: void mapOptional(const char* Key, T& Val, const T& Default) { this->processKeyWithDefault(Key, Val, Default, false); } - - + private: template void processKeyWithDefault(const char *Key, T &Val, const T& DefaultValue, @@ -696,6 +696,7 @@ public: private: virtual bool outputting(); + virtual bool mapTag(StringRef, bool); virtual void beginMapping(); virtual void endMapping(); virtual bool preflightKey(const char *, bool, bool, bool &, void *&); @@ -819,6 +820,7 @@ public: virtual ~Output(); virtual bool outputting(); + virtual bool mapTag(StringRef, bool); virtual void beginMapping(); virtual void endMapping(); virtual bool preflightKey(const char *key, bool, bool, bool &, void *&); -- cgit v1.1 From 082ac99cc86b17c7cd2a1f2a6faa2d1adc184e17 Mon Sep 17 00:00:00 2001 From: Jiangning Liu Date: Thu, 14 Nov 2013 01:57:32 +0000 Subject: Implement AArch64 NEON instruction set AdvSIMD (table). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194648 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 45 ++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 782fea2..4d2e053 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -84,6 +84,51 @@ def int_aarch64_neon_vminv : Neon_Across_Intrinsic; def int_aarch64_neon_vmaxnmv : Neon_Across_Intrinsic; def int_aarch64_neon_vminnmv : Neon_Across_Intrinsic; +// Vector Table Lookup. +def int_aarch64_neon_vtbl1 : + Intrinsic<[llvm_anyvector_ty], + [llvm_anyvector_ty, LLVMMatchType<0>], [IntrNoMem]>; + +def int_aarch64_neon_vtbl2 : + Intrinsic<[llvm_anyvector_ty], + [llvm_anyvector_ty, LLVMMatchType<1>, LLVMMatchType<0>], + [IntrNoMem]>; + +def int_aarch64_neon_vtbl3 : + Intrinsic<[llvm_anyvector_ty], + [llvm_anyvector_ty, LLVMMatchType<1>, LLVMMatchType<1>, + LLVMMatchType<0>], [IntrNoMem]>; + +def int_aarch64_neon_vtbl4 : + Intrinsic<[llvm_anyvector_ty], + [llvm_anyvector_ty, LLVMMatchType<1>, LLVMMatchType<1>, + LLVMMatchType<1>, LLVMMatchType<0>], [IntrNoMem]>; + +// Vector Table Extension. +// Some elements of the destination vector may not be updated, so the original +// value of that vector is passed as the first argument. The next 1-4 +// arguments after that are the table. +def int_aarch64_neon_vtbx1 : + Intrinsic<[llvm_anyvector_ty], + [LLVMMatchType<0>, llvm_anyvector_ty, LLVMMatchType<0>], + [IntrNoMem]>; + +def int_aarch64_neon_vtbx2 : + Intrinsic<[llvm_anyvector_ty], + [LLVMMatchType<0>, llvm_anyvector_ty, LLVMMatchType<1>, + LLVMMatchType<0>], [IntrNoMem]>; + +def int_aarch64_neon_vtbx3 : + Intrinsic<[llvm_anyvector_ty], + [LLVMMatchType<0>, llvm_anyvector_ty, LLVMMatchType<1>, + LLVMMatchType<1>, LLVMMatchType<0>], [IntrNoMem]>; + +def int_aarch64_neon_vtbx4 : + Intrinsic<[llvm_anyvector_ty], + [LLVMMatchType<0>, llvm_anyvector_ty, LLVMMatchType<1>, + LLVMMatchType<1>, LLVMMatchType<1>, LLVMMatchType<0>], + [IntrNoMem]>; + // Scalar Add def int_aarch64_neon_vaddds : Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], [IntrNoMem]>; -- cgit v1.1 From e2058ff5bd4fa0397b57f6bdd84e5a5aa2343433 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Thu, 14 Nov 2013 02:27:46 +0000 Subject: Added BlockFrequencyInfo::view for displaying the block frequency propagation graph via graphviz. This is useful for debugging issues in the BlockFrequency implementation since one can easily visualize where probability mass and other errors occur in the propagation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194654 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/BlockFrequencyInfo.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm/Analysis/BlockFrequencyInfo.h b/include/llvm/Analysis/BlockFrequencyInfo.h index 64bd15c..a123d0b 100644 --- a/include/llvm/Analysis/BlockFrequencyInfo.h +++ b/include/llvm/Analysis/BlockFrequencyInfo.h @@ -41,6 +41,8 @@ public: bool runOnFunction(Function &F); void print(raw_ostream &O, const Module *M) const; + const Function *getFunction() const; + void view() const; /// getblockFreq - Return block frequency. Return 0 if we don't have the /// information. Please note that initial frequency is equal to ENTRY_FREQ. It -- cgit v1.1 From 04fca67d6f4b314ba618714698b58dbfba3af005 Mon Sep 17 00:00:00 2001 From: Nick Kledzik Date: Thu, 14 Nov 2013 02:38:07 +0000 Subject: Add dyn_cast<> support to YAML I/O's IO class git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194655 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/YAMLTraits.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h index 6b6a8b7..d6eeaac 100644 --- a/include/llvm/Support/YAMLTraits.h +++ b/include/llvm/Support/YAMLTraits.h @@ -18,6 +18,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/YAMLParser.h" @@ -317,7 +318,7 @@ public: IO(void *Ctxt=NULL); virtual ~IO(); - virtual bool outputting() = 0; + virtual bool outputting() const = 0; virtual unsigned beginSequence() = 0; virtual bool preflightElement(unsigned, void *&) = 0; @@ -694,8 +695,10 @@ public: // To set alternate error reporting. void setDiagHandler(llvm::SourceMgr::DiagHandlerTy Handler, void *Ctxt = 0); + static bool classof(const IO *io) { return !io->outputting(); } + private: - virtual bool outputting(); + virtual bool outputting() const; virtual bool mapTag(StringRef, bool); virtual void beginMapping(); virtual void endMapping(); @@ -819,7 +822,9 @@ public: Output(llvm::raw_ostream &, void *Ctxt=NULL); virtual ~Output(); - virtual bool outputting(); + static bool classof(const IO *io) { return io->outputting(); } + + virtual bool outputting() const; virtual bool mapTag(StringRef, bool); virtual void beginMapping(); virtual void endMapping(); -- cgit v1.1 From a08063a000cfc7499f08a472d85f14e7a5e90f8d Mon Sep 17 00:00:00 2001 From: Kevin Qin Date: Thu, 14 Nov 2013 02:44:13 +0000 Subject: Implement aarch64 neon instruction class SIMD misc. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194656 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 4d2e053..d015d91 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -22,6 +22,39 @@ def int_aarch64_neon_vacgeq : def int_aarch64_neon_vacgtq : Intrinsic<[llvm_v2i64_ty], [llvm_v2f64_ty, llvm_v2f64_ty], [IntrNoMem]>; +// Vector saturating accumulate +def int_aarch64_neon_suqadd : Neon_2Arg_Intrinsic; +def int_aarch64_neon_usqadd : Neon_2Arg_Intrinsic; + +// Vector Bitwise reverse +def int_aarch64_neon_rbit : Neon_1Arg_Intrinsic; + +// Vector extract and narrow +def int_aarch64_neon_xtn : + Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>; + +// Vector floating-point convert +def int_aarch64_neon_frintn : Neon_1Arg_Intrinsic; +def int_aarch64_neon_fsqrt : Neon_1Arg_Intrinsic; +def int_aarch64_neon_fcvtxn : + Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>; +def int_aarch64_neon_fcvtns : + Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>; +def int_aarch64_neon_fcvtnu : + Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>; +def int_aarch64_neon_fcvtps : + Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>; +def int_aarch64_neon_fcvtpu : + Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>; +def int_aarch64_neon_fcvtms : + Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>; +def int_aarch64_neon_fcvtmu : + Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>; +def int_aarch64_neon_fcvtas : + Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>; +def int_aarch64_neon_fcvtau : + Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>; + // Vector maxNum (Floating Point) def int_aarch64_neon_vmaxnm : Neon_2Arg_Intrinsic; -- cgit v1.1 From 0710afb9af81cff9846ceda7b56d03cf177dd6ef Mon Sep 17 00:00:00 2001 From: Kevin Qin Date: Thu, 14 Nov 2013 03:27:58 +0000 Subject: [AArch64 neon] support poly64 and relevant intrinsic functions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194659 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index d015d91..42b00aa 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -325,6 +325,9 @@ def int_aarch64_neon_vshld_n : Neon_2Arg_ShiftImm_Intrinsic; def int_aarch64_neon_vqshls_n : Neon_N2V_Intrinsic; def int_aarch64_neon_vqshlu_n : Neon_N2V_Intrinsic; +// Scalar Signed Saturating Shift Left Unsigned (Immediate) +def int_aarch64_neon_vqshlus_n : Neon_N2V_Intrinsic; + // Scalar Signed Fixed-point Convert To Floating-Point (Immediate) def int_aarch64_neon_vcvtf32_n_s32 : Intrinsic<[llvm_v1f32_ty], [llvm_v1i32_ty, llvm_i32_ty], [IntrNoMem]>; -- cgit v1.1 From 4701c4702e2f37d7a9f3ea9ef91ec47d73515093 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Thu, 14 Nov 2013 10:55:14 +0000 Subject: Fix the header comment of the new pass manager stuff to not claim to be the legacy stuff. =] git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194689 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/PassManager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h index 55c653c..08aac77 100644 --- a/include/llvm/IR/PassManager.h +++ b/include/llvm/IR/PassManager.h @@ -1,4 +1,4 @@ -//===- PassManager.h - LegacyContainer for Passes --------------*- C++ -*-===// +//===- PassManager.h - Pass management infrastructure -----------*- C++ -*-===// // // The LLVM Compiler Infrastructure // -- cgit v1.1 From 2b7fef0ad4bfaaf9fd41cda5abda35aab701b598 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 15 Nov 2013 01:25:34 +0000 Subject: Include raw_ostream.h. Including only Debug.h did not cause a compilation error, but you couldn't do anything (like writing something with <<) to raw_ostreams returned by llvm::dbgs() or llvm::errs() without including raw_ostream.h. So including it from Debug.h should make sense. Differential Revision: http://llvm-reviews.chandlerc.com/D2183 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194759 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Debug.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/Debug.h b/include/llvm/Support/Debug.h index 896fe84..2702408 100644 --- a/include/llvm/Support/Debug.h +++ b/include/llvm/Support/Debug.h @@ -26,9 +26,9 @@ #ifndef LLVM_SUPPORT_DEBUG_H #define LLVM_SUPPORT_DEBUG_H -namespace llvm { +#include "llvm/Support/raw_ostream.h" -class raw_ostream; +namespace llvm { /// DEBUG_TYPE macro - Files can specify a DEBUG_TYPE as a string, which causes /// all of their DEBUG statements to be activatable with -debug-only=thatstring. -- cgit v1.1 From 59d3ae6cdc4316ad338cd848251f33a236ccb36c Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 15 Nov 2013 01:34:59 +0000 Subject: Add addrspacecast instruction. Patch by Michele Scandale! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194760 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Core.h | 5 +++++ include/llvm/AutoUpgrade.h | 13 +++++++++++ include/llvm/Bitcode/LLVMBitCodes.h | 3 ++- include/llvm/CodeGen/ISDOpcodes.h | 4 ++++ include/llvm/CodeGen/SelectionDAG.h | 4 ++++ include/llvm/CodeGen/SelectionDAGNodes.h | 17 +++++++++++++++ include/llvm/IR/Constants.h | 1 + include/llvm/IR/IRBuilder.h | 4 ++++ include/llvm/IR/Instruction.def | 35 +++++++++++++++--------------- include/llvm/IR/Instructions.h | 37 ++++++++++++++++++++++++++++++++ include/llvm/InstVisitor.h | 1 + include/llvm/Target/TargetLowering.h | 5 +++++ 12 files changed, 111 insertions(+), 18 deletions(-) (limited to 'include') diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index d4de523..9953d52 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -222,6 +222,7 @@ typedef enum { LLVMPtrToInt = 39, LLVMIntToPtr = 40, LLVMBitCast = 41, + LLVMAddrSpaceCast = 60, /* Other Operators */ LLVMICmp = 42, @@ -1159,6 +1160,7 @@ LLVMTypeRef LLVMX86MMXType(void); macro(UnaryInstruction) \ macro(AllocaInst) \ macro(CastInst) \ + macro(AddrSpaceCastInst) \ macro(BitCastInst) \ macro(FPExtInst) \ macro(FPToSIInst) \ @@ -1630,6 +1632,7 @@ LLVMValueRef LLVMConstFPToSI(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstPtrToInt(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstIntToPtr(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); +LLVMValueRef LLVMConstAddrSpaceCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstZExtOrBitCast(LLVMValueRef ConstantVal, LLVMTypeRef ToType); LLVMValueRef LLVMConstSExtOrBitCast(LLVMValueRef ConstantVal, @@ -2605,6 +2608,8 @@ LLVMValueRef LLVMBuildIntToPtr(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildBitCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); +LLVMValueRef LLVMBuildAddrSpaceCast(LLVMBuilderRef, LLVMValueRef Val, + LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildZExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, LLVMTypeRef DestTy, const char *Name); LLVMValueRef LLVMBuildSExtOrBitCast(LLVMBuilderRef, LLVMValueRef Val, diff --git a/include/llvm/AutoUpgrade.h b/include/llvm/AutoUpgrade.h index 8df87fa..22d0c43 100644 --- a/include/llvm/AutoUpgrade.h +++ b/include/llvm/AutoUpgrade.h @@ -15,11 +15,14 @@ #define LLVM_AUTOUPGRADE_H namespace llvm { + class Constant; class Module; class GlobalVariable; class Function; class CallInst; class Instruction; + class Value; + class Type; /// This is a more granular function that simply checks an intrinsic function /// for upgrading, and returns true if it requires upgrading. It may return @@ -44,6 +47,16 @@ namespace llvm { /// If the TBAA tag for the given instruction uses the scalar TBAA format, /// we upgrade it to the struct-path aware TBAA format. void UpgradeInstWithTBAATag(Instruction *I); + + /// This is an auto-upgrade for bitcast between pointers with different + /// address spaces: the instruction is replaced by a pair ptrtoint+inttoptr. + Instruction *UpgradeBitCastInst(unsigned Opc, Value *V, Type *DestTy, + Instruction *&Temp); + + /// This is an auto-upgrade for bitcast constant expression between pointers + /// with different address spaces: the instruction is replaced by a pair + /// ptrtoint+inttoptr. + Value *UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy); } // End llvm namespace #endif diff --git a/include/llvm/Bitcode/LLVMBitCodes.h b/include/llvm/Bitcode/LLVMBitCodes.h index 90e9063..b3d2466 100644 --- a/include/llvm/Bitcode/LLVMBitCodes.h +++ b/include/llvm/Bitcode/LLVMBitCodes.h @@ -194,7 +194,8 @@ namespace bitc { CAST_FPEXT = 8, CAST_PTRTOINT = 9, CAST_INTTOPTR = 10, - CAST_BITCAST = 11 + CAST_BITCAST = 11, + CAST_ADDRSPACECAST = 12 }; /// BinaryOpcodes - These are values used in the bitcode files to encode which diff --git a/include/llvm/CodeGen/ISDOpcodes.h b/include/llvm/CodeGen/ISDOpcodes.h index 3a49dd8..48a0523 100644 --- a/include/llvm/CodeGen/ISDOpcodes.h +++ b/include/llvm/CodeGen/ISDOpcodes.h @@ -419,6 +419,10 @@ namespace ISD { /// getNode(). BITCAST, + /// ADDRSPACECAST - This operator converts between pointers of different + /// address spaces. + ADDRSPACECAST, + /// CONVERT_RNDSAT - This operator is used to support various conversions /// between various types (float, signed, unsigned and vectors of those /// types) with rounding and saturation. NOTE: Avoid using this operator as diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index 3f27bce..5f18c4e 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -802,6 +802,10 @@ public: /// getMDNode - Return an MDNodeSDNode which holds an MDNode. SDValue getMDNode(const MDNode *MD); + /// getAddrSpaceCast - Return an AddrSpaceCastSDNode. + SDValue getAddrSpaceCast(SDLoc dl, EVT VT, SDValue Ptr, + unsigned SrcAS, unsigned DestAS); + /// getShiftAmountOperand - Return the specified value casted to /// the target's desired shift amount type. SDValue getShiftAmountOperand(EVT LHSTy, SDValue Op); diff --git a/include/llvm/CodeGen/SelectionDAGNodes.h b/include/llvm/CodeGen/SelectionDAGNodes.h index 8ec3b09..70c15e6 100644 --- a/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/include/llvm/CodeGen/SelectionDAGNodes.h @@ -950,6 +950,23 @@ public: const SDValue &getValue() const { return Op; } }; +class AddrSpaceCastSDNode : public UnarySDNode { +private: + unsigned SrcAddrSpace; + unsigned DestAddrSpace; + +public: + AddrSpaceCastSDNode(unsigned Order, DebugLoc dl, EVT VT, SDValue X, + unsigned SrcAS, unsigned DestAS); + + unsigned getSrcAddressSpace() const { return SrcAddrSpace; } + unsigned getDestAddressSpace() const { return DestAddrSpace; } + + static bool classof(const SDNode *N) { + return N->getOpcode() == ISD::ADDRSPACECAST; + } +}; + /// Abstact virtual class for operations for memory operations class MemSDNode : public SDNode { private: diff --git a/include/llvm/IR/Constants.h b/include/llvm/IR/Constants.h index 99aed0d..b6e2082 100644 --- a/include/llvm/IR/Constants.h +++ b/include/llvm/IR/Constants.h @@ -862,6 +862,7 @@ public: static Constant *getPtrToInt(Constant *C, Type *Ty); static Constant *getIntToPtr(Constant *C, Type *Ty); static Constant *getBitCast (Constant *C, Type *Ty); + static Constant *getAddrSpaceCast (Constant *C, Type *Ty); static Constant *getNSWNeg(Constant *C) { return getNeg(C, false, true); } static Constant *getNUWNeg(Constant *C) { return getNeg(C, true, false); } diff --git a/include/llvm/IR/IRBuilder.h b/include/llvm/IR/IRBuilder.h index e2aeed3..8d1432d 100644 --- a/include/llvm/IR/IRBuilder.h +++ b/include/llvm/IR/IRBuilder.h @@ -1133,6 +1133,10 @@ public: const Twine &Name = "") { return CreateCast(Instruction::BitCast, V, DestTy, Name); } + Value *CreateAddrSpaceCast(Value *V, Type *DestTy, + const Twine &Name = "") { + return CreateCast(Instruction::AddrSpaceCast, V, DestTy, Name); + } Value *CreateZExtOrBitCast(Value *V, Type *DestTy, const Twine &Name = "") { if (V->getType() == DestTy) diff --git a/include/llvm/IR/Instruction.def b/include/llvm/IR/Instruction.def index e59a052..d46314c 100644 --- a/include/llvm/IR/Instruction.def +++ b/include/llvm/IR/Instruction.def @@ -154,25 +154,26 @@ HANDLE_CAST_INST(41, FPExt , FPExtInst ) // Extend floating point HANDLE_CAST_INST(42, PtrToInt, PtrToIntInst) // Pointer -> Integer HANDLE_CAST_INST(43, IntToPtr, IntToPtrInst) // Integer -> Pointer HANDLE_CAST_INST(44, BitCast , BitCastInst ) // Type cast - LAST_CAST_INST(44) +HANDLE_CAST_INST(45, AddrSpaceCast, AddrSpaceCastInst) // addrspace cast + LAST_CAST_INST(45) // Other operators... - FIRST_OTHER_INST(45) -HANDLE_OTHER_INST(45, ICmp , ICmpInst ) // Integer comparison instruction -HANDLE_OTHER_INST(46, FCmp , FCmpInst ) // Floating point comparison instr. -HANDLE_OTHER_INST(47, PHI , PHINode ) // PHI node instruction -HANDLE_OTHER_INST(48, Call , CallInst ) // Call a function -HANDLE_OTHER_INST(49, Select , SelectInst ) // select instruction -HANDLE_OTHER_INST(50, UserOp1, Instruction) // May be used internally in a pass -HANDLE_OTHER_INST(51, UserOp2, Instruction) // Internal to passes only -HANDLE_OTHER_INST(52, VAArg , VAArgInst ) // vaarg instruction -HANDLE_OTHER_INST(53, ExtractElement, ExtractElementInst)// extract from vector -HANDLE_OTHER_INST(54, InsertElement, InsertElementInst) // insert into vector -HANDLE_OTHER_INST(55, ShuffleVector, ShuffleVectorInst) // shuffle two vectors. -HANDLE_OTHER_INST(56, ExtractValue, ExtractValueInst)// extract from aggregate -HANDLE_OTHER_INST(57, InsertValue, InsertValueInst) // insert into aggregate -HANDLE_OTHER_INST(58, LandingPad, LandingPadInst) // Landing pad instruction. - LAST_OTHER_INST(58) + FIRST_OTHER_INST(46) +HANDLE_OTHER_INST(46, ICmp , ICmpInst ) // Integer comparison instruction +HANDLE_OTHER_INST(47, FCmp , FCmpInst ) // Floating point comparison instr. +HANDLE_OTHER_INST(48, PHI , PHINode ) // PHI node instruction +HANDLE_OTHER_INST(49, Call , CallInst ) // Call a function +HANDLE_OTHER_INST(50, Select , SelectInst ) // select instruction +HANDLE_OTHER_INST(51, UserOp1, Instruction) // May be used internally in a pass +HANDLE_OTHER_INST(52, UserOp2, Instruction) // Internal to passes only +HANDLE_OTHER_INST(53, VAArg , VAArgInst ) // vaarg instruction +HANDLE_OTHER_INST(54, ExtractElement, ExtractElementInst)// extract from vector +HANDLE_OTHER_INST(55, InsertElement, InsertElementInst) // insert into vector +HANDLE_OTHER_INST(56, ShuffleVector, ShuffleVectorInst) // shuffle two vectors. +HANDLE_OTHER_INST(57, ExtractValue, ExtractValueInst)// extract from aggregate +HANDLE_OTHER_INST(58, InsertValue, InsertValueInst) // insert into aggregate +HANDLE_OTHER_INST(59, LandingPad, LandingPadInst) // Landing pad instruction. + LAST_OTHER_INST(59) #undef FIRST_TERM_INST #undef HANDLE_TERM_INST diff --git a/include/llvm/IR/Instructions.h b/include/llvm/IR/Instructions.h index da260fb..0843d8f 100644 --- a/include/llvm/IR/Instructions.h +++ b/include/llvm/IR/Instructions.h @@ -3615,6 +3615,43 @@ public: } }; +//===----------------------------------------------------------------------===// +// AddrSpaceCastInst Class +//===----------------------------------------------------------------------===// + +/// \brief This class represents a conversion between pointers from +/// one address space to another. +class AddrSpaceCastInst : public CastInst { +protected: + /// \brief Clone an identical AddrSpaceCastInst + virtual AddrSpaceCastInst *clone_impl() const; + +public: + /// \brief Constructor with insert-before-instruction semantics + AddrSpaceCastInst( + Value *S, ///< The value to be casted + Type *Ty, ///< The type to casted to + const Twine &NameStr = "", ///< A name for the new instruction + Instruction *InsertBefore = 0 ///< Where to insert the new instruction + ); + + /// \brief Constructor with insert-at-end-of-block semantics + AddrSpaceCastInst( + Value *S, ///< The value to be casted + Type *Ty, ///< The type to casted to + const Twine &NameStr, ///< A name for the new instruction + BasicBlock *InsertAtEnd ///< The block to insert the instruction into + ); + + // Methods for support type inquiry through isa, cast, and dyn_cast: + static inline bool classof(const Instruction *I) { + return I->getOpcode() == AddrSpaceCast; + } + static inline bool classof(const Value *V) { + return isa(V) && classof(cast(V)); + } +}; + } // End llvm namespace #endif diff --git a/include/llvm/InstVisitor.h b/include/llvm/InstVisitor.h index 2911703..de7206d 100644 --- a/include/llvm/InstVisitor.h +++ b/include/llvm/InstVisitor.h @@ -191,6 +191,7 @@ public: RetTy visitPtrToIntInst(PtrToIntInst &I) { DELEGATE(CastInst);} RetTy visitIntToPtrInst(IntToPtrInst &I) { DELEGATE(CastInst);} RetTy visitBitCastInst(BitCastInst &I) { DELEGATE(CastInst);} + RetTy visitAddrSpaceCastInst(AddrSpaceCastInst &I) { DELEGATE(CastInst);} RetTy visitSelectInst(SelectInst &I) { DELEGATE(Instruction);} RetTy visitVAArgInst(VAArgInst &I) { DELEGATE(UnaryInstruction);} RetTy visitExtractElementInst(ExtractElementInst &I) { DELEGATE(Instruction);} diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 5d6d1d2..2649d26 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -827,6 +827,11 @@ public: return 0; } + /// Returns true if a cast between SrcAS and DestAS is a noop. + virtual bool isNoopAddrSpaceCast(unsigned SrcAS, unsigned DestAS) const { + return false; + } + //===--------------------------------------------------------------------===// /// \name Helpers for TargetTransformInfo implementations /// @{ -- cgit v1.1 From 5ea0c20ce7a161d23a9bf8f1beea0ffb6a02898c Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Fri, 15 Nov 2013 02:51:01 +0000 Subject: [llvm-c] Simplify signature of LLVMGetTargetFromName LLVMGetTargetFromName was not yet present in an LLVM release, so this does not break compatibility. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194769 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/TargetMachine.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm-c/TargetMachine.h b/include/llvm-c/TargetMachine.h index 84f9144..15d664f 100644 --- a/include/llvm-c/TargetMachine.h +++ b/include/llvm-c/TargetMachine.h @@ -64,7 +64,7 @@ LLVMTargetRef LLVMGetNextTarget(LLVMTargetRef T); /*===-- Target ------------------------------------------------------------===*/ /** Finds the target corresponding to the given name and stores it in \p T. Returns 0 on success. */ -LLVMBool LLVMGetTargetFromName(const char *Name, LLVMTargetRef *T); +LLVMTargetRef LLVMGetTargetFromName(const char *Name); /** Finds the target corresponding to the given triple and stores it in \p T. Returns 0 on success. Optionally returns any error in ErrorMessage. -- cgit v1.1 From fa74752298602e0b74fb60ce3f0e76d0c461d3d8 Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Fri, 15 Nov 2013 02:51:12 +0000 Subject: [llvm-c] Add missing const qualifiers to LLVMCreateTargetMachine git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194770 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/TargetMachine.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm-c/TargetMachine.h b/include/llvm-c/TargetMachine.h index 15d664f..e159411 100644 --- a/include/llvm-c/TargetMachine.h +++ b/include/llvm-c/TargetMachine.h @@ -89,9 +89,9 @@ LLVMBool LLVMTargetHasAsmBackend(LLVMTargetRef T); /*===-- Target Machine ----------------------------------------------------===*/ /** Creates a new llvm::TargetMachine. See llvm::Target::createTargetMachine */ -LLVMTargetMachineRef LLVMCreateTargetMachine(LLVMTargetRef T, char *Triple, - char *CPU, char *Features, LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc, - LLVMCodeModel CodeModel); +LLVMTargetMachineRef LLVMCreateTargetMachine(LLVMTargetRef T, + const char *Triple, const char *CPU, const char *Features, + LLVMCodeGenOptLevel Level, LLVMRelocMode Reloc, LLVMCodeModel CodeModel); /** Dispose the LLVMTargetMachineRef instance generated by LLVMCreateTargetMachine. */ -- cgit v1.1 From 509a492442b7e889d615d3b451629c81a810aef1 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 15 Nov 2013 04:42:23 +0000 Subject: Add target hook to prevent folding some bitcasted loads. This is to avoid this transformation in some cases: fold (conv (load x)) -> (load (conv*)x) On architectures that don't natively support some vector loads efficiently casting the load to a smaller vector of larger types and loading is more efficient. Patch by Micah Villmow. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194783 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetLowering.h | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'include') diff --git a/include/llvm/Target/TargetLowering.h b/include/llvm/Target/TargetLowering.h index 2649d26..5ab04f7 100644 --- a/include/llvm/Target/TargetLowering.h +++ b/include/llvm/Target/TargetLowering.h @@ -204,6 +204,17 @@ public: return PredictableSelectIsExpensive; } + /// isLoadBitCastBeneficial() - Return true if the following transform + /// is beneficial. + /// fold (conv (load x)) -> (load (conv*)x) + /// On architectures that don't natively support some vector loads efficiently, + /// casting the load to a smaller vector of larger types and loading + /// is more efficient, however, this can be undone by optimizations in + /// dag combiner. + virtual bool isLoadBitCastBeneficial(EVT /* Load */, EVT /* Bitcast */) const { + return true; + } + /// Return the ValueType of the result of SETCC operations. Also used to /// obtain the target's preferred type for the condition operand of SELECT and /// BRCOND nodes. In the case of BRCOND the argument passed is MVT::Other -- cgit v1.1 From ea28aafa83fc2b6dd632041278c9a18e5a2b2b41 Mon Sep 17 00:00:00 2001 From: Daniel Sanders Date: Fri, 15 Nov 2013 12:56:49 +0000 Subject: Fix illegal DAG produced by SelectionDAG::getConstant() for v2i64 type Summary: When getConstant() is called for an expanded vector type, it is split into multiple scalar constants which are then combined using appropriate build_vector and bitcast operations. In addition to the usual big/little endian differences, the case where the element-order of the vector does not have the same endianness as the elements themselves is also accounted for. For example, for v4i32 on big-endian MIPS, the byte-order of the vector is <3210,7654,BA98,FEDC>. For little-endian, it is <0123,4567,89AB,CDEF>. Handling this case turns out to be a nop since getConstant() returns a splatted vector (so reversing the element order doesn't change the value) This fixes a number of cases in MIPS MSA where calling getConstant() during operation legalization introduces illegal types (e.g. to legalize v2i64 UNDEF into a v2i64 BUILD_VECTOR of illegal i64 zeros). It should also handle bigger differences between illegal and legal types such as legalizing v2i64 into v8i16. lowerMSASplatImm() in the MIPS backend no longer needs to avoid calling getConstant() so this function has been updated in the same patch. For the sake of transparency, the steps I've taken since the review are: * Added 'virtual' to isVectorEltOrderLittleEndian() as requested. This revealed that the MIPS tests were falsely passing because a polymorphic function was not actually polymorphic in the reviewed patch. * Fixed the tests that were now failing. This involved deleting the code to handle the MIPS MSA element-order (which was previously doing an byte-order swap instead of an element-order swap). This left isVectorEltOrderLittleEndian() unused and it was deleted. * Fixed build failures caused by rebasing beyond r194467-r194472. These build failures involved the bset, bneg, and bclr instructions added in these commits using lowerMSASplatImm() in a way that was no longer valid after this patch. Some of these were fixed by calling SelectionDAG::getConstant() instead, others were fixed by a new function getBuildVectorSplat() that provided the removed functionality of lowerMSASplatImm() in a more sensible way. Reviewers: bkramer Reviewed By: bkramer CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D1973 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194811 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/SelectionDAG.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index 5f18c4e..9a9bb99 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -236,6 +236,13 @@ public: virtual void NodeUpdated(SDNode *N); }; + /// NewNodesMustHaveLegalTypes - When true, additional steps are taken to + /// ensure that getConstant() and similar functions return DAG nodes that + /// have legal types. This is important after type legalization since + /// any illegally typed nodes generated after this point will not experience + /// type legalization. + bool NewNodesMustHaveLegalTypes; + private: /// DAGUpdateListener is a friend so it can manipulate the listener stack. friend struct DAGUpdateListener; -- cgit v1.1 From 28e12e9f02cf1c5029994b4a6d7e2988512e1310 Mon Sep 17 00:00:00 2001 From: Cameron McInally Date: Fri, 15 Nov 2013 17:01:14 +0000 Subject: Add AVX512 unmasked FMA intrinsics and support. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194824 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsX86.td | 48 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsX86.td b/include/llvm/IR/IntrinsicsX86.td index 1fe1c91..4c5718f 100644 --- a/include/llvm/IR/IntrinsicsX86.td +++ b/include/llvm/IR/IntrinsicsX86.td @@ -1864,6 +1864,14 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_fma_vfmadd_ps_512 : GCCBuiltin<"__builtin_ia32_vfmaddps512">, + Intrinsic<[llvm_v16f32_ty], + [llvm_v16f32_ty, llvm_v16f32_ty, llvm_v16f32_ty], + [IntrNoMem]>; + def int_x86_fma_vfmadd_pd_512 : GCCBuiltin<"__builtin_ia32_vfmaddpd512">, + Intrinsic<[llvm_v8f64_ty], + [llvm_v8f64_ty, llvm_v8f64_ty, llvm_v8f64_ty], + [IntrNoMem]>; def int_x86_fma_vfmsub_ss : GCCBuiltin<"__builtin_ia32_vfmsubss">, Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty], @@ -1888,6 +1896,14 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_fma_vfmsub_ps_512 : GCCBuiltin<"__builtin_ia32_vfmsubps512">, + Intrinsic<[llvm_v16f32_ty], + [llvm_v16f32_ty, llvm_v16f32_ty, llvm_v16f32_ty], + [IntrNoMem]>; + def int_x86_fma_vfmsub_pd_512 : GCCBuiltin<"__builtin_ia32_vfmsubpd512">, + Intrinsic<[llvm_v8f64_ty], + [llvm_v8f64_ty, llvm_v8f64_ty, llvm_v8f64_ty], + [IntrNoMem]>; def int_x86_fma_vfnmadd_ss : GCCBuiltin<"__builtin_ia32_vfnmaddss">, Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty], @@ -1912,6 +1928,14 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_fma_vfnmadd_ps_512 : GCCBuiltin<"__builtin_ia32_vfnmaddps512">, + Intrinsic<[llvm_v16f32_ty], + [llvm_v16f32_ty, llvm_v16f32_ty, llvm_v16f32_ty], + [IntrNoMem]>; + def int_x86_fma_vfnmadd_pd_512 : GCCBuiltin<"__builtin_ia32_vfnmaddpd512">, + Intrinsic<[llvm_v8f64_ty], + [llvm_v8f64_ty, llvm_v8f64_ty, llvm_v8f64_ty], + [IntrNoMem]>; def int_x86_fma_vfnmsub_ss : GCCBuiltin<"__builtin_ia32_vfnmsubss">, Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty], @@ -1936,6 +1960,14 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_fma_vfnmsub_ps_512 : GCCBuiltin<"__builtin_ia32_vfnmsubps512">, + Intrinsic<[llvm_v16f32_ty], + [llvm_v16f32_ty, llvm_v16f32_ty, llvm_v16f32_ty], + [IntrNoMem]>; + def int_x86_fma_vfnmsub_pd_512 : GCCBuiltin<"__builtin_ia32_vfnmsubpd512">, + Intrinsic<[llvm_v8f64_ty], + [llvm_v8f64_ty, llvm_v8f64_ty, llvm_v8f64_ty], + [IntrNoMem]>; def int_x86_fma_vfmaddsub_ps : GCCBuiltin<"__builtin_ia32_vfmaddsubps">, Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty], @@ -1954,6 +1986,14 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_fma_vfmaddsub_ps_512 : GCCBuiltin<"__builtin_ia32_vfmaddsubps512">, + Intrinsic<[llvm_v16f32_ty], + [llvm_v16f32_ty, llvm_v16f32_ty, llvm_v16f32_ty], + [IntrNoMem]>; + def int_x86_fma_vfmaddsub_pd_512 : GCCBuiltin<"__builtin_ia32_vfmaddsubpd512">, + Intrinsic<[llvm_v8f64_ty], + [llvm_v8f64_ty, llvm_v8f64_ty, llvm_v8f64_ty], + [IntrNoMem]>; def int_x86_fma_vfmsubadd_ps : GCCBuiltin<"__builtin_ia32_vfmsubaddps">, Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, llvm_v4f32_ty, llvm_v4f32_ty], @@ -1972,6 +2012,14 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_v4f64_ty, llvm_v4f64_ty], [IntrNoMem]>; + def int_x86_fma_vfmsubadd_ps_512 : GCCBuiltin<"__builtin_ia32_vfmsubaddps512">, + Intrinsic<[llvm_v16f32_ty], + [llvm_v16f32_ty, llvm_v16f32_ty, llvm_v16f32_ty], + [IntrNoMem]>; + def int_x86_fma_vfmsubadd_pd_512 : GCCBuiltin<"__builtin_ia32_vfmsubaddpd512">, + Intrinsic<[llvm_v8f64_ty], + [llvm_v8f64_ty, llvm_v8f64_ty, llvm_v8f64_ty], + [IntrNoMem]>; } //===----------------------------------------------------------------------===// -- cgit v1.1 From cc7052343e5e955d4e2f48885c06360f9003390a Mon Sep 17 00:00:00 2001 From: Bob Wilson Date: Fri, 15 Nov 2013 19:09:27 +0000 Subject: Avoid illegal integer promotion in fastisel Stop folding constant adds into GEP when the type size doesn't match. Otherwise, the adds' operands are effectively being promoted, changing the conditions of an overflow. Results are different when: sext(a) + sext(b) != sext(a + b) Problem originally found on x86-64, but also fixed issues with ARM and PPC, which used similar code. Patch by Duncan Exon Smith! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194840 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/FastISel.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/FastISel.h b/include/llvm/CodeGen/FastISel.h index 0063474..1e0ef6b 100644 --- a/include/llvm/CodeGen/FastISel.h +++ b/include/llvm/CodeGen/FastISel.h @@ -358,6 +358,15 @@ protected: return 0; } + /// \brief Check if \c Add is an add that can be safely folded into \c GEP. + /// + /// \c Add can be folded into \c GEP if: + /// - \c Add is an add, + /// - \c Add's size matches \c GEP's, + /// - \c Add is in the same basic block as \c GEP, and + /// - \c Add has a constant operand. + bool canFoldAddIntoGEP(const User *GEP, const Value *Add); + private: bool SelectBinaryOp(const User *I, unsigned ISDOpcode); -- cgit v1.1 From 3a226015a0ca52936763a079da582656164c2908 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 15 Nov 2013 20:23:25 +0000 Subject: Readobj: If NumbersOfSections is 0xffff, it's an COFF import library. 0xffff does not mean that there are 65535 sections in a COFF file but indicates that it's a COFF import library. This patch fixes SEGV error when an import library file is passed to llvm-readobj. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194844 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Object/COFF.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h index ec8998c..e05ae6c 100644 --- a/include/llvm/Object/COFF.h +++ b/include/llvm/Object/COFF.h @@ -57,6 +57,8 @@ struct coff_file_header { support::ulittle32_t NumberOfSymbols; support::ulittle16_t SizeOfOptionalHeader; support::ulittle16_t Characteristics; + + bool isImportLibrary() const { return NumberOfSections == 0xffff; } }; /// The 32-bit PE header that follows the COFF header. -- cgit v1.1 From 8a631b2cbe2f8621eb3679a4898205da577453b7 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Fri, 15 Nov 2013 21:22:02 +0000 Subject: Path: Recognize COFF import library file magic. Summary: Make identify_magic to recognize COFF import file. Reviewers: Bigcheese CC: llvm-commits Differential Revision: http://llvm-reviews.chandlerc.com/D2165 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194852 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/FileSystem.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/Support/FileSystem.h b/include/llvm/Support/FileSystem.h index 48ff224..d301f84 100644 --- a/include/llvm/Support/FileSystem.h +++ b/include/llvm/Support/FileSystem.h @@ -238,6 +238,7 @@ struct file_magic { macho_dsym_companion, ///< Mach-O dSYM companion file macho_universal_binary, ///< Mach-O universal binary coff_object, ///< COFF object file + coff_import_library, ///< COFF import library pecoff_executable, ///< PECOFF executable file windows_resource ///< Windows compiled resource file (.rc) }; -- cgit v1.1 From 5758c3c832daf4c0b37042684f822fa1896966ac Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Fri, 15 Nov 2013 21:28:10 +0000 Subject: [AArch64] Fix the scalar NEON ACLE functions so that they return float/double rather than the vector equivalent. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194853 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 42b00aa..29026f6 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -233,15 +233,15 @@ def int_aarch64_neon_vpfminnmq : // Scalar Signed Integer Convert To Floating-point def int_aarch64_neon_vcvtf32_s32 : - Intrinsic<[llvm_v1f32_ty], [llvm_v1i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_float_ty], [llvm_v1i32_ty], [IntrNoMem]>; def int_aarch64_neon_vcvtf64_s64 : - Intrinsic<[llvm_v1f64_ty], [llvm_v1i64_ty], [IntrNoMem]>; + Intrinsic<[llvm_double_ty], [llvm_v1i64_ty], [IntrNoMem]>; // Scalar Unsigned Integer Convert To Floating-point def int_aarch64_neon_vcvtf32_u32 : - Intrinsic<[llvm_v1f32_ty], [llvm_v1i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_float_ty], [llvm_v1i32_ty], [IntrNoMem]>; def int_aarch64_neon_vcvtf64_u64 : - Intrinsic<[llvm_v1f64_ty], [llvm_v1i64_ty], [IntrNoMem]>; + Intrinsic<[llvm_double_ty], [llvm_v1i64_ty], [IntrNoMem]>; // Scalar Floating-point Reciprocal Exponent def int_aarch64_neon_vrecpx : Neon_1Arg_Intrinsic; @@ -330,15 +330,15 @@ def int_aarch64_neon_vqshlus_n : Neon_N2V_Intrinsic; // Scalar Signed Fixed-point Convert To Floating-Point (Immediate) def int_aarch64_neon_vcvtf32_n_s32 : - Intrinsic<[llvm_v1f32_ty], [llvm_v1i32_ty, llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_float_ty], [llvm_v1i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_aarch64_neon_vcvtf64_n_s64 : - Intrinsic<[llvm_v1f64_ty], [llvm_v1i64_ty, llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_double_ty], [llvm_v1i64_ty, llvm_i32_ty], [IntrNoMem]>; // Scalar Unsigned Fixed-point Convert To Floating-Point (Immediate) def int_aarch64_neon_vcvtf32_n_u32 : - Intrinsic<[llvm_v1f32_ty], [llvm_v1i32_ty, llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_float_ty], [llvm_v1i32_ty, llvm_i32_ty], [IntrNoMem]>; def int_aarch64_neon_vcvtf64_n_u64 : - Intrinsic<[llvm_v1f64_ty], [llvm_v1i64_ty, llvm_i32_ty], [IntrNoMem]>; + Intrinsic<[llvm_double_ty], [llvm_v1i64_ty, llvm_i32_ty], [IntrNoMem]>; // Scalar Floating-point Convert To Signed Fixed-point (Immediate) def int_aarch64_neon_vcvts_n_s32_f32 : -- cgit v1.1 From 5a364c5561ec04e33a6f5d52c14f1bac6f247ea0 Mon Sep 17 00:00:00 2001 From: Juergen Ributzka Date: Fri, 15 Nov 2013 22:34:48 +0000 Subject: [weak vtables] Remove a bunch of weak vtables This patch removes most of the trivial cases of weak vtables by pinning them to a single object file. Differential Revision: http://llvm-reviews.chandlerc.com/D2068 Reviewed by Andy git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194865 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineRegisterInfo.h | 3 ++- include/llvm/CodeGen/MachineScheduler.h | 2 ++ include/llvm/ExecutionEngine/ObjectBuffer.h | 2 -- include/llvm/ExecutionEngine/ObjectCache.h | 1 + include/llvm/ExecutionEngine/ObjectImage.h | 1 + include/llvm/MC/MCAtom.h | 1 + include/llvm/MC/MCStreamer.h | 1 + include/llvm/MC/MCWinCOFFObjectWriter.h | 2 ++ include/llvm/Support/CommandLine.h | 4 ++++ include/llvm/Support/ValueHandle.h | 5 +++-- include/llvm/Support/YAMLParser.h | 7 +++++++ include/llvm/Support/YAMLTraits.h | 7 +++++-- 12 files changed, 29 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineRegisterInfo.h b/include/llvm/CodeGen/MachineRegisterInfo.h index 736a0a2..58ca907 100644 --- a/include/llvm/CodeGen/MachineRegisterInfo.h +++ b/include/llvm/CodeGen/MachineRegisterInfo.h @@ -30,8 +30,9 @@ class PSetIterator; class MachineRegisterInfo { public: class Delegate { + virtual void anchor(); public: - virtual void MRI_NoteNewVirtualRegister(unsigned Reg) {} + virtual void MRI_NoteNewVirtualRegister(unsigned Reg) = 0; virtual ~Delegate() {} }; diff --git a/include/llvm/CodeGen/MachineScheduler.h b/include/llvm/CodeGen/MachineScheduler.h index e6af370..7782895 100644 --- a/include/llvm/CodeGen/MachineScheduler.h +++ b/include/llvm/CodeGen/MachineScheduler.h @@ -164,6 +164,7 @@ struct MachineSchedPolicy { /// Initialization sequence: /// initPolicy -> shouldTrackPressure -> initialize(DAG) -> registerRoots class MachineSchedStrategy { + virtual void anchor(); public: virtual ~MachineSchedStrategy() {} @@ -262,6 +263,7 @@ public: /// Mutate the DAG as a postpass after normal DAG building. class ScheduleDAGMutation { + virtual void anchor(); public: virtual ~ScheduleDAGMutation() {} diff --git a/include/llvm/ExecutionEngine/ObjectBuffer.h b/include/llvm/ExecutionEngine/ObjectBuffer.h index 32de404..51051c9 100644 --- a/include/llvm/ExecutionEngine/ObjectBuffer.h +++ b/include/llvm/ExecutionEngine/ObjectBuffer.h @@ -33,7 +33,6 @@ class ObjectBuffer { public: ObjectBuffer() {} ObjectBuffer(MemoryBuffer* Buf) : Buffer(Buf) {} - virtual ~ObjectBuffer() {} /// getMemBuffer - Like MemoryBuffer::getMemBuffer() this function /// returns a pointer to an object that is owned by the caller. However, @@ -58,7 +57,6 @@ protected: class ObjectBufferStream : public ObjectBuffer { public: ObjectBufferStream() : OS(SV) {} - virtual ~ObjectBufferStream() {} raw_ostream &getOStream() { return OS; } void flush() diff --git a/include/llvm/ExecutionEngine/ObjectCache.h b/include/llvm/ExecutionEngine/ObjectCache.h index 6f55e43..d1849df 100644 --- a/include/llvm/ExecutionEngine/ObjectCache.h +++ b/include/llvm/ExecutionEngine/ObjectCache.h @@ -20,6 +20,7 @@ class Module; /// ExecutionEngine for the purpose of avoiding compilation for Modules that /// have already been compiled and an object file is available. class ObjectCache { + virtual void anchor(); public: ObjectCache() { } diff --git a/include/llvm/ExecutionEngine/ObjectImage.h b/include/llvm/ExecutionEngine/ObjectImage.h index 9fddca7..076f4b1 100644 --- a/include/llvm/ExecutionEngine/ObjectImage.h +++ b/include/llvm/ExecutionEngine/ObjectImage.h @@ -25,6 +25,7 @@ namespace llvm { class ObjectImage { ObjectImage() LLVM_DELETED_FUNCTION; ObjectImage(const ObjectImage &other) LLVM_DELETED_FUNCTION; + virtual void anchor(); protected: OwningPtr Buffer; diff --git a/include/llvm/MC/MCAtom.h b/include/llvm/MC/MCAtom.h index 4758588..eab32d6 100644 --- a/include/llvm/MC/MCAtom.h +++ b/include/llvm/MC/MCAtom.h @@ -32,6 +32,7 @@ class MCDataAtom; /// \brief Represents a contiguous range of either instructions (a TextAtom) /// or data (a DataAtom). Address ranges are expressed as _closed_ intervals. class MCAtom { + virtual void anchor(); public: virtual ~MCAtom() {} diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 04af407..0b1fe6e 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -76,6 +76,7 @@ public: // FIXME: declared here because it is used from // lib/CodeGen/AsmPrinter/ARMException.cpp. class ARMTargetStreamer : public MCTargetStreamer { + virtual void anchor(); public: virtual void emitFnStart() = 0; virtual void emitFnEnd() = 0; diff --git a/include/llvm/MC/MCWinCOFFObjectWriter.h b/include/llvm/MC/MCWinCOFFObjectWriter.h index f13e7d5..e79e4bc 100644 --- a/include/llvm/MC/MCWinCOFFObjectWriter.h +++ b/include/llvm/MC/MCWinCOFFObjectWriter.h @@ -19,6 +19,8 @@ namespace llvm { class MCWinCOFFObjectTargetWriter { const unsigned Machine; + virtual void anchor(); + protected: MCWinCOFFObjectTargetWriter(unsigned Machine_); diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index c0bfbae..4efb6a6 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -350,6 +350,9 @@ struct cat { struct GenericOptionValue { virtual ~GenericOptionValue() {} virtual bool compare(const GenericOptionValue &V) const = 0; + +private: + virtual void anchor(); }; template struct OptionValue; @@ -1752,6 +1755,7 @@ void getRegisteredOptions(StringMap &Map); /// \brief Saves strings in the inheritor's stable storage and returns a stable /// raw character pointer. class StringSaver { + virtual void anchor(); public: virtual const char *SaveString(const char *Str) = 0; virtual ~StringSaver() {}; // Pacify -Wnon-virtual-dtor. diff --git a/include/llvm/Support/ValueHandle.h b/include/llvm/Support/ValueHandle.h index b49341c..bc02ba3 100644 --- a/include/llvm/Support/ValueHandle.h +++ b/include/llvm/Support/ValueHandle.h @@ -339,6 +339,7 @@ public: /// rearrange itself when the pointer changes). Unlike ValueHandleBase, this /// class has a vtable and a virtual destructor. class CallbackVH : public ValueHandleBase { + virtual void anchor(); protected: CallbackVH(const CallbackVH &RHS) : ValueHandleBase(Callback, RHS) {} @@ -365,13 +366,13 @@ public: /// /// All implementations must remove the reference from this object to the /// Value that's being destroyed. - virtual void deleted(); + virtual void deleted() { setValPtr(NULL); } /// Called when this->getValPtr()->replaceAllUsesWith(new_value) is called, /// _before_ any of the uses have actually been replaced. If WeakVH were /// implemented as a CallbackVH, it would use this method to call /// setValPtr(new_value). AssertingVH would do nothing in this method. - virtual void allUsesReplacedWith(Value *); + virtual void allUsesReplacedWith(Value *) {} }; } // End llvm namespace diff --git a/include/llvm/Support/YAMLParser.h b/include/llvm/Support/YAMLParser.h index 0e780ba..7020449 100644 --- a/include/llvm/Support/YAMLParser.h +++ b/include/llvm/Support/YAMLParser.h @@ -105,6 +105,7 @@ private: /// @brief Abstract base class for all Nodes. class Node { + virtual void anchor(); public: enum NodeKind { NK_Null, @@ -175,6 +176,7 @@ private: /// Example: /// !!null null class NullNode : public Node { + virtual void anchor(); public: NullNode(OwningPtr &D) : Node(NK_Null, D, StringRef(), StringRef()) {} @@ -190,6 +192,7 @@ public: /// Example: /// Adena class ScalarNode : public Node { + virtual void anchor(); public: ScalarNode(OwningPtr &D, StringRef Anchor, StringRef Tag, StringRef Val) @@ -231,6 +234,7 @@ private: /// Example: /// Section: .text class KeyValueNode : public Node { + virtual void anchor(); public: KeyValueNode(OwningPtr &D) : Node(NK_KeyValue, D, StringRef(), StringRef()) @@ -342,6 +346,7 @@ void skip(CollectionType &C) { /// Name: _main /// Scope: Global class MappingNode : public Node { + virtual void anchor(); public: enum MappingType { MT_Block, @@ -391,6 +396,7 @@ private: /// - Hello /// - World class SequenceNode : public Node { + virtual void anchor(); public: enum SequenceType { ST_Block, @@ -446,6 +452,7 @@ private: /// Example: /// *AnchorName class AliasNode : public Node { + virtual void anchor(); public: AliasNode(OwningPtr &D, StringRef Val) : Node(NK_Alias, D, StringRef(), StringRef()), Name(Val) {} diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h index d6eeaac..4c271e0 100644 --- a/include/llvm/Support/YAMLTraits.h +++ b/include/llvm/Support/YAMLTraits.h @@ -723,6 +723,7 @@ private: virtual bool canElideEmptySequence(); class HNode { + virtual void anchor(); public: HNode(Node *n) : _node(n) { } virtual ~HNode() { } @@ -732,9 +733,9 @@ private: }; class EmptyHNode : public HNode { + virtual void anchor(); public: EmptyHNode(Node *n) : HNode(n) { } - virtual ~EmptyHNode() {} static inline bool classof(const HNode *n) { return NullNode::classof(n->_node); } @@ -742,9 +743,9 @@ private: }; class ScalarHNode : public HNode { + virtual void anchor(); public: ScalarHNode(Node *n, StringRef s) : HNode(n), _value(s) { } - virtual ~ScalarHNode() { } StringRef value() const { return _value; } @@ -757,6 +758,7 @@ private: }; class MapHNode : public HNode { + virtual void anchor(); public: MapHNode(Node *n) : HNode(n) { } virtual ~MapHNode(); @@ -775,6 +777,7 @@ private: }; class SequenceHNode : public HNode { + virtual void anchor(); public: SequenceHNode(Node *n) : HNode(n) { } virtual ~SequenceHNode(); -- cgit v1.1 From a53bf06f7a998f9ea9e13ba844efc2460a2185dd Mon Sep 17 00:00:00 2001 From: Ana Pazos Date: Fri, 15 Nov 2013 23:32:10 +0000 Subject: Implemented aarch64 Neon scalar vmulx_lane intrinsics Implemented aarch64 Neon scalar vfma_lane intrinsics Implemented aarch64 Neon scalar vfms_lane intrinsics Implemented legacy vmul_n_f64, vmul_lane_f64, vmul_laneq_f64 intrinsics (v1f64 parameter type) using Neon scalar instructions. Implemented legacy vfma_lane_f64, vfms_lane_f64, vfma_laneq_f64, vfms_laneq_f64 intrinsics (v1f64 parameter type) using Neon scalar instructions. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194888 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 29026f6..27e78a5 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -67,8 +67,9 @@ def int_aarch64_neon_vpmaxnm : Neon_2Arg_Intrinsic; // Vector Pairwise minNum (Floating Point) def int_aarch64_neon_vpminnm : Neon_2Arg_Intrinsic; -// Vector Multiply Extended (Floating Point) -def int_aarch64_neon_vmulx : Neon_2Arg_Intrinsic; +// Vector Multiply Extended and Scalar Multiply Extended (Floating Point) +def int_aarch64_neon_vmulx : + Intrinsic<[llvm_anyfloat_ty], [LLVMMatchType<0>, LLVMMatchType<0>]>; class Neon_N2V_Intrinsic : Intrinsic<[llvm_anyvector_ty], [LLVMMatchType<0>, llvm_i32_ty], -- cgit v1.1 From 35de9946d5fc01d2fed970bdcc7966bad92bdbc4 Mon Sep 17 00:00:00 2001 From: Jim Grosbach Date: Sat, 16 Nov 2013 00:52:57 +0000 Subject: X86: Encode the 'h' cpu subtype in the MachO header for x86. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194906 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/MachO.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/MachO.h b/include/llvm/Support/MachO.h index dcf9e42..897a611 100644 --- a/include/llvm/Support/MachO.h +++ b/include/llvm/Support/MachO.h @@ -948,7 +948,8 @@ namespace llvm { CPU_SUBTYPE_X86_ALL = 3, CPU_SUBTYPE_X86_64_ALL = 3, - CPU_SUBTYPE_X86_ARCH1 = 4 + CPU_SUBTYPE_X86_ARCH1 = 4, + CPU_SUBTYPE_X86_64_H = 8 }; static inline int CPU_SUBTYPE_INTEL(int Family, int Model) { return Family | (Model << 4); -- cgit v1.1 From bd9f36f4db42f4b73caeb8cfe04e98f047d99375 Mon Sep 17 00:00:00 2001 From: "Duncan P. N. Exon Smith" Date: Sat, 16 Nov 2013 15:40:54 +0000 Subject: Fix filename in header comment git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194924 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/RuntimeLibcalls.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/RuntimeLibcalls.h b/include/llvm/CodeGen/RuntimeLibcalls.h index 37920ae..009b8a0 100644 --- a/include/llvm/CodeGen/RuntimeLibcalls.h +++ b/include/llvm/CodeGen/RuntimeLibcalls.h @@ -1,4 +1,4 @@ -//===-- CodeGen/RuntimeLibcall.h - Runtime Library Calls --------*- C++ -*-===// +//===-- CodeGen/RuntimeLibcalls.h - Runtime Library Calls -------*- C++ -*-===// // // The LLVM Compiler Infrastructure // -- cgit v1.1 From b69143c6a9bfc969e7c95bbd48b83bb962086070 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 16 Nov 2013 16:25:41 +0000 Subject: Annotate APInt methods where it's not clear whether they are in place with warn_unused_result. Fix ScalarEvolution bugs uncovered by this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194928 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/APInt.h | 64 ++++++++++++++++++++++++++--------------------- include/llvm/ADT/APSInt.h | 12 ++++----- 2 files changed, 41 insertions(+), 35 deletions(-) (limited to 'include') diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index 625a6db..d494ad2 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -765,7 +765,9 @@ public: return APInt(getBitWidth(), VAL & RHS.VAL); return AndSlowCase(RHS); } - APInt And(const APInt &RHS) const { return this->operator&(RHS); } + APInt LLVM_ATTRIBUTE_UNUSED_RESULT And(const APInt &RHS) const { + return this->operator&(RHS); + } /// \brief Bitwise OR operator. /// @@ -785,7 +787,9 @@ public: /// calling operator|. /// /// \returns An APInt value representing the bitwise OR of *this and RHS. - APInt Or(const APInt &RHS) const { return this->operator|(RHS); } + APInt LLVM_ATTRIBUTE_UNUSED_RESULT Or(const APInt &RHS) const { + return this->operator|(RHS); + } /// \brief Bitwise XOR operator. /// @@ -805,7 +809,9 @@ public: /// through the usage of operator^. /// /// \returns An APInt value representing the bitwise XOR of *this and RHS. - APInt Xor(const APInt &RHS) const { return this->operator^(RHS); } + APInt LLVM_ATTRIBUTE_UNUSED_RESULT Xor(const APInt &RHS) const { + return this->operator^(RHS); + } /// \brief Multiplication operator. /// @@ -837,17 +843,17 @@ public: /// \brief Arithmetic right-shift function. /// /// Arithmetic right-shift this APInt by shiftAmt. - APInt ashr(unsigned shiftAmt) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT ashr(unsigned shiftAmt) const; /// \brief Logical right-shift function. /// /// Logical right-shift this APInt by shiftAmt. - APInt lshr(unsigned shiftAmt) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT lshr(unsigned shiftAmt) const; /// \brief Left-shift function. /// /// Left-shift this APInt by shiftAmt. - APInt shl(unsigned shiftAmt) const { + APInt LLVM_ATTRIBUTE_UNUSED_RESULT shl(unsigned shiftAmt) const { assert(shiftAmt <= BitWidth && "Invalid shift amount"); if (isSingleWord()) { if (shiftAmt >= BitWidth) @@ -858,31 +864,31 @@ public: } /// \brief Rotate left by rotateAmt. - APInt rotl(unsigned rotateAmt) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT rotl(unsigned rotateAmt) const; /// \brief Rotate right by rotateAmt. - APInt rotr(unsigned rotateAmt) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT rotr(unsigned rotateAmt) const; /// \brief Arithmetic right-shift function. /// /// Arithmetic right-shift this APInt by shiftAmt. - APInt ashr(const APInt &shiftAmt) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT ashr(const APInt &shiftAmt) const; /// \brief Logical right-shift function. /// /// Logical right-shift this APInt by shiftAmt. - APInt lshr(const APInt &shiftAmt) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT lshr(const APInt &shiftAmt) const; /// \brief Left-shift function. /// /// Left-shift this APInt by shiftAmt. - APInt shl(const APInt &shiftAmt) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT shl(const APInt &shiftAmt) const; /// \brief Rotate left by rotateAmt. - APInt rotl(const APInt &rotateAmt) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT rotl(const APInt &rotateAmt) const; /// \brief Rotate right by rotateAmt. - APInt rotr(const APInt &rotateAmt) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT rotr(const APInt &rotateAmt) const; /// \brief Unsigned division operation. /// @@ -890,12 +896,12 @@ public: /// RHS are treated as unsigned quantities for purposes of this division. /// /// \returns a new APInt value containing the division result - APInt udiv(const APInt &RHS) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT udiv(const APInt &RHS) const; /// \brief Signed division function for APInt. /// /// Signed divide this APInt by APInt RHS. - APInt sdiv(const APInt &RHS) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT sdiv(const APInt &RHS) const; /// \brief Unsigned remainder operation. /// @@ -906,12 +912,12 @@ public: /// is *this. /// /// \returns a new APInt value containing the remainder result - APInt urem(const APInt &RHS) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT urem(const APInt &RHS) const; /// \brief Function for signed remainder operation. /// /// Signed remainder operation on APInt. - APInt srem(const APInt &RHS) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT srem(const APInt &RHS) const; /// \brief Dual division/remainder interface. /// @@ -1145,7 +1151,7 @@ public: /// /// Truncate the APInt to a specified width. It is an error to specify a width /// that is greater than or equal to the current width. - APInt trunc(unsigned width) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT trunc(unsigned width) const; /// \brief Sign extend to a new width. /// @@ -1153,38 +1159,38 @@ public: /// bit is set, the fill on the left will be done with 1 bits, otherwise zero. /// It is an error to specify a width that is less than or equal to the /// current width. - APInt sext(unsigned width) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT sext(unsigned width) const; /// \brief Zero extend to a new width. /// /// This operation zero extends the APInt to a new width. The high order bits /// are filled with 0 bits. It is an error to specify a width that is less /// than or equal to the current width. - APInt zext(unsigned width) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT zext(unsigned width) const; /// \brief Sign extend or truncate to width /// /// Make this APInt have the bit width given by \p width. The value is sign /// extended, truncated, or left alone to make it that width. - APInt sextOrTrunc(unsigned width) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT sextOrTrunc(unsigned width) const; /// \brief Zero extend or truncate to width /// /// Make this APInt have the bit width given by \p width. The value is zero /// extended, truncated, or left alone to make it that width. - APInt zextOrTrunc(unsigned width) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT zextOrTrunc(unsigned width) const; /// \brief Sign extend or truncate to width /// /// Make this APInt have the bit width given by \p width. The value is sign /// extended, or left alone to make it that width. - APInt sextOrSelf(unsigned width) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT sextOrSelf(unsigned width) const; /// \brief Zero extend or truncate to width /// /// Make this APInt have the bit width given by \p width. The value is zero /// extended, or left alone to make it that width. - APInt zextOrSelf(unsigned width) const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT zextOrSelf(unsigned width) const; /// @} /// \name Bit Manipulation Operators @@ -1421,7 +1427,7 @@ public: std::string toString(unsigned Radix, bool Signed) const; /// \returns a byte-swapped representation of this APInt Value. - APInt byteSwap() const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT byteSwap() const; /// \brief Converts this APInt to a double value. double roundToDouble(bool isSigned) const; @@ -1464,7 +1470,7 @@ public: /// /// The conversion does not do a translation from double to integer, it just /// re-interprets the bits of the double. - static APInt doubleToBits(double V) { + static APInt LLVM_ATTRIBUTE_UNUSED_RESULT doubleToBits(double V) { union { uint64_t I; double D; @@ -1477,7 +1483,7 @@ public: /// /// The conversion does not do a translation from float to integer, it just /// re-interprets the bits of the float. - static APInt floatToBits(float V) { + static APInt LLVM_ATTRIBUTE_UNUSED_RESULT floatToBits(float V) { union { unsigned I; float F; @@ -1507,12 +1513,12 @@ public: } /// \brief Compute the square root - APInt sqrt() const; + APInt LLVM_ATTRIBUTE_UNUSED_RESULT sqrt() const; /// \brief Get the absolute value; /// /// If *this is < 0 then return -(*this), otherwise *this; - APInt abs() const { + APInt LLVM_ATTRIBUTE_UNUSED_RESULT abs() const { if (isNegative()) return -(*this); return *this; diff --git a/include/llvm/ADT/APSInt.h b/include/llvm/ADT/APSInt.h index 11be4c5..ad035a7 100644 --- a/include/llvm/ADT/APSInt.h +++ b/include/llvm/ADT/APSInt.h @@ -68,18 +68,18 @@ public: } using APInt::toString; - APSInt trunc(uint32_t width) const { + APSInt LLVM_ATTRIBUTE_UNUSED_RESULT trunc(uint32_t width) const { return APSInt(APInt::trunc(width), IsUnsigned); } - APSInt extend(uint32_t width) const { + APSInt LLVM_ATTRIBUTE_UNUSED_RESULT extend(uint32_t width) const { if (IsUnsigned) return APSInt(zext(width), IsUnsigned); else return APSInt(sext(width), IsUnsigned); } - APSInt extOrTrunc(uint32_t width) const { + APSInt LLVM_ATTRIBUTE_UNUSED_RESULT extOrTrunc(uint32_t width) const { if (IsUnsigned) return APSInt(zextOrTrunc(width), IsUnsigned); else @@ -212,7 +212,7 @@ public: assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); return APSInt(static_cast(*this) & RHS, IsUnsigned); } - APSInt And(const APSInt& RHS) const { + APSInt LLVM_ATTRIBUTE_UNUSED_RESULT And(const APSInt& RHS) const { return this->operator&(RHS); } @@ -220,7 +220,7 @@ public: assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); return APSInt(static_cast(*this) | RHS, IsUnsigned); } - APSInt Or(const APSInt& RHS) const { + APSInt LLVM_ATTRIBUTE_UNUSED_RESULT Or(const APSInt& RHS) const { return this->operator|(RHS); } @@ -229,7 +229,7 @@ public: assert(IsUnsigned == RHS.IsUnsigned && "Signedness mismatch!"); return APSInt(static_cast(*this) ^ RHS, IsUnsigned); } - APSInt Xor(const APSInt& RHS) const { + APSInt LLVM_ATTRIBUTE_UNUSED_RESULT Xor(const APSInt& RHS) const { return this->operator^(RHS); } -- cgit v1.1 From 2905440bdd9627f202398137aab5ded38f681fc9 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer Date: Sat, 16 Nov 2013 16:25:47 +0000 Subject: ScalarEvolution: Warn if the result of setFlags/clearFlags is unused. This was a source of bugs in the past. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194929 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/ScalarEvolution.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/llvm/Analysis/ScalarEvolution.h b/include/llvm/Analysis/ScalarEvolution.h index 944b144..d7f6178 100644 --- a/include/llvm/Analysis/ScalarEvolution.h +++ b/include/llvm/Analysis/ScalarEvolution.h @@ -189,15 +189,16 @@ namespace llvm { /// Convenient NoWrapFlags manipulation that hides enum casts and is /// visible in the ScalarEvolution name space. - static SCEV::NoWrapFlags maskFlags(SCEV::NoWrapFlags Flags, int Mask) { + static SCEV::NoWrapFlags LLVM_ATTRIBUTE_UNUSED_RESULT + maskFlags(SCEV::NoWrapFlags Flags, int Mask) { return (SCEV::NoWrapFlags)(Flags & Mask); } - static SCEV::NoWrapFlags setFlags(SCEV::NoWrapFlags Flags, - SCEV::NoWrapFlags OnFlags) { + static SCEV::NoWrapFlags LLVM_ATTRIBUTE_UNUSED_RESULT + setFlags(SCEV::NoWrapFlags Flags, SCEV::NoWrapFlags OnFlags) { return (SCEV::NoWrapFlags)(Flags | OnFlags); } - static SCEV::NoWrapFlags clearFlags(SCEV::NoWrapFlags Flags, - SCEV::NoWrapFlags OffFlags) { + static SCEV::NoWrapFlags LLVM_ATTRIBUTE_UNUSED_RESULT + clearFlags(SCEV::NoWrapFlags Flags, SCEV::NoWrapFlags OffFlags) { return (SCEV::NoWrapFlags)(Flags & ~OffFlags); } -- cgit v1.1 From bebe48dbfe00078329341945bfb11f778ace6d12 Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Sat, 16 Nov 2013 23:59:05 +0000 Subject: Add a loop rerolling pass This adds a loop rerolling pass: the opposite of (partial) loop unrolling. The transformation aims to take loops like this: for (int i = 0; i < 3200; i += 5) { a[i] += alpha * b[i]; a[i + 1] += alpha * b[i + 1]; a[i + 2] += alpha * b[i + 2]; a[i + 3] += alpha * b[i + 3]; a[i + 4] += alpha * b[i + 4]; } and turn them into this: for (int i = 0; i < 3200; ++i) { a[i] += alpha * b[i]; } and loops like this: for (int i = 0; i < 500; ++i) { x[3*i] = foo(0); x[3*i+1] = foo(0); x[3*i+2] = foo(0); } and turn them into this: for (int i = 0; i < 1500; ++i) { x[i] = foo(0); } There are two motivations for this transformation: 1. Code-size reduction (especially relevant, obviously, when compiling for code size). 2. Providing greater choice to the loop vectorizer (and generic unroller) to choose the unrolling factor (and a better ability to vectorize). The loop vectorizer can take vector lengths and register pressure into account when choosing an unrolling factor, for example, and a pre-unrolled loop limits that choice. This is especially problematic if the manual unrolling was optimized for a machine different from the current target. The current implementation is limited to single basic-block loops only. The rerolling recognition should work regardless of how the loop iterations are intermixed within the loop body (subject to dependency and side-effect constraints), but the significant restriction is that the order of the instructions in each iteration must be identical. This seems sufficient to capture all current use cases. This pass is not currently enabled by default at any optimization level. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194939 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm-c/Transforms/Scalar.h | 3 +++ include/llvm/InitializePasses.h | 1 + include/llvm/LinkAllPasses.h | 1 + include/llvm/Transforms/Scalar.h | 6 ++++++ 4 files changed, 11 insertions(+) (limited to 'include') diff --git a/include/llvm-c/Transforms/Scalar.h b/include/llvm-c/Transforms/Scalar.h index 2456c6c..355e8dc 100644 --- a/include/llvm-c/Transforms/Scalar.h +++ b/include/llvm-c/Transforms/Scalar.h @@ -65,6 +65,9 @@ void LLVMAddLoopIdiomPass(LLVMPassManagerRef PM); /** See llvm::createLoopRotatePass function. */ void LLVMAddLoopRotatePass(LLVMPassManagerRef PM); +/** See llvm::createLoopRerollPass function. */ +void LLVMAddLoopRerollPass(LLVMPassManagerRef PM); + /** See llvm::createLoopUnrollPass function. */ void LLVMAddLoopUnrollPass(LLVMPassManagerRef PM); diff --git a/include/llvm/InitializePasses.h b/include/llvm/InitializePasses.h index acfe3bd..aefb3c0 100644 --- a/include/llvm/InitializePasses.h +++ b/include/llvm/InitializePasses.h @@ -162,6 +162,7 @@ void initializeLoopRotatePass(PassRegistry&); void initializeLoopSimplifyPass(PassRegistry&); void initializeLoopStrengthReducePass(PassRegistry&); void initializeGlobalMergePass(PassRegistry&); +void initializeLoopRerollPass(PassRegistry&); void initializeLoopUnrollPass(PassRegistry&); void initializeLoopUnswitchPass(PassRegistry&); void initializeLoopIdiomRecognizePass(PassRegistry&); diff --git a/include/llvm/LinkAllPasses.h b/include/llvm/LinkAllPasses.h index d97e54c..8183fa2 100644 --- a/include/llvm/LinkAllPasses.h +++ b/include/llvm/LinkAllPasses.h @@ -91,6 +91,7 @@ namespace { (void) llvm::createLoopExtractorPass(); (void) llvm::createLoopSimplifyPass(); (void) llvm::createLoopStrengthReducePass(); + (void) llvm::createLoopRerollPass(); (void) llvm::createLoopUnrollPass(); (void) llvm::createLoopUnswitchPass(); (void) llvm::createLoopIdiomPass(); diff --git a/include/llvm/Transforms/Scalar.h b/include/llvm/Transforms/Scalar.h index 5d06157..1521c4c 100644 --- a/include/llvm/Transforms/Scalar.h +++ b/include/llvm/Transforms/Scalar.h @@ -145,6 +145,12 @@ Pass *createLoopUnrollPass(int Threshold = -1, int Count = -1, //===----------------------------------------------------------------------===// // +// LoopReroll - This pass is a simple loop rerolling pass. +// +Pass *createLoopRerollPass(); + +//===----------------------------------------------------------------------===// +// // LoopRotate - This pass is a simple loop rotating pass. // Pass *createLoopRotatePass(); -- cgit v1.1 From bb756ca24401e190e3b704e5d92759c7a79cc6b7 Mon Sep 17 00:00:00 2001 From: Andrew Trick Date: Sun, 17 Nov 2013 01:36:23 +0000 Subject: Added a size field to the stack map record to handle subregister spills. Implementing this on bigendian platforms could get strange. I added a target hook, getStackSlotRange, per Jakob's recommendation to make this as explicit as possible. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194942 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/StackMaps.h | 9 +++++---- include/llvm/Target/TargetInstrInfo.h | 17 +++++++++++++++++ 2 files changed, 22 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/StackMaps.h b/include/llvm/CodeGen/StackMaps.h index c79c342..f832132 100644 --- a/include/llvm/CodeGen/StackMaps.h +++ b/include/llvm/CodeGen/StackMaps.h @@ -26,18 +26,19 @@ public: enum LocationType { Unprocessed, Register, Direct, Indirect, Constant, ConstantIndex }; LocationType LocType; + unsigned Size; unsigned Reg; int64_t Offset; - Location() : LocType(Unprocessed), Reg(0), Offset(0) {} - Location(LocationType LocType, unsigned Reg, int64_t Offset) - : LocType(LocType), Reg(Reg), Offset(Offset) {} + Location() : LocType(Unprocessed), Size(0), Reg(0), Offset(0) {} + Location(LocationType LocType, unsigned Size, unsigned Reg, int64_t Offset) + : LocType(LocType), Size(Size), Reg(Reg), Offset(Offset) {} }; // Typedef a function pointer for functions that parse sequences of operands // and return a Location, plus a new "next" operand iterator. typedef std::pair (*OperandParser)(MachineInstr::const_mop_iterator, - MachineInstr::const_mop_iterator); + MachineInstr::const_mop_iterator, const TargetMachine&); // OpTypes are used to encode information about the following logical // operand (which may consist of several MachineOperands) for the diff --git a/include/llvm/Target/TargetInstrInfo.h b/include/llvm/Target/TargetInstrInfo.h index f9edc7d..d4e14f6 100644 --- a/include/llvm/Target/TargetInstrInfo.h +++ b/include/llvm/Target/TargetInstrInfo.h @@ -181,6 +181,23 @@ public: return false; } + /// Compute the size in bytes and offset within a stack slot of a spilled + /// register or subregister. + /// + /// \param [out] Size in bytes of the spilled value. + /// \param [out] Offset in bytes within the stack slot. + /// \returns true if both Size and Offset are successfully computed. + /// + /// Not all subregisters have computable spill slots. For example, + /// subregisters registers may not be byte-sized, and a pair of discontiguous + /// subregisters has no single offset. + /// + /// Targets with nontrivial bigendian implementations may need to override + /// this, particularly to support spilled vector registers. + virtual bool getStackSlotRange(const TargetRegisterClass *RC, unsigned SubIdx, + unsigned &Size, unsigned &Offset, + const TargetMachine *TM) const; + /// reMaterialize - Re-issue the specified 'original' instruction at the /// specific location targeting a new destination register. /// The register in Orig->getOperand(0).getReg() will be substituted by -- cgit v1.1 From 8417e857818e972f318bd549caabc54bdf537c26 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sun, 17 Nov 2013 03:18:05 +0000 Subject: [PM] Completely remove support for explicit 'require' methods on the AnalysisManager. All this method did was assert something and we have a perfectly good way to trigger that assert from the query path. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194947 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/PassManager.h | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/PassManager.h b/include/llvm/IR/PassManager.h index 08aac77..833547a 100644 --- a/include/llvm/IR/PassManager.h +++ b/include/llvm/IR/PassManager.h @@ -151,6 +151,9 @@ public: /// constructed around. template const typename PassT::Result &getResult(Module *M) { + assert(ModuleAnalysisPasses.count(PassT::ID()) && + "This analysis pass was not registered prior to being queried"); + const AnalysisResultConcept &ResultConcept = getResultImpl(PassT::ID(), M); typedef AnalysisResultModel ResultModelT; @@ -163,6 +166,9 @@ public: /// re-run the analysis to produce a valid result. template const typename PassT::Result &getResult(Function *F) { + assert(FunctionAnalysisPasses.count(PassT::ID()) && + "This analysis pass was not registered prior to being queried"); + const AnalysisResultConcept &ResultConcept = getResultImpl(PassT::ID(), F); typedef AnalysisResultModel ResultModelT; @@ -180,21 +186,6 @@ public: registerAnalysisPassImpl(llvm_move(Pass)); } - /// \brief Require that a particular analysis pass is provided by the manager. - /// - /// This allows transform passes to assert ther requirements during - /// construction and fail fast if the analysis manager doesn't provide the - /// needed facilities. - /// - /// We force the analysis manager to have these passes explicitly registered - /// first to ensure that there is exactly one place in the code responsible - /// for adding an analysis pass to the manager as all transforms will share - /// a single pass within the manager and each may not be the canonical place - /// to initialize such a pass. - template void requireAnalysisPass() { - requireAnalysisPassImpl(); - } - /// \brief Invalidate a specific analysis pass for an IR module. /// /// Note that the analysis result can disregard invalidation. @@ -334,22 +325,6 @@ private: new AnalysisPassModel(llvm_move(Pass)); } - /// \brief Module pass specific implementation of requirement declaration. - template - typename enable_if >::type - requireAnalysisPassImpl() { - assert(ModuleAnalysisPasses.count(PassT::ID()) && - "This analysis pass was not registered prior to being required"); - } - - /// \brief Function pass specific implementation of requirement declaration. - template - typename enable_if >::type - requireAnalysisPassImpl() { - assert(FunctionAnalysisPasses.count(PassT::ID()) && - "This analysis pass was not registered prior to being required"); - } - /// \brief Map type from module analysis pass ID to pass concept pointer. typedef DenseMap > > -- cgit v1.1 From e7a1e3ee8279f12d0f2b49fb198d577949795c88 Mon Sep 17 00:00:00 2001 From: Michael Gottesman Date: Sun, 17 Nov 2013 03:25:24 +0000 Subject: [block-freq] Add BlockFrequency::scale that returns a remainder from the division and make the private scale in BlockFrequency more performant. This change is the first in a series of changes improving LLVM's Block Frequency propogation implementation to not lose probability mass in branchy code when propogating block frequency information from a basic block to its successors. This patch is a simple infrastructure improvement that does not actually modify the block frequency algorithm. The specific changes are: 1. Changes the division algorithm used when scaling block frequencies by branch probabilities to a short division algorithm. This gives us the remainder for free as well as provides a nice speed boost. When I benched the old routine and the new routine on a Sandy Bridge iMac with disabled turbo mode performing 8192 iterations on an array of length 32768, I saw ~600% increase in speed in mean/median performance. 2. Exposes a scale method that returns a remainder. This is important so we can ensure that when we scale a block frequency by some branch probability BP = N/D, the remainder from the division by D can be retrieved and propagated to other children to ensure no probability mass is lost (more to come on this). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194950 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/BlockFrequency.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/BlockFrequency.h b/include/llvm/Support/BlockFrequency.h index 666b3c8..21879e7 100644 --- a/include/llvm/Support/BlockFrequency.h +++ b/include/llvm/Support/BlockFrequency.h @@ -27,8 +27,10 @@ class BlockFrequency { uint64_t Frequency; static const int64_t ENTRY_FREQ = 1 << 14; - // Scale frequency by N/D, saturating on overflow. - void scale(uint32_t N, uint32_t D); + /// \brief Scale the given BlockFrequency by N/D. Return the remainder from + /// the division by D. Upon overflow, the routine will saturate and + /// additionally will return the remainder set to D. + uint32_t scale(uint32_t N, uint32_t D); public: BlockFrequency(uint64_t Freq = 0) : Frequency(Freq) { } @@ -57,6 +59,10 @@ public: BlockFrequency &operator+=(const BlockFrequency &Freq); const BlockFrequency operator+(const BlockFrequency &Freq) const; + /// \brief Scale the given BlockFrequency by N/D. Return the remainder from + /// the division by D. Upon overflow, the routine will saturate. + uint32_t scale(const BranchProbability &Prob); + bool operator<(const BlockFrequency &RHS) const { return Frequency < RHS.Frequency; } -- cgit v1.1 From e5a694ab578416d8d280836937c7d2714b1a83e6 Mon Sep 17 00:00:00 2001 From: Yaron Keren Date: Sun, 17 Nov 2013 09:47:39 +0000 Subject: DebugLoc defines LineCol as 32 bit in comment but unsigned in code. This patch modifies LineCol to be a uint32_t. See http://llvm.org/bugs/show_bug.cgi?id=17957 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194957 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/DebugLoc.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/Support/DebugLoc.h b/include/llvm/Support/DebugLoc.h index f35d407..05f31d7 100644 --- a/include/llvm/Support/DebugLoc.h +++ b/include/llvm/Support/DebugLoc.h @@ -15,6 +15,8 @@ #ifndef LLVM_SUPPORT_DEBUGLOC_H #define LLVM_SUPPORT_DEBUGLOC_H +#include "llvm/Support/DataTypes.h" + namespace llvm { template struct DenseMapInfo; class MDNode; @@ -45,7 +47,7 @@ namespace llvm { /// LineCol - This 32-bit value encodes the line and column number for the /// location, encoded as 24-bits for line and 8 bits for col. A value of 0 /// for either means unknown. - unsigned LineCol; + uint32_t LineCol; /// ScopeIdx - This is an opaque ID# for Scope/InlinedAt information, /// decoded by LLVMContext. 0 is unknown. -- cgit v1.1 From c8dc96be28fd1a3d6ddebbb48b8d55b61e4bd89b Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Sun, 17 Nov 2013 16:02:50 +0000 Subject: Add a loop rerolling flag to the PassManagerBuilder This adds a boolean member variable to the PassManagerBuilder to control loop rerolling (just like we have for unrolling and the various vectorization options). This is necessary for control by the frontend. Loop rerolling remains disabled by default at all optimization levels. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194966 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Transforms/IPO/PassManagerBuilder.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/Transforms/IPO/PassManagerBuilder.h b/include/llvm/Transforms/IPO/PassManagerBuilder.h index 3648a3d..2788774 100644 --- a/include/llvm/Transforms/IPO/PassManagerBuilder.h +++ b/include/llvm/Transforms/IPO/PassManagerBuilder.h @@ -112,6 +112,7 @@ public: bool SLPVectorize; bool LoopVectorize; bool LateVectorize; + bool RerollLoops; private: /// ExtensionList - This is list of all of the extensions that are registered. -- cgit v1.1 From 2b31b8227fb5507c26a8c4724574fc87fb90f482 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Sun, 17 Nov 2013 18:42:37 +0000 Subject: Debug Info Verifier: enable public functions of Finder to update the type map. We used to depend on running processModule before the other public functions such as processDeclare, processValue and processLocation. We are now relaxing the constraint by adding a module argument to the three functions and letting the three functions to initialize the type map. This will be used in a follow-on patch that collects nodes reachable from a Function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194973 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 0a070fe..e73fda8 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -766,16 +766,19 @@ public: void processModule(const Module &M); /// processDeclare - Process DbgDeclareInst. - void processDeclare(const DbgDeclareInst *DDI); + void processDeclare(const Module &M, const DbgDeclareInst *DDI); /// Process DbgValueInst. - void processValue(const DbgValueInst *DVI); + void processValue(const Module &M, const DbgValueInst *DVI); /// processLocation - Process DILocation. - void processLocation(DILocation Loc); + void processLocation(const Module &M, DILocation Loc); /// Clear all lists. void reset(); private: + /// Initialize TypeIdentifierMap. + void IntializeTypeMap(const Module &M); + /// processType - Process DIType. void processType(DIType DT); @@ -828,6 +831,8 @@ private: SmallVector Scopes; // Scopes SmallPtrSet NodesSeen; DITypeIdentifierMap TypeIdentifierMap; + /// Specify if TypeIdentifierMap is initialized. + bool TypeMapInitialized; }; } // end namespace llvm -- cgit v1.1 From 6950be28511caf355abdf405404b5f37cc136bc5 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Sun, 17 Nov 2013 19:35:03 +0000 Subject: Debug Info: fix typo in function name. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194975 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index e73fda8..91bbc2b 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -777,7 +777,7 @@ public: private: /// Initialize TypeIdentifierMap. - void IntializeTypeMap(const Module &M); + void InitializeTypeMap(const Module &M); /// processType - Process DIType. void processType(DIType DT); -- cgit v1.1 From 1572ba716bad4944a83040adef76c186c4841e95 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Mon, 18 Nov 2013 02:51:33 +0000 Subject: Fix spacing, forward declare order. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194985 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/AutoUpgrade.h | 8 ++++---- include/llvm/IR/Constants.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/include/llvm/AutoUpgrade.h b/include/llvm/AutoUpgrade.h index 22d0c43..b638d4f 100644 --- a/include/llvm/AutoUpgrade.h +++ b/include/llvm/AutoUpgrade.h @@ -15,14 +15,14 @@ #define LLVM_AUTOUPGRADE_H namespace llvm { + class CallInst; class Constant; - class Module; - class GlobalVariable; class Function; - class CallInst; class Instruction; - class Value; + class Module; + class GlobalVariable; class Type; + class Value; /// This is a more granular function that simply checks an intrinsic function /// for upgrading, and returns true if it requires upgrading. It may return diff --git a/include/llvm/IR/Constants.h b/include/llvm/IR/Constants.h index b6e2082..f1cee5a 100644 --- a/include/llvm/IR/Constants.h +++ b/include/llvm/IR/Constants.h @@ -862,7 +862,7 @@ public: static Constant *getPtrToInt(Constant *C, Type *Ty); static Constant *getIntToPtr(Constant *C, Type *Ty); static Constant *getBitCast (Constant *C, Type *Ty); - static Constant *getAddrSpaceCast (Constant *C, Type *Ty); + static Constant *getAddrSpaceCast(Constant *C, Type *Ty); static Constant *getNSWNeg(Constant *C) { return getNeg(C, false, true); } static Constant *getNUWNeg(Constant *C) { return getNeg(C, true, false); } @@ -1080,8 +1080,8 @@ public: /// as this ConstantExpr. The instruction is not linked to any basic block. /// /// A better approach to this could be to have a constructor for Instruction - /// which would take a ConstantExpr parameter, but that would have spread - /// implementation details of ConstantExpr outside of Constants.cpp, which + /// which would take a ConstantExpr parameter, but that would have spread + /// implementation details of ConstantExpr outside of Constants.cpp, which /// would make it harder to remove ConstantExprs altogether. Instruction *getAsInstruction(); -- cgit v1.1 From 97577757c6dc84233ad10cd432664257e593e76d Mon Sep 17 00:00:00 2001 From: Hao Liu Date: Mon, 18 Nov 2013 06:31:53 +0000 Subject: Implement the newly added ACLE functions for ld1/st1 with 2/3/4 vectors. The functions are like: vst1_s8_x2 ... git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194990 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 27e78a5..c403963 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -163,6 +163,33 @@ def int_aarch64_neon_vtbx4 : LLVMMatchType<1>, LLVMMatchType<1>, LLVMMatchType<0>], [IntrNoMem]>; +// Vector Load/store +def int_aarch64_neon_vld1x2 : Intrinsic<[llvm_anyvector_ty, LLVMMatchType<0>], + [llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; +def int_aarch64_neon_vld1x3 : Intrinsic<[llvm_anyvector_ty, LLVMMatchType<0>, + LLVMMatchType<0>], + [llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; +def int_aarch64_neon_vld1x4 : Intrinsic<[llvm_anyvector_ty, LLVMMatchType<0>, + LLVMMatchType<0>, LLVMMatchType<0>], + [llvm_ptr_ty, llvm_i32_ty], + [IntrReadArgMem]>; + +def int_aarch64_neon_vst1x2 : Intrinsic<[], + [llvm_ptr_ty, llvm_anyvector_ty, + LLVMMatchType<0>, llvm_i32_ty], + [IntrReadWriteArgMem]>; +def int_aarch64_neon_vst1x3 : Intrinsic<[], + [llvm_ptr_ty, llvm_anyvector_ty, + LLVMMatchType<0>, LLVMMatchType<0>, + llvm_i32_ty], [IntrReadWriteArgMem]>; +def int_aarch64_neon_vst1x4 : Intrinsic<[], + [llvm_ptr_ty, llvm_anyvector_ty, + LLVMMatchType<0>, LLVMMatchType<0>, + LLVMMatchType<0>, llvm_i32_ty], + [IntrReadWriteArgMem]>; + // Scalar Add def int_aarch64_neon_vaddds : Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], [IntrNoMem]>; -- cgit v1.1 From b21ab43cfc3fa0dacf5c95f04e58b6d804b59a16 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Mon, 18 Nov 2013 09:31:53 +0000 Subject: Revert r194865 and r194874. This change is incorrect. If you delete virtual destructor of both a base class and a subclass, then the following code: Base *foo = new Child(); delete foo; will not cause the destructor for members of Child class. As a result, I observe plently of memory leaks. Notable examples I investigated are: ObjectBuffer and ObjectBufferStream, AttributeImpl and StringSAttributeImpl. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194997 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineRegisterInfo.h | 3 +-- include/llvm/CodeGen/MachineScheduler.h | 2 -- include/llvm/ExecutionEngine/ObjectBuffer.h | 2 ++ include/llvm/ExecutionEngine/ObjectCache.h | 1 - include/llvm/ExecutionEngine/ObjectImage.h | 1 - include/llvm/MC/MCAtom.h | 1 - include/llvm/MC/MCStreamer.h | 1 - include/llvm/MC/MCWinCOFFObjectWriter.h | 2 -- include/llvm/Support/CommandLine.h | 4 ---- include/llvm/Support/ValueHandle.h | 5 ++--- include/llvm/Support/YAMLParser.h | 7 ------- include/llvm/Support/YAMLTraits.h | 7 ++----- 12 files changed, 7 insertions(+), 29 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineRegisterInfo.h b/include/llvm/CodeGen/MachineRegisterInfo.h index 58ca907..736a0a2 100644 --- a/include/llvm/CodeGen/MachineRegisterInfo.h +++ b/include/llvm/CodeGen/MachineRegisterInfo.h @@ -30,9 +30,8 @@ class PSetIterator; class MachineRegisterInfo { public: class Delegate { - virtual void anchor(); public: - virtual void MRI_NoteNewVirtualRegister(unsigned Reg) = 0; + virtual void MRI_NoteNewVirtualRegister(unsigned Reg) {} virtual ~Delegate() {} }; diff --git a/include/llvm/CodeGen/MachineScheduler.h b/include/llvm/CodeGen/MachineScheduler.h index 7782895..e6af370 100644 --- a/include/llvm/CodeGen/MachineScheduler.h +++ b/include/llvm/CodeGen/MachineScheduler.h @@ -164,7 +164,6 @@ struct MachineSchedPolicy { /// Initialization sequence: /// initPolicy -> shouldTrackPressure -> initialize(DAG) -> registerRoots class MachineSchedStrategy { - virtual void anchor(); public: virtual ~MachineSchedStrategy() {} @@ -263,7 +262,6 @@ public: /// Mutate the DAG as a postpass after normal DAG building. class ScheduleDAGMutation { - virtual void anchor(); public: virtual ~ScheduleDAGMutation() {} diff --git a/include/llvm/ExecutionEngine/ObjectBuffer.h b/include/llvm/ExecutionEngine/ObjectBuffer.h index 51051c9..32de404 100644 --- a/include/llvm/ExecutionEngine/ObjectBuffer.h +++ b/include/llvm/ExecutionEngine/ObjectBuffer.h @@ -33,6 +33,7 @@ class ObjectBuffer { public: ObjectBuffer() {} ObjectBuffer(MemoryBuffer* Buf) : Buffer(Buf) {} + virtual ~ObjectBuffer() {} /// getMemBuffer - Like MemoryBuffer::getMemBuffer() this function /// returns a pointer to an object that is owned by the caller. However, @@ -57,6 +58,7 @@ protected: class ObjectBufferStream : public ObjectBuffer { public: ObjectBufferStream() : OS(SV) {} + virtual ~ObjectBufferStream() {} raw_ostream &getOStream() { return OS; } void flush() diff --git a/include/llvm/ExecutionEngine/ObjectCache.h b/include/llvm/ExecutionEngine/ObjectCache.h index d1849df..6f55e43 100644 --- a/include/llvm/ExecutionEngine/ObjectCache.h +++ b/include/llvm/ExecutionEngine/ObjectCache.h @@ -20,7 +20,6 @@ class Module; /// ExecutionEngine for the purpose of avoiding compilation for Modules that /// have already been compiled and an object file is available. class ObjectCache { - virtual void anchor(); public: ObjectCache() { } diff --git a/include/llvm/ExecutionEngine/ObjectImage.h b/include/llvm/ExecutionEngine/ObjectImage.h index 076f4b1..9fddca7 100644 --- a/include/llvm/ExecutionEngine/ObjectImage.h +++ b/include/llvm/ExecutionEngine/ObjectImage.h @@ -25,7 +25,6 @@ namespace llvm { class ObjectImage { ObjectImage() LLVM_DELETED_FUNCTION; ObjectImage(const ObjectImage &other) LLVM_DELETED_FUNCTION; - virtual void anchor(); protected: OwningPtr Buffer; diff --git a/include/llvm/MC/MCAtom.h b/include/llvm/MC/MCAtom.h index eab32d6..4758588 100644 --- a/include/llvm/MC/MCAtom.h +++ b/include/llvm/MC/MCAtom.h @@ -32,7 +32,6 @@ class MCDataAtom; /// \brief Represents a contiguous range of either instructions (a TextAtom) /// or data (a DataAtom). Address ranges are expressed as _closed_ intervals. class MCAtom { - virtual void anchor(); public: virtual ~MCAtom() {} diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 0b1fe6e..04af407 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -76,7 +76,6 @@ public: // FIXME: declared here because it is used from // lib/CodeGen/AsmPrinter/ARMException.cpp. class ARMTargetStreamer : public MCTargetStreamer { - virtual void anchor(); public: virtual void emitFnStart() = 0; virtual void emitFnEnd() = 0; diff --git a/include/llvm/MC/MCWinCOFFObjectWriter.h b/include/llvm/MC/MCWinCOFFObjectWriter.h index e79e4bc..f13e7d5 100644 --- a/include/llvm/MC/MCWinCOFFObjectWriter.h +++ b/include/llvm/MC/MCWinCOFFObjectWriter.h @@ -19,8 +19,6 @@ namespace llvm { class MCWinCOFFObjectTargetWriter { const unsigned Machine; - virtual void anchor(); - protected: MCWinCOFFObjectTargetWriter(unsigned Machine_); diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index 4efb6a6..c0bfbae 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -350,9 +350,6 @@ struct cat { struct GenericOptionValue { virtual ~GenericOptionValue() {} virtual bool compare(const GenericOptionValue &V) const = 0; - -private: - virtual void anchor(); }; template struct OptionValue; @@ -1755,7 +1752,6 @@ void getRegisteredOptions(StringMap &Map); /// \brief Saves strings in the inheritor's stable storage and returns a stable /// raw character pointer. class StringSaver { - virtual void anchor(); public: virtual const char *SaveString(const char *Str) = 0; virtual ~StringSaver() {}; // Pacify -Wnon-virtual-dtor. diff --git a/include/llvm/Support/ValueHandle.h b/include/llvm/Support/ValueHandle.h index bc02ba3..b49341c 100644 --- a/include/llvm/Support/ValueHandle.h +++ b/include/llvm/Support/ValueHandle.h @@ -339,7 +339,6 @@ public: /// rearrange itself when the pointer changes). Unlike ValueHandleBase, this /// class has a vtable and a virtual destructor. class CallbackVH : public ValueHandleBase { - virtual void anchor(); protected: CallbackVH(const CallbackVH &RHS) : ValueHandleBase(Callback, RHS) {} @@ -366,13 +365,13 @@ public: /// /// All implementations must remove the reference from this object to the /// Value that's being destroyed. - virtual void deleted() { setValPtr(NULL); } + virtual void deleted(); /// Called when this->getValPtr()->replaceAllUsesWith(new_value) is called, /// _before_ any of the uses have actually been replaced. If WeakVH were /// implemented as a CallbackVH, it would use this method to call /// setValPtr(new_value). AssertingVH would do nothing in this method. - virtual void allUsesReplacedWith(Value *) {} + virtual void allUsesReplacedWith(Value *); }; } // End llvm namespace diff --git a/include/llvm/Support/YAMLParser.h b/include/llvm/Support/YAMLParser.h index 7020449..0e780ba 100644 --- a/include/llvm/Support/YAMLParser.h +++ b/include/llvm/Support/YAMLParser.h @@ -105,7 +105,6 @@ private: /// @brief Abstract base class for all Nodes. class Node { - virtual void anchor(); public: enum NodeKind { NK_Null, @@ -176,7 +175,6 @@ private: /// Example: /// !!null null class NullNode : public Node { - virtual void anchor(); public: NullNode(OwningPtr &D) : Node(NK_Null, D, StringRef(), StringRef()) {} @@ -192,7 +190,6 @@ public: /// Example: /// Adena class ScalarNode : public Node { - virtual void anchor(); public: ScalarNode(OwningPtr &D, StringRef Anchor, StringRef Tag, StringRef Val) @@ -234,7 +231,6 @@ private: /// Example: /// Section: .text class KeyValueNode : public Node { - virtual void anchor(); public: KeyValueNode(OwningPtr &D) : Node(NK_KeyValue, D, StringRef(), StringRef()) @@ -346,7 +342,6 @@ void skip(CollectionType &C) { /// Name: _main /// Scope: Global class MappingNode : public Node { - virtual void anchor(); public: enum MappingType { MT_Block, @@ -396,7 +391,6 @@ private: /// - Hello /// - World class SequenceNode : public Node { - virtual void anchor(); public: enum SequenceType { ST_Block, @@ -452,7 +446,6 @@ private: /// Example: /// *AnchorName class AliasNode : public Node { - virtual void anchor(); public: AliasNode(OwningPtr &D, StringRef Val) : Node(NK_Alias, D, StringRef(), StringRef()), Name(Val) {} diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h index 4c271e0..d6eeaac 100644 --- a/include/llvm/Support/YAMLTraits.h +++ b/include/llvm/Support/YAMLTraits.h @@ -723,7 +723,6 @@ private: virtual bool canElideEmptySequence(); class HNode { - virtual void anchor(); public: HNode(Node *n) : _node(n) { } virtual ~HNode() { } @@ -733,9 +732,9 @@ private: }; class EmptyHNode : public HNode { - virtual void anchor(); public: EmptyHNode(Node *n) : HNode(n) { } + virtual ~EmptyHNode() {} static inline bool classof(const HNode *n) { return NullNode::classof(n->_node); } @@ -743,9 +742,9 @@ private: }; class ScalarHNode : public HNode { - virtual void anchor(); public: ScalarHNode(Node *n, StringRef s) : HNode(n), _value(s) { } + virtual ~ScalarHNode() { } StringRef value() const { return _value; } @@ -758,7 +757,6 @@ private: }; class MapHNode : public HNode { - virtual void anchor(); public: MapHNode(Node *n) : HNode(n) { } virtual ~MapHNode(); @@ -777,7 +775,6 @@ private: }; class SequenceHNode : public HNode { - virtual void anchor(); public: SequenceHNode(Node *n) : HNode(n) { } virtual ~SequenceHNode(); -- cgit v1.1 From f56f1dfecc04078dd76121cf06dae4024372f329 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Mon, 18 Nov 2013 11:06:01 +0000 Subject: Fix forgotten member initialization detected by MSan bootstrap bot git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195003 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 91bbc2b..12cd40f 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -761,6 +761,8 @@ DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes); /// used by the CUs. class DebugInfoFinder { public: + DebugInfoFinder() : TypeMapInitialized(false) {} + /// processModule - Process entire module and collect debug info /// anchors. void processModule(const Module &M); -- cgit v1.1 From 6919bec07f9c4ee57a0e99f263b63546b386f22b Mon Sep 17 00:00:00 2001 From: Alexander Kornienko Date: Mon, 18 Nov 2013 15:50:04 +0000 Subject: Recover gracefully when deserializing invalid YAML input. Fixes http://llvm.org/PR16221, http://llvm.org/PR15927 Phabricator: http://llvm-reviews.chandlerc.com/D1236 Patch by Andrew Tulloch! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195016 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/YAMLTraits.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h index d6eeaac..8be5439 100644 --- a/include/llvm/Support/YAMLTraits.h +++ b/include/llvm/Support/YAMLTraits.h @@ -685,16 +685,18 @@ private: /// class Input : public IO { public: - // Construct a yaml Input object from a StringRef and optional user-data. - Input(StringRef InputContent, void *Ctxt=NULL); + // Construct a yaml Input object from a StringRef and optional + // user-data. The DiagHandler can be specified to provide + // alternative error reporting. + Input(StringRef InputContent, + void *Ctxt = NULL, + SourceMgr::DiagHandlerTy DiagHandler = NULL, + void *DiagHandlerCtxt = NULL); ~Input(); - + // Check if there was an syntax or semantic error during parsing. llvm::error_code error(); - // To set alternate error reporting. - void setDiagHandler(llvm::SourceMgr::DiagHandlerTy Handler, void *Ctxt = 0); - static bool classof(const IO *io) { return !io->outputting(); } private: @@ -968,8 +970,8 @@ template inline typename llvm::enable_if_c::value,Input &>::type operator>>(Input &yin, T &docSeq) { - yin.setCurrentDocument(); - yamlize(yin, docSeq, true); + if (yin.setCurrentDocument()) + yamlize(yin, docSeq, true); return yin; } -- cgit v1.1 From 4adba52570723c2e1654b1c01feddf759893f096 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Mon, 18 Nov 2013 23:33:32 +0000 Subject: DebugInfo: Simplify a few more explicit constructions, underconstrained types, and make DIType(MDNode*) explicit like all the other DI* node ctors. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195055 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DIBuilder.h | 6 +++--- include/llvm/DebugInfo.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm/DIBuilder.h b/include/llvm/DIBuilder.h index 420dcef..bac1679 100644 --- a/include/llvm/DIBuilder.h +++ b/include/llvm/DIBuilder.h @@ -289,7 +289,7 @@ namespace llvm { uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags, DIType DerivedFrom, DIArray Elements, - DIType VTableHolder = NULL, + DIType VTableHolder = DIType(), MDNode *TemplateParms = 0, StringRef UniqueIdentifier = StringRef()); @@ -309,7 +309,7 @@ namespace llvm { uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, DIType DerivedFrom, DIArray Elements, unsigned RunTimeLang = 0, - DIType VTableHolder = NULL, + DIType VTableHolder = DIType(), StringRef UniqueIdentifier = StringRef()); /// createUnionType - Create debugging information entry for an union. @@ -601,7 +601,7 @@ namespace llvm { DICompositeType Ty, bool isLocalToUnit, bool isDefinition, unsigned Virtuality = 0, unsigned VTableIndex = 0, - DIType VTableHolder = NULL, + DIType VTableHolder = DIType(), unsigned Flags = 0, bool isOptimized = false, Function *Fn = 0, diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 12cd40f..07bd832 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -281,7 +281,7 @@ protected: void printInternal(raw_ostream &OS) const; public: - DIType(const MDNode *N = 0) : DIScope(N) {} + explicit DIType(const MDNode *N = 0) : DIScope(N) {} /// Verify - Verify that a type descriptor is well formed. bool Verify() const; -- cgit v1.1 From 354362524a72b3fa43a6c09380b7ae3b2380cbba Mon Sep 17 00:00:00 2001 From: Juergen Ributzka Date: Tue, 19 Nov 2013 00:57:56 +0000 Subject: [weak vtables] Remove a bunch of weak vtables This patch removes most of the trivial cases of weak vtables by pinning them to a single object file. The memory leaks in this version have been fixed. Thanks Alexey for pointing them out. Differential Revision: http://llvm-reviews.chandlerc.com/D2068 Reviewed by Andy git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195064 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineRegisterInfo.h | 3 ++- include/llvm/CodeGen/MachineScheduler.h | 2 ++ include/llvm/ExecutionEngine/ObjectBuffer.h | 2 ++ include/llvm/ExecutionEngine/ObjectCache.h | 1 + include/llvm/ExecutionEngine/ObjectImage.h | 1 + include/llvm/MC/MCAtom.h | 1 + include/llvm/MC/MCStreamer.h | 1 + include/llvm/MC/MCWinCOFFObjectWriter.h | 1 + include/llvm/Support/CommandLine.h | 4 ++++ include/llvm/Support/ValueHandle.h | 5 +++-- include/llvm/Support/YAMLParser.h | 7 +++++++ include/llvm/Support/YAMLTraits.h | 5 +++-- 12 files changed, 28 insertions(+), 5 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineRegisterInfo.h b/include/llvm/CodeGen/MachineRegisterInfo.h index 736a0a2..58ca907 100644 --- a/include/llvm/CodeGen/MachineRegisterInfo.h +++ b/include/llvm/CodeGen/MachineRegisterInfo.h @@ -30,8 +30,9 @@ class PSetIterator; class MachineRegisterInfo { public: class Delegate { + virtual void anchor(); public: - virtual void MRI_NoteNewVirtualRegister(unsigned Reg) {} + virtual void MRI_NoteNewVirtualRegister(unsigned Reg) = 0; virtual ~Delegate() {} }; diff --git a/include/llvm/CodeGen/MachineScheduler.h b/include/llvm/CodeGen/MachineScheduler.h index e6af370..7782895 100644 --- a/include/llvm/CodeGen/MachineScheduler.h +++ b/include/llvm/CodeGen/MachineScheduler.h @@ -164,6 +164,7 @@ struct MachineSchedPolicy { /// Initialization sequence: /// initPolicy -> shouldTrackPressure -> initialize(DAG) -> registerRoots class MachineSchedStrategy { + virtual void anchor(); public: virtual ~MachineSchedStrategy() {} @@ -262,6 +263,7 @@ public: /// Mutate the DAG as a postpass after normal DAG building. class ScheduleDAGMutation { + virtual void anchor(); public: virtual ~ScheduleDAGMutation() {} diff --git a/include/llvm/ExecutionEngine/ObjectBuffer.h b/include/llvm/ExecutionEngine/ObjectBuffer.h index 32de404..af2a926 100644 --- a/include/llvm/ExecutionEngine/ObjectBuffer.h +++ b/include/llvm/ExecutionEngine/ObjectBuffer.h @@ -30,6 +30,7 @@ namespace llvm { /// ObjectFile) as needed, but the MemoryBuffer instance returned does not own the /// actual memory it points to. class ObjectBuffer { + virtual void anchor(); public: ObjectBuffer() {} ObjectBuffer(MemoryBuffer* Buf) : Buffer(Buf) {} @@ -56,6 +57,7 @@ protected: /// while providing a common ObjectBuffer interface for access to the /// memory once the object has been generated. class ObjectBufferStream : public ObjectBuffer { + virtual void anchor(); public: ObjectBufferStream() : OS(SV) {} virtual ~ObjectBufferStream() {} diff --git a/include/llvm/ExecutionEngine/ObjectCache.h b/include/llvm/ExecutionEngine/ObjectCache.h index 6f55e43..d1849df 100644 --- a/include/llvm/ExecutionEngine/ObjectCache.h +++ b/include/llvm/ExecutionEngine/ObjectCache.h @@ -20,6 +20,7 @@ class Module; /// ExecutionEngine for the purpose of avoiding compilation for Modules that /// have already been compiled and an object file is available. class ObjectCache { + virtual void anchor(); public: ObjectCache() { } diff --git a/include/llvm/ExecutionEngine/ObjectImage.h b/include/llvm/ExecutionEngine/ObjectImage.h index 9fddca7..076f4b1 100644 --- a/include/llvm/ExecutionEngine/ObjectImage.h +++ b/include/llvm/ExecutionEngine/ObjectImage.h @@ -25,6 +25,7 @@ namespace llvm { class ObjectImage { ObjectImage() LLVM_DELETED_FUNCTION; ObjectImage(const ObjectImage &other) LLVM_DELETED_FUNCTION; + virtual void anchor(); protected: OwningPtr Buffer; diff --git a/include/llvm/MC/MCAtom.h b/include/llvm/MC/MCAtom.h index 4758588..eab32d6 100644 --- a/include/llvm/MC/MCAtom.h +++ b/include/llvm/MC/MCAtom.h @@ -32,6 +32,7 @@ class MCDataAtom; /// \brief Represents a contiguous range of either instructions (a TextAtom) /// or data (a DataAtom). Address ranges are expressed as _closed_ intervals. class MCAtom { + virtual void anchor(); public: virtual ~MCAtom() {} diff --git a/include/llvm/MC/MCStreamer.h b/include/llvm/MC/MCStreamer.h index 04af407..0b1fe6e 100644 --- a/include/llvm/MC/MCStreamer.h +++ b/include/llvm/MC/MCStreamer.h @@ -76,6 +76,7 @@ public: // FIXME: declared here because it is used from // lib/CodeGen/AsmPrinter/ARMException.cpp. class ARMTargetStreamer : public MCTargetStreamer { + virtual void anchor(); public: virtual void emitFnStart() = 0; virtual void emitFnEnd() = 0; diff --git a/include/llvm/MC/MCWinCOFFObjectWriter.h b/include/llvm/MC/MCWinCOFFObjectWriter.h index f13e7d5..213481c 100644 --- a/include/llvm/MC/MCWinCOFFObjectWriter.h +++ b/include/llvm/MC/MCWinCOFFObjectWriter.h @@ -17,6 +17,7 @@ namespace llvm { class raw_ostream; class MCWinCOFFObjectTargetWriter { + virtual void anchor(); const unsigned Machine; protected: diff --git a/include/llvm/Support/CommandLine.h b/include/llvm/Support/CommandLine.h index c0bfbae..4efb6a6 100644 --- a/include/llvm/Support/CommandLine.h +++ b/include/llvm/Support/CommandLine.h @@ -350,6 +350,9 @@ struct cat { struct GenericOptionValue { virtual ~GenericOptionValue() {} virtual bool compare(const GenericOptionValue &V) const = 0; + +private: + virtual void anchor(); }; template struct OptionValue; @@ -1752,6 +1755,7 @@ void getRegisteredOptions(StringMap &Map); /// \brief Saves strings in the inheritor's stable storage and returns a stable /// raw character pointer. class StringSaver { + virtual void anchor(); public: virtual const char *SaveString(const char *Str) = 0; virtual ~StringSaver() {}; // Pacify -Wnon-virtual-dtor. diff --git a/include/llvm/Support/ValueHandle.h b/include/llvm/Support/ValueHandle.h index b49341c..bc02ba3 100644 --- a/include/llvm/Support/ValueHandle.h +++ b/include/llvm/Support/ValueHandle.h @@ -339,6 +339,7 @@ public: /// rearrange itself when the pointer changes). Unlike ValueHandleBase, this /// class has a vtable and a virtual destructor. class CallbackVH : public ValueHandleBase { + virtual void anchor(); protected: CallbackVH(const CallbackVH &RHS) : ValueHandleBase(Callback, RHS) {} @@ -365,13 +366,13 @@ public: /// /// All implementations must remove the reference from this object to the /// Value that's being destroyed. - virtual void deleted(); + virtual void deleted() { setValPtr(NULL); } /// Called when this->getValPtr()->replaceAllUsesWith(new_value) is called, /// _before_ any of the uses have actually been replaced. If WeakVH were /// implemented as a CallbackVH, it would use this method to call /// setValPtr(new_value). AssertingVH would do nothing in this method. - virtual void allUsesReplacedWith(Value *); + virtual void allUsesReplacedWith(Value *) {} }; } // End llvm namespace diff --git a/include/llvm/Support/YAMLParser.h b/include/llvm/Support/YAMLParser.h index 0e780ba..7020449 100644 --- a/include/llvm/Support/YAMLParser.h +++ b/include/llvm/Support/YAMLParser.h @@ -105,6 +105,7 @@ private: /// @brief Abstract base class for all Nodes. class Node { + virtual void anchor(); public: enum NodeKind { NK_Null, @@ -175,6 +176,7 @@ private: /// Example: /// !!null null class NullNode : public Node { + virtual void anchor(); public: NullNode(OwningPtr &D) : Node(NK_Null, D, StringRef(), StringRef()) {} @@ -190,6 +192,7 @@ public: /// Example: /// Adena class ScalarNode : public Node { + virtual void anchor(); public: ScalarNode(OwningPtr &D, StringRef Anchor, StringRef Tag, StringRef Val) @@ -231,6 +234,7 @@ private: /// Example: /// Section: .text class KeyValueNode : public Node { + virtual void anchor(); public: KeyValueNode(OwningPtr &D) : Node(NK_KeyValue, D, StringRef(), StringRef()) @@ -342,6 +346,7 @@ void skip(CollectionType &C) { /// Name: _main /// Scope: Global class MappingNode : public Node { + virtual void anchor(); public: enum MappingType { MT_Block, @@ -391,6 +396,7 @@ private: /// - Hello /// - World class SequenceNode : public Node { + virtual void anchor(); public: enum SequenceType { ST_Block, @@ -446,6 +452,7 @@ private: /// Example: /// *AnchorName class AliasNode : public Node { + virtual void anchor(); public: AliasNode(OwningPtr &D, StringRef Val) : Node(NK_Alias, D, StringRef(), StringRef()), Name(Val) {} diff --git a/include/llvm/Support/YAMLTraits.h b/include/llvm/Support/YAMLTraits.h index 8be5439..c19eb23 100644 --- a/include/llvm/Support/YAMLTraits.h +++ b/include/llvm/Support/YAMLTraits.h @@ -725,6 +725,7 @@ private: virtual bool canElideEmptySequence(); class HNode { + virtual void anchor(); public: HNode(Node *n) : _node(n) { } virtual ~HNode() { } @@ -734,9 +735,9 @@ private: }; class EmptyHNode : public HNode { + virtual void anchor(); public: EmptyHNode(Node *n) : HNode(n) { } - virtual ~EmptyHNode() {} static inline bool classof(const HNode *n) { return NullNode::classof(n->_node); } @@ -744,9 +745,9 @@ private: }; class ScalarHNode : public HNode { + virtual void anchor(); public: ScalarHNode(Node *n, StringRef s) : HNode(n), _value(s) { } - virtual ~ScalarHNode() { } StringRef value() const { return _value; } -- cgit v1.1 From 72ef53ad21cf2df7cdf6f2a0470b4eaa98d9e7ed Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 19 Nov 2013 06:36:46 +0000 Subject: Merging r195093: ------------------------------------------------------------------------ r195093 | atrick | 2013-11-18 19:29:56 -0800 (Mon, 18 Nov 2013) | 4 lines Add an abstraction to handle patchpoint operands. Hard-coded operand indices were scattered throughout lowering stages and layers. It was super bug prone. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@195112 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/StackMaps.h | 81 +++++++++++++++++++++++++++++++++++----- 1 file changed, 71 insertions(+), 10 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/StackMaps.h b/include/llvm/CodeGen/StackMaps.h index f832132..86d55cf 100644 --- a/include/llvm/CodeGen/StackMaps.h +++ b/include/llvm/CodeGen/StackMaps.h @@ -20,6 +20,60 @@ namespace llvm { class AsmPrinter; class MCExpr; +/// \brief MI-level patchpoint operands. +/// +/// MI patchpoint operations take the form: +/// [], , , , , , ... +/// +/// Note that IR/SD patchpoints do not have the or operands. +/// +/// Patchpoints following the anyregcc convention are handled specially. For +/// these, the stack map also records the location of the return value and +/// arguments. +class PatchPointOpers { +public: + /// Enumerate the meta operands. + enum { IDPos, NBytesPos, TargetPos, NArgPos, CCPos, MetaEnd }; +private: + const MachineInstr *MI; + bool HasDef; + bool IsAnyReg; +public: + explicit PatchPointOpers(const MachineInstr *MI); + + bool isAnyReg() const { return IsAnyReg; } + bool hasDef() const { return HasDef; } + + unsigned getMetaIdx(unsigned Pos = 0) const { + assert(Pos < MetaEnd && "Meta operand index out of range."); + return (HasDef ? 1 : 0) + Pos; + } + + const MachineOperand &getMetaOper(unsigned Pos) { + return MI->getOperand(getMetaIdx(Pos)); + } + + unsigned getArgIdx() const { return getMetaIdx() + MetaEnd; } + + /// Get the operand index of the variable list of non-argument operands. + /// These hold the "live state". + unsigned getVarIdx() const { + return getMetaIdx() + MetaEnd + + MI->getOperand(getMetaIdx(NArgPos)).getImm(); + } + + /// Get the index at which stack map locations will be recorded. + /// Arguments are not recorded unless the anyregcc convention is used. + unsigned getStackMapStartIdx() const { + if (IsAnyReg) + return getArgIdx(); + return getVarIdx(); + } + + /// \brief Get the next scratch register operand index. + unsigned getNextScratchIdx(unsigned StartIdx = 0) const; +}; + class StackMaps { public: struct Location { @@ -48,15 +102,13 @@ public: StackMaps(AsmPrinter &AP, OperandParser OpParser) : AP(AP), OpParser(OpParser) {} - /// This should be called by the MC lowering code _immediately_ before - /// lowering the MI to an MCInst. It records where the operands for the - /// instruction are stored, and outputs a label to record the offset of - /// the call from the start of the text section. In special cases (e.g. AnyReg - /// calling convention) the return register is also recorded if requested. - void recordStackMap(const MachineInstr &MI, uint32_t ID, - MachineInstr::const_mop_iterator MOI, - MachineInstr::const_mop_iterator MOE, - bool recordResult = false); + /// \brief Generate a stackmap record for a stackmap instruction. + /// + /// MI must be a raw STACKMAP, not a PATCHPOINT. + void recordStackMap(const MachineInstr &MI); + + /// \brief Generate a stackmap record for a patchpoint instruction. + void recordPatchPoint(const MachineInstr &MI); /// If there is any stack map data, create a stack map section and serialize /// the map info into it. This clears the stack map data structures @@ -64,7 +116,6 @@ public: void serializeToStackMapSection(); private: - typedef SmallVector LocationVec; struct CallsiteInfo { @@ -103,6 +154,16 @@ private: OperandParser OpParser; CallsiteInfoList CSInfos; ConstantPool ConstPool; + + /// This should be called by the MC lowering code _immediately_ before + /// lowering the MI to an MCInst. It records where the operands for the + /// instruction are stored, and outputs a label to record the offset of + /// the call from the start of the text section. In special cases (e.g. AnyReg + /// calling convention) the return register is also recorded if requested. + void recordStackMapOpers(const MachineInstr &MI, uint32_t ID, + MachineInstr::const_mop_iterator MOI, + MachineInstr::const_mop_iterator MOE, + bool recordResult = false); }; } -- cgit v1.1 From c00090b16b2b35f2d042d965945c4246d13321b5 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 19 Nov 2013 06:43:35 +0000 Subject: Merging r195103: ------------------------------------------------------------------------ r195103 | atrick | 2013-11-18 21:05:43 -0800 (Mon, 18 Nov 2013) | 1 line Fix patchpoint comments. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@195115 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/StackMaps.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/StackMaps.h b/include/llvm/CodeGen/StackMaps.h index 86d55cf..e90f22e 100644 --- a/include/llvm/CodeGen/StackMaps.h +++ b/include/llvm/CodeGen/StackMaps.h @@ -25,7 +25,11 @@ class MCExpr; /// MI patchpoint operations take the form: /// [], , , , , , ... /// -/// Note that IR/SD patchpoints do not have the or operands. +/// IR patchpoint intrinsics do not have the operand because calling +/// convention is part of the subclass data. +/// +/// SD patchpoint nodes do not have a def operand because it is part of the +/// SDValue. /// /// Patchpoints following the anyregcc convention are handled specially. For /// these, the stack map also records the location of the return value and -- cgit v1.1 From c817d3e36d82787e639668dc1b898fd17415570d Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 20 Nov 2013 09:55:44 +0000 Subject: Regenerate configure files with 3.4svn changed to 3.4. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@195231 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Config/config.h.in | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'include') diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in index 0d43ae5..dcec8f8 100644 --- a/include/llvm/Config/config.h.in +++ b/include/llvm/Config/config.h.in @@ -3,6 +3,9 @@ #ifndef CONFIG_H #define CONFIG_H +/* Define if building universal (internal helper macro) */ +#undef AC_APPLE_UNIVERSAL_BUILD + /* Bug report URL. */ #undef BUG_REPORT_URL @@ -670,6 +673,9 @@ /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME +/* Define to the home page for this package. */ +#undef PACKAGE_URL + /* Define to the version of this package. */ #undef PACKAGE_VERSION @@ -694,6 +700,18 @@ /* Type of 1st arg on ELM Callback */ #undef WIN32_ELMCB_PCSTR +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +# undef WORDS_BIGENDIAN +# endif +#endif + /* Define to empty if `const' does not conform to ANSI C. */ #undef const -- cgit v1.1 From 0a0da619eb7a072836cf2c5debee1c5c7c8f5496 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 21 Nov 2013 07:11:48 +0000 Subject: Merging r195317: ------------------------------------------------------------------------ r195317 | probinson | 2013-11-20 22:33:32 -0800 (Wed, 20 Nov 2013) | 4 lines Teach ISel not to optimize 'optnone' functions. Based on work by Andrea Di Biagio. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@195321 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCCodeGenInfo.h | 3 +++ include/llvm/Target/TargetMachine.h | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/MC/MCCodeGenInfo.h b/include/llvm/MC/MCCodeGenInfo.h index d1765e1..84ce934 100644 --- a/include/llvm/MC/MCCodeGenInfo.h +++ b/include/llvm/MC/MCCodeGenInfo.h @@ -42,6 +42,9 @@ namespace llvm { CodeModel::Model getCodeModel() const { return CMModel; } CodeGenOpt::Level getOptLevel() const { return OptLevel; } + + // Allow overriding OptLevel on a per-function basis. + void setOptLevel(CodeGenOpt::Level Level) { OptLevel = Level; } }; } // namespace llvm diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index 91e4715..11b0f5f 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -75,7 +75,8 @@ protected: // Can only create subclasses. std::string TargetFS; /// CodeGenInfo - Low level target information such as relocation model. - const MCCodeGenInfo *CodeGenInfo; + /// Non-const to allow resetting optimization level per-function. + MCCodeGenInfo *CodeGenInfo; /// AsmInfo - Contains target specific asm information. /// @@ -213,6 +214,9 @@ public: /// Default, or Aggressive. CodeGenOpt::Level getOptLevel() const; + /// \brief Overrides the optimization level. + void setOptLevel(CodeGenOpt::Level Level) const; + void setFastISel(bool Enable) { Options.EnableFastISel = Enable; } bool shouldPrintMachineCode() const { return Options.PrintMachineCode; } -- cgit v1.1 From 54075bbea7e70fea6cdb9e5e89b066118c1d314b Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Thu, 21 Nov 2013 20:18:40 +0000 Subject: Merging r195339: ------------------------------------------------------------------------ r195339 | chapuni | 2013-11-21 02:55:15 -0800 (Thu, 21 Nov 2013) | 5 lines Revert r195317 (and r195333), "Teach ISel not to optimize 'optnone' functions." It broke, at least, i686 target. It is reproducible with "llc -mtriple=i686-unknown". FYI, it didn't appear to add either "-O0" or "-fast-isel". ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@195375 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCCodeGenInfo.h | 3 --- include/llvm/Target/TargetMachine.h | 6 +----- 2 files changed, 1 insertion(+), 8 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCCodeGenInfo.h b/include/llvm/MC/MCCodeGenInfo.h index 84ce934..d1765e1 100644 --- a/include/llvm/MC/MCCodeGenInfo.h +++ b/include/llvm/MC/MCCodeGenInfo.h @@ -42,9 +42,6 @@ namespace llvm { CodeModel::Model getCodeModel() const { return CMModel; } CodeGenOpt::Level getOptLevel() const { return OptLevel; } - - // Allow overriding OptLevel on a per-function basis. - void setOptLevel(CodeGenOpt::Level Level) { OptLevel = Level; } }; } // namespace llvm diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index 11b0f5f..91e4715 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -75,8 +75,7 @@ protected: // Can only create subclasses. std::string TargetFS; /// CodeGenInfo - Low level target information such as relocation model. - /// Non-const to allow resetting optimization level per-function. - MCCodeGenInfo *CodeGenInfo; + const MCCodeGenInfo *CodeGenInfo; /// AsmInfo - Contains target specific asm information. /// @@ -214,9 +213,6 @@ public: /// Default, or Aggressive. CodeGenOpt::Level getOptLevel() const; - /// \brief Overrides the optimization level. - void setOptLevel(CodeGenOpt::Level Level) const; - void setFastISel(bool Enable) { Options.EnableFastISel = Enable; } bool shouldPrintMachineCode() const { return Options.PrintMachineCode; } -- cgit v1.1 From ee287ca22abcce9f769618c107ff3f46aa2d0cba Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 22 Nov 2013 05:17:44 +0000 Subject: Merging r195156: ------------------------------------------------------------------------ r195156 | ributzka | 2013-11-19 13:20:17 -0800 (Tue, 19 Nov 2013) | 3 lines [DAG] Refactor vector splitting code in SelectionDAG. No functional change intended. Reviewed by Tom ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@195412 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/SelectionDAG.h | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index 9a9bb99..4b3f904 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -170,6 +170,7 @@ class SelectionDAG { const TargetMachine &TM; const TargetSelectionDAGInfo &TSI; const TargetTransformInfo *TTI; + const TargetLowering *TLI; MachineFunction *MF; LLVMContext *Context; CodeGenOpt::Level OptLevel; @@ -268,7 +269,8 @@ public: /// init - Prepare this SelectionDAG to process code in the given /// MachineFunction. /// - void init(MachineFunction &mf, const TargetTransformInfo *TTI); + void init(MachineFunction &mf, const TargetTransformInfo *TTI, + const TargetLowering *TLI); /// clear - Clear state and free memory necessary to make this /// SelectionDAG ready to process a new block. @@ -277,9 +279,7 @@ public: MachineFunction &getMachineFunction() const { return *MF; } const TargetMachine &getTarget() const { return TM; } - const TargetLowering &getTargetLoweringInfo() const { - return *TM.getTargetLowering(); - } + const TargetLowering &getTargetLoweringInfo() const { return *TLI; } const TargetSelectionDAGInfo &getSelectionDAGInfo() const { return TSI; } const TargetTransformInfo *getTargetTransformInfo() const { return TTI; } LLVMContext *getContext() const {return Context; } @@ -1130,6 +1130,29 @@ public: /// it cannot be inferred. unsigned InferPtrAlignment(SDValue Ptr) const; + /// GetSplitDestVTs - Compute the VTs needed for the low/hi parts of a type + /// which is split (or expanded) into two not necessarily identical pieces. + std::pair GetSplitDestVTs(const EVT &VT) const; + + /// SplitVector - Split the vector with EXTRACT_SUBVECTOR using the provides + /// VTs and return the low/high part. + std::pair SplitVector(const SDValue &N, const SDLoc &DL, + const EVT &LoVT, const EVT &HiVT); + + /// SplitVector - Split the vector with EXTRACT_SUBVECTOR and return the + /// low/high part. + std::pair SplitVector(const SDValue &N, const SDLoc &DL) { + EVT LoVT, HiVT; + llvm::tie(LoVT, HiVT) = GetSplitDestVTs(N.getValueType()); + return SplitVector(N, DL, LoVT, HiVT); + } + + /// SplitVectorOperand - Split the node's operand with EXTRACT_SUBVECTOR and + /// return the low/high part. + std::pair SplitVectorOperand(SDNode *N, unsigned OpNo) { + return SplitVector(N->getOperand(OpNo), SDLoc(N)); + } + private: bool RemoveNodeFromCSEMaps(SDNode *N); void AddModifiedNodeToCSEMaps(SDNode *N); -- cgit v1.1 From f62b274a93d4014d56fa3a656f4fac6e7d827358 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Fri, 22 Nov 2013 05:18:07 +0000 Subject: Merging r195397: ------------------------------------------------------------------------ r195397 | tstellar | 2013-11-21 16:39:23 -0800 (Thu, 21 Nov 2013) | 11 lines Split SETCC if VSELECT requires splitting too. This patch is a rewrite of the original patch commited in r194542. Instead of relying on the type legalizer to do the splitting for us, we now peform the splitting ourselves in the DAG combiner. This is necessary for the case where the vector mask is a legal type after promotion and still wouldn't require splitting. Patch by: Juergen Ributzka NOTE: This is a candidate for the 3.4 branch. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@195413 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/SelectionDAG.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/CodeGen/SelectionDAG.h b/include/llvm/CodeGen/SelectionDAG.h index 4b3f904..82becca 100644 --- a/include/llvm/CodeGen/SelectionDAG.h +++ b/include/llvm/CodeGen/SelectionDAG.h @@ -1149,7 +1149,8 @@ public: /// SplitVectorOperand - Split the node's operand with EXTRACT_SUBVECTOR and /// return the low/high part. - std::pair SplitVectorOperand(SDNode *N, unsigned OpNo) { + std::pair SplitVectorOperand(const SDNode *N, unsigned OpNo) + { return SplitVector(N->getOperand(OpNo), SDLoc(N)); } -- cgit v1.1 From f02a188899769cde2315c964f0fbed1d024b7514 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 25 Nov 2013 05:21:50 +0000 Subject: Merging r195491: ------------------------------------------------------------------------ r195491 | probinson | 2013-11-22 11:11:24 -0800 (Fri, 22 Nov 2013) | 11 lines Teach ISel not to optimize 'optnone' functions (revised). Improvements over r195317: - Set/restore EnableFastISel flag instead of just running FastISel within SelectAllBasicBlocks; the flag is checked in various places, and FastISel won't run properly if those places don't do the right thing. - Test looks for normal ISel versus FastISel behavior, and not something more subtle that doesn't work everywhere. Based on work by Andrea Di Biagio. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@195604 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCCodeGenInfo.h | 3 +++ include/llvm/Target/TargetMachine.h | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/MC/MCCodeGenInfo.h b/include/llvm/MC/MCCodeGenInfo.h index d1765e1..84ce934 100644 --- a/include/llvm/MC/MCCodeGenInfo.h +++ b/include/llvm/MC/MCCodeGenInfo.h @@ -42,6 +42,9 @@ namespace llvm { CodeModel::Model getCodeModel() const { return CMModel; } CodeGenOpt::Level getOptLevel() const { return OptLevel; } + + // Allow overriding OptLevel on a per-function basis. + void setOptLevel(CodeGenOpt::Level Level) { OptLevel = Level; } }; } // namespace llvm diff --git a/include/llvm/Target/TargetMachine.h b/include/llvm/Target/TargetMachine.h index 91e4715..11b0f5f 100644 --- a/include/llvm/Target/TargetMachine.h +++ b/include/llvm/Target/TargetMachine.h @@ -75,7 +75,8 @@ protected: // Can only create subclasses. std::string TargetFS; /// CodeGenInfo - Low level target information such as relocation model. - const MCCodeGenInfo *CodeGenInfo; + /// Non-const to allow resetting optimization level per-function. + MCCodeGenInfo *CodeGenInfo; /// AsmInfo - Contains target specific asm information. /// @@ -213,6 +214,9 @@ public: /// Default, or Aggressive. CodeGenOpt::Level getOptLevel() const; + /// \brief Overrides the optimization level. + void setOptLevel(CodeGenOpt::Level Level) const; + void setFastISel(bool Enable) { Options.EnableFastISel = Enable; } bool shouldPrintMachineCode() const { return Options.PrintMachineCode; } -- cgit v1.1 From 83a5c7898e26166199ef8a55527d176b5dc4cb04 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 25 Nov 2013 05:38:27 +0000 Subject: Merging r195327: ------------------------------------------------------------------------ r195327 | apazos | 2013-11-20 23:37:04 -0800 (Wed, 20 Nov 2013) | 6 lines Implemented Neon scalar by element intrinsics. Intrinsics implemented: vqdmull_lane, vqdmulh_lane, vqrdmulh_lane, vqdmlal_lane, vqdmlsl_lane scalar Neon intrinsics. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@195611 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 9 --------- 1 file changed, 9 deletions(-) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index c403963..172a569 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -196,9 +196,6 @@ def int_aarch64_neon_vaddds : def int_aarch64_neon_vadddu : Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], [IntrNoMem]>; -// Scalar Saturating Add (Signed, Unsigned) -def int_aarch64_neon_vqadds : Neon_2Arg_Intrinsic; -def int_aarch64_neon_vqaddu : Neon_2Arg_Intrinsic; // Scalar Sub def int_aarch64_neon_vsubds : @@ -206,9 +203,6 @@ def int_aarch64_neon_vsubds : def int_aarch64_neon_vsubdu : Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_v1i64_ty], [IntrNoMem]>; -// Scalar Saturating Sub (Signed, Unsigned) -def int_aarch64_neon_vqsubs : Neon_2Arg_Intrinsic; -def int_aarch64_neon_vqsubu : Neon_2Arg_Intrinsic; // Scalar Shift // Scalar Shift Left @@ -324,9 +318,6 @@ def int_aarch64_neon_vqdmlal : Neon_3Arg_Long_Intrinsic; // Signed Saturating Doubling Multiply-Subtract Long def int_aarch64_neon_vqdmlsl : Neon_3Arg_Long_Intrinsic; -// Signed Saturating Doubling Multiply Long -def int_aarch64_neon_vqdmull : Neon_2Arg_Long_Intrinsic; - class Neon_2Arg_ShiftImm_Intrinsic : Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty, llvm_i32_ty], [IntrNoMem]>; -- cgit v1.1 From 0ae07098f7d2ad5a1868d448d0b1b4eef2a3b091 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Wed, 27 Nov 2013 06:44:18 +0000 Subject: Merging r195148: ------------------------------------------------------------------------ r195148 | rafael | 2013-11-19 11:52:52 -0800 (Tue, 19 Nov 2013) | 15 lines Support multiple COFF sections with the same name but different COMDAT. This is the first step to fix pr17918. It extends the .section directive a bit, inspired by what the ELF one looks like. The problem with using linkonce is that given .section foo .linkonce.... .section foo .linkonce we would already have switched sections when getting to .linkonce. The cleanest solution seems to be to add the comdat information in the .section itself. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@195822 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCContext.h | 8 +++++++- include/llvm/MC/MCSectionCOFF.h | 14 +++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/llvm/MC/MCContext.h b/include/llvm/MC/MCContext.h index 8fba18c..c8b6626 100644 --- a/include/llvm/MC/MCContext.h +++ b/include/llvm/MC/MCContext.h @@ -258,9 +258,15 @@ namespace llvm { const MCSectionCOFF *getCOFFSection(StringRef Section, unsigned Characteristics, - SectionKind Kind, int Selection = 0, + SectionKind Kind, + StringRef COMDATSymName, + int Selection, const MCSectionCOFF *Assoc = 0); + const MCSectionCOFF *getCOFFSection(StringRef Section, + unsigned Characteristics, + SectionKind Kind); + const MCSectionCOFF *getCOFFSection(StringRef Section); /// @} diff --git a/include/llvm/MC/MCSectionCOFF.h b/include/llvm/MC/MCSectionCOFF.h index 754e829..45c84ae 100644 --- a/include/llvm/MC/MCSectionCOFF.h +++ b/include/llvm/MC/MCSectionCOFF.h @@ -19,6 +19,7 @@ #include "llvm/Support/COFF.h" namespace llvm { +class MCSymbol; /// MCSectionCOFF - This represents a section on Windows class MCSectionCOFF : public MCSection { @@ -32,6 +33,11 @@ namespace llvm { /// drawn from the enums below. mutable unsigned Characteristics; + /// The COMDAT symbol of this section. Only valid if this is a COMDAT + /// section. Two COMDAT sections are merged if they have the same + /// COMDAT symbol. + const MCSymbol *COMDATSymbol; + /// Selection - This is the Selection field for the section symbol, if /// it is a COMDAT section (Characteristics & IMAGE_SCN_LNK_COMDAT) != 0 mutable int Selection; @@ -44,9 +50,11 @@ namespace llvm { private: friend class MCContext; MCSectionCOFF(StringRef Section, unsigned Characteristics, - int Selection, const MCSectionCOFF *Assoc, SectionKind K) - : MCSection(SV_COFF, K), SectionName(Section), - Characteristics(Characteristics), Selection(Selection), Assoc(Assoc) { + const MCSymbol *COMDATSymbol, int Selection, + const MCSectionCOFF *Assoc, SectionKind K) + : MCSection(SV_COFF, K), SectionName(Section), + Characteristics(Characteristics), COMDATSymbol(COMDATSymbol), + Selection(Selection), Assoc(Assoc) { assert ((Characteristics & 0x00F00000) == 0 && "alignment must not be set upon section creation"); assert ((Selection == COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE) == -- cgit v1.1 From 2527bdac885f5822bb2b9a805fc9d80b35dd8f8b Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 1 Dec 2013 03:05:13 +0000 Subject: Merging r195788: ------------------------------------------------------------------------ r195788 | mcrosier | 2013-11-26 14:17:37 -0800 (Tue, 26 Nov 2013) | 2 lines [AArch64] Add support for NEON scalar floating-point to integer convert instructions. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@195993 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 172a569..36e9cb6 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -54,6 +54,10 @@ def int_aarch64_neon_fcvtas : Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>; def int_aarch64_neon_fcvtau : Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>; +def int_aarch64_neon_fcvtzs : + Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>; +def int_aarch64_neon_fcvtzu : + Intrinsic<[llvm_anyvector_ty], [llvm_anyvector_ty], [IntrNoMem]>; // Vector maxNum (Floating Point) def int_aarch64_neon_vmaxnm : Neon_2Arg_Intrinsic; -- cgit v1.1 From 5f1f4773d95560b68a9c75856563e45e3a4d57e3 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 1 Dec 2013 03:06:07 +0000 Subject: Merging r195803: ------------------------------------------------------------------------ r195803 | mcrosier | 2013-11-26 17:45:58 -0800 (Tue, 26 Nov 2013) | 1 line [AArch64] Add support for NEON scalar floating-point absolute difference. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@195994 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/IntrinsicsAArch64.td | 3 +++ 1 file changed, 3 insertions(+) (limited to 'include') diff --git a/include/llvm/IR/IntrinsicsAArch64.td b/include/llvm/IR/IntrinsicsAArch64.td index 36e9cb6..68af8c1 100644 --- a/include/llvm/IR/IntrinsicsAArch64.td +++ b/include/llvm/IR/IntrinsicsAArch64.td @@ -312,6 +312,9 @@ def int_aarch64_neon_vsqadd : Neon_2Arg_Intrinsic; def int_aarch64_neon_vabs : Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty], [IntrNoMem]>; +// Scalar Absolute Difference +def int_aarch64_neon_vabd : Neon_2Arg_Intrinsic; + // Scalar Negate Value def int_aarch64_neon_vneg : Intrinsic<[llvm_v1i64_ty], [llvm_v1i64_ty], [IntrNoMem]>; -- cgit v1.1 From 3d238de4d54eb0b16afd96a57f49f92b2f7748e0 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 2 Dec 2013 07:37:46 +0000 Subject: Merging r195401: ------------------------------------------------------------------------ r195401 | lhames | 2013-11-21 16:46:32 -0800 (Thu, 21 Nov 2013) | 8 lines Fix a typo where we were creating operands instead of ones. Add an assertion to make sure we catch this in the future. Fixes . ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@196073 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/MachineOperand.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'include') diff --git a/include/llvm/CodeGen/MachineOperand.h b/include/llvm/CodeGen/MachineOperand.h index 57b28fe..40f3580 100644 --- a/include/llvm/CodeGen/MachineOperand.h +++ b/include/llvm/CodeGen/MachineOperand.h @@ -564,6 +564,8 @@ public: unsigned SubReg = 0, bool isDebug = false, bool isInternalRead = false) { + assert(!(isDead && !isDef) && "Dead flag on non-def"); + assert(!(isKill && isDef) && "Kill flag on def"); MachineOperand Op(MachineOperand::MO_Register); Op.IsDef = isDef; Op.IsImp = isImp; -- cgit v1.1 From cf5f97edf1355be0d7847c73559f8f2b73b54074 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Sun, 8 Dec 2013 00:23:35 +0000 Subject: Merging r196637: ------------------------------------------------------------------------ r196637 | arsenm | 2013-12-06 18:58:41 -0800 (Fri, 06 Dec 2013) | 1 line Add getBitCastOrAddrSpaceCast ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@196707 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Constants.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/IR/Constants.h b/include/llvm/IR/Constants.h index f1cee5a..dac20c9 100644 --- a/include/llvm/IR/Constants.h +++ b/include/llvm/IR/Constants.h @@ -943,12 +943,20 @@ public: Type *Ty ///< The type to trunc or bitcast C to ); - /// @brief Create a BitCast or a PtrToInt cast constant expression + /// @brief Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant + /// expression. static Constant *getPointerCast( Constant *C, ///< The pointer value to be casted (operand 0) Type *Ty ///< The type to which cast should be made ); + /// @brief Create a BitCast or AddrSpaceCast for a pointer type depending on + /// the address space. + static Constant *getPointerBitCastOrAddrSpaceCast( + Constant *C, ///< The constant to addrspacecast or bitcast + Type *Ty ///< The type to bitcast or addrspacecast C to + ); + /// @brief Create a ZExt, Bitcast or Trunc for integer -> integer casts static Constant *getIntegerCast( Constant *C, ///< The integer constant to be casted -- cgit v1.1 From 35a02635b23f3b063a8860b6258c5b3e9507840a Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Mon, 9 Dec 2013 08:35:51 +0000 Subject: Merging r195494: ------------------------------------------------------------------------ r195494 | mren | 2013-11-22 11:41:59 -0800 (Fri, 22 Nov 2013) | 4 lines Debug Info: add a constant for debug info version number. This will be used to output the debug info version number as a module flag. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@196760 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/Dwarf.h | 1 + 1 file changed, 1 insertion(+) (limited to 'include') diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index 23bbd1c..e1a4dc0 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -57,6 +57,7 @@ enum LLVMConstants LLVM_ENUM_INT_TYPE(uint32_t) { DW_TAG_user_base = 0x1000, // Recommended base for user tags. DWARF_VERSION = 4, // Default dwarf version we output. + DEBUG_INFO_VERSION = 1, // Current debug info version number. DW_CIE_VERSION = 1, // Common frame information version. DW_PUBTYPES_VERSION = 2, // Section version number for .debug_pubtypes. DW_PUBNAMES_VERSION = 2, // Section version number for .debug_pubnames. -- cgit v1.1 From c877b10446669bf107c19cab78b920ce9cffb989 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Mon, 9 Dec 2013 21:00:02 +0000 Subject: Merging r195505: ------------------------------------------------------------------------ r195505 | mren | 2013-11-22 14:06:31 -0800 (Fri, 22 Nov 2013) | 8 lines Debug Info: move StripDebugInfo from StripSymbols.cpp to DebugInfo.cpp. We can share the implementation between StripSymbols and dropping debug info for metadata versions that do not match. Also update the comments to match the implementation. A follow-on patch will drop the "Debug Info Version" module flag in StripDebugInfo. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@196816 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 07bd832..0ff7d85 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -753,6 +753,12 @@ DIVariable cleanseInlinedVariable(MDNode *DV, LLVMContext &VMContext); /// Construct DITypeIdentifierMap by going through retained types of each CU. DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes); +/// Strip debug info in the module if it exists. +/// To do this, we remove all calls to the debugger intrinsics and any named +/// metadata for debugging. We also remove debug locations for instructions. +/// Return true if module is modified. +bool StripDebugInfo(Module &M); + /// DebugInfoFinder tries to list all debug info MDNodes used in a module. To /// list debug info MDNodes used by an instruction, DebugInfoFinder uses /// processDeclare, processValue and processLocation to handle DbgDeclareInst, -- cgit v1.1 From 7bb782b1cd3b931cf27565bd7c5a8952037f01cb Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Mon, 9 Dec 2013 21:03:35 +0000 Subject: Merging r196144: ------------------------------------------------------------------------ r196144 | mren | 2013-12-02 12:09:52 -0800 (Mon, 02 Dec 2013) | 4 lines Debug Info: Move the constant for Debug Info Version from Dwarf.h to Metadata.h. Suggested by Eric. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@196819 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/Metadata.h | 4 ++++ include/llvm/Support/Dwarf.h | 1 - 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/llvm/IR/Metadata.h b/include/llvm/IR/Metadata.h index 49eb895..9659c2e 100644 --- a/include/llvm/IR/Metadata.h +++ b/include/llvm/IR/Metadata.h @@ -28,6 +28,10 @@ template class SymbolTableListTraits; +enum LLVMConstants LLVM_ENUM_INT_TYPE(uint32_t) { + DEBUG_METADATA_VERSION = 1 // Current debug info version number. +}; + //===----------------------------------------------------------------------===// /// MDString - a single uniqued string. /// These are used to efficiently contain a byte sequence for metadata. diff --git a/include/llvm/Support/Dwarf.h b/include/llvm/Support/Dwarf.h index e1a4dc0..23bbd1c 100644 --- a/include/llvm/Support/Dwarf.h +++ b/include/llvm/Support/Dwarf.h @@ -57,7 +57,6 @@ enum LLVMConstants LLVM_ENUM_INT_TYPE(uint32_t) { DW_TAG_user_base = 0x1000, // Recommended base for user tags. DWARF_VERSION = 4, // Default dwarf version we output. - DEBUG_INFO_VERSION = 1, // Current debug info version number. DW_CIE_VERSION = 1, // Common frame information version. DW_PUBTYPES_VERSION = 2, // Section version number for .debug_pubtypes. DW_PUBNAMES_VERSION = 2, // Section version number for .debug_pubnames. -- cgit v1.1 From 27457ac42f7a9267ab7e0190424a95fecf0ea201 Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Mon, 9 Dec 2013 21:06:30 +0000 Subject: Merging r196158: ------------------------------------------------------------------------ r196158 | mren | 2013-12-02 13:29:56 -0800 (Mon, 02 Dec 2013) | 12 lines Debug Info: drop debug info via upgrading path if version number does not match. Add a helper function getDebugInfoVersionFromModule to return the debug info version number for a module. "Verifier/module-flags-1.ll" checks for verification errors. It will seg fault when calling getDebugInfoVersionFromModule because of the incorrect format for module flags in the testing case. We make getModuleFlagsMetadata more robust by checking for error conditions. PR17982 ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@196822 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/AutoUpgrade.h | 4 ++++ include/llvm/DebugInfo.h | 3 +++ 2 files changed, 7 insertions(+) (limited to 'include') diff --git a/include/llvm/AutoUpgrade.h b/include/llvm/AutoUpgrade.h index b638d4f..c774782 100644 --- a/include/llvm/AutoUpgrade.h +++ b/include/llvm/AutoUpgrade.h @@ -57,6 +57,10 @@ namespace llvm { /// with different address spaces: the instruction is replaced by a pair /// ptrtoint+inttoptr. Value *UpgradeBitCastExpr(unsigned Opc, Constant *C, Type *DestTy); + + /// Check the debug info version number, if it is out-dated, drop the debug + /// info. Return true if module is modified. + bool UpgradeDebugInfo(Module &M); } // End llvm namespace #endif diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 0ff7d85..7c4c112 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -759,6 +759,9 @@ DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes); /// Return true if module is modified. bool StripDebugInfo(Module &M); +/// Return Debug Info Version by checking module flags. +unsigned getDebugInfoVersionFromModule(const Module &M); + /// DebugInfoFinder tries to list all debug info MDNodes used in a module. To /// list debug info MDNodes used by an instruction, DebugInfoFinder uses /// processDeclare, processValue and processLocation to handle DbgDeclareInst, -- cgit v1.1 From 51fce2c886e4ca33272975cc80bc1cc5abfcdffd Mon Sep 17 00:00:00 2001 From: Manman Ren Date: Mon, 9 Dec 2013 21:07:27 +0000 Subject: Merging r196172: ------------------------------------------------------------------------ r196172 | mren | 2013-12-02 16:12:14 -0800 (Mon, 02 Dec 2013) | 4 lines Debug Info: rename getDebugInfoVersionFromModule to getDebugMetadataVersionFromModule. Suggested by Eric. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@196823 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/DebugInfo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/llvm/DebugInfo.h b/include/llvm/DebugInfo.h index 7c4c112..768cf4e 100644 --- a/include/llvm/DebugInfo.h +++ b/include/llvm/DebugInfo.h @@ -759,8 +759,8 @@ DITypeIdentifierMap generateDITypeIdentifierMap(const NamedMDNode *CU_Nodes); /// Return true if module is modified. bool StripDebugInfo(Module &M); -/// Return Debug Info Version by checking module flags. -unsigned getDebugInfoVersionFromModule(const Module &M); +/// Return Debug Info Metadata Version by checking module flags. +unsigned getDebugMetadataVersionFromModule(const Module &M); /// DebugInfoFinder tries to list all debug info MDNodes used in a module. To /// list debug info MDNodes used by an instruction, DebugInfoFinder uses -- cgit v1.1 From 90b81731c1a9bc126d0b29321b3513c9b85f8414 Mon Sep 17 00:00:00 2001 From: Bill Wendling Date: Tue, 10 Dec 2013 18:46:12 +0000 Subject: Merging r196768: ------------------------------------------------------------------------ r196768 | majnemer | 2013-12-09 01:04:00 -0800 (Mon, 09 Dec 2013) | 5 lines ADT: Implement MutableArrayRef::reverse_iterator This adds rbegin/rend methods to MutableArrayRef, they will be used by a follow-on commit in clang. ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_34@196945 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/ADT/ArrayRef.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/llvm/ADT/ArrayRef.h b/include/llvm/ADT/ArrayRef.h index 61467e9..e5562c3 100644 --- a/include/llvm/ADT/ArrayRef.h +++ b/include/llvm/ADT/ArrayRef.h @@ -185,6 +185,8 @@ namespace llvm { public: typedef T *iterator; + typedef std::reverse_iterator reverse_iterator; + /// Construct an empty MutableArrayRef. /*implicit*/ MutableArrayRef() : ArrayRef() {} @@ -219,6 +221,9 @@ namespace llvm { iterator begin() const { return data(); } iterator end() const { return data() + this->size(); } + reverse_iterator rbegin() const { return reverse_iterator(end()); } + reverse_iterator rend() const { return reverse_iterator(begin()); } + /// front - Get the first element. T &front() const { assert(!this->empty()); -- cgit v1.1