reduce nesting and minor cleanups, no functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119128 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-11-15 06:42:13 +00:00
parent 85cf7d737d
commit 98e969ae20

View File

@ -62,13 +62,10 @@ void CodeEmitterGen::reverseBits(std::vector<Record*> &Insts) {
// return the variable bit position. Otherwise return -1. // return the variable bit position. Otherwise return -1.
int CodeEmitterGen::getVariableBit(const std::string &VarName, int CodeEmitterGen::getVariableBit(const std::string &VarName,
BitsInit *BI, int bit) { BitsInit *BI, int bit) {
if (VarBitInit *VBI = dynamic_cast<VarBitInit*>(BI->getBit(bit))) { if (VarBitInit *VBI = dynamic_cast<VarBitInit*>(BI->getBit(bit)))
TypedInit *TI = VBI->getVariable(); if (VarInit *VI = dynamic_cast<VarInit*>(VBI->getVariable()))
if (VI->getName() == VarName)
if (VarInit *VI = dynamic_cast<VarInit*>(TI)) { return VBI->getBitNum();
if (VI->getName() == VarName) return VBI->getBitNum();
}
}
return -1; return -1;
} }
@ -141,7 +138,10 @@ void CodeEmitterGen::run(raw_ostream &o) {
// operands to the instruction. // operands to the instruction.
unsigned NumberedOp = 0; unsigned NumberedOp = 0;
for (unsigned i = 0, e = Vals.size(); i != e; ++i) { for (unsigned i = 0, e = Vals.size(); i != e; ++i) {
if (!Vals[i].getPrefix() && !Vals[i].getValue()->isComplete()) { // Ignore fixed fields.
if (Vals[i].getPrefix() || Vals[i].getValue()->isComplete())
continue;
// Is the operand continuous? If so, we can just mask and OR it in // Is the operand continuous? If so, we can just mask and OR it in
// instead of doing it bit-by-bit, saving a lot in runtime cost. // instead of doing it bit-by-bit, saving a lot in runtime cost.
const std::string &VarName = Vals[i].getName(); const std::string &VarName = Vals[i].getName();
@ -150,9 +150,12 @@ void CodeEmitterGen::run(raw_ostream &o) {
for (int bit = BI->getNumBits()-1; bit >= 0; ) { for (int bit = BI->getNumBits()-1; bit >= 0; ) {
int varBit = getVariableBit(VarName, BI, bit); int varBit = getVariableBit(VarName, BI, bit);
// If this bit isn't from a variable, skip it.
if (varBit == -1) { if (varBit == -1) {
--bit; --bit;
} else { continue;
}
int beginInstBit = bit; int beginInstBit = bit;
int beginVarBit = varBit; int beginVarBit = varBit;
int N = 1; int N = 1;
@ -227,8 +230,6 @@ void CodeEmitterGen::run(raw_ostream &o) {
} }
} }
} }
}
}
std::string PostEmitter = R->getValueAsString("PostEncoderMethod"); std::string PostEmitter = R->getValueAsString("PostEncoderMethod");
if (!PostEmitter.empty()) if (!PostEmitter.empty())