external/mesa
修订版 | d3e9661e8fa101f4159db70161dca0fe6033b7c4 (tree) |
---|---|
时间 | 2015-07-16 22:48:42 |
作者 | Chih-Wei Huang <cwhuang@linu...> |
Commiter | Chih-Wei Huang |
nv50/ir: support different unordered_set implementations
If build with C++11 standard, use std::unordered_set.
Otherwise if build on old Android version with stlport,
use std::tr1::unordered_set with a wrapper class.
Otherwise use std::tr1::unordered_set.
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
@@ -29,8 +29,8 @@ | ||
29 | 29 | #include <deque> |
30 | 30 | #include <list> |
31 | 31 | #include <vector> |
32 | -#include <tr1/unordered_set> | |
33 | 32 | |
33 | +#include "codegen/unordered_set.h" | |
34 | 34 | #include "codegen/nv50_ir_util.h" |
35 | 35 | #include "codegen/nv50_ir_graph.h" |
36 | 36 |
@@ -582,10 +582,10 @@ public: | ||
582 | 582 | |
583 | 583 | static inline Value *get(Iterator&); |
584 | 584 | |
585 | - std::tr1::unordered_set<ValueRef *> uses; | |
585 | + unordered_set<ValueRef *> uses; | |
586 | 586 | std::list<ValueDef *> defs; |
587 | - typedef std::tr1::unordered_set<ValueRef *>::iterator UseIterator; | |
588 | - typedef std::tr1::unordered_set<ValueRef *>::const_iterator UseCIterator; | |
587 | + typedef unordered_set<ValueRef *>::iterator UseIterator; | |
588 | + typedef unordered_set<ValueRef *>::const_iterator UseCIterator; | |
589 | 589 | typedef std::list<ValueDef *>::iterator DefIterator; |
590 | 590 | typedef std::list<ValueDef *>::const_iterator DefCIterator; |
591 | 591 |
@@ -201,7 +201,7 @@ NVC0LegalizePostRA::findFirstUses( | ||
201 | 201 | const Instruction *texi, |
202 | 202 | const Instruction *insn, |
203 | 203 | std::list<TexUse> &uses, |
204 | - std::tr1::unordered_set<const Instruction *>& visited) | |
204 | + unordered_set<const Instruction *>& visited) | |
205 | 205 | { |
206 | 206 | for (int d = 0; insn->defExists(d); ++d) { |
207 | 207 | Value *v = insn->getDef(d); |
@@ -300,7 +300,7 @@ NVC0LegalizePostRA::insertTextureBarriers(Function *fn) | ||
300 | 300 | if (!uses) |
301 | 301 | return false; |
302 | 302 | for (size_t i = 0; i < texes.size(); ++i) { |
303 | - std::tr1::unordered_set<const Instruction *> visited; | |
303 | + unordered_set<const Instruction *> visited; | |
304 | 304 | findFirstUses(texes[i], texes[i], uses[i], visited); |
305 | 305 | } |
306 | 306 |
@@ -20,8 +20,6 @@ | ||
20 | 20 | * OTHER DEALINGS IN THE SOFTWARE. |
21 | 21 | */ |
22 | 22 | |
23 | -#include <tr1/unordered_set> | |
24 | - | |
25 | 23 | #include "codegen/nv50_ir.h" |
26 | 24 | #include "codegen/nv50_ir_build_util.h" |
27 | 25 |
@@ -73,7 +71,7 @@ private: | ||
73 | 71 | inline bool insnDominatedBy(const Instruction *, const Instruction *) const; |
74 | 72 | void findFirstUses(const Instruction *tex, const Instruction *def, |
75 | 73 | std::list<TexUse>&, |
76 | - std::tr1::unordered_set<const Instruction *>&); | |
74 | + unordered_set<const Instruction *>&); | |
77 | 75 | void findOverwritingDefs(const Instruction *tex, Instruction *insn, |
78 | 76 | const BasicBlock *term, |
79 | 77 | std::list<TexUse>&); |
@@ -25,7 +25,6 @@ | ||
25 | 25 | |
26 | 26 | #include <stack> |
27 | 27 | #include <limits> |
28 | -#include <tr1/unordered_set> | |
29 | 28 | |
30 | 29 | namespace nv50_ir { |
31 | 30 |
@@ -1551,7 +1550,7 @@ SpillCodeInserter::run(const std::list<ValuePair>& lst) | ||
1551 | 1550 | // Keep track of which instructions to delete later. Deleting them |
1552 | 1551 | // inside the loop is unsafe since a single instruction may have |
1553 | 1552 | // multiple destinations that all need to be spilled (like OP_SPLIT). |
1554 | - std::tr1::unordered_set<Instruction *> to_del; | |
1553 | + unordered_set<Instruction *> to_del; | |
1555 | 1554 | |
1556 | 1555 | for (Value::DefIterator d = lval->defs.begin(); d != lval->defs.end(); |
1557 | 1556 | ++d) { |
@@ -1593,7 +1592,7 @@ SpillCodeInserter::run(const std::list<ValuePair>& lst) | ||
1593 | 1592 | } |
1594 | 1593 | } |
1595 | 1594 | |
1596 | - for (std::tr1::unordered_set<Instruction *>::const_iterator it = to_del.begin(); | |
1595 | + for (unordered_set<Instruction *>::const_iterator it = to_del.begin(); | |
1597 | 1596 | it != to_del.end(); ++it) |
1598 | 1597 | delete_Instruction(func->getProgram(), *it); |
1599 | 1598 | } |
@@ -0,0 +1,48 @@ | ||
1 | +#ifndef __NV50_UNORDERED_SET_H__ | |
2 | +#define __NV50_UNORDERED_SET_H__ | |
3 | + | |
4 | +#if (__cplusplus >= 201103L) || defined(ANDROID) | |
5 | +#include <unordered_set> | |
6 | +#else | |
7 | +#include <tr1/unordered_set> | |
8 | +#endif | |
9 | + | |
10 | +namespace nv50_ir { | |
11 | + | |
12 | +#if __cplusplus >= 201103L | |
13 | +using std::unordered_set; | |
14 | +#elif !defined(ANDROID) | |
15 | +using std::tr1::unordered_set; | |
16 | +#else // Android release before lollipop | |
17 | +using std::isfinite; | |
18 | +typedef std::tr1::unordered_set<void *> voidptr_unordered_set; | |
19 | + | |
20 | +template <typename V> | |
21 | +class unordered_set : public voidptr_unordered_set { | |
22 | + public: | |
23 | + typedef voidptr_unordered_set _base; | |
24 | + typedef _base::iterator _biterator; | |
25 | + typedef _base::const_iterator const_biterator; | |
26 | + | |
27 | + class iterator : public _biterator { | |
28 | + public: | |
29 | + iterator(const _biterator & i) : _biterator(i) {} | |
30 | + V operator*() const { return reinterpret_cast<V>(*_biterator(*this)); } | |
31 | + }; | |
32 | + class const_iterator : public const_biterator { | |
33 | + public: | |
34 | + const_iterator(const iterator & i) : const_biterator(i) {} | |
35 | + const_iterator(const const_biterator & i) : const_biterator(i) {} | |
36 | + const V operator*() const { return reinterpret_cast<const V>(*const_biterator(*this)); } | |
37 | + }; | |
38 | + | |
39 | + iterator begin() { return _base::begin(); } | |
40 | + iterator end() { return _base::end(); } | |
41 | + const_iterator begin() const { return _base::begin(); } | |
42 | + const_iterator end() const { return _base::end(); } | |
43 | +}; | |
44 | +#endif | |
45 | + | |
46 | +} // namespace nv50_ir | |
47 | + | |
48 | +#endif // __NV50_UNORDERED_SET_H__ |