Change the 'isStore' inferrer to look for 'SDNPMayStore'
instead of "ISD::STORE". This allows us to mark target-specific dag
nodes as storing (such as ppc byteswap stores). This allows us to remove
more explicit isStore flags from the .td files.
Finally, add a warning for when a .td file contains an explicit
isStore and tblgen is able to infer it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45654 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/utils/TableGen/CodeGenDAGPatterns.cpp b/utils/TableGen/CodeGenDAGPatterns.cpp
index 52610cf..5a826cd 100644
--- a/utils/TableGen/CodeGenDAGPatterns.cpp
+++ b/utils/TableGen/CodeGenDAGPatterns.cpp
@@ -317,6 +317,8 @@
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 f024c1d..02afe95 100644
--- a/utils/TableGen/CodeGenTarget.h
+++ b/utils/TableGen/CodeGenTarget.h
@@ -30,8 +30,15 @@
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 4ab285f..86615eb 100644
--- a/utils/TableGen/InstrInfoEmitter.cpp
+++ b/utils/TableGen/InstrInfoEmitter.cpp
@@ -157,9 +157,7 @@
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 @@
// 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 @@
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
}