Deleted Added
sdiff udiff text old ( 202375 ) new ( 203954 )
full compact
1//===-- MSP430ISelDAGToDAG.cpp - A dag to dag inst selector for MSP430 ----===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 119 unchanged lines hidden (view full) ---

128 virtual const char *getPassName() const {
129 return "MSP430 DAG->DAG Pattern Instruction Selection";
130 }
131
132 bool MatchAddress(SDValue N, MSP430ISelAddressMode &AM);
133 bool MatchWrapper(SDValue N, MSP430ISelAddressMode &AM);
134 bool MatchAddressBase(SDValue N, MSP430ISelAddressMode &AM);
135
136 bool IsLegalAndProfitableToFold(SDNode *N, SDNode *U,
137 SDNode *Root) const;
138
139 virtual bool
140 SelectInlineAsmMemoryOperand(const SDValue &Op, char ConstraintCode,
141 std::vector<SDValue> &OutOps);
142
143 // Include the pieces autogenerated from the target description.
144 #include "MSP430GenDAGISel.inc"
145

--- 185 unchanged lines hidden (view full) ---

331 break;
332 }
333
334 OutOps.push_back(Op0);
335 OutOps.push_back(Op1);
336 return false;
337}
338
339bool MSP430DAGToDAGISel::IsLegalAndProfitableToFold(SDNode *N, SDNode *U,
340 SDNode *Root) const {
341 if (OptLevel == CodeGenOpt::None) return false;
342
343 /// RMW preprocessing creates the following code:
344 /// [Load1]
345 /// ^ ^
346 /// / |
347 /// / |
348 /// [Load2] |

--- 10 unchanged lines hidden (view full) ---

359 ///
360 /// The path Store => Load2 => Load1 is via chain. Note that in general it is
361 /// not allowed to fold Load1 into Op (and Store) since it will creates a
362 /// cycle. However, this is perfectly legal for the loads moved below the
363 /// TokenFactor by PreprocessForRMW. Query the map Store => Load1 (created
364 /// during preprocessing) to determine whether it's legal to introduce such
365 /// "cycle" for a moment.
366 DenseMap<SDNode*, SDNode*>::const_iterator I = RMWStores.find(Root);
367 if (I != RMWStores.end() && I->second == N)
368 return true;
369
370 // Proceed to 'generic' cycle finder code
371 return SelectionDAGISel::IsLegalAndProfitableToFold(N, U, Root);
372}
373
374
375/// MoveBelowTokenFactor - Replace TokenFactor operand with load's chain operand
376/// and move load below the TokenFactor. Replace store's chain operand with
377/// load's chain result.
378static void MoveBelowTokenFactor(SelectionDAG *CurDAG, SDValue Load,
379 SDValue Store, SDValue TF) {

--- 271 unchanged lines hidden (view full) ---

651 LD->getBasePtr(), LD->getChain());
652}
653
654SDNode *MSP430DAGToDAGISel::SelectIndexedBinOp(SDNode *Op,
655 SDValue N1, SDValue N2,
656 unsigned Opc8, unsigned Opc16) {
657 if (N1.getOpcode() == ISD::LOAD &&
658 N1.hasOneUse() &&
659 IsLegalAndProfitableToFold(N1.getNode(), Op, Op)) {
660 LoadSDNode *LD = cast<LoadSDNode>(N1);
661 if (!isValidIndexedLoad(LD))
662 return NULL;
663
664 MVT VT = LD->getMemoryVT().getSimpleVT();
665 unsigned Opc = (VT == MVT::i16 ? Opc16 : Opc8);
666 MachineSDNode::mmo_iterator MemRefs0 = MF->allocateMemRefsArray(1);
667 MemRefs0[0] = cast<MemSDNode>(N1)->getMemOperand();

--- 154 unchanged lines hidden ---