1792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt/* 2792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * Copyright © 2014 Broadcom 3792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * 4792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * Permission is hereby granted, free of charge, to any person obtaining a 5792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * copy of this software and associated documentation files (the "Software"), 6792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * to deal in the Software without restriction, including without limitation 7792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * and/or sell copies of the Software, and to permit persons to whom the 9792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * Software is furnished to do so, subject to the following conditions: 10792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * 11792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * The above copyright notice and this permission notice (including the next 12792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * paragraph) shall be included in all copies or substantial portions of the 13792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * Software. 14792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * 15792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * IN THE SOFTWARE. 22792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt */ 23792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 24792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt#ifndef VC4_QIR_H 25792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt#define VC4_QIR_H 26792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 273f1e1287fd960966eee8b12a75c8a8f62e11cdd2Eric Anholt#include <assert.h> 28b0a1e401a93b7b13870b936bc667b3fc15dba6d5Eric Anholt#include <stdio.h> 29b0a1e401a93b7b13870b936bc667b3fc15dba6d5Eric Anholt#include <stdlib.h> 301d23d55ae97d07b6eb70a3e37a91ecb7de38d8d2Eric Anholt#include <stdbool.h> 31792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt#include <stdint.h> 3255d2a1626219ac041ce05477827b592efa1c7b81Eric Anholt#include <string.h> 33792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 34a8e14c293b19a2d298f91f283d6b6839f36fb518Eric Anholt#include "util/macros.h" 35a39a8fbbaa129f4e52f2a3ad2747182e9a74d910Emil Velikov#include "compiler/nir/nir.h" 3678c773bb3646295e4a4f1fe7d6d10f05758ee48bEric Anholt#include "util/list.h" 37877b48a531adc397493e508e509aba2918915349Eric Anholt#include "util/u_math.h" 38792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 3913ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt#include "vc4_screen.h" 4099a9a5a345fab8bbf36ab4e42581f8ee04a59a63Eric Anholt#include "vc4_qpu_defines.h" 4189918c1e74e454af119e7ae23f3ed66fc26abc4bEric Anholt#include "vc4_qpu.h" 42a97b40dca4949b5b8b3320e76768e54f430c9e78Eric Anholt#include "kernel/vc4_packet.h" 4313ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt#include "pipe/p_state.h" 4413ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt 45bf3c50fba221f216e38d3f60f89161ced4c684c0Eric Anholtstruct nir_builder; 46bf3c50fba221f216e38d3f60f89161ced4c684c0Eric Anholt 47792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholtenum qfile { 48792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QFILE_NULL, 49792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QFILE_TEMP, 50792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QFILE_VARY, 51792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QFILE_UNIF, 52a871eff16cc18232ee03b372d75cb6f633213e14Eric Anholt QFILE_VPM, 53f029932cac36859df5a6d04d1dd7343672ced83aEric Anholt QFILE_TLB_COLOR_WRITE, 54f029932cac36859df5a6d04d1dd7343672ced83aEric Anholt QFILE_TLB_COLOR_WRITE_MS, 55f029932cac36859df5a6d04d1dd7343672ced83aEric Anholt QFILE_TLB_Z_WRITE, 56f029932cac36859df5a6d04d1dd7343672ced83aEric Anholt QFILE_TLB_STENCIL_SETUP, 57e473fbe4690b5cbe3769042a4917f22559e2ba8dEric Anholt 58d4c20e82ae34b105fb2d06c8c412656aba2ca1b9Eric Anholt /* If tex_s is written on its own without preceding t/r/b setup, it's 59d4c20e82ae34b105fb2d06c8c412656aba2ca1b9Eric Anholt * a direct memory access using the input value, without the sideband 60d4c20e82ae34b105fb2d06c8c412656aba2ca1b9Eric Anholt * uniform load. We represent these in QIR as a separate write 61d4c20e82ae34b105fb2d06c8c412656aba2ca1b9Eric Anholt * destination so we can tell if the sideband uniform is present. 62d4c20e82ae34b105fb2d06c8c412656aba2ca1b9Eric Anholt */ 63d4c20e82ae34b105fb2d06c8c412656aba2ca1b9Eric Anholt QFILE_TEX_S_DIRECT, 64d4c20e82ae34b105fb2d06c8c412656aba2ca1b9Eric Anholt 65d4c20e82ae34b105fb2d06c8c412656aba2ca1b9Eric Anholt QFILE_TEX_S, 66d4c20e82ae34b105fb2d06c8c412656aba2ca1b9Eric Anholt QFILE_TEX_T, 67d4c20e82ae34b105fb2d06c8c412656aba2ca1b9Eric Anholt QFILE_TEX_R, 68d4c20e82ae34b105fb2d06c8c412656aba2ca1b9Eric Anholt QFILE_TEX_B, 69d4c20e82ae34b105fb2d06c8c412656aba2ca1b9Eric Anholt 7030b818d5eb67c7427fbefb456c7bc2d876bf9eacEric Anholt /* Payload registers that aren't in the physical register file, so we 7130b818d5eb67c7427fbefb456c7bc2d876bf9eacEric Anholt * can just use the corresponding qpu_reg at qpu_emit time. 7230b818d5eb67c7427fbefb456c7bc2d876bf9eacEric Anholt */ 7330b818d5eb67c7427fbefb456c7bc2d876bf9eacEric Anholt QFILE_FRAG_X, 7430b818d5eb67c7427fbefb456c7bc2d876bf9eacEric Anholt QFILE_FRAG_Y, 7530b818d5eb67c7427fbefb456c7bc2d876bf9eacEric Anholt QFILE_FRAG_REV_FLAG, 7631da39ddc92e780dc539bf34d2de7f82fc65fa86Eric Anholt QFILE_QPU_ELEMENT, 7730b818d5eb67c7427fbefb456c7bc2d876bf9eacEric Anholt 78e473fbe4690b5cbe3769042a4917f22559e2ba8dEric Anholt /** 79a1f698881e13a4993e958815b79f8150d48e2739Eric Anholt * Stores an immediate value in the index field that will be used 80a1f698881e13a4993e958815b79f8150d48e2739Eric Anholt * directly by qpu_load_imm(). 81a1f698881e13a4993e958815b79f8150d48e2739Eric Anholt */ 82a1f698881e13a4993e958815b79f8150d48e2739Eric Anholt QFILE_LOAD_IMM, 83a1f698881e13a4993e958815b79f8150d48e2739Eric Anholt 84a1f698881e13a4993e958815b79f8150d48e2739Eric Anholt /** 85e473fbe4690b5cbe3769042a4917f22559e2ba8dEric Anholt * Stores an immediate value in the index field that can be turned 86e473fbe4690b5cbe3769042a4917f22559e2ba8dEric Anholt * into a small immediate field by qpu_encode_small_immediate(). 87e473fbe4690b5cbe3769042a4917f22559e2ba8dEric Anholt */ 88e473fbe4690b5cbe3769042a4917f22559e2ba8dEric Anholt QFILE_SMALL_IMM, 89792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt}; 90792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 91792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholtstruct qreg { 92792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt enum qfile file; 93792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt uint32_t index; 948b36d107fdd6f6b91556fcdc3498df16803d4181Eric Anholt int pack; 95792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt}; 96792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 9744d7b8ad12df504058615901c7233c45e4f24a9fEric Anholtstatic inline struct qreg qir_reg(enum qfile file, uint32_t index) 9844d7b8ad12df504058615901c7233c45e4f24a9fEric Anholt{ 9944d7b8ad12df504058615901c7233c45e4f24a9fEric Anholt return (struct qreg){file, index}; 10044d7b8ad12df504058615901c7233c45e4f24a9fEric Anholt} 10144d7b8ad12df504058615901c7233c45e4f24a9fEric Anholt 102792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholtenum qop { 103792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QOP_UNDEF, 104792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QOP_MOV, 10599a9a5a345fab8bbf36ab4e42581f8ee04a59a63Eric Anholt QOP_FMOV, 10601ca4f207efac555ff5f729dce1687a68ba65400Eric Anholt QOP_MMOV, 107792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QOP_FADD, 108792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QOP_FSUB, 109792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QOP_FMUL, 1108e701fda499af0387f5c72f7bc14510182738647Eric Anholt QOP_V8MULD, 1118e701fda499af0387f5c72f7bc14510182738647Eric Anholt QOP_V8MIN, 1128e701fda499af0387f5c72f7bc14510182738647Eric Anholt QOP_V8MAX, 1138e701fda499af0387f5c72f7bc14510182738647Eric Anholt QOP_V8ADDS, 1148e701fda499af0387f5c72f7bc14510182738647Eric Anholt QOP_V8SUBS, 11580b27ca2cd8cd2bb2937baa441c43a396887cc03Eric Anholt QOP_MUL24, 116792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QOP_FMIN, 117792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QOP_FMAX, 118792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QOP_FMINABS, 119792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QOP_FMAXABS, 12080b27ca2cd8cd2bb2937baa441c43a396887cc03Eric Anholt QOP_ADD, 12180b27ca2cd8cd2bb2937baa441c43a396887cc03Eric Anholt QOP_SUB, 12280b27ca2cd8cd2bb2937baa441c43a396887cc03Eric Anholt QOP_SHL, 12380b27ca2cd8cd2bb2937baa441c43a396887cc03Eric Anholt QOP_SHR, 12480b27ca2cd8cd2bb2937baa441c43a396887cc03Eric Anholt QOP_ASR, 12580b27ca2cd8cd2bb2937baa441c43a396887cc03Eric Anholt QOP_MIN, 126ce0eebc935b5fb91b29ca656f79bdfff39beb8f8Eric Anholt QOP_MIN_NOIMM, 12780b27ca2cd8cd2bb2937baa441c43a396887cc03Eric Anholt QOP_MAX, 12880b27ca2cd8cd2bb2937baa441c43a396887cc03Eric Anholt QOP_AND, 12980b27ca2cd8cd2bb2937baa441c43a396887cc03Eric Anholt QOP_OR, 13080b27ca2cd8cd2bb2937baa441c43a396887cc03Eric Anholt QOP_XOR, 13180b27ca2cd8cd2bb2937baa441c43a396887cc03Eric Anholt QOP_NOT, 1322e35981d4d625d951328ef5b8f95798112997fb3Eric Anholt 133792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QOP_FTOI, 134bf542cd37286decbd9fc0c939007b82176e16a81Eric Anholt QOP_ITOF, 135792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QOP_RCP, 136792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QOP_RSQ, 137792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QOP_EXP2, 138792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QOP_LOG2, 139792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QOP_VW_SETUP, 140792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QOP_VR_SETUP, 1417c65b714ed974248f09dcc0b4f020b2e2bf50227Eric Anholt QOP_TLB_COLOR_READ, 14274c4b3b80cc4246fd1eb503d97edb3d293eef5deEric Anholt QOP_MS_MASK, 143c29392751180e21a2857cade8d0b4902cbe9d001Eric Anholt QOP_VARY_ADD_C, 14466c6c401279aa4152a24681f64d0e101aa004593Eric Anholt 145e63598aecb5d1cc2a20b8db1ef85790e301f4241Eric Anholt QOP_FRAG_Z, 146dcd03e74768bb4ba55b5742250f3ed15771b6f66Eric Anholt QOP_FRAG_W, 147e63598aecb5d1cc2a20b8db1ef85790e301f4241Eric Anholt 14866c6c401279aa4152a24681f64d0e101aa004593Eric Anholt /** 14966c6c401279aa4152a24681f64d0e101aa004593Eric Anholt * Signal of texture read being necessary and then reading r4 into 15066c6c401279aa4152a24681f64d0e101aa004593Eric Anholt * the destination 15166c6c401279aa4152a24681f64d0e101aa004593Eric Anholt */ 15266c6c401279aa4152a24681f64d0e101aa004593Eric Anholt QOP_TEX_RESULT, 153a1f698881e13a4993e958815b79f8150d48e2739Eric Anholt 1544f527f12604269f15704bbd14a4962766afdfb9aEric Anholt /** 1554f527f12604269f15704bbd14a4962766afdfb9aEric Anholt * Insert the signal for switching threads in a threaded fragment 1564f527f12604269f15704bbd14a4962766afdfb9aEric Anholt * shader. No value can be live in an accumulator across a thrsw. 1574f527f12604269f15704bbd14a4962766afdfb9aEric Anholt * 1584f527f12604269f15704bbd14a4962766afdfb9aEric Anholt * At the QPU level, this will have several delay slots before the 1594f527f12604269f15704bbd14a4962766afdfb9aEric Anholt * switch happens. Those slots are the responsibility of the 1604f527f12604269f15704bbd14a4962766afdfb9aEric Anholt * scheduler. 1614f527f12604269f15704bbd14a4962766afdfb9aEric Anholt */ 1624f527f12604269f15704bbd14a4962766afdfb9aEric Anholt QOP_THRSW, 1634f527f12604269f15704bbd14a4962766afdfb9aEric Anholt 164074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt /* 32-bit immediate loaded to each SIMD channel */ 165a1f698881e13a4993e958815b79f8150d48e2739Eric Anholt QOP_LOAD_IMM, 16605bcd9dd960d5658801ab35d429ba9778f67cad0Eric Anholt 167074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt /* 32-bit immediate divided into 16 2-bit unsigned int values and 168074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt * loaded to each corresponding SIMD channel. 169074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt */ 170074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt QOP_LOAD_IMM_U2, 171074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt /* 32-bit immediate divided into 16 2-bit signed int values and 172074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt * loaded to each corresponding SIMD channel. 173074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt */ 174074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt QOP_LOAD_IMM_I2, 175074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt 1768ce65261789f085e657e6a487db93d38ee6bea63Eric Anholt QOP_ROT_MUL, 1778ce65261789f085e657e6a487db93d38ee6bea63Eric Anholt 17805bcd9dd960d5658801ab35d429ba9778f67cad0Eric Anholt /* Jumps to block->successor[0] if the qinst->cond (as a 17905bcd9dd960d5658801ab35d429ba9778f67cad0Eric Anholt * QPU_COND_BRANCH_*) passes, or block->successor[1] if not. Note 18005bcd9dd960d5658801ab35d429ba9778f67cad0Eric Anholt * that block->successor[1] may be unset if the condition is ALWAYS. 18105bcd9dd960d5658801ab35d429ba9778f67cad0Eric Anholt */ 18205bcd9dd960d5658801ab35d429ba9778f67cad0Eric Anholt QOP_BRANCH, 1839194473dd260fe72042807a97be0072c6f0537daEric Anholt 1849194473dd260fe72042807a97be0072c6f0537daEric Anholt /* Emits an ADD from src[0] to src[1], where src[0] must be a 1859194473dd260fe72042807a97be0072c6f0537daEric Anholt * QOP_LOAD_IMM result and src[1] is a QUNIFORM_UNIFORMS_ADDRESS, 1869194473dd260fe72042807a97be0072c6f0537daEric Anholt * required by the kernel as part of its branch validation. 1879194473dd260fe72042807a97be0072c6f0537daEric Anholt */ 1889194473dd260fe72042807a97be0072c6f0537daEric Anholt QOP_UNIFORMS_RESET, 189792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt}; 190792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 1913fe4d8e1e39b47c9c5c4bfdd87300abd0c336a7eEric Anholtstruct queued_qpu_inst { 19278c773bb3646295e4a4f1fe7d6d10f05758ee48bEric Anholt struct list_head link; 1933fe4d8e1e39b47c9c5c4bfdd87300abd0c336a7eEric Anholt uint64_t inst; 1943fe4d8e1e39b47c9c5c4bfdd87300abd0c336a7eEric Anholt}; 1953fe4d8e1e39b47c9c5c4bfdd87300abd0c336a7eEric Anholt 196792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholtstruct qinst { 19778c773bb3646295e4a4f1fe7d6d10f05758ee48bEric Anholt struct list_head link; 198792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 199792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt enum qop op; 200792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt struct qreg dst; 201d4c20e82ae34b105fb2d06c8c412656aba2ca1b9Eric Anholt struct qreg src[3]; 2023f1e1287fd960966eee8b12a75c8a8f62e11cdd2Eric Anholt bool sf; 203d4ae5ca823227214dd1f536e5f4058bede20b2ddEric Anholt bool cond_is_exec_mask; 20471db7d3dc577e48da3689fd66989ec3b0a069089Eric Anholt uint8_t cond; 205792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt}; 206792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 207792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholtenum qstage { 208792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt /** 209792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * Coordinate shader, runs during binning, before the VS, and just 210792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * outputs position. 211792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt */ 212792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QSTAGE_COORD, 213792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QSTAGE_VERT, 214792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QSTAGE_FRAG, 215792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt}; 216792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 217792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholtenum quniform_contents { 218792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt /** 219792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * Indicates that a constant 32-bit value is copied from the program's 220792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * uniform contents. 221792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt */ 222792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QUNIFORM_CONSTANT, 223792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt /** 224792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * Indicates that the program's uniform contents are used as an index 225792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * into the GL uniform storage. 226792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt */ 227792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QUNIFORM_UNIFORM, 228792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 229792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt /** @{ 230792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * Scaling factors from clip coordinates to relative to the viewport 231792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * center. 232792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * 233792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * This is used by the coordinate and vertex shaders to produce the 234792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * 32-bit entry consisting of 2 16-bit fields with 12.4 signed fixed 235792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt * point offsets from the viewport ccenter. 236792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt */ 237792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QUNIFORM_VIEWPORT_X_SCALE, 238792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt QUNIFORM_VIEWPORT_Y_SCALE, 239792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt /** @} */ 24066c6c401279aa4152a24681f64d0e101aa004593Eric Anholt 24199070c6daad72c96d517ffb18185c8b21b9d67f2Eric Anholt QUNIFORM_VIEWPORT_Z_OFFSET, 24299070c6daad72c96d517ffb18185c8b21b9d67f2Eric Anholt QUNIFORM_VIEWPORT_Z_SCALE, 24399070c6daad72c96d517ffb18185c8b21b9d67f2Eric Anholt 244201d4c0b2a6f7f0c1d59c4fd5cce4916fc48a2d2Eric Anholt QUNIFORM_USER_CLIP_PLANE, 245201d4c0b2a6f7f0c1d59c4fd5cce4916fc48a2d2Eric Anholt 24666c6c401279aa4152a24681f64d0e101aa004593Eric Anholt /** 24766c6c401279aa4152a24681f64d0e101aa004593Eric Anholt * A reference to a texture config parameter 0 uniform. 24866c6c401279aa4152a24681f64d0e101aa004593Eric Anholt * 24966c6c401279aa4152a24681f64d0e101aa004593Eric Anholt * This is a uniform implicitly loaded with a QPU_W_TMU* write, which 25066c6c401279aa4152a24681f64d0e101aa004593Eric Anholt * defines texture type, miplevels, and such. It will be found as a 25166c6c401279aa4152a24681f64d0e101aa004593Eric Anholt * parameter to the first QOP_TEX_[STRB] instruction in a sequence. 25266c6c401279aa4152a24681f64d0e101aa004593Eric Anholt */ 25366c6c401279aa4152a24681f64d0e101aa004593Eric Anholt QUNIFORM_TEXTURE_CONFIG_P0, 25466c6c401279aa4152a24681f64d0e101aa004593Eric Anholt 25566c6c401279aa4152a24681f64d0e101aa004593Eric Anholt /** 25666c6c401279aa4152a24681f64d0e101aa004593Eric Anholt * A reference to a texture config parameter 1 uniform. 25766c6c401279aa4152a24681f64d0e101aa004593Eric Anholt * 25866c6c401279aa4152a24681f64d0e101aa004593Eric Anholt * This is a uniform implicitly loaded with a QPU_W_TMU* write, which 25966c6c401279aa4152a24681f64d0e101aa004593Eric Anholt * defines texture width, height, filters, and wrap modes. It will be 26066c6c401279aa4152a24681f64d0e101aa004593Eric Anholt * found as a parameter to the second QOP_TEX_[STRB] instruction in a 26166c6c401279aa4152a24681f64d0e101aa004593Eric Anholt * sequence. 26266c6c401279aa4152a24681f64d0e101aa004593Eric Anholt */ 26366c6c401279aa4152a24681f64d0e101aa004593Eric Anholt QUNIFORM_TEXTURE_CONFIG_P1, 264857dcc09fa89aa676fdc95d318ecc4f7ad9cd70aEric Anholt 265730267eb23b418637c78662a77de0a93af91be35Eric Anholt /** A reference to a texture config parameter 2 cubemap stride uniform */ 266730267eb23b418637c78662a77de0a93af91be35Eric Anholt QUNIFORM_TEXTURE_CONFIG_P2, 267730267eb23b418637c78662a77de0a93af91be35Eric Anholt 268bc1fc9c98539f38f5a29b314d4a993a2e2f7ca0aEric Anholt QUNIFORM_TEXTURE_FIRST_LEVEL, 269bc1fc9c98539f38f5a29b314d4a993a2e2f7ca0aEric Anholt 2706b4dfd53ae9b4f86cda0377a4d67b79e9faf7cc8Eric Anholt QUNIFORM_TEXTURE_MSAA_ADDR, 2716b4dfd53ae9b4f86cda0377a4d67b79e9faf7cc8Eric Anholt 272f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt QUNIFORM_UBO_ADDR, 273f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt 274857dcc09fa89aa676fdc95d318ecc4f7ad9cd70aEric Anholt QUNIFORM_TEXRECT_SCALE_X, 275857dcc09fa89aa676fdc95d318ecc4f7ad9cd70aEric Anholt QUNIFORM_TEXRECT_SCALE_Y, 2767c65b714ed974248f09dcc0b4f020b2e2bf50227Eric Anholt 277ae22f5aa14db0a42f4b6adafa11aa9f7bfd5d115Eric Anholt QUNIFORM_TEXTURE_BORDER_COLOR, 278ae22f5aa14db0a42f4b6adafa11aa9f7bfd5d115Eric Anholt 279bf3c50fba221f216e38d3f60f89161ced4c684c0Eric Anholt QUNIFORM_BLEND_CONST_COLOR_X, 280bf3c50fba221f216e38d3f60f89161ced4c684c0Eric Anholt QUNIFORM_BLEND_CONST_COLOR_Y, 281bf3c50fba221f216e38d3f60f89161ced4c684c0Eric Anholt QUNIFORM_BLEND_CONST_COLOR_Z, 282bf3c50fba221f216e38d3f60f89161ced4c684c0Eric Anholt QUNIFORM_BLEND_CONST_COLOR_W, 28370b06fb5d55d639fd74596a2ff6971cb57c030caEric Anholt QUNIFORM_BLEND_CONST_COLOR_RGBA, 28470b06fb5d55d639fd74596a2ff6971cb57c030caEric Anholt QUNIFORM_BLEND_CONST_COLOR_AAAA, 285bf3c50fba221f216e38d3f60f89161ced4c684c0Eric Anholt 28619589147ef660c0bf7fcc52ca82dfbbadf3a9a23Eric Anholt QUNIFORM_STENCIL, 2878cd165051b52a9d70512fd138463aa165bea849aEric Anholt 2888cd165051b52a9d70512fd138463aa165bea849aEric Anholt QUNIFORM_ALPHA_REF, 289a664233042e1ad343184a0c237c3bd7ac5010779Eric Anholt QUNIFORM_SAMPLE_MASK, 2909194473dd260fe72042807a97be0072c6f0537daEric Anholt 2919194473dd260fe72042807a97be0072c6f0537daEric Anholt /* Placeholder uniform that will be updated by the kernel when used by 2929194473dd260fe72042807a97be0072c6f0537daEric Anholt * an instruction writing to QPU_W_UNIFORMS_ADDRESS. 2939194473dd260fe72042807a97be0072c6f0537daEric Anholt */ 2949194473dd260fe72042807a97be0072c6f0537daEric Anholt QUNIFORM_UNIFORMS_ADDRESS, 295792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt}; 296792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 297cfa980f49356eb2d94178f8cc9d67d01b4e3d695Eric Anholtstruct vc4_varying_slot { 298cfa980f49356eb2d94178f8cc9d67d01b4e3d695Eric Anholt uint8_t slot; 2995d72a1c95662109b1338605da83329dd25e00859Eric Anholt uint8_t swizzle; 3005d72a1c95662109b1338605da83329dd25e00859Eric Anholt}; 3015d72a1c95662109b1338605da83329dd25e00859Eric Anholt 302f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholtstruct vc4_compiler_ubo_range { 303f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt /** 304f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt * offset in bytes from the start of the ubo where this range is 305f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt * uploaded. 306f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt * 307f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt * Only set once used is set. 308f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt */ 309f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt uint32_t dst_offset; 310f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt 311f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt /** 312f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt * offset in bytes from the start of the gallium uniforms where the 313f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt * data comes from. 314f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt */ 315f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt uint32_t src_offset; 316f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt 317f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt /** size in bytes of this ubo range */ 318f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt uint32_t size; 319f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt 320f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt /** 321f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt * Set if this range is used by the shader for indirect uniforms 322f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt * access. 323f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt */ 324f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt bool used; 325f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt}; 326f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt 32713ddd48b97474c261ef2d7412629748d6d91f2adEric Anholtstruct vc4_key { 32813ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt struct vc4_uncompiled_shader *shader_state; 32913ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt struct { 33013ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt enum pipe_format format; 33113ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt uint8_t swizzle[4]; 3326b4dfd53ae9b4f86cda0377a4d67b79e9faf7cc8Eric Anholt union { 3336b4dfd53ae9b4f86cda0377a4d67b79e9faf7cc8Eric Anholt struct { 3346b4dfd53ae9b4f86cda0377a4d67b79e9faf7cc8Eric Anholt unsigned compare_mode:1; 3356b4dfd53ae9b4f86cda0377a4d67b79e9faf7cc8Eric Anholt unsigned compare_func:3; 3366b4dfd53ae9b4f86cda0377a4d67b79e9faf7cc8Eric Anholt unsigned wrap_s:3; 3376b4dfd53ae9b4f86cda0377a4d67b79e9faf7cc8Eric Anholt unsigned wrap_t:3; 338bc1fc9c98539f38f5a29b314d4a993a2e2f7ca0aEric Anholt bool force_first_level:1; 3396b4dfd53ae9b4f86cda0377a4d67b79e9faf7cc8Eric Anholt }; 3406b4dfd53ae9b4f86cda0377a4d67b79e9faf7cc8Eric Anholt struct { 3416b4dfd53ae9b4f86cda0377a4d67b79e9faf7cc8Eric Anholt uint16_t msaa_width, msaa_height; 3426b4dfd53ae9b4f86cda0377a4d67b79e9faf7cc8Eric Anholt }; 3436b4dfd53ae9b4f86cda0377a4d67b79e9faf7cc8Eric Anholt }; 34413ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt } tex[VC4_MAX_TEXTURE_SAMPLERS]; 34513ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt uint8_t ucp_enables; 34613ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt}; 34713ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt 34813ddd48b97474c261ef2d7412629748d6d91f2adEric Anholtstruct vc4_fs_key { 34913ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt struct vc4_key base; 35013ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt enum pipe_format color_format; 35113ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt bool depth_enabled; 35213ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt bool stencil_enabled; 35313ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt bool stencil_twoside; 35413ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt bool stencil_full_writemasks; 35513ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt bool is_points; 35613ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt bool is_lines; 35713ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt bool alpha_test; 35813ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt bool point_coord_upper_left; 35913ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt bool light_twoside; 360a97b40dca4949b5b8b3320e76768e54f430c9e78Eric Anholt bool msaa; 361a97b40dca4949b5b8b3320e76768e54f430c9e78Eric Anholt bool sample_coverage; 362a97b40dca4949b5b8b3320e76768e54f430c9e78Eric Anholt bool sample_alpha_to_coverage; 363a97b40dca4949b5b8b3320e76768e54f430c9e78Eric Anholt bool sample_alpha_to_one; 36413ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt uint8_t alpha_test_func; 36513ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt uint8_t logicop_func; 36613ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt uint32_t point_sprite_mask; 36713ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt 36813ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt struct pipe_rt_blend_state blend; 36913ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt}; 37013ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt 37113ddd48b97474c261ef2d7412629748d6d91f2adEric Anholtstruct vc4_vs_key { 37213ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt struct vc4_key base; 37313ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt 3742350569a78c60d32e3b751b4386ea7e6d7e2ebe9Eric Anholt const struct vc4_fs_inputs *fs_inputs; 37513ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt enum pipe_format attr_formats[8]; 37613ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt bool is_coord; 37713ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt bool per_vertex_point_size; 37818260d05820eca971873407e939007c12600660cEric Anholt bool clamp_color; 37913ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt}; 38013ddd48b97474c261ef2d7412629748d6d91f2adEric Anholt 3816c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt/** A basic block of QIR intructions. */ 3826c1f834a237540c344fa794d60501a69bf066fb5Eric Anholtstruct qblock { 3836c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt struct list_head link; 3846c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt 3856c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt struct list_head instructions; 386a59da513d3229c883809ac2088c9612abcec1470Eric Anholt struct list_head qpu_inst_list; 3876c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt 3886c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt struct set *predecessors; 3896c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt struct qblock *successors[2]; 3906c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt 3916c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt int index; 39289918c1e74e454af119e7ae23f3ed66fc26abc4bEric Anholt 39344df061aaad96fc5db630ae69fb2fe2a03bb5659Eric Anholt /* Instruction IPs for the first and last instruction of the block. 39444df061aaad96fc5db630ae69fb2fe2a03bb5659Eric Anholt * Set by vc4_qpu_schedule.c. 39544df061aaad96fc5db630ae69fb2fe2a03bb5659Eric Anholt */ 39644df061aaad96fc5db630ae69fb2fe2a03bb5659Eric Anholt uint32_t start_qpu_ip; 39744df061aaad96fc5db630ae69fb2fe2a03bb5659Eric Anholt uint32_t end_qpu_ip; 39844df061aaad96fc5db630ae69fb2fe2a03bb5659Eric Anholt 39944df061aaad96fc5db630ae69fb2fe2a03bb5659Eric Anholt /* Instruction IP for the branch instruction of the block. Set by 40044df061aaad96fc5db630ae69fb2fe2a03bb5659Eric Anholt * vc4_qpu_schedule.c. 40144df061aaad96fc5db630ae69fb2fe2a03bb5659Eric Anholt */ 40244df061aaad96fc5db630ae69fb2fe2a03bb5659Eric Anholt uint32_t branch_qpu_ip; 40344df061aaad96fc5db630ae69fb2fe2a03bb5659Eric Anholt 40489918c1e74e454af119e7ae23f3ed66fc26abc4bEric Anholt /** @{ used by vc4_qir_live_variables.c */ 40589918c1e74e454af119e7ae23f3ed66fc26abc4bEric Anholt BITSET_WORD *def; 40689918c1e74e454af119e7ae23f3ed66fc26abc4bEric Anholt BITSET_WORD *use; 40789918c1e74e454af119e7ae23f3ed66fc26abc4bEric Anholt BITSET_WORD *live_in; 40889918c1e74e454af119e7ae23f3ed66fc26abc4bEric Anholt BITSET_WORD *live_out; 40989918c1e74e454af119e7ae23f3ed66fc26abc4bEric Anholt int start_ip, end_ip; 41089918c1e74e454af119e7ae23f3ed66fc26abc4bEric Anholt /** @} */ 4116c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt}; 4126c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt 4134bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholtstruct vc4_compile { 4145d72a1c95662109b1338605da83329dd25e00859Eric Anholt struct vc4_context *vc4; 41573e2d4837d7e4611f31532ab0ccc14369341e0cbEric Anholt nir_shader *s; 41673e2d4837d7e4611f31532ab0ccc14369341e0cbEric Anholt nir_function_impl *impl; 41773e2d4837d7e4611f31532ab0ccc14369341e0cbEric Anholt struct exec_list *cf_node_list; 41873e2d4837d7e4611f31532ab0ccc14369341e0cbEric Anholt 41973e2d4837d7e4611f31532ab0ccc14369341e0cbEric Anholt /** 42073e2d4837d7e4611f31532ab0ccc14369341e0cbEric Anholt * Mapping from nir_register * or nir_ssa_def * to array of struct 42173e2d4837d7e4611f31532ab0ccc14369341e0cbEric Anholt * qreg for the values. 42273e2d4837d7e4611f31532ab0ccc14369341e0cbEric Anholt */ 42373e2d4837d7e4611f31532ab0ccc14369341e0cbEric Anholt struct hash_table *def_ht; 42473e2d4837d7e4611f31532ab0ccc14369341e0cbEric Anholt 42585316d059c899ac096331251de6b233229aa0b4fEric Anholt /* For each temp, the instruction generating its value. */ 42685316d059c899ac096331251de6b233229aa0b4fEric Anholt struct qinst **defs; 42785316d059c899ac096331251de6b233229aa0b4fEric Anholt uint32_t defs_array_size; 42873e2d4837d7e4611f31532ab0ccc14369341e0cbEric Anholt 4295d72a1c95662109b1338605da83329dd25e00859Eric Anholt /** 4305d72a1c95662109b1338605da83329dd25e00859Eric Anholt * Inputs to the shader, arranged by TGSI declaration order. 4315d72a1c95662109b1338605da83329dd25e00859Eric Anholt * 4325d72a1c95662109b1338605da83329dd25e00859Eric Anholt * Not all fragment shader QFILE_VARY reads are present in this array. 4335d72a1c95662109b1338605da83329dd25e00859Eric Anholt */ 4344bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholt struct qreg *inputs; 4354bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholt struct qreg *outputs; 436a97b40dca4949b5b8b3320e76768e54f430c9e78Eric Anholt bool msaa_per_sample_output; 437a97b40dca4949b5b8b3320e76768e54f430c9e78Eric Anholt struct qreg color_reads[VC4_MAX_SAMPLES]; 438a97b40dca4949b5b8b3320e76768e54f430c9e78Eric Anholt struct qreg sample_colors[VC4_MAX_SAMPLES]; 4395638b87d4c72e0ed7bb4544885829f27ae3a91f5Eric Anholt uint32_t inputs_array_size; 4405638b87d4c72e0ed7bb4544885829f27ae3a91f5Eric Anholt uint32_t outputs_array_size; 4415638b87d4c72e0ed7bb4544885829f27ae3a91f5Eric Anholt uint32_t uniforms_array_size; 442f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt 443f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt struct vc4_compiler_ubo_range *ubo_ranges; 444f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt uint32_t ubo_ranges_array_size; 44573e2d4837d7e4611f31532ab0ccc14369341e0cbEric Anholt /** Number of uniform areas declared in ubo_ranges. */ 44673e2d4837d7e4611f31532ab0ccc14369341e0cbEric Anholt uint32_t num_uniform_ranges; 44773e2d4837d7e4611f31532ab0ccc14369341e0cbEric Anholt /** Number of uniform areas used for indirect addressed loads. */ 448f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt uint32_t num_ubo_ranges; 449f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt uint32_t next_ubo_dst_offset; 450f87c7008958cdb095efa1cfb29ca8f3c9b9066e4Eric Anholt 451f505f66cd5a266dc70ad12e2b015e6c631651aecEric Anholt /* State for whether we're executing on each channel currently. 0 if 452f505f66cd5a266dc70ad12e2b015e6c631651aecEric Anholt * yes, otherwise a block number + 1 that the channel jumped to. 453f505f66cd5a266dc70ad12e2b015e6c631651aecEric Anholt */ 454f505f66cd5a266dc70ad12e2b015e6c631651aecEric Anholt struct qreg execute; 455f505f66cd5a266dc70ad12e2b015e6c631651aecEric Anholt 4564bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholt struct qreg line_x, point_x, point_y; 45760bed14d0fdc3a05b6251b4ffc6013b5d3ca3e0fEric Anholt /** boolean (~0 -> true) if the fragment has been discarded. */ 4584bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholt struct qreg discard; 459b145b731ab01937993e2bf7ecc072217932568ffEric Anholt struct qreg payload_FRAG_Z; 460b145b731ab01937993e2bf7ecc072217932568ffEric Anholt struct qreg payload_FRAG_W; 4614bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholt 462b920ecf793bd419558a240014624add08774765dEric Anholt uint8_t vattr_sizes[8]; 463b920ecf793bd419558a240014624add08774765dEric Anholt 4645d72a1c95662109b1338605da83329dd25e00859Eric Anholt /** 465cfa980f49356eb2d94178f8cc9d67d01b4e3d695Eric Anholt * Array of the VARYING_SLOT_* of all FS QFILE_VARY reads. 4665d72a1c95662109b1338605da83329dd25e00859Eric Anholt * 4675d72a1c95662109b1338605da83329dd25e00859Eric Anholt * This includes those that aren't part of the VPM varyings, like 4685d72a1c95662109b1338605da83329dd25e00859Eric Anholt * point/line coordinates. 4695d72a1c95662109b1338605da83329dd25e00859Eric Anholt */ 470cfa980f49356eb2d94178f8cc9d67d01b4e3d695Eric Anholt struct vc4_varying_slot *input_slots; 471cfa980f49356eb2d94178f8cc9d67d01b4e3d695Eric Anholt uint32_t num_input_slots; 472cfa980f49356eb2d94178f8cc9d67d01b4e3d695Eric Anholt uint32_t input_slots_array_size; 4735d72a1c95662109b1338605da83329dd25e00859Eric Anholt 4745d72a1c95662109b1338605da83329dd25e00859Eric Anholt /** 475cfa980f49356eb2d94178f8cc9d67d01b4e3d695Eric Anholt * An entry per outputs[] in the VS indicating what the VARYING_SLOT_* 476cfa980f49356eb2d94178f8cc9d67d01b4e3d695Eric Anholt * of the output is. Used to emit from the VS in the order that the 477cfa980f49356eb2d94178f8cc9d67d01b4e3d695Eric Anholt * FS needs. 4785d72a1c95662109b1338605da83329dd25e00859Eric Anholt */ 479cfa980f49356eb2d94178f8cc9d67d01b4e3d695Eric Anholt struct vc4_varying_slot *output_slots; 4805d72a1c95662109b1338605da83329dd25e00859Eric Anholt 4814bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholt struct pipe_shader_state *shader_state; 4824bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholt struct vc4_key *key; 4834bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholt struct vc4_fs_key *fs_key; 4844bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholt struct vc4_vs_key *vs_key; 4854bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholt 48689918c1e74e454af119e7ae23f3ed66fc26abc4bEric Anholt /* Live ranges of temps. */ 48789918c1e74e454af119e7ae23f3ed66fc26abc4bEric Anholt int *temp_start, *temp_end; 48889918c1e74e454af119e7ae23f3ed66fc26abc4bEric Anholt 4894bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholt uint32_t *uniform_data; 4904bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholt enum quniform_contents *uniform_contents; 49175f8e0bc2ae03154038c3f17fec1bcad699856e0Eric Anholt uint32_t uniform_array_size; 4924bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholt uint32_t num_uniforms; 4934bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholt uint32_t num_outputs; 4944bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholt uint32_t num_texture_samples; 4952264925f85f349f57773d46114806a148eae6394Eric Anholt uint32_t output_position_index; 4962264925f85f349f57773d46114806a148eae6394Eric Anholt uint32_t output_color_index; 49766b7bd60e01fd17a356bf26d69ea351261080586Eric Anholt uint32_t output_point_size_index; 49874c4b3b80cc4246fd1eb503d97edb3d293eef5deEric Anholt uint32_t output_sample_mask_index; 4994bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholt 500792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt struct qreg undef; 501792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt enum qstage stage; 502792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt uint32_t num_temps; 5036c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt 5046c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt struct list_head blocks; 5056c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt int next_block_index; 5066c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt struct qblock *cur_block; 507420845acb2207cb9d903e67b66deaf08637ac3b2Eric Anholt struct qblock *loop_cont_block; 508420845acb2207cb9d903e67b66deaf08637ac3b2Eric Anholt struct qblock *loop_break_block; 509792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 51078c773bb3646295e4a4f1fe7d6d10f05758ee48bEric Anholt struct list_head qpu_inst_list; 511a59da513d3229c883809ac2088c9612abcec1470Eric Anholt 512ace0d810e56a1e2978fc3ac237158918ebe2a23cEric Anholt /* Pre-QPU-scheduled instruction containing the last THRSW */ 513ace0d810e56a1e2978fc3ac237158918ebe2a23cEric Anholt uint64_t *last_thrsw; 514ace0d810e56a1e2978fc3ac237158918ebe2a23cEric Anholt 515792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt uint64_t *qpu_insts; 516eea1d36915cb97ee1a6eb6aeaf15dd5689f03148Eric Anholt uint32_t qpu_inst_count; 517eea1d36915cb97ee1a6eb6aeaf15dd5689f03148Eric Anholt uint32_t qpu_inst_size; 51875afa64ef85aa33dfed8325aae767f8a55fd1840Eric Anholt uint32_t num_inputs; 5195d32e263357e562779bfc0d2af712d4c7538a32bEric Anholt 52087a88f2daabfe14b12d447b3d96b9f8938c5cf03Eric Anholt /** 52187a88f2daabfe14b12d447b3d96b9f8938c5cf03Eric Anholt * Number of inputs from num_inputs remaining to be queued to the read 52287a88f2daabfe14b12d447b3d96b9f8938c5cf03Eric Anholt * FIFO in the VS/CS. 52387a88f2daabfe14b12d447b3d96b9f8938c5cf03Eric Anholt */ 52487a88f2daabfe14b12d447b3d96b9f8938c5cf03Eric Anholt uint32_t num_inputs_remaining; 52587a88f2daabfe14b12d447b3d96b9f8938c5cf03Eric Anholt 52687a88f2daabfe14b12d447b3d96b9f8938c5cf03Eric Anholt /* Number of inputs currently in the read FIFO for the VS/CS */ 52787a88f2daabfe14b12d447b3d96b9f8938c5cf03Eric Anholt uint32_t num_inputs_in_fifo; 52887a88f2daabfe14b12d447b3d96b9f8938c5cf03Eric Anholt 52987a88f2daabfe14b12d447b3d96b9f8938c5cf03Eric Anholt /** Next offset in the VPM to read from in the VS/CS */ 53087a88f2daabfe14b12d447b3d96b9f8938c5cf03Eric Anholt uint32_t vpm_read_offset; 53187a88f2daabfe14b12d447b3d96b9f8938c5cf03Eric Anholt 5325d32e263357e562779bfc0d2af712d4c7538a32bEric Anholt uint32_t program_id; 5335d32e263357e562779bfc0d2af712d4c7538a32bEric Anholt uint32_t variant_id; 534755037173d19b65777a97f55455c1f64bf618264Eric Anholt 535755037173d19b65777a97f55455c1f64bf618264Eric Anholt /* Set to compile program in threaded FS mode, where SIG_THREAD_SWITCH 536755037173d19b65777a97f55455c1f64bf618264Eric Anholt * is used to hide texturing latency at the cost of limiting ourselves 537755037173d19b65777a97f55455c1f64bf618264Eric Anholt * to the bottom half of physical reg space. 538755037173d19b65777a97f55455c1f64bf618264Eric Anholt */ 539755037173d19b65777a97f55455c1f64bf618264Eric Anholt bool fs_threaded; 540755037173d19b65777a97f55455c1f64bf618264Eric Anholt 541ace0d810e56a1e2978fc3ac237158918ebe2a23cEric Anholt bool last_thrsw_at_top_level; 542ace0d810e56a1e2978fc3ac237158918ebe2a23cEric Anholt 5434d019bd703e7c20d56d5b858577607115b4926a3Eric Anholt bool failed; 544792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt}; 545792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 546bf3c50fba221f216e38d3f60f89161ced4c684c0Eric Anholt/* Special nir_load_input intrinsic index for loading the current TLB 547bf3c50fba221f216e38d3f60f89161ced4c684c0Eric Anholt * destination color. 548bf3c50fba221f216e38d3f60f89161ced4c684c0Eric Anholt */ 549bf3c50fba221f216e38d3f60f89161ced4c684c0Eric Anholt#define VC4_NIR_TLB_COLOR_READ_INPUT 2000000000 550bf3c50fba221f216e38d3f60f89161ced4c684c0Eric Anholt 551a97b40dca4949b5b8b3320e76768e54f430c9e78Eric Anholt#define VC4_NIR_MS_MASK_OUTPUT 2000000000 552a97b40dca4949b5b8b3320e76768e54f430c9e78Eric Anholt 5534bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholtstruct vc4_compile *qir_compile_init(void); 5544bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholtvoid qir_compile_destroy(struct vc4_compile *c); 5556c1f834a237540c344fa794d60501a69bf066fb5Eric Anholtstruct qblock *qir_new_block(struct vc4_compile *c); 5566c1f834a237540c344fa794d60501a69bf066fb5Eric Anholtvoid qir_set_emit_block(struct vc4_compile *c, struct qblock *block); 5576c1f834a237540c344fa794d60501a69bf066fb5Eric Anholtvoid qir_link_blocks(struct qblock *predecessor, struct qblock *successor); 5586c1f834a237540c344fa794d60501a69bf066fb5Eric Anholtstruct qblock *qir_entry_block(struct vc4_compile *c); 5596c1f834a237540c344fa794d60501a69bf066fb5Eric Anholtstruct qblock *qir_exit_block(struct vc4_compile *c); 560792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholtstruct qinst *qir_inst(enum qop op, struct qreg dst, 561792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt struct qreg src0, struct qreg src1); 56285316d059c899ac096331251de6b233229aa0b4fEric Anholtvoid qir_remove_instruction(struct vc4_compile *c, struct qinst *qinst); 563877b48a531adc397493e508e509aba2918915349Eric Anholtstruct qreg qir_uniform(struct vc4_compile *c, 564877b48a531adc397493e508e509aba2918915349Eric Anholt enum quniform_contents contents, 565877b48a531adc397493e508e509aba2918915349Eric Anholt uint32_t data); 566f1fb85e5440d8874997eea1df982cf02b6ca2ca2Eric Anholtvoid qir_schedule_instructions(struct vc4_compile *c); 5675e90ed79f670cc1c5c12c8b733d4591af0acb5abEric Anholtvoid qir_reorder_uniforms(struct vc4_compile *c); 5689194473dd260fe72042807a97be0072c6f0537daEric Anholtvoid qir_emit_uniform_stream_resets(struct vc4_compile *c); 5694ae137534a8718db4611782dbfec773504b6e3beEric Anholt 570ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholtstruct qreg qir_emit_def(struct vc4_compile *c, struct qinst *inst); 571ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholtstruct qinst *qir_emit_nondef(struct vc4_compile *c, struct qinst *inst); 5724ae137534a8718db4611782dbfec773504b6e3beEric Anholt 5734bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholtstruct qreg qir_get_temp(struct vc4_compile *c); 57489918c1e74e454af119e7ae23f3ed66fc26abc4bEric Anholtvoid qir_calculate_live_intervals(struct vc4_compile *c); 575314f0c57e4c00b0a5cb544fa43e356c1069acd8fEric Anholtint qir_get_nsrc(struct qinst *inst); 576d4c20e82ae34b105fb2d06c8c412656aba2ca1b9Eric Anholtint qir_get_non_sideband_nsrc(struct qinst *inst); 577d4c20e82ae34b105fb2d06c8c412656aba2ca1b9Eric Anholtint qir_get_tex_uniform_src(struct qinst *inst); 5781d23d55ae97d07b6eb70a3e37a91ecb7de38d8d2Eric Anholtbool qir_reg_equals(struct qreg a, struct qreg b); 57952824811b9c0a9bb78a40fcb43af00b315f612d0Eric Anholtbool qir_has_side_effects(struct vc4_compile *c, struct qinst *inst); 580c772c92153fdcd4ba4920b7ef1745ce83b09603bEric Anholtbool qir_has_side_effect_reads(struct vc4_compile *c, struct qinst *inst); 5814690a93b123a64f8730a870a336ae9756d11fd18Eric Anholtbool qir_has_uniform_read(struct qinst *inst); 582572a48366d9dfac6a7f9ee8f4d29832c496125e2Eric Anholtbool qir_is_mul(struct qinst *inst); 583f09ed63f4342846e361242233162799140674d5fEric Anholtbool qir_is_raw_mov(struct qinst *inst); 58414dc281c1332518b6144718e1fb3845abbe23ff7Eric Anholtbool qir_is_tex(struct qinst *inst); 585d4c20e82ae34b105fb2d06c8c412656aba2ca1b9Eric Anholtbool qir_has_implicit_tex_uniform(struct qinst *inst); 586652a864b257650e730ecec9e5882d765840a02e1Eric Anholtbool qir_is_float_input(struct qinst *inst); 58755d2a1626219ac041ce05477827b592efa1c7b81Eric Anholtbool qir_depends_on_flags(struct qinst *inst); 58855d2a1626219ac041ce05477827b592efa1c7b81Eric Anholtbool qir_writes_r4(struct qinst *inst); 58985316d059c899ac096331251de6b233229aa0b4fEric Anholtstruct qreg qir_follow_movs(struct vc4_compile *c, struct qreg reg); 59089918c1e74e454af119e7ae23f3ed66fc26abc4bEric Anholtuint8_t qir_channels_written(struct qinst *inst); 591792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 5924bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholtvoid qir_dump(struct vc4_compile *c); 59364122b16ce74a3fb65269bab325c651c26ccd2d0Eric Anholtvoid qir_dump_inst(struct vc4_compile *c, struct qinst *inst); 594792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholtconst char *qir_get_stage_name(enum qstage stage); 595792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 5968e2d0843c02daf5280184f179ae8ed440ac90d7fEric Anholtvoid qir_validate(struct vc4_compile *c); 5978e2d0843c02daf5280184f179ae8ed440ac90d7fEric Anholt 5984bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholtvoid qir_optimize(struct vc4_compile *c); 5994bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholtbool qir_opt_algebraic(struct vc4_compile *c); 60027544ea8d330309a7f1604bece6d2fcb4e9a8ae3Eric Anholtbool qir_opt_coalesce_ff_writes(struct vc4_compile *c); 6018c5dcdbccb68b73d2856d9c1faafadc536e682e3Eric Anholtbool qir_opt_constant_folding(struct vc4_compile *c); 6024bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholtbool qir_opt_copy_propagation(struct vc4_compile *c); 6034bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholtbool qir_opt_dead_code(struct vc4_compile *c); 604200b4e4bd5e87fea91193e3d1976b9cf0eabf8baEric Anholtbool qir_opt_peephole_sf(struct vc4_compile *c); 605e473fbe4690b5cbe3769042a4917f22559e2ba8dEric Anholtbool qir_opt_small_immediates(struct vc4_compile *c); 606e103b52aec773537d2821d8acc42ac9caa2a4b17Varad Gautambool qir_opt_vpm(struct vc4_compile *c); 60799a759a4a3c29c283ae93612017d2f31c0ddbe73Eric Anholtvoid vc4_nir_lower_blend(nir_shader *s, struct vc4_compile *c); 60899a759a4a3c29c283ae93612017d2f31c0ddbe73Eric Anholtvoid vc4_nir_lower_io(nir_shader *s, struct vc4_compile *c); 609bf3c50fba221f216e38d3f60f89161ced4c684c0Eric Anholtnir_ssa_def *vc4_nir_get_swizzled_channel(struct nir_builder *b, 610bf3c50fba221f216e38d3f60f89161ced4c684c0Eric Anholt nir_ssa_def **srcs, int swiz); 61199a759a4a3c29c283ae93612017d2f31c0ddbe73Eric Anholtvoid vc4_nir_lower_txf_ms(nir_shader *s, struct vc4_compile *c); 61214dc281c1332518b6144718e1fb3845abbe23ff7Eric Anholtvoid qir_lower_uniforms(struct vc4_compile *c); 6131d23d55ae97d07b6eb70a3e37a91ecb7de38d8d2Eric Anholt 6145989ef2b0feb40821a20768c7b4b196b3e793960Eric Anholtuint32_t qpu_schedule_instructions(struct vc4_compile *c); 6153fe4d8e1e39b47c9c5c4bfdd87300abd0c336a7eEric Anholt 6163f1e1287fd960966eee8b12a75c8a8f62e11cdd2Eric Anholtvoid qir_SF(struct vc4_compile *c, struct qreg src); 6173f1e1287fd960966eee8b12a75c8a8f62e11cdd2Eric Anholt 618877b48a531adc397493e508e509aba2918915349Eric Anholtstatic inline struct qreg 619877b48a531adc397493e508e509aba2918915349Eric Anholtqir_uniform_ui(struct vc4_compile *c, uint32_t ui) 620877b48a531adc397493e508e509aba2918915349Eric Anholt{ 621877b48a531adc397493e508e509aba2918915349Eric Anholt return qir_uniform(c, QUNIFORM_CONSTANT, ui); 622877b48a531adc397493e508e509aba2918915349Eric Anholt} 623877b48a531adc397493e508e509aba2918915349Eric Anholt 624877b48a531adc397493e508e509aba2918915349Eric Anholtstatic inline struct qreg 625877b48a531adc397493e508e509aba2918915349Eric Anholtqir_uniform_f(struct vc4_compile *c, float f) 626877b48a531adc397493e508e509aba2918915349Eric Anholt{ 627877b48a531adc397493e508e509aba2918915349Eric Anholt return qir_uniform(c, QUNIFORM_CONSTANT, fui(f)); 628877b48a531adc397493e508e509aba2918915349Eric Anholt} 629877b48a531adc397493e508e509aba2918915349Eric Anholt 630e63598aecb5d1cc2a20b8db1ef85790e301f4241Eric Anholt#define QIR_ALU0(name) \ 631e63598aecb5d1cc2a20b8db1ef85790e301f4241Eric Anholtstatic inline struct qreg \ 6324bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholtqir_##name(struct vc4_compile *c) \ 633e63598aecb5d1cc2a20b8db1ef85790e301f4241Eric Anholt{ \ 634ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt return qir_emit_def(c, qir_inst(QOP_##name, c->undef, \ 635ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt c->undef, c->undef)); \ 636ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt} \ 637ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholtstatic inline struct qinst * \ 638ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholtqir_##name##_dest(struct vc4_compile *c, struct qreg dest) \ 639ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt{ \ 640ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt return qir_emit_nondef(c, qir_inst(QOP_##name, dest, \ 641ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt c->undef, c->undef)); \ 642e63598aecb5d1cc2a20b8db1ef85790e301f4241Eric Anholt} 643e63598aecb5d1cc2a20b8db1ef85790e301f4241Eric Anholt 644792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt#define QIR_ALU1(name) \ 645792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholtstatic inline struct qreg \ 6464bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholtqir_##name(struct vc4_compile *c, struct qreg a) \ 647792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt{ \ 648ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt return qir_emit_def(c, qir_inst(QOP_##name, c->undef, \ 649ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt a, c->undef)); \ 6504ae137534a8718db4611782dbfec773504b6e3beEric Anholt} \ 65171db7d3dc577e48da3689fd66989ec3b0a069089Eric Anholtstatic inline struct qinst * \ 6524ae137534a8718db4611782dbfec773504b6e3beEric Anholtqir_##name##_dest(struct vc4_compile *c, struct qreg dest, \ 6534ae137534a8718db4611782dbfec773504b6e3beEric Anholt struct qreg a) \ 6544ae137534a8718db4611782dbfec773504b6e3beEric Anholt{ \ 655ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt return qir_emit_nondef(c, qir_inst(QOP_##name, dest, a, \ 656ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt c->undef)); \ 657792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt} 658792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 659792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt#define QIR_ALU2(name) \ 660792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholtstatic inline struct qreg \ 6614bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholtqir_##name(struct vc4_compile *c, struct qreg a, struct qreg b) \ 662792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt{ \ 663ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt return qir_emit_def(c, qir_inst(QOP_##name, c->undef, a, b)); \ 6644ae137534a8718db4611782dbfec773504b6e3beEric Anholt} \ 665ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholtstatic inline struct qinst * \ 6664ae137534a8718db4611782dbfec773504b6e3beEric Anholtqir_##name##_dest(struct vc4_compile *c, struct qreg dest, \ 6674ae137534a8718db4611782dbfec773504b6e3beEric Anholt struct qreg a, struct qreg b) \ 6684ae137534a8718db4611782dbfec773504b6e3beEric Anholt{ \ 669ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt return qir_emit_nondef(c, qir_inst(QOP_##name, dest, a, b)); \ 670792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt} 671792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 67266c6c401279aa4152a24681f64d0e101aa004593Eric Anholt#define QIR_NODST_1(name) \ 6732b9f0dffe00bdc556436da02c099b8a50ecc4f49Eric Anholtstatic inline struct qinst * \ 6744bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholtqir_##name(struct vc4_compile *c, struct qreg a) \ 67566c6c401279aa4152a24681f64d0e101aa004593Eric Anholt{ \ 676ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt return qir_emit_nondef(c, qir_inst(QOP_##name, c->undef, \ 677ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt a, c->undef)); \ 67866c6c401279aa4152a24681f64d0e101aa004593Eric Anholt} 67966c6c401279aa4152a24681f64d0e101aa004593Eric Anholt 68066c6c401279aa4152a24681f64d0e101aa004593Eric Anholt#define QIR_NODST_2(name) \ 6812b9f0dffe00bdc556436da02c099b8a50ecc4f49Eric Anholtstatic inline struct qinst * \ 6824bca922878a4d433077d21d4918b1db71b3a15f7Eric Anholtqir_##name(struct vc4_compile *c, struct qreg a, struct qreg b) \ 68366c6c401279aa4152a24681f64d0e101aa004593Eric Anholt{ \ 684ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt return qir_emit_nondef(c, qir_inst(QOP_##name, c->undef, \ 685ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt a, b)); \ 68669ef08d303cdf153fe2432a7e40faccae5d62aabEric Anholt} 68769ef08d303cdf153fe2432a7e40faccae5d62aabEric Anholt 688b145b731ab01937993e2bf7ecc072217932568ffEric Anholt#define QIR_PAYLOAD(name) \ 689b145b731ab01937993e2bf7ecc072217932568ffEric Anholtstatic inline struct qreg \ 690b145b731ab01937993e2bf7ecc072217932568ffEric Anholtqir_##name(struct vc4_compile *c) \ 691b145b731ab01937993e2bf7ecc072217932568ffEric Anholt{ \ 692b145b731ab01937993e2bf7ecc072217932568ffEric Anholt struct qreg *payload = &c->payload_##name; \ 693b145b731ab01937993e2bf7ecc072217932568ffEric Anholt if (payload->file != QFILE_NULL) \ 694b145b731ab01937993e2bf7ecc072217932568ffEric Anholt return *payload; \ 695b145b731ab01937993e2bf7ecc072217932568ffEric Anholt *payload = qir_get_temp(c); \ 696b145b731ab01937993e2bf7ecc072217932568ffEric Anholt struct qinst *inst = qir_inst(QOP_##name, *payload, \ 697b145b731ab01937993e2bf7ecc072217932568ffEric Anholt c->undef, c->undef); \ 6986c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt struct qblock *entry = qir_entry_block(c); \ 6996c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt list_add(&inst->link, &entry->instructions); \ 700b145b731ab01937993e2bf7ecc072217932568ffEric Anholt c->defs[payload->index] = inst; \ 701b145b731ab01937993e2bf7ecc072217932568ffEric Anholt return *payload; \ 702b145b731ab01937993e2bf7ecc072217932568ffEric Anholt} 703b145b731ab01937993e2bf7ecc072217932568ffEric Anholt 704792d1c92df6f58f219eb8b77e668424cdcc9c9afEric AnholtQIR_ALU1(MOV) 70599a9a5a345fab8bbf36ab4e42581f8ee04a59a63Eric AnholtQIR_ALU1(FMOV) 70601ca4f207efac555ff5f729dce1687a68ba65400Eric AnholtQIR_ALU1(MMOV) 707792d1c92df6f58f219eb8b77e668424cdcc9c9afEric AnholtQIR_ALU2(FADD) 708792d1c92df6f58f219eb8b77e668424cdcc9c9afEric AnholtQIR_ALU2(FSUB) 709792d1c92df6f58f219eb8b77e668424cdcc9c9afEric AnholtQIR_ALU2(FMUL) 7108e701fda499af0387f5c72f7bc14510182738647Eric AnholtQIR_ALU2(V8MULD) 7118e701fda499af0387f5c72f7bc14510182738647Eric AnholtQIR_ALU2(V8MIN) 7128e701fda499af0387f5c72f7bc14510182738647Eric AnholtQIR_ALU2(V8MAX) 7138e701fda499af0387f5c72f7bc14510182738647Eric AnholtQIR_ALU2(V8ADDS) 7148e701fda499af0387f5c72f7bc14510182738647Eric AnholtQIR_ALU2(V8SUBS) 71580b27ca2cd8cd2bb2937baa441c43a396887cc03Eric AnholtQIR_ALU2(MUL24) 716792d1c92df6f58f219eb8b77e668424cdcc9c9afEric AnholtQIR_ALU2(FMIN) 717792d1c92df6f58f219eb8b77e668424cdcc9c9afEric AnholtQIR_ALU2(FMAX) 718792d1c92df6f58f219eb8b77e668424cdcc9c9afEric AnholtQIR_ALU2(FMINABS) 719792d1c92df6f58f219eb8b77e668424cdcc9c9afEric AnholtQIR_ALU2(FMAXABS) 720792d1c92df6f58f219eb8b77e668424cdcc9c9afEric AnholtQIR_ALU1(FTOI) 721bf542cd37286decbd9fc0c939007b82176e16a81Eric AnholtQIR_ALU1(ITOF) 72280b27ca2cd8cd2bb2937baa441c43a396887cc03Eric Anholt 72380b27ca2cd8cd2bb2937baa441c43a396887cc03Eric AnholtQIR_ALU2(ADD) 72480b27ca2cd8cd2bb2937baa441c43a396887cc03Eric AnholtQIR_ALU2(SUB) 72580b27ca2cd8cd2bb2937baa441c43a396887cc03Eric AnholtQIR_ALU2(SHL) 72680b27ca2cd8cd2bb2937baa441c43a396887cc03Eric AnholtQIR_ALU2(SHR) 72780b27ca2cd8cd2bb2937baa441c43a396887cc03Eric AnholtQIR_ALU2(ASR) 72880b27ca2cd8cd2bb2937baa441c43a396887cc03Eric AnholtQIR_ALU2(MIN) 729ce0eebc935b5fb91b29ca656f79bdfff39beb8f8Eric AnholtQIR_ALU2(MIN_NOIMM) 73080b27ca2cd8cd2bb2937baa441c43a396887cc03Eric AnholtQIR_ALU2(MAX) 73180b27ca2cd8cd2bb2937baa441c43a396887cc03Eric AnholtQIR_ALU2(AND) 73280b27ca2cd8cd2bb2937baa441c43a396887cc03Eric AnholtQIR_ALU2(OR) 73380b27ca2cd8cd2bb2937baa441c43a396887cc03Eric AnholtQIR_ALU2(XOR) 73480b27ca2cd8cd2bb2937baa441c43a396887cc03Eric AnholtQIR_ALU1(NOT) 73580b27ca2cd8cd2bb2937baa441c43a396887cc03Eric Anholt 736792d1c92df6f58f219eb8b77e668424cdcc9c9afEric AnholtQIR_ALU1(RCP) 737792d1c92df6f58f219eb8b77e668424cdcc9c9afEric AnholtQIR_ALU1(RSQ) 738792d1c92df6f58f219eb8b77e668424cdcc9c9afEric AnholtQIR_ALU1(EXP2) 739792d1c92df6f58f219eb8b77e668424cdcc9c9afEric AnholtQIR_ALU1(LOG2) 740c29392751180e21a2857cade8d0b4902cbe9d001Eric AnholtQIR_ALU1(VARY_ADD_C) 741b145b731ab01937993e2bf7ecc072217932568ffEric AnholtQIR_PAYLOAD(FRAG_Z) 742b145b731ab01937993e2bf7ecc072217932568ffEric AnholtQIR_PAYLOAD(FRAG_W) 743d952a98c5322e64cb436bd8b0f0064441f37ac77Eric AnholtQIR_ALU0(TEX_RESULT) 744d952a98c5322e64cb436bd8b0f0064441f37ac77Eric AnholtQIR_ALU0(TLB_COLOR_READ) 74574c4b3b80cc4246fd1eb503d97edb3d293eef5deEric AnholtQIR_NODST_1(MS_MASK) 746792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt 7476ff2129d5842898eb87d2a457ee018fe66471f06Eric Anholtstatic inline struct qreg 74871db7d3dc577e48da3689fd66989ec3b0a069089Eric Anholtqir_SEL(struct vc4_compile *c, uint8_t cond, struct qreg src0, struct qreg src1) 74971db7d3dc577e48da3689fd66989ec3b0a069089Eric Anholt{ 75071db7d3dc577e48da3689fd66989ec3b0a069089Eric Anholt struct qreg t = qir_get_temp(c); 751414dbb2d5c48b7e9dc0dc8b14583f91415ca3960Eric Anholt qir_MOV_dest(c, t, src1); 752414dbb2d5c48b7e9dc0dc8b14583f91415ca3960Eric Anholt qir_MOV_dest(c, t, src0)->cond = cond; 75371db7d3dc577e48da3689fd66989ec3b0a069089Eric Anholt return t; 75471db7d3dc577e48da3689fd66989ec3b0a069089Eric Anholt} 75571db7d3dc577e48da3689fd66989ec3b0a069089Eric Anholt 75671db7d3dc577e48da3689fd66989ec3b0a069089Eric Anholtstatic inline struct qreg 7578e678de761e755564ade2794dbf68280a4972b66Eric Anholtqir_UNPACK_8_F(struct vc4_compile *c, struct qreg src, int i) 7582e48b286bf21501ac06832799a4b7957bb8ac893Eric Anholt{ 75999a9a5a345fab8bbf36ab4e42581f8ee04a59a63Eric Anholt struct qreg t = qir_FMOV(c, src); 76099a9a5a345fab8bbf36ab4e42581f8ee04a59a63Eric Anholt c->defs[t.index]->src[0].pack = QPU_UNPACK_8A + i; 7612e48b286bf21501ac06832799a4b7957bb8ac893Eric Anholt return t; 7622e48b286bf21501ac06832799a4b7957bb8ac893Eric Anholt} 7632e48b286bf21501ac06832799a4b7957bb8ac893Eric Anholt 76424d998056275f4fab9bf3e98c962d91245ef1b7bEric Anholtstatic inline struct qreg 7652142fd1f6f36ef9a384ef298fec02111dc826308Eric Anholtqir_UNPACK_8_I(struct vc4_compile *c, struct qreg src, int i) 7662142fd1f6f36ef9a384ef298fec02111dc826308Eric Anholt{ 76799a9a5a345fab8bbf36ab4e42581f8ee04a59a63Eric Anholt struct qreg t = qir_MOV(c, src); 76899a9a5a345fab8bbf36ab4e42581f8ee04a59a63Eric Anholt c->defs[t.index]->src[0].pack = QPU_UNPACK_8A + i; 7692142fd1f6f36ef9a384ef298fec02111dc826308Eric Anholt return t; 7702142fd1f6f36ef9a384ef298fec02111dc826308Eric Anholt} 7712142fd1f6f36ef9a384ef298fec02111dc826308Eric Anholt 7722142fd1f6f36ef9a384ef298fec02111dc826308Eric Anholtstatic inline struct qreg 77348a2154520351a22fc860efcdaa4329a51d29c8dEric Anholtqir_UNPACK_16_F(struct vc4_compile *c, struct qreg src, int i) 77448a2154520351a22fc860efcdaa4329a51d29c8dEric Anholt{ 77599a9a5a345fab8bbf36ab4e42581f8ee04a59a63Eric Anholt struct qreg t = qir_FMOV(c, src); 77699a9a5a345fab8bbf36ab4e42581f8ee04a59a63Eric Anholt c->defs[t.index]->src[0].pack = QPU_UNPACK_16A + i; 77748a2154520351a22fc860efcdaa4329a51d29c8dEric Anholt return t; 77848a2154520351a22fc860efcdaa4329a51d29c8dEric Anholt} 77948a2154520351a22fc860efcdaa4329a51d29c8dEric Anholt 78048a2154520351a22fc860efcdaa4329a51d29c8dEric Anholtstatic inline struct qreg 78148a2154520351a22fc860efcdaa4329a51d29c8dEric Anholtqir_UNPACK_16_I(struct vc4_compile *c, struct qreg src, int i) 78248a2154520351a22fc860efcdaa4329a51d29c8dEric Anholt{ 78399a9a5a345fab8bbf36ab4e42581f8ee04a59a63Eric Anholt struct qreg t = qir_MOV(c, src); 78499a9a5a345fab8bbf36ab4e42581f8ee04a59a63Eric Anholt c->defs[t.index]->src[0].pack = QPU_UNPACK_16A + i; 78548a2154520351a22fc860efcdaa4329a51d29c8dEric Anholt return t; 78648a2154520351a22fc860efcdaa4329a51d29c8dEric Anholt} 78748a2154520351a22fc860efcdaa4329a51d29c8dEric Anholt 78801ca4f207efac555ff5f729dce1687a68ba65400Eric Anholtstatic inline void 78969ef08d303cdf153fe2432a7e40faccae5d62aabEric Anholtqir_PACK_8_F(struct vc4_compile *c, struct qreg dest, struct qreg val, int chan) 79072cb6619cb75a92901d372d687505a747a384571Eric Anholt{ 79101ca4f207efac555ff5f729dce1687a68ba65400Eric Anholt assert(!dest.pack); 79201ca4f207efac555ff5f729dce1687a68ba65400Eric Anholt dest.pack = QPU_PACK_MUL_8A + chan; 793ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt qir_emit_nondef(c, qir_inst(QOP_MMOV, dest, val, c->undef)); 79401ca4f207efac555ff5f729dce1687a68ba65400Eric Anholt} 79501ca4f207efac555ff5f729dce1687a68ba65400Eric Anholt 79601ca4f207efac555ff5f729dce1687a68ba65400Eric Anholtstatic inline struct qreg 79701ca4f207efac555ff5f729dce1687a68ba65400Eric Anholtqir_PACK_8888_F(struct vc4_compile *c, struct qreg val) 79801ca4f207efac555ff5f729dce1687a68ba65400Eric Anholt{ 79901ca4f207efac555ff5f729dce1687a68ba65400Eric Anholt struct qreg dest = qir_MMOV(c, val); 80001ca4f207efac555ff5f729dce1687a68ba65400Eric Anholt c->defs[dest.index]->dst.pack = QPU_PACK_MUL_8888; 80169ef08d303cdf153fe2432a7e40faccae5d62aabEric Anholt return dest; 80272cb6619cb75a92901d372d687505a747a384571Eric Anholt} 80372cb6619cb75a92901d372d687505a747a384571Eric Anholt 80472cb6619cb75a92901d372d687505a747a384571Eric Anholtstatic inline struct qreg 80524d998056275f4fab9bf3e98c962d91245ef1b7bEric Anholtqir_POW(struct vc4_compile *c, struct qreg x, struct qreg y) 80624d998056275f4fab9bf3e98c962d91245ef1b7bEric Anholt{ 80724d998056275f4fab9bf3e98c962d91245ef1b7bEric Anholt return qir_EXP2(c, qir_FMUL(c, 80824d998056275f4fab9bf3e98c962d91245ef1b7bEric Anholt y, 80924d998056275f4fab9bf3e98c962d91245ef1b7bEric Anholt qir_LOG2(c, x))); 81024d998056275f4fab9bf3e98c962d91245ef1b7bEric Anholt} 81124d998056275f4fab9bf3e98c962d91245ef1b7bEric Anholt 812a871eff16cc18232ee03b372d75cb6f633213e14Eric Anholtstatic inline void 813a871eff16cc18232ee03b372d75cb6f633213e14Eric Anholtqir_VPM_WRITE(struct vc4_compile *c, struct qreg val) 814a871eff16cc18232ee03b372d75cb6f633213e14Eric Anholt{ 81544d7b8ad12df504058615901c7233c45e4f24a9fEric Anholt qir_MOV_dest(c, qir_reg(QFILE_VPM, 0), val); 816a871eff16cc18232ee03b372d75cb6f633213e14Eric Anholt} 817a871eff16cc18232ee03b372d75cb6f633213e14Eric Anholt 818a1f698881e13a4993e958815b79f8150d48e2739Eric Anholtstatic inline struct qreg 819a1f698881e13a4993e958815b79f8150d48e2739Eric Anholtqir_LOAD_IMM(struct vc4_compile *c, uint32_t val) 820a1f698881e13a4993e958815b79f8150d48e2739Eric Anholt{ 821ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt return qir_emit_def(c, qir_inst(QOP_LOAD_IMM, c->undef, 822ac772b24a18bddc490dae171441795dedd85d7b2Eric Anholt qir_reg(QFILE_LOAD_IMM, val), c->undef)); 823a1f698881e13a4993e958815b79f8150d48e2739Eric Anholt} 824a1f698881e13a4993e958815b79f8150d48e2739Eric Anholt 825074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholtstatic inline struct qreg 826074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholtqir_LOAD_IMM_U2(struct vc4_compile *c, uint32_t val) 827074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt{ 828074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt return qir_emit_def(c, qir_inst(QOP_LOAD_IMM_U2, c->undef, 829074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt qir_reg(QFILE_LOAD_IMM, val), 830074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt c->undef)); 831074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt} 832074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt 833074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholtstatic inline struct qreg 834074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholtqir_LOAD_IMM_I2(struct vc4_compile *c, uint32_t val) 835074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt{ 836074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt return qir_emit_def(c, qir_inst(QOP_LOAD_IMM_I2, c->undef, 837074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt qir_reg(QFILE_LOAD_IMM, val), 838074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt c->undef)); 839074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt} 840074f1f3c0c2cd15213a62eb7f589423ece6391c8Eric Anholt 8418ce65261789f085e657e6a487db93d38ee6bea63Eric Anholt/** Shifts the multiply output to the right by rot channels */ 8428ce65261789f085e657e6a487db93d38ee6bea63Eric Anholtstatic inline struct qreg 8438ce65261789f085e657e6a487db93d38ee6bea63Eric Anholtqir_ROT_MUL(struct vc4_compile *c, struct qreg val, uint32_t rot) 8448ce65261789f085e657e6a487db93d38ee6bea63Eric Anholt{ 8458ce65261789f085e657e6a487db93d38ee6bea63Eric Anholt return qir_emit_def(c, qir_inst(QOP_ROT_MUL, c->undef, 8468ce65261789f085e657e6a487db93d38ee6bea63Eric Anholt val, 8478ce65261789f085e657e6a487db93d38ee6bea63Eric Anholt qir_reg(QFILE_LOAD_IMM, 8488ce65261789f085e657e6a487db93d38ee6bea63Eric Anholt QPU_SMALL_IMM_MUL_ROT + rot))); 8498ce65261789f085e657e6a487db93d38ee6bea63Eric Anholt} 8508ce65261789f085e657e6a487db93d38ee6bea63Eric Anholt 851d4ae5ca823227214dd1f536e5f4058bede20b2ddEric Anholtstatic inline struct qinst * 852f505f66cd5a266dc70ad12e2b015e6c631651aecEric Anholtqir_MOV_cond(struct vc4_compile *c, uint8_t cond, 853f505f66cd5a266dc70ad12e2b015e6c631651aecEric Anholt struct qreg dest, struct qreg src) 854f505f66cd5a266dc70ad12e2b015e6c631651aecEric Anholt{ 855d4ae5ca823227214dd1f536e5f4058bede20b2ddEric Anholt struct qinst *mov = qir_MOV_dest(c, dest, src); 856d4ae5ca823227214dd1f536e5f4058bede20b2ddEric Anholt mov->cond = cond; 857d4ae5ca823227214dd1f536e5f4058bede20b2ddEric Anholt return mov; 858f505f66cd5a266dc70ad12e2b015e6c631651aecEric Anholt} 859f505f66cd5a266dc70ad12e2b015e6c631651aecEric Anholt 86005bcd9dd960d5658801ab35d429ba9778f67cad0Eric Anholtstatic inline struct qinst * 86105bcd9dd960d5658801ab35d429ba9778f67cad0Eric Anholtqir_BRANCH(struct vc4_compile *c, uint8_t cond) 86205bcd9dd960d5658801ab35d429ba9778f67cad0Eric Anholt{ 86305bcd9dd960d5658801ab35d429ba9778f67cad0Eric Anholt struct qinst *inst = qir_inst(QOP_BRANCH, c->undef, c->undef, c->undef); 86405bcd9dd960d5658801ab35d429ba9778f67cad0Eric Anholt inst->cond = cond; 86505bcd9dd960d5658801ab35d429ba9778f67cad0Eric Anholt qir_emit_nondef(c, inst); 86605bcd9dd960d5658801ab35d429ba9778f67cad0Eric Anholt return inst; 86705bcd9dd960d5658801ab35d429ba9778f67cad0Eric Anholt} 86805bcd9dd960d5658801ab35d429ba9778f67cad0Eric Anholt 8696c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt#define qir_for_each_block(block, c) \ 8706c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt list_for_each_entry(struct qblock, block, &c->blocks, link) 8716c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt 8726c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt#define qir_for_each_block_rev(block, c) \ 8736c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt list_for_each_entry_rev(struct qblock, block, &c->blocks, link) 8746c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt 8756c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt/* Loop over the non-NULL members of the successors array. */ 8766c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt#define qir_for_each_successor(succ, block) \ 8776c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt for (struct qblock *succ = block->successors[0]; \ 8786c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt succ != NULL; \ 8796c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt succ = (succ == block->successors[1] ? NULL : \ 8806c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt block->successors[1])) 8816c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt 8826c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt#define qir_for_each_inst(inst, block) \ 8836c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt list_for_each_entry(struct qinst, inst, &block->instructions, link) 8846c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt 8856c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt#define qir_for_each_inst_rev(inst, block) \ 8866c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt list_for_each_entry_rev(struct qinst, inst, &block->instructions, link) 8876c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt 8886c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt#define qir_for_each_inst_safe(inst, block) \ 8896c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt list_for_each_entry_safe(struct qinst, inst, &block->instructions, link) 8906c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt 891d3cdbf6fd817ae5e7a8a72bcc3f43cc1b04a709bEric Anholt#define qir_for_each_inst_inorder(inst, c) \ 8926c1f834a237540c344fa794d60501a69bf066fb5Eric Anholt qir_for_each_block(_block, c) \ 893a025983dd9cfcba8a452205efbc5c0be8ff3da74Eric Anholt qir_for_each_inst_safe(inst, _block) 894d3cdbf6fd817ae5e7a8a72bcc3f43cc1b04a709bEric Anholt 895792d1c92df6f58f219eb8b77e668424cdcc9c9afEric Anholt#endif /* VC4_QIR_H */ 896