2012-10-03 21:44:12 +01:00
|
|
|
/*
|
|
|
|
* Copyright © 2012 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* Eric Anholt <eric@anholt.net>
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-03-20 16:04:38 +00:00
|
|
|
#ifndef BRW_VEC4_LIVE_VARIABLES_H
|
|
|
|
#define BRW_VEC4_LIVE_VARIABLES_H
|
|
|
|
|
2015-02-11 23:05:06 +00:00
|
|
|
#include "util/bitset.h"
|
2012-10-03 21:44:12 +01:00
|
|
|
#include "brw_vec4.h"
|
|
|
|
|
|
|
|
namespace brw {
|
|
|
|
|
|
|
|
struct block_data {
|
|
|
|
/**
|
|
|
|
* Which variables are defined before being used in the block.
|
|
|
|
*
|
|
|
|
* Note that for our purposes, "defined" means unconditionally, completely
|
|
|
|
* defined.
|
|
|
|
*/
|
2013-10-21 18:57:29 +01:00
|
|
|
BITSET_WORD *def;
|
2012-10-03 21:44:12 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Which variables are used before being defined in the block.
|
|
|
|
*/
|
2013-10-21 18:57:29 +01:00
|
|
|
BITSET_WORD *use;
|
2012-10-03 21:44:12 +01:00
|
|
|
|
|
|
|
/** Which defs reach the entry point of the block. */
|
2013-10-21 18:57:29 +01:00
|
|
|
BITSET_WORD *livein;
|
2012-10-03 21:44:12 +01:00
|
|
|
|
|
|
|
/** Which defs reach the exit point of the block. */
|
2013-10-21 18:57:29 +01:00
|
|
|
BITSET_WORD *liveout;
|
2014-11-03 05:16:44 +00:00
|
|
|
|
|
|
|
BITSET_WORD flag_def[1];
|
|
|
|
BITSET_WORD flag_use[1];
|
|
|
|
BITSET_WORD flag_livein[1];
|
|
|
|
BITSET_WORD flag_liveout[1];
|
2012-10-03 21:44:12 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
class vec4_live_variables {
|
|
|
|
public:
|
2013-09-21 00:37:55 +01:00
|
|
|
DECLARE_RALLOC_CXX_OPERATORS(vec4_live_variables)
|
2012-10-03 21:44:12 +01:00
|
|
|
|
2015-03-18 14:03:30 +00:00
|
|
|
vec4_live_variables(const simple_allocator &alloc, cfg_t *cfg);
|
2012-10-03 21:44:12 +01:00
|
|
|
~vec4_live_variables();
|
|
|
|
|
2014-06-29 03:52:04 +01:00
|
|
|
int num_vars;
|
|
|
|
int bitset_words;
|
|
|
|
|
|
|
|
/** Per-basic-block information on live variables */
|
2014-10-29 20:35:16 +00:00
|
|
|
struct block_data *block_data;
|
2014-06-29 03:52:04 +01:00
|
|
|
|
|
|
|
protected:
|
2012-10-03 21:44:12 +01:00
|
|
|
void setup_def_use();
|
|
|
|
void compute_live_variables();
|
|
|
|
|
2015-03-18 14:03:30 +00:00
|
|
|
const simple_allocator &alloc;
|
2012-10-03 21:44:12 +01:00
|
|
|
cfg_t *cfg;
|
|
|
|
void *mem_ctx;
|
|
|
|
};
|
|
|
|
|
2016-06-10 12:55:00 +01:00
|
|
|
/* Returns the variable index for the k-th dword of the c-th component of
|
|
|
|
* register reg.
|
|
|
|
*/
|
2015-03-18 18:17:23 +00:00
|
|
|
inline unsigned
|
|
|
|
var_from_reg(const simple_allocator &alloc, const src_reg ®,
|
2016-06-10 12:55:00 +01:00
|
|
|
unsigned c = 0, unsigned k = 0)
|
2015-03-18 18:17:23 +00:00
|
|
|
{
|
2016-06-10 12:55:00 +01:00
|
|
|
assert(reg.file == VGRF && reg.nr < alloc.count && c < 4);
|
|
|
|
const unsigned csize = DIV_ROUND_UP(type_sz(reg.type), 4);
|
|
|
|
unsigned result =
|
|
|
|
8 * (alloc.offsets[reg.nr] + reg.offset / REG_SIZE) +
|
|
|
|
(BRW_GET_SWZ(reg.swizzle, c) + k / csize * 4) * csize + k % csize;
|
|
|
|
/* Do not exceed the limit for this register */
|
|
|
|
assert(result < 8 * (alloc.offsets[reg.nr] + alloc.sizes[reg.nr]));
|
|
|
|
return result;
|
2015-03-18 18:17:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline unsigned
|
|
|
|
var_from_reg(const simple_allocator &alloc, const dst_reg ®,
|
2016-06-10 12:55:00 +01:00
|
|
|
unsigned c = 0, unsigned k = 0)
|
2015-03-18 18:17:23 +00:00
|
|
|
{
|
2016-06-10 12:55:00 +01:00
|
|
|
assert(reg.file == VGRF && reg.nr < alloc.count && c < 4);
|
|
|
|
const unsigned csize = DIV_ROUND_UP(type_sz(reg.type), 4);
|
|
|
|
unsigned result =
|
|
|
|
8 * (alloc.offsets[reg.nr] + reg.offset / REG_SIZE) +
|
|
|
|
(c + k / csize * 4) * csize + k % csize;
|
|
|
|
/* Do not exceed the limit for this register */
|
|
|
|
assert(result < 8 * (alloc.offsets[reg.nr] + alloc.sizes[reg.nr]));
|
|
|
|
return result;
|
2015-03-18 18:17:23 +00:00
|
|
|
}
|
|
|
|
|
2012-10-03 21:44:12 +01:00
|
|
|
} /* namespace brw */
|
2017-03-20 16:04:38 +00:00
|
|
|
|
|
|
|
#endif /* BRW_VEC4_LIVE_VARIABLES_H */
|