mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-15 23:31:37 +00:00
Set up the shift and setcc types.
If we emit a load because we followed a token chain to get to it, try to fold it into its single user if possible. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@19620 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
714b69d047
commit
4df0de975a
@ -39,6 +39,12 @@ namespace {
|
||||
public:
|
||||
X86TargetLowering(TargetMachine &TM) : TargetLowering(TM) {
|
||||
// Set up the TargetLowering object.
|
||||
|
||||
// X86 is wierd, it always uses i8 for shift amounts and setcc results.
|
||||
setShiftAmountType(MVT::i8);
|
||||
setSetCCResultType(MVT::i8);
|
||||
|
||||
// Set up the register classes.
|
||||
addRegisterClass(MVT::i8, X86::R8RegisterClass);
|
||||
addRegisterClass(MVT::i16, X86::R16RegisterClass);
|
||||
addRegisterClass(MVT::i32, X86::R32RegisterClass);
|
||||
@ -2303,10 +2309,35 @@ void ISel::Select(SDOperand N) {
|
||||
return;
|
||||
}
|
||||
|
||||
case ISD::LOAD:
|
||||
// If this load could be folded into the only using instruction, and if it
|
||||
// is safe to emit the instruction here, try to do so now.
|
||||
if (Node->hasNUsesOfValue(1, 0)) {
|
||||
SDOperand TheVal = N.getValue(0);
|
||||
SDNode *User = 0;
|
||||
for (SDNode::use_iterator UI = Node->use_begin(); ; ++UI) {
|
||||
assert(UI != Node->use_end() && "Didn't find use!");
|
||||
SDNode *UN = *UI;
|
||||
for (unsigned i = 0, e = UN->getNumOperands(); i != e; ++i)
|
||||
if (UN->getOperand(i) == TheVal) {
|
||||
User = UN;
|
||||
goto FoundIt;
|
||||
}
|
||||
}
|
||||
FoundIt:
|
||||
// Only handle unary operators right now.
|
||||
if (User->getNumOperands() == 1) {
|
||||
LoweredTokens.erase(N);
|
||||
SelectExpr(SDOperand(User, 0));
|
||||
return;
|
||||
}
|
||||
}
|
||||
SelectExpr(N);
|
||||
return;
|
||||
|
||||
case ISD::EXTLOAD:
|
||||
case ISD::SEXTLOAD:
|
||||
case ISD::ZEXTLOAD:
|
||||
case ISD::LOAD:
|
||||
case ISD::CALL:
|
||||
case ISD::DYNAMIC_STACKALLOC:
|
||||
SelectExpr(N);
|
||||
|
Loading…
x
Reference in New Issue
Block a user