#include "bifrost.h"
#include "compiler/nir/nir.h"
+#include "panfrost/util/pan_ir.h"
/* Bifrost opcodes are tricky -- the same op may exist on both FMA and
* ADD with two completely different opcodes, and opcodes can be varying
[libpanfrost_bifrost_files],
include_directories : [inc_common, inc_include, inc_src],
dependencies: [idep_nir],
+ link_with: [libpanfrost_util],
c_args : [c_vis_args, no_override_init_args],
cpp_args : [cpp_vis_args],
build_by_default : false,
])
subdir('shared')
+subdir('util')
subdir('midgard')
subdir('bifrost')
subdir('pandecode')
#include "main/mtypes.h"
#include "compiler/nir_types.h"
#include "compiler/nir/nir.h"
+#include "panfrost/util/pan_ir.h"
/* Forward declare */
struct midgard_block;
unsigned mir_bytes_for_mode(midgard_reg_mode mode);
midgard_reg_mode mir_mode_for_destsize(unsigned size);
uint16_t mir_from_bytemask(uint16_t bytemask, midgard_reg_mode mode);
-uint16_t mir_to_bytemask(midgard_reg_mode mode, unsigned mask);
uint16_t mir_bytemask(midgard_instruction *ins);
uint16_t mir_round_bytemask_up(uint16_t mask, midgard_reg_mode mode);
void mir_set_bytemask(midgard_instruction *ins, uint16_t bytemask);
dependencies: [
idep_nir
],
+ link_with: [libpanfrost_util],
c_args : [c_vis_args, no_override_init_args],
cpp_args : [cpp_vis_args],
build_by_default : false,
}
/* Once we have the NIR mask, we need to normalize to work in 32-bit space */
- unsigned bytemask = mir_to_bytemask(mir_mode_for_destsize(dsize), nir_mask);
+ unsigned bytemask = pan_to_bytemask(dsize, nir_mask);
mir_set_bytemask(ins, bytemask);
if (dsize == 64)
}
}
-
-/* Converts per-component mask to a byte mask */
-
-uint16_t
-mir_to_bytemask(midgard_reg_mode mode, unsigned mask)
-{
- switch (mode) {
- case midgard_reg_mode_8:
- return mask;
-
- case midgard_reg_mode_16: {
- unsigned space =
- (mask & 0x1) |
- ((mask & 0x2) << (2 - 1)) |
- ((mask & 0x4) << (4 - 2)) |
- ((mask & 0x8) << (6 - 3)) |
- ((mask & 0x10) << (8 - 4)) |
- ((mask & 0x20) << (10 - 5)) |
- ((mask & 0x40) << (12 - 6)) |
- ((mask & 0x80) << (14 - 7));
-
- return space | (space << 1);
- }
-
- case midgard_reg_mode_32: {
- unsigned space =
- (mask & 0x1) |
- ((mask & 0x2) << (4 - 1)) |
- ((mask & 0x4) << (8 - 2)) |
- ((mask & 0x8) << (12 - 3));
-
- return space | (space << 1) | (space << 2) | (space << 3);
- }
-
- case midgard_reg_mode_64: {
- unsigned A = (mask & 0x1) ? 0xFF : 0x00;
- unsigned B = (mask & 0x2) ? 0xFF : 0x00;
- return A | (B << 8);
- }
-
- default:
- unreachable("Invalid register mode");
- }
-}
-
/* ...and the inverse */
unsigned
uint16_t
mir_bytemask(midgard_instruction *ins)
{
- return mir_to_bytemask(mir_typesize(ins), ins->mask);
+ return pan_to_bytemask(mir_bytes_for_mode(mir_typesize(ins)) * 8, ins->mask);
}
void
cmask |= (1 << swizzle[c]);
}
- return mir_to_bytemask(mode, cmask);
+ return pan_to_bytemask(mir_bytes_for_mode(mode) * 8, cmask);
}
uint16_t
--- /dev/null
+# Copyright © 2018 Rob Clark
+# Copyright © 2019 Collabora
+
+# 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.
+
+libpanfrost_util_files = files(
+ 'pan_ir.c',
+ 'pan_ir.h',
+)
+
+libpanfrost_util = static_library(
+ 'panfrost_util',
+ [libpanfrost_util_files],
+ include_directories : [inc_common],
+ c_args : [c_vis_args, no_override_init_args],
+ cpp_args : [cpp_vis_args],
+ build_by_default : false,
+)
--- /dev/null
+/*
+ * Copyright (C) 2020 Collabora Ltd.
+ *
+ * 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 (including the next
+ * paragraph) 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.
+ *
+ * Authors (Collabora):
+ * Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
+ */
+
+#include "pan_ir.h"
+#include "util/macros.h"
+
+/* Converts a per-component mask to a byte mask */
+
+uint16_t
+pan_to_bytemask(unsigned bytes, unsigned mask)
+{
+ switch (bytes) {
+ case 8:
+ return mask;
+
+ case 16: {
+ unsigned space =
+ (mask & 0x1) |
+ ((mask & 0x2) << (2 - 1)) |
+ ((mask & 0x4) << (4 - 2)) |
+ ((mask & 0x8) << (6 - 3)) |
+ ((mask & 0x10) << (8 - 4)) |
+ ((mask & 0x20) << (10 - 5)) |
+ ((mask & 0x40) << (12 - 6)) |
+ ((mask & 0x80) << (14 - 7));
+
+ return space | (space << 1);
+ }
+
+ case 32: {
+ unsigned space =
+ (mask & 0x1) |
+ ((mask & 0x2) << (4 - 1)) |
+ ((mask & 0x4) << (8 - 2)) |
+ ((mask & 0x8) << (12 - 3));
+
+ return space | (space << 1) | (space << 2) | (space << 3);
+ }
+
+ case 64: {
+ unsigned A = (mask & 0x1) ? 0xFF : 0x00;
+ unsigned B = (mask & 0x2) ? 0xFF : 0x00;
+ return A | (B << 8);
+ }
+
+ default:
+ unreachable("Invalid register mode");
+ }
+}
--- /dev/null
+/*
+ * Copyright (C) 2020 Collabora, Ltd.
+ *
+ * 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 (including the next
+ * paragraph) 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.
+ */
+
+#ifndef __PAN_IR_H
+#define __PAN_IR_H
+
+#include <stdint.h>
+
+uint16_t
+pan_to_bytemask(unsigned bytes, unsigned mask);
+
+#endif