Mercurial > hg > CbC > CbC_llvm
comparison utils/TableGen/CodeGenDAGPatterns.h @ 134:3a76565eade5 LLVM5.0.1
update 5.0.1
author | mir3636 |
---|---|
date | Sat, 17 Feb 2018 09:57:20 +0900 |
parents | 803732b1fca8 |
children | c2174574ed3a |
comparison
equal
deleted
inserted
replaced
133:c60214abe0e8 | 134:3a76565eade5 |
---|---|
16 #define LLVM_UTILS_TABLEGEN_CODEGENDAGPATTERNS_H | 16 #define LLVM_UTILS_TABLEGEN_CODEGENDAGPATTERNS_H |
17 | 17 |
18 #include "CodeGenHwModes.h" | 18 #include "CodeGenHwModes.h" |
19 #include "CodeGenIntrinsics.h" | 19 #include "CodeGenIntrinsics.h" |
20 #include "CodeGenTarget.h" | 20 #include "CodeGenTarget.h" |
21 #include "SDNodeProperties.h" | |
21 #include "llvm/ADT/SmallVector.h" | 22 #include "llvm/ADT/SmallVector.h" |
22 #include "llvm/ADT/StringMap.h" | 23 #include "llvm/ADT/StringMap.h" |
23 #include "llvm/ADT/StringSet.h" | 24 #include "llvm/ADT/StringSet.h" |
24 #include "llvm/Support/ErrorHandling.h" | 25 #include "llvm/Support/ErrorHandling.h" |
25 #include "llvm/Support/MathExtras.h" | 26 #include "llvm/Support/MathExtras.h" |
26 #include <algorithm> | 27 #include <algorithm> |
27 #include <array> | 28 #include <array> |
29 #include <functional> | |
28 #include <map> | 30 #include <map> |
29 #include <set> | 31 #include <set> |
30 #include <vector> | 32 #include <vector> |
31 | 33 |
32 namespace llvm { | 34 namespace llvm { |
231 | 233 |
232 bool operator==(const TypeSetByHwMode &VTS) const; | 234 bool operator==(const TypeSetByHwMode &VTS) const; |
233 bool operator!=(const TypeSetByHwMode &VTS) const { return !(*this == VTS); } | 235 bool operator!=(const TypeSetByHwMode &VTS) const { return !(*this == VTS); } |
234 | 236 |
235 void dump() const; | 237 void dump() const; |
236 void validate() const; | 238 bool validate() const; |
237 | 239 |
238 private: | 240 private: |
239 /// Intersect two sets. Return true if anything has changed. | 241 /// Intersect two sets. Return true if anything has changed. |
240 bool intersect(SetType &Out, const SetType &In); | 242 bool intersect(SetType &Out, const SetType &In); |
241 }; | 243 }; |
316 void expandOverloads(TypeSetByHwMode &VTS); | 318 void expandOverloads(TypeSetByHwMode &VTS); |
317 void expandOverloads(TypeSetByHwMode::SetType &Out, | 319 void expandOverloads(TypeSetByHwMode::SetType &Out, |
318 const TypeSetByHwMode::SetType &Legal); | 320 const TypeSetByHwMode::SetType &Legal); |
319 | 321 |
320 struct ValidateOnExit { | 322 struct ValidateOnExit { |
321 ValidateOnExit(TypeSetByHwMode &T) : VTS(T) {} | 323 ValidateOnExit(TypeSetByHwMode &T, TypeInfer &TI) : Infer(TI), VTS(T) {} |
322 ~ValidateOnExit() { VTS.validate(); } | 324 #ifndef NDEBUG |
325 ~ValidateOnExit(); | |
326 #else | |
327 ~ValidateOnExit() {} // Empty destructor with NDEBUG. | |
328 #endif | |
329 TypeInfer &Infer; | |
323 TypeSetByHwMode &VTS; | 330 TypeSetByHwMode &VTS; |
324 }; | 331 }; |
325 | 332 |
326 TreePattern &TP; | 333 TreePattern &TP; |
327 unsigned ForceMode; // Mode to use when set. | 334 unsigned ForceMode; // Mode to use when set. |
483 | 490 |
484 // Is the desired predefined predicate for a load? | 491 // Is the desired predefined predicate for a load? |
485 bool isLoad() const; | 492 bool isLoad() const; |
486 // Is the desired predefined predicate for a store? | 493 // Is the desired predefined predicate for a store? |
487 bool isStore() const; | 494 bool isStore() const; |
495 // Is the desired predefined predicate for an atomic? | |
496 bool isAtomic() const; | |
488 | 497 |
489 /// Is this predicate the predefined unindexed load predicate? | 498 /// Is this predicate the predefined unindexed load predicate? |
490 /// Is this predicate the predefined unindexed store predicate? | 499 /// Is this predicate the predefined unindexed store predicate? |
491 bool isUnindexed() const; | 500 bool isUnindexed() const; |
492 /// Is this predicate the predefined non-extending load predicate? | 501 /// Is this predicate the predefined non-extending load predicate? |
500 /// Is this predicate the predefined non-truncating store predicate? | 509 /// Is this predicate the predefined non-truncating store predicate? |
501 bool isNonTruncStore() const; | 510 bool isNonTruncStore() const; |
502 /// Is this predicate the predefined truncating store predicate? | 511 /// Is this predicate the predefined truncating store predicate? |
503 bool isTruncStore() const; | 512 bool isTruncStore() const; |
504 | 513 |
514 /// Is this predicate the predefined monotonic atomic predicate? | |
515 bool isAtomicOrderingMonotonic() const; | |
516 /// Is this predicate the predefined acquire atomic predicate? | |
517 bool isAtomicOrderingAcquire() const; | |
518 /// Is this predicate the predefined release atomic predicate? | |
519 bool isAtomicOrderingRelease() const; | |
520 /// Is this predicate the predefined acquire-release atomic predicate? | |
521 bool isAtomicOrderingAcquireRelease() const; | |
522 /// Is this predicate the predefined sequentially consistent atomic predicate? | |
523 bool isAtomicOrderingSequentiallyConsistent() const; | |
524 | |
525 /// Is this predicate the predefined acquire-or-stronger atomic predicate? | |
526 bool isAtomicOrderingAcquireOrStronger() const; | |
527 /// Is this predicate the predefined weaker-than-acquire atomic predicate? | |
528 bool isAtomicOrderingWeakerThanAcquire() const; | |
529 | |
530 /// Is this predicate the predefined release-or-stronger atomic predicate? | |
531 bool isAtomicOrderingReleaseOrStronger() const; | |
532 /// Is this predicate the predefined weaker-than-release atomic predicate? | |
533 bool isAtomicOrderingWeakerThanRelease() const; | |
534 | |
505 /// If non-null, indicates that this predicate is a predefined memory VT | 535 /// If non-null, indicates that this predicate is a predefined memory VT |
506 /// predicate for a load/store and returns the ValueType record for the memory VT. | 536 /// predicate for a load/store and returns the ValueType record for the memory VT. |
507 Record *getMemoryVT() const; | 537 Record *getMemoryVT() const; |
508 /// If non-null, indicates that this predicate is a predefined memory VT | 538 /// If non-null, indicates that this predicate is a predefined memory VT |
509 /// predicate (checking only the scalar type) for load/store and returns the | 539 /// predicate (checking only the scalar type) for load/store and returns the |
778 /// getTrees - Return the tree patterns which corresponds to this pattern. | 808 /// getTrees - Return the tree patterns which corresponds to this pattern. |
779 /// | 809 /// |
780 const std::vector<TreePatternNode*> &getTrees() const { return Trees; } | 810 const std::vector<TreePatternNode*> &getTrees() const { return Trees; } |
781 unsigned getNumTrees() const { return Trees.size(); } | 811 unsigned getNumTrees() const { return Trees.size(); } |
782 TreePatternNode *getTree(unsigned i) const { return Trees[i]; } | 812 TreePatternNode *getTree(unsigned i) const { return Trees[i]; } |
813 void setTree(unsigned i, TreePatternNode *Tree) { Trees[i] = Tree; } | |
783 TreePatternNode *getOnlyTree() const { | 814 TreePatternNode *getOnlyTree() const { |
784 assert(Trees.size() == 1 && "Doesn't have exactly one pattern!"); | 815 assert(Trees.size() == 1 && "Doesn't have exactly one pattern!"); |
785 return Trees[0]; | 816 return Trees[0]; |
786 } | 817 } |
787 | 818 |
1027 /// emit. | 1058 /// emit. |
1028 std::vector<PatternToMatch> PatternsToMatch; | 1059 std::vector<PatternToMatch> PatternsToMatch; |
1029 | 1060 |
1030 TypeSetByHwMode LegalVTS; | 1061 TypeSetByHwMode LegalVTS; |
1031 | 1062 |
1063 using PatternRewriterFn = std::function<void (TreePattern *)>; | |
1064 PatternRewriterFn PatternRewriter; | |
1065 | |
1032 public: | 1066 public: |
1033 CodeGenDAGPatterns(RecordKeeper &R); | 1067 CodeGenDAGPatterns(RecordKeeper &R, |
1068 PatternRewriterFn PatternRewriter = nullptr); | |
1034 | 1069 |
1035 CodeGenTarget &getTargetInfo() { return Target; } | 1070 CodeGenTarget &getTargetInfo() { return Target; } |
1036 const CodeGenTarget &getTargetInfo() const { return Target; } | 1071 const CodeGenTarget &getTargetInfo() const { return Target; } |
1037 const TypeSetByHwMode &getLegalTypes() const { return LegalVTS; } | 1072 const TypeSetByHwMode &getLegalTypes() const { return LegalVTS; } |
1038 | 1073 |
1173 bool MadeChange = false; | 1208 bool MadeChange = false; |
1174 for (unsigned i = 0, e = TypeConstraints.size(); i != e; ++i) | 1209 for (unsigned i = 0, e = TypeConstraints.size(); i != e; ++i) |
1175 MadeChange |= TypeConstraints[i].ApplyTypeConstraint(N, *this, TP); | 1210 MadeChange |= TypeConstraints[i].ApplyTypeConstraint(N, *this, TP); |
1176 return MadeChange; | 1211 return MadeChange; |
1177 } | 1212 } |
1213 | |
1178 } // end namespace llvm | 1214 } // end namespace llvm |
1179 | 1215 |
1180 #endif | 1216 #endif |