blob: 5946dcb61e6de68b44b90da18b7e494ba48c1cb7 [file] [log] [blame]
Ben Olmsteadc0d77842019-07-31 17:34:05 -07001# Copyright 2019 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# Shared utilities for Emboss back ends.
16
Ted Pudlik4a044db2024-04-10 15:56:42 -070017load("@rules_python//python:py_library.bzl", "py_library")
18load("@rules_python//python:py_test.bzl", "py_test")
19
Ben Olmsteadc0d77842019-07-31 17:34:05 -070020package(
reventlov6731fc42019-10-03 15:23:13 -070021 default_visibility = ["//compiler:__subpackages__"],
22)
23
24py_library(
Eric Rahm12c5e842024-03-22 09:37:24 -070025 name = "ir_data",
reventlov6731fc42019-10-03 15:23:13 -070026 srcs = [
Eric Rahm12c5e842024-03-22 09:37:24 -070027 "ir_data.py",
Eric Rahm79946532024-04-12 11:44:44 -070028 "ir_data_utils.py",
reventlov6731fc42019-10-03 15:23:13 -070029 ],
Ben Olmsteadc0d77842019-07-31 17:34:05 -070030)
31
32py_library(
33 name = "expression_parser",
34 srcs = ["expression_parser.py"],
35 deps = [
reventlov6731fc42019-10-03 15:23:13 -070036 "//compiler/front_end:module_ir",
37 "//compiler/front_end:parser",
38 "//compiler/front_end:tokenizer",
Ben Olmsteadc0d77842019-07-31 17:34:05 -070039 ],
40)
41
42py_library(
43 name = "ir_util",
44 srcs = ["ir_util.py"],
Eric Rahm12c5e842024-03-22 09:37:24 -070045 deps = [":ir_data"],
Ben Olmsteadc0d77842019-07-31 17:34:05 -070046)
47
48py_test(
49 name = "ir_util_test",
50 srcs = ["ir_util_test.py"],
51 python_version = "PY3",
52 deps = [
53 ":expression_parser",
Eric Rahm12c5e842024-03-22 09:37:24 -070054 ":ir_data",
Dmitri Prime5b381262023-05-01 23:55:07 -070055 ":ir_util",
56 ],
57)
58
59py_library(
60 name = "attribute_util",
61 srcs = ["attribute_util.py"],
62 deps = [
63 ":error",
Eric Rahm12c5e842024-03-22 09:37:24 -070064 ":ir_data",
Dmitri Prime5b381262023-05-01 23:55:07 -070065 ":ir_util",
66 ":traverse_ir",
Ben Olmsteadc0d77842019-07-31 17:34:05 -070067 ],
68)
69
70py_library(
71 name = "simple_memoizer",
72 srcs = ["simple_memoizer.py"],
73 deps = [],
74)
75
76py_test(
77 name = "simple_memoizer_test",
78 srcs = ["simple_memoizer_test.py"],
79 python_version = "PY3",
80 deps = [
81 ":simple_memoizer",
82 ],
83)
84
85py_library(
Jason Graffius91910772023-05-18 12:43:52 -040086 name = "test_util",
87 testonly = 1,
88 srcs = ["test_util.py"],
89 deps = [],
90)
91
92py_test(
93 name = "test_util_test",
94 srcs = ["test_util_test.py"],
95 python_version = "PY3",
96 deps = [
97 ":test_util",
Eric Rahm12c5e842024-03-22 09:37:24 -070098 "//compiler/util:ir_data",
Jason Graffius91910772023-05-18 12:43:52 -040099 "//compiler/util:parser_types",
100 ],
101)
102
103py_library(
Ben Olmsteadc0d77842019-07-31 17:34:05 -0700104 name = "traverse_ir",
105 srcs = ["traverse_ir.py"],
106 deps = [
Ted Pudlik4a044db2024-04-10 15:56:42 -0700107 ":simple_memoizer",
Eric Rahm12c5e842024-03-22 09:37:24 -0700108 ":ir_data",
Ben Olmsteadc0d77842019-07-31 17:34:05 -0700109 ],
110)
111
112py_test(
113 name = "traverse_ir_test",
114 srcs = ["traverse_ir_test.py"],
115 python_version = "PY3",
116 deps = [
Ted Pudlik4a044db2024-04-10 15:56:42 -0700117 ":traverse_ir",
Eric Rahm12c5e842024-03-22 09:37:24 -0700118 ":ir_data",
Ben Olmsteadc0d77842019-07-31 17:34:05 -0700119 ],
120)
121
122py_library(
123 name = "parser_types",
124 srcs = ["parser_types.py"],
125 deps = [
Eric Rahm12c5e842024-03-22 09:37:24 -0700126 ":ir_data",
Ben Olmsteadc0d77842019-07-31 17:34:05 -0700127 ],
128)
129
130py_test(
131 name = "parser_types_test",
132 srcs = ["parser_types_test.py"],
133 python_version = "PY3",
134 deps = [
Ted Pudlik4a044db2024-04-10 15:56:42 -0700135 ":parser_types",
Eric Rahm12c5e842024-03-22 09:37:24 -0700136 ":ir_data",
Ben Olmsteadc0d77842019-07-31 17:34:05 -0700137 ],
138)
139
140py_library(
141 name = "error",
142 srcs = [
143 "error.py",
144 ],
145 deps = [
146 ":parser_types",
147 ],
148)
149
150py_test(
151 name = "error_test",
152 srcs = ["error_test.py"],
153 python_version = "PY3",
154 deps = [
155 ":error",
156 ":parser_types",
157 ],
158)
159
160py_library(
161 name = "name_conversion",
162 srcs = ["name_conversion.py"],
163 deps = [],
164)
165
166py_test(
167 name = "name_conversion_test",
168 srcs = ["name_conversion_test.py"],
169 python_version = "PY3",
170 deps = [
171 ":name_conversion",
172 ],
173)
Ben Olmsteadb9b93c32024-02-20 21:47:41 +0000174
175py_library(
176 name = "resources",
177 srcs = ["resources.py"],
178 deps = [],
179)