2006-08-09 19:14:05 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) Intel Corp. 2006. All Rights Reserved.
|
s/Tungsten Graphics/VMware/
Tungsten Graphics Inc. was acquired by VMware Inc. in 2008. Leaving the
old copyright name is creating unnecessary confusion, hence this change.
This was the sed script I used:
$ cat tg2vmw.sed
# Run as:
#
# git reset --hard HEAD && find include scons src -type f -not -name 'sed*' -print0 | xargs -0 sed -i -f tg2vmw.sed
#
# Rename copyrights
s/Tungsten Gra\(ph\|hp\)ics,\? [iI]nc\.\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./g
/Copyright/s/Tungsten Graphics\(,\? [iI]nc\.\)\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./
s/TUNGSTEN GRAPHICS/VMWARE/g
# Rename emails
s/alanh@tungstengraphics.com/alanh@vmware.com/
s/jens@tungstengraphics.com/jowen@vmware.com/g
s/jrfonseca-at-tungstengraphics-dot-com/jfonseca-at-vmware-dot-com/
s/jrfonseca\?@tungstengraphics.com/jfonseca@vmware.com/g
s/keithw\?@tungstengraphics.com/keithw@vmware.com/g
s/michel@tungstengraphics.com/daenzer@vmware.com/g
s/thomas-at-tungstengraphics-dot-com/thellstom-at-vmware-dot-com/
s/zack@tungstengraphics.com/zackr@vmware.com/
# Remove dead links
s@Tungsten Graphics (http://www.tungstengraphics.com)@Tungsten Graphics@g
# C string src/gallium/state_trackers/vega/api_misc.c
s/"Tungsten Graphics, Inc"/"VMware, Inc"/
Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-17 16:27:50 +00:00
|
|
|
Intel funded Tungsten Graphics to
|
2006-08-09 19:14:05 +00:00
|
|
|
develop this 3D driver.
|
2013-11-25 15:39:03 -08:00
|
|
|
|
2006-08-09 19:14:05 +00:00
|
|
|
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:
|
2013-11-25 15:39:03 -08:00
|
|
|
|
2006-08-09 19:14:05 +00:00
|
|
|
The above copyright notice and this permission notice (including the
|
|
|
|
next paragraph) shall be included in all copies or substantial
|
|
|
|
portions of the Software.
|
2013-11-25 15:39:03 -08:00
|
|
|
|
2006-08-09 19:14:05 +00:00
|
|
|
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 COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS 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.
|
2013-11-25 15:39:03 -08:00
|
|
|
|
2006-08-09 19:14:05 +00:00
|
|
|
**********************************************************************/
|
|
|
|
/*
|
|
|
|
* Authors:
|
s/Tungsten Graphics/VMware/
Tungsten Graphics Inc. was acquired by VMware Inc. in 2008. Leaving the
old copyright name is creating unnecessary confusion, hence this change.
This was the sed script I used:
$ cat tg2vmw.sed
# Run as:
#
# git reset --hard HEAD && find include scons src -type f -not -name 'sed*' -print0 | xargs -0 sed -i -f tg2vmw.sed
#
# Rename copyrights
s/Tungsten Gra\(ph\|hp\)ics,\? [iI]nc\.\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./g
/Copyright/s/Tungsten Graphics\(,\? [iI]nc\.\)\?\(, Cedar Park\)\?\(, Austin\)\?\(, \(Texas\|TX\)\)\?\.\?/VMware, Inc./
s/TUNGSTEN GRAPHICS/VMWARE/g
# Rename emails
s/alanh@tungstengraphics.com/alanh@vmware.com/
s/jens@tungstengraphics.com/jowen@vmware.com/g
s/jrfonseca-at-tungstengraphics-dot-com/jfonseca-at-vmware-dot-com/
s/jrfonseca\?@tungstengraphics.com/jfonseca@vmware.com/g
s/keithw\?@tungstengraphics.com/keithw@vmware.com/g
s/michel@tungstengraphics.com/daenzer@vmware.com/g
s/thomas-at-tungstengraphics-dot-com/thellstom-at-vmware-dot-com/
s/zack@tungstengraphics.com/zackr@vmware.com/
# Remove dead links
s@Tungsten Graphics (http://www.tungstengraphics.com)@Tungsten Graphics@g
# C string src/gallium/state_trackers/vega/api_misc.c
s/"Tungsten Graphics, Inc"/"VMware, Inc"/
Reviewed-by: Brian Paul <brianp@vmware.com>
2014-01-17 16:27:50 +00:00
|
|
|
* Keith Whitwell <keithw@vmware.com>
|
2006-08-09 19:14:05 +00:00
|
|
|
*/
|
2013-11-25 15:39:03 -08:00
|
|
|
|
2006-08-09 19:14:05 +00:00
|
|
|
|
|
|
|
#include "brw_context.h"
|
|
|
|
#include "brw_defines.h"
|
|
|
|
#include "brw_eu.h"
|
|
|
|
|
2014-02-24 23:39:14 -08:00
|
|
|
#include "util/ralloc.h"
|
2011-05-16 12:25:18 -07:00
|
|
|
|
2014-02-05 13:27:15 -08:00
|
|
|
/**
|
|
|
|
* Converts a BRW_REGISTER_TYPE_* enum to a short string (F, UD, and so on).
|
|
|
|
*
|
|
|
|
* This is different than reg_encoding from brw_disasm.c in that it operates
|
|
|
|
* on the abstract enum values, rather than the generation-specific encoding.
|
|
|
|
*/
|
|
|
|
const char *
|
|
|
|
brw_reg_type_letters(unsigned type)
|
|
|
|
{
|
|
|
|
const char *names[] = {
|
|
|
|
[BRW_REGISTER_TYPE_UD] = "UD",
|
|
|
|
[BRW_REGISTER_TYPE_D] = "D",
|
|
|
|
[BRW_REGISTER_TYPE_UW] = "UW",
|
|
|
|
[BRW_REGISTER_TYPE_W] = "W",
|
|
|
|
[BRW_REGISTER_TYPE_F] = "F",
|
|
|
|
[BRW_REGISTER_TYPE_UB] = "UB",
|
|
|
|
[BRW_REGISTER_TYPE_B] = "B",
|
|
|
|
[BRW_REGISTER_TYPE_UV] = "UV",
|
|
|
|
[BRW_REGISTER_TYPE_V] = "V",
|
|
|
|
[BRW_REGISTER_TYPE_VF] = "VF",
|
|
|
|
[BRW_REGISTER_TYPE_DF] = "DF",
|
|
|
|
[BRW_REGISTER_TYPE_HF] = "HF",
|
|
|
|
[BRW_REGISTER_TYPE_UQ] = "UQ",
|
|
|
|
[BRW_REGISTER_TYPE_Q] = "Q",
|
|
|
|
};
|
|
|
|
assert(type <= BRW_REGISTER_TYPE_UQ);
|
|
|
|
return names[type];
|
|
|
|
}
|
|
|
|
|
2011-04-09 08:22:42 -10:00
|
|
|
/* Returns the corresponding conditional mod for swapping src0 and
|
|
|
|
* src1 in e.g. CMP.
|
|
|
|
*/
|
2014-06-29 17:50:20 -07:00
|
|
|
enum brw_conditional_mod
|
2011-04-09 08:22:42 -10:00
|
|
|
brw_swap_cmod(uint32_t cmod)
|
|
|
|
{
|
|
|
|
switch (cmod) {
|
|
|
|
case BRW_CONDITIONAL_Z:
|
|
|
|
case BRW_CONDITIONAL_NZ:
|
|
|
|
return cmod;
|
|
|
|
case BRW_CONDITIONAL_G:
|
|
|
|
return BRW_CONDITIONAL_L;
|
2012-06-16 02:08:13 -07:00
|
|
|
case BRW_CONDITIONAL_GE:
|
|
|
|
return BRW_CONDITIONAL_LE;
|
2011-04-09 08:22:42 -10:00
|
|
|
case BRW_CONDITIONAL_L:
|
|
|
|
return BRW_CONDITIONAL_G;
|
2012-06-16 02:08:13 -07:00
|
|
|
case BRW_CONDITIONAL_LE:
|
|
|
|
return BRW_CONDITIONAL_GE;
|
2011-04-09 08:22:42 -10:00
|
|
|
default:
|
|
|
|
return ~0;
|
|
|
|
}
|
|
|
|
}
|
2006-08-09 19:14:05 +00:00
|
|
|
|
2014-05-31 16:57:02 -07:00
|
|
|
void brw_set_default_predicate_control( struct brw_compile *p, unsigned pc )
|
2006-08-09 19:14:05 +00:00
|
|
|
{
|
2014-06-07 21:24:41 -07:00
|
|
|
brw_inst_set_pred_control(p->brw, p->current, pc);
|
2006-08-09 19:14:05 +00:00
|
|
|
}
|
|
|
|
|
2014-05-31 16:57:02 -07:00
|
|
|
void brw_set_default_predicate_inverse(struct brw_compile *p, bool predicate_inverse)
|
2011-04-09 08:29:59 -10:00
|
|
|
{
|
2014-06-07 21:24:41 -07:00
|
|
|
brw_inst_set_pred_inv(p->brw, p->current, predicate_inverse);
|
2011-04-09 08:29:59 -10:00
|
|
|
}
|
|
|
|
|
2014-05-31 16:57:02 -07:00
|
|
|
void brw_set_default_flag_reg(struct brw_compile *p, int reg, int subreg)
|
2012-12-06 10:36:11 -08:00
|
|
|
{
|
2014-06-07 21:24:41 -07:00
|
|
|
if (p->brw->gen >= 7)
|
|
|
|
brw_inst_set_flag_reg_nr(p->brw, p->current, reg);
|
|
|
|
|
|
|
|
brw_inst_set_flag_subreg_nr(p->brw, p->current, subreg);
|
2012-12-06 10:36:11 -08:00
|
|
|
}
|
|
|
|
|
2014-05-31 16:57:02 -07:00
|
|
|
void brw_set_default_access_mode( struct brw_compile *p, unsigned access_mode )
|
2006-08-09 19:14:05 +00:00
|
|
|
{
|
2014-06-07 21:24:41 -07:00
|
|
|
brw_inst_set_access_mode(p->brw, p->current, access_mode);
|
2006-08-09 19:14:05 +00:00
|
|
|
}
|
|
|
|
|
2011-10-07 12:32:52 -07:00
|
|
|
void
|
2014-05-31 16:57:02 -07:00
|
|
|
brw_set_default_compression_control(struct brw_compile *p,
|
2011-10-07 12:32:52 -07:00
|
|
|
enum brw_compression compression_control)
|
2006-08-09 19:14:05 +00:00
|
|
|
{
|
2014-06-10 17:44:56 -07:00
|
|
|
struct brw_context *brw = p->brw;
|
|
|
|
|
2010-12-03 11:49:29 -08:00
|
|
|
p->compressed = (compression_control == BRW_COMPRESSION_COMPRESSED);
|
|
|
|
|
2014-06-10 17:44:56 -07:00
|
|
|
if (brw->gen >= 6) {
|
2013-11-12 15:33:27 -08:00
|
|
|
/* Since we don't use the SIMD32 support in gen6, we translate
|
2010-12-03 11:49:29 -08:00
|
|
|
* the pre-gen6 compression control here.
|
|
|
|
*/
|
|
|
|
switch (compression_control) {
|
|
|
|
case BRW_COMPRESSION_NONE:
|
|
|
|
/* This is the "use the first set of bits of dmask/vmask/arf
|
|
|
|
* according to execsize" option.
|
|
|
|
*/
|
2014-06-07 21:24:41 -07:00
|
|
|
brw_inst_set_qtr_control(brw, p->current, GEN6_COMPRESSION_1Q);
|
2010-12-03 11:49:29 -08:00
|
|
|
break;
|
|
|
|
case BRW_COMPRESSION_2NDHALF:
|
2013-11-12 15:33:27 -08:00
|
|
|
/* For SIMD8, this is "use the second set of 8 bits." */
|
2014-06-07 21:24:41 -07:00
|
|
|
brw_inst_set_qtr_control(brw, p->current, GEN6_COMPRESSION_2Q);
|
2010-12-03 11:49:29 -08:00
|
|
|
break;
|
|
|
|
case BRW_COMPRESSION_COMPRESSED:
|
2013-11-12 15:33:27 -08:00
|
|
|
/* For SIMD16 instruction compression, use the first set of 16 bits
|
|
|
|
* since we don't do SIMD32 dispatch.
|
2010-12-03 11:49:29 -08:00
|
|
|
*/
|
2014-06-07 21:24:41 -07:00
|
|
|
brw_inst_set_qtr_control(brw, p->current, GEN6_COMPRESSION_1H);
|
2010-12-03 11:49:29 -08:00
|
|
|
break;
|
|
|
|
default:
|
2014-06-29 14:54:01 -07:00
|
|
|
unreachable("not reached");
|
2010-12-03 11:49:29 -08:00
|
|
|
}
|
|
|
|
} else {
|
2014-06-07 21:24:41 -07:00
|
|
|
brw_inst_set_qtr_control(brw, p->current, compression_control);
|
2010-12-03 11:49:29 -08:00
|
|
|
}
|
2006-08-09 19:14:05 +00:00
|
|
|
}
|
|
|
|
|
2014-05-31 16:57:02 -07:00
|
|
|
void brw_set_default_mask_control( struct brw_compile *p, unsigned value )
|
2006-08-09 19:14:05 +00:00
|
|
|
{
|
2014-06-07 21:24:41 -07:00
|
|
|
brw_inst_set_mask_control(p->brw, p->current, value);
|
2006-08-09 19:14:05 +00:00
|
|
|
}
|
|
|
|
|
2014-05-31 16:57:02 -07:00
|
|
|
void brw_set_default_saturate( struct brw_compile *p, bool enable )
|
2006-08-09 19:14:05 +00:00
|
|
|
{
|
2014-06-07 21:24:41 -07:00
|
|
|
brw_inst_set_saturate(p->brw, p->current, enable);
|
2006-08-09 19:14:05 +00:00
|
|
|
}
|
|
|
|
|
2014-05-31 16:57:02 -07:00
|
|
|
void brw_set_default_acc_write_control(struct brw_compile *p, unsigned value)
|
2010-08-20 14:37:19 -07:00
|
|
|
{
|
2014-06-10 17:44:56 -07:00
|
|
|
struct brw_context *brw = p->brw;
|
|
|
|
|
|
|
|
if (brw->gen >= 6)
|
2014-06-07 21:24:41 -07:00
|
|
|
brw_inst_set_acc_wr_control(p->brw, p->current, value);
|
2010-08-20 14:37:19 -07:00
|
|
|
}
|
|
|
|
|
2006-08-09 19:14:05 +00:00
|
|
|
void brw_push_insn_state( struct brw_compile *p )
|
|
|
|
{
|
|
|
|
assert(p->current != &p->stack[BRW_EU_MAX_INSN_STACK-1]);
|
2014-06-13 14:29:25 -07:00
|
|
|
memcpy(p->current + 1, p->current, sizeof(brw_inst));
|
2010-12-03 11:49:29 -08:00
|
|
|
p->compressed_stack[p->current - p->stack] = p->compressed;
|
2013-11-25 15:39:03 -08:00
|
|
|
p->current++;
|
2006-08-09 19:14:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void brw_pop_insn_state( struct brw_compile *p )
|
|
|
|
{
|
|
|
|
assert(p->current != p->stack);
|
|
|
|
p->current--;
|
2010-12-03 11:49:29 -08:00
|
|
|
p->compressed = p->compressed_stack[p->current - p->stack];
|
2006-08-09 19:14:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
*/
|
2011-05-16 11:49:57 -07:00
|
|
|
void
|
|
|
|
brw_init_compile(struct brw_context *brw, struct brw_compile *p, void *mem_ctx)
|
2006-08-09 19:14:05 +00:00
|
|
|
{
|
2012-08-30 16:22:52 -07:00
|
|
|
memset(p, 0, sizeof(*p));
|
|
|
|
|
2008-01-29 11:13:53 +08:00
|
|
|
p->brw = brw;
|
2011-12-21 15:38:44 +08:00
|
|
|
/*
|
|
|
|
* Set the initial instruction store array size to 1024, if found that
|
|
|
|
* isn't enough, then it will double the store size at brw_next_insn()
|
|
|
|
* until out of memory.
|
|
|
|
*/
|
|
|
|
p->store_size = 1024;
|
2014-06-13 14:29:25 -07:00
|
|
|
p->store = rzalloc_array(mem_ctx, brw_inst, p->store_size);
|
2006-08-09 19:14:05 +00:00
|
|
|
p->nr_insn = 0;
|
|
|
|
p->current = p->stack;
|
2010-12-03 11:49:29 -08:00
|
|
|
p->compressed = false;
|
2006-08-09 19:14:05 +00:00
|
|
|
memset(p->current, 0, sizeof(p->current[0]));
|
|
|
|
|
2011-05-16 11:49:57 -07:00
|
|
|
p->mem_ctx = mem_ctx;
|
|
|
|
|
2006-08-09 19:14:05 +00:00
|
|
|
/* Some defaults?
|
|
|
|
*/
|
2014-05-31 16:57:02 -07:00
|
|
|
brw_set_default_mask_control(p, BRW_MASK_ENABLE); /* what does this do? */
|
|
|
|
brw_set_default_saturate(p, 0);
|
|
|
|
brw_set_default_compression_control(p, BRW_COMPRESSION_NONE);
|
2011-05-16 12:25:18 -07:00
|
|
|
|
|
|
|
/* Set up control flow stack */
|
|
|
|
p->if_stack_depth = 0;
|
|
|
|
p->if_stack_array_size = 16;
|
2011-12-21 14:51:59 +08:00
|
|
|
p->if_stack = rzalloc_array(mem_ctx, int, p->if_stack_array_size);
|
2011-12-06 12:13:32 -08:00
|
|
|
|
|
|
|
p->loop_stack_depth = 0;
|
|
|
|
p->loop_stack_array_size = 16;
|
|
|
|
p->loop_stack = rzalloc_array(mem_ctx, int, p->loop_stack_array_size);
|
2011-12-06 12:44:41 -08:00
|
|
|
p->if_depth_in_loop = rzalloc_array(mem_ctx, int, p->loop_stack_array_size);
|
2012-02-10 16:32:56 -08:00
|
|
|
|
2013-07-02 23:17:14 -07:00
|
|
|
brw_init_compaction_tables(brw);
|
2006-08-09 19:14:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-11-25 15:51:24 -08:00
|
|
|
const unsigned *brw_get_program( struct brw_compile *p,
|
|
|
|
unsigned *sz )
|
2006-08-09 19:14:05 +00:00
|
|
|
{
|
2012-02-03 11:50:42 +01:00
|
|
|
*sz = p->next_insn_offset;
|
2013-11-25 15:51:24 -08:00
|
|
|
return (const unsigned *)p->store;
|
2006-08-09 19:14:05 +00:00
|
|
|
}
|
2012-02-03 11:50:42 +01:00
|
|
|
|
|
|
|
void
|
2014-05-15 16:10:09 -07:00
|
|
|
brw_disassemble(struct brw_context *brw,
|
|
|
|
void *assembly, int start, int end, FILE *out)
|
2012-02-03 11:50:42 +01:00
|
|
|
{
|
2012-01-31 16:55:20 -08:00
|
|
|
bool dump_hex = false;
|
2012-02-03 11:50:42 +01:00
|
|
|
|
2012-01-31 16:55:20 -08:00
|
|
|
for (int offset = start; offset < end;) {
|
2014-06-13 14:29:25 -07:00
|
|
|
brw_inst *insn = assembly + offset;
|
|
|
|
brw_inst uncompacted;
|
2014-06-07 21:24:41 -07:00
|
|
|
bool compacted = brw_inst_cmpt_control(brw, insn);
|
2014-07-17 16:29:41 -07:00
|
|
|
if (0)
|
|
|
|
fprintf(out, "0x%08x: ", offset);
|
2012-02-03 11:50:42 +01:00
|
|
|
|
2014-06-07 21:24:41 -07:00
|
|
|
if (compacted) {
|
2014-06-13 16:16:28 -07:00
|
|
|
brw_compact_inst *compacted = (void *)insn;
|
2012-01-31 16:55:20 -08:00
|
|
|
if (dump_hex) {
|
2013-12-05 17:34:56 +02:00
|
|
|
fprintf(out, "0x%08x 0x%08x ",
|
|
|
|
((uint32_t *)insn)[1],
|
|
|
|
((uint32_t *)insn)[0]);
|
2012-01-31 16:55:20 -08:00
|
|
|
}
|
|
|
|
|
2013-07-02 23:17:14 -07:00
|
|
|
brw_uncompact_instruction(brw, &uncompacted, compacted);
|
2012-01-31 16:55:20 -08:00
|
|
|
insn = &uncompacted;
|
|
|
|
offset += 8;
|
|
|
|
} else {
|
|
|
|
if (dump_hex) {
|
2013-12-05 17:34:56 +02:00
|
|
|
fprintf(out, "0x%08x 0x%08x 0x%08x 0x%08x ",
|
|
|
|
((uint32_t *)insn)[3],
|
|
|
|
((uint32_t *)insn)[2],
|
|
|
|
((uint32_t *)insn)[1],
|
|
|
|
((uint32_t *)insn)[0]);
|
2012-01-31 16:55:20 -08:00
|
|
|
}
|
|
|
|
offset += 16;
|
2012-02-03 11:50:42 +01:00
|
|
|
}
|
|
|
|
|
2014-06-12 16:08:02 -07:00
|
|
|
brw_disassemble_inst(out, brw, insn, compacted);
|
2012-02-03 11:50:42 +01:00
|
|
|
}
|
|
|
|
}
|