mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-21 01:25:20 +00:00
Remove a dead field, make the map go to integer type ID to hash better and
avoid a getType. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18691 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
31127e1d89
commit
389bd04b96
@ -35,14 +35,11 @@ namespace {
|
|||||||
/// @brief A class for maintaining the slot number definition
|
/// @brief A class for maintaining the slot number definition
|
||||||
/// as a placeholder for the actual definition for forward constants defs.
|
/// as a placeholder for the actual definition for forward constants defs.
|
||||||
class ConstantPlaceHolder : public ConstantExpr {
|
class ConstantPlaceHolder : public ConstantExpr {
|
||||||
unsigned ID;
|
|
||||||
ConstantPlaceHolder(); // DO NOT IMPLEMENT
|
ConstantPlaceHolder(); // DO NOT IMPLEMENT
|
||||||
void operator=(const ConstantPlaceHolder &); // DO NOT IMPLEMENT
|
void operator=(const ConstantPlaceHolder &); // DO NOT IMPLEMENT
|
||||||
public:
|
public:
|
||||||
ConstantPlaceHolder(const Type *Ty, unsigned id)
|
ConstantPlaceHolder(const Type *Ty)
|
||||||
: ConstantExpr(Instruction::UserOp1, Constant::getNullValue(Ty), Ty),
|
: ConstantExpr(Instruction::UserOp1, Constant::getNullValue(Ty), Ty) {}
|
||||||
ID(id) {}
|
|
||||||
unsigned getID() { return ID; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -494,8 +491,7 @@ Constant* BytecodeReader::getConstantValue(unsigned TypeSlot, unsigned Slot) {
|
|||||||
error("Value for slot " + utostr(Slot) +
|
error("Value for slot " + utostr(Slot) +
|
||||||
" is expected to be a constant!");
|
" is expected to be a constant!");
|
||||||
|
|
||||||
const Type *Ty = getType(TypeSlot);
|
std::pair<unsigned, unsigned> Key(TypeSlot, Slot);
|
||||||
std::pair<const Type*, unsigned> Key(Ty, Slot);
|
|
||||||
ConstantRefsType::iterator I = ConstantFwdRefs.lower_bound(Key);
|
ConstantRefsType::iterator I = ConstantFwdRefs.lower_bound(Key);
|
||||||
|
|
||||||
if (I != ConstantFwdRefs.end() && I->first == Key) {
|
if (I != ConstantFwdRefs.end() && I->first == Key) {
|
||||||
@ -503,7 +499,7 @@ Constant* BytecodeReader::getConstantValue(unsigned TypeSlot, unsigned Slot) {
|
|||||||
} else {
|
} else {
|
||||||
// Create a placeholder for the constant reference and
|
// Create a placeholder for the constant reference and
|
||||||
// keep track of the fact that we have a forward ref to recycle it
|
// keep track of the fact that we have a forward ref to recycle it
|
||||||
Constant *C = new ConstantPlaceHolder(Ty, Slot);
|
Constant *C = new ConstantPlaceHolder(getType(TypeSlot));
|
||||||
|
|
||||||
// Keep track of the fact that we have a forward ref to recycle it
|
// Keep track of the fact that we have a forward ref to recycle it
|
||||||
ConstantFwdRefs.insert(I, std::make_pair(Key, C));
|
ConstantFwdRefs.insert(I, std::make_pair(Key, C));
|
||||||
@ -1477,9 +1473,10 @@ Constant *BytecodeReader::ParseConstantValue(unsigned TypeID) {
|
|||||||
/// referenced constants in the ConstantFwdRefs map. It uses the
|
/// referenced constants in the ConstantFwdRefs map. It uses the
|
||||||
/// replaceAllUsesWith method of Value class to substitute the placeholder
|
/// replaceAllUsesWith method of Value class to substitute the placeholder
|
||||||
/// instance with the actual instance.
|
/// instance with the actual instance.
|
||||||
void BytecodeReader::ResolveReferencesToConstant(Constant *NewV, unsigned Slot){
|
void BytecodeReader::ResolveReferencesToConstant(Constant *NewV, unsigned Typ,
|
||||||
|
unsigned Slot) {
|
||||||
ConstantRefsType::iterator I =
|
ConstantRefsType::iterator I =
|
||||||
ConstantFwdRefs.find(std::make_pair(NewV->getType(), Slot));
|
ConstantFwdRefs.find(std::make_pair(Typ, Slot));
|
||||||
if (I == ConstantFwdRefs.end()) return; // Never forward referenced?
|
if (I == ConstantFwdRefs.end()) return; // Never forward referenced?
|
||||||
|
|
||||||
Value *PH = I->second; // Get the placeholder...
|
Value *PH = I->second; // Get the placeholder...
|
||||||
@ -1518,7 +1515,7 @@ void BytecodeReader::ParseStringConstants(unsigned NumEntries, ValueTable &Tab){
|
|||||||
// Create the constant, inserting it as needed.
|
// Create the constant, inserting it as needed.
|
||||||
Constant *C = ConstantArray::get(ATy, Elements);
|
Constant *C = ConstantArray::get(ATy, Elements);
|
||||||
unsigned Slot = insertValue(C, Typ, Tab);
|
unsigned Slot = insertValue(C, Typ, Tab);
|
||||||
ResolveReferencesToConstant(C, Slot);
|
ResolveReferencesToConstant(C, Typ, Slot);
|
||||||
if (Handler) Handler->handleConstantString(cast<ConstantArray>(C));
|
if (Handler) Handler->handleConstantString(cast<ConstantArray>(C));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1564,7 +1561,7 @@ void BytecodeReader::ParseConstantPool(ValueTable &Tab,
|
|||||||
if (&Tab != &ModuleValues && Typ < ModuleValues.size() &&
|
if (&Tab != &ModuleValues && Typ < ModuleValues.size() &&
|
||||||
ModuleValues[Typ])
|
ModuleValues[Typ])
|
||||||
Slot += ModuleValues[Typ]->size();
|
Slot += ModuleValues[Typ]->size();
|
||||||
ResolveReferencesToConstant(C, Slot);
|
ResolveReferencesToConstant(C, Typ, Slot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1572,14 +1569,12 @@ void BytecodeReader::ParseConstantPool(ValueTable &Tab,
|
|||||||
// After we have finished parsing the constant pool, we had better not have
|
// After we have finished parsing the constant pool, we had better not have
|
||||||
// any dangling references left.
|
// any dangling references left.
|
||||||
if (!ConstantFwdRefs.empty()) {
|
if (!ConstantFwdRefs.empty()) {
|
||||||
typedef std::map<std::pair<const Type*,unsigned>, Constant*> ConstantRefsType;
|
|
||||||
ConstantRefsType::const_iterator I = ConstantFwdRefs.begin();
|
ConstantRefsType::const_iterator I = ConstantFwdRefs.begin();
|
||||||
const Type* missingType = I->first.first;
|
|
||||||
Constant* missingConst = I->second;
|
Constant* missingConst = I->second;
|
||||||
error(utostr(ConstantFwdRefs.size()) +
|
error(utostr(ConstantFwdRefs.size()) +
|
||||||
" unresolved constant reference exist. First one is '" +
|
" unresolved constant reference exist. First one is '" +
|
||||||
missingConst->getName() + "' of type '" +
|
missingConst->getName() + "' of type '" +
|
||||||
missingType->getDescription() + "'.");
|
missingConst->getType()->getDescription() + "'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
checkPastBlockEnd("Constant Pool");
|
checkPastBlockEnd("Constant Pool");
|
||||||
|
@ -102,7 +102,7 @@ public:
|
|||||||
/// This map is needed so that forward references to constants can be looked
|
/// This map is needed so that forward references to constants can be looked
|
||||||
/// up by Type and slot number when resolving those references.
|
/// up by Type and slot number when resolving those references.
|
||||||
/// @brief A mapping of a Type/slot pair to a Constant*.
|
/// @brief A mapping of a Type/slot pair to a Constant*.
|
||||||
typedef std::map<std::pair<const Type*,unsigned>, Constant*> ConstantRefsType;
|
typedef std::map<std::pair<unsigned,unsigned>, Constant*> ConstantRefsType;
|
||||||
|
|
||||||
/// For lazy read-in of functions, we need to save the location in the
|
/// For lazy read-in of functions, we need to save the location in the
|
||||||
/// data stream where the function is located. This structure provides that
|
/// data stream where the function is located. This structure provides that
|
||||||
@ -453,7 +453,7 @@ private:
|
|||||||
|
|
||||||
/// @brief Resolve all references to the placeholder (if any) for the
|
/// @brief Resolve all references to the placeholder (if any) for the
|
||||||
/// given constant.
|
/// given constant.
|
||||||
void ResolveReferencesToConstant(Constant *C, unsigned Slot);
|
void ResolveReferencesToConstant(Constant *C, unsigned Typ, unsigned Slot);
|
||||||
|
|
||||||
/// @brief Release our memory.
|
/// @brief Release our memory.
|
||||||
void freeState() {
|
void freeState() {
|
||||||
|
Loading…
Reference in New Issue
Block a user