mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-03-02 22:32:08 +00:00
Minor code simplification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90628 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
63be493b52
commit
7004b9cf33
@ -61,14 +61,11 @@ void CodeEmitterGen::reverseBits(std::vector<Record*> &Insts) {
|
|||||||
|
|
||||||
// If the VarBitInit at position 'bit' matches the specified variable then
|
// If the VarBitInit at position 'bit' matches the specified variable then
|
||||||
// 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 Init *VarVal,
|
||||||
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();
|
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;
|
return -1;
|
||||||
@ -162,11 +159,11 @@ void CodeEmitterGen::run(raw_ostream &o) {
|
|||||||
if (!Vals[i].getPrefix() && !Vals[i].getValue()->isComplete()) {
|
if (!Vals[i].getPrefix() && !Vals[i].getValue()->isComplete()) {
|
||||||
// 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 Init *VarVal = Vals[i].getValue();
|
||||||
bool gotOp = false;
|
bool gotOp = false;
|
||||||
|
|
||||||
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(VarVal, BI, bit);
|
||||||
|
|
||||||
if (varBit == -1) {
|
if (varBit == -1) {
|
||||||
--bit;
|
--bit;
|
||||||
@ -176,7 +173,7 @@ void CodeEmitterGen::run(raw_ostream &o) {
|
|||||||
int N = 1;
|
int N = 1;
|
||||||
|
|
||||||
for (--bit; bit >= 0;) {
|
for (--bit; bit >= 0;) {
|
||||||
varBit = getVariableBit(VarName, BI, bit);
|
varBit = getVariableBit(VarVal, BI, bit);
|
||||||
if (varBit == -1 || varBit != (beginVarBit - N)) break;
|
if (varBit == -1 || varBit != (beginVarBit - N)) break;
|
||||||
++N;
|
++N;
|
||||||
--bit;
|
--bit;
|
||||||
@ -188,7 +185,7 @@ void CodeEmitterGen::run(raw_ostream &o) {
|
|||||||
while (CGI.isFlatOperandNotEmitted(op))
|
while (CGI.isFlatOperandNotEmitted(op))
|
||||||
++op;
|
++op;
|
||||||
|
|
||||||
Case += " // op: " + VarName + "\n"
|
Case += " // op: " + Vals[i].getName() + "\n"
|
||||||
+ " op = getMachineOpValue(MI, MI.getOperand("
|
+ " op = getMachineOpValue(MI, MI.getOperand("
|
||||||
+ utostr(op++) + "));\n";
|
+ utostr(op++) + "));\n";
|
||||||
gotOp = true;
|
gotOp = true;
|
||||||
|
@ -23,6 +23,7 @@ namespace llvm {
|
|||||||
|
|
||||||
class RecordVal;
|
class RecordVal;
|
||||||
class BitsInit;
|
class BitsInit;
|
||||||
|
class Init;
|
||||||
|
|
||||||
class CodeEmitterGen : public TableGenBackend {
|
class CodeEmitterGen : public TableGenBackend {
|
||||||
RecordKeeper &Records;
|
RecordKeeper &Records;
|
||||||
@ -35,7 +36,7 @@ private:
|
|||||||
void emitMachineOpEmitter(raw_ostream &o, const std::string &Namespace);
|
void emitMachineOpEmitter(raw_ostream &o, const std::string &Namespace);
|
||||||
void emitGetValueBit(raw_ostream &o, const std::string &Namespace);
|
void emitGetValueBit(raw_ostream &o, const std::string &Namespace);
|
||||||
void reverseBits(std::vector<Record*> &Insts);
|
void reverseBits(std::vector<Record*> &Insts);
|
||||||
int getVariableBit(const std::string &VarName, BitsInit *BI, int bit);
|
int getVariableBit(const Init *VarVal, BitsInit *BI, int bit);
|
||||||
};
|
};
|
||||||
|
|
||||||
} // End llvm namespace
|
} // End llvm namespace
|
||||||
|
Loading…
x
Reference in New Issue
Block a user