15ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt/* 25ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * Copyright © 2010 Intel Corporation 35ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * 45ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * Permission is hereby granted, free of charge, to any person obtaining a 55ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * copy of this software and associated documentation files (the "Software"), 65ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * to deal in the Software without restriction, including without limitation 75ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * the rights to use, copy, modify, merge, publish, distribute, sublicense, 85ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * and/or sell copies of the Software, and to permit persons to whom the 95ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * Software is furnished to do so, subject to the following conditions: 105ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * 115ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * The above copyright notice and this permission notice (including the next 125ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * paragraph) shall be included in all copies or substantial portions of the 135ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * Software. 145ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * 155ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 165ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 175ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 185ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 195ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 205ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 215ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * IN THE SOFTWARE. 225ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * 235ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * Authors: 245ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * Eric Anholt <eric@anholt.net> 255ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * 265ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt */ 275ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 285ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt#include "brw_fs.h" 292f0edc60f4bd2ae5999a6afa656e3bb3f181bf0fChad Versace#include "glsl/glsl_types.h" 302f0edc60f4bd2ae5999a6afa656e3bb3f181bf0fChad Versace#include "glsl/ir_optimization.h" 312f0edc60f4bd2ae5999a6afa656e3bb3f181bf0fChad Versace#include "glsl/ir_print_visitor.h" 325ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 335ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholtstatic void 342ac1cb8b83ad1f7700cc40519a82c3cf698b543bEric Anholtassign_reg(int *reg_hw_locations, fs_reg *reg, int reg_width) 355ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt{ 36b76378d46a211521582cfab56dc05031a57502a6Eric Anholt if (reg->file == GRF) { 375ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt assert(reg->reg_offset >= 0); 38c9e81fe14f36933617c862efb15ae09194485eabEric Anholt reg->reg = reg_hw_locations[reg->reg] + reg->reg_offset * reg_width; 39c9e81fe14f36933617c862efb15ae09194485eabEric Anholt reg->reg_offset = 0; 405ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 415ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt} 425ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 435ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholtvoid 445ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholtfs_visitor::assign_regs_trivial() 455ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt{ 46a6411520b40d59a8806289c7aaea4a6b26a54443Eric Anholt int hw_reg_mapping[this->virtual_grf_count + 1]; 475ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt int i; 482ac1cb8b83ad1f7700cc40519a82c3cf698b543bEric Anholt int reg_width = c->dispatch_width / 8; 495ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 502ac1cb8b83ad1f7700cc40519a82c3cf698b543bEric Anholt /* Note that compressed instructions require alignment to 2 registers. */ 51b76378d46a211521582cfab56dc05031a57502a6Eric Anholt hw_reg_mapping[0] = ALIGN(this->first_non_payload_grf, reg_width); 52a6411520b40d59a8806289c7aaea4a6b26a54443Eric Anholt for (i = 1; i <= this->virtual_grf_count; i++) { 535ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt hw_reg_mapping[i] = (hw_reg_mapping[i - 1] + 542ac1cb8b83ad1f7700cc40519a82c3cf698b543bEric Anholt this->virtual_grf_sizes[i - 1] * reg_width); 555ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 56a6411520b40d59a8806289c7aaea4a6b26a54443Eric Anholt this->grf_used = hw_reg_mapping[this->virtual_grf_count]; 575ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 5844ffb4ae207e48f78fae55925601b8708ed09c1dEric Anholt foreach_list(node, &this->instructions) { 5944ffb4ae207e48f78fae55925601b8708ed09c1dEric Anholt fs_inst *inst = (fs_inst *)node; 605ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 612ac1cb8b83ad1f7700cc40519a82c3cf698b543bEric Anholt assign_reg(hw_reg_mapping, &inst->dst, reg_width); 622ac1cb8b83ad1f7700cc40519a82c3cf698b543bEric Anholt assign_reg(hw_reg_mapping, &inst->src[0], reg_width); 632ac1cb8b83ad1f7700cc40519a82c3cf698b543bEric Anholt assign_reg(hw_reg_mapping, &inst->src[1], reg_width); 64a1bfafc5a96012c14db9b0d28223ab54feae131cEric Anholt assign_reg(hw_reg_mapping, &inst->src[2], reg_width); 655ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 665ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 67e910241e9754b6e673ed0fc3133c8b1de56e76c7Eric Anholt if (this->grf_used >= max_grf) { 682ac1cb8b83ad1f7700cc40519a82c3cf698b543bEric Anholt fail("Ran out of regs on trivial allocator (%d/%d)\n", 69e910241e9754b6e673ed0fc3133c8b1de56e76c7Eric Anholt this->grf_used, max_grf); 702ac1cb8b83ad1f7700cc40519a82c3cf698b543bEric Anholt } 712ac1cb8b83ad1f7700cc40519a82c3cf698b543bEric Anholt 725ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt} 735ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 74b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholtstatic void 75b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholtbrw_alloc_reg_set_for_classes(struct brw_context *brw, 76b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt int *class_sizes, 77b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt int class_count, 78b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt int reg_width, 79b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt int base_reg_count) 805ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt{ 81b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt struct intel_context *intel = &brw->intel; 825ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 834e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt /* Compute the total number of registers across all classes. */ 845ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt int ra_reg_count = 0; 855ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt for (int i = 0; i < class_count; i++) { 864e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt ra_reg_count += base_reg_count - (class_sizes[i] - 1); 875ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 885ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 89b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt ralloc_free(brw->wm.ra_reg_to_grf); 90b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt brw->wm.ra_reg_to_grf = ralloc_array(brw, uint8_t, ra_reg_count); 91b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt ralloc_free(brw->wm.regs); 92b972744c78e45928876ea781b9eeef09b3baf083Eric Anholt brw->wm.regs = ra_alloc_reg_set(brw, ra_reg_count); 93b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt ralloc_free(brw->wm.classes); 94b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt brw->wm.classes = ralloc_array(brw, int, class_count + 1); 95b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt 96b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt brw->wm.aligned_pairs_class = -1; 974e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt 984e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt /* Now, add the registers to their classes, and add the conflicts 994e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt * between them and the base GRF registers (and also each other). 1004e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt */ 1014e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt int reg = 0; 1024e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt int pairs_base_reg = 0; 1034e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt int pairs_reg_count = 0; 1045ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt for (int i = 0; i < class_count; i++) { 1054e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt int class_reg_count = base_reg_count - (class_sizes[i] - 1); 106b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt brw->wm.classes[i] = ra_alloc_reg_class(brw->wm.regs); 1075ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 1084e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt /* Save this off for the aligned pair class at the end. */ 1094e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt if (class_sizes[i] == 2) { 1104e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt pairs_base_reg = reg; 1114e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt pairs_reg_count = class_reg_count; 1124e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt } 1134e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt 1144e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt for (int j = 0; j < class_reg_count; j++) { 115b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt ra_class_add_reg(brw->wm.regs, brw->wm.classes[i], reg); 1165ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 117b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt brw->wm.ra_reg_to_grf[reg] = j; 118bbcf13adbe525bd389a65ba15dd7831a56b8b13cEric Anholt 1194e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt for (int base_reg = j; 1204e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt base_reg < j + class_sizes[i]; 121bbcf13adbe525bd389a65ba15dd7831a56b8b13cEric Anholt base_reg++) { 122b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt ra_add_transitive_reg_conflict(brw->wm.regs, base_reg, reg); 1235ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 1244e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt 1254e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt reg++; 1265ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 1275ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 1284e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt assert(reg == ra_reg_count); 1295ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 1305ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt /* Add a special class for aligned pairs, which we'll put delta_x/y 1315ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * in on gen5 so that we can do PLN. 1325ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt */ 1332ac1cb8b83ad1f7700cc40519a82c3cf698b543bEric Anholt if (brw->has_pln && reg_width == 1 && intel->gen < 6) { 134b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt brw->wm.aligned_pairs_class = ra_alloc_reg_class(brw->wm.regs); 1354e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt 1364e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt for (int i = 0; i < pairs_reg_count; i++) { 137b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt if ((brw->wm.ra_reg_to_grf[pairs_base_reg + i] & 1) == 0) { 138b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt ra_class_add_reg(brw->wm.regs, brw->wm.aligned_pairs_class, 1394e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt pairs_base_reg + i); 1404e10d5825b31d2c58c0af3e29b7fc2eacb2b4709Eric Anholt } 1415ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 1425ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt class_count++; 1435ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 1445ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 145b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt ra_set_finalize(brw->wm.regs); 146b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt} 147b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt 148b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholtbool 149b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholtfs_visitor::assign_regs() 150b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt{ 151b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt /* Most of this allocation was written for a reg_width of 1 152b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt * (dispatch_width == 8). In extending to 16-wide, the code was 153b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt * left in place and it was converted to have the hardware 154b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt * registers it's allocating be contiguous physical pairs of regs 155b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt * for reg_width == 2. 156b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt */ 157b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt int reg_width = c->dispatch_width / 8; 158a6411520b40d59a8806289c7aaea4a6b26a54443Eric Anholt int hw_reg_mapping[this->virtual_grf_count]; 159b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt int first_assigned_grf = ALIGN(this->first_non_payload_grf, reg_width); 160e910241e9754b6e673ed0fc3133c8b1de56e76c7Eric Anholt int base_reg_count = (max_grf - first_assigned_grf) / reg_width; 161b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt int class_sizes[base_reg_count]; 162b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt int class_count = 0; 163b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt 164b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt calculate_live_intervals(); 165b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt 166b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt /* Set up the register classes. 167b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt * 168b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt * The base registers store a scalar value. For texture samples, 169b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt * we get virtual GRFs composed of 4 contiguous hw register. For 170b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt * structures and arrays, we store them as contiguous larger things 171b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt * than that, though we should be able to do better most of the 172b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt * time. 173b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt */ 174b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt class_sizes[class_count++] = 1; 175b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt if (brw->has_pln && intel->gen < 6) { 176b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt /* Always set up the (unaligned) pairs for gen5, so we can find 177b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt * them for making the aligned pair class. 178b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt */ 179b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt class_sizes[class_count++] = 2; 180b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt } 181a6411520b40d59a8806289c7aaea4a6b26a54443Eric Anholt for (int r = 0; r < this->virtual_grf_count; r++) { 182b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt int i; 183b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt 184b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt for (i = 0; i < class_count; i++) { 185b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt if (class_sizes[i] == this->virtual_grf_sizes[r]) 186b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt break; 187b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt } 188b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt if (i == class_count) { 189b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt if (this->virtual_grf_sizes[r] >= base_reg_count) { 190b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt fail("Object too large to register allocate.\n"); 191b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt } 192b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt 193b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt class_sizes[class_count++] = this->virtual_grf_sizes[r]; 194b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt } 195b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt } 196b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt 197b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt brw_alloc_reg_set_for_classes(brw, class_sizes, class_count, 198b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt reg_width, base_reg_count); 1995ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 200b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt struct ra_graph *g = ra_alloc_interference_graph(brw->wm.regs, 201a6411520b40d59a8806289c7aaea4a6b26a54443Eric Anholt this->virtual_grf_count); 2025ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 203a6411520b40d59a8806289c7aaea4a6b26a54443Eric Anholt for (int i = 0; i < this->virtual_grf_count; i++) { 2045ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt for (int c = 0; c < class_count; c++) { 2055ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt if (class_sizes[c] == this->virtual_grf_sizes[i]) { 206e04bdeae82797dbdcf6f544a997a4626fdfd4aeePaul Berry /* Special case: on pre-GEN6 hardware that supports PLN, the 207e04bdeae82797dbdcf6f544a997a4626fdfd4aeePaul Berry * second operand of a PLN instruction needs to be an 208e04bdeae82797dbdcf6f544a997a4626fdfd4aeePaul Berry * even-numbered register, so we have a special register class 209e04bdeae82797dbdcf6f544a997a4626fdfd4aeePaul Berry * wm_aligned_pairs_class to handle this case. pre-GEN6 always 210e04bdeae82797dbdcf6f544a997a4626fdfd4aeePaul Berry * uses this->delta_x[BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC] as the 211e04bdeae82797dbdcf6f544a997a4626fdfd4aeePaul Berry * second operand of a PLN instruction (since it doesn't support 212e04bdeae82797dbdcf6f544a997a4626fdfd4aeePaul Berry * any other interpolation modes). So all we need to do is find 213e04bdeae82797dbdcf6f544a997a4626fdfd4aeePaul Berry * that register and set it to the appropriate class. 214e04bdeae82797dbdcf6f544a997a4626fdfd4aeePaul Berry */ 215b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt if (brw->wm.aligned_pairs_class >= 0 && 216e04bdeae82797dbdcf6f544a997a4626fdfd4aeePaul Berry this->delta_x[BRW_WM_PERSPECTIVE_PIXEL_BARYCENTRIC].reg == i) { 217b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt ra_set_node_class(g, i, brw->wm.aligned_pairs_class); 2185ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } else { 219b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt ra_set_node_class(g, i, brw->wm.classes[c]); 2205ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 2215ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt break; 2225ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 2235ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 2245ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 225b76378d46a211521582cfab56dc05031a57502a6Eric Anholt for (int j = 0; j < i; j++) { 2265ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt if (virtual_grf_interferes(i, j)) { 2275ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt ra_add_node_interference(g, i, j); 2285ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 2295ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 2305ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 2315ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 2325ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt if (!ra_allocate_no_spills(g)) { 23399b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt /* Failed to allocate registers. Spill a reg, and the caller will 23499b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt * loop back into here to try again. 23599b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt */ 23699b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt int reg = choose_spill_reg(g); 2372911fa0cca86f7acbc5423cab4dd328a412253cdEric Anholt 2382911fa0cca86f7acbc5423cab4dd328a412253cdEric Anholt if (reg == -1) { 2392911fa0cca86f7acbc5423cab4dd328a412253cdEric Anholt fail("no register to spill\n"); 2402ac1cb8b83ad1f7700cc40519a82c3cf698b543bEric Anholt } else if (c->dispatch_width == 16) { 241d72ff03e699e78381049e29d89163519e6730dd4Eric Anholt fail("Failure to register allocate. Reduce number of live scalar " 242d72ff03e699e78381049e29d89163519e6730dd4Eric Anholt "values to avoid this."); 24399b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt } else { 24499b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt spill_reg(reg); 24599b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt } 24699b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 24799b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 248d3073f58c17d8675a2ecdd5dfa83e5520c78e1a8Kenneth Graunke ralloc_free(g); 24999b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 25099b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt return false; 2515ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 2525ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 2535ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt /* Get the chosen virtual registers for each node, and map virtual 2545ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * regs in the register classes back down to real hardware reg 2555ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt * numbers. 2565ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt */ 257773556e0f537eba82d9d68d618e229140f413620Eric Anholt this->grf_used = first_assigned_grf; 258a6411520b40d59a8806289c7aaea4a6b26a54443Eric Anholt for (int i = 0; i < this->virtual_grf_count; i++) { 2595ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt int reg = ra_get_node_reg(g, i); 2605ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 261b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt hw_reg_mapping[i] = (first_assigned_grf + 262b1f0bffd399f377a19b0541e1d834afad8b9dad0Eric Anholt brw->wm.ra_reg_to_grf[reg] * reg_width); 263773556e0f537eba82d9d68d618e229140f413620Eric Anholt this->grf_used = MAX2(this->grf_used, 264773556e0f537eba82d9d68d618e229140f413620Eric Anholt hw_reg_mapping[i] + this->virtual_grf_sizes[i] * 265773556e0f537eba82d9d68d618e229140f413620Eric Anholt reg_width); 2665ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 2675ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 26844ffb4ae207e48f78fae55925601b8708ed09c1dEric Anholt foreach_list(node, &this->instructions) { 26944ffb4ae207e48f78fae55925601b8708ed09c1dEric Anholt fs_inst *inst = (fs_inst *)node; 2705ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 2712ac1cb8b83ad1f7700cc40519a82c3cf698b543bEric Anholt assign_reg(hw_reg_mapping, &inst->dst, reg_width); 2722ac1cb8b83ad1f7700cc40519a82c3cf698b543bEric Anholt assign_reg(hw_reg_mapping, &inst->src[0], reg_width); 2732ac1cb8b83ad1f7700cc40519a82c3cf698b543bEric Anholt assign_reg(hw_reg_mapping, &inst->src[1], reg_width); 274a1bfafc5a96012c14db9b0d28223ab54feae131cEric Anholt assign_reg(hw_reg_mapping, &inst->src[2], reg_width); 2755ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt } 2765ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt 277d3073f58c17d8675a2ecdd5dfa83e5520c78e1a8Kenneth Graunke ralloc_free(g); 27899b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 27999b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt return true; 28099b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt} 28199b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 28299b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholtvoid 28399b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholtfs_visitor::emit_unspill(fs_inst *inst, fs_reg dst, uint32_t spill_offset) 28499b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt{ 285a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt fs_inst *unspill_inst = new(mem_ctx) fs_inst(FS_OPCODE_UNSPILL, dst); 286a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt unspill_inst->offset = spill_offset; 287a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt unspill_inst->ir = inst->ir; 288a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt unspill_inst->annotation = inst->annotation; 289a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt 290a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt /* Choose a MRF that won't conflict with an MRF that's live across the 291a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt * spill. Nothing else will make it up to MRF 14/15. 292a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt */ 293a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt unspill_inst->base_mrf = 14; 294a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt unspill_inst->mlen = 1; /* header contains offset */ 295a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt inst->insert_before(unspill_inst); 29699b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt} 29799b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 29899b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholtint 29999b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholtfs_visitor::choose_spill_reg(struct ra_graph *g) 30099b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt{ 30199b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt float loop_scale = 1.0; 302a6411520b40d59a8806289c7aaea4a6b26a54443Eric Anholt float spill_costs[this->virtual_grf_count]; 303a6411520b40d59a8806289c7aaea4a6b26a54443Eric Anholt bool no_spill[this->virtual_grf_count]; 30499b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 305a6411520b40d59a8806289c7aaea4a6b26a54443Eric Anholt for (int i = 0; i < this->virtual_grf_count; i++) { 30699b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt spill_costs[i] = 0.0; 30799b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt no_spill[i] = false; 30899b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt } 30999b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 31099b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt /* Calculate costs for spilling nodes. Call it a cost of 1 per 31199b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt * spill/unspill we'll have to do, and guess that the insides of 31299b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt * loops run 10 times. 31399b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt */ 31444ffb4ae207e48f78fae55925601b8708ed09c1dEric Anholt foreach_list(node, &this->instructions) { 31544ffb4ae207e48f78fae55925601b8708ed09c1dEric Anholt fs_inst *inst = (fs_inst *)node; 31699b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 31799b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt for (unsigned int i = 0; i < 3; i++) { 31899b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt if (inst->src[i].file == GRF) { 319a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt spill_costs[inst->src[i].reg] += loop_scale; 320849a3d243d8a0d951202515c06d9b17daf59d2f2Paul Berry 321849a3d243d8a0d951202515c06d9b17daf59d2f2Paul Berry /* Register spilling logic assumes full-width registers; smeared 322849a3d243d8a0d951202515c06d9b17daf59d2f2Paul Berry * registers have a width of 1 so if we try to spill them we'll 323849a3d243d8a0d951202515c06d9b17daf59d2f2Paul Berry * generate invalid assembly. This shouldn't be a problem because 324849a3d243d8a0d951202515c06d9b17daf59d2f2Paul Berry * smeared registers are only used as short-term temporaries when 325849a3d243d8a0d951202515c06d9b17daf59d2f2Paul Berry * loading pull constants, so spilling them is unlikely to reduce 326849a3d243d8a0d951202515c06d9b17daf59d2f2Paul Berry * register pressure anyhow. 327849a3d243d8a0d951202515c06d9b17daf59d2f2Paul Berry */ 328849a3d243d8a0d951202515c06d9b17daf59d2f2Paul Berry if (inst->src[i].smear >= 0) { 329849a3d243d8a0d951202515c06d9b17daf59d2f2Paul Berry no_spill[inst->src[i].reg] = true; 330849a3d243d8a0d951202515c06d9b17daf59d2f2Paul Berry } 33199b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt } 33299b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt } 33399b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 33499b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt if (inst->dst.file == GRF) { 335a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt spill_costs[inst->dst.reg] += inst->regs_written() * loop_scale; 336849a3d243d8a0d951202515c06d9b17daf59d2f2Paul Berry 337849a3d243d8a0d951202515c06d9b17daf59d2f2Paul Berry if (inst->dst.smear >= 0) { 338849a3d243d8a0d951202515c06d9b17daf59d2f2Paul Berry no_spill[inst->dst.reg] = true; 339849a3d243d8a0d951202515c06d9b17daf59d2f2Paul Berry } 34099b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt } 34199b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 34299b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt switch (inst->opcode) { 34399b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 34499b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt case BRW_OPCODE_DO: 34599b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt loop_scale *= 10; 34699b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt break; 34799b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 34899b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt case BRW_OPCODE_WHILE: 34999b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt loop_scale /= 10; 35099b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt break; 35199b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 35299b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt case FS_OPCODE_SPILL: 35399b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt if (inst->src[0].file == GRF) 35499b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt no_spill[inst->src[0].reg] = true; 35599b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt break; 35699b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 35799b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt case FS_OPCODE_UNSPILL: 35899b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt if (inst->dst.file == GRF) 35999b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt no_spill[inst->dst.reg] = true; 36099b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt break; 3616034b9a5124475d300d0678bd2fb6160865fa972Eric Anholt 3626034b9a5124475d300d0678bd2fb6160865fa972Eric Anholt default: 3636034b9a5124475d300d0678bd2fb6160865fa972Eric Anholt break; 36499b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt } 36599b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt } 36699b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 367a6411520b40d59a8806289c7aaea4a6b26a54443Eric Anholt for (int i = 0; i < this->virtual_grf_count; i++) { 36899b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt if (!no_spill[i]) 36999b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt ra_set_node_spill_cost(g, i, spill_costs[i]); 37099b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt } 37199b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 37299b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt return ra_get_best_spill_node(g); 37399b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt} 37499b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 37599b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholtvoid 37699b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholtfs_visitor::spill_reg(int spill_reg) 37799b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt{ 37899b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt int size = virtual_grf_sizes[spill_reg]; 37999b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt unsigned int spill_offset = c->last_scratch; 38099b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt assert(ALIGN(spill_offset, 16) == spill_offset); /* oword read/write req. */ 38199b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt c->last_scratch += size * REG_SIZE; 38299b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 38399b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt /* Generate spill/unspill instructions for the objects being 38499b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt * spilled. Right now, we spill or unspill the whole thing to a 38599b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt * virtual grf of the same size. For most instructions, though, we 38699b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt * could just spill/unspill the GRF being accessed. 38799b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt */ 38844ffb4ae207e48f78fae55925601b8708ed09c1dEric Anholt foreach_list(node, &this->instructions) { 38944ffb4ae207e48f78fae55925601b8708ed09c1dEric Anholt fs_inst *inst = (fs_inst *)node; 39099b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 39199b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt for (unsigned int i = 0; i < 3; i++) { 39299b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt if (inst->src[i].file == GRF && 39399b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt inst->src[i].reg == spill_reg) { 394a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt inst->src[i].reg = virtual_grf_alloc(1); 395a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt emit_unspill(inst, inst->src[i], 396a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt spill_offset + REG_SIZE * inst->src[i].reg_offset); 39799b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt } 39899b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt } 39999b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 40099b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt if (inst->dst.file == GRF && 40199b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt inst->dst.reg == spill_reg) { 402a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt int subset_spill_offset = (spill_offset + 403a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt REG_SIZE * inst->dst.reg_offset); 404a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt inst->dst.reg = virtual_grf_alloc(inst->regs_written()); 405a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt inst->dst.reg_offset = 0; 406a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt 407a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt /* If our write is going to affect just part of the 408a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt * inst->regs_written(), then we need to unspill the destination 409a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt * since we write back out all of the regs_written(). 41099b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt */ 411a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt if (inst->predicated || inst->force_uncompressed || inst->force_sechalf) { 412a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt fs_reg unspill_reg = inst->dst; 413a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt for (int chan = 0; chan < inst->regs_written(); chan++) { 414a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt emit_unspill(inst, unspill_reg, 415a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt subset_spill_offset + REG_SIZE * chan); 416a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt unspill_reg.reg_offset++; 417a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt } 41899b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt } 41999b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 42099b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt fs_reg spill_src = inst->dst; 42199b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt spill_src.reg_offset = 0; 42299b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt spill_src.abs = false; 42399b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt spill_src.negate = false; 42407cd8f46acc34b04308f81de2faf05ba33da264bEric Anholt spill_src.smear = -1; 42599b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt 426a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt for (int chan = 0; chan < inst->regs_written(); chan++) { 42799b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt fs_inst *spill_inst = new(mem_ctx) fs_inst(FS_OPCODE_SPILL, 42899b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt reg_null_f, spill_src); 42999b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt spill_src.reg_offset++; 430a40c1f95229915214be061fbbf9a02e5225fbf01Eric Anholt spill_inst->offset = subset_spill_offset + chan * REG_SIZE; 43199b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt spill_inst->ir = inst->ir; 43299b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt spill_inst->annotation = inst->annotation; 43399b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt spill_inst->base_mrf = 14; 43499b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt spill_inst->mlen = 2; /* header, value */ 43599b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt inst->insert_after(spill_inst); 43699b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt } 43799b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt } 43899b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt } 439e880a57a71bbd5152ed26367dcc7051f21c20981Eric Anholt 440e880a57a71bbd5152ed26367dcc7051f21c20981Eric Anholt this->live_intervals_valid = false; 4415ac6c4ecfe77bf7e02ae61981b2c8b1fe73027cdEric Anholt} 442