19f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/*
29f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt Copyright (C) Intel Corp.  2006.  All Rights Reserved.
39f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
49f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt develop this 3D driver.
59f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
69f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt Permission is hereby granted, free of charge, to any person obtaining
79f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt a copy of this software and associated documentation files (the
89f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt "Software"), to deal in the Software without restriction, including
99f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt without limitation the rights to use, copy, modify, merge, publish,
109f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt distribute, sublicense, and/or sell copies of the Software, and to
119f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt permit persons to whom the Software is furnished to do so, subject to
129f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt the following conditions:
139f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
149f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt The above copyright notice and this permission notice (including the
159f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt next paragraph) shall be included in all copies or substantial
169f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt portions of the Software.
179f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
189f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
199f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
209f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
219f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
229f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
239f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
249f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
259f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
269f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt **********************************************************************/
279f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt /*
289f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt  * Authors:
299f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt  *   Keith Whitwell <keith@tungstengraphics.com>
309f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt  */
319f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
329f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
339f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#ifndef BRW_EU_H
349f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define BRW_EU_H
359f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
36245662f3083795e272fe9ef5d4cbeb6d048cf0e5Eric Anholt#include <stdbool.h>
379f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#include "brw_structs.h"
389f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#include "brw_defines.h"
39ec2b92f98c2e7f161521b447cc1d9a36bce3707cBrian Paul#include "program/prog_instruction.h"
409f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
41434fc8bde41f07687ad8941ceba03c4b3e0e75bbPaul Berry#ifdef __cplusplus
42434fc8bde41f07687ad8941ceba03c4b3e0e75bbPaul Berryextern "C" {
43434fc8bde41f07687ad8941ceba03c4b3e0e75bbPaul Berry#endif
44434fc8bde41f07687ad8941ceba03c4b3e0e75bbPaul Berry
459f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define BRW_SWIZZLE4(a,b,c,d) (((a)<<0) | ((b)<<2) | ((c)<<4) | ((d)<<6))
469f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define BRW_GET_SWZ(swz, idx) (((swz) >> ((idx)*2)) & 0x3)
479f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
489f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define BRW_SWIZZLE_NOOP      BRW_SWIZZLE4(0,1,2,3)
499f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define BRW_SWIZZLE_XYZW      BRW_SWIZZLE4(0,1,2,3)
509f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define BRW_SWIZZLE_XXXX      BRW_SWIZZLE4(0,0,0,0)
51af3c9803d818fd33139f1247a387d64b967b8992Eric Anholt#define BRW_SWIZZLE_YYYY      BRW_SWIZZLE4(1,1,1,1)
52af3c9803d818fd33139f1247a387d64b967b8992Eric Anholt#define BRW_SWIZZLE_ZZZZ      BRW_SWIZZLE4(2,2,2,2)
53af3c9803d818fd33139f1247a387d64b967b8992Eric Anholt#define BRW_SWIZZLE_WWWW      BRW_SWIZZLE4(3,3,3,3)
549f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define BRW_SWIZZLE_XYXY      BRW_SWIZZLE4(0,1,0,1)
559f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
562b28fd6ca603df40a5d02aac4035eced3a1d079aEric Anholtstatic inline bool brw_is_single_value_swizzle(int swiz)
572b28fd6ca603df40a5d02aac4035eced3a1d079aEric Anholt{
582b28fd6ca603df40a5d02aac4035eced3a1d079aEric Anholt   return (swiz == BRW_SWIZZLE_XXXX ||
592b28fd6ca603df40a5d02aac4035eced3a1d079aEric Anholt	   swiz == BRW_SWIZZLE_YYYY ||
602b28fd6ca603df40a5d02aac4035eced3a1d079aEric Anholt	   swiz == BRW_SWIZZLE_ZZZZ ||
612b28fd6ca603df40a5d02aac4035eced3a1d079aEric Anholt	   swiz == BRW_SWIZZLE_WWWW);
622b28fd6ca603df40a5d02aac4035eced3a1d079aEric Anholt}
639f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
649f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define REG_SIZE (8*4)
659f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
669f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
679f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/* These aren't hardware structs, just something useful for us to pass around:
689f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt *
699f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * Align1 operation has a lot of control over input ranges.  Used in
709f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * WM programs to implement shaders decomposed into "channel serial"
719f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * or "structure of array" form:
729f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */
739f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtstruct brw_reg
749f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
759f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLuint type:4;
769f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLuint file:2;
779f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLuint nr:8;
789f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLuint subnr:5;		/* :1 in align16 */
799f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLuint negate:1;		/* source only */
809f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLuint abs:1;		/* source only */
819f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLuint vstride:4;		/* source only */
829f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLuint width:3;		/* src only, align1 only */
8358dc8b7db5829188dbb45c020ab44732d6053888Gary Wong   GLuint hstride:2;   		/* align1 only */
849f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLuint address_mode:1;	/* relative addressing, hopefully! */
859f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLuint pad0:1;
869f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
879f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   union {
889f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      struct {
899f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	 GLuint swizzle:8;		/* src only, align16 only */
909f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	 GLuint writemask:4;		/* dest only, align16 only */
919f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	 GLint  indirect_offset:10;	/* relative addressing offset */
929f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	 GLuint pad1:10;		/* two dwords total */
939f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      } bits;
949f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
959f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      GLfloat f;
969f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      GLint   d;
979f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      GLuint ud;
989f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   } dw1;
999f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt};
1009f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
1019f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
1029f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtstruct brw_indirect {
1039f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLuint addr_subnr:4;
1049f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLint addr_offset:10;
1059f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLuint pad:18;
1069f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt};
1079f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
1089f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
1099f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define BRW_EU_MAX_INSN_STACK 5
1109f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
1119f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtstruct brw_compile {
1123aa3c3f75894ca0eb08087c0ec3dd114eeae4bb7Yuanhan Liu   struct brw_instruction *store;
1133aa3c3f75894ca0eb08087c0ec3dd114eeae4bb7Yuanhan Liu   int store_size;
1149f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLuint nr_insn;
1159f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
116774fb90db3e83d5e7326b7a72e05ce805c306b24Kenneth Graunke   void *mem_ctx;
117774fb90db3e83d5e7326b7a72e05ce805c306b24Kenneth Graunke
1189f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   /* Allow clients to push/pop instruction state:
1199f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt    */
1209f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct brw_instruction stack[BRW_EU_MAX_INSN_STACK];
121245662f3083795e272fe9ef5d4cbeb6d048cf0e5Eric Anholt   bool compressed_stack[BRW_EU_MAX_INSN_STACK];
1229f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct brw_instruction *current;
1239f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
1249f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLuint flag_value;
1252e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke   bool single_program_flow;
126245662f3083795e272fe9ef5d4cbeb6d048cf0e5Eric Anholt   bool compressed;
1278e444fb9e2685e3eac42beb848b08e91dc20c88aXiang, Haihao   struct brw_context *brw;
128c51c822ee02cb47ddba46da668577d51b7c02831Brian Paul
1295936d96d33e767aa99f6afa92f2a6582ff04df23Kenneth Graunke   /* Control flow stacks:
1305936d96d33e767aa99f6afa92f2a6582ff04df23Kenneth Graunke    * - if_stack contains IF and ELSE instructions which must be patched
1315936d96d33e767aa99f6afa92f2a6582ff04df23Kenneth Graunke    *   (and popped) once the matching ENDIF instruction is encountered.
1320a17093eaf84696b05d04a45d6d51281f7b2786bYuanhan Liu    *
1330a17093eaf84696b05d04a45d6d51281f7b2786bYuanhan Liu    *   Just store the instruction pointer(an index).
1345936d96d33e767aa99f6afa92f2a6582ff04df23Kenneth Graunke    */
1350a17093eaf84696b05d04a45d6d51281f7b2786bYuanhan Liu   int *if_stack;
1365936d96d33e767aa99f6afa92f2a6582ff04df23Kenneth Graunke   int if_stack_depth;
1375936d96d33e767aa99f6afa92f2a6582ff04df23Kenneth Graunke   int if_stack_array_size;
1385936d96d33e767aa99f6afa92f2a6582ff04df23Kenneth Graunke
13932118cfe37495738ed5931c6b1a71b8ee2ad189cEric Anholt   /**
14032118cfe37495738ed5931c6b1a71b8ee2ad189cEric Anholt    * loop_stack contains the instruction pointers of the starts of loops which
14132118cfe37495738ed5931c6b1a71b8ee2ad189cEric Anholt    * must be patched (and popped) once the matching WHILE instruction is
14232118cfe37495738ed5931c6b1a71b8ee2ad189cEric Anholt    * encountered.
14332118cfe37495738ed5931c6b1a71b8ee2ad189cEric Anholt    */
14432118cfe37495738ed5931c6b1a71b8ee2ad189cEric Anholt   int *loop_stack;
145f1d89638c02afafbf82ef657cd6ba9965dad6738Eric Anholt   /**
146f1d89638c02afafbf82ef657cd6ba9965dad6738Eric Anholt    * pre-gen6, the BREAK and CONT instructions had to tell how many IF/ENDIF
147f1d89638c02afafbf82ef657cd6ba9965dad6738Eric Anholt    * blocks they were popping out of, to fix up the mask stack.  This tracks
148f1d89638c02afafbf82ef657cd6ba9965dad6738Eric Anholt    * the IF/ENDIF nesting in each current nested loop level.
149f1d89638c02afafbf82ef657cd6ba9965dad6738Eric Anholt    */
150f1d89638c02afafbf82ef657cd6ba9965dad6738Eric Anholt   int *if_depth_in_loop;
15132118cfe37495738ed5931c6b1a71b8ee2ad189cEric Anholt   int loop_stack_depth;
15232118cfe37495738ed5931c6b1a71b8ee2ad189cEric Anholt   int loop_stack_array_size;
1539f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt};
1549f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
155cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE int type_sz( GLuint type )
1569f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
1579f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   switch( type ) {
1589f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case BRW_REGISTER_TYPE_UD:
1599f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case BRW_REGISTER_TYPE_D:
1609f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case BRW_REGISTER_TYPE_F:
1619f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return 4;
1629f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case BRW_REGISTER_TYPE_HF:
1639f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case BRW_REGISTER_TYPE_UW:
1649f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case BRW_REGISTER_TYPE_W:
1659f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return 2;
1669f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case BRW_REGISTER_TYPE_UB:
1679f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case BRW_REGISTER_TYPE_B:
1689f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return 1;
1699f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   default:
1709f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt      return 0;
1719f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   }
1729f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
1739f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
1743b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/**
1753b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul * Construct a brw_reg.
1763b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul * \param file  one of the BRW_x_REGISTER_FILE values
1773b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul * \param nr  register number/index
1783b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul * \param subnr  register sub number
1793b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul * \param type  one of BRW_REGISTER_TYPE_x
1803b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul * \param vstride  one of BRW_VERTICAL_STRIDE_x
1813b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul * \param width  one of BRW_WIDTH_x
1823b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul * \param hstride  one of BRW_HORIZONTAL_STRIDE_x
1833b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul * \param swizzle  one of BRW_SWIZZLE_x
1843b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul * \param writemask  WRITEMASK_X/Y/Z/W bitfield
1853b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul */
186cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_reg( GLuint file,
1873b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul                                      GLuint nr,
1883b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul                                      GLuint subnr,
1893b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul                                      GLuint type,
1903b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul                                      GLuint vstride,
1913b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul                                      GLuint width,
1923b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul                                      GLuint hstride,
1933b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul                                      GLuint swizzle,
1943b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul                                      GLuint writemask )
1953b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul{
1969f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct brw_reg reg;
1978baee3d25beb616f6d5ba575684e889d60e38740Eric Anholt   if (file == BRW_GENERAL_REGISTER_FILE)
19876a5a5dace715aa629ee98a37acb3075a7de153cBrian Paul      assert(nr < BRW_MAX_GRF);
1998baee3d25beb616f6d5ba575684e889d60e38740Eric Anholt   else if (file == BRW_MESSAGE_REGISTER_FILE)
2008baee3d25beb616f6d5ba575684e889d60e38740Eric Anholt      assert((nr & ~(1 << 7)) < BRW_MAX_MRF);
2018baee3d25beb616f6d5ba575684e889d60e38740Eric Anholt   else if (file == BRW_ARCHITECTURE_REGISTER_FILE)
2027d6478cfccf03c87f2b9daa541ae486dc24bb388Brian Paul      assert(nr <= BRW_ARF_IP);
2037d6478cfccf03c87f2b9daa541ae486dc24bb388Brian Paul
2049f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.type = type;
2059f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.file = file;
2069f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.nr = nr;
2079f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.subnr = subnr * type_sz(type);
2089f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.negate = 0;
2099f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.abs = 0;
2109f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.vstride = vstride;
2119f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.width = width;
2129f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.hstride = hstride;
2139f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.address_mode = BRW_ADDRESS_DIRECT;
2149f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.pad0 = 0;
2159f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
2169f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   /* Could do better: If the reg is r5.3<0;1,0>, we probably want to
2179f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt    * set swizzle and writemask to W, as the lower bits of subnr will
2189f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt    * be lost when converted to align16.  This is probably too much to
2199f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt    * keep track of as you'd want it adjusted by suboffset(), etc.
2209f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt    * Perhaps fix up when converting to align16?
2219f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt    */
2229f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.dw1.bits.swizzle = swizzle;
2239f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.dw1.bits.writemask = writemask;
2249f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.dw1.bits.indirect_offset = 0;
2259f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.dw1.bits.pad1 = 0;
2269f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return reg;
2279f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
2289f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
2293b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct float[16] register */
230cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_vec16_reg( GLuint file,
2319f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					      GLuint nr,
2329f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					      GLuint subnr )
2339f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
2349f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_reg(file,
2359f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  nr,
2369f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  subnr,
2379f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_REGISTER_TYPE_F,
2389f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_VERTICAL_STRIDE_16,
2399f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_WIDTH_16,
2409f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_HORIZONTAL_STRIDE_1,
2419f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_SWIZZLE_XYZW,
2429f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  WRITEMASK_XYZW);
2439f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
2449f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
2453b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct float[8] register */
246cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_vec8_reg( GLuint file,
2479f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					     GLuint nr,
2489f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					     GLuint subnr )
2499f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
2509f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_reg(file,
2519f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  nr,
2529f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  subnr,
2539f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_REGISTER_TYPE_F,
2549f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_VERTICAL_STRIDE_8,
2559f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_WIDTH_8,
2569f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_HORIZONTAL_STRIDE_1,
2579f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_SWIZZLE_XYZW,
2589f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  WRITEMASK_XYZW);
2599f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
2609f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
2613b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct float[4] register */
262cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_vec4_reg( GLuint file,
2639f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					      GLuint nr,
2649f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					      GLuint subnr )
2659f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
2669f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_reg(file,
2679f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  nr,
2689f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  subnr,
2699f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_REGISTER_TYPE_F,
2709f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_VERTICAL_STRIDE_4,
2719f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_WIDTH_4,
2729f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_HORIZONTAL_STRIDE_1,
2739f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_SWIZZLE_XYZW,
2749f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  WRITEMASK_XYZW);
2759f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
2769f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
2773b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct float[2] register */
278cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_vec2_reg( GLuint file,
2799f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					      GLuint nr,
2809f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					      GLuint subnr )
2819f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
2829f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_reg(file,
2839f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  nr,
2849f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  subnr,
2859f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_REGISTER_TYPE_F,
2869f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_VERTICAL_STRIDE_2,
2879f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_WIDTH_2,
2889f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_HORIZONTAL_STRIDE_1,
2899f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_SWIZZLE_XYXY,
2909f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  WRITEMASK_XY);
2919f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
2929f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
2933b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct float[1] register */
294cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_vec1_reg( GLuint file,
2959f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					     GLuint nr,
2969f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					     GLuint subnr )
2979f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
2989f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_reg(file,
2999f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  nr,
3009f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  subnr,
3019f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_REGISTER_TYPE_F,
3029f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_VERTICAL_STRIDE_0,
3039f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_WIDTH_1,
3049f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_HORIZONTAL_STRIDE_0,
3059f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_SWIZZLE_XXXX,
3069f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  WRITEMASK_X);
3079f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
3089f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
3099f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
310cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg retype( struct brw_reg reg,
3119f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt				       GLuint type )
3129f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
3139f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.type = type;
3149f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return reg;
3159f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
3169f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
317148a32e622c5b95a4dbd9a8776fddf85ef484147Eric Anholtstatic inline struct brw_reg
318148a32e622c5b95a4dbd9a8776fddf85ef484147Eric Anholtsechalf(struct brw_reg reg)
319148a32e622c5b95a4dbd9a8776fddf85ef484147Eric Anholt{
320148a32e622c5b95a4dbd9a8776fddf85ef484147Eric Anholt   if (reg.vstride)
321148a32e622c5b95a4dbd9a8776fddf85ef484147Eric Anholt      reg.nr++;
322148a32e622c5b95a4dbd9a8776fddf85ef484147Eric Anholt   return reg;
323148a32e622c5b95a4dbd9a8776fddf85ef484147Eric Anholt}
324148a32e622c5b95a4dbd9a8776fddf85ef484147Eric Anholt
325cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg suboffset( struct brw_reg reg,
3269f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					  GLuint delta )
3279f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
3289f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.subnr += delta * type_sz(reg.type);
3299f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return reg;
3309f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
3319f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
3329f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
333cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg offset( struct brw_reg reg,
3349f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt				       GLuint delta )
3359f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
3369f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.nr += delta;
3379f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return reg;
3389f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
3399f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
3409f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
341cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg byte_offset( struct brw_reg reg,
3429f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					    GLuint bytes )
3439f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
3449f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   GLuint newoffset = reg.nr * REG_SIZE + reg.subnr + bytes;
3459f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.nr = newoffset / REG_SIZE;
3469f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.subnr = newoffset % REG_SIZE;
3479f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return reg;
3489f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
3499f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
3509f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
3513b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct unsigned word[16] register */
352cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_uw16_reg( GLuint file,
3539f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					     GLuint nr,
3549f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					     GLuint subnr )
3559f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
3569f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return suboffset(retype(brw_vec16_reg(file, nr, 0), BRW_REGISTER_TYPE_UW), subnr);
3579f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
3589f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
3593b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct unsigned word[8] register */
360cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_uw8_reg( GLuint file,
3619f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					    GLuint nr,
3629f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					    GLuint subnr )
3639f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
3649f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return suboffset(retype(brw_vec8_reg(file, nr, 0), BRW_REGISTER_TYPE_UW), subnr);
3659f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
3669f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
3673b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct unsigned word[1] register */
368cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_uw1_reg( GLuint file,
3699f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					    GLuint nr,
3709f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					    GLuint subnr )
3719f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
3729f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return suboffset(retype(brw_vec1_reg(file, nr, 0), BRW_REGISTER_TYPE_UW), subnr);
3739f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
3749f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
375cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_imm_reg( GLuint type )
3769f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
3779f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_reg( BRW_IMMEDIATE_VALUE,
3789f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   0,
3799f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   0,
3809f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   type,
3819f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   BRW_VERTICAL_STRIDE_0,
3829f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   BRW_WIDTH_1,
3839f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   BRW_HORIZONTAL_STRIDE_0,
3849f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   0,
3859f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   0);
3869f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
3879f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
3883b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct float immediate register */
389cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_imm_f( GLfloat f )
3909f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
3919f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_F);
3929f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   imm.dw1.f = f;
3939f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return imm;
3949f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
3959f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
3963b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct integer immediate register */
397cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_imm_d( GLint d )
3989f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
3999f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_D);
4009f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   imm.dw1.d = d;
4019f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return imm;
4029f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
4039f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
4043b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct uint immediate register */
405cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_imm_ud( GLuint ud )
4069f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
4079f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_UD);
4089f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   imm.dw1.ud = ud;
4099f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return imm;
4109f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
4119f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
4123b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct ushort immediate register */
413cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_imm_uw( GLushort uw )
4149f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
4159f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_UW);
416ca73488f48e3ee278f0185bb7dcc03d7bdedb62dKeith Packard   imm.dw1.ud = uw | (uw << 16);
4179f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return imm;
4189f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
4199f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
4203b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct short immediate register */
421cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_imm_w( GLshort w )
4229f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
4239f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_W);
424ca73488f48e3ee278f0185bb7dcc03d7bdedb62dKeith Packard   imm.dw1.d = w | (w << 16);
4259f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return imm;
4269f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
4279f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
4289f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/* brw_imm_b and brw_imm_ub aren't supported by hardware - the type
4299f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * numbers alias with _V and _VF below:
4309f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */
4319f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
4323b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct vector of eight signed half-byte values */
433cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_imm_v( GLuint v )
4349f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
4359f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_V);
4369f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   imm.vstride = BRW_VERTICAL_STRIDE_0;
4379f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   imm.width = BRW_WIDTH_8;
4389f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   imm.hstride = BRW_HORIZONTAL_STRIDE_1;
4399f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   imm.dw1.ud = v;
4409f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return imm;
4419f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
4429f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
4433b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct vector of four 8-bit float values */
444cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_imm_vf( GLuint v )
4459f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
4469f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_VF);
4479f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   imm.vstride = BRW_VERTICAL_STRIDE_0;
4489f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   imm.width = BRW_WIDTH_4;
4499f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   imm.hstride = BRW_HORIZONTAL_STRIDE_1;
4509f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   imm.dw1.ud = v;
4519f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return imm;
4529f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
4539f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
4549f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define VF_ZERO 0x0
4559f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define VF_ONE  0x30
4569f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define VF_NEG  (1<<7)
4579f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
458cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_imm_vf4( GLuint v0,
4599f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					    GLuint v1,
4609f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					    GLuint v2,
4619f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					    GLuint v3)
4629f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
4639f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct brw_reg imm = brw_imm_reg(BRW_REGISTER_TYPE_VF);
4649f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   imm.vstride = BRW_VERTICAL_STRIDE_0;
4659f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   imm.width = BRW_WIDTH_4;
4669f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   imm.hstride = BRW_HORIZONTAL_STRIDE_1;
4679f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   imm.dw1.ud = ((v0 << 0) |
4689f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		 (v1 << 8) |
4699f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		 (v2 << 16) |
4709f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		 (v3 << 24));
4719f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return imm;
4729f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
4739f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
4749f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
475cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_address( struct brw_reg reg )
4769f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
4779f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_imm_uw(reg.nr * REG_SIZE + reg.subnr);
4789f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
4799f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
4803b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct float[1] general-purpose register */
4813b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paulstatic INLINE struct brw_reg brw_vec1_grf( GLuint nr, GLuint subnr )
4829f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
4839f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_vec1_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
4849f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
4859f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
4863b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct float[2] general-purpose register */
4873b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paulstatic INLINE struct brw_reg brw_vec2_grf( GLuint nr, GLuint subnr )
4889f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
4893b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul   return brw_vec2_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
4909f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
4919f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
4923b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct float[4] general-purpose register */
4933b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paulstatic INLINE struct brw_reg brw_vec4_grf( GLuint nr, GLuint subnr )
4949f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
4959f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_vec4_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
4969f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
4979f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
4983b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct float[8] general-purpose register */
4993b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paulstatic INLINE struct brw_reg brw_vec8_grf( GLuint nr, GLuint subnr )
5009f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
5013b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul   return brw_vec8_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
5029f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
5039f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
5043b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul
5053b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paulstatic INLINE struct brw_reg brw_uw8_grf( GLuint nr, GLuint subnr )
5069f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
5079f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_uw8_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
5089f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
5099f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
5103b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paulstatic INLINE struct brw_reg brw_uw16_grf( GLuint nr, GLuint subnr )
5110060d4154999777bd3b17013c457ca073aa660dcGary Wong{
5120060d4154999777bd3b17013c457ca073aa660dcGary Wong   return brw_uw16_reg(BRW_GENERAL_REGISTER_FILE, nr, subnr);
5130060d4154999777bd3b17013c457ca073aa660dcGary Wong}
5140060d4154999777bd3b17013c457ca073aa660dcGary Wong
5153b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul
5163b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul/** Construct null register (usually used for setting condition codes) */
517cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_null_reg( void )
5189f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
5199f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_vec8_reg(BRW_ARCHITECTURE_REGISTER_FILE,
5209f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		       BRW_ARF_NULL,
5219f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		       0);
5229f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
5239f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
524cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_address_reg( GLuint subnr )
5259f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
5269f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE,
5279f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		      BRW_ARF_ADDRESS,
5289f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		      subnr);
5299f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
5309f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
5319f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/* If/else instructions break in align16 mode if writemask & swizzle
5329f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * aren't xyzw.  This goes against the convention for other scalar
5339f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * regs:
5349f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */
535cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_ip_reg( void )
5369f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
5379f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_reg(BRW_ARCHITECTURE_REGISTER_FILE,
5389f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_ARF_IP,
5399f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  0,
5409f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_REGISTER_TYPE_UD,
5419f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_VERTICAL_STRIDE_4, /* ? */
5429f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_WIDTH_1,
5439f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_HORIZONTAL_STRIDE_0,
5449f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  BRW_SWIZZLE_XYZW, /* NOTE! */
5459f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  WRITEMASK_XYZW); /* NOTE! */
5469f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
5479f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
548cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_acc_reg( void )
5499f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
5509f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_vec8_reg(BRW_ARCHITECTURE_REGISTER_FILE,
5519f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		       BRW_ARF_ACCUMULATOR,
5529f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		       0);
5539f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
5549f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
55520be3ff57670529a410b30a1008a71e768d08428Zhenyu Wangstatic INLINE struct brw_reg brw_notification_1_reg(void)
55620be3ff57670529a410b30a1008a71e768d08428Zhenyu Wang{
55720be3ff57670529a410b30a1008a71e768d08428Zhenyu Wang
55820be3ff57670529a410b30a1008a71e768d08428Zhenyu Wang   return brw_reg(BRW_ARCHITECTURE_REGISTER_FILE,
55920be3ff57670529a410b30a1008a71e768d08428Zhenyu Wang		  BRW_ARF_NOTIFICATION_COUNT,
56020be3ff57670529a410b30a1008a71e768d08428Zhenyu Wang		  1,
56120be3ff57670529a410b30a1008a71e768d08428Zhenyu Wang		  BRW_REGISTER_TYPE_UD,
56220be3ff57670529a410b30a1008a71e768d08428Zhenyu Wang		  BRW_VERTICAL_STRIDE_0,
56320be3ff57670529a410b30a1008a71e768d08428Zhenyu Wang		  BRW_WIDTH_1,
56420be3ff57670529a410b30a1008a71e768d08428Zhenyu Wang		  BRW_HORIZONTAL_STRIDE_0,
56520be3ff57670529a410b30a1008a71e768d08428Zhenyu Wang		  BRW_SWIZZLE_XXXX,
56620be3ff57670529a410b30a1008a71e768d08428Zhenyu Wang		  WRITEMASK_X);
56720be3ff57670529a410b30a1008a71e768d08428Zhenyu Wang}
56820be3ff57670529a410b30a1008a71e768d08428Zhenyu Wang
5699f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
570cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_flag_reg( void )
5719f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
5729f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE,
5739f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		      BRW_ARF_FLAG,
5749f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		      0);
5759f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
5769f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
5779f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
578cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_mask_reg( GLuint subnr )
5799f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
5809f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_uw1_reg(BRW_ARCHITECTURE_REGISTER_FILE,
5819f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		      BRW_ARF_MASK,
5829f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		      subnr);
5839f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
5849f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
585cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_message_reg( GLuint nr )
5869f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
5878baee3d25beb616f6d5ba575684e889d60e38740Eric Anholt   assert((nr & ~(1 << 7)) < BRW_MAX_MRF);
5889f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_vec8_reg(BRW_MESSAGE_REGISTER_FILE,
5899f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		       nr,
5909f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		       0);
5919f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
5929f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
5939f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
5949f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
5959f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
5969f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/* This is almost always called with a numeric constant argument, so
5979f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * make things easy to evaluate at compile time:
5989f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */
599cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE GLuint cvt( GLuint val )
6009f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
6019f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   switch (val) {
6029f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case 0: return 0;
6039f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case 1: return 1;
6049f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case 2: return 2;
6059f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case 4: return 3;
6069f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case 8: return 4;
6079f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case 16: return 5;
6089f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   case 32: return 6;
6099f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   }
6109f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return 0;
6119f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
6129f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
613cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg stride( struct brw_reg reg,
6149f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt				       GLuint vstride,
6159f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt				       GLuint width,
6169f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt				       GLuint hstride )
6179f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
6189f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.vstride = cvt(vstride);
6199f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.width = cvt(width) - 1;
6209f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.hstride = cvt(hstride);
6219f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return reg;
6229f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
6239f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
6243b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul
625cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg vec16( struct brw_reg reg )
6269f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
6279f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return stride(reg, 16,16,1);
6289f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
6299f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
630cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg vec8( struct brw_reg reg )
6319f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
6329f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return stride(reg, 8,8,1);
6339f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
6349f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
635cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg vec4( struct brw_reg reg )
6369f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
6379f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return stride(reg, 4,4,1);
6389f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
6399f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
640cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg vec2( struct brw_reg reg )
6419f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
6429f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return stride(reg, 2,2,1);
6439f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
6449f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
645cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg vec1( struct brw_reg reg )
6469f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
6479f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return stride(reg, 0,1,0);
6489f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
6499f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
6503b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul
651cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg get_element( struct brw_reg reg, GLuint elt )
6529f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
6539f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return vec1(suboffset(reg, elt));
6549f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
6559f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
656cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg get_element_ud( struct brw_reg reg, GLuint elt )
6579f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
6589f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return vec1(suboffset(retype(reg, BRW_REGISTER_TYPE_UD), elt));
6599f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
6609f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
661d4976158c7f32705b48c773c3abd1b22bebe9c16Paul Berrystatic INLINE struct brw_reg get_element_d( struct brw_reg reg, GLuint elt )
662d4976158c7f32705b48c773c3abd1b22bebe9c16Paul Berry{
663d4976158c7f32705b48c773c3abd1b22bebe9c16Paul Berry   return vec1(suboffset(retype(reg, BRW_REGISTER_TYPE_D), elt));
664d4976158c7f32705b48c773c3abd1b22bebe9c16Paul Berry}
665d4976158c7f32705b48c773c3abd1b22bebe9c16Paul Berry
6669f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
667cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_swizzle( struct brw_reg reg,
6689f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					    GLuint x,
6699f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					    GLuint y,
6709f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					    GLuint z,
6719f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					    GLuint w)
6729f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
673bad29dc6dad7ed1bff46c67e61dab01f8d82b557Eric Anholt   assert(reg.file != BRW_IMMEDIATE_VALUE);
674bad29dc6dad7ed1bff46c67e61dab01f8d82b557Eric Anholt
6759f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.dw1.bits.swizzle = BRW_SWIZZLE4(BRW_GET_SWZ(reg.dw1.bits.swizzle, x),
6769f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt				       BRW_GET_SWZ(reg.dw1.bits.swizzle, y),
6779f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt				       BRW_GET_SWZ(reg.dw1.bits.swizzle, z),
6789f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt				       BRW_GET_SWZ(reg.dw1.bits.swizzle, w));
6799f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return reg;
6809f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
6819f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
6829f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
683cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_swizzle1( struct brw_reg reg,
6849f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					     GLuint x )
6859f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
6869f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_swizzle(reg, x, x, x, x);
6879f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
6889f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
689cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_writemask( struct brw_reg reg,
6909f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt					      GLuint mask )
6919f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
692bad29dc6dad7ed1bff46c67e61dab01f8d82b557Eric Anholt   assert(reg.file != BRW_IMMEDIATE_VALUE);
6939f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.dw1.bits.writemask &= mask;
6949f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return reg;
6959f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
6969f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
697cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_set_writemask( struct brw_reg reg,
6989f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt						  GLuint mask )
6999f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
700bad29dc6dad7ed1bff46c67e61dab01f8d82b557Eric Anholt   assert(reg.file != BRW_IMMEDIATE_VALUE);
7019f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.dw1.bits.writemask = mask;
7029f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return reg;
7039f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
7049f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
705cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg negate( struct brw_reg reg )
7069f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
7079f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.negate ^= 1;
7089f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return reg;
7099f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
7109f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
711cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_abs( struct brw_reg reg )
7129f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
7139f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.abs = 1;
714d06cc42c3c85382600176d118d8bf492b4de6a55Paul Berry   reg.negate = 0;
7159f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return reg;
7169f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
7179f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
7189f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/***********************************************************************
7199f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */
720cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_vec4_indirect( GLuint subnr,
7219f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt						  GLint offset )
7229f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
7239f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct brw_reg reg =  brw_vec4_grf(0, 0);
7249f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.subnr = subnr;
7259f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER;
7269f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.dw1.bits.indirect_offset = offset;
7279f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return reg;
7289f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
7299f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
730cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg brw_vec1_indirect( GLuint subnr,
7319f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt						  GLint offset )
7329f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
7339f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct brw_reg reg =  brw_vec1_grf(0, 0);
7349f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.subnr = subnr;
7359f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.address_mode = BRW_ADDRESS_REGISTER_INDIRECT_REGISTER;
7369f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   reg.dw1.bits.indirect_offset = offset;
7379f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return reg;
7389f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
7399f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
740cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg deref_4f(struct brw_indirect ptr, GLint offset)
7419f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
7429f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_vec4_indirect(ptr.addr_subnr, ptr.addr_offset + offset);
7439f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
7449f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
745cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg deref_1f(struct brw_indirect ptr, GLint offset)
7469f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
7479f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_vec1_indirect(ptr.addr_subnr, ptr.addr_offset + offset);
7489f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
7499f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
750cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg deref_4b(struct brw_indirect ptr, GLint offset)
7519f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
7529f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return retype(deref_4f(ptr, offset), BRW_REGISTER_TYPE_B);
7539f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
7549f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
755cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg deref_1uw(struct brw_indirect ptr, GLint offset)
7569f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
7579f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return retype(deref_1f(ptr, offset), BRW_REGISTER_TYPE_UW);
7589f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
7599f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
760cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg deref_1d(struct brw_indirect ptr, GLint offset)
761d0ebdca4fa70506107a318e6cfd03f0fb4297897Zou Nan hai{
762d0ebdca4fa70506107a318e6cfd03f0fb4297897Zou Nan hai   return retype(deref_1f(ptr, offset), BRW_REGISTER_TYPE_D);
763d0ebdca4fa70506107a318e6cfd03f0fb4297897Zou Nan hai}
764d0ebdca4fa70506107a318e6cfd03f0fb4297897Zou Nan hai
765cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg deref_1ud(struct brw_indirect ptr, GLint offset)
7663d6c4109902b555a3f8076170d572c7caeb6cbfeZou Nan hai{
7673d6c4109902b555a3f8076170d572c7caeb6cbfeZou Nan hai   return retype(deref_1f(ptr, offset), BRW_REGISTER_TYPE_UD);
7683d6c4109902b555a3f8076170d572c7caeb6cbfeZou Nan hai}
7693d6c4109902b555a3f8076170d572c7caeb6cbfeZou Nan hai
770cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_reg get_addr_reg(struct brw_indirect ptr)
7719f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
7729f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return brw_address_reg(ptr.addr_subnr);
7739f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
7749f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
775cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_indirect brw_indirect_offset( struct brw_indirect ptr, GLint offset )
7769f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
7779f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   ptr.addr_offset += offset;
7789f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return ptr;
7799f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
7809f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
781cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_indirect brw_indirect( GLuint addr_subnr, GLint offset )
7829f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt{
7839f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   struct brw_indirect ptr;
7849f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   ptr.addr_subnr = addr_subnr;
7859f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   ptr.addr_offset = offset;
7869f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   ptr.pad = 0;
7879f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt   return ptr;
7889f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt}
7899f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
79021982a2cd597aeb22d7ee2bd3a5067c58f97ca6fBrian Paul/** Do two brw_regs refer to the same register? */
7912e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunkestatic INLINE bool
79221982a2cd597aeb22d7ee2bd3a5067c58f97ca6fBrian Paulbrw_same_reg(struct brw_reg r1, struct brw_reg r2)
79321982a2cd597aeb22d7ee2bd3a5067c58f97ca6fBrian Paul{
79421982a2cd597aeb22d7ee2bd3a5067c58f97ca6fBrian Paul   return r1.file == r2.file && r1.nr == r2.nr;
79521982a2cd597aeb22d7ee2bd3a5067c58f97ca6fBrian Paul}
79621982a2cd597aeb22d7ee2bd3a5067c58f97ca6fBrian Paul
797cc96d5492038cb79806031e513365e08647d6bfaBrian Paulstatic INLINE struct brw_instruction *current_insn( struct brw_compile *p)
798d19d0596daf004b56d80f78fa1a329b43c2ebf94Zou Nan hai{
7993b891a502b030f2ce8cd7a1aba93df11595f5c95Brian Paul   return &p->store[p->nr_insn];
800d19d0596daf004b56d80f78fa1a329b43c2ebf94Zou Nan hai}
8019f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
8029f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_pop_insn_state( struct brw_compile *p );
8039f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_push_insn_state( struct brw_compile *p );
8049f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_set_mask_control( struct brw_compile *p, GLuint value );
80533dfdc735e052d9c9b33883350e926d40220b6acEric Anholtvoid brw_set_saturate( struct brw_compile *p, bool enable );
8069f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_set_access_mode( struct brw_compile *p, GLuint access_mode );
8073f5e938a9ded42ae8dc9ae2486e8d5c8b64cfe07Kenneth Graunkevoid brw_set_compression_control(struct brw_compile *p, enum brw_compression c);
8089f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_set_predicate_control_flag_value( struct brw_compile *p, GLuint value );
8099f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_set_predicate_control( struct brw_compile *p, GLuint pc );
8104847f802c28e595130bda14055cd52c9b1f51cd7Eric Anholtvoid brw_set_predicate_inverse(struct brw_compile *p, bool predicate_inverse);
8119f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_set_conditionalmod( struct brw_compile *p, GLuint conditional );
81293ba0055c325007656c14ba38302e21be3dc599fZhenyu Wangvoid brw_set_acc_write_control(struct brw_compile *p, GLuint value);
8139f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
814774fb90db3e83d5e7326b7a72e05ce805c306b24Kenneth Graunkevoid brw_init_compile(struct brw_context *, struct brw_compile *p,
815774fb90db3e83d5e7326b7a72e05ce805c306b24Kenneth Graunke		      void *mem_ctx);
8169f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtconst GLuint *brw_get_program( struct brw_compile *p, GLuint *sz );
8179f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
8180f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholtstruct brw_instruction *brw_next_insn(struct brw_compile *p, GLuint opcode);
8190f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholtvoid brw_set_dest(struct brw_compile *p, struct brw_instruction *insn,
8200f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt		  struct brw_reg dest);
8210f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholtvoid brw_set_src0(struct brw_compile *p, struct brw_instruction *insn,
8220f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt		  struct brw_reg reg);
8230f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt
824483f5b348b0f3c0ca7082fd2047c354e8af285e7Eric Anholtvoid gen6_resolve_implied_move(struct brw_compile *p,
825483f5b348b0f3c0ca7082fd2047c354e8af285e7Eric Anholt			       struct brw_reg *src,
826483f5b348b0f3c0ca7082fd2047c354e8af285e7Eric Anholt			       GLuint msg_reg_nr);
8279f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
8289f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/* Helpers for regular instructions:
8299f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */
8309f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define ALU1(OP)					\
8319f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtstruct brw_instruction *brw_##OP(struct brw_compile *p,	\
8329f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	      struct brw_reg dest,			\
8339f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	      struct brw_reg src0);
8349f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
8359f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#define ALU2(OP)					\
8369f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtstruct brw_instruction *brw_##OP(struct brw_compile *p,	\
8379f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	      struct brw_reg dest,			\
8389f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	      struct brw_reg src0,			\
8399f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	      struct brw_reg src1);
8409f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
8412b28fd6ca603df40a5d02aac4035eced3a1d079aEric Anholt#define ALU3(OP)					\
8422b28fd6ca603df40a5d02aac4035eced3a1d079aEric Anholtstruct brw_instruction *brw_##OP(struct brw_compile *p,	\
8432b28fd6ca603df40a5d02aac4035eced3a1d079aEric Anholt	      struct brw_reg dest,			\
8442b28fd6ca603df40a5d02aac4035eced3a1d079aEric Anholt	      struct brw_reg src0,			\
8452b28fd6ca603df40a5d02aac4035eced3a1d079aEric Anholt	      struct brw_reg src1,			\
8462b28fd6ca603df40a5d02aac4035eced3a1d079aEric Anholt	      struct brw_reg src2);
8472b28fd6ca603df40a5d02aac4035eced3a1d079aEric Anholt
848897f6d3c7d06316b0535971cc2de318157c23692Kenneth Graunke#define ROUND(OP) \
849897f6d3c7d06316b0535971cc2de318157c23692Kenneth Graunkevoid brw_##OP(struct brw_compile *p, struct brw_reg dest, struct brw_reg src0);
850897f6d3c7d06316b0535971cc2de318157c23692Kenneth Graunke
8519f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU1(MOV)
8529f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(SEL)
8539f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU1(NOT)
8549f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(AND)
8559f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(OR)
8569f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(XOR)
8579f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(SHR)
8589f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(SHL)
8599f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(RSR)
8609f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(RSL)
8619f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(ASR)
8629f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(JMPI)
8639f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(ADD)
8646a27506181b29c8b7eda7bd6cf80689f849e181dPaul BerryALU2(AVG)
8659f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(MUL)
8669f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU1(FRC)
8679f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU1(RNDD)
8689f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(MAC)
8699f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(MACH)
8709f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU1(LZD)
8719f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(DP4)
8729f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(DPH)
8739f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(DP3)
8749f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(DP2)
8759f344b3e7d6e23674dd4747faec253f103563b36Eric AnholtALU2(LINE)
87656ff30a9f97a1a7094432333906544d6138d6bf2Eric AnholtALU2(PLN)
8772b28fd6ca603df40a5d02aac4035eced3a1d079aEric AnholtALU3(MAD)
8789f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
879897f6d3c7d06316b0535971cc2de318157c23692Kenneth GraunkeROUND(RNDZ)
880f157812bbbcf9caac1f84988e738fc9d1e051056Kenneth GraunkeROUND(RNDE)
881897f6d3c7d06316b0535971cc2de318157c23692Kenneth Graunke
8829f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#undef ALU1
8839f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#undef ALU2
8842b28fd6ca603df40a5d02aac4035eced3a1d079aEric Anholt#undef ALU3
885897f6d3c7d06316b0535971cc2de318157c23692Kenneth Graunke#undef ROUND
8869f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
8879f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
8889f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/* Helpers for SEND instruction:
8899f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */
8905f4575d42fdaaf671d4b3cdcf2c733ad9d35d339Kenneth Graunkevoid brw_set_sampler_message(struct brw_compile *p,
8915f4575d42fdaaf671d4b3cdcf2c733ad9d35d339Kenneth Graunke                             struct brw_instruction *insn,
8925f4575d42fdaaf671d4b3cdcf2c733ad9d35d339Kenneth Graunke                             GLuint binding_table_index,
8935f4575d42fdaaf671d4b3cdcf2c733ad9d35d339Kenneth Graunke                             GLuint sampler,
8945f4575d42fdaaf671d4b3cdcf2c733ad9d35d339Kenneth Graunke                             GLuint msg_type,
8955f4575d42fdaaf671d4b3cdcf2c733ad9d35d339Kenneth Graunke                             GLuint response_length,
8965f4575d42fdaaf671d4b3cdcf2c733ad9d35d339Kenneth Graunke                             GLuint msg_length,
8975f4575d42fdaaf671d4b3cdcf2c733ad9d35d339Kenneth Graunke                             GLuint header_present,
8985f4575d42fdaaf671d4b3cdcf2c733ad9d35d339Kenneth Graunke                             GLuint simd_mode,
8995f4575d42fdaaf671d4b3cdcf2c733ad9d35d339Kenneth Graunke                             GLuint return_format);
9005f4575d42fdaaf671d4b3cdcf2c733ad9d35d339Kenneth Graunke
9010f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholtvoid brw_set_dp_read_message(struct brw_compile *p,
9020f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt			     struct brw_instruction *insn,
9030f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt			     GLuint binding_table_index,
9040f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt			     GLuint msg_control,
9050f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt			     GLuint msg_type,
9060f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt			     GLuint target_cache,
9070f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt			     GLuint msg_length,
9080f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt			     GLuint response_length);
9090f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt
9100f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholtvoid brw_set_dp_write_message(struct brw_compile *p,
9110f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt			      struct brw_instruction *insn,
9120f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt			      GLuint binding_table_index,
9130f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt			      GLuint msg_control,
9140f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt			      GLuint msg_type,
9150f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt			      GLuint msg_length,
9162e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke			      bool header_present,
91753798f90e818e9bf213c3ae4298751362a5ecd50Kenneth Graunke			      GLuint last_render_target,
9180f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt			      GLuint response_length,
9190f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt			      GLuint end_of_thread,
9200f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt			      GLuint send_commit_msg);
9210f22f98ccd69bb5e8df3c78203bce9bc630965c1Eric Anholt
9229f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_urb_WRITE(struct brw_compile *p,
9239f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   struct brw_reg dest,
9249f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   GLuint msg_reg_nr,
9259f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   struct brw_reg src0,
9262e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke		   bool allocate,
9272e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke		   bool used,
9289f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   GLuint msg_length,
9299f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   GLuint response_length,
9302e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke		   bool eot,
9312e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke		   bool writes_complete,
9329f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   GLuint offset,
9339f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   GLuint swizzle);
9349f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
9352995bf0d68f1b28ba68b81e9dc79e3ab52bc2795Xiang, Haihaovoid brw_ff_sync(struct brw_compile *p,
9362995bf0d68f1b28ba68b81e9dc79e3ab52bc2795Xiang, Haihao		   struct brw_reg dest,
9372995bf0d68f1b28ba68b81e9dc79e3ab52bc2795Xiang, Haihao		   GLuint msg_reg_nr,
9382995bf0d68f1b28ba68b81e9dc79e3ab52bc2795Xiang, Haihao		   struct brw_reg src0,
9392e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke		   bool allocate,
9402995bf0d68f1b28ba68b81e9dc79e3ab52bc2795Xiang, Haihao		   GLuint response_length,
9412e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke		   bool eot);
9422995bf0d68f1b28ba68b81e9dc79e3ab52bc2795Xiang, Haihao
9439308f298300beaa757194a0db8ed50924754c011Paul Berryvoid brw_svb_write(struct brw_compile *p,
9449308f298300beaa757194a0db8ed50924754c011Paul Berry                   struct brw_reg dest,
9459308f298300beaa757194a0db8ed50924754c011Paul Berry                   GLuint msg_reg_nr,
9469308f298300beaa757194a0db8ed50924754c011Paul Berry                   struct brw_reg src0,
9479308f298300beaa757194a0db8ed50924754c011Paul Berry                   GLuint binding_table_index,
9489308f298300beaa757194a0db8ed50924754c011Paul Berry                   bool   send_commit_msg);
9499308f298300beaa757194a0db8ed50924754c011Paul Berry
9509f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_fb_WRITE(struct brw_compile *p,
951e6ec500e19f455237828f4f3955f888ad0b56382Eric Anholt		  int dispatch_width,
9529f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   GLuint msg_reg_nr,
9539f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   struct brw_reg src0,
95429362875f2613ad87abe7725ce3c56c36d16cf9bEric Anholt		   GLuint msg_control,
9559f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   GLuint binding_table_index,
9569f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   GLuint msg_length,
9579f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		   GLuint response_length,
9582e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke		   bool eot,
9592e5a1a254ed81b1d3efa6064f48183eefac784d0Kenneth Graunke		   bool header_present);
9609f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
9619f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_SAMPLE(struct brw_compile *p,
9629f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		struct brw_reg dest,
9639f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		GLuint msg_reg_nr,
9649f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		struct brw_reg src0,
9659f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		GLuint binding_table_index,
9669f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		GLuint sampler,
9679f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		GLuint writemask,
9689f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		GLuint msg_type,
9699f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		GLuint response_length,
9709f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		GLuint msg_length,
9712995bf0d68f1b28ba68b81e9dc79e3ab52bc2795Xiang, Haihao		GLuint header_present,
9727e84a64dd02794a59586ba58ef0864118534d3c6Eric Anholt		GLuint simd_mode,
9737e84a64dd02794a59586ba58ef0864118534d3c6Eric Anholt		GLuint return_format);
9749f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
9759f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_math_16( struct brw_compile *p,
9769f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  struct brw_reg dest,
9779f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  GLuint function,
9789f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  GLuint msg_reg_nr,
9799f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  struct brw_reg src,
9809f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		  GLuint precision );
9819f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
9829f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_math( struct brw_compile *p,
9839f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	       struct brw_reg dest,
9849f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	       GLuint function,
9859f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	       GLuint msg_reg_nr,
9869f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	       struct brw_reg src,
9879f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	       GLuint data_type,
9889f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	       GLuint precision );
9899f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
990fe2d4a5ea02df38c9940a726aa04bcf550fab1daEric Anholtvoid brw_math2(struct brw_compile *p,
991fe2d4a5ea02df38c9940a726aa04bcf550fab1daEric Anholt	       struct brw_reg dest,
992fe2d4a5ea02df38c9940a726aa04bcf550fab1daEric Anholt	       GLuint function,
993fe2d4a5ea02df38c9940a726aa04bcf550fab1daEric Anholt	       struct brw_reg src0,
994fe2d4a5ea02df38c9940a726aa04bcf550fab1daEric Anholt	       struct brw_reg src1);
995fe2d4a5ea02df38c9940a726aa04bcf550fab1daEric Anholt
99699b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholtvoid brw_oword_block_read(struct brw_compile *p,
99799b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt			  struct brw_reg dest,
99899b2c8570ea6f46c6564681631f0e0750a0641ccEric Anholt			  struct brw_reg mrf,
99907cd8f46acc34b04308f81de2faf05ba33da264bEric Anholt			  uint32_t offset,
100007cd8f46acc34b04308f81de2faf05ba33da264bEric Anholt			  uint32_t bind_table_index);
10019f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
100207cd8f46acc34b04308f81de2faf05ba33da264bEric Anholtvoid brw_oword_block_read_scratch(struct brw_compile *p,
100307cd8f46acc34b04308f81de2faf05ba33da264bEric Anholt				  struct brw_reg dest,
100407cd8f46acc34b04308f81de2faf05ba33da264bEric Anholt				  struct brw_reg mrf,
100507cd8f46acc34b04308f81de2faf05ba33da264bEric Anholt				  int num_regs,
100607cd8f46acc34b04308f81de2faf05ba33da264bEric Anholt				  GLuint offset);
100707cd8f46acc34b04308f81de2faf05ba33da264bEric Anholt
100807cd8f46acc34b04308f81de2faf05ba33da264bEric Anholtvoid brw_oword_block_write_scratch(struct brw_compile *p,
100907cd8f46acc34b04308f81de2faf05ba33da264bEric Anholt				   struct brw_reg mrf,
101007cd8f46acc34b04308f81de2faf05ba33da264bEric Anholt				   int num_regs,
101107cd8f46acc34b04308f81de2faf05ba33da264bEric Anholt				   GLuint offset);
10128127e49b93820d1768e2d298bbe238dd55c20732Brian Paul
10133789d5025a3200c40a39119c94c3d38a13e4b65aEric Anholtvoid brw_dword_scattered_read(struct brw_compile *p,
10143789d5025a3200c40a39119c94c3d38a13e4b65aEric Anholt			      struct brw_reg dest,
10153789d5025a3200c40a39119c94c3d38a13e4b65aEric Anholt			      struct brw_reg mrf,
10163789d5025a3200c40a39119c94c3d38a13e4b65aEric Anholt			      uint32_t bind_table_index);
10173789d5025a3200c40a39119c94c3d38a13e4b65aEric Anholt
1018cafea7528052624c8d3e4cd1c5b26a61bf04d1d0Brian Paulvoid brw_dp_READ_4_vs( struct brw_compile *p,
1019cafea7528052624c8d3e4cd1c5b26a61bf04d1d0Brian Paul                       struct brw_reg dest,
1020cafea7528052624c8d3e4cd1c5b26a61bf04d1d0Brian Paul                       GLuint location,
1021cafea7528052624c8d3e4cd1c5b26a61bf04d1d0Brian Paul                       GLuint bind_table_index );
1022cafea7528052624c8d3e4cd1c5b26a61bf04d1d0Brian Paul
102396b11f1e3ee12f06be1d33bf085bf1353f23e667Eric Anholtvoid brw_dp_READ_4_vs_relative(struct brw_compile *p,
102496b11f1e3ee12f06be1d33bf085bf1353f23e667Eric Anholt			       struct brw_reg dest,
102596b11f1e3ee12f06be1d33bf085bf1353f23e667Eric Anholt			       struct brw_reg addrReg,
102696b11f1e3ee12f06be1d33bf085bf1353f23e667Eric Anholt			       GLuint offset,
102796b11f1e3ee12f06be1d33bf085bf1353f23e667Eric Anholt			       GLuint bind_table_index);
102896b11f1e3ee12f06be1d33bf085bf1353f23e667Eric Anholt
10299f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/* If/else/endif.  Works by manipulating the execution flags on each
10309f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * channel.
10319f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */
10329f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtstruct brw_instruction *brw_IF(struct brw_compile *p,
10339f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt			       GLuint execute_size);
10342279156fe7ac9718533b8b0de90ae96100486680Kenneth Graunkestruct brw_instruction *gen6_IF(struct brw_compile *p, uint32_t conditional,
10352279156fe7ac9718533b8b0de90ae96100486680Kenneth Graunke				struct brw_reg src0, struct brw_reg src1);
10369f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
10375936d96d33e767aa99f6afa92f2a6582ff04df23Kenneth Graunkevoid brw_ELSE(struct brw_compile *p);
10385936d96d33e767aa99f6afa92f2a6582ff04df23Kenneth Graunkevoid brw_ENDIF(struct brw_compile *p);
10399f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
10409f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/* DO/WHILE loops:
10419f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */
10429f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtstruct brw_instruction *brw_DO(struct brw_compile *p,
10439f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt			       GLuint execute_size);
10449f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
104532118cfe37495738ed5931c6b1a71b8ee2ad189cEric Anholtstruct brw_instruction *brw_WHILE(struct brw_compile *p);
10469f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
1047f1d89638c02afafbf82ef657cd6ba9965dad6738Eric Anholtstruct brw_instruction *brw_BREAK(struct brw_compile *p);
1048f1d89638c02afafbf82ef657cd6ba9965dad6738Eric Anholtstruct brw_instruction *brw_CONT(struct brw_compile *p);
10499f8814752f306cb9a26d283f0b7cf876639e10f7Eric Anholtstruct brw_instruction *gen6_CONT(struct brw_compile *p);
10509f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/* Forward jumps:
10519f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */
1052328e6a5497e54b0e8aed803cf6d2ae9a2a00b2feYuanhan Liuvoid brw_land_fwd_jump(struct brw_compile *p, int jmp_insn_idx);
10539f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
10549f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
10559f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
10569f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_NOP(struct brw_compile *p);
10579f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
105820be3ff57670529a410b30a1008a71e768d08428Zhenyu Wangvoid brw_WAIT(struct brw_compile *p);
105920be3ff57670529a410b30a1008a71e768d08428Zhenyu Wang
10609f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/* Special case: there is never a destination, execution size will be
10619f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * taken from src0:
10629f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */
10639f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_CMP(struct brw_compile *p,
10649f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	     struct brw_reg dest,
10659f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	     GLuint conditional,
10669f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	     struct brw_reg src0,
10679f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	     struct brw_reg src1);
10689f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
10699f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_print_reg( struct brw_reg reg );
10709f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
10719f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
10729f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt/***********************************************************************
10739f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt * brw_eu_util.c:
10749f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt */
10759f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
10769f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_copy_indirect_to_indirect(struct brw_compile *p,
10779f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt				   struct brw_indirect dst_ptr,
10789f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt				   struct brw_indirect src_ptr,
10799f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt				   GLuint count);
10809f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
10819f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_copy_from_indirect(struct brw_compile *p,
10829f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt			    struct brw_reg dst,
10839f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt			    struct brw_indirect ptr,
10849f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt			    GLuint count);
10859f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
10869f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_copy4(struct brw_compile *p,
10879f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	       struct brw_reg dst,
10889f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	       struct brw_reg src,
10899f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	       GLuint count);
10909f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
10919f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_copy8(struct brw_compile *p,
10929f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	       struct brw_reg dst,
10939f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	       struct brw_reg src,
10949f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt	       GLuint count);
10959f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
10969f344b3e7d6e23674dd4747faec253f103563b36Eric Anholtvoid brw_math_invert( struct brw_compile *p,
10979f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		      struct brw_reg dst,
10989f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt		      struct brw_reg src);
10999f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt
11001309d2ea723613f1e755dd7785d22456dd39bb08Kenneth Graunkevoid brw_set_src1(struct brw_compile *p,
11011309d2ea723613f1e755dd7785d22456dd39bb08Kenneth Graunke		  struct brw_instruction *insn,
11021309d2ea723613f1e755dd7785d22456dd39bb08Kenneth Graunke		  struct brw_reg reg);
1103512d8ca2f34bcaa96e18daace4ae9f95e679471eEric Anholt
110400e5a743e2ee3981a34b95067a97fa73c0f5d779Eric Anholtvoid brw_set_uip_jip(struct brw_compile *p);
1105512d8ca2f34bcaa96e18daace4ae9f95e679471eEric Anholt
1106811c147220d2630b769e505ce4d40ef9108fe034Eric Anholtuint32_t brw_swap_cmod(uint32_t cmod);
1107811c147220d2630b769e505ce4d40ef9108fe034Eric Anholt
1108512d8ca2f34bcaa96e18daace4ae9f95e679471eEric Anholt/* brw_optimize.c */
1109512d8ca2f34bcaa96e18daace4ae9f95e679471eEric Anholtvoid brw_optimize(struct brw_compile *p);
111022f839292f48a47601e1b97a7f4679018c42d0edEric Anholtvoid brw_remove_duplicate_mrf_moves(struct brw_compile *p);
11112621100458e337e34166b4b769be0536f6acb32aEric Anholtvoid brw_remove_grf_to_mrf_moves(struct brw_compile *p);
1112512d8ca2f34bcaa96e18daace4ae9f95e679471eEric Anholt
1113434fc8bde41f07687ad8941ceba03c4b3e0e75bbPaul Berry#ifdef __cplusplus
1114434fc8bde41f07687ad8941ceba03c4b3e0e75bbPaul Berry}
1115434fc8bde41f07687ad8941ceba03c4b3e0e75bbPaul Berry#endif
1116434fc8bde41f07687ad8941ceba03c4b3e0e75bbPaul Berry
11179f344b3e7d6e23674dd4747faec253f103563b36Eric Anholt#endif
1118