Line data Source code
1 : #include "optimizer/util.hpp" 2 : #include "optimizer/controlflow.hpp" 3 : #include "optimizer/acyclicgraph.hpp" 4 : 5 : template<typename T> 6 11727 : int find(std::vector<T> vec, T x) { 7 65707 : for (int i = 0; i < vec.size(); i++) { 8 60099 : if (vec[i] == x) return i; 9 : } 10 5608 : return -1; 11 : } 12 : 13 : template<typename K, typename V> 14 36 : int find(std::vector<std::pair<K, V>> vec, K x) { 15 57 : for (int i = 0; i < vec.size(); i++) { 16 40 : if (vec[i].first == x) return i; 17 : } 18 17 : return -1; 19 : } 20 : 21 : template<typename K, typename V> 22 96 : int find(std::vector<std::pair<K, V>> vec, V x) { 23 144 : for (int i = 0; i < vec.size(); i++) { 24 144 : if (vec[i].second == x) return i; 25 : } 26 0 : return -1; 27 : } 28 : 29 329 : void copyPOLIZ(POLIZ & src, POLIZ & dst, int start, int end) { 30 329 : int j = dst.getSize(); 31 1568 : for (int i = start; i < end; i++) { 32 1239 : dst.getEB()[j] = src.getEB()[i]; 33 1239 : dst.getProg()[j] = src.getProg()[i]; 34 1239 : dst.incIter(); 35 1239 : j++; 36 : } 37 329 : } 38 : 39 : template int find(std::vector<int> vec, int x); 40 : template int find(std::vector<flowTree*>, flowTree*); 41 : template int find(std::vector<DAGRow*>, DAGRow*); 42 : template int find(std::vector<std::pair<flowTree*, char>>, flowTree*); 43 : template int find(std::vector<std::pair<flowTree*, char>>, char); 44 : template int find(std::vector<std::pair<IdentTable*, DAGRow*>>, IdentTable*);