+//===----------------------------------------------------------------------===//
+// Instruction Analysis
+//===----------------------------------------------------------------------===//
+
+void InstrInfoEmitter::InferFromPattern(const CodeGenInstruction &Inst,
+ bool &isStore, bool &isLoad,
+ bool &NeverHasSideEffects) {
+ isStore = Inst.isStore;
+ isLoad = Inst.isLoad;
+ NeverHasSideEffects = Inst.neverHasSideEffects;
+
+ const TreePattern *Pattern = CDP.getInstruction(Inst.TheDef).getPattern();
+ if (Pattern == 0) return; // No pattern.
+
+ // FIXME: Change this to use pattern info.
+ if (dynamic_cast<ListInit*>(Inst.TheDef->getValueInit("Pattern"))) {
+ ListInit *LI = Inst.TheDef->getValueAsListInit("Pattern");
+ if (LI && LI->getSize() > 0) {
+ DagInit *Dag = (DagInit *)LI->getElement(0);
+ DefInit *OpDef = dynamic_cast<DefInit*>(Dag->getOperator());
+ if (OpDef) {
+ Record *Operator = OpDef->getDef();
+ if (Operator->isSubClassOf("SDNode")) {
+ const std::string Opcode = Operator->getValueAsString("Opcode");
+ if (Opcode == "ISD::STORE" || Opcode == "ISD::TRUNCSTORE")
+ isStore = true;
+ }
+ }
+ }
+ }
+
+}
+
+