Stop using the `Offset' variable, as we are cycling through the bits of a field

initializer and the loop index variable already carries the offset information
that we need.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7123 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Misha Brukman 2003-07-07 22:30:44 +00:00
parent 29abc97100
commit 48aa824279
2 changed files with 14 additions and 16 deletions

View File

@ -74,8 +74,7 @@ void CodeEmitterGen::createEmitter(std::ostream &o) {
} }
} }
unsigned Offset = 31; for (unsigned f = 0, e = Vals.size(); f != e; ++f) {
for (int f = Vals.size()-1; f >= 0; --f) {
if (Vals[f].getPrefix()) { if (Vals[f].getPrefix()) {
BitsInit *FieldInitializer = (BitsInit*)Vals[f].getValue(); BitsInit *FieldInitializer = (BitsInit*)Vals[f].getValue();
@ -83,18 +82,17 @@ void CodeEmitterGen::createEmitter(std::ostream &o) {
// variable... // variable...
for (int i = FieldInitializer->getNumBits()-1; i >= 0; --i) { for (int i = FieldInitializer->getNumBits()-1; i >= 0; --i) {
if (BitInit *BI=dynamic_cast<BitInit*>(FieldInitializer->getBit(i))){ if (BitInit *BI=dynamic_cast<BitInit*>(FieldInitializer->getBit(i))){
--Offset; o << " // bit init: f: " << f << ", i: " << i << "\n";
} else if (UnsetInit *UI = } else if (UnsetInit *UI =
dynamic_cast<UnsetInit*>(FieldInitializer->getBit(i))) { dynamic_cast<UnsetInit*>(FieldInitializer->getBit(i))) {
--Offset; o << " // unset init: f: " << f << ", i: " << i << "\n";
} else if (VarBitInit *VBI = } else if (VarBitInit *VBI =
dynamic_cast<VarBitInit*>(FieldInitializer->getBit(i))) { dynamic_cast<VarBitInit*>(FieldInitializer->getBit(i))) {
TypedInit *TI = VBI->getVariable(); TypedInit *TI = VBI->getVariable();
if (VarInit *VI = dynamic_cast<VarInit*>(TI)) { if (VarInit *VI = dynamic_cast<VarInit*>(TI)) {
o << " Value |= getValueBit(op" << OpOrder[VI->getName()] o << " Value |= getValueBit(op" << OpOrder[VI->getName()]
<< ", " << VBI->getBitNum() << ", " << VBI->getBitNum()
<< ")" << " << " << Offset << ";\n"; << ")" << " << " << i << ";\n";
--Offset;
} else if (FieldInit *FI = dynamic_cast<FieldInit*>(TI)) { } else if (FieldInit *FI = dynamic_cast<FieldInit*>(TI)) {
// FIXME: implement this! // FIXME: implement this!
o << "FIELD INIT not implemented yet!\n"; o << "FIELD INIT not implemented yet!\n";
@ -105,8 +103,9 @@ void CodeEmitterGen::createEmitter(std::ostream &o) {
} }
} else { } else {
// ignore annul and predict bits since no one sets them yet // ignore annul and predict bits since no one sets them yet
if (Vals[f].getName() == "annul" || Vals[f].getName() == "predict") if (Vals[f].getName() == "annul" || Vals[f].getName() == "predict") {
--Offset; o << " // found " << Vals[f].getName() << "\n";
}
} }
} }

View File

@ -74,8 +74,7 @@ void CodeEmitterGen::createEmitter(std::ostream &o) {
} }
} }
unsigned Offset = 31; for (unsigned f = 0, e = Vals.size(); f != e; ++f) {
for (int f = Vals.size()-1; f >= 0; --f) {
if (Vals[f].getPrefix()) { if (Vals[f].getPrefix()) {
BitsInit *FieldInitializer = (BitsInit*)Vals[f].getValue(); BitsInit *FieldInitializer = (BitsInit*)Vals[f].getValue();
@ -83,18 +82,17 @@ void CodeEmitterGen::createEmitter(std::ostream &o) {
// variable... // variable...
for (int i = FieldInitializer->getNumBits()-1; i >= 0; --i) { for (int i = FieldInitializer->getNumBits()-1; i >= 0; --i) {
if (BitInit *BI=dynamic_cast<BitInit*>(FieldInitializer->getBit(i))){ if (BitInit *BI=dynamic_cast<BitInit*>(FieldInitializer->getBit(i))){
--Offset; o << " // bit init: f: " << f << ", i: " << i << "\n";
} else if (UnsetInit *UI = } else if (UnsetInit *UI =
dynamic_cast<UnsetInit*>(FieldInitializer->getBit(i))) { dynamic_cast<UnsetInit*>(FieldInitializer->getBit(i))) {
--Offset; o << " // unset init: f: " << f << ", i: " << i << "\n";
} else if (VarBitInit *VBI = } else if (VarBitInit *VBI =
dynamic_cast<VarBitInit*>(FieldInitializer->getBit(i))) { dynamic_cast<VarBitInit*>(FieldInitializer->getBit(i))) {
TypedInit *TI = VBI->getVariable(); TypedInit *TI = VBI->getVariable();
if (VarInit *VI = dynamic_cast<VarInit*>(TI)) { if (VarInit *VI = dynamic_cast<VarInit*>(TI)) {
o << " Value |= getValueBit(op" << OpOrder[VI->getName()] o << " Value |= getValueBit(op" << OpOrder[VI->getName()]
<< ", " << VBI->getBitNum() << ", " << VBI->getBitNum()
<< ")" << " << " << Offset << ";\n"; << ")" << " << " << i << ";\n";
--Offset;
} else if (FieldInit *FI = dynamic_cast<FieldInit*>(TI)) { } else if (FieldInit *FI = dynamic_cast<FieldInit*>(TI)) {
// FIXME: implement this! // FIXME: implement this!
o << "FIELD INIT not implemented yet!\n"; o << "FIELD INIT not implemented yet!\n";
@ -105,8 +103,9 @@ void CodeEmitterGen::createEmitter(std::ostream &o) {
} }
} else { } else {
// ignore annul and predict bits since no one sets them yet // ignore annul and predict bits since no one sets them yet
if (Vals[f].getName() == "annul" || Vals[f].getName() == "predict") if (Vals[f].getName() == "annul" || Vals[f].getName() == "predict") {
--Offset; o << " // found " << Vals[f].getName() << "\n";
}
} }
} }