llvm.org GIT mirror llvm / e67bde5
set the 'isstore' flag for instructions whose pattern is an intrinsic that writes to memory. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45650 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
3 changed file(s) with 36 addition(s) and 15 deletion(s). Raw diff Collapse all Expand all
632632 return Other;
633633 }
634634
635
636 /// getIntrinsicInfo - If this node corresponds to an intrinsic, return the
637 /// CodeGenIntrinsic information for it, otherwise return a null pointer.
638 const CodeGenIntrinsic *TreePatternNode::
639 getIntrinsicInfo(const CodeGenDAGPatterns &CDP) const {
640 if (getOperator() != CDP.get_intrinsic_void_sdnode() &&
641 getOperator() != CDP.get_intrinsic_w_chain_sdnode() &&
642 getOperator() != CDP.get_intrinsic_wo_chain_sdnode())
643 return 0;
644
645 unsigned IID =
646 dynamic_cast(getChild(0)->getLeafValue())->getValue();
647 return &CDP.getIntrinsicInfo(IID);
648 }
649
650
635651 /// ApplyTypeConstraints - Apply all of the type constraints relevent to
636652 /// this node and its children in the tree. This returns true if it makes a
637653 /// change, false otherwise. If a type contradiction is found, throw an
698714 MadeChange = getChild(i)->ApplyTypeConstraints(TP, NotRegisters);
699715 MadeChange |= UpdateNodeType(MVT::isVoid, TP);
700716 return MadeChange;
701 } else if (getOperator() == CDP.get_intrinsic_void_sdnode() ||
702 getOperator() == CDP.get_intrinsic_w_chain_sdnode() ||
703 getOperator() == CDP.get_intrinsic_wo_chain_sdnode()) {
704 unsigned IID =
705 dynamic_cast(getChild(0)->getLeafValue())->getValue();
706 const CodeGenIntrinsic &Int = CDP.getIntrinsicInfo(IID);
717 } else if (const CodeGenIntrinsic *Int = getIntrinsicInfo(CDP)) {
707718 bool MadeChange = false;
708719
709720 // Apply the result type to the node.
710 MadeChange = UpdateNodeType(Int.ArgVTs[0], TP);
711
712 if (getNumChildren() != Int.ArgVTs.size())
713 TP.error("Intrinsic '" + Int.Name + "' expects " +
714 utostr(Int.ArgVTs.size()-1) + " operands, not " +
721 MadeChange = UpdateNodeType(Int->ArgVTs[0], TP);
722
723 if (getNumChildren() != Int->ArgVTs.size())
724 TP.error("Intrinsic '" + Int->Name + "' expects " +
725 utostr(Int->ArgVTs.size()-1) + " operands, not " +
715726 utostr(getNumChildren()-1) + " operands!");
716727
717728 // Apply type info to the intrinsic ID.
718729 MadeChange |= getChild(0)->UpdateNodeType(MVT::iPTR, TP);
719730
720731 for (unsigned i = 1, e = getNumChildren(); i != e; ++i) {
721 MVT::ValueType OpVT = Int.ArgVTs[i];
732 MVT::ValueType OpVT = Int->ArgVTs[i];
722733 MadeChange |= getChild(i)->UpdateNodeType(OpVT, TP);
723734 MadeChange |= getChild(i)->ApplyTypeConstraints(TP, NotRegisters);
724735 }
202202 void setChild(unsigned i, TreePatternNode *N) {
203203 Children[i] = N;
204204 }
205
206
205
207206 const std::string &getPredicateFn() const { return PredicateFn; }
208207 void setPredicateFn(const std::string &Fn) { PredicateFn = Fn; }
209208
210209 Record *getTransformFn() const { return TransformFn; }
211210 void setTransformFn(Record *Fn) { TransformFn = Fn; }
211
212 /// getIntrinsicInfo - If this node corresponds to an intrinsic, return the
213 /// CodeGenIntrinsic information for it, otherwise return a null pointer.
214 const CodeGenIntrinsic *getIntrinsicInfo(const CodeGenDAGPatterns &CDP) const;
212215
213216 void print(std::ostream &OS) const;
214217 void dump() const;
175175 // Get information about the SDNode for the operator.
176176 const SDNodeInfo &OpInfo = CDP.getSDNodeInfo(N->getOperator());
177177
178 if (OpInfo.getEnumName() == "ISD::STORE")
178 // If this is a store node, it obviously stores to memory.
179 if (OpInfo.getEnumName() == "ISD::STORE") {
179180 isStore = true;
181
182 } else if (const CodeGenIntrinsic *IntInfo = N->getIntrinsicInfo(CDP)) {
183 // If this is an intrinsic, analyze it.
184 if (IntInfo->ModRef >= CodeGenIntrinsic::WriteArgMem)
185 isStore = true; // Intrinsics that can write to memory are 'isStore'.
186 }
180187 }
181188
182189 for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i)