From cc86964ab3b2925fbb30a9fc7f2a238a58a29e02 Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Tue, 8 Nov 2016 12:29:17 -0800 Subject: [PATCH] Move ast, xform, and legalize modules. - cdsl.ast defines classes representing abstract syntax trees. - cdsl.xform defines classes for instruction transformations. - base.legalize defines legalization patterns. --- lib/cretonne/meta/{cretonne => base}/legalize.py | 12 ++++++------ lib/cretonne/meta/{cretonne => cdsl}/ast.py | 2 +- lib/cretonne/meta/cdsl/instructions.py | 4 ++-- lib/cretonne/meta/{cretonne => cdsl}/test_ast.py | 0 lib/cretonne/meta/{cretonne => cdsl}/test_xform.py | 0 lib/cretonne/meta/{cretonne => cdsl}/xform.py | 3 ++- lib/cretonne/meta/gen_legalizer.py | 6 +++--- 7 files changed, 14 insertions(+), 13 deletions(-) rename lib/cretonne/meta/{cretonne => base}/legalize.py (91%) rename lib/cretonne/meta/{cretonne => cdsl}/ast.py (99%) rename lib/cretonne/meta/{cretonne => cdsl}/test_ast.py (100%) rename lib/cretonne/meta/{cretonne => cdsl}/test_xform.py (100%) rename lib/cretonne/meta/{cretonne => cdsl}/xform.py (99%) diff --git a/lib/cretonne/meta/cretonne/legalize.py b/lib/cretonne/meta/base/legalize.py similarity index 91% rename from lib/cretonne/meta/cretonne/legalize.py rename to lib/cretonne/meta/base/legalize.py index dd534cf108..f054d16d9e 100644 --- a/lib/cretonne/meta/cretonne/legalize.py +++ b/lib/cretonne/meta/base/legalize.py @@ -7,12 +7,12 @@ patterns that describe how base instructions can be transformed to other base instructions that are legal. """ from __future__ import absolute_import -from base.instructions import iadd, iadd_cout, iadd_cin, iadd_carry -from base.instructions import isub, isub_bin, isub_bout, isub_borrow -from base.instructions import band, bor, bxor, isplit_lohi, iconcat_lohi -from base.instructions import icmp -from .ast import Var -from .xform import Rtl, XFormGroup +from .instructions import iadd, iadd_cout, iadd_cin, iadd_carry +from .instructions import isub, isub_bin, isub_bout, isub_borrow +from .instructions import band, bor, bxor, isplit_lohi, iconcat_lohi +from .instructions import icmp +from cdsl.ast import Var +from cdsl.xform import Rtl, XFormGroup narrow = XFormGroup('narrow', """ diff --git a/lib/cretonne/meta/cretonne/ast.py b/lib/cretonne/meta/cdsl/ast.py similarity index 99% rename from lib/cretonne/meta/cretonne/ast.py rename to lib/cretonne/meta/cdsl/ast.py index 0212de7a0b..853437e4e5 100644 --- a/lib/cretonne/meta/cretonne/ast.py +++ b/lib/cretonne/meta/cdsl/ast.py @@ -5,7 +5,7 @@ This module defines classes that can be used to create abstract syntax trees for patern matching an rewriting of cretonne instructions. """ from __future__ import absolute_import -from cdsl import instructions +from . import instructions try: from typing import Union, Tuple # noqa diff --git a/lib/cretonne/meta/cdsl/instructions.py b/lib/cretonne/meta/cdsl/instructions.py index da9f5bb179..8132f144f6 100644 --- a/lib/cretonne/meta/cdsl/instructions.py +++ b/lib/cretonne/meta/cdsl/instructions.py @@ -259,7 +259,7 @@ class Instruction(object): Create an `ast.Apply` AST node representing the application of this instruction to the arguments. """ - from cretonne.ast import Apply + from .ast import Apply return Apply(self, args) @@ -312,5 +312,5 @@ class BoundInstruction(object): Create an `ast.Apply` AST node representing the application of this instruction to the arguments. """ - from cretonne.ast import Apply + from .ast import Apply return Apply(self, args) diff --git a/lib/cretonne/meta/cretonne/test_ast.py b/lib/cretonne/meta/cdsl/test_ast.py similarity index 100% rename from lib/cretonne/meta/cretonne/test_ast.py rename to lib/cretonne/meta/cdsl/test_ast.py diff --git a/lib/cretonne/meta/cretonne/test_xform.py b/lib/cretonne/meta/cdsl/test_xform.py similarity index 100% rename from lib/cretonne/meta/cretonne/test_xform.py rename to lib/cretonne/meta/cdsl/test_xform.py diff --git a/lib/cretonne/meta/cretonne/xform.py b/lib/cretonne/meta/cdsl/xform.py similarity index 99% rename from lib/cretonne/meta/cretonne/xform.py rename to lib/cretonne/meta/cdsl/xform.py index f8f66de85c..164747fac9 100644 --- a/lib/cretonne/meta/cretonne/xform.py +++ b/lib/cretonne/meta/cdsl/xform.py @@ -2,10 +2,11 @@ Instruction transformations. """ from __future__ import absolute_import -from .ast import Def, Var, Apply, Expr # noqa +from .ast import Def, Var, Apply try: from typing import Union, Iterator, Sequence, Iterable # noqa + from .ast import Expr # noqa DefApply = Union[Def, Apply] except ImportError: pass diff --git a/lib/cretonne/meta/gen_legalizer.py b/lib/cretonne/meta/gen_legalizer.py index bd4ff926eb..409ebb7cf2 100644 --- a/lib/cretonne/meta/gen_legalizer.py +++ b/lib/cretonne/meta/gen_legalizer.py @@ -9,12 +9,12 @@ the input instruction. """ from __future__ import absolute_import from srcgen import Formatter -import cretonne.legalize as legalize -from cretonne.ast import Def # noqa -from cretonne.xform import XForm, XFormGroup # noqa +from base import legalize try: from typing import Sequence # noqa + from cdsl.ast import Def # noqa + from cdsl.xform import XForm, XFormGroup # noqa except ImportError: pass