diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/TableGen/CodeGenDAGPatterns.cpp | 2 | ||||
-rw-r--r-- | utils/TableGen/CodeGenTarget.h | 11 | ||||
-rw-r--r-- | utils/TableGen/InstrInfoEmitter.cpp | 32 |
3 files changed, 33 insertions, 12 deletions
diff --git a/utils/TableGen/CodeGenDAGPatterns.cpp b/utils/TableGen/CodeGenDAGPatterns.cpp index 52610cfaa4..5a826cd0f1 100644 --- a/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/utils/TableGen/CodeGenDAGPatterns.cpp @@ -317,6 +317,8 @@ SDNodeInfo::SDNodeInfo(Record *R) : Def(R) { Properties |= 1 << SDNPInFlag; } else if (PropList[i]->getName() == "SDNPOptInFlag") { Properties |= 1 << SDNPOptInFlag; + } else if (PropList[i]->getName() == "SDNPMayStore") { + Properties |= 1 << SDNPMayStore; } else { cerr << "Unknown SD Node property '" << PropList[i]->getName() << "' on node '" << R->getName() << "'!\n"; diff --git a/utils/TableGen/CodeGenTarget.h b/utils/TableGen/CodeGenTarget.h index f024c1d62a..02afe95547 100644 --- a/utils/TableGen/CodeGenTarget.h +++ b/utils/TableGen/CodeGenTarget.h @@ -30,8 +30,15 @@ struct CodeGenRegister; class CodeGenTarget; // SelectionDAG node properties. -enum SDNP { SDNPCommutative, SDNPAssociative, SDNPHasChain, - SDNPOutFlag, SDNPInFlag, SDNPOptInFlag }; +enum SDNP { + SDNPCommutative, + SDNPAssociative, + SDNPHasChain, + SDNPOutFlag, + SDNPInFlag, + SDNPOptInFlag, + SDNPMayStore +}; /// getValueType - Return the MVT::ValueType that the specified TableGen record /// corresponds to. diff --git a/utils/TableGen/InstrInfoEmitter.cpp b/utils/TableGen/InstrInfoEmitter.cpp index 4ab285f58f..86615eb932 100644 --- a/utils/TableGen/InstrInfoEmitter.cpp +++ b/utils/TableGen/InstrInfoEmitter.cpp @@ -157,9 +157,7 @@ public: if (Pattern == 0) return; // No pattern. // Assume there is no side-effect unless we see one. - // FIXME: Enable this. - //NeverHasSideEffects = true; - + NeverHasSideEffects = true; // FIXME: Assume only the first tree is the pattern. The others are clobber // nodes. @@ -176,10 +174,9 @@ private: // Get information about the SDNode for the operator. const SDNodeInfo &OpInfo = CDP.getSDNodeInfo(N->getOperator()); - // If this is a store node, it obviously stores to memory. - if (OpInfo.getEnumName() == "ISD::STORE") { + // If node writes to memory, it obviously stores to memory. + if (OpInfo.hasProperty(SDNPMayStore)) { isStore = true; - } else if (const CodeGenIntrinsic *IntInfo = N->getIntrinsicInfo(CDP)) { // If this is an intrinsic, analyze it. if (IntInfo->ModRef >= CodeGenIntrinsic::WriteArgMem) @@ -196,15 +193,30 @@ private: void InstrInfoEmitter::InferFromPattern(const CodeGenInstruction &Inst, bool &isStore, bool &isLoad, bool &NeverHasSideEffects) { - isStore = Inst.isStore; - isLoad = Inst.isLoad; - NeverHasSideEffects = Inst.neverHasSideEffects; + isStore = isLoad = NeverHasSideEffects = false; InstAnalyzer(CDP, isStore, isLoad, NeverHasSideEffects).Analyze(Inst.TheDef); - + + // InstAnalyzer only correctly analyzes isStore so far. + if (Inst.isStore) { // If the .td file explicitly sets isStore, use it. + // If we decided that this is a store from the pattern, then the .td file + // entry is redundant. + if (isStore) + fprintf(stderr, "Warning: isStore flag explicitly set on instruction '%s'" + " but flag already inferred from pattern.\n", + Inst.getName().c_str()); + isStore = true; + } + + // These two override everything. + isLoad = Inst.isLoad; + NeverHasSideEffects = Inst.neverHasSideEffects; + +#if 0 // If the .td file explicitly says there is no side effect, believe it. if (Inst.neverHasSideEffects) NeverHasSideEffects = true; +#endif } |