#ifndef LLVM_CODEGEN_SLOTINDEXES_H
#define LLVM_CODEGEN_SLOTINDEXES_H
-#include "llvm/ADT/PointerIntPair.h"
-#include "llvm/ADT/SmallVector.h"
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
-#include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/DenseMap.h"
#include "llvm/Support/Allocator.h"
-#include "llvm/Support/ErrorHandling.h"
namespace llvm {
/// SlotIndex & SlotIndexes classes for the public interface to this
/// information.
class IndexListEntry {
- private:
-
static const unsigned EMPTY_KEY_INDEX = ~0U & ~3U,
TOMBSTONE_KEY_INDEX = ~0U & ~7U;
public:
IndexListEntry(MachineInstr *mi, unsigned index) : mi(mi), index(index) {
- if (index == EMPTY_KEY_INDEX || index == TOMBSTONE_KEY_INDEX) {
- llvm_report_error("Attempt to create invalid index. "
- "Available indexes may have been exhausted?.");
- }
+ assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX &&
+ "Attempt to create invalid index. "
+ "Available indexes may have been exhausted?.");
+ }
+
+ bool isValid() const {
+ return (index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX);
}
MachineInstr* getInstr() const { return mi; }
void setInstr(MachineInstr *mi) {
- assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX &&
- "Attempt to modify reserved index.");
+ assert(isValid() && "Attempt to modify reserved index.");
this->mi = mi;
}
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.");
+ assert(isValid() && "Attempt to reset reserved index value.");
this->index = index;
}
IndexListEntry* getNext() { return next; }
const IndexListEntry* getNext() const { return next; }
void setNext(IndexListEntry *next) {
- assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX &&
- "Attempt to modify reserved index.");
+ assert(isValid() && "Attempt to modify reserved index.");
this->next = next;
}
IndexListEntry* getPrev() { return prev; }
const IndexListEntry* getPrev() const { return prev; }
void setPrev(IndexListEntry *prev) {
- assert(index != EMPTY_KEY_INDEX && index != TOMBSTONE_KEY_INDEX &&
- "Attempt to modify reserved index.");
+ assert(isValid() && "Attempt to modify reserved index.");
this->prev = prev;
}
// Construct a new slot index from the given one, set the phi flag on the
// new index to the value of the phi parameter.
SlotIndex(const SlotIndex &li, bool phi)
- : lie(&li.entry(), phi ? PHI_BIT & li.getSlot() : (unsigned)li.getSlot()){
+ : lie(&li.entry(), phi ? PHI_BIT | li.getSlot() : (unsigned)li.getSlot()){
assert(lie.getPointer() != 0 &&
"Attempt to construct index with 0 pointer.");
}
// Construct a new slot index from the given one, set the phi flag on the
// new index to the value of the phi parameter, and the slot to the new slot.
SlotIndex(const SlotIndex &li, bool phi, Slot s)
- : lie(&li.entry(), phi ? PHI_BIT & s : (unsigned)s) {
+ : lie(&li.entry(), phi ? PHI_BIT | s : (unsigned)s) {
assert(lie.getPointer() != 0 &&
"Attempt to construct index with 0 pointer.");
}
/// Returns true if this is a valid index. Invalid indicies do
/// not point into an index table, and cannot be compared.
bool isValid() const {
- return (lie.getPointer() != 0) && (lie.getPointer()->getIndex() != 0);
+ IndexListEntry *entry = lie.getPointer();
+ return ((entry!= 0) && (entry->isValid()));
}
/// Print this index to the given raw_ostream.
};
/// DenseMapInfo specialization for SlotIndex.
- /// TODO: Not a POD?
template <>
struct DenseMapInfo<SlotIndex> {
static inline SlotIndex getEmptyKey() {
return (LHS == RHS);
}
};
+
+ template <> struct isPodLike<SlotIndex> { static const bool value = true; };
+
inline raw_ostream& operator<<(raw_ostream &os, SlotIndex li) {
li.print(os);
(I == idx2MBBMap.end() && idx2MBBMap.size()>0)) ? (I-1): I;
assert(J != idx2MBBMap.end() && J->first <= index &&
- index <= getMBBEndIdx(J->second) &&
+ index < getMBBEndIdx(J->second) &&
"index does not correspond to an MBB");
return J->second;
}