diff options
Diffstat (limited to 'include')
29 files changed, 370 insertions, 703 deletions
diff --git a/include/llvm-c/lto.h b/include/llvm-c/lto.h index 5d9cecb..f43d365 100644 --- a/include/llvm-c/lto.h +++ b/include/llvm-c/lto.h @@ -251,12 +251,6 @@ lto_codegen_set_assembler_args(lto_code_gen_t cg, const char **args, int nargs); /** - * Enables the internalize pass during LTO optimizations. - */ -extern void -lto_codegen_set_whole_program_optimization(lto_code_gen_t cg); - -/** * 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. diff --git a/include/llvm/ADT/SmallPtrSet.h b/include/llvm/ADT/SmallPtrSet.h index 70693d5..498a034 100644 --- a/include/llvm/ADT/SmallPtrSet.h +++ b/include/llvm/ADT/SmallPtrSet.h @@ -126,9 +126,6 @@ protected: private: bool isSmall() const { return CurArray == SmallArray; } - unsigned Hash(const void *Ptr) const { - return static_cast<unsigned>(((uintptr_t)Ptr >> 4) & (CurArraySize-1)); - } const void * const *FindBucketFor(const void *Ptr) const; void shrink_and_clear(); diff --git a/include/llvm/ADT/StringMap.h b/include/llvm/ADT/StringMap.h index 097418e..b4497a2 100644 --- a/include/llvm/ADT/StringMap.h +++ b/include/llvm/ADT/StringMap.h @@ -239,7 +239,7 @@ public: explicit StringMap(AllocatorTy A) : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))), Allocator(A) {} - explicit StringMap(const StringMap &RHS) + StringMap(const StringMap &RHS) : StringMapImpl(static_cast<unsigned>(sizeof(MapEntryTy))) { assert(RHS.empty() && "Copy ctor from non-empty stringmap not implemented yet!"); diff --git a/include/llvm/CodeGen/DFAPacketizer.h b/include/llvm/CodeGen/DFAPacketizer.h index 2d2db78..ee1ed07 100644 --- a/include/llvm/CodeGen/DFAPacketizer.h +++ b/include/llvm/CodeGen/DFAPacketizer.h @@ -28,7 +28,6 @@ #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/ADT/DenseMap.h" -#include <map> namespace llvm { @@ -37,7 +36,7 @@ class MachineInstr; class MachineLoopInfo; class MachineDominatorTree; class InstrItineraryData; -class DefaultVLIWScheduler; +class ScheduleDAGInstrs; class SUnit; class DFAPacketizer { @@ -78,8 +77,6 @@ public: // reserveResources - Reserve the resources occupied by a machine // instruction and change the current state to reflect that change. void reserveResources(llvm::MachineInstr *MI); - - const InstrItineraryData *getInstrItins() const { return InstrItins; } }; // VLIWPacketizerList - Implements a simple VLIW packetizer using DFA. The @@ -90,21 +87,20 @@ public: // and machine resource is marked as taken. If any dependency is found, a target // API call is made to prune the dependence. class VLIWPacketizerList { -protected: const TargetMachine &TM; const MachineFunction &MF; const TargetInstrInfo *TII; - // The VLIW Scheduler. - DefaultVLIWScheduler *VLIWScheduler; + // Encapsulate data types not exposed to the target interface. + ScheduleDAGInstrs *SchedulerImpl; +protected: // Vector of instructions assigned to the current packet. std::vector<MachineInstr*> CurrentPacketMIs; // DFA resource tracker. DFAPacketizer *ResourceTracker; - - // Generate MI -> SU map. - std::map<MachineInstr*, SUnit*> MIToSUnit; + // Scheduling units. + std::vector<SUnit> SUnits; public: VLIWPacketizerList( @@ -122,32 +118,17 @@ public: DFAPacketizer *getResourceTracker() {return ResourceTracker;} // addToPacket - Add MI to the current packet. - virtual MachineBasicBlock::iterator addToPacket(MachineInstr *MI) { - MachineBasicBlock::iterator MII = MI; - CurrentPacketMIs.push_back(MI); - ResourceTracker->reserveResources(MI); - return MII; - } + void addToPacket(MachineInstr *MI); // endPacket - End the current packet. - void endPacket(MachineBasicBlock *MBB, MachineInstr *MI); - - // initPacketizerState - perform initialization before packetizing - // an instruction. This function is supposed to be overrided by - // the target dependent packetizer. - virtual void initPacketizerState(void) { return; } + void endPacket(MachineBasicBlock *MBB, MachineInstr *I); // ignorePseudoInstruction - Ignore bundling of pseudo instructions. - virtual bool ignorePseudoInstruction(MachineInstr *I, - MachineBasicBlock *MBB) { - return false; - } + bool ignorePseudoInstruction(MachineInstr *I, MachineBasicBlock *MBB); - // isSoloInstruction - return true if instruction MI can not be packetized - // with any other instruction, which means that MI itself is a packet. - virtual bool isSoloInstruction(MachineInstr *MI) { - return true; - } + // isSoloInstruction - return true if instruction I must end previous + // packet. + bool isSoloInstruction(MachineInstr *I); // isLegalToPacketizeTogether - Is it legal to packetize SUI and SUJ // together. @@ -160,7 +141,6 @@ public: virtual bool isLegalToPruneDependencies(SUnit *SUI, SUnit *SUJ) { return false; } - }; } diff --git a/include/llvm/CodeGen/Passes.h b/include/llvm/CodeGen/Passes.h index 3b38199..e76fe99 100644 --- a/include/llvm/CodeGen/Passes.h +++ b/include/llvm/CodeGen/Passes.h @@ -56,7 +56,7 @@ public: protected: TargetMachine *TM; - PassManagerBase &PM; + PassManagerBase *PM; PassConfigImpl *Impl; // Internal data structures bool Initialized; // Flagged after all passes are configured. diff --git a/include/llvm/CodeGen/ScheduleDAGInstrs.h b/include/llvm/CodeGen/ScheduleDAGInstrs.h index c8de7bc..4fee108 100644 --- a/include/llvm/CodeGen/ScheduleDAGInstrs.h +++ b/include/llvm/CodeGen/ScheduleDAGInstrs.h @@ -181,6 +181,13 @@ namespace llvm { /// 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 + /// TargetInstrInfo::isSchedulingBoundary then enable this flag to indicate + /// it has taken responsibility for scheduling the terminator correctly. + bool CanHandleTerminators; + /// State specific to the current scheduling region. /// ------------------------------------------------ diff --git a/include/llvm/CodeGen/SlotIndexes.h b/include/llvm/CodeGen/SlotIndexes.h index d868cb8..0457e43 100644 --- a/include/llvm/CodeGen/SlotIndexes.h +++ b/include/llvm/CodeGen/SlotIndexes.h @@ -23,6 +23,7 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/ADT/PointerIntPair.h" +#include "llvm/ADT/ilist.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/Allocator.h" @@ -33,8 +34,7 @@ namespace llvm { /// SlotIndexes pass. It should not be used directly. See the /// SlotIndex & SlotIndexes classes for the public interface to this /// information. - class IndexListEntry { - IndexListEntry *next, *prev; + class IndexListEntry : public ilist_node<IndexListEntry> { MachineInstr *mi; unsigned index; @@ -51,31 +51,26 @@ namespace llvm { void setIndex(unsigned index) { this->index = index; } - - IndexListEntry* getNext() { return next; } - const IndexListEntry* getNext() const { return next; } - void setNext(IndexListEntry *next) { - this->next = next; - } - IndexListEntry* getPrev() { return prev; } - const IndexListEntry* getPrev() const { return prev; } - void setPrev(IndexListEntry *prev) { - this->prev = prev; - } }; - // Specialize PointerLikeTypeTraits for IndexListEntry. template <> - class PointerLikeTypeTraits<IndexListEntry*> { + struct ilist_traits<IndexListEntry> : public ilist_default_traits<IndexListEntry> { + private: + mutable ilist_half_node<IndexListEntry> Sentinel; public: - static inline void* getAsVoidPointer(IndexListEntry *p) { - return p; + IndexListEntry *createSentinel() const { + return static_cast<IndexListEntry*>(&Sentinel); } - static inline IndexListEntry* getFromVoidPointer(void *p) { - return static_cast<IndexListEntry*>(p); - } - enum { NumLowBitsAvailable = 3 }; + void destroySentinel(IndexListEntry *) const {} + + IndexListEntry *provideInitialHead() const { return createSentinel(); } + IndexListEntry *ensureHead(IndexListEntry*) const { return createSentinel(); } + static void noteHead(IndexListEntry*, IndexListEntry*) {} + void deleteNode(IndexListEntry *N) {} + + private: + void createNode(const IndexListEntry &); }; /// SlotIndex - An opaque wrapper around machine indexes. @@ -112,13 +107,13 @@ namespace llvm { SlotIndex(IndexListEntry *entry, unsigned slot) : lie(entry, slot) {} - IndexListEntry& entry() const { + IndexListEntry* listEntry() const { assert(isValid() && "Attempt to compare reserved index."); - return *lie.getPointer(); + return lie.getPointer(); } int getIndex() const { - return entry().getIndex() | getSlot(); + return listEntry()->getIndex() | getSlot(); } /// Returns the slot for this SlotIndex. @@ -150,8 +145,7 @@ namespace llvm { SlotIndex() : lie(0, 0) {} // Construct a new slot index from the given one, and set the slot. - SlotIndex(const SlotIndex &li, Slot s) - : lie(&li.entry(), unsigned(s)) { + SlotIndex(const SlotIndex &li, Slot s) : lie(li.listEntry(), unsigned(s)) { assert(lie.getPointer() != 0 && "Attempt to construct index with 0 pointer."); } @@ -179,7 +173,7 @@ namespace llvm { bool operator!=(SlotIndex other) const { return lie != other.lie; } - + /// Compare two SlotIndex objects. Return true if the first index /// is strictly lower than the second. bool operator<(SlotIndex other) const { @@ -211,7 +205,7 @@ namespace llvm { /// isEarlierInstr - Return true if A refers to an instruction earlier than /// B. This is equivalent to A < B && !isSameInstr(A, B). static bool isEarlierInstr(SlotIndex A, SlotIndex B) { - return A.entry().getIndex() < B.entry().getIndex(); + return A.listEntry()->getIndex() < B.listEntry()->getIndex(); } /// Return the distance from this index to the given one. @@ -236,25 +230,25 @@ namespace llvm { /// is the one associated with the Slot_Block slot for the instruction /// pointed to by this index. SlotIndex getBaseIndex() const { - return SlotIndex(&entry(), Slot_Block); + return SlotIndex(listEntry(), Slot_Block); } /// Returns the boundary index for associated with this index. The boundary /// index is the one associated with the Slot_Block slot for the instruction /// pointed to by this index. SlotIndex getBoundaryIndex() const { - return SlotIndex(&entry(), Slot_Dead); + return SlotIndex(listEntry(), Slot_Dead); } /// Returns the register use/def slot in the current instruction for a /// normal or early-clobber def. SlotIndex getRegSlot(bool EC = false) const { - return SlotIndex(&entry(), EC ? Slot_EarlyClobber : Slot_Register); + return SlotIndex(listEntry(), EC ? Slot_EarlyClobber : Slot_Register); } /// Returns the dead def kill slot for the current instruction. SlotIndex getDeadSlot() const { - return SlotIndex(&entry(), Slot_Dead); + return SlotIndex(listEntry(), Slot_Dead); } /// Returns the next slot in the index list. This could be either the @@ -266,15 +260,15 @@ namespace llvm { SlotIndex getNextSlot() const { Slot s = getSlot(); if (s == Slot_Dead) { - return SlotIndex(entry().getNext(), Slot_Block); + return SlotIndex(listEntry()->getNextNode(), Slot_Block); } - return SlotIndex(&entry(), s + 1); + return SlotIndex(listEntry(), s + 1); } /// Returns the next index. This is the index corresponding to the this /// index's slot, but for the next instruction. SlotIndex getNextIndex() const { - return SlotIndex(entry().getNext(), getSlot()); + return SlotIndex(listEntry()->getNextNode(), getSlot()); } /// Returns the previous slot in the index list. This could be either the @@ -286,15 +280,15 @@ namespace llvm { SlotIndex getPrevSlot() const { Slot s = getSlot(); if (s == Slot_Block) { - return SlotIndex(entry().getPrev(), Slot_Dead); + return SlotIndex(listEntry()->getPrevNode(), Slot_Dead); } - return SlotIndex(&entry(), s - 1); + return SlotIndex(listEntry(), s - 1); } /// Returns the previous index. This is the index corresponding to this /// index's slot, but for the previous instruction. SlotIndex getPrevIndex() const { - return SlotIndex(entry().getPrev(), getSlot()); + return SlotIndex(listEntry()->getPrevNode(), getSlot()); } }; @@ -315,7 +309,7 @@ namespace llvm { return (LHS == RHS); } }; - + template <> struct isPodLike<SlotIndex> { static const bool value = true; }; @@ -346,8 +340,10 @@ namespace llvm { class SlotIndexes : public MachineFunctionPass { private: + typedef ilist<IndexListEntry> IndexList; + IndexList indexList; + MachineFunction *mf; - IndexListEntry *indexListHead; unsigned functionSize; typedef DenseMap<const MachineInstr*, SlotIndex> Mi2IndexMap; @@ -374,84 +370,18 @@ namespace llvm { return entry; } - void initList() { - assert(indexListHead == 0 && "Zero entry non-null at initialisation."); - indexListHead = createEntry(0, ~0U); - indexListHead->setNext(0); - indexListHead->setPrev(indexListHead); - } - - void clearList() { - indexListHead = 0; - ileAllocator.Reset(); - } - - IndexListEntry* getTail() { - assert(indexListHead != 0 && "Call to getTail on uninitialized list."); - return indexListHead->getPrev(); - } - - const IndexListEntry* getTail() const { - assert(indexListHead != 0 && "Call to getTail on uninitialized list."); - return indexListHead->getPrev(); - } - - // Returns true if the index list is empty. - bool empty() const { return (indexListHead == getTail()); } - - IndexListEntry* front() { - assert(!empty() && "front() called on empty index list."); - return indexListHead; - } - - const IndexListEntry* front() const { - assert(!empty() && "front() called on empty index list."); - return indexListHead; - } - - IndexListEntry* back() { - assert(!empty() && "back() called on empty index list."); - return getTail()->getPrev(); - } - - const IndexListEntry* back() const { - assert(!empty() && "back() called on empty index list."); - return getTail()->getPrev(); - } - - /// Insert a new entry before itr. - void insert(IndexListEntry *itr, IndexListEntry *val) { - assert(itr != 0 && "itr should not be null."); - IndexListEntry *prev = itr->getPrev(); - val->setNext(itr); - val->setPrev(prev); - - if (itr != indexListHead) { - prev->setNext(val); - } - else { - indexListHead = val; - } - itr->setPrev(val); - } - - /// Push a new entry on to the end of the list. - void push_back(IndexListEntry *val) { - insert(getTail(), val); - } - - /// Renumber locally after inserting newEntry. - void renumberIndexes(IndexListEntry *newEntry); + /// Renumber locally after inserting curItr. + void renumberIndexes(IndexList::iterator curItr); public: static char ID; - SlotIndexes() : MachineFunctionPass(ID), indexListHead(0) { + SlotIndexes() : MachineFunctionPass(ID) { initializeSlotIndexesPass(*PassRegistry::getPassRegistry()); } virtual void getAnalysisUsage(AnalysisUsage &au) const; - virtual void releaseMemory(); + virtual void releaseMemory(); virtual bool runOnMachineFunction(MachineFunction &fn); @@ -463,22 +393,21 @@ namespace llvm { /// Returns the zero index for this analysis. SlotIndex getZeroIndex() { - assert(front()->getIndex() == 0 && "First index is not 0?"); - return SlotIndex(front(), 0); + assert(indexList.front().getIndex() == 0 && "First index is not 0?"); + return SlotIndex(&indexList.front(), 0); } /// Returns the base index of the last slot in this analysis. SlotIndex getLastIndex() { - return SlotIndex(back(), 0); + return SlotIndex(&indexList.back(), 0); } /// Returns the distance between the highest and lowest indexes allocated /// so far. unsigned getIndexesLength() const { - assert(front()->getIndex() == 0 && + assert(indexList.front().getIndex() == 0 && "Initial index isn't zero?"); - - return back()->getIndex(); + return indexList.back().getIndex(); } /// Returns the number of instructions in the function. @@ -503,19 +432,15 @@ namespace llvm { /// Returns the instruction for the given index, or null if the given /// index has no instruction associated with it. MachineInstr* getInstructionFromIndex(SlotIndex index) const { - return index.isValid() ? index.entry().getInstr() : 0; + return index.isValid() ? index.listEntry()->getInstr() : 0; } /// Returns the next non-null index. SlotIndex getNextNonNullIndex(SlotIndex index) { - SlotIndex nextNonNull = index.getNextIndex(); - - while (&nextNonNull.entry() != getTail() && - getInstructionFromIndex(nextNonNull) == 0) { - nextNonNull = nextNonNull.getNextIndex(); - } - - return nextNonNull; + IndexList::iterator itr(index.listEntry()); + ++itr; + while (itr != indexList.end() && itr->getInstr() == 0) { ++itr; } + return SlotIndex(itr, index.getSlot()); } /// getIndexBefore - Returns the index of the last indexed instruction @@ -659,31 +584,31 @@ namespace llvm { assert(mi->getParent() != 0 && "Instr must be added to function."); // Get the entries where mi should be inserted. - IndexListEntry *prevEntry, *nextEntry; + IndexList::iterator prevItr, nextItr; if (Late) { // Insert mi's index immediately before the following instruction. - nextEntry = &getIndexAfter(mi).entry(); - prevEntry = nextEntry->getPrev(); + nextItr = getIndexAfter(mi).listEntry(); + prevItr = prior(nextItr); } else { // Insert mi's index immediately after the preceeding instruction. - prevEntry = &getIndexBefore(mi).entry(); - nextEntry = prevEntry->getNext(); + prevItr = getIndexBefore(mi).listEntry(); + nextItr = llvm::next(prevItr); } // Get a number for the new instr, or 0 if there's no room currently. // In the latter case we'll force a renumber later. - unsigned dist = ((nextEntry->getIndex() - prevEntry->getIndex())/2) & ~3u; - unsigned newNumber = prevEntry->getIndex() + dist; + unsigned dist = ((nextItr->getIndex() - prevItr->getIndex())/2) & ~3u; + unsigned newNumber = prevItr->getIndex() + dist; // Insert a new list entry for mi. - IndexListEntry *newEntry = createEntry(mi, newNumber); - insert(nextEntry, newEntry); + IndexList::iterator newItr = + indexList.insert(nextItr, createEntry(mi, newNumber)); // Renumber locally if we need to. if (dist == 0) - renumberIndexes(newEntry); + renumberIndexes(newItr); - SlotIndex newIndex(newEntry, SlotIndex::Slot_Block); + SlotIndex newIndex(&*newItr, SlotIndex::Slot_Block); mi2iMap.insert(std::make_pair(mi, newIndex)); return newIndex; } @@ -694,7 +619,7 @@ namespace llvm { // MachineInstr -> index mappings Mi2IndexMap::iterator mi2iItr = mi2iMap.find(mi); if (mi2iItr != mi2iMap.end()) { - IndexListEntry *miEntry(&mi2iItr->second.entry()); + IndexListEntry *miEntry(mi2iItr->second.listEntry()); assert(miEntry->getInstr() == mi && "Instruction indexes broken."); // FIXME: Eventually we want to actually delete these indexes. miEntry->setInstr(0); @@ -709,7 +634,7 @@ namespace llvm { if (mi2iItr == mi2iMap.end()) return; SlotIndex replaceBaseIndex = mi2iItr->second; - IndexListEntry *miEntry(&replaceBaseIndex.entry()); + IndexListEntry *miEntry(replaceBaseIndex.listEntry()); assert(miEntry->getInstr() == mi && "Mismatched instruction in index tables."); miEntry->setInstr(newMI); @@ -726,13 +651,13 @@ namespace llvm { IndexListEntry *nextEntry = 0; if (nextMBB == mbb->getParent()->end()) { - nextEntry = getTail(); + nextEntry = indexList.end(); } else { - nextEntry = &getMBBStartIdx(nextMBB).entry(); + nextEntry = getMBBStartIdx(nextMBB).listEntry(); } - insert(nextEntry, startEntry); - insert(nextEntry, stopEntry); + indexList.insert(nextEntry, startEntry); + indexList.insert(nextEntry, stopEntry); SlotIndex startIdx(startEntry, SlotIndex::Slot_Block); SlotIndex endIdx(nextEntry, SlotIndex::Slot_Block); @@ -766,4 +691,4 @@ namespace llvm { } -#endif // LLVM_CODEGEN_LIVEINDEX_H +#endif // LLVM_CODEGEN_SLOTINDEXES_H diff --git a/include/llvm/Config/config.h.cmake b/include/llvm/Config/config.h.cmake index 69e3580..95c4d6c 100644 --- a/include/llvm/Config/config.h.cmake +++ b/include/llvm/Config/config.h.cmake @@ -11,9 +11,6 @@ /* Relative directory for resource files */ #define CLANG_RESOURCE_DIR "${CLANG_RESOURCE_DIR}" -/* Directory wherelibstdc++ is installed. */ -#define GCC_INSTALL_PREFIX "${GCC_INSTALL_PREFIX}" - /* Directories clang will search for headers */ #define C_INCLUDE_DIRS "${C_INCLUDE_DIRS}" diff --git a/include/llvm/Config/config.h.in b/include/llvm/Config/config.h.in index ccff7da..677bf2e 100644 --- a/include/llvm/Config/config.h.in +++ b/include/llvm/Config/config.h.in @@ -12,6 +12,9 @@ /* Directories clang will search for headers */ #undef C_INCLUDE_DIRS +/* Default <path> to all compiler invocations for --sysroot=<path>. */ +#undef DEFAULT_SYSROOT + /* Define if position independent code is enabled */ #undef ENABLE_PIC diff --git a/include/llvm/IntrinsicsX86.td b/include/llvm/IntrinsicsX86.td index a6fda4a..cb7b3ea 100644 --- a/include/llvm/IntrinsicsX86.td +++ b/include/llvm/IntrinsicsX86.td @@ -1091,20 +1091,6 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". GCCBuiltin<"__builtin_ia32_vperm2f128_si256">, Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty, llvm_i8_ty], [IntrNoMem]>; - - def int_x86_avx_vpermil_pd : - Intrinsic<[llvm_v2f64_ty], [llvm_v2f64_ty, - llvm_i8_ty], [IntrNoMem]>; - def int_x86_avx_vpermil_ps : - Intrinsic<[llvm_v4f32_ty], [llvm_v4f32_ty, - llvm_i8_ty], [IntrNoMem]>; - - def int_x86_avx_vpermil_pd_256 : - Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, - llvm_i8_ty], [IntrNoMem]>; - def int_x86_avx_vpermil_ps_256 : - Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, - llvm_i8_ty], [IntrNoMem]>; } // Vector blend @@ -1659,15 +1645,9 @@ let TargetPrefix = "x86" in { // All intrinsics start with "llvm.x86.". def int_x86_avx2_permd : GCCBuiltin<"__builtin_ia32_permvarsi256">, Intrinsic<[llvm_v8i32_ty], [llvm_v8i32_ty, llvm_v8i32_ty], [IntrNoMem]>; - def int_x86_avx2_permq : GCCBuiltin<"__builtin_ia32_permdi256">, - Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_i8_ty], - [IntrNoMem]>; def int_x86_avx2_permps : GCCBuiltin<"__builtin_ia32_permvarsf256">, Intrinsic<[llvm_v8f32_ty], [llvm_v8f32_ty, llvm_v8f32_ty], [IntrNoMem]>; - def int_x86_avx2_permpd : GCCBuiltin<"__builtin_ia32_permdf256">, - Intrinsic<[llvm_v4f64_ty], [llvm_v4f64_ty, llvm_i8_ty], - [IntrNoMem]>; def int_x86_avx2_vperm2i128 : GCCBuiltin<"__builtin_ia32_permti256">, Intrinsic<[llvm_v4i64_ty], [llvm_v4i64_ty, llvm_v4i64_ty, llvm_i8_ty], [IntrNoMem]>; diff --git a/include/llvm/LLVMContext.h b/include/llvm/LLVMContext.h index 18adcd1..a8306a9 100644 --- a/include/llvm/LLVMContext.h +++ b/include/llvm/LLVMContext.h @@ -42,7 +42,7 @@ public: MD_dbg = 0, // "dbg" MD_tbaa = 1, // "tbaa" MD_prof = 2, // "prof" - MD_fpaccuracy = 3, // "fpaccuracy" + MD_fpmath = 3, // "fpmath" MD_range = 4 // "range" }; diff --git a/include/llvm/MC/MCParser/AsmLexer.h b/include/llvm/MC/MCParser/AsmLexer.h index dcecfb6..9a8735f 100644 --- a/include/llvm/MC/MCParser/AsmLexer.h +++ b/include/llvm/MC/MCParser/AsmLexer.h @@ -16,14 +16,11 @@ #include "llvm/ADT/StringRef.h" #include "llvm/MC/MCParser/MCAsmLexer.h" -#include "llvm/MC/MCAsmInfo.h" #include "llvm/Support/DataTypes.h" #include <string> -#include <cassert> namespace llvm { class MemoryBuffer; -class SMLoc; class MCAsmInfo; /// AsmLexer - Lexer class for assembly files. diff --git a/include/llvm/MC/MCParser/MCAsmLexer.h b/include/llvm/MC/MCParser/MCAsmLexer.h index ac04483..5e29ad4 100644 --- a/include/llvm/MC/MCParser/MCAsmLexer.h +++ b/include/llvm/MC/MCParser/MCAsmLexer.h @@ -15,8 +15,6 @@ #include "llvm/Support/SMLoc.h" namespace llvm { -class MCAsmLexer; -class MCInst; /// AsmToken - Target independent representation for an assembler token. class AsmToken { @@ -53,6 +51,7 @@ public: Greater, GreaterEqual, GreaterGreater, At }; +private: TokenKind Kind; /// A reference to the entire token contents; this is always a pointer into diff --git a/include/llvm/Object/ELF.h b/include/llvm/Object/ELF.h index 0828985..e493f5b 100644 --- a/include/llvm/Object/ELF.h +++ b/include/llvm/Object/ELF.h @@ -33,6 +33,15 @@ namespace llvm { namespace object { +// Subclasses of ELFObjectFile may need this for template instantiation +inline std::pair<unsigned char, unsigned char> +getElfArchType(MemoryBuffer *Object) { + if (Object->getBufferSize() < ELF::EI_NIDENT) + return std::make_pair((uint8_t)ELF::ELFCLASSNONE,(uint8_t)ELF::ELFDATANONE); + return std::make_pair( (uint8_t)Object->getBufferStart()[ELF::EI_CLASS] + , (uint8_t)Object->getBufferStart()[ELF::EI_DATA]); +} + // Templates to choose Elf_Addr and Elf_Off depending on is64Bits. template<support::endianness target_endianness> struct ELFDataTypeTypedefHelperCommon { diff --git a/include/llvm/Operator.h b/include/llvm/Operator.h index abd6a19..1e86980 100644 --- a/include/llvm/Operator.h +++ b/include/llvm/Operator.h @@ -15,8 +15,9 @@ #ifndef LLVM_OPERATOR_H #define LLVM_OPERATOR_H -#include "llvm/Instruction.h" #include "llvm/Constants.h" +#include "llvm/Instruction.h" +#include "llvm/Type.h" namespace llvm { @@ -129,14 +130,15 @@ public: IsExact = (1 << 0) }; +private: + ~PossiblyExactOperator(); // do not implement + friend class BinaryOperator; friend class ConstantExpr; void setIsExact(bool B) { SubclassOptionalData = (SubclassOptionalData & ~IsExact) | (B * IsExact); } -private: - ~PossiblyExactOperator(); // do not implement public: /// isExact - Test whether this division is known to be exact, with /// zero remainder. @@ -161,7 +163,28 @@ public: (isa<ConstantExpr>(V) && classof(cast<ConstantExpr>(V))); } }; - + +/// FPMathOperator - Utility class for floating point operations which can have +/// information about relaxed accuracy requirements attached to them. +class FPMathOperator : public Operator { +private: + ~FPMathOperator(); // do not implement + +public: + + /// \brief Get the maximum error permitted by this operation in ULPs. An + /// accuracy of 0.0 means that the operation should be performed with the + /// default precision. + float getFPAccuracy() const; + + static inline bool classof(const FPMathOperator *) { return true; } + static inline bool classof(const Instruction *I) { + return I->getType()->isFPOrFPVectorTy(); + } + static inline bool classof(const Value *V) { + return isa<Instruction>(V) && classof(cast<Instruction>(V)); + } +}; /// ConcreteOperator - A helper template for defining operators for individual diff --git a/include/llvm/Support/IRBuilder.h b/include/llvm/Support/IRBuilder.h index 7828001..ef00e8e 100644 --- a/include/llvm/Support/IRBuilder.h +++ b/include/llvm/Support/IRBuilder.h @@ -17,6 +17,7 @@ #include "llvm/Instructions.h" #include "llvm/BasicBlock.h" +#include "llvm/LLVMContext.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" #include "llvm/ADT/Twine.h" @@ -331,49 +332,63 @@ template<bool preserveNames = true, typename T = ConstantFolder, typename Inserter = IRBuilderDefaultInserter<preserveNames> > class IRBuilder : public IRBuilderBase, public Inserter { T Folder; + MDNode *DefaultFPMathTag; public: - IRBuilder(LLVMContext &C, const T &F, const Inserter &I = Inserter()) - : IRBuilderBase(C), Inserter(I), Folder(F) { + IRBuilder(LLVMContext &C, const T &F, const Inserter &I = Inserter(), + MDNode *FPMathTag = 0) + : IRBuilderBase(C), Inserter(I), Folder(F), DefaultFPMathTag(FPMathTag) { } - explicit IRBuilder(LLVMContext &C) : IRBuilderBase(C), Folder() { + explicit IRBuilder(LLVMContext &C, MDNode *FPMathTag = 0) : IRBuilderBase(C), + Folder(), DefaultFPMathTag(FPMathTag) { } - explicit IRBuilder(BasicBlock *TheBB, const T &F) - : IRBuilderBase(TheBB->getContext()), Folder(F) { + explicit IRBuilder(BasicBlock *TheBB, const T &F, MDNode *FPMathTag = 0) + : IRBuilderBase(TheBB->getContext()), Folder(F), + DefaultFPMathTag(FPMathTag) { SetInsertPoint(TheBB); } - explicit IRBuilder(BasicBlock *TheBB) - : IRBuilderBase(TheBB->getContext()), Folder() { + explicit IRBuilder(BasicBlock *TheBB, MDNode *FPMathTag = 0) + : IRBuilderBase(TheBB->getContext()), Folder(), + DefaultFPMathTag(FPMathTag) { SetInsertPoint(TheBB); } - explicit IRBuilder(Instruction *IP) - : IRBuilderBase(IP->getContext()), Folder() { + explicit IRBuilder(Instruction *IP, MDNode *FPMathTag = 0) + : IRBuilderBase(IP->getContext()), Folder(), DefaultFPMathTag(FPMathTag) { SetInsertPoint(IP); SetCurrentDebugLocation(IP->getDebugLoc()); } - explicit IRBuilder(Use &U) - : IRBuilderBase(U->getContext()), Folder() { + explicit IRBuilder(Use &U, MDNode *FPMathTag = 0) + : IRBuilderBase(U->getContext()), Folder(), DefaultFPMathTag(FPMathTag) { SetInsertPoint(U); SetCurrentDebugLocation(cast<Instruction>(U.getUser())->getDebugLoc()); } - IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F) - : IRBuilderBase(TheBB->getContext()), Folder(F) { + IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F, + MDNode *FPMathTag = 0) + : IRBuilderBase(TheBB->getContext()), Folder(F), + DefaultFPMathTag(FPMathTag) { SetInsertPoint(TheBB, IP); } - IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP) - : IRBuilderBase(TheBB->getContext()), Folder() { + IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, MDNode *FPMathTag = 0) + : IRBuilderBase(TheBB->getContext()), Folder(), + DefaultFPMathTag(FPMathTag) { SetInsertPoint(TheBB, IP); } /// getFolder - Get the constant folder being used. const T &getFolder() { return Folder; } + /// getDefaultFPMathTag - Get the floating point math metadata being used. + MDNode *getDefaultFPMathTag() const { return DefaultFPMathTag; } + + /// SetDefaultFPMathTag - Set the floating point math metadata to be used. + void SetDefaultFPMathTag(MDNode *FPMathTag) { DefaultFPMathTag = FPMathTag; } + /// isNamePreserving - Return true if this builder is configured to actually /// add the requested names to IR created through it. bool isNamePreserving() const { return preserveNames; } @@ -496,6 +511,14 @@ private: if (HasNSW) BO->setHasNoSignedWrap(); return BO; } + + Instruction *AddFPMathTag(Instruction *I, MDNode *FPMathTag) const { + if (!FPMathTag) + FPMathTag = DefaultFPMathTag; + if (FPMathTag) + I->setMetadata(LLVMContext::MD_fpmath, FPMathTag); + return I; + } public: Value *CreateAdd(Value *LHS, Value *RHS, const Twine &Name = "", bool HasNUW = false, bool HasNSW = false) { @@ -511,11 +534,13 @@ public: Value *CreateNUWAdd(Value *LHS, Value *RHS, const Twine &Name = "") { return CreateAdd(LHS, RHS, Name, true, false); } - Value *CreateFAdd(Value *LHS, Value *RHS, const Twine &Name = "") { + Value *CreateFAdd(Value *LHS, Value *RHS, const Twine &Name = "", + MDNode *FPMathTag = 0) { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return Insert(Folder.CreateFAdd(LC, RC), Name); - return Insert(BinaryOperator::CreateFAdd(LHS, RHS), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFAdd(LHS, RHS), + FPMathTag), Name); } Value *CreateSub(Value *LHS, Value *RHS, const Twine &Name = "", bool HasNUW = false, bool HasNSW = false) { @@ -531,11 +556,13 @@ public: Value *CreateNUWSub(Value *LHS, Value *RHS, const Twine &Name = "") { return CreateSub(LHS, RHS, Name, true, false); } - Value *CreateFSub(Value *LHS, Value *RHS, const Twine &Name = "") { + Value *CreateFSub(Value *LHS, Value *RHS, const Twine &Name = "", + MDNode *FPMathTag = 0) { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return Insert(Folder.CreateFSub(LC, RC), Name); - return Insert(BinaryOperator::CreateFSub(LHS, RHS), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFSub(LHS, RHS), + FPMathTag), Name); } Value *CreateMul(Value *LHS, Value *RHS, const Twine &Name = "", bool HasNUW = false, bool HasNSW = false) { @@ -551,11 +578,13 @@ public: Value *CreateNUWMul(Value *LHS, Value *RHS, const Twine &Name = "") { return CreateMul(LHS, RHS, Name, true, false); } - Value *CreateFMul(Value *LHS, Value *RHS, const Twine &Name = "") { + Value *CreateFMul(Value *LHS, Value *RHS, const Twine &Name = "", + MDNode *FPMathTag = 0) { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return Insert(Folder.CreateFMul(LC, RC), Name); - return Insert(BinaryOperator::CreateFMul(LHS, RHS), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFMul(LHS, RHS), + FPMathTag), Name); } Value *CreateUDiv(Value *LHS, Value *RHS, const Twine &Name = "", bool isExact = false) { @@ -581,11 +610,13 @@ public: Value *CreateExactSDiv(Value *LHS, Value *RHS, const Twine &Name = "") { return CreateSDiv(LHS, RHS, Name, true); } - Value *CreateFDiv(Value *LHS, Value *RHS, const Twine &Name = "") { + Value *CreateFDiv(Value *LHS, Value *RHS, const Twine &Name = "", + MDNode *FPMathTag = 0) { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return Insert(Folder.CreateFDiv(LC, RC), Name); - return Insert(BinaryOperator::CreateFDiv(LHS, RHS), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFDiv(LHS, RHS), + FPMathTag), Name); } Value *CreateURem(Value *LHS, Value *RHS, const Twine &Name = "") { if (Constant *LC = dyn_cast<Constant>(LHS)) @@ -599,11 +630,13 @@ public: return Insert(Folder.CreateSRem(LC, RC), Name); return Insert(BinaryOperator::CreateSRem(LHS, RHS), Name); } - Value *CreateFRem(Value *LHS, Value *RHS, const Twine &Name = "") { + Value *CreateFRem(Value *LHS, Value *RHS, const Twine &Name = "", + MDNode *FPMathTag = 0) { if (Constant *LC = dyn_cast<Constant>(LHS)) if (Constant *RC = dyn_cast<Constant>(RHS)) return Insert(Folder.CreateFRem(LC, RC), Name); - return Insert(BinaryOperator::CreateFRem(LHS, RHS), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFRem(LHS, RHS), + FPMathTag), Name); } Value *CreateShl(Value *LHS, Value *RHS, const Twine &Name = "", @@ -729,10 +762,10 @@ public: Value *CreateNUWNeg(Value *V, const Twine &Name = "") { return CreateNeg(V, Name, true, false); } - Value *CreateFNeg(Value *V, const Twine &Name = "") { + Value *CreateFNeg(Value *V, const Twine &Name = "", MDNode *FPMathTag = 0) { if (Constant *VC = dyn_cast<Constant>(V)) return Insert(Folder.CreateFNeg(VC), Name); - return Insert(BinaryOperator::CreateFNeg(V), Name); + return Insert(AddFPMathTag(BinaryOperator::CreateFNeg(V), FPMathTag), Name); } Value *CreateNot(Value *V, const Twine &Name = "") { if (Constant *VC = dyn_cast<Constant>(V)) diff --git a/include/llvm/Support/JSONParser.h b/include/llvm/Support/JSONParser.h deleted file mode 100644 index 11149f1..0000000 --- a/include/llvm/Support/JSONParser.h +++ /dev/null @@ -1,448 +0,0 @@ -//===--- JSONParser.h - Simple JSON parser ----------------------*- 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 JSON parser. -// -// See http://www.json.org/ for an overview. -// See http://www.ietf.org/rfc/rfc4627.txt for the full standard. -// -// FIXME: Currently this supports a subset of JSON. Specifically, support -// for numbers, booleans and null for values is missing. -// -//===----------------------------------------------------------------------===// - -#ifndef LLVM_SUPPORT_JSON_PARSER_H -#define LLVM_SUPPORT_JSON_PARSER_H - -#include "llvm/ADT/StringRef.h" -#include "llvm/Support/Allocator.h" -#include "llvm/Support/Casting.h" -#include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/SourceMgr.h" - -namespace llvm { - -class JSONContainer; -class JSONString; -class JSONValue; -class JSONKeyValuePair; - -/// \brief Base class for a parsable JSON atom. -/// -/// This class has no semantics other than being a unit of JSON data which can -/// be parsed out of a JSON document. -class JSONAtom { -public: - /// \brief Possible types of JSON objects. - enum Kind { JK_KeyValuePair, JK_Array, JK_Object, JK_String }; - - /// \brief Returns the type of this value. - Kind getKind() const { return MyKind; } - - static bool classof(const JSONAtom *Atom) { return true; } - -protected: - JSONAtom(Kind MyKind) : MyKind(MyKind) {} - -private: - Kind MyKind; -}; - -/// \brief A parser for JSON text. -/// -/// Use an object of JSONParser to iterate over the values of a JSON text. -/// All objects are parsed during the iteration, so you can only iterate once -/// over the JSON text, but the cost of partial iteration is minimized. -/// Create a new JSONParser if you want to iterate multiple times. -class JSONParser { -public: - /// \brief Create a JSONParser for the given input. - /// - /// Parsing is started via parseRoot(). Access to the object returned from - /// parseRoot() will parse the input lazily. - JSONParser(StringRef Input, SourceMgr *SM); - - /// \brief Returns the outermost JSON value (either an array or an object). - /// - /// Can return NULL if the input does not start with an array or an object. - /// The object is not parsed yet - the caller must iterate over the - /// returned object to trigger parsing. - /// - /// A JSONValue can be either a JSONString, JSONObject or JSONArray. - JSONValue *parseRoot(); - - /// \brief Parses the JSON text and returns whether it is valid JSON. - /// - /// In case validate() return false, failed() will return true and - /// getErrorMessage() will return the parsing error. - bool validate(); - - /// \brief Returns true if an error occurs during parsing. - /// - /// If there was an error while parsing an object that was created by - /// iterating over the result of 'parseRoot', 'failed' will return true. - bool failed() const; - -private: - /// \brief These methods manage the implementation details of parsing new JSON - /// atoms. - /// @{ - JSONString *parseString(); - JSONValue *parseValue(); - JSONKeyValuePair *parseKeyValuePair(); - /// @} - - /// \brief Helpers to parse the elements out of both forms of containers. - /// @{ - const JSONAtom *parseElement(JSONAtom::Kind ContainerKind); - StringRef::iterator parseFirstElement(JSONAtom::Kind ContainerKind, - char StartChar, char EndChar, - const JSONAtom *&Element); - StringRef::iterator parseNextElement(JSONAtom::Kind ContainerKind, - char EndChar, - const JSONAtom *&Element); - /// @} - - /// \brief Whitespace parsing. - /// @{ - void nextNonWhitespace(); - bool isWhitespace(); - /// @} - - /// \brief These methods are used for error handling. - /// { - void setExpectedError(StringRef Expected, StringRef Found); - void setExpectedError(StringRef Expected, char Found); - bool errorIfAtEndOfFile(StringRef Message); - bool errorIfNotAt(char C, StringRef Message); - /// } - - /// \brief Skips all elements in the given container. - bool skipContainer(const JSONContainer &Container); - - /// \brief Skips to the next position behind the given JSON atom. - bool skip(const JSONAtom &Atom); - - /// All nodes are allocated by the parser and will be deallocated when the - /// parser is destroyed. - BumpPtrAllocator ValueAllocator; - - /// \brief The original input to the parser. - MemoryBuffer *InputBuffer; - - /// \brief The source manager used for diagnostics and buffer management. - SourceMgr *SM; - - /// \brief The current position in the parse stream. - StringRef::iterator Position; - - /// \brief The end position for fast EOF checks without introducing - /// unnecessary dereferences. - StringRef::iterator End; - - /// \brief If true, an error has occurred. - bool Failed; - - friend class JSONContainer; -}; - - -/// \brief Base class for JSON value objects. -/// -/// This object represents an abstract JSON value. It is the root node behind -/// the group of JSON entities that can represent top-level values in a JSON -/// document. It has no API, and is just a placeholder in the type hierarchy of -/// nodes. -class JSONValue : public JSONAtom { -protected: - JSONValue(Kind MyKind) : JSONAtom(MyKind) {} - -public: - /// \brief dyn_cast helpers - ///@{ - static bool classof(const JSONAtom *Atom) { - switch (Atom->getKind()) { - case JK_Array: - case JK_Object: - case JK_String: - return true; - case JK_KeyValuePair: - return false; - } - llvm_unreachable("Invalid JSONAtom kind"); - } - static bool classof(const JSONValue *Value) { return true; } - ///@} -}; - -/// \brief Gives access to the text of a JSON string. -/// -/// FIXME: Implement a method to return the unescaped text. -class JSONString : public JSONValue { -public: - /// \brief Returns the underlying parsed text of the string. - /// - /// This is the unescaped content of the JSON text. - /// See http://www.ietf.org/rfc/rfc4627.txt for details. - StringRef getRawText() const { return RawText; } - -private: - JSONString(StringRef RawText) : JSONValue(JK_String), RawText(RawText) {} - - StringRef RawText; - - friend class JSONParser; - -public: - /// \brief dyn_cast helpers - ///@{ - static bool classof(const JSONAtom *Atom) { - return Atom->getKind() == JK_String; - } - static bool classof(const JSONString *String) { return true; } - ///@} -}; - -/// \brief A (key, value) tuple of type (JSONString *, JSONValue *). -/// -/// Note that JSONKeyValuePair is not a JSONValue, it is a bare JSONAtom. -/// JSONKeyValuePairs can be elements of a JSONObject, but not of a JSONArray. -/// They are not viable as top-level values either. -class JSONKeyValuePair : public JSONAtom { -public: - const JSONString * const Key; - const JSONValue * const Value; - -private: - JSONKeyValuePair(const JSONString *Key, const JSONValue *Value) - : JSONAtom(JK_KeyValuePair), Key(Key), Value(Value) {} - - friend class JSONParser; - -public: - /// \brief dyn_cast helpers - ///@{ - static bool classof(const JSONAtom *Atom) { - return Atom->getKind() == JK_KeyValuePair; - } - static bool classof(const JSONKeyValuePair *KeyValuePair) { return true; } - ///@} -}; - -/// \brief Implementation of JSON containers (arrays and objects). -/// -/// JSONContainers drive the lazy parsing of JSON arrays and objects via -/// forward iterators. -class JSONContainer : public JSONValue { -private: - /// \brief An iterator that parses the underlying container during iteration. - /// - /// Iterators on the same collection use shared state, so when multiple copies - /// of an iterator exist, only one is allowed to be used for iteration; - /// iterating multiple copies of an iterator of the same collection will lead - /// to undefined behavior. - class AtomIterator { - public: - AtomIterator(const AtomIterator &I) : Container(I.Container) {} - - /// \brief Iterator interface. - ///@{ - bool operator==(const AtomIterator &I) const { - if (isEnd() || I.isEnd()) - return isEnd() == I.isEnd(); - return Container->Position == I.Container->Position; - } - bool operator!=(const AtomIterator &I) const { - return !(*this == I); - } - AtomIterator &operator++() { - Container->parseNextElement(); - return *this; - } - const JSONAtom *operator*() { - return Container->Current; - } - ///@} - - private: - /// \brief Create an iterator for which 'isEnd' returns true. - AtomIterator() : Container(0) {} - - /// \brief Create an iterator for the given container. - AtomIterator(const JSONContainer *Container) : Container(Container) {} - - bool isEnd() const { - return Container == 0 || Container->Position == StringRef::iterator(); - } - - const JSONContainer * const Container; - - friend class JSONContainer; - }; - -protected: - /// \brief An iterator for the specified AtomT. - /// - /// Used for the implementation of iterators for JSONArray and JSONObject. - template <typename AtomT> - class IteratorTemplate : public std::iterator<std::forward_iterator_tag, - const AtomT*> { - public: - explicit IteratorTemplate(const AtomIterator& AtomI) - : AtomI(AtomI) {} - - bool operator==(const IteratorTemplate &I) const { - return AtomI == I.AtomI; - } - bool operator!=(const IteratorTemplate &I) const { return !(*this == I); } - - IteratorTemplate &operator++() { - ++AtomI; - return *this; - } - - const AtomT *operator*() { return dyn_cast<AtomT>(*AtomI); } - - private: - AtomIterator AtomI; - }; - - JSONContainer(JSONParser *Parser, char StartChar, char EndChar, - JSONAtom::Kind ContainerKind) - : JSONValue(ContainerKind), Parser(Parser), - Position(), Current(0), Started(false), - StartChar(StartChar), EndChar(EndChar) {} - - /// \brief Returns a lazy parsing iterator over the container. - /// - /// As the iterator drives the parse stream, begin() must only be called - /// once per container. - AtomIterator atom_begin() const { - if (Started) - report_fatal_error("Cannot parse container twice."); - Started = true; - // Set up the position and current element when we begin iterating over the - // container. - Position = Parser->parseFirstElement(getKind(), StartChar, EndChar, Current); - return AtomIterator(this); - } - AtomIterator atom_end() const { - return AtomIterator(); - } - -private: - AtomIterator atom_current() const { - if (!Started) - return atom_begin(); - - return AtomIterator(this); - } - - /// \brief Parse the next element in the container into the Current element. - /// - /// This routine is called as an iterator into this container walks through - /// its elements. It mutates the container's internal current node to point to - /// the next atom of the container. - void parseNextElement() const { - Parser->skip(*Current); - Position = Parser->parseNextElement(getKind(), EndChar, Current); - } - - // For parsing, JSONContainers call back into the JSONParser. - JSONParser * const Parser; - - // 'Position', 'Current' and 'Started' store the state of the parse stream - // for iterators on the container, they don't change the container's elements - // and are thus marked as mutable. - mutable StringRef::iterator Position; - mutable const JSONAtom *Current; - mutable bool Started; - - const char StartChar; - const char EndChar; - - friend class JSONParser; - -public: - /// \brief dyn_cast helpers - ///@{ - static bool classof(const JSONAtom *Atom) { - switch (Atom->getKind()) { - case JK_Array: - case JK_Object: - return true; - case JK_KeyValuePair: - case JK_String: - return false; - } - llvm_unreachable("Invalid JSONAtom kind"); - } - static bool classof(const JSONContainer *Container) { return true; } - ///@} -}; - -/// \brief A simple JSON array. -class JSONArray : public JSONContainer { -public: - typedef IteratorTemplate<JSONValue> const_iterator; - - /// \brief Returns a lazy parsing iterator over the container. - /// - /// As the iterator drives the parse stream, begin() must only be called - /// once per container. - const_iterator begin() const { return const_iterator(atom_begin()); } - const_iterator end() const { return const_iterator(atom_end()); } - -private: - JSONArray(JSONParser *Parser) - : JSONContainer(Parser, '[', ']', JSONAtom::JK_Array) {} - -public: - /// \brief dyn_cast helpers - ///@{ - static bool classof(const JSONAtom *Atom) { - return Atom->getKind() == JSONAtom::JK_Array; - } - static bool classof(const JSONArray *Array) { return true; } - ///@} - - friend class JSONParser; -}; - -/// \brief A JSON object: an iterable list of JSON key-value pairs. -class JSONObject : public JSONContainer { -public: - typedef IteratorTemplate<JSONKeyValuePair> const_iterator; - - /// \brief Returns a lazy parsing iterator over the container. - /// - /// As the iterator drives the parse stream, begin() must only be called - /// once per container. - const_iterator begin() const { return const_iterator(atom_begin()); } - const_iterator end() const { return const_iterator(atom_end()); } - -private: - JSONObject(JSONParser *Parser) - : JSONContainer(Parser, '{', '}', JSONAtom::JK_Object) {} - -public: - /// \brief dyn_cast helpers - ///@{ - static bool classof(const JSONAtom *Atom) { - return Atom->getKind() == JSONAtom::JK_Object; - } - static bool classof(const JSONObject *Object) { return true; } - ///@} - - friend class JSONParser; -}; - -} // end namespace llvm - -#endif // LLVM_SUPPORT_JSON_PARSER_H diff --git a/include/llvm/Support/Locale.h b/include/llvm/Support/Locale.h new file mode 100644 index 0000000..b0f1295 --- /dev/null +++ b/include/llvm/Support/Locale.h @@ -0,0 +1,17 @@ +#ifndef LLVM_SUPPORT_LOCALE +#define LLVM_SUPPORT_LOCALE + +#include "llvm/ADT/StringRef.h" + +namespace llvm { +namespace sys { +namespace locale { + +int columnWidth(StringRef s); +bool isPrint(int c); + +} +} +} + +#endif // LLVM_SUPPORT_LOCALE diff --git a/include/llvm/Support/MDBuilder.h b/include/llvm/Support/MDBuilder.h new file mode 100644 index 0000000..40f028a --- /dev/null +++ b/include/llvm/Support/MDBuilder.h @@ -0,0 +1,118 @@ +//===---- llvm/Support/MDBuilder.h - Builder for LLVM metadata --*- 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 MDBuilder class, which is used as a convenient way to +// create LLVM metadata with a consistent and simplified interface. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_SUPPORT_MDBUILDER_H +#define LLVM_SUPPORT_MDBUILDER_H + +#include "llvm/Constants.h" +#include "llvm/DerivedTypes.h" +#include "llvm/LLVMContext.h" +#include "llvm/Metadata.h" +#include "llvm/ADT/APInt.h" + +namespace llvm { + + class MDBuilder { + LLVMContext &Context; + + public: + MDBuilder(LLVMContext &context) : Context(context) {} + + /// \brief Return the given string as metadata. + MDString *createString(StringRef Str) { + return MDString::get(Context, Str); + } + + //===------------------------------------------------------------------===// + // FPMath metadata. + //===------------------------------------------------------------------===// + + /// \brief Return metadata with the given settings. The special value 0.0 + /// for the Accuracy parameter indicates the default (maximal precision) + /// setting. + MDNode *createFPMath(float Accuracy) { + if (Accuracy == 0.0) + return 0; + assert(Accuracy > 0.0 && "Invalid fpmath accuracy!"); + Value *Op = ConstantFP::get(Type::getFloatTy(Context), Accuracy); + return MDNode::get(Context, Op); + } + + + //===------------------------------------------------------------------===// + // Range metadata. + //===------------------------------------------------------------------===// + + /// \brief Return metadata describing the range [Lo, Hi). + MDNode *createRange(const APInt &Lo, const APInt &Hi) { + assert(Lo.getBitWidth() == Hi.getBitWidth() && "Mismatched bitwidths!"); + // If the range is everything then it is useless. + if (Hi == Lo) + return 0; + + // Return the range [Lo, Hi). + Type *Ty = IntegerType::get(Context, Lo.getBitWidth()); + Value *Range[2] = { ConstantInt::get(Ty, Lo), ConstantInt::get(Ty, Hi) }; + return MDNode::get(Context, Range); + } + + + //===------------------------------------------------------------------===// + // TBAA metadata. + //===------------------------------------------------------------------===// + + /// \brief Return metadata appropriate for a TBAA root node. Each returned + /// node is distinct from all other metadata and will never be identified + /// (uniqued) with anything else. + MDNode *createAnonymousTBAARoot() { + // To ensure uniqueness the root node is self-referential. + MDNode *Dummy = MDNode::getTemporary(Context, ArrayRef<Value*>()); + MDNode *Root = MDNode::get(Context, Dummy); + // At this point we have + // !0 = metadata !{} <- dummy + // !1 = metadata !{metadata !0} <- root + // Replace the dummy operand with the root node itself and delete the dummy. + Root->replaceOperandWith(0, Root); + MDNode::deleteTemporary(Dummy); + // We now have + // !1 = metadata !{metadata !1} <- self-referential root + return Root; + } + + /// \brief Return metadata appropriate for a TBAA root node with the given + /// name. This may be identified (uniqued) with other roots with the same + /// name. + MDNode *createTBAARoot(StringRef Name) { + return MDNode::get(Context, createString(Name)); + } + + /// \brief Return metadata for a non-root TBAA node with the given name, + /// parent in the TBAA tree, and value for 'pointsToConstantMemory'. + MDNode *createTBAANode(StringRef Name, MDNode *Parent, + bool isConstant = false) { + if (isConstant) { + Constant *Flags = ConstantInt::get(Type::getInt64Ty(Context), 1); + Value *Ops[3] = { createString(Name), Parent, Flags }; + return MDNode::get(Context, Ops); + } else { + Value *Ops[2] = { createString(Name), Parent }; + return MDNode::get(Context, Ops); + } + } + + }; + +} // end namespace llvm + +#endif diff --git a/include/llvm/Support/Process.h b/include/llvm/Support/Process.h index 3379922..d796b79 100644 --- a/include/llvm/Support/Process.h +++ b/include/llvm/Support/Process.h @@ -136,6 +136,10 @@ namespace sys { /// Same as OutputColor, but only enables the bold attribute. static const char *OutputBold(bool bg); + /// This function returns the escape sequence to reverse forground and + /// background colors. + static const char *OutputReverse(); + /// Resets the terminals colors, or returns an escape sequence to do so. static const char *ResetColor(); /// @} diff --git a/include/llvm/Support/SourceMgr.h b/include/llvm/Support/SourceMgr.h index 58b8fab..76967db 100644 --- a/include/llvm/Support/SourceMgr.h +++ b/include/llvm/Support/SourceMgr.h @@ -128,8 +128,11 @@ public: /// PrintMessage - Emit a message about the specified location with the /// specified string. /// + /// @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, - ArrayRef<SMRange> Ranges = ArrayRef<SMRange>()) const; + ArrayRef<SMRange> Ranges = ArrayRef<SMRange>(), + bool ShowColors = true) const; /// GetMessage - Return an SMDiagnostic at the specified location with the @@ -188,7 +191,7 @@ public: const std::vector<std::pair<unsigned, unsigned> > &getRanges() const { return Ranges; } - void print(const char *ProgName, raw_ostream &S) const; + void print(const char *ProgName, raw_ostream &S, bool ShowColors = true) const; }; } // end llvm namespace diff --git a/include/llvm/Support/YAMLParser.h b/include/llvm/Support/YAMLParser.h index b24cacd..47206b3 100644 --- a/include/llvm/Support/YAMLParser.h +++ b/include/llvm/Support/YAMLParser.h @@ -516,8 +516,11 @@ public: document_iterator() : Doc(NullDoc) {} document_iterator(OwningPtr<Document> &D) : Doc(D) {} + bool operator ==(const document_iterator &Other) { + return Doc == Other.Doc; + } bool operator !=(const document_iterator &Other) { - return Doc != Other.Doc; + return !(*this == Other); } document_iterator operator ++() { diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h index 6bfae5e..6c5d478 100644 --- a/include/llvm/Support/raw_ostream.h +++ b/include/llvm/Support/raw_ostream.h @@ -222,6 +222,9 @@ public: /// outputting colored text, or before program exit. virtual raw_ostream &resetColor() { return *this; } + /// Reverses the forground and background colors. + virtual raw_ostream &reverseColor() { return *this; } + /// This function determines if this stream is connected to a "tty" or /// "console" window. That is, the output would be displayed to the user /// rather than being put on a pipe or stored in a file. @@ -379,6 +382,8 @@ public: bool bg=false); virtual raw_ostream &resetColor(); + virtual raw_ostream &reverseColor(); + virtual bool is_displayed() const; /// has_error - Return the value of the flag in this raw_fd_ostream indicating diff --git a/include/llvm/TableGen/Error.h b/include/llvm/TableGen/Error.h index c01b32b..fd5f805 100644 --- a/include/llvm/TableGen/Error.h +++ b/include/llvm/TableGen/Error.h @@ -29,6 +29,11 @@ public: const std::string &getMessage() const { return Message; } }; +void PrintWarning(SMLoc WarningLoc, const Twine &Msg); +void PrintWarning(const char *Loc, const Twine &Msg); +void PrintWarning(const Twine &Msg); +void PrintWarning(const TGError &Warning); + void PrintError(SMLoc ErrorLoc, const Twine &Msg); void PrintError(const char *Loc, const Twine &Msg); void PrintError(const Twine &Msg); diff --git a/include/llvm/TableGen/Record.h b/include/llvm/TableGen/Record.h index 5e68c10..3aea1ae 100644 --- a/include/llvm/TableGen/Record.h +++ b/include/llvm/TableGen/Record.h @@ -454,7 +454,7 @@ public: /// without adding quote markers. This primaruly affects /// StringInits where we will not surround the string value with /// quotes. - virtual std::string getAsUnquotedString() const { return getAsString(); } + virtual std::string getAsUnquotedString() const { return getAsString(); } /// dump - Debugging method that may be called through a debugger, just /// invokes print on stderr. @@ -1529,7 +1529,7 @@ struct MultiClass { void dump() const; - MultiClass(const std::string &Name, SMLoc Loc, RecordKeeper &Records) : + MultiClass(const std::string &Name, SMLoc Loc, RecordKeeper &Records) : Rec(Name, Loc, Records) {} }; diff --git a/include/llvm/Target/TargetLibraryInfo.h b/include/llvm/Target/TargetLibraryInfo.h index 70e26bf..c8cacf2 100644 --- a/include/llvm/Target/TargetLibraryInfo.h +++ b/include/llvm/Target/TargetLibraryInfo.h @@ -83,7 +83,7 @@ namespace llvm { /// long double expm1l(long double x); expm1l, /// float expm1f(float x); - expl1f, + expm1f, /// double fabs(double x); fabs, /// long double fabsl(long double x); @@ -159,8 +159,14 @@ namespace llvm { rint, /// float rintf(float x); rintf, - /// long dobule rintl(long double x); + /// long double rintl(long double x); rintl, + /// double round(double x); + round, + /// float roundf(float x); + roundf, + /// long double roundl(long double x); + roundl, /// double sin(double x); sin, /// long double sinl(long double x); diff --git a/include/llvm/Target/TargetRegisterInfo.h b/include/llvm/Target/TargetRegisterInfo.h index 7d8a46b..6ddd364 100644 --- a/include/llvm/Target/TargetRegisterInfo.h +++ b/include/llvm/Target/TargetRegisterInfo.h @@ -205,7 +205,7 @@ struct TargetRegisterInfoDesc { /// Each TargetRegisterClass has a per register weight, and weight /// limit which must be less than the limits of its pressure sets. struct RegClassWeight { - unsigned RegWeigt; + unsigned RegWeight; unsigned WeightLimit; }; diff --git a/include/llvm/Transforms/Utils/BasicBlockUtils.h b/include/llvm/Transforms/Utils/BasicBlockUtils.h index 867b9e4..2f9dc54 100644 --- a/include/llvm/Transforms/Utils/BasicBlockUtils.h +++ b/include/llvm/Transforms/Utils/BasicBlockUtils.h @@ -110,7 +110,8 @@ bool isCriticalEdge(const TerminatorInst *TI, unsigned SuccNum, /// BasicBlock *SplitCriticalEdge(TerminatorInst *TI, unsigned SuccNum, Pass *P = 0, bool MergeIdenticalEdges = false, - bool DontDeleteUselessPHIs = false); + bool DontDeleteUselessPHIs = false, + bool SplitLandingPads = false); inline BasicBlock *SplitCriticalEdge(BasicBlock *BB, succ_iterator SI, Pass *P = 0) { diff --git a/include/llvm/Transforms/Vectorize.h b/include/llvm/Transforms/Vectorize.h index 7701ceb..652916c 100644 --- a/include/llvm/Transforms/Vectorize.h +++ b/include/llvm/Transforms/Vectorize.h @@ -34,6 +34,9 @@ struct VectorizeConfig { /// @brief Vectorize floating-point values. bool VectorizeFloats; + /// @brief Vectorize pointer values. + bool VectorizePointers; + /// @brief Vectorize casting (conversion) operations. bool VectorizeCasts; @@ -43,6 +46,12 @@ struct VectorizeConfig { /// @brief Vectorize the fused-multiply-add intrinsic. bool VectorizeFMA; + /// @brief Vectorize select instructions. + bool VectorizeSelect; + + /// @brief Vectorize getelementptr instructions. + bool VectorizeGEP; + /// @brief Vectorize loads and stores. bool VectorizeMemOps; |