freedreno/registers: split header build into subdirs

Instead of building the adreno/foo.xml headers from the toplevel, split
out a subdir().  This fits better with how meson likes things to be
structured.  But it does require fixing a bit about how gen_header.py
resolves imports, ie. it cannot assume the src file is at the root of
the $RNN_PATH.

This is needed for the next patch, to add support for installing the
register database for use with installed tools.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6154>
This commit is contained in:
Rob Clark
2020-08-02 11:35:48 -07:00
committed by Marge Bot
parent e59b241213
commit 62ebd342e6
10 changed files with 87 additions and 53 deletions

View File

@@ -25,9 +25,9 @@
#include "util/u_math.h"
#include "registers/adreno_pm4.xml.h"
#include "registers/adreno_common.xml.h"
#include "registers/a6xx.xml.h"
#include "adreno_pm4.xml.h"
#include "adreno_common.xml.h"
#include "a6xx.xml.h"
#include "main.h"
#include "ir3_asm.h"

View File

@@ -31,8 +31,8 @@
#include "drm/freedreno_drmif.h"
#include "drm/freedreno_ringbuffer.h"
#include "registers/adreno_pm4.xml.h"
#include "registers/adreno_common.xml.h"
#include "adreno_pm4.xml.h"
#include "adreno_common.xml.h"
#define MAX_BUFS 4

View File

@@ -18,7 +18,7 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
inc_freedreno = include_directories(['.', './registers', './common'])
inc_freedreno = include_directories(['.', './registers', './registers/adreno', './common'])
inc_freedreno_rnn = include_directories('rnn')
rnn_src_path = meson.source_root() + '/src/freedreno/registers'

View File

@@ -0,0 +1,56 @@
# Copyright © 2019 Google, Inc
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
xml_files = [
'a2xx.xml',
'a3xx.xml',
'a4xx.xml',
'a5xx.xml',
'a6xx.xml',
'adreno_common.xml',
'adreno_pm4.xml',
]
foreach f : xml_files
_name = f + '.h'
freedreno_xml_header_files += custom_target(
_name,
input: [gen_header_py, f],
output: _name,
command: [prog_python, '@INPUT0@', rnn_src_path, '@INPUT1@'],
capture: true,
)
endforeach
freedreno_xml_header_files += custom_target(
'a6xx-pack.xml.h',
input: [gen_header_py, 'a6xx.xml'],
output: 'a6xx-pack.xml.h',
command: [prog_python, '@INPUT0@', rnn_src_path, '@INPUT1@', '--pack-structs'],
capture: true,
)
freedreno_xml_header_files += custom_target(
'adreno-pm4-pack.xml.h',
input: [gen_header_py, 'adreno_pm4.xml'],
output: 'adreno-pm4-pack.xml.h',
command: [prog_python, '@INPUT0@', rnn_src_path, '@INPUT1@', '--pack-structs'],
capture: true,
)

View File

@@ -335,14 +335,7 @@ class Parser(object):
raise self.error(e);
def do_parse(self, filename):
try:
file = open(filename, "rb")
except FileNotFoundError as e:
# Look for the file in the parent directory if not
# found in same directory:
path = os.path.dirname(filename)
base = os.path.basename(filename)
file = open(path + "/../" + base, "rb")
file = open(filename, "rb")
parser = xml.parsers.expat.ParserCreate()
self.stack.append((parser, filename))
parser.StartElementHandler = self.start_element
@@ -351,8 +344,8 @@ class Parser(object):
self.stack.pop()
file.close()
def parse(self, filename):
self.path = os.path.dirname(filename)
def parse(self, rnn_path, filename):
self.path = rnn_path
self.stack = []
self.do_parse(filename)
@@ -373,7 +366,7 @@ class Parser(object):
def start_element(self, name, attrs):
if name == "import":
filename = os.path.basename(attrs["file"])
filename = attrs["file"]
self.do_parse(os.path.join(self.path, filename))
elif name == "domain":
self.current_domain = attrs["name"]
@@ -449,8 +442,9 @@ class Parser(object):
def main():
p = Parser()
xml_file = sys.argv[1]
if len(sys.argv) > 2 and sys.argv[2] == '--pack-structs':
rnn_path = sys.argv[1]
xml_file = sys.argv[2]
if len(sys.argv) > 3 and sys.argv[3] == '--pack-structs':
do_structs = True
guard = str.replace(os.path.basename(xml_file), '.', '_').upper() + '_STRUCTS'
else:
@@ -460,7 +454,7 @@ def main():
print("#ifndef %s\n#define %s\n" % (guard, guard))
try:
p.parse(xml_file)
p.parse(rnn_path, xml_file)
except Error as e:
print(e)
exit(1)

View File

@@ -19,38 +19,22 @@
# SOFTWARE.
xml_files = [
'a2xx.xml',
'a3xx.xml',
'a4xx.xml',
'a5xx.xml',
'a6xx.xml',
'adreno_common.xml',
'adreno_pm4.xml',
'adreno.xml',
]
gen_header_py = files('gen_header.py')
freedreno_xml_header_files = []
foreach f : xml_files
_name = f + '.h'
freedreno_xml_header_files += custom_target(
_name,
input : ['gen_header.py', 'adreno/' + f],
output : _name,
command : [prog_python, '@INPUT@'],
capture : true,
input: [gen_header_py, f],
output: _name,
command: [prog_python, '@INPUT0@', rnn_src_path, '@INPUT1@'],
capture: true,
)
endforeach
freedreno_xml_header_files += custom_target(
'a6xx-pack.xml.h',
input : ['gen_header.py', 'adreno/a6xx.xml'],
output : 'a6xx-pack.xml.h',
command : [prog_python, '@INPUT@', '--pack-structs'],
capture : true,
)
freedreno_xml_header_files += custom_target(
'adreno-pm4-pack.xml.h',
input : ['gen_header.py', 'adreno/adreno_pm4.xml'],
output : 'adreno-pm4-pack.xml.h',
command : [prog_python, '@INPUT@', '--pack-structs'],
capture : true,
)
subdir('adreno')

View File

@@ -27,8 +27,8 @@
#include "tu_private.h"
#include "registers/adreno_pm4.xml.h"
#include "registers/adreno_common.xml.h"
#include "adreno_pm4.xml.h"
#include "adreno_common.xml.h"
#include "vk_format.h"

View File

@@ -25,7 +25,7 @@
#include "tu_private.h"
#include "registers/adreno_pm4.xml.h"
#include "adreno_pm4.xml.h"
void
tu_cs_init(struct tu_cs *cs,

View File

@@ -25,8 +25,8 @@
#include "tu_private.h"
#include "registers/adreno_common.xml.h"
#include "registers/a6xx.xml.h"
#include "adreno_common.xml.h"
#include "a6xx.xml.h"
#include "vk_format.h"
#include "vk_util.h"

View File

@@ -31,9 +31,9 @@
#include <string.h>
#include <unistd.h>
#include "registers/adreno_pm4.xml.h"
#include "registers/adreno_common.xml.h"
#include "registers/a6xx.xml.h"
#include "adreno_pm4.xml.h"
#include "adreno_common.xml.h"
#include "a6xx.xml.h"
#include "nir/nir_builder.h"
#include "util/os_time.h"