1/* 2 * Copyright © 2015 Intel Corporation 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21 * IN THE SOFTWARE. 22 */ 23 24/** @file brw_fs_validate.cpp 25 * 26 * Implements a pass that validates various invariants of the IR. The current 27 * pass only validates that GRF's uses are sane. More can be added later. 28 */ 29 30#include "brw_fs.h" 31#include "brw_cfg.h" 32 33#define fsv_assert(cond) \ 34 if (!(cond)) { \ 35 fprintf(stderr, "ASSERT: Scalar %s validation failed!\n", stage_abbrev); \ 36 dump_instruction(inst, stderr); \ 37 fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, #cond); \ 38 abort(); \ 39 } 40 41void 42fs_visitor::validate() 43{ 44#ifndef NDEBUG 45 foreach_block_and_inst (block, fs_inst, inst, cfg) { 46 if (inst->dst.file == VGRF) { 47 fsv_assert(inst->dst.offset / REG_SIZE + regs_written(inst) <= 48 alloc.sizes[inst->dst.nr]); 49 } 50 51 for (unsigned i = 0; i < inst->sources; i++) { 52 if (inst->src[i].file == VGRF) { 53 fsv_assert(inst->src[i].offset / REG_SIZE + regs_read(inst, i) <= 54 alloc.sizes[inst->src[i].nr]); 55 } 56 } 57 } 58#endif 59} 60