103b705cfSriastradh/* 203b705cfSriastradh Copyright (C) Intel Corp. 2006. All Rights Reserved. 303b705cfSriastradh Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to 403b705cfSriastradh develop this 3D driver. 503b705cfSriastradh 603b705cfSriastradh Permission is hereby granted, free of charge, to any person obtaining 703b705cfSriastradh a copy of this software and associated documentation files (the 803b705cfSriastradh "Software"), to deal in the Software without restriction, including 903b705cfSriastradh without limitation the rights to use, copy, modify, merge, publish, 1003b705cfSriastradh distribute, sublicense, and/or sell copies of the Software, and to 1103b705cfSriastradh permit persons to whom the Software is furnished to do so, subject to 1203b705cfSriastradh the following conditions: 1303b705cfSriastradh 1403b705cfSriastradh The above copyright notice and this permission notice (including the 1503b705cfSriastradh next paragraph) shall be included in all copies or substantial 1603b705cfSriastradh portions of the Software. 1703b705cfSriastradh 1803b705cfSriastradh THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 1903b705cfSriastradh EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2003b705cfSriastradh MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 2103b705cfSriastradh IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE 2203b705cfSriastradh LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 2303b705cfSriastradh OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 2403b705cfSriastradh WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 2503b705cfSriastradh 2603b705cfSriastradh **********************************************************************/ 2703b705cfSriastradh/* 2803b705cfSriastradh * Authors: 2903b705cfSriastradh * Keith Whitwell <keith@tungstengraphics.com> 3003b705cfSriastradh */ 3103b705cfSriastradh 3203b705cfSriastradh#ifndef BRW_EU_H 3303b705cfSriastradh#define BRW_EU_H 3403b705cfSriastradh 3503b705cfSriastradh#include <stdbool.h> 3603b705cfSriastradh#include <stdint.h> 3703b705cfSriastradh#include <stdio.h> 3813496ba1Ssnj 3903b705cfSriastradh#include <assert.h> 4003b705cfSriastradh 4103b705cfSriastradh#define BRW_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<2) | ((c)<<4) | ((d)<<6)) 4203b705cfSriastradh#define BRW_GET_SWZ(swz, idx) (((swz) >> ((idx)*2)) & 0x3) 4303b705cfSriastradh 4403b705cfSriastradh#define BRW_SWIZZLE_NOOP BRW_SWIZZLE4(0,1,2,3) 4503b705cfSriastradh#define BRW_SWIZZLE_XYZW BRW_SWIZZLE4(0,1,2,3) 4603b705cfSriastradh#define BRW_SWIZZLE_XXXX BRW_SWIZZLE4(0,0,0,0) 4703b705cfSriastradh#define BRW_SWIZZLE_YYYY BRW_SWIZZLE4(1,1,1,1) 4803b705cfSriastradh#define BRW_SWIZZLE_ZZZZ BRW_SWIZZLE4(2,2,2,2) 4903b705cfSriastradh#define BRW_SWIZZLE_WWWW BRW_SWIZZLE4(3,3,3,3) 5003b705cfSriastradh#define BRW_SWIZZLE_XYXY BRW_SWIZZLE4(0,1,0,1) 5103b705cfSriastradh 5203b705cfSriastradh#define WRITEMASK_X 0x1 5303b705cfSriastradh#define WRITEMASK_Y 0x2 5403b705cfSriastradh#define WRITEMASK_Z 0x4 5503b705cfSriastradh#define WRITEMASK_W 0x8 5603b705cfSriastradh 5703b705cfSriastradh#define WRITEMASK_XY (WRITEMASK_X | WRITEMASK_Y) 5803b705cfSriastradh#define WRITEMASK_XYZ (WRITEMASK_X | WRITEMASK_Y | WRITEMASK_Z) 5903b705cfSriastradh#define WRITEMASK_XYZW (WRITEMASK_X | WRITEMASK_Y | WRITEMASK_Z | WRITEMASK_W) 6003b705cfSriastradh 6103b705cfSriastradh/** Number of general purpose registers (VS, WM, etc) */ 6203b705cfSriastradh#define BRW_MAX_GRF 128 6303b705cfSriastradh 6403b705cfSriastradh/** Number of message register file registers */ 6503b705cfSriastradh#define BRW_MAX_MRF 16 6603b705cfSriastradh 6703b705cfSriastradh 6803b705cfSriastradh#define BRW_ALIGN_1 0 6903b705cfSriastradh#define BRW_ALIGN_16 1 7003b705cfSriastradh 7103b705cfSriastradh#define BRW_ADDRESS_DIRECT 0 7203b705cfSriastradh#define BRW_ADDRESS_REGISTER_INDIRECT_REGISTER 1 7303b705cfSriastradh 7403b705cfSriastradh#define BRW_CHANNEL_X 0 7503b705cfSriastradh#define BRW_CHANNEL_Y 1 7603b705cfSriastradh#define BRW_CHANNEL_Z 2 7703b705cfSriastradh#define BRW_CHANNEL_W 3 7803b705cfSriastradh 7903b705cfSriastradhenum brw_compression { 8003b705cfSriastradh BRW_COMPRESSION_NONE, 8103b705cfSriastradh BRW_COMPRESSION_2NDHALF, 8203b705cfSriastradh BRW_COMPRESSION_COMPRESSED, 8303b705cfSriastradh}; 8403b705cfSriastradh 8503b705cfSriastradh#define GEN6_COMPRESSION_1Q 0 8603b705cfSriastradh#define GEN6_COMPRESSION_2Q 1 8703b705cfSriastradh#define GEN6_COMPRESSION_3Q 2 8803b705cfSriastradh#define GEN6_COMPRESSION_4Q 3 8903b705cfSriastradh#define GEN6_COMPRESSION_1H 0 9003b705cfSriastradh#define GEN6_COMPRESSION_2H 2 9103b705cfSriastradh 9203b705cfSriastradh#define BRW_CONDITIONAL_NONE 0 9303b705cfSriastradh#define BRW_CONDITIONAL_Z 1 9403b705cfSriastradh#define BRW_CONDITIONAL_NZ 2 9503b705cfSriastradh#define BRW_CONDITIONAL_EQ 1 /* Z */ 9603b705cfSriastradh#define BRW_CONDITIONAL_NEQ 2 /* NZ */ 9703b705cfSriastradh#define BRW_CONDITIONAL_G 3 9803b705cfSriastradh#define BRW_CONDITIONAL_GE 4 9903b705cfSriastradh#define BRW_CONDITIONAL_L 5 10003b705cfSriastradh#define BRW_CONDITIONAL_LE 6 10103b705cfSriastradh#define BRW_CONDITIONAL_R 7 10203b705cfSriastradh#define BRW_CONDITIONAL_O 8 10303b705cfSriastradh#define BRW_CONDITIONAL_U 9 10403b705cfSriastradh 10503b705cfSriastradh#define BRW_DEBUG_NONE 0 10603b705cfSriastradh#define BRW_DEBUG_BREAKPOINT 1 10703b705cfSriastradh 10803b705cfSriastradh#define BRW_DEPENDENCY_NORMAL 0 10903b705cfSriastradh#define BRW_DEPENDENCY_NOTCLEARED 1 11003b705cfSriastradh#define BRW_DEPENDENCY_NOTCHECKED 2 11103b705cfSriastradh#define BRW_DEPENDENCY_DISABLE 3 11203b705cfSriastradh 11303b705cfSriastradh#define BRW_EXECUTE_1 0 11403b705cfSriastradh#define BRW_EXECUTE_2 1 11503b705cfSriastradh#define BRW_EXECUTE_4 2 11603b705cfSriastradh#define BRW_EXECUTE_8 3 11703b705cfSriastradh#define BRW_EXECUTE_16 4 11803b705cfSriastradh#define BRW_EXECUTE_32 5 11903b705cfSriastradh 12003b705cfSriastradh#define BRW_HORIZONTAL_STRIDE_0 0 12103b705cfSriastradh#define BRW_HORIZONTAL_STRIDE_1 1 12203b705cfSriastradh#define BRW_HORIZONTAL_STRIDE_2 2 12303b705cfSriastradh#define BRW_HORIZONTAL_STRIDE_4 3 12403b705cfSriastradh 12503b705cfSriastradh#define BRW_INSTRUCTION_NORMAL 0 12603b705cfSriastradh#define BRW_INSTRUCTION_SATURATE 1 12703b705cfSriastradh 12803b705cfSriastradh#define BRW_MASK_ENABLE 0 12903b705cfSriastradh#define BRW_MASK_DISABLE 1 13003b705cfSriastradh 13103b705cfSriastradh/** @{ 13203b705cfSriastradh * 13303b705cfSriastradh * Gen6 has replaced "mask enable/disable" with WECtrl, which is 13403b705cfSriastradh * effectively the same but much simpler to think about. Now, there 13503b705cfSriastradh * are two contributors ANDed together to whether channels are 13603b705cfSriastradh * executed: The predication on the instruction, and the channel write 13703b705cfSriastradh * enable. 13803b705cfSriastradh */ 13903b705cfSriastradh/** 14003b705cfSriastradh * This is the default value. It means that a channel's write enable is set 14103b705cfSriastradh * if the per-channel IP is pointing at this instruction. 14203b705cfSriastradh */ 14303b705cfSriastradh#define BRW_WE_NORMAL 0 14403b705cfSriastradh/** 14503b705cfSriastradh * This is used like BRW_MASK_DISABLE, and causes all channels to have 14603b705cfSriastradh * their write enable set. Note that predication still contributes to 14703b705cfSriastradh * whether the channel actually gets written. 14803b705cfSriastradh */ 14903b705cfSriastradh#define BRW_WE_ALL 1 15003b705cfSriastradh/** @} */ 15103b705cfSriastradh 15203b705cfSriastradhenum opcode { 15303b705cfSriastradh /* These are the actual hardware opcodes. */ 15403b705cfSriastradh BRW_OPCODE_MOV = 1, 15503b705cfSriastradh BRW_OPCODE_SEL = 2, 15603b705cfSriastradh BRW_OPCODE_NOT = 4, 15703b705cfSriastradh BRW_OPCODE_AND = 5, 15803b705cfSriastradh BRW_OPCODE_OR = 6, 15903b705cfSriastradh BRW_OPCODE_XOR = 7, 16003b705cfSriastradh BRW_OPCODE_SHR = 8, 16103b705cfSriastradh BRW_OPCODE_SHL = 9, 16203b705cfSriastradh BRW_OPCODE_RSR = 10, 16303b705cfSriastradh BRW_OPCODE_RSL = 11, 16403b705cfSriastradh BRW_OPCODE_ASR = 12, 16503b705cfSriastradh BRW_OPCODE_CMP = 16, 16603b705cfSriastradh BRW_OPCODE_CMPN = 17, 16703b705cfSriastradh BRW_OPCODE_JMPI = 32, 16803b705cfSriastradh BRW_OPCODE_IF = 34, 16903b705cfSriastradh BRW_OPCODE_IFF = 35, 17003b705cfSriastradh BRW_OPCODE_ELSE = 36, 17103b705cfSriastradh BRW_OPCODE_ENDIF = 37, 17203b705cfSriastradh BRW_OPCODE_DO = 38, 17303b705cfSriastradh BRW_OPCODE_WHILE = 39, 17403b705cfSriastradh BRW_OPCODE_BREAK = 40, 17503b705cfSriastradh BRW_OPCODE_CONTINUE = 41, 17603b705cfSriastradh BRW_OPCODE_HALT = 42, 17703b705cfSriastradh BRW_OPCODE_MSAVE = 44, 17803b705cfSriastradh BRW_OPCODE_MRESTORE = 45, 17903b705cfSriastradh BRW_OPCODE_PUSH = 46, 18003b705cfSriastradh BRW_OPCODE_POP = 47, 18103b705cfSriastradh BRW_OPCODE_WAIT = 48, 18203b705cfSriastradh BRW_OPCODE_SEND = 49, 18303b705cfSriastradh BRW_OPCODE_SENDC = 50, 18403b705cfSriastradh BRW_OPCODE_MATH = 56, 18503b705cfSriastradh BRW_OPCODE_ADD = 64, 18603b705cfSriastradh BRW_OPCODE_MUL = 65, 18703b705cfSriastradh BRW_OPCODE_AVG = 66, 18803b705cfSriastradh BRW_OPCODE_FRC = 67, 18903b705cfSriastradh BRW_OPCODE_RNDU = 68, 19003b705cfSriastradh BRW_OPCODE_RNDD = 69, 19103b705cfSriastradh BRW_OPCODE_RNDE = 70, 19203b705cfSriastradh BRW_OPCODE_RNDZ = 71, 19303b705cfSriastradh BRW_OPCODE_MAC = 72, 19403b705cfSriastradh BRW_OPCODE_MACH = 73, 19503b705cfSriastradh BRW_OPCODE_LZD = 74, 19603b705cfSriastradh BRW_OPCODE_SAD2 = 80, 19703b705cfSriastradh BRW_OPCODE_SADA2 = 81, 19803b705cfSriastradh BRW_OPCODE_DP4 = 84, 19903b705cfSriastradh BRW_OPCODE_DPH = 85, 20003b705cfSriastradh BRW_OPCODE_DP3 = 86, 20103b705cfSriastradh BRW_OPCODE_DP2 = 87, 20203b705cfSriastradh BRW_OPCODE_DPA2 = 88, 20303b705cfSriastradh BRW_OPCODE_LINE = 89, 20403b705cfSriastradh BRW_OPCODE_PLN = 90, 20503b705cfSriastradh BRW_OPCODE_NOP = 126, 20603b705cfSriastradh 20703b705cfSriastradh /* These are compiler backend opcodes that get translated into other 20803b705cfSriastradh * instructions. 20903b705cfSriastradh */ 21003b705cfSriastradh FS_OPCODE_FB_WRITE = 128, 21103b705cfSriastradh SHADER_OPCODE_RCP, 21203b705cfSriastradh SHADER_OPCODE_RSQ, 21303b705cfSriastradh SHADER_OPCODE_SQRT, 21403b705cfSriastradh SHADER_OPCODE_EXP2, 21503b705cfSriastradh SHADER_OPCODE_LOG2, 21603b705cfSriastradh SHADER_OPCODE_POW, 21703b705cfSriastradh SHADER_OPCODE_SIN, 21803b705cfSriastradh SHADER_OPCODE_COS, 21903b705cfSriastradh FS_OPCODE_DDX, 22003b705cfSriastradh FS_OPCODE_DDY, 22103b705cfSriastradh FS_OPCODE_PIXEL_X, 22203b705cfSriastradh FS_OPCODE_PIXEL_Y, 22303b705cfSriastradh FS_OPCODE_CINTERP, 22403b705cfSriastradh FS_OPCODE_LINTERP, 22503b705cfSriastradh FS_OPCODE_TEX, 22603b705cfSriastradh FS_OPCODE_TXB, 22703b705cfSriastradh FS_OPCODE_TXD, 22803b705cfSriastradh FS_OPCODE_TXF, 22903b705cfSriastradh FS_OPCODE_TXL, 23003b705cfSriastradh FS_OPCODE_TXS, 23103b705cfSriastradh FS_OPCODE_DISCARD, 23203b705cfSriastradh FS_OPCODE_SPILL, 23303b705cfSriastradh FS_OPCODE_UNSPILL, 23403b705cfSriastradh FS_OPCODE_PULL_CONSTANT_LOAD, 23503b705cfSriastradh 23603b705cfSriastradh VS_OPCODE_URB_WRITE, 23703b705cfSriastradh VS_OPCODE_SCRATCH_READ, 23803b705cfSriastradh VS_OPCODE_SCRATCH_WRITE, 23903b705cfSriastradh VS_OPCODE_PULL_CONSTANT_LOAD, 24003b705cfSriastradh}; 24103b705cfSriastradh 24203b705cfSriastradh#define BRW_PREDICATE_NONE 0 24303b705cfSriastradh#define BRW_PREDICATE_NORMAL 1 24403b705cfSriastradh#define BRW_PREDICATE_ALIGN1_ANYV 2 24503b705cfSriastradh#define BRW_PREDICATE_ALIGN1_ALLV 3 24603b705cfSriastradh#define BRW_PREDICATE_ALIGN1_ANY2H 4 24703b705cfSriastradh#define BRW_PREDICATE_ALIGN1_ALL2H 5 24803b705cfSriastradh#define BRW_PREDICATE_ALIGN1_ANY4H 6 24903b705cfSriastradh#define BRW_PREDICATE_ALIGN1_ALL4H 7 25003b705cfSriastradh#define BRW_PREDICATE_ALIGN1_ANY8H 8 25103b705cfSriastradh#define BRW_PREDICATE_ALIGN1_ALL8H 9 25203b705cfSriastradh#define BRW_PREDICATE_ALIGN1_ANY16H 10 25303b705cfSriastradh#define BRW_PREDICATE_ALIGN1_ALL16H 11 25403b705cfSriastradh#define BRW_PREDICATE_ALIGN16_REPLICATE_X 2 25503b705cfSriastradh#define BRW_PREDICATE_ALIGN16_REPLICATE_Y 3 25603b705cfSriastradh#define BRW_PREDICATE_ALIGN16_REPLICATE_Z 4 25703b705cfSriastradh#define BRW_PREDICATE_ALIGN16_REPLICATE_W 5 25803b705cfSriastradh#define BRW_PREDICATE_ALIGN16_ANY4H 6 25903b705cfSriastradh#define BRW_PREDICATE_ALIGN16_ALL4H 7 26003b705cfSriastradh 26103b705cfSriastradh#define BRW_ARCHITECTURE_REGISTER_FILE 0 26203b705cfSriastradh#define BRW_GENERAL_REGISTER_FILE 1 26303b705cfSriastradh#define BRW_MESSAGE_REGISTER_FILE 2 26403b705cfSriastradh#define BRW_IMMEDIATE_VALUE 3 26503b705cfSriastradh 26603b705cfSriastradh#define BRW_REGISTER_TYPE_UD 0 26703b705cfSriastradh#define BRW_REGISTER_TYPE_D 1 26803b705cfSriastradh#define BRW_REGISTER_TYPE_UW 2 26903b705cfSriastradh#define BRW_REGISTER_TYPE_W 3 27003b705cfSriastradh#define BRW_REGISTER_TYPE_UB 4 27103b705cfSriastradh#define BRW_REGISTER_TYPE_B 5 27203b705cfSriastradh#define BRW_REGISTER_TYPE_VF 5 /* packed float vector, immediates only? */ 27303b705cfSriastradh#define BRW_REGISTER_TYPE_HF 6 27403b705cfSriastradh#define BRW_REGISTER_TYPE_V 6 /* packed int vector, immediates only, uword dest only */ 27503b705cfSriastradh#define BRW_REGISTER_TYPE_F 7 27603b705cfSriastradh 27703b705cfSriastradh#define BRW_ARF_NULL 0x00 27803b705cfSriastradh#define BRW_ARF_ADDRESS 0x10 27903b705cfSriastradh#define BRW_ARF_ACCUMULATOR 0x20 28003b705cfSriastradh#define BRW_ARF_FLAG 0x30 28103b705cfSriastradh#define BRW_ARF_MASK 0x40 28203b705cfSriastradh#define BRW_ARF_MASK_STACK 0x50 28303b705cfSriastradh#define BRW_ARF_MASK_STACK_DEPTH 0x60 28403b705cfSriastradh#define BRW_ARF_STATE 0x70 28503b705cfSriastradh#define BRW_ARF_CONTROL 0x80 28603b705cfSriastradh#define BRW_ARF_NOTIFICATION_COUNT 0x90 28703b705cfSriastradh#define BRW_ARF_IP 0xA0 28803b705cfSriastradh 28903b705cfSriastradh#define BRW_MRF_COMPR4 (1 << 7) 29003b705cfSriastradh 29103b705cfSriastradh#define BRW_AMASK 0 29203b705cfSriastradh#define BRW_IMASK 1 29303b705cfSriastradh#define BRW_LMASK 2 29403b705cfSriastradh#define BRW_CMASK 3 29503b705cfSriastradh 29603b705cfSriastradh#define BRW_THREAD_NORMAL 0 29703b705cfSriastradh#define BRW_THREAD_ATOMIC 1 29803b705cfSriastradh#define BRW_THREAD_SWITCH 2 29903b705cfSriastradh 30003b705cfSriastradh#define BRW_VERTICAL_STRIDE_0 0 30103b705cfSriastradh#define BRW_VERTICAL_STRIDE_1 1 30203b705cfSriastradh#define BRW_VERTICAL_STRIDE_2 2 30303b705cfSriastradh#define BRW_VERTICAL_STRIDE_4 3 30403b705cfSriastradh#define BRW_VERTICAL_STRIDE_8 4 30503b705cfSriastradh#define BRW_VERTICAL_STRIDE_16 5 30603b705cfSriastradh#define BRW_VERTICAL_STRIDE_32 6 30703b705cfSriastradh#define BRW_VERTICAL_STRIDE_64 7 30803b705cfSriastradh#define BRW_VERTICAL_STRIDE_128 8 30903b705cfSriastradh#define BRW_VERTICAL_STRIDE_256 9 31003b705cfSriastradh#define BRW_VERTICAL_STRIDE_ONE_DIMENSIONAL 0xF 31103b705cfSriastradh 31203b705cfSriastradh#define BRW_WIDTH_1 0 31303b705cfSriastradh#define BRW_WIDTH_2 1 31403b705cfSriastradh#define BRW_WIDTH_4 2 31503b705cfSriastradh#define BRW_WIDTH_8 3 31603b705cfSriastradh#define BRW_WIDTH_16 4 31703b705cfSriastradh 31803b705cfSriastradh#define BRW_STATELESS_BUFFER_BOUNDARY_1K 0 31903b705cfSriastradh#define BRW_STATELESS_BUFFER_BOUNDARY_2K 1 32003b705cfSriastradh#define BRW_STATELESS_BUFFER_BOUNDARY_4K 2 32103b705cfSriastradh#define BRW_STATELESS_BUFFER_BOUNDARY_8K 3 32203b705cfSriastradh#define BRW_STATELESS_BUFFER_BOUNDARY_16K 4 32303b705cfSriastradh#define BRW_STATELESS_BUFFER_BOUNDARY_32K 5 32403b705cfSriastradh#define BRW_STATELESS_BUFFER_BOUNDARY_64K 6 32503b705cfSriastradh#define BRW_STATELESS_BUFFER_BOUNDARY_128K 7 32603b705cfSriastradh#define BRW_STATELESS_BUFFER_BOUNDARY_256K 8 32703b705cfSriastradh#define BRW_STATELESS_BUFFER_BOUNDARY_512K 9 32803b705cfSriastradh#define BRW_STATELESS_BUFFER_BOUNDARY_1M 10 32903b705cfSriastradh#define BRW_STATELESS_BUFFER_BOUNDARY_2M 11 33003b705cfSriastradh 33103b705cfSriastradh#define BRW_POLYGON_FACING_FRONT 0 33203b705cfSriastradh#define BRW_POLYGON_FACING_BACK 1 33303b705cfSriastradh 33403b705cfSriastradh#define BRW_MESSAGE_TARGET_NULL 0 33503b705cfSriastradh#define BRW_MESSAGE_TARGET_MATH 1 /* reserved on GEN6 */ 33603b705cfSriastradh#define BRW_MESSAGE_TARGET_SAMPLER 2 33703b705cfSriastradh#define BRW_MESSAGE_TARGET_GATEWAY 3 33803b705cfSriastradh#define BRW_MESSAGE_TARGET_DATAPORT_READ 4 33903b705cfSriastradh#define BRW_MESSAGE_TARGET_DATAPORT_WRITE 5 34003b705cfSriastradh#define BRW_MESSAGE_TARGET_URB 6 34103b705cfSriastradh#define BRW_MESSAGE_TARGET_THREAD_SPAWNER 7 34203b705cfSriastradh 34303b705cfSriastradh#define GEN6_MESSAGE_TARGET_DP_SAMPLER_CACHE 4 34403b705cfSriastradh#define GEN6_MESSAGE_TARGET_DP_RENDER_CACHE 5 34503b705cfSriastradh#define GEN6_MESSAGE_TARGET_DP_CONST_CACHE 9 34603b705cfSriastradh 34703b705cfSriastradh#define BRW_SAMPLER_RETURN_FORMAT_FLOAT32 0 34803b705cfSriastradh#define BRW_SAMPLER_RETURN_FORMAT_UINT32 2 34903b705cfSriastradh#define BRW_SAMPLER_RETURN_FORMAT_SINT32 3 35003b705cfSriastradh 35103b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SAMPLE 0 35203b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE 0 35303b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE 0 35403b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_BIAS 0 35503b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SIMD8_KILLPIX 1 35603b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_LOD 1 35703b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_LOD 1 35803b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_GRADIENTS 2 35903b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_GRADIENTS 2 36003b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SIMD4X2_SAMPLE_COMPARE 0 36103b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SIMD16_SAMPLE_COMPARE 2 36203b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_BIAS_COMPARE 0 36303b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SIMD8_SAMPLE_LOD_COMPARE 1 36403b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SIMD4X2_RESINFO 2 36503b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SIMD16_RESINFO 2 36603b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SIMD4X2_LD 3 36703b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SIMD8_LD 3 36803b705cfSriastradh#define BRW_SAMPLER_MESSAGE_SIMD16_LD 3 36903b705cfSriastradh 37003b705cfSriastradh#define GEN5_SAMPLER_MESSAGE_SAMPLE 0 37103b705cfSriastradh#define GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS 1 37203b705cfSriastradh#define GEN5_SAMPLER_MESSAGE_SAMPLE_LOD 2 37303b705cfSriastradh#define GEN5_SAMPLER_MESSAGE_SAMPLE_COMPARE 3 37403b705cfSriastradh#define GEN5_SAMPLER_MESSAGE_SAMPLE_DERIVS 4 37503b705cfSriastradh#define GEN5_SAMPLER_MESSAGE_SAMPLE_BIAS_COMPARE 5 37603b705cfSriastradh#define GEN5_SAMPLER_MESSAGE_SAMPLE_LOD_COMPARE 6 37703b705cfSriastradh#define GEN5_SAMPLER_MESSAGE_SAMPLE_LD 7 37803b705cfSriastradh#define GEN5_SAMPLER_MESSAGE_SAMPLE_RESINFO 10 37903b705cfSriastradh 38003b705cfSriastradh/* for GEN5 only */ 38103b705cfSriastradh#define BRW_SAMPLER_SIMD_MODE_SIMD4X2 0 38203b705cfSriastradh#define BRW_SAMPLER_SIMD_MODE_SIMD8 1 38303b705cfSriastradh#define BRW_SAMPLER_SIMD_MODE_SIMD16 2 38403b705cfSriastradh#define BRW_SAMPLER_SIMD_MODE_SIMD32_64 3 38503b705cfSriastradh 38603b705cfSriastradh#define BRW_DATAPORT_OWORD_BLOCK_1_OWORDLOW 0 38703b705cfSriastradh#define BRW_DATAPORT_OWORD_BLOCK_1_OWORDHIGH 1 38803b705cfSriastradh#define BRW_DATAPORT_OWORD_BLOCK_2_OWORDS 2 38903b705cfSriastradh#define BRW_DATAPORT_OWORD_BLOCK_4_OWORDS 3 39003b705cfSriastradh#define BRW_DATAPORT_OWORD_BLOCK_8_OWORDS 4 39103b705cfSriastradh 39203b705cfSriastradh#define BRW_DATAPORT_OWORD_DUAL_BLOCK_1OWORD 0 39303b705cfSriastradh#define BRW_DATAPORT_OWORD_DUAL_BLOCK_4OWORDS 2 39403b705cfSriastradh 39503b705cfSriastradh#define BRW_DATAPORT_DWORD_SCATTERED_BLOCK_8DWORDS 2 39603b705cfSriastradh#define BRW_DATAPORT_DWORD_SCATTERED_BLOCK_16DWORDS 3 39703b705cfSriastradh 39803b705cfSriastradh/* This one stays the same across generations. */ 39903b705cfSriastradh#define BRW_DATAPORT_READ_MESSAGE_OWORD_BLOCK_READ 0 40003b705cfSriastradh/* GEN4 */ 40103b705cfSriastradh#define BRW_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ 1 40203b705cfSriastradh#define BRW_DATAPORT_READ_MESSAGE_MEDIA_BLOCK_READ 2 40303b705cfSriastradh#define BRW_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ 3 40403b705cfSriastradh/* G45, GEN5 */ 40503b705cfSriastradh#define G45_DATAPORT_READ_MESSAGE_RENDER_UNORM_READ 1 40603b705cfSriastradh#define G45_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ 2 40703b705cfSriastradh#define G45_DATAPORT_READ_MESSAGE_AVC_LOOP_FILTER_READ 3 40803b705cfSriastradh#define G45_DATAPORT_READ_MESSAGE_MEDIA_BLOCK_READ 4 40903b705cfSriastradh#define G45_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ 6 41003b705cfSriastradh/* GEN6 */ 41103b705cfSriastradh#define GEN6_DATAPORT_READ_MESSAGE_RENDER_UNORM_READ 1 41203b705cfSriastradh#define GEN6_DATAPORT_READ_MESSAGE_OWORD_DUAL_BLOCK_READ 2 41303b705cfSriastradh#define GEN6_DATAPORT_READ_MESSAGE_MEDIA_BLOCK_READ 4 41403b705cfSriastradh#define GEN6_DATAPORT_READ_MESSAGE_OWORD_UNALIGN_BLOCK_READ 5 41503b705cfSriastradh#define GEN6_DATAPORT_READ_MESSAGE_DWORD_SCATTERED_READ 6 41603b705cfSriastradh 41703b705cfSriastradh#define BRW_DATAPORT_READ_TARGET_DATA_CACHE 0 41803b705cfSriastradh#define BRW_DATAPORT_READ_TARGET_RENDER_CACHE 1 41903b705cfSriastradh#define BRW_DATAPORT_READ_TARGET_SAMPLER_CACHE 2 42003b705cfSriastradh 42103b705cfSriastradh#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE 0 42203b705cfSriastradh#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD16_SINGLE_SOURCE_REPLICATED 1 42303b705cfSriastradh#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN01 2 42403b705cfSriastradh#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_DUAL_SOURCE_SUBSPAN23 3 42503b705cfSriastradh#define BRW_DATAPORT_RENDER_TARGET_WRITE_SIMD8_SINGLE_SOURCE_SUBSPAN01 4 42603b705cfSriastradh 42703b705cfSriastradh/** 42803b705cfSriastradh * Message target: Shared Function ID for where to SEND a message. 42903b705cfSriastradh * 43003b705cfSriastradh * These are enumerated in the ISA reference under "send - Send Message". 43103b705cfSriastradh * In particular, see the following tables: 43203b705cfSriastradh * - G45 PRM, Volume 4, Table 14-15 "Message Descriptor Definition" 43303b705cfSriastradh * - Sandybridge PRM, Volume 4 Part 2, Table 8-16 "Extended Message Descriptor" 43403b705cfSriastradh * - BSpec, Volume 1a (GPU Overview) / Graphics Processing Engine (GPE) / 43503b705cfSriastradh * Overview / GPE Function IDs 43603b705cfSriastradh */ 43703b705cfSriastradhenum brw_message_target { 43803b705cfSriastradh BRW_SFID_NULL = 0, 43903b705cfSriastradh BRW_SFID_MATH = 1, /* Only valid on Gen4-5 */ 44003b705cfSriastradh BRW_SFID_SAMPLER = 2, 44103b705cfSriastradh BRW_SFID_MESSAGE_GATEWAY = 3, 44203b705cfSriastradh BRW_SFID_DATAPORT_READ = 4, 44303b705cfSriastradh BRW_SFID_DATAPORT_WRITE = 5, 44403b705cfSriastradh BRW_SFID_URB = 6, 44503b705cfSriastradh BRW_SFID_THREAD_SPAWNER = 7, 44603b705cfSriastradh 44703b705cfSriastradh GEN6_SFID_DATAPORT_SAMPLER_CACHE = 4, 44803b705cfSriastradh GEN6_SFID_DATAPORT_RENDER_CACHE = 5, 44903b705cfSriastradh GEN6_SFID_DATAPORT_CONSTANT_CACHE = 9, 45003b705cfSriastradh 45103b705cfSriastradh GEN7_SFID_DATAPORT_DATA_CACHE = 10, 45203b705cfSriastradh}; 45303b705cfSriastradh 45403b705cfSriastradh#define GEN7_MESSAGE_TARGET_DP_DATA_CACHE 10 45503b705cfSriastradh 45603b705cfSriastradh#define BRW_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE 0 45703b705cfSriastradh#define BRW_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE 1 45803b705cfSriastradh#define BRW_DATAPORT_WRITE_MESSAGE_MEDIA_BLOCK_WRITE 2 45903b705cfSriastradh#define BRW_DATAPORT_WRITE_MESSAGE_DWORD_SCATTERED_WRITE 3 46003b705cfSriastradh#define BRW_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE 4 46103b705cfSriastradh#define BRW_DATAPORT_WRITE_MESSAGE_STREAMED_VERTEX_BUFFER_WRITE 5 46203b705cfSriastradh#define BRW_DATAPORT_WRITE_MESSAGE_FLUSH_RENDER_CACHE 7 46303b705cfSriastradh 46403b705cfSriastradh/* GEN6 */ 46503b705cfSriastradh#define GEN6_DATAPORT_WRITE_MESSAGE_DWORD_ATOMIC_WRITE 7 46603b705cfSriastradh#define GEN6_DATAPORT_WRITE_MESSAGE_OWORD_BLOCK_WRITE 8 46703b705cfSriastradh#define GEN6_DATAPORT_WRITE_MESSAGE_OWORD_DUAL_BLOCK_WRITE 9 46803b705cfSriastradh#define GEN6_DATAPORT_WRITE_MESSAGE_MEDIA_BLOCK_WRITE 10 46903b705cfSriastradh#define GEN6_DATAPORT_WRITE_MESSAGE_DWORD_SCATTERED_WRITE 11 47003b705cfSriastradh#define GEN6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_WRITE 12 47103b705cfSriastradh#define GEN6_DATAPORT_WRITE_MESSAGE_STREAMED_VB_WRITE 13 47203b705cfSriastradh#define GEN6_DATAPORT_WRITE_MESSAGE_RENDER_TARGET_UNORM_WRITE 14 47303b705cfSriastradh 47403b705cfSriastradh#define BRW_MATH_FUNCTION_INV 1 47503b705cfSriastradh#define BRW_MATH_FUNCTION_LOG 2 47603b705cfSriastradh#define BRW_MATH_FUNCTION_EXP 3 47703b705cfSriastradh#define BRW_MATH_FUNCTION_SQRT 4 47803b705cfSriastradh#define BRW_MATH_FUNCTION_RSQ 5 47903b705cfSriastradh#define BRW_MATH_FUNCTION_SIN 6 /* was 7 */ 48003b705cfSriastradh#define BRW_MATH_FUNCTION_COS 7 /* was 8 */ 48103b705cfSriastradh#define BRW_MATH_FUNCTION_SINCOS 8 /* was 6 */ 48203b705cfSriastradh#define BRW_MATH_FUNCTION_TAN 9 /* gen4 */ 48303b705cfSriastradh#define BRW_MATH_FUNCTION_FDIV 9 /* gen6+ */ 48403b705cfSriastradh#define BRW_MATH_FUNCTION_POW 10 48503b705cfSriastradh#define BRW_MATH_FUNCTION_INT_DIV_QUOTIENT_AND_REMAINDER 11 48603b705cfSriastradh#define BRW_MATH_FUNCTION_INT_DIV_QUOTIENT 12 48703b705cfSriastradh#define BRW_MATH_FUNCTION_INT_DIV_REMAINDER 13 48803b705cfSriastradh 48903b705cfSriastradh#define BRW_MATH_INTEGER_UNSIGNED 0 49003b705cfSriastradh#define BRW_MATH_INTEGER_SIGNED 1 49103b705cfSriastradh 49203b705cfSriastradh#define BRW_MATH_PRECISION_FULL 0 49303b705cfSriastradh#define BRW_MATH_PRECISION_PARTIAL 1 49403b705cfSriastradh 49503b705cfSriastradh#define BRW_MATH_SATURATE_NONE 0 49603b705cfSriastradh#define BRW_MATH_SATURATE_SATURATE 1 49703b705cfSriastradh 49803b705cfSriastradh#define BRW_MATH_DATA_VECTOR 0 49903b705cfSriastradh#define BRW_MATH_DATA_SCALAR 1 50003b705cfSriastradh 50103b705cfSriastradh#define BRW_URB_OPCODE_WRITE 0 50203b705cfSriastradh 50303b705cfSriastradh#define BRW_URB_SWIZZLE_NONE 0 50403b705cfSriastradh#define BRW_URB_SWIZZLE_INTERLEAVE 1 50503b705cfSriastradh#define BRW_URB_SWIZZLE_TRANSPOSE 2 50603b705cfSriastradh 50703b705cfSriastradh#define BRW_SCRATCH_SPACE_SIZE_1K 0 50803b705cfSriastradh#define BRW_SCRATCH_SPACE_SIZE_2K 1 50903b705cfSriastradh#define BRW_SCRATCH_SPACE_SIZE_4K 2 51003b705cfSriastradh#define BRW_SCRATCH_SPACE_SIZE_8K 3 51103b705cfSriastradh#define BRW_SCRATCH_SPACE_SIZE_16K 4 51203b705cfSriastradh#define BRW_SCRATCH_SPACE_SIZE_32K 5 51303b705cfSriastradh#define BRW_SCRATCH_SPACE_SIZE_64K 6 51403b705cfSriastradh#define BRW_SCRATCH_SPACE_SIZE_128K 7 51503b705cfSriastradh#define BRW_SCRATCH_SPACE_SIZE_256K 8 51603b705cfSriastradh#define BRW_SCRATCH_SPACE_SIZE_512K 9 51703b705cfSriastradh#define BRW_SCRATCH_SPACE_SIZE_1M 10 51803b705cfSriastradh#define BRW_SCRATCH_SPACE_SIZE_2M 11 51903b705cfSriastradh 52003b705cfSriastradh#define REG_SIZE (8*4) 52103b705cfSriastradh 52203b705cfSriastradhstruct brw_instruction { 52303b705cfSriastradh struct { 52403b705cfSriastradh unsigned opcode:7; 52503b705cfSriastradh unsigned pad:1; 52603b705cfSriastradh unsigned access_mode:1; 52703b705cfSriastradh unsigned mask_control:1; 52803b705cfSriastradh unsigned dependency_control:2; 52903b705cfSriastradh unsigned compression_control:2; /* gen6: quater control */ 53003b705cfSriastradh unsigned thread_control:2; 53103b705cfSriastradh unsigned predicate_control:4; 53203b705cfSriastradh unsigned predicate_inverse:1; 53303b705cfSriastradh unsigned execution_size:3; 53403b705cfSriastradh /** 53503b705cfSriastradh * Conditional Modifier for most instructions. On Gen6+, this is also 53603b705cfSriastradh * used for the SEND instruction's Message Target/SFID. 53703b705cfSriastradh */ 53803b705cfSriastradh unsigned destreg__conditionalmod:4; 53903b705cfSriastradh unsigned acc_wr_control:1; 54003b705cfSriastradh unsigned cmpt_control:1; 54103b705cfSriastradh unsigned debug_control:1; 54203b705cfSriastradh unsigned saturate:1; 54303b705cfSriastradh } header; 54403b705cfSriastradh 54503b705cfSriastradh union { 54603b705cfSriastradh struct { 54703b705cfSriastradh unsigned dest_reg_file:2; 54803b705cfSriastradh unsigned dest_reg_type:3; 54903b705cfSriastradh unsigned src0_reg_file:2; 55003b705cfSriastradh unsigned src0_reg_type:3; 55103b705cfSriastradh unsigned src1_reg_file:2; 55203b705cfSriastradh unsigned src1_reg_type:3; 55303b705cfSriastradh unsigned pad:1; 55403b705cfSriastradh unsigned dest_subreg_nr:5; 55503b705cfSriastradh unsigned dest_reg_nr:8; 55603b705cfSriastradh unsigned dest_horiz_stride:2; 55703b705cfSriastradh unsigned dest_address_mode:1; 55803b705cfSriastradh } da1; 55903b705cfSriastradh 56003b705cfSriastradh struct { 56103b705cfSriastradh unsigned dest_reg_file:2; 56203b705cfSriastradh unsigned dest_reg_type:3; 56303b705cfSriastradh unsigned src0_reg_file:2; 56403b705cfSriastradh unsigned src0_reg_type:3; 56503b705cfSriastradh unsigned src1_reg_file:2; /* 0x00000c00 */ 56603b705cfSriastradh unsigned src1_reg_type:3; /* 0x00007000 */ 56703b705cfSriastradh unsigned pad:1; 56803b705cfSriastradh int dest_indirect_offset:10; /* offset against the deref'd address reg */ 56903b705cfSriastradh unsigned dest_subreg_nr:3; /* subnr for the address reg a0.x */ 57003b705cfSriastradh unsigned dest_horiz_stride:2; 57103b705cfSriastradh unsigned dest_address_mode:1; 57203b705cfSriastradh } ia1; 57303b705cfSriastradh 57403b705cfSriastradh struct { 57503b705cfSriastradh unsigned dest_reg_file:2; 57603b705cfSriastradh unsigned dest_reg_type:3; 57703b705cfSriastradh unsigned src0_reg_file:2; 57803b705cfSriastradh unsigned src0_reg_type:3; 57903b705cfSriastradh unsigned src1_reg_file:2; 58003b705cfSriastradh unsigned src1_reg_type:3; 58103b705cfSriastradh unsigned pad:1; 58203b705cfSriastradh unsigned dest_writemask:4; 58303b705cfSriastradh unsigned dest_subreg_nr:1; 58403b705cfSriastradh unsigned dest_reg_nr:8; 58503b705cfSriastradh unsigned dest_horiz_stride:2; 58603b705cfSriastradh unsigned dest_address_mode:1; 58703b705cfSriastradh } da16; 58803b705cfSriastradh 58903b705cfSriastradh struct { 59003b705cfSriastradh unsigned dest_reg_file:2; 59103b705cfSriastradh unsigned dest_reg_type:3; 59203b705cfSriastradh unsigned src0_reg_file:2; 59303b705cfSriastradh unsigned src0_reg_type:3; 59403b705cfSriastradh unsigned pad0:6; 59503b705cfSriastradh unsigned dest_writemask:4; 59603b705cfSriastradh int dest_indirect_offset:6; 59703b705cfSriastradh unsigned dest_subreg_nr:3; 59803b705cfSriastradh unsigned dest_horiz_stride:2; 59903b705cfSriastradh unsigned dest_address_mode:1; 60003b705cfSriastradh } ia16; 60103b705cfSriastradh 60203b705cfSriastradh struct { 60303b705cfSriastradh unsigned dest_reg_file:2; 60403b705cfSriastradh unsigned dest_reg_type:3; 60503b705cfSriastradh unsigned src0_reg_file:2; 60603b705cfSriastradh unsigned src0_reg_type:3; 60703b705cfSriastradh unsigned src1_reg_file:2; 60803b705cfSriastradh unsigned src1_reg_type:3; 60903b705cfSriastradh unsigned pad:1; 61003b705cfSriastradh 61103b705cfSriastradh int jump_count:16; 61203b705cfSriastradh } branch_gen6; 61303b705cfSriastradh 61403b705cfSriastradh struct { 61503b705cfSriastradh unsigned dest_reg_file:1; 61603b705cfSriastradh unsigned flag_subreg_num:1; 61703b705cfSriastradh unsigned pad0:2; 61803b705cfSriastradh unsigned src0_abs:1; 61903b705cfSriastradh unsigned src0_negate:1; 62003b705cfSriastradh unsigned src1_abs:1; 62103b705cfSriastradh unsigned src1_negate:1; 62203b705cfSriastradh unsigned src2_abs:1; 62303b705cfSriastradh unsigned src2_negate:1; 62403b705cfSriastradh unsigned pad1:7; 62503b705cfSriastradh unsigned dest_writemask:4; 62603b705cfSriastradh unsigned dest_subreg_nr:3; 62703b705cfSriastradh unsigned dest_reg_nr:8; 62803b705cfSriastradh } da3src; 62903b705cfSriastradh } bits1; 63003b705cfSriastradh 63103b705cfSriastradh 63203b705cfSriastradh union { 63303b705cfSriastradh struct { 63403b705cfSriastradh unsigned src0_subreg_nr:5; 63503b705cfSriastradh unsigned src0_reg_nr:8; 63603b705cfSriastradh unsigned src0_abs:1; 63703b705cfSriastradh unsigned src0_negate:1; 63803b705cfSriastradh unsigned src0_address_mode:1; 63903b705cfSriastradh unsigned src0_horiz_stride:2; 64003b705cfSriastradh unsigned src0_width:3; 64103b705cfSriastradh unsigned src0_vert_stride:4; 64203b705cfSriastradh unsigned flag_subreg_nr:1; 64303b705cfSriastradh unsigned flag_reg_nr:1; 64403b705cfSriastradh unsigned pad:5; 64503b705cfSriastradh } da1; 64603b705cfSriastradh 64703b705cfSriastradh struct { 64803b705cfSriastradh int src0_indirect_offset:10; 64903b705cfSriastradh unsigned src0_subreg_nr:3; 65003b705cfSriastradh unsigned src0_abs:1; 65103b705cfSriastradh unsigned src0_negate:1; 65203b705cfSriastradh unsigned src0_address_mode:1; 65303b705cfSriastradh unsigned src0_horiz_stride:2; 65403b705cfSriastradh unsigned src0_width:3; 65503b705cfSriastradh unsigned src0_vert_stride:4; 65603b705cfSriastradh unsigned flag_subreg_nr:1; 65703b705cfSriastradh unsigned flag_reg_nr:1; 65803b705cfSriastradh unsigned pad:5; 65903b705cfSriastradh } ia1; 66003b705cfSriastradh 66103b705cfSriastradh struct { 66203b705cfSriastradh unsigned src0_swz_x:2; 66303b705cfSriastradh unsigned src0_swz_y:2; 66403b705cfSriastradh unsigned src0_subreg_nr:1; 66503b705cfSriastradh unsigned src0_reg_nr:8; 66603b705cfSriastradh unsigned src0_abs:1; 66703b705cfSriastradh unsigned src0_negate:1; 66803b705cfSriastradh unsigned src0_address_mode:1; 66903b705cfSriastradh unsigned src0_swz_z:2; 67003b705cfSriastradh unsigned src0_swz_w:2; 67103b705cfSriastradh unsigned pad0:1; 67203b705cfSriastradh unsigned src0_vert_stride:4; 67303b705cfSriastradh unsigned flag_subreg_nr:1; 67403b705cfSriastradh unsigned flag_reg_nr:1; 67503b705cfSriastradh unsigned pad1:5; 67603b705cfSriastradh } da16; 67703b705cfSriastradh 67803b705cfSriastradh struct { 67903b705cfSriastradh unsigned src0_swz_x:2; 68003b705cfSriastradh unsigned src0_swz_y:2; 68103b705cfSriastradh int src0_indirect_offset:6; 68203b705cfSriastradh unsigned src0_subreg_nr:3; 68303b705cfSriastradh unsigned src0_abs:1; 68403b705cfSriastradh unsigned src0_negate:1; 68503b705cfSriastradh unsigned src0_address_mode:1; 68603b705cfSriastradh unsigned src0_swz_z:2; 68703b705cfSriastradh unsigned src0_swz_w:2; 68803b705cfSriastradh unsigned pad0:1; 68903b705cfSriastradh unsigned src0_vert_stride:4; 69003b705cfSriastradh unsigned flag_subreg_nr:1; 69103b705cfSriastradh unsigned flag_reg_nr:1; 69203b705cfSriastradh unsigned pad1:5; 69303b705cfSriastradh } ia16; 69403b705cfSriastradh 69503b705cfSriastradh /* Extended Message Descriptor for Ironlake (Gen5) SEND instruction. 69603b705cfSriastradh * 69703b705cfSriastradh * Does not apply to Gen6+. The SFID/message target moved to bits 69803b705cfSriastradh * 27:24 of the header (destreg__conditionalmod); EOT is in bits3. 69903b705cfSriastradh */ 70003b705cfSriastradh struct { 70103b705cfSriastradh unsigned pad:26; 70203b705cfSriastradh unsigned end_of_thread:1; 70303b705cfSriastradh unsigned pad1:1; 70403b705cfSriastradh unsigned sfid:4; 70503b705cfSriastradh } send_gen5; /* for Ironlake only */ 70603b705cfSriastradh 70703b705cfSriastradh struct { 70803b705cfSriastradh unsigned src0_rep_ctrl:1; 70903b705cfSriastradh unsigned src0_swizzle:8; 71003b705cfSriastradh unsigned src0_subreg_nr:3; 71103b705cfSriastradh unsigned src0_reg_nr:8; 71203b705cfSriastradh unsigned pad0:1; 71303b705cfSriastradh unsigned src1_rep_ctrl:1; 71403b705cfSriastradh unsigned src1_swizzle:8; 71503b705cfSriastradh unsigned src1_subreg_nr_low:2; 71603b705cfSriastradh } da3src; 71703b705cfSriastradh } bits2; 71803b705cfSriastradh 71903b705cfSriastradh union { 72003b705cfSriastradh struct { 72103b705cfSriastradh unsigned src1_subreg_nr:5; 72203b705cfSriastradh unsigned src1_reg_nr:8; 72303b705cfSriastradh unsigned src1_abs:1; 72403b705cfSriastradh unsigned src1_negate:1; 72503b705cfSriastradh unsigned src1_address_mode:1; 72603b705cfSriastradh unsigned src1_horiz_stride:2; 72703b705cfSriastradh unsigned src1_width:3; 72803b705cfSriastradh unsigned src1_vert_stride:4; 72903b705cfSriastradh unsigned pad0:7; 73003b705cfSriastradh } da1; 73103b705cfSriastradh 73203b705cfSriastradh struct { 73303b705cfSriastradh unsigned src1_swz_x:2; 73403b705cfSriastradh unsigned src1_swz_y:2; 73503b705cfSriastradh unsigned src1_subreg_nr:1; 73603b705cfSriastradh unsigned src1_reg_nr:8; 73703b705cfSriastradh unsigned src1_abs:1; 73803b705cfSriastradh unsigned src1_negate:1; 73903b705cfSriastradh unsigned src1_address_mode:1; 74003b705cfSriastradh unsigned src1_swz_z:2; 74103b705cfSriastradh unsigned src1_swz_w:2; 74203b705cfSriastradh unsigned pad1:1; 74303b705cfSriastradh unsigned src1_vert_stride:4; 74403b705cfSriastradh unsigned pad2:7; 74503b705cfSriastradh } da16; 74603b705cfSriastradh 74703b705cfSriastradh struct { 74803b705cfSriastradh int src1_indirect_offset:10; 74903b705cfSriastradh unsigned src1_subreg_nr:3; 75003b705cfSriastradh unsigned src1_abs:1; 75103b705cfSriastradh unsigned src1_negate:1; 75203b705cfSriastradh unsigned src1_address_mode:1; 75303b705cfSriastradh unsigned src1_horiz_stride:2; 75403b705cfSriastradh unsigned src1_width:3; 75503b705cfSriastradh unsigned src1_vert_stride:4; 75603b705cfSriastradh unsigned flag_subreg_nr:1; 75703b705cfSriastradh unsigned flag_reg_nr:1; 75803b705cfSriastradh unsigned pad1:5; 75903b705cfSriastradh } ia1; 76003b705cfSriastradh 76103b705cfSriastradh struct { 76203b705cfSriastradh unsigned src1_swz_x:2; 76303b705cfSriastradh unsigned src1_swz_y:2; 76403b705cfSriastradh int src1_indirect_offset:6; 76503b705cfSriastradh unsigned src1_subreg_nr:3; 76603b705cfSriastradh unsigned src1_abs:1; 76703b705cfSriastradh unsigned src1_negate:1; 76803b705cfSriastradh unsigned pad0:1; 76903b705cfSriastradh unsigned src1_swz_z:2; 77003b705cfSriastradh unsigned src1_swz_w:2; 77103b705cfSriastradh unsigned pad1:1; 77203b705cfSriastradh unsigned src1_vert_stride:4; 77303b705cfSriastradh unsigned flag_subreg_nr:1; 77403b705cfSriastradh unsigned flag_reg_nr:1; 77503b705cfSriastradh unsigned pad2:5; 77603b705cfSriastradh } ia16; 77703b705cfSriastradh 77803b705cfSriastradh struct { 77903b705cfSriastradh int jump_count:16; /* note: signed */ 78003b705cfSriastradh unsigned pop_count:4; 78103b705cfSriastradh unsigned pad0:12; 78203b705cfSriastradh } if_else; 78303b705cfSriastradh 78403b705cfSriastradh /* This is also used for gen7 IF/ELSE instructions */ 78503b705cfSriastradh struct { 78603b705cfSriastradh /* Signed jump distance to the ip to jump to if all channels 78703b705cfSriastradh * are disabled after the break or continue. It should point 78803b705cfSriastradh * to the end of the innermost control flow block, as that's 78903b705cfSriastradh * where some channel could get re-enabled. 79003b705cfSriastradh */ 79103b705cfSriastradh int jip:16; 79203b705cfSriastradh 79303b705cfSriastradh /* Signed jump distance to the location to resume execution 79403b705cfSriastradh * of this channel if it's enabled for the break or continue. 79503b705cfSriastradh */ 79603b705cfSriastradh int uip:16; 79703b705cfSriastradh } break_cont; 79803b705cfSriastradh 79903b705cfSriastradh /** 80003b705cfSriastradh * \defgroup SEND instructions / Message Descriptors 80103b705cfSriastradh * 80203b705cfSriastradh * @{ 80303b705cfSriastradh */ 80403b705cfSriastradh 80503b705cfSriastradh /** 80603b705cfSriastradh * Generic Message Descriptor for Gen4 SEND instructions. The structs 80703b705cfSriastradh * below expand function_control to something specific for their 80803b705cfSriastradh * message. Due to struct packing issues, they duplicate these bits. 80903b705cfSriastradh * 81003b705cfSriastradh * See the G45 PRM, Volume 4, Table 14-15. 81103b705cfSriastradh */ 81203b705cfSriastradh struct { 81303b705cfSriastradh unsigned function_control:16; 81403b705cfSriastradh unsigned response_length:4; 81503b705cfSriastradh unsigned msg_length:4; 81603b705cfSriastradh unsigned msg_target:4; 81703b705cfSriastradh unsigned pad1:3; 81803b705cfSriastradh unsigned end_of_thread:1; 81903b705cfSriastradh } generic; 82003b705cfSriastradh 82103b705cfSriastradh /** 82203b705cfSriastradh * Generic Message Descriptor for Gen5-7 SEND instructions. 82303b705cfSriastradh * 82403b705cfSriastradh * See the Sandybridge PRM, Volume 2 Part 2, Table 8-15. (Sadly, most 82503b705cfSriastradh * of the information on the SEND instruction is missing from the public 82603b705cfSriastradh * Ironlake PRM.) 82703b705cfSriastradh * 82803b705cfSriastradh * The table claims that bit 31 is reserved/MBZ on Gen6+, but it lies. 82903b705cfSriastradh * According to the SEND instruction description: 83003b705cfSriastradh * "The MSb of the message description, the EOT field, always comes from 83103b705cfSriastradh * bit 127 of the instruction word"...which is bit 31 of this field. 83203b705cfSriastradh */ 83303b705cfSriastradh struct { 83403b705cfSriastradh unsigned function_control:19; 83503b705cfSriastradh unsigned header_present:1; 83603b705cfSriastradh unsigned response_length:5; 83703b705cfSriastradh unsigned msg_length:4; 83803b705cfSriastradh unsigned pad1:2; 83903b705cfSriastradh unsigned end_of_thread:1; 84003b705cfSriastradh } generic_gen5; 84103b705cfSriastradh 84203b705cfSriastradh /** G45 PRM, Volume 4, Section 6.1.1.1 */ 84303b705cfSriastradh struct { 84403b705cfSriastradh unsigned function:4; 84503b705cfSriastradh unsigned int_type:1; 84603b705cfSriastradh unsigned precision:1; 84703b705cfSriastradh unsigned saturate:1; 84803b705cfSriastradh unsigned data_type:1; 84903b705cfSriastradh unsigned pad0:8; 85003b705cfSriastradh unsigned response_length:4; 85103b705cfSriastradh unsigned msg_length:4; 85203b705cfSriastradh unsigned msg_target:4; 85303b705cfSriastradh unsigned pad1:3; 85403b705cfSriastradh unsigned end_of_thread:1; 85503b705cfSriastradh } math; 85603b705cfSriastradh 85703b705cfSriastradh /** Ironlake PRM, Volume 4 Part 1, Section 6.1.1.1 */ 85803b705cfSriastradh struct { 85903b705cfSriastradh unsigned function:4; 86003b705cfSriastradh unsigned int_type:1; 86103b705cfSriastradh unsigned precision:1; 86203b705cfSriastradh unsigned saturate:1; 86303b705cfSriastradh unsigned data_type:1; 86403b705cfSriastradh unsigned snapshot:1; 86503b705cfSriastradh unsigned pad0:10; 86603b705cfSriastradh unsigned header_present:1; 86703b705cfSriastradh unsigned response_length:5; 86803b705cfSriastradh unsigned msg_length:4; 86903b705cfSriastradh unsigned pad1:2; 87003b705cfSriastradh unsigned end_of_thread:1; 87103b705cfSriastradh } math_gen5; 87203b705cfSriastradh 87303b705cfSriastradh /** G45 PRM, Volume 4, Section 4.8.1.1.1 [DevBW] and [DevCL] */ 87403b705cfSriastradh struct { 87503b705cfSriastradh unsigned binding_table_index:8; 87603b705cfSriastradh unsigned sampler:4; 87703b705cfSriastradh unsigned return_format:2; 87803b705cfSriastradh unsigned msg_type:2; 87903b705cfSriastradh unsigned response_length:4; 88003b705cfSriastradh unsigned msg_length:4; 88103b705cfSriastradh unsigned msg_target:4; 88203b705cfSriastradh unsigned pad1:3; 88303b705cfSriastradh unsigned end_of_thread:1; 88403b705cfSriastradh } sampler; 88503b705cfSriastradh 88603b705cfSriastradh /** G45 PRM, Volume 4, Section 4.8.1.1.2 [DevCTG] */ 88703b705cfSriastradh struct { 88803b705cfSriastradh unsigned binding_table_index:8; 88903b705cfSriastradh unsigned sampler:4; 89003b705cfSriastradh unsigned msg_type:4; 89103b705cfSriastradh unsigned response_length:4; 89203b705cfSriastradh unsigned msg_length:4; 89303b705cfSriastradh unsigned msg_target:4; 89403b705cfSriastradh unsigned pad1:3; 89503b705cfSriastradh unsigned end_of_thread:1; 89603b705cfSriastradh } sampler_g4x; 89703b705cfSriastradh 89803b705cfSriastradh /** Ironlake PRM, Volume 4 Part 1, Section 4.11.1.1.3 */ 89903b705cfSriastradh struct { 90003b705cfSriastradh unsigned binding_table_index:8; 90103b705cfSriastradh unsigned sampler:4; 90203b705cfSriastradh unsigned msg_type:4; 90303b705cfSriastradh unsigned simd_mode:2; 90403b705cfSriastradh unsigned pad0:1; 90503b705cfSriastradh unsigned header_present:1; 90603b705cfSriastradh unsigned response_length:5; 90703b705cfSriastradh unsigned msg_length:4; 90803b705cfSriastradh unsigned pad1:2; 90903b705cfSriastradh unsigned end_of_thread:1; 91003b705cfSriastradh } sampler_gen5; 91103b705cfSriastradh 91203b705cfSriastradh struct { 91303b705cfSriastradh unsigned binding_table_index:8; 91403b705cfSriastradh unsigned sampler:4; 91503b705cfSriastradh unsigned msg_type:5; 91603b705cfSriastradh unsigned simd_mode:2; 91703b705cfSriastradh unsigned header_present:1; 91803b705cfSriastradh unsigned response_length:5; 91903b705cfSriastradh unsigned msg_length:4; 92003b705cfSriastradh unsigned pad1:2; 92103b705cfSriastradh unsigned end_of_thread:1; 92203b705cfSriastradh } sampler_gen7; 92303b705cfSriastradh 92403b705cfSriastradh struct brw_urb_immediate { 92503b705cfSriastradh unsigned opcode:4; 92603b705cfSriastradh unsigned offset:6; 92703b705cfSriastradh unsigned swizzle_control:2; 92803b705cfSriastradh unsigned pad:1; 92903b705cfSriastradh unsigned allocate:1; 93003b705cfSriastradh unsigned used:1; 93103b705cfSriastradh unsigned complete:1; 93203b705cfSriastradh unsigned response_length:4; 93303b705cfSriastradh unsigned msg_length:4; 93403b705cfSriastradh unsigned msg_target:4; 93503b705cfSriastradh unsigned pad1:3; 93603b705cfSriastradh unsigned end_of_thread:1; 93703b705cfSriastradh } urb; 93803b705cfSriastradh 93903b705cfSriastradh struct { 94003b705cfSriastradh unsigned opcode:4; 94103b705cfSriastradh unsigned offset:6; 94203b705cfSriastradh unsigned swizzle_control:2; 94303b705cfSriastradh unsigned pad:1; 94403b705cfSriastradh unsigned allocate:1; 94503b705cfSriastradh unsigned used:1; 94603b705cfSriastradh unsigned complete:1; 94703b705cfSriastradh unsigned pad0:3; 94803b705cfSriastradh unsigned header_present:1; 94903b705cfSriastradh unsigned response_length:5; 95003b705cfSriastradh unsigned msg_length:4; 95103b705cfSriastradh unsigned pad1:2; 95203b705cfSriastradh unsigned end_of_thread:1; 95303b705cfSriastradh } urb_gen5; 95403b705cfSriastradh 95503b705cfSriastradh struct { 95603b705cfSriastradh unsigned opcode:3; 95703b705cfSriastradh unsigned offset:11; 95803b705cfSriastradh unsigned swizzle_control:1; 95903b705cfSriastradh unsigned complete:1; 96003b705cfSriastradh unsigned per_slot_offset:1; 96103b705cfSriastradh unsigned pad0:2; 96203b705cfSriastradh unsigned header_present:1; 96303b705cfSriastradh unsigned response_length:5; 96403b705cfSriastradh unsigned msg_length:4; 96503b705cfSriastradh unsigned pad1:2; 96603b705cfSriastradh unsigned end_of_thread:1; 96703b705cfSriastradh } urb_gen7; 96803b705cfSriastradh 96903b705cfSriastradh /** 965 PRM, Volume 4, Section 5.10.1.1: Message Descriptor */ 97003b705cfSriastradh struct { 97103b705cfSriastradh unsigned binding_table_index:8; 97203b705cfSriastradh unsigned msg_control:4; 97303b705cfSriastradh unsigned msg_type:2; 97403b705cfSriastradh unsigned target_cache:2; 97503b705cfSriastradh unsigned response_length:4; 97603b705cfSriastradh unsigned msg_length:4; 97703b705cfSriastradh unsigned msg_target:4; 97803b705cfSriastradh unsigned pad1:3; 97903b705cfSriastradh unsigned end_of_thread:1; 98003b705cfSriastradh } dp_read; 98103b705cfSriastradh 98203b705cfSriastradh /** G45 PRM, Volume 4, Section 5.10.1.1.2 */ 98303b705cfSriastradh struct { 98403b705cfSriastradh unsigned binding_table_index:8; 98503b705cfSriastradh unsigned msg_control:3; 98603b705cfSriastradh unsigned msg_type:3; 98703b705cfSriastradh unsigned target_cache:2; 98803b705cfSriastradh unsigned response_length:4; 98903b705cfSriastradh unsigned msg_length:4; 99003b705cfSriastradh unsigned msg_target:4; 99103b705cfSriastradh unsigned pad1:3; 99203b705cfSriastradh unsigned end_of_thread:1; 99303b705cfSriastradh } dp_read_g4x; 99403b705cfSriastradh 99503b705cfSriastradh /** Ironlake PRM, Volume 4 Part 1, Section 5.10.2.1.2. */ 99603b705cfSriastradh struct { 99703b705cfSriastradh unsigned binding_table_index:8; 99803b705cfSriastradh unsigned msg_control:3; 99903b705cfSriastradh unsigned msg_type:3; 100003b705cfSriastradh unsigned target_cache:2; 100103b705cfSriastradh unsigned pad0:3; 100203b705cfSriastradh unsigned header_present:1; 100303b705cfSriastradh unsigned response_length:5; 100403b705cfSriastradh unsigned msg_length:4; 100503b705cfSriastradh unsigned pad1:2; 100603b705cfSriastradh unsigned end_of_thread:1; 100703b705cfSriastradh } dp_read_gen5; 100803b705cfSriastradh 100903b705cfSriastradh /** G45 PRM, Volume 4, Section 5.10.1.1.2. For both Gen4 and G45. */ 101003b705cfSriastradh struct { 101103b705cfSriastradh unsigned binding_table_index:8; 101203b705cfSriastradh unsigned msg_control:3; 101303b705cfSriastradh unsigned last_render_target:1; 101403b705cfSriastradh unsigned msg_type:3; 101503b705cfSriastradh unsigned send_commit_msg:1; 101603b705cfSriastradh unsigned response_length:4; 101703b705cfSriastradh unsigned msg_length:4; 101803b705cfSriastradh unsigned msg_target:4; 101903b705cfSriastradh unsigned pad1:3; 102003b705cfSriastradh unsigned end_of_thread:1; 102103b705cfSriastradh } dp_write; 102203b705cfSriastradh 102303b705cfSriastradh /** Ironlake PRM, Volume 4 Part 1, Section 5.10.2.1.2. */ 102403b705cfSriastradh struct { 102503b705cfSriastradh unsigned binding_table_index:8; 102603b705cfSriastradh unsigned msg_control:3; 102703b705cfSriastradh unsigned last_render_target:1; 102803b705cfSriastradh unsigned msg_type:3; 102903b705cfSriastradh unsigned send_commit_msg:1; 103003b705cfSriastradh unsigned pad0:3; 103103b705cfSriastradh unsigned header_present:1; 103203b705cfSriastradh unsigned response_length:5; 103303b705cfSriastradh unsigned msg_length:4; 103403b705cfSriastradh unsigned pad1:2; 103503b705cfSriastradh unsigned end_of_thread:1; 103603b705cfSriastradh } dp_write_gen5; 103703b705cfSriastradh 103803b705cfSriastradh /** 103903b705cfSriastradh * Message for the Sandybridge Sampler Cache or Constant Cache Data Port. 104003b705cfSriastradh * 104103b705cfSriastradh * See the Sandybridge PRM, Volume 4 Part 1, Section 3.9.2.1.1. 104203b705cfSriastradh **/ 104303b705cfSriastradh struct { 104403b705cfSriastradh unsigned binding_table_index:8; 104503b705cfSriastradh unsigned msg_control:5; 104603b705cfSriastradh unsigned msg_type:3; 104703b705cfSriastradh unsigned pad0:3; 104803b705cfSriastradh unsigned header_present:1; 104903b705cfSriastradh unsigned response_length:5; 105003b705cfSriastradh unsigned msg_length:4; 105103b705cfSriastradh unsigned pad1:2; 105203b705cfSriastradh unsigned end_of_thread:1; 105303b705cfSriastradh } gen6_dp_sampler_const_cache; 105403b705cfSriastradh 105503b705cfSriastradh /** 105603b705cfSriastradh * Message for the Sandybridge Render Cache Data Port. 105703b705cfSriastradh * 105803b705cfSriastradh * Most fields are defined in the Sandybridge PRM, Volume 4 Part 1, 105903b705cfSriastradh * Section 3.9.2.1.1: Message Descriptor. 106003b705cfSriastradh * 106103b705cfSriastradh * "Slot Group Select" and "Last Render Target" are part of the 106203b705cfSriastradh * 5-bit message control for Render Target Write messages. See 106303b705cfSriastradh * Section 3.9.9.2.1 of the same volume. 106403b705cfSriastradh */ 106503b705cfSriastradh struct { 106603b705cfSriastradh unsigned binding_table_index:8; 106703b705cfSriastradh unsigned msg_control:3; 106803b705cfSriastradh unsigned slot_group_select:1; 106903b705cfSriastradh unsigned last_render_target:1; 107003b705cfSriastradh unsigned msg_type:4; 107103b705cfSriastradh unsigned send_commit_msg:1; 107203b705cfSriastradh unsigned pad0:1; 107303b705cfSriastradh unsigned header_present:1; 107403b705cfSriastradh unsigned response_length:5; 107503b705cfSriastradh unsigned msg_length:4; 107603b705cfSriastradh unsigned pad1:2; 107703b705cfSriastradh unsigned end_of_thread:1; 107803b705cfSriastradh } gen6_dp; 107903b705cfSriastradh 108003b705cfSriastradh /** 108103b705cfSriastradh * Message for any of the Gen7 Data Port caches. 108203b705cfSriastradh * 108303b705cfSriastradh * Most fields are defined in BSpec volume 5c.2 Data Port / Messages / 108403b705cfSriastradh * Data Port Messages / Message Descriptor. Once again, "Slot Group 108503b705cfSriastradh * Select" and "Last Render Target" are part of the 6-bit message 108603b705cfSriastradh * control for Render Target Writes. 108703b705cfSriastradh */ 108803b705cfSriastradh struct { 108903b705cfSriastradh unsigned binding_table_index:8; 109003b705cfSriastradh unsigned msg_control:3; 109103b705cfSriastradh unsigned slot_group_select:1; 109203b705cfSriastradh unsigned last_render_target:1; 109303b705cfSriastradh unsigned msg_control_pad:1; 109403b705cfSriastradh unsigned msg_type:4; 109503b705cfSriastradh unsigned pad1:1; 109603b705cfSriastradh unsigned header_present:1; 109703b705cfSriastradh unsigned response_length:5; 109803b705cfSriastradh unsigned msg_length:4; 109903b705cfSriastradh unsigned pad2:2; 110003b705cfSriastradh unsigned end_of_thread:1; 110103b705cfSriastradh } gen7_dp; 110203b705cfSriastradh /** @} */ 110303b705cfSriastradh 110403b705cfSriastradh struct { 110503b705cfSriastradh unsigned src1_subreg_nr_high:1; 110603b705cfSriastradh unsigned src1_reg_nr:8; 110703b705cfSriastradh unsigned pad0:1; 110803b705cfSriastradh unsigned src2_rep_ctrl:1; 110903b705cfSriastradh unsigned src2_swizzle:8; 111003b705cfSriastradh unsigned src2_subreg_nr:3; 111103b705cfSriastradh unsigned src2_reg_nr:8; 111203b705cfSriastradh unsigned pad1:2; 111303b705cfSriastradh } da3src; 111403b705cfSriastradh 111503b705cfSriastradh int d; 111603b705cfSriastradh unsigned ud; 111703b705cfSriastradh float f; 111803b705cfSriastradh } bits3; 111903b705cfSriastradh}; 112003b705cfSriastradh 112103b705cfSriastradh 112203b705cfSriastradh/* These aren't hardware structs, just something useful for us to pass around: 112303b705cfSriastradh * 112403b705cfSriastradh * Align1 operation has a lot of control over input ranges. Used in 112503b705cfSriastradh * WM programs to implement shaders decomposed into "channel serial" 112603b705cfSriastradh * or "structure of array" form: 112703b705cfSriastradh */ 112803b705cfSriastradhstruct brw_reg { 112903b705cfSriastradh unsigned type:4; 113003b705cfSriastradh unsigned file:2; 113103b705cfSriastradh unsigned nr:8; 113203b705cfSriastradh unsigned subnr:5; /* :1 in align16 */ 113303b705cfSriastradh unsigned negate:1; /* source only */ 113403b705cfSriastradh unsigned abs:1; /* source only */ 113503b705cfSriastradh unsigned vstride:4; /* source only */ 113603b705cfSriastradh unsigned width:3; /* src only, align1 only */ 113703b705cfSriastradh unsigned hstride:2; /* align1 only */ 113803b705cfSriastradh unsigned address_mode:1; /* relative addressing, hopefully! */ 113903b705cfSriastradh unsigned pad0:1; 114003b705cfSriastradh 114103b705cfSriastradh union { 114203b705cfSriastradh struct { 114303b705cfSriastradh unsigned swizzle:8; /* src only, align16 only */ 114403b705cfSriastradh unsigned writemask:4; /* dest only, align16 only */ 114503b705cfSriastradh int indirect_offset:10; /* relative addressing offset */ 114603b705cfSriastradh unsigned pad1:10; /* two dwords total */ 114703b705cfSriastradh } bits; 114803b705cfSriastradh 114903b705cfSriastradh float f; 115003b705cfSriastradh int d; 115103b705cfSriastradh unsigned ud; 115203b705cfSriastradh } dw1; 115303b705cfSriastradh}; 115403b705cfSriastradh 115503b705cfSriastradhstruct brw_indirect { 115603b705cfSriastradh unsigned addr_subnr:4; 115703b705cfSriastradh int addr_offset:10; 115803b705cfSriastradh unsigned pad:18; 115903b705cfSriastradh}; 116003b705cfSriastradh 116103b705cfSriastradh#define BRW_EU_MAX_INSN_STACK 5 116203b705cfSriastradh#define BRW_EU_MAX_INSN 10000 116303b705cfSriastradh 116403b705cfSriastradhstruct brw_compile { 116503b705cfSriastradh struct brw_instruction *store; 116603b705cfSriastradh unsigned nr_insn; 116703b705cfSriastradh 116803b705cfSriastradh int gen; 116903b705cfSriastradh 117003b705cfSriastradh /* Allow clients to push/pop instruction state: 117103b705cfSriastradh */ 117203b705cfSriastradh struct brw_instruction stack[BRW_EU_MAX_INSN_STACK]; 117303b705cfSriastradh bool compressed_stack[BRW_EU_MAX_INSN_STACK]; 117403b705cfSriastradh struct brw_instruction *current; 117503b705cfSriastradh 117603b705cfSriastradh unsigned flag_value; 117703b705cfSriastradh bool single_program_flow; 117803b705cfSriastradh bool compressed; 117903b705cfSriastradh 118003b705cfSriastradh /* Control flow stacks: 118103b705cfSriastradh * - if_stack contains IF and ELSE instructions which must be patched 118203b705cfSriastradh * (and popped) once the matching ENDIF instruction is encountered. 118303b705cfSriastradh */ 118403b705cfSriastradh struct brw_instruction **if_stack; 118503b705cfSriastradh int if_stack_depth; 118603b705cfSriastradh int if_stack_array_size; 118703b705cfSriastradh}; 118803b705cfSriastradh 118903b705cfSriastradhstatic inline int type_sz(unsigned type) 119003b705cfSriastradh{ 119103b705cfSriastradh switch (type) { 119203b705cfSriastradh case BRW_REGISTER_TYPE_UD: 119303b705cfSriastradh case BRW_REGISTER_TYPE_D: 119403b705cfSriastradh case BRW_REGISTER_TYPE_F: 119503b705cfSriastradh return 4; 119603b705cfSriastradh case BRW_REGISTER_TYPE_HF: 119703b705cfSriastradh case BRW_REGISTER_TYPE_UW: 119803b705cfSriastradh case BRW_REGISTER_TYPE_W: 119903b705cfSriastradh return 2; 120003b705cfSriastradh case BRW_REGISTER_TYPE_UB: 120103b705cfSriastradh case BRW_REGISTER_TYPE_B: 120203b705cfSriastradh return 1; 120303b705cfSriastradh default: 120403b705cfSriastradh return 0; 120503b705cfSriastradh } 120603b705cfSriastradh} 120703b705cfSriastradh 120803b705cfSriastradh/** 120903b705cfSriastradh * Construct a brw_reg. 121003b705cfSriastradh * \param file one of the BRW_x_REGISTER_FILE values 121103b705cfSriastradh * \param nr register number/index 121203b705cfSriastradh * \param subnr register sub number 121303b705cfSriastradh * \param type one of BRW_REGISTER_TYPE_x 121403b705cfSriastradh * \param vstride one of BRW_VERTICAL_STRIDE_x 121503b705cfSriastradh * \param width one of BRW_WIDTH_x 121603b705cfSriastradh * \param hstride one of BRW_HORIZONTAL_STRIDE_x 121703b705cfSriastradh * \param swizzle one of BRW_SWIZZLE_x 121803b705cfSriastradh * \param writemask WRITEMASK_X/Y/Z/W bitfield 121903b705cfSriastradh */ 122003b705cfSriastradhstatic inline struct brw_reg brw_reg(unsigned file, 122103b705cfSriastradh unsigned nr, 122203b705cfSriastradh unsigned subnr, 122303b705cfSriastradh unsigned type, 122403b705cfSriastradh unsigned vstride, 122503b705cfSriastradh unsigned width, 122603b705cfSriastradh unsigned hstride, 122703b705cfSriastradh unsigned swizzle, 122803b705cfSriastradh unsigned writemask) 122903b705cfSriastradh{ 123003b705cfSriastradh struct brw_reg reg; 123103b705cfSriastradh if (file == BRW_GENERAL_REGISTER_FILE) 123203b705cfSriastradh assert(nr < BRW_MAX_GRF); 123303b705cfSriastradh else if (file == BRW_MESSAGE_REGISTER_FILE) 123403b705cfSriastradh assert((nr & ~(1 << 7)) < BRW_MAX_MRF); 123503b705cfSriastradh else if (file == BRW_ARCHITECTURE_REGISTER_FILE) 123603b705cfSriastradh assert(nr <= BRW_ARF_IP); 123703b705cfSriastradh 123803b705cfSriastradh reg.type = type; 123903b705cfSriastradh reg.file = file; 124003b705cfSriastradh reg.nr = nr; 124103b705cfSriastradh reg.subnr = subnr * type_sz(type); 124203b705cfSriastradh reg.negate = 0; 124303b705cfSriastradh reg.abs = 0; 124403b705cfSriastradh reg.vstride = vstride; 124503b705cfSriastradh reg.width = width; 124603b705cfSriastradh reg.hstride = hstride; 124703b705cfSriastradh reg.address_mode = BRW_ADDRESS_DIRECT; 124803b705cfSriastradh reg.pad0 = 0; 124903b705cfSriastradh 125003b705cfSriastradh /* Could do better: If the reg is r5.3<0;1,0>, we probably want to 125103b705cfSriastradh * set swizzle and writemask to W, as the lower bits of subnr will 125203b705cfSriastradh * be lost when converted to align16. This is probably too much to 125303b705cfSriastradh * keep track of as you'd want it adjusted by suboffset(), etc. 125403b705cfSriastradh * Perhaps fix up when converting to align16? 125503b705cfSriastradh */ 125603b705cfSriastradh reg.dw1.bits.swizzle = swizzle; 125703b705cfSriastradh reg.dw1.bits.writemask = writemask; 125803b705cfSriastradh reg.dw1.bits.indirect_offset = 0; 125903b705cfSriastradh reg.dw1.bits.pad1 = 0; 126003b705cfSriastradh return reg; 126103b705cfSriastradh} 126203b705cfSriastradh 126303b705cfSriastradh/** Construct float[16] register */ 126403b705cfSriastradhstatic inline struct brw_reg brw_vec16_reg(unsigned file, 126503b705cfSriastradh unsigned nr, 126603b705cfSriastradh unsigned subnr) 126703b705cfSriastradh{ 126803b705cfSriastradh return brw_reg(file, 126903b705cfSriastradh nr, 127003b705cfSriastradh subnr, 127103b705cfSriastradh BRW_REGISTER_TYPE_F, 127203b705cfSriastradh BRW_VERTICAL_STRIDE_16, 127303b705cfSriastradh BRW_WIDTH_16, 127403b705cfSriastradh BRW_HORIZONTAL_STRIDE_1, 127503b705cfSriastradh BRW_SWIZZLE_XYZW, 127603b705cfSriastradh WRITEMASK_XYZW); 127703b705cfSriastradh} 127803b705cfSriastradh 127903b705cfSriastradh/** Construct float[8] register */ 128003b705cfSriastradhstatic inline struct brw_reg brw_vec8_reg(unsigned file, 128103b705cfSriastradh unsigned nr, 128203b705cfSriastradh unsigned subnr) 128303b705cfSriastradh{ 128403b705cfSriastradh return brw_reg(file, 128503b705cfSriastradh nr, 128603b705cfSriastradh subnr, 128703b705cfSriastradh BRW_REGISTER_TYPE_F, 128803b705cfSriastradh BRW_VERTICAL_STRIDE_8, 128903b705cfSriastradh BRW_WIDTH_8, 129003b705cfSriastradh BRW_HORIZONTAL_STRIDE_1, 129103b705cfSriastradh BRW_SWIZZLE_XYZW, 129203b705cfSriastradh WRITEMASK_XYZW); 129303b705cfSriastradh} 129403b705cfSriastradh 129503b705cfSriastradh/** Construct float[4] register */ 129603b705cfSriastradhstatic inline struct brw_reg brw_vec4_reg(unsigned file, 129703b705cfSriastradh unsigned nr, 129803b705cfSriastradh unsigned subnr) 129903b705cfSriastradh{ 130003b705cfSriastradh return brw_reg(file, 130103b705cfSriastradh nr, 130203b705cfSriastradh subnr, 130303b705cfSriastradh BRW_REGISTER_TYPE_F, 130403b705cfSriastradh BRW_VERTICAL_STRIDE_4, 130503b705cfSriastradh BRW_WIDTH_4, 130603b705cfSriastradh BRW_HORIZONTAL_STRIDE_1, 130703b705cfSriastradh BRW_SWIZZLE_XYZW, 130803b705cfSriastradh WRITEMASK_XYZW); 130903b705cfSriastradh} 131003b705cfSriastradh 131103b705cfSriastradh/** Construct float[2] register */ 131203b705cfSriastradhstatic inline struct brw_reg brw_vec2_reg(unsigned file, 131303b705cfSriastradh unsigned nr, 131403b705cfSriastradh unsigned subnr) 131503b705cfSriastradh{ 131603b705cfSriastradh return brw_reg(file, 131703b705cfSriastradh nr, 131803b705cfSriastradh subnr, 131903b705cfSriastradh BRW_REGISTER_TYPE_F, 132003b705cfSriastradh BRW_VERTICAL_STRIDE_2, 132103b705cfSriastradh BRW_WIDTH_2, 132203b705cfSriastradh BRW_HORIZONTAL_STRIDE_1, 132303b705cfSriastradh BRW_SWIZZLE_XYXY, 132403b705cfSriastradh WRITEMASK_XY); 132503b705cfSriastradh} 132603b705cfSriastradh 132703b705cfSriastradh/** Construct float[1] register */ 132803b705cfSriastradhstatic inline struct brw_reg brw_vec1_reg(unsigned file, 132903b705cfSriastradh unsigned nr, 133003b705cfSriastradh unsigned subnr) 133103b705cfSriastradh{ 133203b705cfSriastradh return brw_reg(file, 133303b705cfSriastradh nr, 133403b705cfSriastradh subnr, 133503b705cfSriastradh BRW_REGISTER_TYPE_F, 133603b705cfSriastradh BRW_VERTICAL_STRIDE_0, 133703b705cfSriastradh BRW_WIDTH_1, 133803b705cfSriastradh BRW_HORIZONTAL_STRIDE_0, 133903b705cfSriastradh BRW_SWIZZLE_XXXX, 134003b705cfSriastradh WRITEMASK_X); 134103b705cfSriastradh} 134203b705cfSriastradh 134303b705cfSriastradh 134403b705cfSriastradhstatic inline struct brw_reg __retype(struct brw_reg reg, 134503b705cfSriastradh unsigned type) 134603b705cfSriastradh{ 134703b705cfSriastradh reg.type = type; 134803b705cfSriastradh return reg; 134903b705cfSriastradh} 135003b705cfSriastradh 135103b705cfSriastradhstatic inline struct brw_reg __retype_d(struct brw_reg reg) 135203b705cfSriastradh{ 135303b705cfSriastradh return __retype(reg, BRW_REGISTER_TYPE_D); 135403b705cfSriastradh} 135503b705cfSriastradh 135603b705cfSriastradhstatic inline struct brw_reg __retype_ud(struct brw_reg reg) 135703b705cfSriastradh{ 135803b705cfSriastradh return __retype(reg, BRW_REGISTER_TYPE_UD); 135903b705cfSriastradh} 136003b705cfSriastradh 136103b705cfSriastradhstatic inline struct brw_reg __retype_uw(struct brw_reg reg) 136203b705cfSriastradh{ 136303b705cfSriastradh return __retype(reg, BRW_REGISTER_TYPE_UW); 136403b705cfSriastradh} 136503b705cfSriastradh 136603b705cfSriastradhstatic inline struct brw_reg __sechalf(struct brw_reg reg) 136703b705cfSriastradh{ 136803b705cfSriastradh if (reg.vstride) 136903b705cfSriastradh reg.nr++; 137003b705cfSriastradh return reg; 137103b705cfSriastradh} 137203b705cfSriastradh 137303b705cfSriastradhstatic inline struct brw_reg __suboffset(struct brw_reg reg, 137403b705cfSriastradh unsigned delta) 137503b705cfSriastradh{ 137603b705cfSriastradh reg.subnr += delta * type_sz(reg.type); 137703b705cfSriastradh return reg; 137803b705cfSriastradh} 137903b705cfSriastradh 138003b705cfSriastradhstatic inline struct brw_reg __offset(struct brw_reg reg, 138103b705cfSriastradh unsigned delta) 138203b705cfSriastradh{ 138303b705cfSriastradh reg.nr += delta; 138403b705cfSriastradh return reg; 138503b705cfSriastradh} 138603b705cfSriastradh 138703b705cfSriastradhstatic inline struct brw_reg byte_offset(struct brw_reg reg, 138803b705cfSriastradh unsigned bytes) 138903b705cfSriastradh{ 139003b705cfSriastradh unsigned newoffset = reg.nr * REG_SIZE + reg.subnr + bytes; 139103b705cfSriastradh reg.nr = newoffset / REG_SIZE; 139203b705cfSriastradh reg.subnr = newoffset % REG_SIZE; 139303b705cfSriastradh return reg; 139403b705cfSriastradh} 139503b705cfSriastradh 139603b705cfSriastradh 139703b705cfSriastradh/** Construct unsigned word[16] register */ 139803b705cfSriastradhstatic inline struct brw_reg brw_uw16_reg(unsigned file, 139903b705cfSriastradh unsigned nr, 140003b705cfSriastradh unsigned subnr) 140103b705cfSriastradh{ 140203b705cfSriastradh return __suboffset(__retype(brw_vec16_reg(file, nr, 0), BRW_REGISTER_TYPE_UW), subnr); 140303b705cfSriastradh} 140403b705cfSriastradh 140503b705cfSriastradh/** Construct unsigned word[8] register */ 140603b705cfSriastradhstatic inline struct brw_reg brw_uw8_reg(unsigned file, 140703b705cfSriastradh unsigned nr, 140803b705cfSriastradh unsigned subnr) 140903b705cfSriastradh{ 141003b705cfSriastradh return __suboffset(__retype(brw_vec8_reg(file, nr, 0), BRW_REGISTER_TYPE_UW), subnr); 141103b705cfSriastradh} 141203b705cfSriastradh 141303b705cfSriastradh/** Construct unsigned word[1] register */ 141403b705cfSriastradhstatic inline struct brw_reg brw_uw1_reg(unsigned file, 141503b705cfSriastradh unsigned nr, 141603b705cfSriastradh unsigned subnr) 141703b705cfSriastradh{ 141803b705cfSriastradh return __suboffset(__retype(brw_vec1_reg(file, nr, 0), BRW_REGISTER_TYPE_UW), subnr); 141903b705cfSriastradh} 142003b705cfSriastradh 142103b705cfSriastradhstatic inline struct brw_reg brw_imm_reg(unsigned type) 142203b705cfSriastradh{ 142303b705cfSriastradh return brw_reg( BRW_IMMEDIATE_VALUE, 142403b705cfSriastradh 0, 142503b705cfSriastradh 0, 142603b705cfSriastradh type, 142703b705cfSriastradh BRW_VERTICAL_STRIDE_0, 142803b705cfSriastradh BRW_WIDTH_1, 142903b705cfSriastradh BRW_HORIZONTAL_STRIDE_0, 143003b705cfSriastradh 0, 143103b705cfSriastradh 0); 143203b705cfSriastradh} 143303b705cfSriastradh 143403b705cfSriastradh/** Construct float immediate register */ 143503b705cfSriastradhstatic inline struct brw_reg brw_imm_f(float f) 143603b705cfSriastradh{ 143703b705cfSriastradh struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_F); 143803b705cfSriastradh imm.dw1.f = f; 143903b705cfSriastradh return imm; 144003b705cfSriastradh} 144103b705cfSriastradh 144203b705cfSriastradh/** Construct integer immediate register */ 144303b705cfSriastradhstatic inline struct brw_reg brw_imm_d(int d) 144403b705cfSriastradh{ 144503b705cfSriastradh struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_D); 144603b705cfSriastradh imm.dw1.d = d; 144703b705cfSriastradh return imm; 144803b705cfSriastradh} 144903b705cfSriastradh 145003b705cfSriastradh/** Construct uint immediate register */ 145103b705cfSriastradhstatic inline struct brw_reg brw_imm_ud(unsigned ud) 145203b705cfSriastradh{ 145303b705cfSriastradh struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_UD); 145403b705cfSriastradh imm.dw1.ud = ud; 145503b705cfSriastradh return imm; 145603b705cfSriastradh} 145703b705cfSriastradh 145803b705cfSriastradh/** Construct ushort immediate register */ 145903b705cfSriastradhstatic inline struct brw_reg brw_imm_uw(uint16_t uw) 146003b705cfSriastradh{ 146103b705cfSriastradh struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_UW); 146203b705cfSriastradh imm.dw1.ud = uw | (uw << 16); 146303b705cfSriastradh return imm; 146403b705cfSriastradh} 146503b705cfSriastradh 146603b705cfSriastradh/** Construct short immediate register */ 146703b705cfSriastradhstatic inline struct brw_reg brw_imm_w(int16_t w) 146803b705cfSriastradh{ 146903b705cfSriastradh struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_W); 147003b705cfSriastradh imm.dw1.d = w | (w << 16); 147103b705cfSriastradh return imm; 147203b705cfSriastradh} 147303b705cfSriastradh 147403b705cfSriastradh/* brw_imm_b and brw_imm_ub aren't supported by hardware - the type 147503b705cfSriastradh * numbers alias with _V and _VF below: 147603b705cfSriastradh */ 147703b705cfSriastradh 147803b705cfSriastradh/** Construct vector of eight signed half-byte values */ 147903b705cfSriastradhstatic inline struct brw_reg brw_imm_v(unsigned v) 148003b705cfSriastradh{ 148103b705cfSriastradh struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_V); 148203b705cfSriastradh imm.vstride = BRW_VERTICAL_STRIDE_0; 148303b705cfSriastradh imm.width = BRW_WIDTH_8; 148403b705cfSriastradh imm.hstride = BRW_HORIZONTAL_STRIDE_1; 148503b705cfSriastradh imm.dw1.ud = v; 148603b705cfSriastradh return imm; 148703b705cfSriastradh} 148803b705cfSriastradh 148903b705cfSriastradh/** Construct vector of four 8-bit float values */ 149003b705cfSriastradhstatic inline struct brw_reg brw_imm_vf(unsigned v) 149103b705cfSriastradh{ 149203b705cfSriastradh struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_VF); 149303b705cfSriastradh imm.vstride = BRW_VERTICAL_STRIDE_0; 149403b705cfSriastradh imm.width = BRW_WIDTH_4; 149503b705cfSriastradh imm.hstride = BRW_HORIZONTAL_STRIDE_1; 149603b705cfSriastradh imm.dw1.ud = v; 149703b705cfSriastradh return imm; 149803b705cfSriastradh} 149903b705cfSriastradh 150003b705cfSriastradh#define VF_ZERO 0x0 150103b705cfSriastradh#define VF_ONE 0x30 150203b705cfSriastradh#define VF_NEG (1<<7) 150303b705cfSriastradh 150403b705cfSriastradhstatic inline struct brw_reg brw_imm_vf4(unsigned v0, 150503b705cfSriastradh unsigned v1, 150603b705cfSriastradh unsigned v2, 150703b705cfSriastradh unsigned v3) 150803b705cfSriastradh{ 150903b705cfSriastradh struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_VF); 151003b705cfSriastradh imm.vstride = BRW_VERTICAL_STRIDE_0; 151103b705cfSriastradh imm.width = BRW_WIDTH_4; 151203b705cfSriastradh imm.hstride = BRW_HORIZONTAL_STRIDE_1; 151303b705cfSriastradh imm.dw1.ud = ((v0 << 0) | 151403b705cfSriastradh (v1 << 8) | 151503b705cfSriastradh (v2 << 16) | 151603b705cfSriastradh (v3 << 24)); 151703b705cfSriastradh return imm; 151803b705cfSriastradh} 151903b705cfSriastradh 152003b705cfSriastradhstatic inline struct brw_reg brw_address(struct brw_reg reg) 152103b705cfSriastradh{ 152203b705cfSriastradh return brw_imm_uw(reg.nr * REG_SIZE + reg.subnr); 152303b705cfSriastradh} 152403b705cfSriastradh 152503b705cfSriastradh/** Construct float[1] general-purpose register */ 152603b705cfSriastradhstatic inline struct brw_reg brw_vec1_grf(unsigned nr, unsigned subnr) 152703b705cfSriastradh{ 152803b705cfSriastradh return brw_vec1_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr); 152903b705cfSriastradh} 153003b705cfSriastradh 153103b705cfSriastradh/** Construct float[2] general-purpose register */ 153203b705cfSriastradhstatic inline struct brw_reg brw_vec2_grf(unsigned nr, unsigned subnr) 153303b705cfSriastradh{ 153403b705cfSriastradh return brw_vec2_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr); 153503b705cfSriastradh} 153603b705cfSriastradh 153703b705cfSriastradh/** Construct float[4] general-purpose register */ 153803b705cfSriastradhstatic inline struct brw_reg brw_vec4_grf(unsigned nr, unsigned subnr) 153903b705cfSriastradh{ 154003b705cfSriastradh return brw_vec4_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr); 154103b705cfSriastradh} 154203b705cfSriastradh 154303b705cfSriastradh/** Construct float[8] general-purpose register */ 154403b705cfSriastradhstatic inline struct brw_reg brw_vec8_grf(unsigned nr, unsigned subnr) 154503b705cfSriastradh{ 154603b705cfSriastradh return brw_vec8_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr); 154703b705cfSriastradh} 154803b705cfSriastradh 154903b705cfSriastradhstatic inline struct brw_reg brw_uw8_grf(unsigned nr, unsigned subnr) 155003b705cfSriastradh{ 155103b705cfSriastradh return brw_uw8_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr); 155203b705cfSriastradh} 155303b705cfSriastradh 155403b705cfSriastradhstatic inline struct brw_reg brw_uw16_grf(unsigned nr, unsigned subnr) 155503b705cfSriastradh{ 155603b705cfSriastradh return brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr); 155703b705cfSriastradh} 155803b705cfSriastradh 155903b705cfSriastradh/** Construct null register (usually used for setting condition codes) */ 156003b705cfSriastradhstatic inline struct brw_reg brw_null_reg(void) 156103b705cfSriastradh{ 156203b705cfSriastradh return brw_vec8_reg(BRW_ARCHITECTURE_REGISTER_FILE, 156303b705cfSriastradh BRW_ARF_NULL, 156403b705cfSriastradh 0); 156503b705cfSriastradh} 156603b705cfSriastradh 156703b705cfSriastradhstatic inline struct brw_reg brw_address_reg(unsigned subnr) 156803b705cfSriastradh{ 156903b705cfSriastradh return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE, 157003b705cfSriastradh BRW_ARF_ADDRESS, 157103b705cfSriastradh subnr); 157203b705cfSriastradh} 157303b705cfSriastradh 157403b705cfSriastradh/* If/else instructions break in align16 mode if writemask & swizzle 157503b705cfSriastradh * aren't xyzw. This goes against the convention for other scalar 157603b705cfSriastradh * regs: 157703b705cfSriastradh */ 157803b705cfSriastradhstatic inline struct brw_reg brw_ip_reg(void) 157903b705cfSriastradh{ 158003b705cfSriastradh return brw_reg(BRW_ARCHITECTURE_REGISTER_FILE, 158103b705cfSriastradh BRW_ARF_IP, 158203b705cfSriastradh 0, 158303b705cfSriastradh BRW_REGISTER_TYPE_UD, 158403b705cfSriastradh BRW_VERTICAL_STRIDE_4, /* ? */ 158503b705cfSriastradh BRW_WIDTH_1, 158603b705cfSriastradh BRW_HORIZONTAL_STRIDE_0, 158703b705cfSriastradh BRW_SWIZZLE_XYZW, /* NOTE! */ 158803b705cfSriastradh WRITEMASK_XYZW); /* NOTE! */ 158903b705cfSriastradh} 159003b705cfSriastradh 159103b705cfSriastradhstatic inline struct brw_reg brw_acc_reg(void) 159203b705cfSriastradh{ 159303b705cfSriastradh return brw_vec8_reg(BRW_ARCHITECTURE_REGISTER_FILE, 159403b705cfSriastradh BRW_ARF_ACCUMULATOR, 159503b705cfSriastradh 0); 159603b705cfSriastradh} 159703b705cfSriastradh 159803b705cfSriastradhstatic inline struct brw_reg brw_notification_1_reg(void) 159903b705cfSriastradh{ 160003b705cfSriastradh return brw_reg(BRW_ARCHITECTURE_REGISTER_FILE, 160103b705cfSriastradh BRW_ARF_NOTIFICATION_COUNT, 160203b705cfSriastradh 1, 160303b705cfSriastradh BRW_REGISTER_TYPE_UD, 160403b705cfSriastradh BRW_VERTICAL_STRIDE_0, 160503b705cfSriastradh BRW_WIDTH_1, 160603b705cfSriastradh BRW_HORIZONTAL_STRIDE_0, 160703b705cfSriastradh BRW_SWIZZLE_XXXX, 160803b705cfSriastradh WRITEMASK_X); 160903b705cfSriastradh} 161003b705cfSriastradh 161103b705cfSriastradhstatic inline struct brw_reg brw_flag_reg(void) 161203b705cfSriastradh{ 161303b705cfSriastradh return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE, 161403b705cfSriastradh BRW_ARF_FLAG, 161503b705cfSriastradh 0); 161603b705cfSriastradh} 161703b705cfSriastradh 161803b705cfSriastradhstatic inline struct brw_reg brw_mask_reg(unsigned subnr) 161903b705cfSriastradh{ 162003b705cfSriastradh return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE, 162103b705cfSriastradh BRW_ARF_MASK, 162203b705cfSriastradh subnr); 162303b705cfSriastradh} 162403b705cfSriastradh 162503b705cfSriastradhstatic inline struct brw_reg brw_message_reg(unsigned nr) 162603b705cfSriastradh{ 162703b705cfSriastradh assert((nr & ~(1 << 7)) < BRW_MAX_MRF); 162803b705cfSriastradh return brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE, nr, 0); 162903b705cfSriastradh} 163003b705cfSriastradh 163103b705cfSriastradhstatic inline struct brw_reg brw_message4_reg(unsigned nr, 163203b705cfSriastradh int subnr) 163303b705cfSriastradh{ 163403b705cfSriastradh assert((nr & ~(1 << 7)) < BRW_MAX_MRF); 163503b705cfSriastradh return brw_vec4_reg(BRW_MESSAGE_REGISTER_FILE, nr, subnr); 163603b705cfSriastradh} 163703b705cfSriastradh 163803b705cfSriastradh/* This is almost always called with a numeric constant argument, so 163903b705cfSriastradh * make things easy to evaluate at compile time: 164003b705cfSriastradh */ 164103b705cfSriastradhstatic inline unsigned cvt(unsigned val) 164203b705cfSriastradh{ 164303b705cfSriastradh switch (val) { 164403b705cfSriastradh case 0: return 0; 164503b705cfSriastradh case 1: return 1; 164603b705cfSriastradh case 2: return 2; 164703b705cfSriastradh case 4: return 3; 164803b705cfSriastradh case 8: return 4; 164903b705cfSriastradh case 16: return 5; 165003b705cfSriastradh case 32: return 6; 165103b705cfSriastradh } 165203b705cfSriastradh return 0; 165303b705cfSriastradh} 165403b705cfSriastradh 165503b705cfSriastradhstatic inline struct brw_reg __stride(struct brw_reg reg, 165603b705cfSriastradh unsigned vstride, 165703b705cfSriastradh unsigned width, 165803b705cfSriastradh unsigned hstride) 165903b705cfSriastradh{ 166003b705cfSriastradh reg.vstride = cvt(vstride); 166103b705cfSriastradh reg.width = cvt(width) - 1; 166203b705cfSriastradh reg.hstride = cvt(hstride); 166303b705cfSriastradh return reg; 166403b705cfSriastradh} 166503b705cfSriastradh 166603b705cfSriastradhstatic inline struct brw_reg vec16(struct brw_reg reg) 166703b705cfSriastradh{ 166803b705cfSriastradh return __stride(reg, 16,16,1); 166903b705cfSriastradh} 167003b705cfSriastradh 167103b705cfSriastradhstatic inline struct brw_reg vec8(struct brw_reg reg) 167203b705cfSriastradh{ 167303b705cfSriastradh return __stride(reg, 8,8,1); 167403b705cfSriastradh} 167503b705cfSriastradh 167603b705cfSriastradhstatic inline struct brw_reg vec4(struct brw_reg reg) 167703b705cfSriastradh{ 167803b705cfSriastradh return __stride(reg, 4,4,1); 167903b705cfSriastradh} 168003b705cfSriastradh 168103b705cfSriastradhstatic inline struct brw_reg vec2(struct brw_reg reg) 168203b705cfSriastradh{ 168303b705cfSriastradh return __stride(reg, 2,2,1); 168403b705cfSriastradh} 168503b705cfSriastradh 168603b705cfSriastradhstatic inline struct brw_reg vec1(struct brw_reg reg) 168703b705cfSriastradh{ 168803b705cfSriastradh return __stride(reg, 0,1,0); 168903b705cfSriastradh} 169003b705cfSriastradh 169103b705cfSriastradhstatic inline struct brw_reg get_element(struct brw_reg reg, unsigned elt) 169203b705cfSriastradh{ 169303b705cfSriastradh return vec1(__suboffset(reg, elt)); 169403b705cfSriastradh} 169503b705cfSriastradh 169603b705cfSriastradhstatic inline struct brw_reg get_element_ud(struct brw_reg reg, unsigned elt) 169703b705cfSriastradh{ 169803b705cfSriastradh return vec1(__suboffset(__retype(reg, BRW_REGISTER_TYPE_UD), elt)); 169903b705cfSriastradh} 170003b705cfSriastradh 170103b705cfSriastradhstatic inline struct brw_reg brw_swizzle(struct brw_reg reg, 170203b705cfSriastradh unsigned x, 170303b705cfSriastradh unsigned y, 170403b705cfSriastradh unsigned z, 170503b705cfSriastradh unsigned w) 170603b705cfSriastradh{ 170703b705cfSriastradh assert(reg.file != BRW_IMMEDIATE_VALUE); 170803b705cfSriastradh 170903b705cfSriastradh reg.dw1.bits.swizzle = BRW_SWIZZLE4(BRW_GET_SWZ(reg.dw1.bits.swizzle, x), 171003b705cfSriastradh BRW_GET_SWZ(reg.dw1.bits.swizzle, y), 171103b705cfSriastradh BRW_GET_SWZ(reg.dw1.bits.swizzle, z), 171203b705cfSriastradh BRW_GET_SWZ(reg.dw1.bits.swizzle, w)); 171303b705cfSriastradh return reg; 171403b705cfSriastradh} 171503b705cfSriastradh 171603b705cfSriastradhstatic inline struct brw_reg brw_swizzle1(struct brw_reg reg, 171703b705cfSriastradh unsigned x) 171803b705cfSriastradh{ 171903b705cfSriastradh return brw_swizzle(reg, x, x, x, x); 172003b705cfSriastradh} 172103b705cfSriastradh 172203b705cfSriastradhstatic inline struct brw_reg brw_writemask(struct brw_reg reg, 172303b705cfSriastradh unsigned mask) 172403b705cfSriastradh{ 172503b705cfSriastradh assert(reg.file != BRW_IMMEDIATE_VALUE); 172603b705cfSriastradh reg.dw1.bits.writemask &= mask; 172703b705cfSriastradh return reg; 172803b705cfSriastradh} 172903b705cfSriastradh 173003b705cfSriastradhstatic inline struct brw_reg brw_set_writemask(struct brw_reg reg, 173103b705cfSriastradh unsigned mask) 173203b705cfSriastradh{ 173303b705cfSriastradh assert(reg.file != BRW_IMMEDIATE_VALUE); 173403b705cfSriastradh reg.dw1.bits.writemask = mask; 173503b705cfSriastradh return reg; 173603b705cfSriastradh} 173703b705cfSriastradh 173803b705cfSriastradhstatic inline struct brw_reg brw_negate(struct brw_reg reg) 173903b705cfSriastradh{ 174003b705cfSriastradh reg.negate ^= 1; 174103b705cfSriastradh return reg; 174203b705cfSriastradh} 174303b705cfSriastradh 174403b705cfSriastradhstatic inline struct brw_reg brw_abs(struct brw_reg reg) 174503b705cfSriastradh{ 174603b705cfSriastradh reg.abs = 1; 174703b705cfSriastradh return reg; 174803b705cfSriastradh} 174903b705cfSriastradh 175003b705cfSriastradh/*********************************************************************** 175103b705cfSriastradh*/ 175203b705cfSriastradhstatic inline struct brw_reg brw_vec4_indirect(unsigned subnr, 175303b705cfSriastradh int offset) 175403b705cfSriastradh{ 175503b705cfSriastradh struct brw_reg reg = brw_vec4_grf(0, 0); 175603b705cfSriastradh reg.subnr = subnr; 175703b705cfSriastradh reg.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER; 175803b705cfSriastradh reg.dw1.bits.indirect_offset = offset; 175903b705cfSriastradh return reg; 176003b705cfSriastradh} 176103b705cfSriastradh 176203b705cfSriastradhstatic inline struct brw_reg brw_vec1_indirect(unsigned subnr, 176303b705cfSriastradh int offset) 176403b705cfSriastradh{ 176503b705cfSriastradh struct brw_reg reg = brw_vec1_grf(0, 0); 176603b705cfSriastradh reg.subnr = subnr; 176703b705cfSriastradh reg.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER; 176803b705cfSriastradh reg.dw1.bits.indirect_offset = offset; 176903b705cfSriastradh return reg; 177003b705cfSriastradh} 177103b705cfSriastradh 177203b705cfSriastradhstatic inline struct brw_reg deref_4f(struct brw_indirect ptr, int offset) 177303b705cfSriastradh{ 177403b705cfSriastradh return brw_vec4_indirect(ptr.addr_subnr, ptr.addr_offset + offset); 177503b705cfSriastradh} 177603b705cfSriastradh 177703b705cfSriastradhstatic inline struct brw_reg deref_1f(struct brw_indirect ptr, int offset) 177803b705cfSriastradh{ 177903b705cfSriastradh return brw_vec1_indirect(ptr.addr_subnr, ptr.addr_offset + offset); 178003b705cfSriastradh} 178103b705cfSriastradh 178203b705cfSriastradhstatic inline struct brw_reg deref_4b(struct brw_indirect ptr, int offset) 178303b705cfSriastradh{ 178403b705cfSriastradh return __retype(deref_4f(ptr, offset), BRW_REGISTER_TYPE_B); 178503b705cfSriastradh} 178603b705cfSriastradh 178703b705cfSriastradhstatic inline struct brw_reg deref_1uw(struct brw_indirect ptr, int offset) 178803b705cfSriastradh{ 178903b705cfSriastradh return __retype(deref_1f(ptr, offset), BRW_REGISTER_TYPE_UW); 179003b705cfSriastradh} 179103b705cfSriastradh 179203b705cfSriastradhstatic inline struct brw_reg deref_1d(struct brw_indirect ptr, int offset) 179303b705cfSriastradh{ 179403b705cfSriastradh return __retype(deref_1f(ptr, offset), BRW_REGISTER_TYPE_D); 179503b705cfSriastradh} 179603b705cfSriastradh 179703b705cfSriastradhstatic inline struct brw_reg deref_1ud(struct brw_indirect ptr, int offset) 179803b705cfSriastradh{ 179903b705cfSriastradh return __retype(deref_1f(ptr, offset), BRW_REGISTER_TYPE_UD); 180003b705cfSriastradh} 180103b705cfSriastradh 180203b705cfSriastradhstatic inline struct brw_reg get_addr_reg(struct brw_indirect ptr) 180303b705cfSriastradh{ 180403b705cfSriastradh return brw_address_reg(ptr.addr_subnr); 180503b705cfSriastradh} 180603b705cfSriastradh 180703b705cfSriastradhstatic inline struct brw_indirect brw_indirect_offset(struct brw_indirect ptr, int offset) 180803b705cfSriastradh{ 180903b705cfSriastradh ptr.addr_offset += offset; 181003b705cfSriastradh return ptr; 181103b705cfSriastradh} 181203b705cfSriastradh 181303b705cfSriastradhstatic inline struct brw_indirect brw_indirect(unsigned addr_subnr, int offset) 181403b705cfSriastradh{ 181503b705cfSriastradh struct brw_indirect ptr; 181603b705cfSriastradh ptr.addr_subnr = addr_subnr; 181703b705cfSriastradh ptr.addr_offset = offset; 181803b705cfSriastradh ptr.pad = 0; 181903b705cfSriastradh return ptr; 182003b705cfSriastradh} 182103b705cfSriastradh 182203b705cfSriastradh/** Do two brw_regs refer to the same register? */ 182303b705cfSriastradhstatic inline bool brw_same_reg(struct brw_reg r1, struct brw_reg r2) 182403b705cfSriastradh{ 182503b705cfSriastradh return r1.file == r2.file && r1.nr == r2.nr; 182603b705cfSriastradh} 182703b705cfSriastradh 182803b705cfSriastradhstatic inline struct brw_instruction *current_insn( struct brw_compile *p) 182903b705cfSriastradh{ 183003b705cfSriastradh return &p->store[p->nr_insn]; 183103b705cfSriastradh} 183203b705cfSriastradh 183303b705cfSriastradhstatic inline void brw_set_predicate_control( struct brw_compile *p, unsigned pc ) 183403b705cfSriastradh{ 183503b705cfSriastradh p->current->header.predicate_control = pc; 183603b705cfSriastradh} 183703b705cfSriastradh 183803b705cfSriastradhstatic inline void brw_set_predicate_inverse(struct brw_compile *p, bool predicate_inverse) 183903b705cfSriastradh{ 184003b705cfSriastradh p->current->header.predicate_inverse = predicate_inverse; 184103b705cfSriastradh} 184203b705cfSriastradh 184303b705cfSriastradhstatic inline void brw_set_conditionalmod( struct brw_compile *p, unsigned conditional ) 184403b705cfSriastradh{ 184503b705cfSriastradh p->current->header.destreg__conditionalmod = conditional; 184603b705cfSriastradh} 184703b705cfSriastradh 184803b705cfSriastradhstatic inline void brw_set_access_mode(struct brw_compile *p, unsigned access_mode) 184903b705cfSriastradh{ 185003b705cfSriastradh p->current->header.access_mode = access_mode; 185103b705cfSriastradh} 185203b705cfSriastradh 185303b705cfSriastradhstatic inline void brw_set_mask_control(struct brw_compile *p, unsigned value) 185403b705cfSriastradh{ 185503b705cfSriastradh p->current->header.mask_control = value; 185603b705cfSriastradh} 185703b705cfSriastradh 185803b705cfSriastradhstatic inline void brw_set_saturate(struct brw_compile *p, unsigned value) 185903b705cfSriastradh{ 186003b705cfSriastradh p->current->header.saturate = value; 186103b705cfSriastradh} 186203b705cfSriastradh 186303b705cfSriastradhstatic inline void brw_set_acc_write_control(struct brw_compile *p, unsigned value) 186403b705cfSriastradh{ 186503b705cfSriastradh if (p->gen >= 060) 186603b705cfSriastradh p->current->header.acc_wr_control = value; 186703b705cfSriastradh} 186803b705cfSriastradh 186903b705cfSriastradhvoid brw_pop_insn_state(struct brw_compile *p); 187003b705cfSriastradhvoid brw_push_insn_state(struct brw_compile *p); 187103b705cfSriastradhvoid brw_set_compression_control(struct brw_compile *p, enum brw_compression control); 187203b705cfSriastradhvoid brw_set_predicate_control_flag_value( struct brw_compile *p, unsigned value ); 187303b705cfSriastradh 187403b705cfSriastradhvoid brw_compile_init(struct brw_compile *p, int gen, void *store); 187503b705cfSriastradh 187603b705cfSriastradhvoid brw_set_dest(struct brw_compile *p, struct brw_instruction *insn, 187703b705cfSriastradh struct brw_reg dest); 187803b705cfSriastradhvoid brw_set_src0(struct brw_compile *p, struct brw_instruction *insn, 187903b705cfSriastradh struct brw_reg reg); 188003b705cfSriastradhvoid brw_set_src1(struct brw_compile *p, 188103b705cfSriastradh struct brw_instruction *insn, 188203b705cfSriastradh struct brw_reg reg); 188303b705cfSriastradh 188403b705cfSriastradhvoid gen6_resolve_implied_move(struct brw_compile *p, 188503b705cfSriastradh struct brw_reg *src, 188603b705cfSriastradh unsigned msg_reg_nr); 188703b705cfSriastradh 188803b705cfSriastradhstatic inline struct brw_instruction * 188903b705cfSriastradhbrw_next_insn(struct brw_compile *p, unsigned opcode) 189003b705cfSriastradh{ 189103b705cfSriastradh struct brw_instruction *insn; 189203b705cfSriastradh 189303b705cfSriastradh assert(p->nr_insn + 1 < BRW_EU_MAX_INSN); 189403b705cfSriastradh 189503b705cfSriastradh insn = &p->store[p->nr_insn++]; 189603b705cfSriastradh *insn = *p->current; 189703b705cfSriastradh 189803b705cfSriastradh if (p->current->header.destreg__conditionalmod) { 189903b705cfSriastradh p->current->header.destreg__conditionalmod = 0; 190003b705cfSriastradh p->current->header.predicate_control = BRW_PREDICATE_NORMAL; 190103b705cfSriastradh } 190203b705cfSriastradh 190303b705cfSriastradh insn->header.opcode = opcode; 190403b705cfSriastradh return insn; 190503b705cfSriastradh} 190603b705cfSriastradh 190703b705cfSriastradh/* Helpers for regular instructions: */ 190803b705cfSriastradh#define ALU1(OP) \ 190903b705cfSriastradhstatic inline struct brw_instruction *brw_##OP(struct brw_compile *p, \ 191003b705cfSriastradh struct brw_reg dest, \ 191103b705cfSriastradh struct brw_reg src0) \ 191203b705cfSriastradh{ \ 191303b705cfSriastradh return brw_alu1(p, BRW_OPCODE_##OP, dest, src0); \ 191403b705cfSriastradh} 191503b705cfSriastradh 191603b705cfSriastradh#define ALU2(OP) \ 191703b705cfSriastradhstatic inline struct brw_instruction *brw_##OP(struct brw_compile *p, \ 191803b705cfSriastradh struct brw_reg dest, \ 191903b705cfSriastradh struct brw_reg src0, \ 192003b705cfSriastradh struct brw_reg src1) \ 192103b705cfSriastradh{ \ 192203b705cfSriastradh return brw_alu2(p, BRW_OPCODE_##OP, dest, src0, src1); \ 192303b705cfSriastradh} 192403b705cfSriastradh 192503b705cfSriastradh/* Rounding operations (other than RNDD) require two instructions - the first 192603b705cfSriastradh * stores a rounded value (possibly the wrong way) in the dest register, but 192703b705cfSriastradh * also sets a per-channel "increment bit" in the flag register. A predicated 192803b705cfSriastradh * add of 1.0 fixes dest to contain the desired result. 192903b705cfSriastradh * 193003b705cfSriastradh * Sandybridge and later appear to round correctly without an ADD. 193103b705cfSriastradh */ 193203b705cfSriastradh#define ROUND(OP) \ 193303b705cfSriastradhstatic inline void brw_##OP(struct brw_compile *p, \ 193403b705cfSriastradh struct brw_reg dest, \ 193503b705cfSriastradh struct brw_reg src) \ 193603b705cfSriastradh{ \ 193703b705cfSriastradh struct brw_instruction *rnd, *add; \ 193803b705cfSriastradh rnd = brw_next_insn(p, BRW_OPCODE_##OP); \ 193903b705cfSriastradh brw_set_dest(p, rnd, dest); \ 194003b705cfSriastradh brw_set_src0(p, rnd, src); \ 194103b705cfSriastradh if (p->gen < 060) { \ 194203b705cfSriastradh /* turn on round-increments */ \ 194303b705cfSriastradh rnd->header.destreg__conditionalmod = BRW_CONDITIONAL_R; \ 194403b705cfSriastradh add = brw_ADD(p, dest, dest, brw_imm_f(1.0f)); \ 194503b705cfSriastradh add->header.predicate_control = BRW_PREDICATE_NORMAL; \ 194603b705cfSriastradh } \ 194703b705cfSriastradh} 194803b705cfSriastradh 194903b705cfSriastradhstatic inline struct brw_instruction *brw_alu1(struct brw_compile *p, 195003b705cfSriastradh unsigned opcode, 195103b705cfSriastradh struct brw_reg dest, 195203b705cfSriastradh struct brw_reg src) 195303b705cfSriastradh{ 195403b705cfSriastradh struct brw_instruction *insn = brw_next_insn(p, opcode); 195503b705cfSriastradh brw_set_dest(p, insn, dest); 195603b705cfSriastradh brw_set_src0(p, insn, src); 195703b705cfSriastradh return insn; 195803b705cfSriastradh} 195903b705cfSriastradh 196003b705cfSriastradhstatic inline struct brw_instruction *brw_alu2(struct brw_compile *p, 196103b705cfSriastradh unsigned opcode, 196203b705cfSriastradh struct brw_reg dest, 196303b705cfSriastradh struct brw_reg src0, 196403b705cfSriastradh struct brw_reg src1 ) 196503b705cfSriastradh{ 196603b705cfSriastradh struct brw_instruction *insn = brw_next_insn(p, opcode); 196703b705cfSriastradh brw_set_dest(p, insn, dest); 196803b705cfSriastradh brw_set_src0(p, insn, src0); 196903b705cfSriastradh brw_set_src1(p, insn, src1); 197003b705cfSriastradh return insn; 197103b705cfSriastradh} 197203b705cfSriastradh 197303b705cfSriastradhstatic inline struct brw_instruction *brw_ADD(struct brw_compile *p, 197403b705cfSriastradh struct brw_reg dest, 197503b705cfSriastradh struct brw_reg src0, 197603b705cfSriastradh struct brw_reg src1) 197703b705cfSriastradh{ 197803b705cfSriastradh /* 6.2.2: add */ 197903b705cfSriastradh if (src0.type == BRW_REGISTER_TYPE_F || 198003b705cfSriastradh (src0.file == BRW_IMMEDIATE_VALUE && 198103b705cfSriastradh src0.type == BRW_REGISTER_TYPE_VF)) { 198203b705cfSriastradh assert(src1.type != BRW_REGISTER_TYPE_UD); 198303b705cfSriastradh assert(src1.type != BRW_REGISTER_TYPE_D); 198403b705cfSriastradh } 198503b705cfSriastradh 198603b705cfSriastradh if (src1.type == BRW_REGISTER_TYPE_F || 198703b705cfSriastradh (src1.file == BRW_IMMEDIATE_VALUE && 198803b705cfSriastradh src1.type == BRW_REGISTER_TYPE_VF)) { 198903b705cfSriastradh assert(src0.type != BRW_REGISTER_TYPE_UD); 199003b705cfSriastradh assert(src0.type != BRW_REGISTER_TYPE_D); 199103b705cfSriastradh } 199203b705cfSriastradh 199303b705cfSriastradh return brw_alu2(p, BRW_OPCODE_ADD, dest, src0, src1); 199403b705cfSriastradh} 199503b705cfSriastradh 199603b705cfSriastradhstatic inline struct brw_instruction *brw_MUL(struct brw_compile *p, 199703b705cfSriastradh struct brw_reg dest, 199803b705cfSriastradh struct brw_reg src0, 199903b705cfSriastradh struct brw_reg src1) 200003b705cfSriastradh{ 200103b705cfSriastradh /* 6.32.38: mul */ 200203b705cfSriastradh if (src0.type == BRW_REGISTER_TYPE_D || 200303b705cfSriastradh src0.type == BRW_REGISTER_TYPE_UD || 200403b705cfSriastradh src1.type == BRW_REGISTER_TYPE_D || 200503b705cfSriastradh src1.type == BRW_REGISTER_TYPE_UD) { 200603b705cfSriastradh assert(dest.type != BRW_REGISTER_TYPE_F); 200703b705cfSriastradh } 200803b705cfSriastradh 200903b705cfSriastradh if (src0.type == BRW_REGISTER_TYPE_F || 201003b705cfSriastradh (src0.file == BRW_IMMEDIATE_VALUE && 201103b705cfSriastradh src0.type == BRW_REGISTER_TYPE_VF)) { 201203b705cfSriastradh assert(src1.type != BRW_REGISTER_TYPE_UD); 201303b705cfSriastradh assert(src1.type != BRW_REGISTER_TYPE_D); 201403b705cfSriastradh } 201503b705cfSriastradh 201603b705cfSriastradh if (src1.type == BRW_REGISTER_TYPE_F || 201703b705cfSriastradh (src1.file == BRW_IMMEDIATE_VALUE && 201803b705cfSriastradh src1.type == BRW_REGISTER_TYPE_VF)) { 201903b705cfSriastradh assert(src0.type != BRW_REGISTER_TYPE_UD); 202003b705cfSriastradh assert(src0.type != BRW_REGISTER_TYPE_D); 202103b705cfSriastradh } 202203b705cfSriastradh 202303b705cfSriastradh assert(src0.file != BRW_ARCHITECTURE_REGISTER_FILE || 202403b705cfSriastradh src0.nr != BRW_ARF_ACCUMULATOR); 202503b705cfSriastradh assert(src1.file != BRW_ARCHITECTURE_REGISTER_FILE || 202603b705cfSriastradh src1.nr != BRW_ARF_ACCUMULATOR); 202703b705cfSriastradh 202803b705cfSriastradh return brw_alu2(p, BRW_OPCODE_MUL, dest, src0, src1); 202903b705cfSriastradh} 203003b705cfSriastradh 203103b705cfSriastradhstatic inline struct brw_instruction *brw_JMPI(struct brw_compile *p, 203203b705cfSriastradh struct brw_reg dest, 203303b705cfSriastradh struct brw_reg src0, 203403b705cfSriastradh struct brw_reg src1) 203503b705cfSriastradh{ 203603b705cfSriastradh struct brw_instruction *insn = brw_alu2(p, BRW_OPCODE_JMPI, dest, src0, src1); 203703b705cfSriastradh 203803b705cfSriastradh insn->header.execution_size = 1; 203903b705cfSriastradh insn->header.compression_control = BRW_COMPRESSION_NONE; 204003b705cfSriastradh insn->header.mask_control = BRW_MASK_DISABLE; 204103b705cfSriastradh 204203b705cfSriastradh p->current->header.predicate_control = BRW_PREDICATE_NONE; 204303b705cfSriastradh 204403b705cfSriastradh return insn; 204503b705cfSriastradh} 204603b705cfSriastradh 204703b705cfSriastradh 204803b705cfSriastradhALU1(MOV); 204903b705cfSriastradhALU2(SEL); 205003b705cfSriastradhALU1(NOT); 205103b705cfSriastradhALU2(AND); 205203b705cfSriastradhALU2(OR); 205303b705cfSriastradhALU2(XOR); 205403b705cfSriastradhALU2(SHR); 205503b705cfSriastradhALU2(SHL); 205603b705cfSriastradhALU2(RSR); 205703b705cfSriastradhALU2(RSL); 205803b705cfSriastradhALU2(ASR); 205903b705cfSriastradhALU1(FRC); 206003b705cfSriastradhALU1(RNDD); 206103b705cfSriastradhALU2(MAC); 206203b705cfSriastradhALU2(MACH); 206303b705cfSriastradhALU1(LZD); 206403b705cfSriastradhALU2(DP4); 206503b705cfSriastradhALU2(DPH); 206603b705cfSriastradhALU2(DP3); 206703b705cfSriastradhALU2(DP2); 206803b705cfSriastradhALU2(LINE); 206903b705cfSriastradhALU2(PLN); 207003b705cfSriastradh 207103b705cfSriastradhROUND(RNDZ); 207203b705cfSriastradhROUND(RNDE); 207303b705cfSriastradh 207403b705cfSriastradh#undef ALU1 207503b705cfSriastradh#undef ALU2 207603b705cfSriastradh#undef ROUND 207703b705cfSriastradh 207803b705cfSriastradh/* Helpers for SEND instruction */ 207903b705cfSriastradhvoid brw_set_dp_read_message(struct brw_compile *p, 208003b705cfSriastradh struct brw_instruction *insn, 208103b705cfSriastradh unsigned binding_table_index, 208203b705cfSriastradh unsigned msg_control, 208303b705cfSriastradh unsigned msg_type, 208403b705cfSriastradh unsigned target_cache, 208503b705cfSriastradh unsigned msg_length, 208603b705cfSriastradh unsigned response_length); 208703b705cfSriastradh 208803b705cfSriastradhvoid brw_set_dp_write_message(struct brw_compile *p, 208903b705cfSriastradh struct brw_instruction *insn, 209003b705cfSriastradh unsigned binding_table_index, 209103b705cfSriastradh unsigned msg_control, 209203b705cfSriastradh unsigned msg_type, 209303b705cfSriastradh unsigned msg_length, 209403b705cfSriastradh bool header_present, 209503b705cfSriastradh bool last_render_target, 209603b705cfSriastradh unsigned response_length, 209703b705cfSriastradh bool end_of_thread, 209803b705cfSriastradh bool send_commit_msg); 209903b705cfSriastradh 210003b705cfSriastradhvoid brw_urb_WRITE(struct brw_compile *p, 210103b705cfSriastradh struct brw_reg dest, 210203b705cfSriastradh unsigned msg_reg_nr, 210303b705cfSriastradh struct brw_reg src0, 210403b705cfSriastradh bool allocate, 210503b705cfSriastradh bool used, 210603b705cfSriastradh unsigned msg_length, 210703b705cfSriastradh unsigned response_length, 210803b705cfSriastradh bool eot, 210903b705cfSriastradh bool writes_complete, 211003b705cfSriastradh unsigned offset, 211103b705cfSriastradh unsigned swizzle); 211203b705cfSriastradh 211303b705cfSriastradhvoid brw_ff_sync(struct brw_compile *p, 211403b705cfSriastradh struct brw_reg dest, 211503b705cfSriastradh unsigned msg_reg_nr, 211603b705cfSriastradh struct brw_reg src0, 211703b705cfSriastradh bool allocate, 211803b705cfSriastradh unsigned response_length, 211903b705cfSriastradh bool eot); 212003b705cfSriastradh 212103b705cfSriastradhvoid brw_fb_WRITE(struct brw_compile *p, 212203b705cfSriastradh int dispatch_width, 212303b705cfSriastradh unsigned msg_reg_nr, 212403b705cfSriastradh struct brw_reg src0, 212503b705cfSriastradh unsigned msg_control, 212603b705cfSriastradh unsigned binding_table_index, 212703b705cfSriastradh unsigned msg_length, 212803b705cfSriastradh unsigned response_length, 212903b705cfSriastradh bool eot, 213003b705cfSriastradh bool header_present); 213103b705cfSriastradh 213203b705cfSriastradhvoid brw_SAMPLE(struct brw_compile *p, 213303b705cfSriastradh struct brw_reg dest, 213403b705cfSriastradh unsigned msg_reg_nr, 213503b705cfSriastradh struct brw_reg src0, 213603b705cfSriastradh unsigned binding_table_index, 213703b705cfSriastradh unsigned sampler, 213803b705cfSriastradh unsigned writemask, 213903b705cfSriastradh unsigned msg_type, 214003b705cfSriastradh unsigned response_length, 214103b705cfSriastradh unsigned msg_length, 214203b705cfSriastradh bool header_present, 214303b705cfSriastradh unsigned simd_mode); 214403b705cfSriastradh 214503b705cfSriastradhvoid brw_math_16(struct brw_compile *p, 214603b705cfSriastradh struct brw_reg dest, 214703b705cfSriastradh unsigned function, 214803b705cfSriastradh unsigned saturate, 214903b705cfSriastradh unsigned msg_reg_nr, 215003b705cfSriastradh struct brw_reg src, 215103b705cfSriastradh unsigned precision); 215203b705cfSriastradh 215303b705cfSriastradhvoid brw_math(struct brw_compile *p, 215403b705cfSriastradh struct brw_reg dest, 215503b705cfSriastradh unsigned function, 215603b705cfSriastradh unsigned saturate, 215703b705cfSriastradh unsigned msg_reg_nr, 215803b705cfSriastradh struct brw_reg src, 215903b705cfSriastradh unsigned data_type, 216003b705cfSriastradh unsigned precision); 216103b705cfSriastradh 216203b705cfSriastradhvoid brw_math2(struct brw_compile *p, 216303b705cfSriastradh struct brw_reg dest, 216403b705cfSriastradh unsigned function, 216503b705cfSriastradh struct brw_reg src0, 216603b705cfSriastradh struct brw_reg src1); 216703b705cfSriastradh 216803b705cfSriastradhvoid brw_oword_block_read(struct brw_compile *p, 216903b705cfSriastradh struct brw_reg dest, 217003b705cfSriastradh struct brw_reg mrf, 217103b705cfSriastradh uint32_t offset, 217203b705cfSriastradh uint32_t bind_table_index); 217303b705cfSriastradh 217403b705cfSriastradhvoid brw_oword_block_read_scratch(struct brw_compile *p, 217503b705cfSriastradh struct brw_reg dest, 217603b705cfSriastradh struct brw_reg mrf, 217703b705cfSriastradh int num_regs, 217803b705cfSriastradh unsigned offset); 217903b705cfSriastradh 218003b705cfSriastradhvoid brw_oword_block_write_scratch(struct brw_compile *p, 218103b705cfSriastradh struct brw_reg mrf, 218203b705cfSriastradh int num_regs, 218303b705cfSriastradh unsigned offset); 218403b705cfSriastradh 218503b705cfSriastradhvoid brw_dword_scattered_read(struct brw_compile *p, 218603b705cfSriastradh struct brw_reg dest, 218703b705cfSriastradh struct brw_reg mrf, 218803b705cfSriastradh uint32_t bind_table_index); 218903b705cfSriastradh 219003b705cfSriastradhvoid brw_dp_READ_4_vs(struct brw_compile *p, 219103b705cfSriastradh struct brw_reg dest, 219203b705cfSriastradh unsigned location, 219303b705cfSriastradh unsigned bind_table_index); 219403b705cfSriastradh 219503b705cfSriastradhvoid brw_dp_READ_4_vs_relative(struct brw_compile *p, 219603b705cfSriastradh struct brw_reg dest, 219703b705cfSriastradh struct brw_reg addrReg, 219803b705cfSriastradh unsigned offset, 219903b705cfSriastradh unsigned bind_table_index); 220003b705cfSriastradh 220103b705cfSriastradh/* If/else/endif. Works by manipulating the execution flags on each 220203b705cfSriastradh * channel. 220303b705cfSriastradh */ 220403b705cfSriastradhstruct brw_instruction *brw_IF(struct brw_compile *p, 220503b705cfSriastradh unsigned execute_size); 220603b705cfSriastradhstruct brw_instruction *gen6_IF(struct brw_compile *p, uint32_t conditional, 220703b705cfSriastradh struct brw_reg src0, struct brw_reg src1); 220803b705cfSriastradh 220903b705cfSriastradhvoid brw_ELSE(struct brw_compile *p); 221003b705cfSriastradhvoid brw_ENDIF(struct brw_compile *p); 221103b705cfSriastradh 221203b705cfSriastradh/* DO/WHILE loops: 221303b705cfSriastradh*/ 221403b705cfSriastradhstruct brw_instruction *brw_DO(struct brw_compile *p, 221503b705cfSriastradh unsigned execute_size); 221603b705cfSriastradh 221703b705cfSriastradhstruct brw_instruction *brw_WHILE(struct brw_compile *p, 221803b705cfSriastradh struct brw_instruction *patch_insn); 221903b705cfSriastradh 222003b705cfSriastradhstruct brw_instruction *brw_BREAK(struct brw_compile *p, int pop_count); 222103b705cfSriastradhstruct brw_instruction *brw_CONT(struct brw_compile *p, int pop_count); 222203b705cfSriastradhstruct brw_instruction *gen6_CONT(struct brw_compile *p, 222303b705cfSriastradh struct brw_instruction *do_insn); 222403b705cfSriastradh/* Forward jumps: 222503b705cfSriastradh*/ 222603b705cfSriastradhvoid brw_land_fwd_jump(struct brw_compile *p, 222703b705cfSriastradh struct brw_instruction *jmp_insn); 222803b705cfSriastradh 222903b705cfSriastradhvoid brw_NOP(struct brw_compile *p); 223003b705cfSriastradh 223103b705cfSriastradhvoid brw_WAIT(struct brw_compile *p); 223203b705cfSriastradh 223303b705cfSriastradh/* Special case: there is never a destination, execution size will be 223403b705cfSriastradh * taken from src0: 223503b705cfSriastradh */ 223603b705cfSriastradhvoid brw_CMP(struct brw_compile *p, 223703b705cfSriastradh struct brw_reg dest, 223803b705cfSriastradh unsigned conditional, 223903b705cfSriastradh struct brw_reg src0, 224003b705cfSriastradh struct brw_reg src1); 224103b705cfSriastradh 224203b705cfSriastradhstatic inline void brw_math_invert(struct brw_compile *p, 224303b705cfSriastradh struct brw_reg dst, 224403b705cfSriastradh struct brw_reg src) 224503b705cfSriastradh{ 224603b705cfSriastradh brw_math(p, 224703b705cfSriastradh dst, 224803b705cfSriastradh BRW_MATH_FUNCTION_INV, 224903b705cfSriastradh BRW_MATH_SATURATE_NONE, 225003b705cfSriastradh 0, 225103b705cfSriastradh src, 225203b705cfSriastradh BRW_MATH_PRECISION_FULL, 225303b705cfSriastradh BRW_MATH_DATA_VECTOR); 225403b705cfSriastradh} 225503b705cfSriastradh 225603b705cfSriastradhvoid brw_set_uip_jip(struct brw_compile *p); 225703b705cfSriastradh 225803b705cfSriastradhuint32_t brw_swap_cmod(uint32_t cmod); 225903b705cfSriastradh 226003b705cfSriastradhvoid brw_disasm(FILE *file, 226103b705cfSriastradh const struct brw_instruction *inst, 226203b705cfSriastradh int gen); 226303b705cfSriastradh 226403b705cfSriastradh#endif 2265