diff options
author | Chris Lattner <sabre@nondot.org> | 2005-01-17 00:00:33 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2005-01-17 00:00:33 +0000 |
commit | c1f386c7b87b5f6319cb75f5f99483b1d8a9af7c (patch) | |
tree | 453d8b0b7cf0ab6d035b1dfe9d77cd09a4a087c8 /llvm/lib/Target/X86/X86ISelPattern.cpp | |
parent | 5f180e46456fe5efba04e11d7981512597e7b22f (diff) | |
download | bcm5719-llvm-c1f386c7b87b5f6319cb75f5f99483b1d8a9af7c.tar.gz bcm5719-llvm-c1f386c7b87b5f6319cb75f5f99483b1d8a9af7c.zip |
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.
llvm-svn: 19620
Diffstat (limited to 'llvm/lib/Target/X86/X86ISelPattern.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86ISelPattern.cpp | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/llvm/lib/Target/X86/X86ISelPattern.cpp b/llvm/lib/Target/X86/X86ISelPattern.cpp index ba359de12e1..005433b0516 100644 --- a/llvm/lib/Target/X86/X86ISelPattern.cpp +++ b/llvm/lib/Target/X86/X86ISelPattern.cpp @@ -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); |