mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-23 14:25:07 +00:00
Reduce the number of pointless copies inserted due to constant pointer refs.
Also, make an assertion actually fireable! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@11713 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -461,8 +461,7 @@ void ISel::copyConstantToRegister(MachineBasicBlock *MBB,
|
|||||||
// Copy zero (null pointer) to the register.
|
// Copy zero (null pointer) to the register.
|
||||||
BMI(MBB, IP, X86::MOVri32, 1, R).addZImm(0);
|
BMI(MBB, IP, X86::MOVri32, 1, R).addZImm(0);
|
||||||
} else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C)) {
|
} else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C)) {
|
||||||
unsigned SrcReg = getReg(CPR->getValue(), MBB, IP);
|
BMI(MBB, IP, X86::MOVri32, 1, R).addGlobalAddress(CPR->getValue());
|
||||||
BMI(MBB, IP, X86::MOVrr32, 1, R).addReg(SrcReg);
|
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "Offending constant: " << C << "\n";
|
std::cerr << "Offending constant: " << C << "\n";
|
||||||
assert(0 && "Type not handled yet!");
|
assert(0 && "Type not handled yet!");
|
||||||
@@ -2048,7 +2047,7 @@ void ISel::emitCastOperation(MachineBasicBlock *BB,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Type::ULongTyID:
|
case Type::ULongTyID:
|
||||||
assert("FIXME: not implemented: cast ulong X to fp type!");
|
assert(0 && "FIXME: not implemented: cast ulong X to fp type!");
|
||||||
default: // No promotion needed...
|
default: // No promotion needed...
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2212,6 +2211,9 @@ void ISel::emitGEPOperation(MachineBasicBlock *MBB,
|
|||||||
User::op_iterator IdxEnd, unsigned TargetReg) {
|
User::op_iterator IdxEnd, unsigned TargetReg) {
|
||||||
const TargetData &TD = TM.getTargetData();
|
const TargetData &TD = TM.getTargetData();
|
||||||
|
|
||||||
|
if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Src))
|
||||||
|
Src = CPR->getValue();
|
||||||
|
|
||||||
std::vector<Value*> GEPOps;
|
std::vector<Value*> GEPOps;
|
||||||
GEPOps.resize(IdxEnd-IdxBegin+1);
|
GEPOps.resize(IdxEnd-IdxBegin+1);
|
||||||
GEPOps[0] = Src;
|
GEPOps[0] = Src;
|
||||||
@@ -2229,9 +2231,13 @@ void ISel::emitGEPOperation(MachineBasicBlock *MBB,
|
|||||||
// The getGEPIndex operation didn't want to build an LEA. Check to see if
|
// The getGEPIndex operation didn't want to build an LEA. Check to see if
|
||||||
// all operands are consumed but the base pointer. If so, just load it
|
// all operands are consumed but the base pointer. If so, just load it
|
||||||
// into the register.
|
// into the register.
|
||||||
unsigned BaseReg = getReg(GEPOps[0], MBB, IP);
|
if (GlobalValue *GV = dyn_cast<GlobalValue>(GEPOps[0])) {
|
||||||
BMI(MBB, IP, X86::MOVrr32, 1, TargetReg).addReg(BaseReg);
|
BMI(MBB, IP, X86::MOVri32, 1, TargetReg).addGlobalAddress(GV);
|
||||||
return; // we are now done
|
} else {
|
||||||
|
unsigned BaseReg = getReg(GEPOps[0], MBB, IP);
|
||||||
|
BMI(MBB, IP, X86::MOVrr32, 1, TargetReg).addReg(BaseReg);
|
||||||
|
}
|
||||||
|
break; // we are now done
|
||||||
} else if (const StructType *StTy = dyn_cast<StructType>(GEPTypes.back())) {
|
} else if (const StructType *StTy = dyn_cast<StructType>(GEPTypes.back())) {
|
||||||
// It's a struct access. CUI is the index into the structure,
|
// It's a struct access. CUI is the index into the structure,
|
||||||
// which names the field. This index must have unsigned type.
|
// which names the field. This index must have unsigned type.
|
||||||
|
@@ -461,8 +461,7 @@ void ISel::copyConstantToRegister(MachineBasicBlock *MBB,
|
|||||||
// Copy zero (null pointer) to the register.
|
// Copy zero (null pointer) to the register.
|
||||||
BMI(MBB, IP, X86::MOVri32, 1, R).addZImm(0);
|
BMI(MBB, IP, X86::MOVri32, 1, R).addZImm(0);
|
||||||
} else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C)) {
|
} else if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(C)) {
|
||||||
unsigned SrcReg = getReg(CPR->getValue(), MBB, IP);
|
BMI(MBB, IP, X86::MOVri32, 1, R).addGlobalAddress(CPR->getValue());
|
||||||
BMI(MBB, IP, X86::MOVrr32, 1, R).addReg(SrcReg);
|
|
||||||
} else {
|
} else {
|
||||||
std::cerr << "Offending constant: " << C << "\n";
|
std::cerr << "Offending constant: " << C << "\n";
|
||||||
assert(0 && "Type not handled yet!");
|
assert(0 && "Type not handled yet!");
|
||||||
@@ -2048,7 +2047,7 @@ void ISel::emitCastOperation(MachineBasicBlock *BB,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Type::ULongTyID:
|
case Type::ULongTyID:
|
||||||
assert("FIXME: not implemented: cast ulong X to fp type!");
|
assert(0 && "FIXME: not implemented: cast ulong X to fp type!");
|
||||||
default: // No promotion needed...
|
default: // No promotion needed...
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2212,6 +2211,9 @@ void ISel::emitGEPOperation(MachineBasicBlock *MBB,
|
|||||||
User::op_iterator IdxEnd, unsigned TargetReg) {
|
User::op_iterator IdxEnd, unsigned TargetReg) {
|
||||||
const TargetData &TD = TM.getTargetData();
|
const TargetData &TD = TM.getTargetData();
|
||||||
|
|
||||||
|
if (ConstantPointerRef *CPR = dyn_cast<ConstantPointerRef>(Src))
|
||||||
|
Src = CPR->getValue();
|
||||||
|
|
||||||
std::vector<Value*> GEPOps;
|
std::vector<Value*> GEPOps;
|
||||||
GEPOps.resize(IdxEnd-IdxBegin+1);
|
GEPOps.resize(IdxEnd-IdxBegin+1);
|
||||||
GEPOps[0] = Src;
|
GEPOps[0] = Src;
|
||||||
@@ -2229,9 +2231,13 @@ void ISel::emitGEPOperation(MachineBasicBlock *MBB,
|
|||||||
// The getGEPIndex operation didn't want to build an LEA. Check to see if
|
// The getGEPIndex operation didn't want to build an LEA. Check to see if
|
||||||
// all operands are consumed but the base pointer. If so, just load it
|
// all operands are consumed but the base pointer. If so, just load it
|
||||||
// into the register.
|
// into the register.
|
||||||
unsigned BaseReg = getReg(GEPOps[0], MBB, IP);
|
if (GlobalValue *GV = dyn_cast<GlobalValue>(GEPOps[0])) {
|
||||||
BMI(MBB, IP, X86::MOVrr32, 1, TargetReg).addReg(BaseReg);
|
BMI(MBB, IP, X86::MOVri32, 1, TargetReg).addGlobalAddress(GV);
|
||||||
return; // we are now done
|
} else {
|
||||||
|
unsigned BaseReg = getReg(GEPOps[0], MBB, IP);
|
||||||
|
BMI(MBB, IP, X86::MOVrr32, 1, TargetReg).addReg(BaseReg);
|
||||||
|
}
|
||||||
|
break; // we are now done
|
||||||
} else if (const StructType *StTy = dyn_cast<StructType>(GEPTypes.back())) {
|
} else if (const StructType *StTy = dyn_cast<StructType>(GEPTypes.back())) {
|
||||||
// It's a struct access. CUI is the index into the structure,
|
// It's a struct access. CUI is the index into the structure,
|
||||||
// which names the field. This index must have unsigned type.
|
// which names the field. This index must have unsigned type.
|
||||||
|
Reference in New Issue
Block a user