agx: Describe whether instructions may be reordered
authorAlyssa Rosenzweig <alyssa@collabora.com>
Sat, 5 Nov 2022 03:26:34 +0000 (23:26 -0400)
committerMarge Bot <emma+marge@anholt.net>
Thu, 10 Nov 2022 02:25:09 +0000 (02:25 +0000)
As per NIR, for the benefit of CSE. It is assumed that instructions that
cannot be eliminated also cannot be reordered.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19590>

src/asahi/compiler/agx_opcodes.c.py
src/asahi/compiler/agx_opcodes.h.py
src/asahi/compiler/agx_opcodes.py

index b981fea..ab47066 100644 (file)
@@ -45,6 +45,7 @@ const struct agx_opcode_info agx_opcodes_info[AGX_NUM_OPCODES] = {
       ${make_encoding(op.encoding_16)},
       ${int(op.is_float)},
       ${int(op.can_eliminate)},
+      ${int(op.can_reorder)},
    },
 % endfor
 };
index 9b7b7b9..81e1a74 100644 (file)
@@ -82,6 +82,7 @@ struct agx_opcode_info {
    struct agx_encoding encoding_16;
    bool is_float : 1;
    bool can_eliminate : 1;
+   bool can_reorder : 1;
 };
 
 extern const struct agx_opcode_info agx_opcodes_info[AGX_NUM_OPCODES];
index 7900d74..c86463f 100644 (file)
@@ -29,7 +29,7 @@ VARIABLE = ~0
 
 class Opcode(object):
    def __init__(self, name, dests, srcs, imms, is_float, can_eliminate,
-           encoding_16, encoding_32):
+                can_reorder, encoding_16, encoding_32):
       self.name = name
       self.dests = dests if dests != VARIABLE else 0
       self.srcs = srcs if srcs != VARIABLE else 0
@@ -38,6 +38,7 @@ class Opcode(object):
       self.imms = imms
       self.is_float = is_float
       self.can_eliminate = can_eliminate
+      self.can_reorder = can_reorder
       self.encoding_16 = encoding_16
       self.encoding_32 = encoding_32
 
@@ -63,11 +64,11 @@ class Encoding(object):
          assert(length_long == length_short + (4 if length_short > 8 else 2))
 
 def op(name, encoding_32, dests = 1, srcs = 0, imms = [], is_float = False,
-        can_eliminate = True, encoding_16 = None):
+        can_eliminate = True, can_reorder = True, encoding_16 = None):
    encoding_16 = Encoding(encoding_16) if encoding_16 is not None else None
    encoding_32 = Encoding(encoding_32) if encoding_32 is not None else None
 
-   opcodes[name] = Opcode(name, dests, srcs, imms, is_float, can_eliminate, encoding_16, encoding_32)
+   opcodes[name] = Opcode(name, dests, srcs, imms, is_float, can_eliminate, can_reorder, encoding_16, encoding_32)
 
 def immediate(name, ctype = "uint32_t"):
    imm = Immediate(name, ctype)
@@ -222,7 +223,7 @@ op("texture_load",
 # sources are base, index
 op("device_load",
       encoding_32 = (0x05, 0x7F, 6, 8),
-      srcs = 2, imms = [FORMAT, MASK, SCOREBOARD])
+      srcs = 2, imms = [FORMAT, MASK, SCOREBOARD], can_reorder = False)
 
 # sources are value, index
 # TODO: Consider permitting the short form
@@ -238,7 +239,7 @@ op("get_sr", (0x72, 0x7F | L, 4, _), dests = 1, imms = [SR])
 op("sample_mask", (0x7fc1, 0xffff, 6, _), dests = 0, srcs = 1, can_eliminate = False)
 
 # Essentially same encoding
-op("ld_tile", (0x49, 0x7F, 8, _), dests = 1, srcs = 0, imms = [FORMAT, MASK])
+op("ld_tile", (0x49, 0x7F, 8, _), dests = 1, srcs = 0, imms = [FORMAT, MASK], can_reorder = False)
 
 op("st_tile", (0x09, 0x7F, 8, _), dests = 0, srcs = 1,
       can_eliminate = False, imms = [FORMAT, MASK])