89 Commits

Author SHA1 Message Date
Damien Lespiau
f0365d40b4 assembler: Don't use GL types
sed -i -e 's/GLuint/unsigned/g' -e 's/GLint/int/g' \
       -e 's/GLfloat/float/g' -e 's/GLubyte/uint8_t/g' \
       -e 's/GLshort/int16_t/g' assembler/*.[ch]

Drop the GL types here, they don't bring anything to the table. For
instance, GLuint has no guarantee to be 32 bits, so it does not make too
much sense to use it in structure describing hardware tables and
opcodes.

Of course, some bikeshedding can be applied to use uin32_t instead, I
figured that some of the GLuint are used without size constraints, so
a sed with uint32_t did not seem the right thing to do. On top of that
initial sed, one bothered enough could change the structures with size
constraints to actually use uint32_t.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:42 +00:00
Damien Lespiau
2f502bcaaa assembler: Use defines for width
Instead of just using hardcoded numbers or resorting to ffs().

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:42 +00:00
Damien Lespiau
2de8b40c48 assembler: Merge declared_register's type into the reg structure
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:42 +00:00
Damien Lespiau
fa2b679cc9 assembler: Use set_instruction_src1() in send
No reason not to!

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:42 +00:00
Damien Lespiau
26da375471 assembler: Use brw_*() functions for 3-src instructions
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:41 +00:00
Damien Lespiau
49861a03b6 assembler: Introduce set_instruction_saturate()
Also simplify the logic that was setting the saturate bit in the math
instruction.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:41 +00:00
Damien Lespiau
b21c2e60e9 assembler: Introduce set_intruction_pred_cond()
This allow us to factor out the test that checks if, when using both
predicates and conditional modifiers, we are using the same flag
register.

Also get rid of of a FIXME that we are now dealing with (the warning
mentioned above).

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:41 +00:00
Damien Lespiau
5d526c8317 assembler: Introduce set_instruction_opcode()
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:41 +00:00
Damien Lespiau
6bf3aa84e0 assembler: Isolate all the options in their own structure
Like with the predicate fields before, there's no need to use the full
instruction to collect the list of options. This allows us to decouple
the list of options from a specific instruction encoding.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:41 +00:00
Damien Lespiau
bca2ff2a02 assembler: Unify adding options to the header
Right now we have duplicated code for when the option is the last in the
list or not. Put that code in a common function.

Interestingly it appears that both sides haven't been kept in sync and
that EOT and ACCWRCTRL had limitations on where they had to be in the
option list. It's fixed now!

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:41 +00:00
Damien Lespiau
dfe6adacc9 assembler: Gather all predicate data in its own structure
Rather than user a full instruction for that. Also use
set_instruction_predicate() for a case that coud not be done like that
before the refactoring (because everyone now uses the same instruction
structure).

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:41 +00:00
Damien Lespiau
9b78f74f23 assembler: Move struct relocation out of relocatable instructions
Now that all instructions (relocatable or not) are struct
brw_program_instructions, this means we can move the relocation specific
information out the "relocatable instruction" structure. This will allow
us to share the relocation information between different types of
instructions.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:41 +00:00
Damien Lespiau
f6e9052e8d assembler: Unify all instructions to be brw_program_instructions
Time to finally unify all instructions on the same structure.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:41 +00:00
Damien Lespiau
d008064b3e assembler: Renamed the instruction field to insn
This will be less typing for the refactoring to come (which is use
struct brw_program_instruction in gram.y for the type of all the
instructions).

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:41 +00:00
Damien Lespiau
888b2dcae6 assembler: Use brw_set_src1()
Everything is now aligned to be able to use brw_set_src1() in the
opcode generation, so use it.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:40 +00:00
Damien Lespiau
8eb30d9493 assembler: Fix ')' placement in condition
A small typo in the condition.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:40 +00:00
Damien Lespiau
1d53e1813e assembler: Cleanup visibility of a few global variables/functions
Not everything has to be exported out the compilation unit. Do a small
cleanup pass.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:40 +00:00
Damien Lespiau
6d3d369535 assembler: Port the warning and error reporting to warn()/error()
This way we ensure to have a single place where these are handled. The
immediate benefit is that now line numbers are always printed out, which
is quite handy.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:40 +00:00
Damien Lespiau
e7cca1a3ca assembler: Use brw_set_src0()
Unfortunately, it's all a walk in the park. Both, internal code in the
assembler and external shaders (libva) generate registers that trigger
assertions in brw_eu_emit.c's brw_validate().

To fix all that I took the option to be able to emit warning with the -W
flag but still make the assembler generate the same opcodes.

We can fix all this, but it requires validation, something that I cannot
do right now.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:40 +00:00
Damien Lespiau
1eb622a847 assembler: Add the input filename to the error/warning messages
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:40 +00:00
Damien Lespiau
95b12082d2 assembler: Add a check for when ExecSize and width are 1
Another check (that we hit if we try to use brw_set_src0()). Again,
protect it with the -W option.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:40 +00:00
Damien Lespiau
d70e9f824f assembler: Add a check for when width is 1 and hstride is not 0
The list of region restrictions in bspec do say that we can't have:
     width == 1 && hstrize != 0

We do have plenty of assembly code that don't respect that behaviour. So
let's hide the warning under a -W flag (for now) while we fix things.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:40 +00:00
Damien Lespiau
e9172aa225 assembler: Add error() and warn() shorthands and use them in set_src[01]
Now that we have locations, we can write error() and warn() functions
giving more information about where it's going wrong.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:39 +00:00
Damien Lespiau
d94e8a6cf0 assembler: Add location support
Let's generate location information about the tokens we are parsing.
This can be used to give accurate location when reporting errors and
warnings.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:39 +00:00
Damien Lespiau
574a249142 assembler: Don't warn if identical declared registers are redefined
There's no real need to warn when the same register is declared twice.
Currently the libva driver does do that and this warning makes other
errors really hide in a sea of warnings.

Redefining a register with different parameters is a real error though,
so we should not allow that and error out in that case.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:39 +00:00
Damien Lespiau
9c72beb701 assembler: Store immediate values in reg.dw1.ud
Another step in pushing the parsing in struct brw_reg.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:39 +00:00
Damien Lespiau
c0592b2882 assembler: Factor out the source register validation
The goal is to use brw_set_src[01](), so let's start by validating the
register we have before generating the opcode.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:39 +00:00
Damien Lespiau
9fcc1bdcad assembler: Use brw_set_dest() to encode the destination
A few notes:

I needed to introduce a brw context and compile structs. These are only
used to get which generation we are compiling code for, but eventually
we can use more of the infrastructure.

brw_set_dest() uses the destination register width to program the
instruction execution size.

The assembler can either take subnr in bytes or in number of elements,
so we need a resolve step when setting a brw_reg.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:39 +00:00
Damien Lespiau
5e0da9f854 assembler: Factor out the destination register validation
The goal is to use brw_set_dest(), so let's start by validating the
register we have before generating the opcode.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:39 +00:00
Damien Lespiau
9d5a87a096 assembler: Use brw_reg in the source operand
Last refactoring step in transition to struct brw_reg.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:38 +00:00
Damien Lespiau
c13613ea2d assembler: Get rid of src operand's swizzle_set
swizzle_set can be derived from the value of swizzle itself, no need for
that field.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:38 +00:00
Damien Lespiau
a82722b60f assembler: Consolidate the swizzling configuration on 8 bits
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:38 +00:00
Damien Lespiau
0375073f05 assembler: Replace struct dst_operand by struct brw_reg
One more step on the road to replacing all register-like structures by
struct brw_reg.

Two things in this commit are worth noting:

* As we are using more and more brw_reg, a lot of the field-by-field
  assignments can be replaced by 1 assignment which results is a
  reduction of code

* As the destination horizontal stride is now stored on 2 bits in
  brw_reg, it's not possible to defer the handling of DEFAULT_DSTREGION
  (aka (int)-1) when setting the destination operand. It has to be done
  when parsing the region and resolve_dst_region() is a helper for that
  task.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:38 +00:00
Damien Lespiau
801b4eb1b3 assembler: Unify the direct and indirect register type
They are all struct brw_reg registers now.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:38 +00:00
Damien Lespiau
36f8f65aa0 assembler: Replace struct indirect_reg by struct brw_reg
More code simplification can be layered on top of that (by using some
brw_* helpers to create registers), that'd be for another commit.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:38 +00:00
Damien Lespiau
b33b8810e0 assembler: Replace struct direct_reg by struct brw_reg
More code simplification can be layered on top of that (by using some
brw_* helpers to create registers), that'd be for another commit.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:38 +00:00
Damien Lespiau
cce4fc2c36 assembler: Make struct declared_register use struct brw_reg
It's time to start converting the emission code in gram.y to use libbrw
infrastructure. Let's start with using brw_reg for declared register.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:38 +00:00
Damien Lespiau
79c62f1134 assembler: Don't change the size of opcodes!
Until now, the assembler had relocation-related fields added to struct
brw_instruction. This changes the size of the structure and break code
assuming the opcode structure is really 16 bytes, for instance the
emission code in brw_eu_emit.c.

With this commit, we build on the infrastructure that slowly emerged in
the few previous commits to add a relocatable instruction with the
needed fields.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:38 +00:00
Damien Lespiau
a45a47183a assembler: Make explicit that labels are part of the instructions list
The output of the parsing is a list of struct brw_program_instruction.
These instructions can be either GEN instructions aka struct
brw_instruction or labels. To make this more explicit we now have a type
to test to determine which instruction we are dealing with.

This will also allow to to pull the relocation bits into struct
brw_program_instruction instead of having them in the structure
representing the opcodes.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:38 +00:00
Damien Lespiau
73d58edab9 assembler: Refactor the code adding instructions and labels
Factoring out the code from the grammar will allow us to switch to
using brw_compile in a cleaner way.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:38 +00:00
Damien Lespiau
c716e2bdb4 assembler: Simplify get_subreg_address()
This function can only be called to resolve subreg_nr in direct mode
(there is an other function for the indirect case) and it makes no sense
to call it with an immediate operand.

Express those facts with asserts and simplify the logic.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:37 +00:00
Damien Lespiau
8322802acb assembler: Use subreg_nr to store the address register subreg
Another step towards using struct brw_reg for source and destination
operands.

Instead of having a separate field to store the sub register number of
the address register in indirect access mode, we can reuse the subreg_nr
field that was only used for direct access so far.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:37 +00:00
Damien Lespiau
02019d4d55 assembler: Remove the writemask_set field of struct dest_operand
writemask_set gets in the way of switching to using struct brw_reg and
it's possible to derive it from the writemask value.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:37 +00:00
Damien Lespiau
db6f5e08ba assembler: Use BRW_WRITEMASK_XYZW instead of the 0xf constant
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:37 +00:00
Damien Lespiau
4431869bef assembler: Rename BRW_ACCWRCTRL_ACCWRCTRL
To a more self-describing define. This hopefully will help its inclusion
into Mesa.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:36 +00:00
Damien Lespiau
5e7e3f43a5 assembler: Adopt enum brw_message_target from mesa
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:36 +00:00
Damien Lespiau
0fde3ddccc assembler: Rename gen5 DP pixel_scoreboard_clear to last_render_target
The purpose of this commit is to synchronize opcode definitions across
the gen4asm assembler and mesa.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:36 +00:00
Damien Lespiau
fe0bd3776e assembler: Remove struct dp_write_gen6 and struct use gen6_dp
We ended up with 2 structures that where exactly the same, so just use
one, which happens to be the one Mesa has.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:36 +00:00
Damien Lespiau
8fa561d4bb assembler: Rename dp_gen7 to gen7_dp and sync it with Mesa's
The purpose of this commit is to synchronize opcode definitions across
the gen4asm assembler and mesa.

I had to drop how mesa splits msg_control as the current assembly
language gives access the the whole msg_control field.

Recompiling the xorg and the intel driver of libva shaders doesn't show
any difference in the assembly created.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:36 +00:00
Damien Lespiau
1f1ad59746 assembler: Rename dp_gen6 to gen6_dp and sync with Mesa's
The purpose of this commit is to synchronize opcode definitions across
the gen4asm assembler and mesa.

I had to drop how mesa splits msg_control as the current assembly
language gives access the the whole msg_control field.

Recompiling the xorg and the intel driver of libva shaders doesn't show
any difference in the assembly created.

Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
2013-03-04 15:54:36 +00:00