summaryrefslogtreecommitdiffstats
path: root/src/amd
diff options
context:
space:
mode:
authorMathieu Bridon <[email protected]>2018-07-05 15:17:32 +0200
committerDylan Baker <[email protected]>2018-07-06 10:04:22 -0700
commit0f7b18fa0d353aab0a44082b1aca8d8c00df71a7 (patch)
treee511fe8f70b48ad5203e3a0e52d0dc1b086bfd91 /src/amd
parentb3a42fa0667caeeebabd9e6aeb46a9534810c2f3 (diff)
python: Use the print function
In Python 2, `print` was a statement, but it became a function in Python 3. Using print functions everywhere makes the script compatible with Python versions >= 2.6, including Python 3. Signed-off-by: Mathieu Bridon <[email protected]> Acked-by: Eric Engestrom <[email protected]> Acked-by: Dylan Baker <[email protected]>
Diffstat (limited to 'src/amd')
-rw-r--r--src/amd/common/sid_tables.py39
-rw-r--r--src/amd/vulkan/vk_format_table.py93
2 files changed, 67 insertions, 65 deletions
diff --git a/src/amd/common/sid_tables.py b/src/amd/common/sid_tables.py
index ca90f82535d..421c2a13352 100644
--- a/src/amd/common/sid_tables.py
+++ b/src/amd/common/sid_tables.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
CopyRight = '''
/*
@@ -333,10 +334,10 @@ def write_tables(asics, packets):
strings_offsets = IntTable("int")
fields = FieldTable()
- print '/* This file is autogenerated by sid_tables.py from sid.h. Do not edit directly. */'
- print
- print CopyRight.strip()
- print '''
+ print('/* This file is autogenerated by sid_tables.py from sid.h. Do not edit directly. */')
+ print()
+ print(CopyRight.strip())
+ print('''
#ifndef SID_TABLES_H
#define SID_TABLES_H
@@ -358,17 +359,17 @@ struct si_packet3 {
unsigned name_offset;
unsigned op;
};
-'''
+''')
- print 'static const struct si_packet3 packet3_table[] = {'
+ print('static const struct si_packet3 packet3_table[] = {')
for pkt in packets:
- print '\t{%s, %s},' % (strings.add(pkt[5:]), pkt)
- print '};'
- print
+ print('\t{%s, %s},' % (strings.add(pkt[5:]), pkt))
+ print('};')
+ print()
regs = {}
for asic in asics:
- print 'static const struct si_reg %s_reg_table[] = {' % (asic.name)
+ print('static const struct si_reg %s_reg_table[] = {' % (asic.name))
for reg in asic.registers:
# Only output a register that was changed or added relative to
# the previous generation
@@ -377,27 +378,27 @@ struct si_packet3 {
continue
if len(reg.fields):
- print '\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
- len(reg.fields), fields.add(reg.fields))
+ print('\t{%s, %s, %s, %s},' % (strings.add(reg.name), reg.r_name,
+ len(reg.fields), fields.add(reg.fields)))
else:
- print '\t{%s, %s},' % (strings.add(reg.name), reg.r_name)
+ print('\t{%s, %s},' % (strings.add(reg.name), reg.r_name))
regs[reg.r_name] = reg
- print '};'
- print
+ print('};')
+ print()
fields.emit(sys.stdout, strings, strings_offsets)
- print
+ print()
strings.emit(sys.stdout, "sid_strings")
- print
+ print()
strings_offsets.emit(sys.stdout, "sid_strings_offsets")
- print
- print '#endif'
+ print()
+ print('#endif')
def main():
diff --git a/src/amd/vulkan/vk_format_table.py b/src/amd/vulkan/vk_format_table.py
index cd1af6226a4..604aac8fa75 100644
--- a/src/amd/vulkan/vk_format_table.py
+++ b/src/amd/vulkan/vk_format_table.py
@@ -1,3 +1,4 @@
+from __future__ import print_function
CopyRight = '''
/**************************************************************************
@@ -79,24 +80,24 @@ def print_channels(format, func):
if format.nr_channels() <= 1:
func(format.le_channels, format.le_swizzles)
else:
- print '#ifdef PIPE_ARCH_BIG_ENDIAN'
+ print('#ifdef PIPE_ARCH_BIG_ENDIAN')
func(format.be_channels, format.be_swizzles)
- print '#else'
+ print('#else')
func(format.le_channels, format.le_swizzles)
- print '#endif'
+ print('#endif')
def write_format_table(formats):
- print '/* This file is autogenerated by vk_format_table.py from vk_format_layout.csv. Do not edit directly. */'
- print
+ print('/* This file is autogenerated by vk_format_table.py from vk_format_layout.csv. Do not edit directly. */')
+ print()
# This will print the copyright message on the top of this file
- print CopyRight.strip()
- print
- print '#include "stdbool.h"'
- print '#include "vk_format.h"'
- print
+ print(CopyRight.strip())
+ print()
+ print('#include "stdbool.h"')
+ print('#include "vk_format.h"')
+ print()
def do_channel_array(channels, swizzles):
- print " {"
+ print(" {")
for i in range(4):
channel = channels[i]
if i < 3:
@@ -104,13 +105,13 @@ def write_format_table(formats):
else:
sep = ""
if channel.size:
- print " {%s, %s, %s, %s, %u, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), bool_map(channel.scaled), channel.size, channel.shift, sep, "xyzw"[i], channel.name)
+ print(" {%s, %s, %s, %s, %u, %u}%s\t/* %s = %s */" % (type_map[channel.type], bool_map(channel.norm), bool_map(channel.pure), bool_map(channel.scaled), channel.size, channel.shift, sep, "xyzw"[i], channel.name))
else:
- print " {0, 0, 0, 0, 0}%s" % (sep,)
- print " },"
+ print(" {0, 0, 0, 0, 0}%s" % (sep,))
+ print(" },")
def do_swizzle_array(channels, swizzles):
- print " {"
+ print(" {")
for i in range(4):
swizzle = swizzles[i]
if i < 3:
@@ -121,43 +122,43 @@ def write_format_table(formats):
comment = colorspace_channels_map[format.colorspace][i]
except (KeyError, IndexError):
comment = 'ignored'
- print " %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment)
- print " },"
+ print(" %s%s\t/* %s */" % (swizzle_map[swizzle], sep, comment))
+ print(" },")
for format in formats:
- print 'static const struct vk_format_description'
- print 'vk_format_%s_description = {' % (format.short_name(),)
- print " %s," % (format.name,)
- print " \"%s\"," % (format.name,)
- print " \"%s\"," % (format.short_name(),)
- print " {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size())
- print " %s," % (layout_map(format.layout),)
- print " %u,\t/* nr_channels */" % (format.nr_channels(),)
- print " %s,\t/* is_array */" % (bool_map(format.is_array()),)
- print " %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),)
- print " %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),)
+ print('static const struct vk_format_description')
+ print('vk_format_%s_description = {' % (format.short_name(),))
+ print(" %s," % (format.name,))
+ print(" \"%s\"," % (format.name,))
+ print(" \"%s\"," % (format.short_name(),))
+ print(" {%u, %u, %u},\t/* block */" % (format.block_width, format.block_height, format.block_size()))
+ print(" %s," % (layout_map(format.layout),))
+ print(" %u,\t/* nr_channels */" % (format.nr_channels(),))
+ print(" %s,\t/* is_array */" % (bool_map(format.is_array()),))
+ print(" %s,\t/* is_bitmask */" % (bool_map(format.is_bitmask()),))
+ print(" %s,\t/* is_mixed */" % (bool_map(format.is_mixed()),))
print_channels(format, do_channel_array)
print_channels(format, do_swizzle_array)
- print " %s," % (colorspace_map(format.colorspace),)
- print "};"
- print
+ print(" %s," % (colorspace_map(format.colorspace),))
+ print("};")
+ print()
- print "const struct vk_format_description *"
- print "vk_format_description(VkFormat format)"
- print "{"
- print " if (format > VK_FORMAT_END_RANGE) {"
- print " return NULL;"
- print " }"
- print
- print " switch (format) {"
+ print("const struct vk_format_description *")
+ print("vk_format_description(VkFormat format)")
+ print("{")
+ print(" if (format > VK_FORMAT_END_RANGE) {")
+ print(" return NULL;")
+ print(" }")
+ print()
+ print(" switch (format) {")
for format in formats:
- print " case %s:" % format.name
- print " return &vk_format_%s_description;" % (format.short_name(),)
- print " default:"
- print " return NULL;"
- print " }"
- print "}"
- print
+ print(" case %s:" % format.name)
+ print(" return &vk_format_%s_description;" % (format.short_name(),))
+ print(" default:")
+ print(" return NULL;")
+ print(" }")
+ print("}")
+ print()
def main():