The CodeEmitterGenerator used to consider ANY uninitialized field as being an

operand (unless it's annul or predict).  Now we only consider fields to be
operands if they are uninitialized AND used in the "Inst" field.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7589 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-08-05 03:53:04 +00:00
parent d9ac6a7d3b
commit d7efef9d14
2 changed files with 96 additions and 96 deletions

View File

@ -46,30 +46,22 @@ void CodeEmitterGen::run(std::ostream &o) {
DEBUG(o << " // " << *R->getValue("Inst") << "\n"); DEBUG(o << " // " << *R->getValue("Inst") << "\n");
o << " Value = " << Value << "U;\n\n"; o << " Value = " << Value << "U;\n\n";
// Loop over all of the fields in the instruction adding in any // Loop over all of the fields in the instruction determining which are the
// contributions to this value (due to bit references). // operands to the instruction.
// //
unsigned op = 0; unsigned op = 0;
std::map<const std::string,unsigned> OpOrder; std::map<std::string, unsigned> OpOrder;
std::map<const std::string,bool> OpContinuous; std::map<std::string, bool> OpContinuous;
for (unsigned i = 0, e = Vals.size(); i != e; ++i) { for (unsigned i = 0, e = Vals.size(); i != e; ++i) {
if (Vals[i].getName() != "Inst" && if (!Vals[i].getPrefix() && !Vals[i].getValue()->isComplete() &&
!Vals[i].getValue()->isComplete() &&
/* ignore annul and predict bits since no one sets them yet */ /* ignore annul and predict bits since no one sets them yet */
Vals[i].getName() != "annul" && Vals[i].getName() != "annul" && Vals[i].getName() != "predict")
Vals[i].getName() != "predict")
{ {
o << " // op" << op << ": " << Vals[i].getName() << "\n"
<< " int64_t op" << op
<<" = getMachineOpValue(MI, MI.getOperand("<<op<<"));\n";
//<< " MachineOperand &op" << op <<" = MI.getOperand("<<op<<");\n";
OpOrder[Vals[i].getName()] = op++;
// 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 BitsInit *InstInit = BI; const BitsInit *InstInit = BI;
int beginBitInVar = -1, endBitInVar = -1, int beginBitInVar = -1, endBitInVar = -1;
beginBitInInst = -1, endBitInInst = -1; int beginBitInInst = -1, endBitInInst = -1;
bool continuous = true; bool continuous = true;
for (int bit = InstInit->getNumBits()-1; bit >= 0; --bit) { for (int bit = InstInit->getNumBits()-1; bit >= 0; --bit) {
@ -111,9 +103,8 @@ void CodeEmitterGen::run(std::ostream &o) {
// maintain same distance between bits in field and bits in // maintain same distance between bits in field and bits in
// instruction. if the relative distances stay the same // instruction. if the relative distances stay the same
// throughout, // throughout,
if ((beginBitInVar - (int)VBI->getBitNum()) != if (beginBitInVar - (int)VBI->getBitNum() !=
(beginBitInInst - bit)) beginBitInInst - bit) {
{
continuous = false; continuous = false;
break; break;
} }
@ -121,39 +112,48 @@ void CodeEmitterGen::run(std::ostream &o) {
} }
} }
DEBUG(o << " // Var: begin = " << beginBitInVar if (beginBitInInst != -1) {
<< ", end = " << endBitInVar o << " // op" << op << ": " << Vals[i].getName() << "\n"
<< "; Inst: begin = " << beginBitInInst << " int64_t op" << op
<< ", end = " << endBitInInst << "\n"); <<" = getMachineOpValue(MI, MI.getOperand("<<op<<"));\n";
//<< " MachineOperand &op" << op <<" = MI.getOperand("<<op<<");\n";
if (continuous) { OpOrder[Vals[i].getName()] = op++;
DEBUG(o << " // continuous: op" << OpOrder[Vals[i].getName()]
<< "\n");
// Mask off the right bits DEBUG(o << " // Var: begin = " << beginBitInVar
// Low mask (ie. shift, if necessary) << ", end = " << endBitInVar
if (endBitInVar != 0) { << "; Inst: begin = " << beginBitInInst
o << " op" << OpOrder[Vals[i].getName()] << ", end = " << endBitInInst << "\n");
<< " >>= " << endBitInVar << ";\n";
beginBitInVar -= endBitInVar; if (continuous) {
endBitInVar = 0; DEBUG(o << " // continuous: op" << OpOrder[Vals[i].getName()]
} << "\n");
// High mask // Mask off the right bits
o << " op" << OpOrder[Vals[i].getName()] // Low mask (ie. shift, if necessary)
<< " &= (1<<" << beginBitInVar+1 << ") - 1;\n"; if (endBitInVar != 0) {
o << " op" << OpOrder[Vals[i].getName()]
// Shift the value to the correct place (according to place in instr) << " >>= " << endBitInVar << ";\n";
if (endBitInInst != 0) beginBitInVar -= endBitInVar;
endBitInVar = 0;
}
// High mask
o << " op" << OpOrder[Vals[i].getName()] o << " op" << OpOrder[Vals[i].getName()]
<< " &= (1<<" << beginBitInVar+1 << ") - 1;\n";
// Shift the value to the correct place (according to place in inst)
if (endBitInInst != 0)
o << " op" << OpOrder[Vals[i].getName()]
<< " <<= " << endBitInInst << ";\n"; << " <<= " << endBitInInst << ";\n";
// Just OR in the result // Just OR in the result
o << " Value |= op" << OpOrder[Vals[i].getName()] << ";\n"; o << " Value |= op" << OpOrder[Vals[i].getName()] << ";\n";
}
// otherwise, will be taken care of in the loop below using this
// value:
OpContinuous[Vals[i].getName()] = continuous;
} }
// otherwise, will be taken care of in the loop below using this value:
OpContinuous[Vals[i].getName()] = continuous;
} }
} }

View File

@ -46,30 +46,22 @@ void CodeEmitterGen::run(std::ostream &o) {
DEBUG(o << " // " << *R->getValue("Inst") << "\n"); DEBUG(o << " // " << *R->getValue("Inst") << "\n");
o << " Value = " << Value << "U;\n\n"; o << " Value = " << Value << "U;\n\n";
// Loop over all of the fields in the instruction adding in any // Loop over all of the fields in the instruction determining which are the
// contributions to this value (due to bit references). // operands to the instruction.
// //
unsigned op = 0; unsigned op = 0;
std::map<const std::string,unsigned> OpOrder; std::map<std::string, unsigned> OpOrder;
std::map<const std::string,bool> OpContinuous; std::map<std::string, bool> OpContinuous;
for (unsigned i = 0, e = Vals.size(); i != e; ++i) { for (unsigned i = 0, e = Vals.size(); i != e; ++i) {
if (Vals[i].getName() != "Inst" && if (!Vals[i].getPrefix() && !Vals[i].getValue()->isComplete() &&
!Vals[i].getValue()->isComplete() &&
/* ignore annul and predict bits since no one sets them yet */ /* ignore annul and predict bits since no one sets them yet */
Vals[i].getName() != "annul" && Vals[i].getName() != "annul" && Vals[i].getName() != "predict")
Vals[i].getName() != "predict")
{ {
o << " // op" << op << ": " << Vals[i].getName() << "\n"
<< " int64_t op" << op
<<" = getMachineOpValue(MI, MI.getOperand("<<op<<"));\n";
//<< " MachineOperand &op" << op <<" = MI.getOperand("<<op<<");\n";
OpOrder[Vals[i].getName()] = op++;
// 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 BitsInit *InstInit = BI; const BitsInit *InstInit = BI;
int beginBitInVar = -1, endBitInVar = -1, int beginBitInVar = -1, endBitInVar = -1;
beginBitInInst = -1, endBitInInst = -1; int beginBitInInst = -1, endBitInInst = -1;
bool continuous = true; bool continuous = true;
for (int bit = InstInit->getNumBits()-1; bit >= 0; --bit) { for (int bit = InstInit->getNumBits()-1; bit >= 0; --bit) {
@ -111,9 +103,8 @@ void CodeEmitterGen::run(std::ostream &o) {
// maintain same distance between bits in field and bits in // maintain same distance between bits in field and bits in
// instruction. if the relative distances stay the same // instruction. if the relative distances stay the same
// throughout, // throughout,
if ((beginBitInVar - (int)VBI->getBitNum()) != if (beginBitInVar - (int)VBI->getBitNum() !=
(beginBitInInst - bit)) beginBitInInst - bit) {
{
continuous = false; continuous = false;
break; break;
} }
@ -121,39 +112,48 @@ void CodeEmitterGen::run(std::ostream &o) {
} }
} }
DEBUG(o << " // Var: begin = " << beginBitInVar if (beginBitInInst != -1) {
<< ", end = " << endBitInVar o << " // op" << op << ": " << Vals[i].getName() << "\n"
<< "; Inst: begin = " << beginBitInInst << " int64_t op" << op
<< ", end = " << endBitInInst << "\n"); <<" = getMachineOpValue(MI, MI.getOperand("<<op<<"));\n";
//<< " MachineOperand &op" << op <<" = MI.getOperand("<<op<<");\n";
if (continuous) { OpOrder[Vals[i].getName()] = op++;
DEBUG(o << " // continuous: op" << OpOrder[Vals[i].getName()]
<< "\n");
// Mask off the right bits DEBUG(o << " // Var: begin = " << beginBitInVar
// Low mask (ie. shift, if necessary) << ", end = " << endBitInVar
if (endBitInVar != 0) { << "; Inst: begin = " << beginBitInInst
o << " op" << OpOrder[Vals[i].getName()] << ", end = " << endBitInInst << "\n");
<< " >>= " << endBitInVar << ";\n";
beginBitInVar -= endBitInVar; if (continuous) {
endBitInVar = 0; DEBUG(o << " // continuous: op" << OpOrder[Vals[i].getName()]
} << "\n");
// High mask // Mask off the right bits
o << " op" << OpOrder[Vals[i].getName()] // Low mask (ie. shift, if necessary)
<< " &= (1<<" << beginBitInVar+1 << ") - 1;\n"; if (endBitInVar != 0) {
o << " op" << OpOrder[Vals[i].getName()]
// Shift the value to the correct place (according to place in instr) << " >>= " << endBitInVar << ";\n";
if (endBitInInst != 0) beginBitInVar -= endBitInVar;
endBitInVar = 0;
}
// High mask
o << " op" << OpOrder[Vals[i].getName()] o << " op" << OpOrder[Vals[i].getName()]
<< " &= (1<<" << beginBitInVar+1 << ") - 1;\n";
// Shift the value to the correct place (according to place in inst)
if (endBitInInst != 0)
o << " op" << OpOrder[Vals[i].getName()]
<< " <<= " << endBitInInst << ";\n"; << " <<= " << endBitInInst << ";\n";
// Just OR in the result // Just OR in the result
o << " Value |= op" << OpOrder[Vals[i].getName()] << ";\n"; o << " Value |= op" << OpOrder[Vals[i].getName()] << ";\n";
}
// otherwise, will be taken care of in the loop below using this
// value:
OpContinuous[Vals[i].getName()] = continuous;
} }
// otherwise, will be taken care of in the loop below using this value:
OpContinuous[Vals[i].getName()] = continuous;
} }
} }