Allows every user of isaspec to add custom meta information
to any bitset. This can be quite handy if you want to know
how many sources your instruction have, if this instruction has
a dest or provide some names for sources that can be used
by some debug tools.
All you need is to sprinkle <meta> tags in the xml file and
provide custom attributes.
<meta has_dest="1" num_sources="3" .. />
With get_meta() method of any bitset you can get access to
the dict with all the attributes. get_meta() walks the whole
tree to collect all <meta> tags on the way to the root node.
Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25451>
self.xml = xml
self.name = xml.attrib['name']
self.display_name = xml.attrib['displayname'] if 'displayname' in xml.attrib else self.name
+ self.meta = {}
# Used for generated encoder, to de-duplicate encoding for
# similar instructions:
if 'max' in gen.attrib:
self.gen_max = int(gen.attrib['max'])
+ if xml.find('meta') is not None:
+ self.meta = xml.find('meta').attrib
+
# Collect up the match/dontcare/mask bitmasks for
# this bitset case:
self.match = 0
return self.isa.bitsets[self.extends].get_root()
return self
+ def get_meta(self):
+ meta = {}
+
+ if self.extends is not None:
+ meta = self.isa.bitsets[self.extends].get_meta()
+
+ if self.meta:
+ meta.update(self.meta)
+
+ return meta
+
class BitSetTemplate(object):
"""Class that encapsulates a template declaration
"""