diff options
author | Chris Lattner <sabre@nondot.org> | 2003-08-05 03:53:04 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-08-05 03:53:04 +0000 |
commit | d7efef9d1481a96425e09b8a37114c815ab5da1c (patch) | |
tree | ca37b1a9ef93af66813099be281efb6a86f86292 /support/tools/TableGen | |
parent | d9ac6a7d3b6a022a2b3d0170c1a20c523c67b436 (diff) | |
download | external_llvm-d7efef9d1481a96425e09b8a37114c815ab5da1c.zip external_llvm-d7efef9d1481a96425e09b8a37114c815ab5da1c.tar.gz external_llvm-d7efef9d1481a96425e09b8a37114c815ab5da1c.tar.bz2 |
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
Diffstat (limited to 'support/tools/TableGen')
-rw-r--r-- | support/tools/TableGen/CodeEmitterGen.cpp | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/support/tools/TableGen/CodeEmitterGen.cpp b/support/tools/TableGen/CodeEmitterGen.cpp index 4aaeed8..f3b238c 100644 --- a/support/tools/TableGen/CodeEmitterGen.cpp +++ b/support/tools/TableGen/CodeEmitterGen.cpp @@ -46,30 +46,22 @@ void CodeEmitterGen::run(std::ostream &o) { DEBUG(o << " // " << *R->getValue("Inst") << "\n"); o << " Value = " << Value << "U;\n\n"; - // Loop over all of the fields in the instruction adding in any - // contributions to this value (due to bit references). + // Loop over all of the fields in the instruction determining which are the + // operands to the instruction. // unsigned op = 0; - std::map<const std::string,unsigned> OpOrder; - std::map<const std::string,bool> OpContinuous; + std::map<std::string, unsigned> OpOrder; + std::map<std::string, bool> OpContinuous; for (unsigned i = 0, e = Vals.size(); i != e; ++i) { - if (Vals[i].getName() != "Inst" && - !Vals[i].getValue()->isComplete() && + if (!Vals[i].getPrefix() && !Vals[i].getValue()->isComplete() && /* ignore annul and predict bits since no one sets them yet */ - Vals[i].getName() != "annul" && - Vals[i].getName() != "predict") + Vals[i].getName() != "annul" && 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 // instead of doing it bit-by-bit, saving a lot in runtime cost. const BitsInit *InstInit = BI; - int beginBitInVar = -1, endBitInVar = -1, - beginBitInInst = -1, endBitInInst = -1; + int beginBitInVar = -1, endBitInVar = -1; + int beginBitInInst = -1, endBitInInst = -1; bool continuous = true; 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 // instruction. if the relative distances stay the same // throughout, - if ((beginBitInVar - (int)VBI->getBitNum()) != - (beginBitInInst - bit)) - { + if (beginBitInVar - (int)VBI->getBitNum() != + beginBitInInst - bit) { continuous = false; break; } @@ -121,39 +112,48 @@ void CodeEmitterGen::run(std::ostream &o) { } } - DEBUG(o << " // Var: begin = " << beginBitInVar - << ", end = " << endBitInVar - << "; Inst: begin = " << beginBitInInst - << ", end = " << endBitInInst << "\n"); - - if (continuous) { - DEBUG(o << " // continuous: op" << OpOrder[Vals[i].getName()] - << "\n"); + if (beginBitInInst != -1) { + 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++; - // Mask off the right bits - // Low mask (ie. shift, if necessary) - if (endBitInVar != 0) { - o << " op" << OpOrder[Vals[i].getName()] - << " >>= " << endBitInVar << ";\n"; - beginBitInVar -= endBitInVar; - endBitInVar = 0; - } - - // High mask - o << " op" << OpOrder[Vals[i].getName()] - << " &= (1<<" << beginBitInVar+1 << ") - 1;\n"; - - // Shift the value to the correct place (according to place in instr) - if (endBitInInst != 0) + DEBUG(o << " // Var: begin = " << beginBitInVar + << ", end = " << endBitInVar + << "; Inst: begin = " << beginBitInInst + << ", end = " << endBitInInst << "\n"); + + if (continuous) { + DEBUG(o << " // continuous: op" << OpOrder[Vals[i].getName()] + << "\n"); + + // Mask off the right bits + // Low mask (ie. shift, if necessary) + if (endBitInVar != 0) { + o << " op" << OpOrder[Vals[i].getName()] + << " >>= " << endBitInVar << ";\n"; + beginBitInVar -= endBitInVar; + endBitInVar = 0; + } + + // High mask 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"; - - // Just OR in the result - o << " Value |= op" << OpOrder[Vals[i].getName()] << ";\n"; + + // Just OR in the result + 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; } } |