Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor[venom]: refactor module structure #4295

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions tests/unit/compiler/venom/test_algebraic_optimizer.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import pytest

from vyper.venom.analysis.analysis import IRAnalysesCache
from vyper.venom.analysis import IRAnalysesCache
from vyper.venom.basicblock import IRBasicBlock, IRLabel
from vyper.venom.context import IRContext
from vyper.venom.passes.algebraic_optimization import AlgebraicOptimizationPass
from vyper.venom.passes.make_ssa import MakeSSA
from vyper.venom.passes.remove_unused_variables import RemoveUnusedVariablesPass
from vyper.venom.passes import AlgebraicOptimizationPass, MakeSSA, RemoveUnusedVariablesPass


@pytest.mark.parametrize("iszero_count", range(5))
Expand Down
6 changes: 2 additions & 4 deletions tests/unit/compiler/venom/test_branch_optimizer.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from vyper.venom.analysis.analysis import IRAnalysesCache
from vyper.venom.analysis.dfg import DFGAnalysis
from vyper.venom.analysis import DFGAnalysis, IRAnalysesCache
from vyper.venom.basicblock import IRBasicBlock, IRLabel
from vyper.venom.context import IRContext
from vyper.venom.passes.branch_optimization import BranchOptimizationPass
from vyper.venom.passes.make_ssa import MakeSSA
from vyper.venom.passes import BranchOptimizationPass, MakeSSA


def test_simple_jump_case():
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/compiler/venom/test_dominator_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

from vyper.exceptions import CompilerPanic
from vyper.utils import OrderedSet
from vyper.venom.analysis.analysis import IRAnalysesCache
from vyper.venom.analysis.dominators import DominatorTreeAnalysis
from vyper.venom.analysis import DominatorTreeAnalysis, IRAnalysesCache
from vyper.venom.basicblock import IRBasicBlock, IRInstruction, IRLabel, IRLiteral, IRVariable
from vyper.venom.context import IRContext
from vyper.venom.function import IRFunction
from vyper.venom.passes.make_ssa import MakeSSA
from vyper.venom.passes import MakeSSA


def _add_bb(
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/compiler/venom/test_duplicate_operands.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from vyper.compiler.settings import OptimizationLevel
from vyper.venom import generate_assembly_experimental
from vyper.venom.analysis.analysis import IRAnalysesCache
from vyper.venom.analysis import IRAnalysesCache
from vyper.venom.context import IRContext
from vyper.venom.passes.store_expansion import StoreExpansionPass
from vyper.venom.passes import StoreExpansionPass


def test_duplicate_operands():
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/compiler/venom/test_make_ssa.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from vyper.venom.analysis.analysis import IRAnalysesCache
from vyper.venom.analysis import IRAnalysesCache
from vyper.venom.basicblock import IRBasicBlock, IRLabel
from vyper.venom.context import IRContext
from vyper.venom.passes.make_ssa import MakeSSA
from vyper.venom.passes import MakeSSA


def test_phi_case():
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/compiler/venom/test_multi_entry_block.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from vyper.venom.analysis.analysis import IRAnalysesCache
from vyper.venom.analysis.cfg import CFGAnalysis
from vyper.venom.analysis import CFGAnalysis, IRAnalysesCache
from vyper.venom.context import IRContext
from vyper.venom.function import IRBasicBlock, IRLabel
from vyper.venom.passes.normalization import NormalizationPass
from vyper.venom.passes import NormalizationPass


def test_multi_entry_block_1():
Expand Down
5 changes: 2 additions & 3 deletions tests/unit/compiler/venom/test_sccp.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import pytest

from vyper.exceptions import StaticAssertionException
from vyper.venom.analysis.analysis import IRAnalysesCache
from vyper.venom.analysis import IRAnalysesCache
from vyper.venom.basicblock import IRBasicBlock, IRLabel, IRLiteral, IRVariable
from vyper.venom.context import IRContext
from vyper.venom.passes.make_ssa import MakeSSA
from vyper.venom.passes.sccp import SCCP
from vyper.venom.passes import SCCP, MakeSSA
from vyper.venom.passes.sccp.sccp import LatticeEnum


Expand Down
5 changes: 2 additions & 3 deletions tests/unit/compiler/venom/test_simplify_cfg.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from vyper.venom.analysis.analysis import IRAnalysesCache
from vyper.venom.analysis import IRAnalysesCache
from vyper.venom.basicblock import IRBasicBlock, IRLabel, IRLiteral
from vyper.venom.context import IRContext
from vyper.venom.passes.sccp import SCCP
from vyper.venom.passes.simplify_cfg import SimplifyCFGPass
from vyper.venom.passes import SCCP, SimplifyCFGPass


def test_phi_reduction_after_block_pruning():
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/compiler/venom/test_stack_reorder.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from vyper.venom import generate_assembly_experimental
from vyper.venom.analysis.analysis import IRAnalysesCache
from vyper.venom.analysis import IRAnalysesCache
from vyper.venom.context import IRContext
from vyper.venom.passes.store_expansion import StoreExpansionPass
from vyper.venom.passes import StoreExpansionPass


def test_stack_reorder():
Expand Down
22 changes: 12 additions & 10 deletions vyper/venom/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@
from vyper.venom.context import IRContext
from vyper.venom.function import IRFunction
from vyper.venom.ir_node_to_venom import ir_node_to_venom
from vyper.venom.passes.algebraic_optimization import AlgebraicOptimizationPass
from vyper.venom.passes.branch_optimization import BranchOptimizationPass
from vyper.venom.passes.dft import DFTPass
from vyper.venom.passes.make_ssa import MakeSSA
from vyper.venom.passes.mem2var import Mem2Var
from vyper.venom.passes.remove_unused_variables import RemoveUnusedVariablesPass
from vyper.venom.passes.sccp import SCCP
from vyper.venom.passes.simplify_cfg import SimplifyCFGPass
from vyper.venom.passes.store_elimination import StoreElimination
from vyper.venom.passes.store_expansion import StoreExpansionPass
from vyper.venom.passes import (
SCCP,
AlgebraicOptimizationPass,
BranchOptimizationPass,
DFTPass,
MakeSSA,
Mem2Var,
RemoveUnusedVariablesPass,
SimplifyCFGPass,
StoreElimination,
StoreExpansionPass,
)
from vyper.venom.venom_to_assembly import VenomCompiler

DEFAULT_OPT_LEVEL = OptimizationLevel.default()
Expand Down
6 changes: 6 additions & 0 deletions vyper/venom/analysis/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from .analysis import IRAnalysesCache, IRAnalysis
from .cfg import CFGAnalysis
from .dfg import DFGAnalysis
from .dominators import DominatorTreeAnalysis
from .equivalent_vars import VarEquivalenceAnalysis
from .liveness import LivenessAnalysis
5 changes: 2 additions & 3 deletions vyper/venom/analysis/cfg.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from vyper.utils import OrderedSet
from vyper.venom.analysis.analysis import IRAnalysis
from vyper.venom.analysis import IRAnalysis
from vyper.venom.basicblock import CFG_ALTERING_INSTRUCTIONS


Expand Down Expand Up @@ -32,8 +32,7 @@ def analyze(self) -> None:
in_bb.add_cfg_out(bb)

def invalidate(self):
from vyper.venom.analysis.dominators import DominatorTreeAnalysis
from vyper.venom.analysis.liveness import LivenessAnalysis
from vyper.venom.analysis import DominatorTreeAnalysis, LivenessAnalysis

self.analyses_cache.invalidate_analysis(DominatorTreeAnalysis)
self.analyses_cache.invalidate_analysis(LivenessAnalysis)
3 changes: 1 addition & 2 deletions vyper/venom/analysis/dfg.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Optional

from vyper.venom.analysis.analysis import IRAnalysesCache, IRAnalysis
from vyper.venom.analysis.liveness import LivenessAnalysis
from vyper.venom.analysis import IRAnalysesCache, IRAnalysis, LivenessAnalysis
from vyper.venom.basicblock import IRInstruction, IRVariable
from vyper.venom.function import IRFunction

Expand Down
3 changes: 1 addition & 2 deletions vyper/venom/analysis/dominators.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from vyper.exceptions import CompilerPanic
from vyper.utils import OrderedSet
from vyper.venom.analysis.analysis import IRAnalysis
from vyper.venom.analysis.cfg import CFGAnalysis
from vyper.venom.analysis import CFGAnalysis, IRAnalysis
from vyper.venom.basicblock import IRBasicBlock
from vyper.venom.function import IRFunction

Expand Down
3 changes: 1 addition & 2 deletions vyper/venom/analysis/equivalent_vars.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from vyper.venom.analysis.analysis import IRAnalysis
from vyper.venom.analysis.dfg import DFGAnalysis
from vyper.venom.analysis import DFGAnalysis, IRAnalysis
from vyper.venom.basicblock import IRVariable


Expand Down
3 changes: 1 addition & 2 deletions vyper/venom/analysis/liveness.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

from vyper.exceptions import CompilerPanic
from vyper.utils import OrderedSet
from vyper.venom.analysis.analysis import IRAnalysis
from vyper.venom.analysis.cfg import CFGAnalysis
from vyper.venom.analysis import CFGAnalysis, IRAnalysis
from vyper.venom.basicblock import IRBasicBlock, IRVariable


Expand Down
11 changes: 11 additions & 0 deletions vyper/venom/passes/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from .algebraic_optimization import AlgebraicOptimizationPass
from .branch_optimization import BranchOptimizationPass
from .dft import DFTPass
from .make_ssa import MakeSSA
from .mem2var import Mem2Var
from .normalization import NormalizationPass
from .remove_unused_variables import RemoveUnusedVariablesPass
from .sccp import SCCP
from .simplify_cfg import SimplifyCFGPass
from .store_elimination import StoreElimination
from .store_expansion import StoreExpansionPass
3 changes: 1 addition & 2 deletions vyper/venom/passes/algebraic_optimization.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from vyper.venom.analysis.dfg import DFGAnalysis
from vyper.venom.analysis.liveness import LivenessAnalysis
from vyper.venom.analysis import DFGAnalysis, LivenessAnalysis
from vyper.venom.basicblock import IRInstruction, IRLabel, IRLiteral, IROperand
from vyper.venom.passes.base_pass import IRPass

Expand Down
2 changes: 1 addition & 1 deletion vyper/venom/passes/base_pass.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from vyper.venom.analysis.analysis import IRAnalysesCache
from vyper.venom.analysis import IRAnalysesCache
from vyper.venom.function import IRFunction


Expand Down
2 changes: 1 addition & 1 deletion vyper/venom/passes/branch_optimization.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from vyper.venom.analysis.dfg import DFGAnalysis
from vyper.venom.analysis import DFGAnalysis
from vyper.venom.passes.base_pass import IRPass


Expand Down
2 changes: 1 addition & 1 deletion vyper/venom/passes/dft.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from vyper.utils import OrderedSet
from vyper.venom.analysis.dfg import DFGAnalysis
from vyper.venom.analysis import DFGAnalysis
from vyper.venom.basicblock import IRBasicBlock, IRInstruction, IRVariable
from vyper.venom.function import IRFunction
from vyper.venom.passes.base_pass import IRPass
Expand Down
4 changes: 1 addition & 3 deletions vyper/venom/passes/make_ssa.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from vyper.utils import OrderedSet
from vyper.venom.analysis.cfg import CFGAnalysis
from vyper.venom.analysis.dominators import DominatorTreeAnalysis
from vyper.venom.analysis.liveness import LivenessAnalysis
from vyper.venom.analysis import CFGAnalysis, DominatorTreeAnalysis, LivenessAnalysis
from vyper.venom.basicblock import IRBasicBlock, IRInstruction, IROperand, IRVariable
from vyper.venom.passes.base_pass import IRPass

Expand Down
4 changes: 1 addition & 3 deletions vyper/venom/passes/mem2var.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from vyper.venom.analysis.cfg import CFGAnalysis
from vyper.venom.analysis.dfg import DFGAnalysis
from vyper.venom.analysis.liveness import LivenessAnalysis
from vyper.venom.analysis import CFGAnalysis, DFGAnalysis, LivenessAnalysis
from vyper.venom.basicblock import IRInstruction, IRVariable
from vyper.venom.function import IRFunction
from vyper.venom.passes.base_pass import IRPass
Expand Down
2 changes: 1 addition & 1 deletion vyper/venom/passes/normalization.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from vyper.exceptions import CompilerPanic
from vyper.venom.analysis.cfg import CFGAnalysis
from vyper.venom.analysis import CFGAnalysis
from vyper.venom.basicblock import IRBasicBlock, IRLabel
from vyper.venom.passes.base_pass import IRPass

Expand Down
3 changes: 1 addition & 2 deletions vyper/venom/passes/remove_unused_variables.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from vyper.utils import OrderedSet
from vyper.venom.analysis.dfg import DFGAnalysis
from vyper.venom.analysis.liveness import LivenessAnalysis
from vyper.venom.analysis import DFGAnalysis, LivenessAnalysis
from vyper.venom.basicblock import IRInstruction
from vyper.venom.passes.base_pass import IRPass

Expand Down
4 changes: 1 addition & 3 deletions vyper/venom/passes/sccp/sccp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

from vyper.exceptions import CompilerPanic, StaticAssertionException
from vyper.utils import OrderedSet
from vyper.venom.analysis.analysis import IRAnalysesCache
from vyper.venom.analysis.cfg import CFGAnalysis
from vyper.venom.analysis.dominators import DominatorTreeAnalysis
from vyper.venom.analysis import CFGAnalysis, DominatorTreeAnalysis, IRAnalysesCache
from vyper.venom.basicblock import (
IRBasicBlock,
IRInstruction,
Expand Down
2 changes: 1 addition & 1 deletion vyper/venom/passes/simplify_cfg.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from vyper.exceptions import CompilerPanic
from vyper.utils import OrderedSet
from vyper.venom.analysis.cfg import CFGAnalysis
from vyper.venom.analysis import CFGAnalysis
from vyper.venom.basicblock import IRBasicBlock, IRLabel
from vyper.venom.passes.base_pass import IRPass

Expand Down
23 changes: 0 additions & 23 deletions vyper/venom/passes/stack_reorder.py

This file was deleted.

4 changes: 1 addition & 3 deletions vyper/venom/passes/store_elimination.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from vyper.venom.analysis.cfg import CFGAnalysis
from vyper.venom.analysis.dfg import DFGAnalysis
from vyper.venom.analysis.liveness import LivenessAnalysis
from vyper.venom.analysis import CFGAnalysis, DFGAnalysis, LivenessAnalysis
from vyper.venom.basicblock import IRVariable
from vyper.venom.passes.base_pass import IRPass

Expand Down
3 changes: 1 addition & 2 deletions vyper/venom/passes/store_expansion.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from vyper.venom.analysis.dfg import DFGAnalysis
from vyper.venom.analysis.liveness import LivenessAnalysis
from vyper.venom.analysis import DFGAnalysis, LivenessAnalysis
from vyper.venom.basicblock import IRInstruction, IRLiteral, IRVariable
from vyper.venom.passes.base_pass import IRPass

Expand Down
6 changes: 2 additions & 4 deletions vyper/venom/venom_to_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@
optimize_assembly,
)
from vyper.utils import MemoryPositions, OrderedSet
from vyper.venom.analysis.analysis import IRAnalysesCache
from vyper.venom.analysis.equivalent_vars import VarEquivalenceAnalysis
from vyper.venom.analysis.liveness import LivenessAnalysis
from vyper.venom.analysis import IRAnalysesCache, LivenessAnalysis, VarEquivalenceAnalysis
from vyper.venom.basicblock import (
IRBasicBlock,
IRInstruction,
Expand All @@ -22,7 +20,7 @@
IRVariable,
)
from vyper.venom.context import IRContext
from vyper.venom.passes.normalization import NormalizationPass
from vyper.venom.passes import NormalizationPass
from vyper.venom.stack_model import StackModel

DEBUG_SHOW_COST = False
Expand Down
Loading