mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-10 02:36:06 +00:00
Update some globals to use ManagedStatic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86342 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
bdea34807a
commit
d6ef7fac1a
@ -29,9 +29,13 @@
|
|||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
#include "llvm/Support/Allocator.h"
|
#include "llvm/Support/Allocator.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
|
#include "llvm/Support/ManagedStatic.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
|
||||||
|
class EmptyIndexListEntry;
|
||||||
|
class TombstoneIndexListEntry;
|
||||||
|
|
||||||
/// This class represents an entry in the slot index list held in the
|
/// This class represents an entry in the slot index list held in the
|
||||||
/// SlotIndexes pass. It should not be used directly. See the
|
/// SlotIndexes pass. It should not be used directly. See the
|
||||||
/// SlotIndex & SlotIndexes classes for the public interface to this
|
/// SlotIndex & SlotIndexes classes for the public interface to this
|
||||||
@ -39,16 +43,22 @@ namespace llvm {
|
|||||||
class IndexListEntry {
|
class IndexListEntry {
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static std::auto_ptr<IndexListEntry> emptyKeyEntry,
|
|
||||||
tombstoneKeyEntry;
|
|
||||||
typedef enum { EMPTY_KEY, TOMBSTONE_KEY } ReservedEntryType;
|
|
||||||
static const unsigned EMPTY_KEY_INDEX = ~0U & ~3U,
|
static const unsigned EMPTY_KEY_INDEX = ~0U & ~3U,
|
||||||
TOMBSTONE_KEY_INDEX = ~0U & ~7U;
|
TOMBSTONE_KEY_INDEX = ~0U & ~7U;
|
||||||
|
|
||||||
|
// The following statics are thread safe. They're read only, and you
|
||||||
|
// can't step from them to any other list entries.
|
||||||
|
static ManagedStatic<EmptyIndexListEntry> emptyKeyEntry;
|
||||||
|
static ManagedStatic<TombstoneIndexListEntry> tombstoneKeyEntry;
|
||||||
|
|
||||||
IndexListEntry *next, *prev;
|
IndexListEntry *next, *prev;
|
||||||
MachineInstr *mi;
|
MachineInstr *mi;
|
||||||
unsigned index;
|
unsigned index;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
typedef enum { EMPTY_KEY, TOMBSTONE_KEY } ReservedEntryType;
|
||||||
|
|
||||||
// This constructor is only to be used by getEmptyKeyEntry
|
// This constructor is only to be used by getEmptyKeyEntry
|
||||||
// & getTombstoneKeyEntry. It sets index to the given
|
// & getTombstoneKeyEntry. It sets index to the given
|
||||||
// value and mi to zero.
|
// value and mi to zero.
|
||||||
@ -58,6 +68,8 @@ namespace llvm {
|
|||||||
case TOMBSTONE_KEY: index = TOMBSTONE_KEY_INDEX; break;
|
case TOMBSTONE_KEY: index = TOMBSTONE_KEY_INDEX; break;
|
||||||
default: assert(false && "Invalid value for constructor.");
|
default: assert(false && "Invalid value for constructor.");
|
||||||
}
|
}
|
||||||
|
next = this;
|
||||||
|
prev = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -70,38 +82,65 @@ namespace llvm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MachineInstr* getInstr() const { return mi; }
|
MachineInstr* getInstr() const { return mi; }
|
||||||
void setInstr(MachineInstr *mi) { this->mi = mi; }
|
void setInstr(MachineInstr *mi) {
|
||||||
|
assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX &&
|
||||||
|
"Attempt to modify reserved index.");
|
||||||
|
this->mi = mi;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned getIndex() const { return index; }
|
unsigned getIndex() const { return index; }
|
||||||
void setIndex(unsigned index) { this->index = index; }
|
void setIndex(unsigned index) {
|
||||||
|
assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX &&
|
||||||
|
"Attempt to set index to invalid value.");
|
||||||
|
assert(this->index != EMPTY_KEY_INDEX &&
|
||||||
|
this->index != TOMBSTONE_KEY_INDEX &&
|
||||||
|
"Attempt to reset reserved index value.");
|
||||||
|
this->index = index;
|
||||||
|
}
|
||||||
|
|
||||||
IndexListEntry* getNext() { return next; }
|
IndexListEntry* getNext() { return next; }
|
||||||
const IndexListEntry* getNext() const { return next; }
|
const IndexListEntry* getNext() const { return next; }
|
||||||
void setNext(IndexListEntry *next) { this->next = next; }
|
void setNext(IndexListEntry *next) {
|
||||||
|
assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX &&
|
||||||
|
"Attempt to modify reserved index.");
|
||||||
|
this->next = next;
|
||||||
|
}
|
||||||
|
|
||||||
IndexListEntry* getPrev() { return prev; }
|
IndexListEntry* getPrev() { return prev; }
|
||||||
const IndexListEntry* getPrev() const { return prev; }
|
const IndexListEntry* getPrev() const { return prev; }
|
||||||
void setPrev(IndexListEntry *prev) { this->prev = prev; }
|
void setPrev(IndexListEntry *prev) {
|
||||||
|
assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX &&
|
||||||
|
"Attempt to modify reserved index.");
|
||||||
|
this->prev = prev;
|
||||||
|
}
|
||||||
|
|
||||||
// This function returns the index list entry that is to be used for empty
|
// This function returns the index list entry that is to be used for empty
|
||||||
// SlotIndex keys.
|
// SlotIndex keys.
|
||||||
static IndexListEntry* getEmptyKeyEntry() {
|
inline static IndexListEntry* getEmptyKeyEntry();
|
||||||
if (emptyKeyEntry.get() == 0) {
|
|
||||||
emptyKeyEntry.reset(new IndexListEntry(EMPTY_KEY));
|
|
||||||
}
|
|
||||||
return emptyKeyEntry.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
// This function returns the index list entry that is to be used for
|
// This function returns the index list entry that is to be used for
|
||||||
// tombstone SlotIndex keys.
|
// tombstone SlotIndex keys.
|
||||||
static IndexListEntry* getTombstoneKeyEntry() {
|
inline static IndexListEntry* getTombstoneKeyEntry();
|
||||||
if (tombstoneKeyEntry.get() == 0) {
|
|
||||||
tombstoneKeyEntry.reset(new IndexListEntry(TOMBSTONE_KEY));
|
|
||||||
}
|
|
||||||
return tombstoneKeyEntry.get();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class EmptyIndexListEntry : public IndexListEntry {
|
||||||
|
public:
|
||||||
|
EmptyIndexListEntry() : IndexListEntry(EMPTY_KEY) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
class TombstoneIndexListEntry : public IndexListEntry {
|
||||||
|
public:
|
||||||
|
TombstoneIndexListEntry() : IndexListEntry(TOMBSTONE_KEY) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline IndexListEntry* IndexListEntry::getEmptyKeyEntry() {
|
||||||
|
return &*emptyKeyEntry;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline IndexListEntry* IndexListEntry::getTombstoneKeyEntry() {
|
||||||
|
return &*tombstoneKeyEntry;
|
||||||
|
}
|
||||||
|
|
||||||
// Specialize PointerLikeTypeTraits for IndexListEntry.
|
// Specialize PointerLikeTypeTraits for IndexListEntry.
|
||||||
template <>
|
template <>
|
||||||
class PointerLikeTypeTraits<IndexListEntry*> {
|
class PointerLikeTypeTraits<IndexListEntry*> {
|
||||||
|
@ -16,8 +16,10 @@
|
|||||||
|
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
std::auto_ptr<IndexListEntry> IndexListEntry::emptyKeyEntry,
|
|
||||||
IndexListEntry::tombstoneKeyEntry;
|
// Yep - these are thread safe. See the header for details.
|
||||||
|
ManagedStatic<EmptyIndexListEntry> IndexListEntry::emptyKeyEntry;
|
||||||
|
ManagedStatic<TombstoneIndexListEntry> IndexListEntry::tombstoneKeyEntry;
|
||||||
|
|
||||||
char SlotIndexes::ID = 0;
|
char SlotIndexes::ID = 0;
|
||||||
static RegisterPass<SlotIndexes> X("slotindexes", "Slot index numbering");
|
static RegisterPass<SlotIndexes> X("slotindexes", "Slot index numbering");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user