AliasAnalysis.h (1491B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- 2 * vim: set ts=8 sts=2 et sw=2 tw=80: 3 * This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef jit_AliasAnalysis_h 8 #define jit_AliasAnalysis_h 9 10 #include "jit/MIR-wasm.h" 11 #include "jit/MIR.h" 12 #include "jit/MIRGraph.h" 13 14 namespace js { 15 namespace jit { 16 17 class LoopAliasInfo; 18 19 class AliasAnalysis { 20 const MIRGenerator* mir; 21 MIRGraph& graph_; 22 LoopAliasInfo* loop_; 23 24 void spewDependencyList(); 25 26 TempAllocator& alloc() const { return graph_.alloc(); } 27 28 public: 29 AliasAnalysis(const MIRGenerator* mir, MIRGraph& graph) 30 : mir(mir), graph_(graph), loop_(nullptr) {} 31 32 [[nodiscard]] bool analyze(); 33 }; 34 35 // Iterates over the flags in an AliasSet. 36 class AliasSetIterator { 37 private: 38 uint32_t flags; 39 unsigned pos; 40 41 public: 42 explicit AliasSetIterator(AliasSet set) : flags(set.flags()), pos(0) { 43 while (flags && (flags & 1) == 0) { 44 flags >>= 1; 45 pos++; 46 } 47 } 48 AliasSetIterator& operator++(int) { 49 do { 50 flags >>= 1; 51 pos++; 52 } while (flags && (flags & 1) == 0); 53 return *this; 54 } 55 explicit operator bool() const { return !!flags; } 56 unsigned operator*() const { 57 MOZ_ASSERT(pos < AliasSet::NumCategories); 58 return pos; 59 } 60 }; 61 62 } // namespace jit 63 } // namespace js 64 65 #endif /* jit_AliasAnalysis_h */