llvm.org GIT mirror llvm / dcc8b4f
add a mayLoad property for machine instructions, a correlary to mayStore. This is currently not set by anything. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@45748 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
4 changed file(s) with 24 addition(s) and 16 deletion(s). Raw diff Collapse all Expand all
8989 NotDuplicable,
9090 DelaySlot,
9191 SimpleLoad,
92 MayLoad,
9293 MayStore,
9394 NeverHasSideEffects,
9495 MayHaveSideEffects,
307308 //===--------------------------------------------------------------------===//
308309 // Side Effect Analysis
309310 //===--------------------------------------------------------------------===//
311
312 /// mayLoad - Return true if this instruction could possibly read memory.
313 /// Instructions with this flag set are not necessarily simple load
314 /// instructions, they may load a value and modify it, for example.
315 bool mayLoad() const {
316 return Flags & (1 << TID::MayLoad);
317 }
318
310319
311320 /// mayStore - Return true if this instruction could possibly modify memory.
312321 /// Instructions with this flag set are not necessarily simple store
315324 bool mayStore() const {
316325 return Flags & (1 << TID::MayStore);
317326 }
318
319 // TODO: mayLoad.
320327
321328 /// hasNoSideEffects - Return true if all instances of this instruction are
322329 /// guaranteed to have no side effects other than:
8383 isBarrier = R->getValueAsBit("isBarrier");
8484 isCall = R->getValueAsBit("isCall");
8585 isSimpleLoad = R->getValueAsBit("isSimpleLoad");
86 mayLoad = R->getValueAsBit("mayLoad");
8687 mayStore = R->getValueAsBit("mayStore");
8788 isImplicitDef= R->getValueAsBit("isImplicitDef");
8889 bool isTwoAddress = R->getValueAsBit("isTwoAddress");
8989 bool isBarrier;
9090 bool isCall;
9191 bool isSimpleLoad;
92 bool mayStore;
92 bool mayLoad, mayStore;
9393 bool isImplicitDef;
9494 bool isPredicable;
9595 bool isConvertibleToThreeAddress;
143143 class InstAnalyzer {
144144 const CodeGenDAGPatterns &CDP;
145145 bool &mayStore;
146 bool &isLoad;
146 bool &mayLoad;
147147 bool &NeverHasSideEffects;
148148 public:
149149 InstAnalyzer(const CodeGenDAGPatterns &cdp,
150 bool &maystore, bool &isload, bool &nhse)
151 : CDP(cdp), mayStore(maystore), isLoad(isload), NeverHasSideEffects(nhse) {
150 bool &maystore, bool &mayload, bool &nhse)
151 : CDP(cdp), mayStore(maystore), mayLoad(mayload), NeverHasSideEffects(nhse){
152152 }
153153
154154 void Analyze(Record *InstRecord) {
165165
166166 private:
167167 void AnalyzeNode(const TreePatternNode *N) {
168 if (N->isLeaf()) {
168 if (N->isLeaf())
169169 return;
170 }
171170
172171 if (N->getOperator()->getName() != "set") {
173172 // Get information about the SDNode for the operator.
190189 };
191190
192191 void InstrInfoEmitter::InferFromPattern(const CodeGenInstruction &Inst,
193 bool &mayStore, bool &isLoad,
192 bool &mayStore, bool &mayLoad,
194193 bool &NeverHasSideEffects) {
195 mayStore = isLoad = NeverHasSideEffects = false;
196
197 InstAnalyzer(CDP, mayStore, isLoad, NeverHasSideEffects).Analyze(Inst.TheDef);
194 mayStore = mayLoad = NeverHasSideEffects = false;
195
196 InstAnalyzer(CDP, mayStore, mayLoad,NeverHasSideEffects).Analyze(Inst.TheDef);
198197
199198 // InstAnalyzer only correctly analyzes mayStore so far.
200199 if (Inst.mayStore) { // If the .td file explicitly sets mayStore, use it.
209208 }
210209
211210 // These two override everything.
212 isLoad = Inst.isSimpleLoad;
211 mayLoad = Inst.mayLoad;
213212 NeverHasSideEffects = Inst.neverHasSideEffects;
214213
215214 #if 0
280279 const OperandInfoMapTy &OpInfo,
281280 std::ostream &OS) {
282281 // Determine properties of the instruction from its pattern.
283 bool mayStore, isSimpleLoad, NeverHasSideEffects;
284 InferFromPattern(Inst, mayStore, isSimpleLoad, NeverHasSideEffects);
282 bool mayStore, mayLoad, NeverHasSideEffects;
283 InferFromPattern(Inst, mayStore, mayLoad, NeverHasSideEffects);
285284
286285 if (NeverHasSideEffects && Inst.mayHaveSideEffects) {
287286 std::cerr << "error: Instruction '" << Inst.TheDef->getName()
307306 if (Inst.isBarrier) OS << "|(1<
308307 if (Inst.hasDelaySlot) OS << "|(1<
309308 if (Inst.isCall) OS << "|(1<
310 if (isSimpleLoad) OS << "|(1<
309 if (Inst.isSimpleLoad) OS << "|(1<
310 if (mayLoad) OS << "|(1<
311311 if (mayStore) OS << "|(1<
312312 if (Inst.isImplicitDef)OS << "|(1<
313313 if (Inst.isPredicable) OS << "|(1<