mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-11-01 15:17:25 +00:00
Minor speedup to do less linear time searches of information we already have.
speeds up disassembly of kc++ by .6s git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10079 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -168,13 +168,11 @@ Constant *BytecodeParser::parseConstantValue(const unsigned char *&Buf,
|
|||||||
unsigned ArgValSlot, ArgTypeSlot;
|
unsigned ArgValSlot, ArgTypeSlot;
|
||||||
if (read_vbr(Buf, EndBuf, ArgValSlot)) throw Error_readvbr;
|
if (read_vbr(Buf, EndBuf, ArgValSlot)) throw Error_readvbr;
|
||||||
if (read_vbr(Buf, EndBuf, ArgTypeSlot)) throw Error_readvbr;
|
if (read_vbr(Buf, EndBuf, ArgTypeSlot)) throw Error_readvbr;
|
||||||
const Type *ArgTy = getType(ArgTypeSlot);
|
BCR_TRACE(4, "CE Arg " << i << ": Type: '" << *getType(ArgTypeSlot)
|
||||||
|
<< "' slot: " << ArgValSlot << "\n");
|
||||||
BCR_TRACE(4, "CE Arg " << i << ": Type: '" << *ArgTy << "' slot: "
|
|
||||||
<< ArgValSlot << "\n");
|
|
||||||
|
|
||||||
// Get the arg value from its slot if it exists, otherwise a placeholder
|
// Get the arg value from its slot if it exists, otherwise a placeholder
|
||||||
ArgVec.push_back(getConstantValue(ArgTy, ArgValSlot));
|
ArgVec.push_back(getConstantValue(ArgTypeSlot, ArgValSlot));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct a ConstantExpr of the appropriate kind
|
// Construct a ConstantExpr of the appropriate kind
|
||||||
@@ -245,12 +243,12 @@ Constant *BytecodeParser::parseConstantValue(const unsigned char *&Buf,
|
|||||||
case Type::ArrayTyID: {
|
case Type::ArrayTyID: {
|
||||||
const ArrayType *AT = cast<ArrayType>(Ty);
|
const ArrayType *AT = cast<ArrayType>(Ty);
|
||||||
unsigned NumElements = AT->getNumElements();
|
unsigned NumElements = AT->getNumElements();
|
||||||
|
unsigned TypeSlot = getTypeSlot(AT->getElementType());
|
||||||
std::vector<Constant*> Elements;
|
std::vector<Constant*> Elements;
|
||||||
while (NumElements--) { // Read all of the elements of the constant.
|
while (NumElements--) { // Read all of the elements of the constant.
|
||||||
unsigned Slot;
|
unsigned Slot;
|
||||||
if (read_vbr(Buf, EndBuf, Slot)) throw Error_readvbr;
|
if (read_vbr(Buf, EndBuf, Slot)) throw Error_readvbr;
|
||||||
Elements.push_back(getConstantValue(AT->getElementType(), Slot));
|
Elements.push_back(getConstantValue(TypeSlot, Slot));
|
||||||
}
|
}
|
||||||
return ConstantArray::get(AT, Elements);
|
return ConstantArray::get(AT, Elements);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -172,13 +172,14 @@ BasicBlock *BytecodeParser::getBasicBlock(unsigned ID) {
|
|||||||
/// constant hasn't been parsed yet, a placeholder is defined and used. Later,
|
/// constant hasn't been parsed yet, a placeholder is defined and used. Later,
|
||||||
/// after the real value is parsed, the placeholder is eliminated.
|
/// after the real value is parsed, the placeholder is eliminated.
|
||||||
///
|
///
|
||||||
Constant *BytecodeParser::getConstantValue(const Type *Ty, unsigned Slot) {
|
Constant *BytecodeParser::getConstantValue(unsigned TypeSlot, unsigned Slot) {
|
||||||
if (Value *V = getValue(Ty, Slot, false))
|
if (Value *V = getValue(TypeSlot, Slot, false))
|
||||||
if (Constant *C = dyn_cast<Constant>(V))
|
if (Constant *C = dyn_cast<Constant>(V))
|
||||||
return C; // If we already have the value parsed, just return it
|
return C; // If we already have the value parsed, just return it
|
||||||
else
|
else
|
||||||
throw std::string("Reference of a value is expected to be a constant!");
|
throw std::string("Reference of a value is expected to be a constant!");
|
||||||
|
|
||||||
|
const Type *Ty = getType(TypeSlot);
|
||||||
std::pair<const Type*, unsigned> Key(Ty, Slot);
|
std::pair<const Type*, unsigned> Key(Ty, Slot);
|
||||||
GlobalRefsType::iterator I = GlobalRefs.lower_bound(Key);
|
GlobalRefsType::iterator I = GlobalRefs.lower_bound(Key);
|
||||||
|
|
||||||
|
|||||||
@@ -180,7 +180,10 @@ private:
|
|||||||
Value *getValue(unsigned TypeID, unsigned num, bool Create = true);
|
Value *getValue(unsigned TypeID, unsigned num, bool Create = true);
|
||||||
const Type *getType(unsigned ID);
|
const Type *getType(unsigned ID);
|
||||||
BasicBlock *getBasicBlock(unsigned ID);
|
BasicBlock *getBasicBlock(unsigned ID);
|
||||||
Constant *getConstantValue(const Type *Ty, unsigned num);
|
Constant *getConstantValue(unsigned TypeID, unsigned num);
|
||||||
|
Constant *getConstantValue(const Type *Ty, unsigned num) {
|
||||||
|
return getConstantValue(getTypeSlot(Ty), num);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned insertValue(Value *V, ValueTable &Table);
|
unsigned insertValue(Value *V, ValueTable &Table);
|
||||||
unsigned insertValue(Value *V, unsigned Type, ValueTable &Table);
|
unsigned insertValue(Value *V, unsigned Type, ValueTable &Table);
|
||||||
|
|||||||
Reference in New Issue
Block a user