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

[PyRTG] Refactor for easier downstream inclusion #8398

Open
wants to merge 1 commit into
base: maerhart-rtg-memory-allocation-in-pipeline
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
71 changes: 47 additions & 24 deletions frontends/PyRTG/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,41 @@ include(AddMLIRPython)
add_compile_definitions("MLIR_PYTHON_PACKAGE_PREFIX=pyrtg.circt.")

declare_mlir_python_sources(PyRTGSources
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}"
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/pyrtg"
SOURCES
pyrtg/__init__.py
pyrtg/arrays.py
pyrtg/bags.py
pyrtg/contexts.py
pyrtg/control_flow.py
pyrtg/core.py
pyrtg/index.py
pyrtg/integers.py
pyrtg/labels.py
pyrtg/memories.py
pyrtg/rtg.py
pyrtg/sequences.py
pyrtg/sets.py
pyrtg/support.py
pyrtg/target.py
pyrtg/tests.py
pyrtg/resources.py
pyrtg/rtgtest.py
pyrtg/scf.py
pyrtg/tuples.py
rtgtool/rtgtool.py
__init__.py
base.py
contexts.py
resources.py
rtgtest.py
support.py
)

declare_mlir_python_sources(PyRTGSources.Core
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/pyrtg"
ADD_TO_PARENT PyRTGSources
SOURCES
arrays.py
bags.py
control_flow.py
core.py
index.py
integers.py
labels.py
memories.py
rtg.py
sequences.py
sets.py
target.py
tests.py
scf.py
tuples.py
)

declare_mlir_python_sources(PyRTGToolSources
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/rtgtool"
SOURCES
rtgtool.py
)

################################################################################
Expand Down Expand Up @@ -65,20 +77,31 @@ add_mlir_python_modules(PyRTG_CIRCTPythonModules
)

add_mlir_python_modules(PyRTG
ROOT_PREFIX "${PYRTG_PYTHON_PACKAGE_DIR}/"
INSTALL_PREFIX "python_packages/"
ROOT_PREFIX "${PYRTG_PYTHON_PACKAGE_DIR}/pyrtg"
INSTALL_PREFIX "python_packages/pyrtg"
DECLARED_SOURCES
PyRTGSources
COMMON_CAPI_LINK_LIBS
PyRTG_CIRCTPythonCAPI
)

add_mlir_python_modules(PyRTGTool
ROOT_PREFIX "${PYRTG_PYTHON_PACKAGE_DIR}/rtgtool"
INSTALL_PREFIX "python_packages/pyrtg/rtgtool"
DECLARED_SOURCES
PyRTGToolSources
)

install(TARGETS PyRTG_CIRCTPythonCAPI
DESTINATION python_packages/pyrtg/circt/_mlir_libs
RUNTIME_DEPENDENCIES
PRE_EXCLUDE_REGEXES ".*"
PRE_INCLUDE_REGEXES ".*zlib.*"
COMPONENT PyRTG
)

add_dependencies(PyRTGTool PyRTG)
add_dependencies(install-PyRTGTool install-PyRTG)

add_dependencies(PyRTG PyRTG_CIRCTPythonModules)
add_dependencies(install-PyRTG install-PyRTG_CIRCTPythonModules)
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from __future__ import annotations

from .circt import ir
from .base import ir
from .rtg import rtg
from .index import index
from .core import Value
Expand Down
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/bags.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from __future__ import annotations

from .circt import ir, support
from .base import ir, support
from .rtg import rtg
from .core import Value
from .index import index
Expand Down
9 changes: 9 additions & 0 deletions frontends/PyRTG/src/pyrtg/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

from .circt import ir, support, dialects

import sys

sys.modules[__name__ + '.dialects'] = dialects
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .rtg import rtg
from .rtgtest import rtgtest
from .core import Value
from .circt import ir
from .base import ir
from .support import _FromCirctValue
from .sequences import Sequence

Expand Down
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/control_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .integers import Bool, Integer
from .arrays import Array
from .core import Value
from .circt import ir
from .base import ir
from .scf import scf
from .support import _FromCirctValue

Expand Down
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

from .circt import ir
from .base import ir


class CodeGenRoot:
Expand Down
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

from .support import wrap_opviews_with_values
from .circt.dialects import index
from .base.dialects import index

wrap_opviews_with_values(index, index.__name__)
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/integers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from __future__ import annotations

from .circt import ir
from .base import ir
from .core import Value
from .index import index
from .rtg import rtg
Expand Down
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from __future__ import annotations

from .circt import ir
from .base import ir
from .core import Value
from .rtg import rtg
from .integers import Integer
Expand Down
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/memories.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from .core import Value
from .circt import ir
from .base import ir
from .index import index
from .rtg import rtg
from .integers import Integer
Expand Down
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .rtg import rtg
from .rtgtest import rtgtest
from .core import Value
from .circt import ir
from .base import ir
from .integers import Integer

from typing import Union
Expand Down
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/rtg.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

from .support import wrap_opviews_with_values
from .circt.dialects import rtg
from .base.dialects import rtg

wrap_opviews_with_values(rtg, rtg.__name__)
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/rtgtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

from .support import wrap_opviews_with_values
from .circt.dialects import rtgtest
from .base.dialects import rtgtest

wrap_opviews_with_values(rtgtest, rtgtest.__name__)
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/scf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

from .support import wrap_opviews_with_values
from .circt.dialects import scf
from .base.dialects import scf

wrap_opviews_with_values(scf, scf.__name__, ["IfOp", "ForOp"])
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from .core import CodeGenRoot, Value
from .support import _FromCirctValue
from .circt import ir, support
from .base import ir, support
from .rtg import rtg


Expand Down
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from __future__ import annotations

from .circt import ir, support
from .base import ir, support
from .rtg import rtg
from .core import Value

Expand Down
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

from .circt import support, ir
from .base import support, ir
from .core import Value


Expand Down
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from __future__ import annotations

from .core import CodeGenRoot, Value
from .circt import ir
from .base import ir
from .rtg import rtg


Expand Down
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

from .circt import ir
from .base import ir
from .core import CodeGenRoot
from .rtg import rtg
from .support import _FromCirctValue
Expand Down
2 changes: 1 addition & 1 deletion frontends/PyRTG/src/pyrtg/tuples.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from __future__ import annotations

from .circt import ir
from .base import ir
from .rtg import rtg
from .core import Value

Expand Down
1 change: 1 addition & 0 deletions frontends/PyRTG/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
set(PyRTG_TEST_DEPENDS
FileCheck count not
PyRTG
PyRTGTool
)

configure_lit_site_cfg(
Expand Down
Loading