forked from OSchip/llvm-project
parent
8fbe78f6fc
commit
c87c16b030
|
@ -61,11 +61,14 @@ void CodeEmitterGen::reverseBits(std::vector<Record*> &Insts) {
|
|||
|
||||
// If the VarBitInit at position 'bit' matches the specified variable then
|
||||
// return the variable bit position. Otherwise return -1.
|
||||
int CodeEmitterGen::getVariableBit(const Init *VarVal,
|
||||
int CodeEmitterGen::getVariableBit(const std::string &VarName,
|
||||
BitsInit *BI, int bit) {
|
||||
if (VarBitInit *VBI = dynamic_cast<VarBitInit*>(BI->getBit(bit))) {
|
||||
TypedInit *TI = VBI->getVariable();
|
||||
if (TI == VarVal) return VBI->getBitNum();
|
||||
|
||||
if (VarInit *VI = dynamic_cast<VarInit*>(TI)) {
|
||||
if (VI->getName() == VarName) return VBI->getBitNum();
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
@ -159,11 +162,11 @@ void CodeEmitterGen::run(raw_ostream &o) {
|
|||
if (!Vals[i].getPrefix() && !Vals[i].getValue()->isComplete()) {
|
||||
// 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 Init *VarVal = Vals[i].getValue();
|
||||
const std::string &VarName = Vals[i].getName();
|
||||
bool gotOp = false;
|
||||
|
||||
for (int bit = BI->getNumBits()-1; bit >= 0; ) {
|
||||
int varBit = getVariableBit(VarVal, BI, bit);
|
||||
int varBit = getVariableBit(VarName, BI, bit);
|
||||
|
||||
if (varBit == -1) {
|
||||
--bit;
|
||||
|
@ -173,7 +176,7 @@ void CodeEmitterGen::run(raw_ostream &o) {
|
|||
int N = 1;
|
||||
|
||||
for (--bit; bit >= 0;) {
|
||||
varBit = getVariableBit(VarVal, BI, bit);
|
||||
varBit = getVariableBit(VarName, BI, bit);
|
||||
if (varBit == -1 || varBit != (beginVarBit - N)) break;
|
||||
++N;
|
||||
--bit;
|
||||
|
@ -185,7 +188,7 @@ void CodeEmitterGen::run(raw_ostream &o) {
|
|||
while (CGI.isFlatOperandNotEmitted(op))
|
||||
++op;
|
||||
|
||||
Case += " // op: " + Vals[i].getName() + "\n"
|
||||
Case += " // op: " + VarName + "\n"
|
||||
+ " op = getMachineOpValue(MI, MI.getOperand("
|
||||
+ utostr(op++) + "));\n";
|
||||
gotOp = true;
|
||||
|
|
|
@ -23,7 +23,6 @@ namespace llvm {
|
|||
|
||||
class RecordVal;
|
||||
class BitsInit;
|
||||
struct Init;
|
||||
|
||||
class CodeEmitterGen : public TableGenBackend {
|
||||
RecordKeeper &Records;
|
||||
|
@ -36,7 +35,7 @@ private:
|
|||
void emitMachineOpEmitter(raw_ostream &o, const std::string &Namespace);
|
||||
void emitGetValueBit(raw_ostream &o, const std::string &Namespace);
|
||||
void reverseBits(std::vector<Record*> &Insts);
|
||||
int getVariableBit(const Init *VarVal, BitsInit *BI, int bit);
|
||||
int getVariableBit(const std::string &VarName, BitsInit *BI, int bit);
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
|
Loading…
Reference in New Issue