llvm.org GIT mirror llvm / 2d51a4c
remove some old hacky code that tried to infer whether a store occured in a pattern, but failed miserably. The new code works for any instruction that has a store in its pattern, including all the x86 mem op mem instructions. The only target-independent code that uses this is branch folding, so this won't change anything in practice. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45648 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
2 changed file(s) with 51 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
140140 // Instruction Analysis
141141 //===----------------------------------------------------------------------===//
142142
143 class InstAnalyzer {
144 const CodeGenDAGPatterns &CDP;
145 bool &isStore;
146 bool &isLoad;
147 bool &NeverHasSideEffects;
148 public:
149 InstAnalyzer(const CodeGenDAGPatterns &cdp,
150 bool &isstore, bool &isload, bool &nhse)
151 : CDP(cdp), isStore(isstore), isLoad(isload), NeverHasSideEffects(nhse) {
152 }
153
154 void Analyze(Record *InstRecord) {
155 const TreePattern *Pattern = CDP.getInstruction(InstRecord).getPattern();
156 if (Pattern == 0) return; // No pattern.
157
158 // Assume there is no side-effect unless we see one.
159 // FIXME: Enable this.
160 //NeverHasSideEffects = true;
161
162
163 // FIXME: Assume only the first tree is the pattern. The others are clobber
164 // nodes.
165 AnalyzeNode(Pattern->getTree(0));
166 }
167
168 private:
169 void AnalyzeNode(const TreePatternNode *N) {
170 if (N->isLeaf()) {
171 return;
172 }
173
174 if (N->getOperator()->getName() != "set") {
175 // Get information about the SDNode for the operator.
176 const SDNodeInfo &OpInfo = CDP.getSDNodeInfo(N->getOperator());
177
178 if (OpInfo.getEnumName() == "ISD::STORE")
179 isStore = true;
180 }
181
182 for (unsigned i = 0, e = N->getNumChildren(); i != e; ++i)
183 AnalyzeNode(N->getChild(i));
184 }
185
186 };
187
143188 void InstrInfoEmitter::InferFromPattern(const CodeGenInstruction &Inst,
144189 bool &isStore, bool &isLoad,
145190 bool &NeverHasSideEffects) {
147192 isLoad = Inst.isLoad;
148193 NeverHasSideEffects = Inst.neverHasSideEffects;
149194
150 const TreePattern *Pattern = CDP.getInstruction(Inst.TheDef).getPattern();
151 if (Pattern == 0) return; // No pattern.
152
153 // FIXME: Change this to use pattern info.
154 if (dynamic_cast(Inst.TheDef->getValueInit("Pattern"))) {
155 ListInit *LI = Inst.TheDef->getValueAsListInit("Pattern");
156 if (LI && LI->getSize() > 0) {
157 DagInit *Dag = (DagInit *)LI->getElement(0);
158 DefInit *OpDef = dynamic_cast(Dag->getOperator());
159 if (OpDef) {
160 Record *Operator = OpDef->getDef();
161 if (Operator->isSubClassOf("SDNode")) {
162 const std::string Opcode = Operator->getValueAsString("Opcode");
163 if (Opcode == "ISD::STORE" || Opcode == "ISD::TRUNCSTORE")
164 isStore = true;
165 }
166 }
167 }
168 }
169
195 InstAnalyzer(CDP, isStore, isLoad, NeverHasSideEffects).Analyze(Inst.TheDef);
196
197 // If the .td file explicitly says there is no side effect, believe it.
198 if (Inst.neverHasSideEffects)
199 NeverHasSideEffects = true;
170200 }
171201
172202
2828
2929 class InstrInfoEmitter : public TableGenBackend {
3030 RecordKeeper &Records;
31 CodeGenDAGPatterns CDP;
31 const CodeGenDAGPatterns CDP;
3232 std::map ItinClassMap;
3333
3434 public: