[Nouveau] [PATCH] Autogenerate uureg opcode macros

Luca Barbieri luca at luca-barbieri.com
Thu Dec 31 11:36:11 PST 2009


This was supposed to go to mesa3d.

On Thu, Dec 31, 2009 at 6:24 PM, Luca Barbieri <luca at luca-barbieri.com>wrote:

> Also some missing _src()s and cosmetic changes.
> ---
>  src/gallium/programs/galliumut/Makefile            |    5 +
>  .../programs/galliumut/gen_uureg_opcodes.sh        |   29 +++
>  src/gallium/programs/galliumut/uureg.h             |  196
> ++++----------------
>  3 files changed, 71 insertions(+), 159 deletions(-)
>  create mode 100644 src/gallium/programs/galliumut/gen_uureg_opcodes.sh
>
> diff --git a/src/gallium/programs/galliumut/Makefile
> b/src/gallium/programs/galliumut/Makefile
> index ab0d684..4cb9d7c 100644
> --- a/src/gallium/programs/galliumut/Makefile
> +++ b/src/gallium/programs/galliumut/Makefile
> @@ -9,3 +9,8 @@ LIBRARY_DEFINES = --std=gnu99
>  C_SOURCES = egl_gallium.c image.c normal_gen.c
>
>  include ../../Makefile.template
> +
> +default: uureg_opcodes.h
> +
> +uureg_opcodes.h: gen_uureg_opcodes.sh
> +       bash $^ > $@
> diff --git a/src/gallium/programs/galliumut/gen_uureg_opcodes.sh
> b/src/gallium/programs/galliumut/gen_uureg_opcodes.sh
> new file mode 100644
> index 0000000..3a56fcb
> --- /dev/null
> +++ b/src/gallium/programs/galliumut/gen_uureg_opcodes.sh
> @@ -0,0 +1,29 @@
> +#!/bin/bash
> +cat - <<EOF
> +#ifndef UUREG_OPCODES_H
> +#define UUREG_OPCODES_H
> +
> +/* Autogenerated file, do not edit manually! Use make to regenerate. */
> +
> +EOF
> +
> +cat - << EOF|cpp -P -E - -I../../auxiliary|sed -re 's/^define /#define _/;
> s/ CAT /##/g;'
> +#define OP00(op) define op() ureg_##op(ureg)
> +#define OP01(op) define op(src) ureg_##op(ureg, _src(src))
> +#define OP00_LBL(op) define op(label) ureg_##op(ureg, label)
> +#define OP01_LBL(op) define op(src, label) ureg_##op(ureg, _src(src),
> label)
> +#define OP10(op) define op(dst) ureg_##op(ureg, dst)
> +#define OP11(op) define op(dst, src) ureg_##op(ureg, dst, _src(src))
> +#define OP12(op) define op(dst, src0, src1) ureg_##op(ureg, dst,
> _src(src0), _src(src1))
> +#define OP12_TEX(op) define op(dst, target, src0, src1) ureg_##op(ureg,
> dst, TGSI_TEXTURE_ CAT target, _src(src0), _src(src1))
> +#define OP13(op) define op(dst, src0, src1, src2) ureg_##op(ureg, dst,
> _src(src0), _src(src1), _src(src2))
> +#define OP14_TEX(op) define op(dst, target, src0, src1, src2, src3)
> ureg_##op(ureg, dst, TGSI_TEXTURE_ CAT target, _src(src0), _src(src1),
> _src(src2), _src(src3))
> +
> +#include <tgsi/tgsi_opcode_tmp.h>
> +EOF
> +
> +cat - <<EOF
> +
> +#endif
> +EOF
> +
> diff --git a/src/gallium/programs/galliumut/uureg.h
> b/src/gallium/programs/galliumut/uureg.h
> index a2d07a7..d30e188 100644
> --- a/src/gallium/programs/galliumut/uureg.h
> +++ b/src/gallium/programs/galliumut/uureg.h
> @@ -60,7 +60,7 @@ static inline struct ureg_src _src(const struct ureg_src&
> src) {return src;}
>  #define _OUTPUT(v, n, i) struct ureg_dst v = ureg_DECL_output(ureg,
> TGSI_SEMANTIC_##n, i)
>  #define _CONST_(v, i) struct ureg_src v = ureg_DECL_constant(ureg, i)
>  #define _CONST(v, s) UREG_CONST(v, ureg, s)
> - #define _CONST_MAT3(v, s) UREG_CONST_MAT3(v, ureg, s)
> +#define _CONST_MAT3(v, s) UREG_CONST_MAT3(v, ureg, s)
>  #define _CONST_MAT4(v, s) UREG_CONST_MAT4(v, ureg, s)
>  #define _ADDRESS(v) struct ureg_src v = ureg_DECL_address(ureg)
>  #define _LOOP(v) struct ureg_src v = ureg_DECL_loop(ureg)
> @@ -88,6 +88,41 @@ static inline struct ureg_src _src(const struct
> ureg_src& src) {return src;}
>  #define _zy(v) _swz(v, Z, Y, Z, Y)
>  #define _zw(v) _swz(v, Z, W, Z, W)
>
> +#define _ind(r, a) ureg_src_indirect(_src(r), _src(a))
> +#define _abs(x) ureg_abs(_src(x))
> +#define _neg(x) ureg_negate(_src(x))
> +#define _undef ureg_src_undef()
> +#define _is_undef(v) ureg_src_is_undef(_src(v))
> +
> +#define _X(v) ureg_writemask((v), TGSI_WRITEMASK_X)
> +#define _Y(v) ureg_writemask((v), TGSI_WRITEMASK_Y)
> +#define _Z(v) ureg_writemask((v), TGSI_WRITEMASK_Z)
> +#define _W(v) ureg_writemask((v), TGSI_WRITEMASK_W)
> +#define _XY(v) ureg_writemask((v), TGSI_WRITEMASK_X | TGSI_WRITEMASK_Y)
> +#define _XZ(v) ureg_writemask((v), TGSI_WRITEMASK_X | TGSI_WRITEMASK_Z)
> +#define _XW(v) ureg_writemask((v), TGSI_WRITEMASK_X | TGSI_WRITEMASK_W)
> +#define _YZ(v) ureg_writemask((v), TGSI_WRITEMASK_Y | TGSI_WRITEMASK_Z)
> +#define _YW(v) ureg_writemask((v), TGSI_WRITEMASK_Y | TGSI_WRITEMASK_W)
> +#define _ZW(v) ureg_writemask((v), TGSI_WRITEMASK_Z | TGSI_WRITEMASK_W)
> +#define _XYZ(v) ureg_writemask((v), TGSI_WRITEMASK_X | TGSI_WRITEMASK_Y |
> TGSI_WRITEMASK_Z)
> +#define _XYW(v) ureg_writemask((v), TGSI_WRITEMASK_X | TGSI_WRITEMASK_Y |
> TGSI_WRITEMASK_W)
> +#define _XZW(v) ureg_writemask((v), TGSI_WRITEMASK_Y | TGSI_WRITEMASK_Z |
> TGSI_WRITEMASK_W)
> +#define _YZW(v) ureg_writemask((v), TGSI_WRITEMASK_Y | TGSI_WRITEMASK_Z |
> TGSI_WRITEMASK_W)
> +#define _XYZW(v) ureg_writemask((v), TGSI_WRITEMASK_X | TGSI_WRITEMASK_Y |
> TGSI_WRITEMASK_Z | TGSI_WRITEMASK_W)
> +
> +#define _SAT(v) ureg_saturate(v)
> +#define _PRED(v, n, x, y, z, w) ureg_predicate(v, n, x, y, z, w)
> +#define _IND(r, a) ureg_dst_indirect(r, _src(a))
> +#define _UNDEF ureg_dst_undef()
> +#define _IS_UNDEF(v) ureg_dst_is_undef(v)
> +
> +#define _VERT struct ureg_program* ureg =
> ureg_create(TGSI_PROCESSOR_VERTEX)
> +#define _FRAG struct ureg_program* ureg =
> ureg_create(TGSI_PROCESSOR_FRAGMENT)
> +
> +#define _END_SHADER(pipe) (_END(), ureg_create_shader_and_destroy(ureg,
> pipe))
> +
> +#include "uureg_opcodes.h"
> +
>  /* generate with
>  #!/usr/bin/python
>  l = ('x', 'y', 'z', 'w')
> @@ -354,162 +389,5 @@ for i in range(256):
>  #define _wwwz(v) _swz(v, W, W, W, Z)
>  #define _wwww(v) _swz(v, W, W, W, W)
>
> -#define _ind(r, a) ureg_src_indirect(_src(r), _src(a))
> -#define _abs(x) ureg_abs(_src(x))
> -#define _neg(x) ureg_negate(_src(x))
> -#define _undef ureg_src_undef()
> -#define _is_undef(v) ureg_src_is_undef(v)
> -
> -#define _X(v) ureg_writemask((v), TGSI_WRITEMASK_X)
> -#define _Y(v) ureg_writemask((v), TGSI_WRITEMASK_Y)
> -#define _Z(v) ureg_writemask((v), TGSI_WRITEMASK_Z)
> -#define _W(v) ureg_writemask((v), TGSI_WRITEMASK_W)
> -#define _XY(v) ureg_writemask((v), TGSI_WRITEMASK_X | TGSI_WRITEMASK_Y)
> -#define _XZ(v) ureg_writemask((v), TGSI_WRITEMASK_X | TGSI_WRITEMASK_Z)
> -#define _XW(v) ureg_writemask((v), TGSI_WRITEMASK_X | TGSI_WRITEMASK_W)
> -#define _YZ(v) ureg_writemask((v), TGSI_WRITEMASK_Y | TGSI_WRITEMASK_Z)
> -#define _YW(v) ureg_writemask((v), TGSI_WRITEMASK_Y | TGSI_WRITEMASK_W)
> -#define _ZW(v) ureg_writemask((v), TGSI_WRITEMASK_Z | TGSI_WRITEMASK_W)
> -#define _XYZ(v) ureg_writemask((v), TGSI_WRITEMASK_X | TGSI_WRITEMASK_Y |
> TGSI_WRITEMASK_Z)
> -#define _XYW(v) ureg_writemask((v), TGSI_WRITEMASK_X | TGSI_WRITEMASK_Y |
> TGSI_WRITEMASK_W)
> -#define _XZW(v) ureg_writemask((v), TGSI_WRITEMASK_Y | TGSI_WRITEMASK_Z |
> TGSI_WRITEMASK_W)
> -#define _YZW(v) ureg_writemask((v), TGSI_WRITEMASK_Y | TGSI_WRITEMASK_Z |
> TGSI_WRITEMASK_W)
> -#define _XYZW(v) ureg_writemask((v), TGSI_WRITEMASK_X | TGSI_WRITEMASK_Y |
> TGSI_WRITEMASK_Z | TGSI_WRITEMASK_W)
> -
> -#define _SAT(v) ureg_saturate(v)
> -#define _PRED(v, n, x, y, z, w) ureg_predicate(v, n, x, y, z, w)
> -#define _IND(r, a) ureg_dst_indirect(r, _src(a))
> -#define _UNDEF ureg_dst_undef()
> -#define _IS_UNDEF(v) ureg_dst_is_undef(v)
> -
> -#define _VERT struct ureg_program* ureg =
> ureg_create(TGSI_PROCESSOR_VERTEX)
> -#define _FRAG struct ureg_program* ureg =
> ureg_create(TGSI_PROCESSOR_FRAGMENT)
> -
> -#define _END_SHADER(pipe) (_END(), ureg_create_shader_and_destroy(ureg,
> pipe))
> -
> -/*
> -Generate with:
> -cat - << EOF|gcc -E - -I../../src/gallium/auxiliary|sed -re
> 's/^define/#define/; s/(ureg.* )(src[0-9]+)/\1_src(\2)/; s/(ureg.*
> )(src[0-9]+)/\1_src(\2)/; s/(ureg.* )(src[0-9]+)/\1_src(\2)/; s/(ureg.*
> )(src[0-9]+)/\1_src(\2)/; s/(ureg.* )(target)/\1TGSI_TEXTURE_##\2/;'
> -#define OP00(op) define op() ureg_##op(ureg)
> -#define OP01(op) define op(src) ureg_##op(ureg, src)
> -#define OP00_LBL(op) define op(label) ureg_##op(ureg, label)
> -#define OP01_LBL(op) define op(src, label) ureg_##op(ureg, src, label)
> -#define OP10(op) define op(dst) ureg_##op(ureg, dst)
> -#define OP11(op) define op(dst, src) ureg_##op(ureg, dst, src)
> -#define OP12(op) define op(dst, src0, src1) ureg_##op(ureg, dst, src0,
> src1)
> -#define OP12_TEX(op) define op(dst, target, src0, src1) ureg_##op(ureg,
> dst, target, src0, src1)
> -#define OP13(op) define op(dst, src0, src1, src2) ureg_##op(ureg, dst,
> src0, src1, src2)
> -#define OP14_TEX(op) define op(dst, target, src0, src1, src2, src3)
> ureg_##op(ureg, dst, target, src0, src1, src2, src3)
> -
> -#include <tgsi/tgsi_opcode_tmp.h>
> -EOF
> -*/
> -
> -#define _ARL(dst, src) ureg_ARL(ureg, dst, _src(src))
> -#define _MOV(dst, src) ureg_MOV(ureg, dst, _src(src))
> -#define _LIT(dst, src) ureg_LIT(ureg, dst, _src(src))
> -#define _RCP(dst, src) ureg_RCP(ureg, dst, _src(src))
> -#define _RSQ(dst, src) ureg_RSQ(ureg, dst, _src(src))
> -#define _EXP(dst, src) ureg_EXP(ureg, dst, _src(src))
> -#define _LOG(dst, src) ureg_LOG(ureg, dst, _src(src))
> -#define _MUL(dst, src0, src1) ureg_MUL(ureg, dst, _src(src0), _src(src1))
> -#define _ADD(dst, src0, src1) ureg_ADD(ureg, dst, _src(src0), _src(src1))
> -#define _DP3(dst, src0, src1) ureg_DP3(ureg, dst, _src(src0), _src(src1))
> -#define _DP4(dst, src0, src1) ureg_DP4(ureg, dst, _src(src0), _src(src1))
> -#define _DST(dst, src0, src1) ureg_DST(ureg, dst, _src(src0), _src(src1))
> -#define _MIN(dst, src0, src1) ureg_MIN(ureg, dst, _src(src0), _src(src1))
> -#define _MAX(dst, src0, src1) ureg_MAX(ureg, dst, _src(src0), _src(src1))
> -#define _SLT(dst, src0, src1) ureg_SLT(ureg, dst, _src(src0), _src(src1))
> -#define _SGE(dst, src0, src1) ureg_SGE(ureg, dst, _src(src0), _src(src1))
> -#define _MAD(dst, src0, src1, src2) ureg_MAD(ureg, dst, _src(src0),
> _src(src1), _src(src2))
> -#define _SUB(dst, src0, src1) ureg_SUB(ureg, dst, _src(src0), _src(src1))
> -#define _LRP(dst, src0, src1, src2) ureg_LRP(ureg, dst, _src(src0),
> _src(src1), _src(src2))
> -#define _CND(dst, src0, src1, src2) ureg_CND(ureg, dst, _src(src0),
> _src(src1), _src(src2))
> -#define _DP2A(dst, src0, src1, src2) ureg_DP2A(ureg, dst, _src(src0),
> _src(src1), _src(src2))
> -#define _FRC(dst, src) ureg_FRC(ureg, dst, _src(src))
> -#define _CLAMP(dst, src0, src1, src2) ureg_CLAMP(ureg, dst, _src(src0),
> _src(src1), _src(src2))
> -#define _FLR(dst, src) ureg_FLR(ureg, dst, _src(src))
> -#define _ROUND(dst, src) ureg_ROUND(ureg, dst, _src(src))
> -#define _EX2(dst, src) ureg_EX2(ureg, dst, _src(src))
> -#define _LG2(dst, src) ureg_LG2(ureg, dst, _src(src))
> -#define _POW(dst, src0, src1) ureg_POW(ureg, dst, _src(src0), _src(src1))
> -#define _XPD(dst, src0, src1) ureg_XPD(ureg, dst, _src(src0), _src(src1))
> -#define _ABS(dst, src) ureg_ABS(ureg, dst, _src(src))
> -#define _RCC(dst, src) ureg_RCC(ureg, dst, _src(src))
> -#define _DPH(dst, src0, src1) ureg_DPH(ureg, dst, _src(src0), _src(src1))
> -#define _COS(dst, src) ureg_COS(ureg, dst, _src(src))
> -#define _DDX(dst, src) ureg_DDX(ureg, dst, _src(src))
> -#define _DDY(dst, src) ureg_DDY(ureg, dst, _src(src))
> -#define _KILP() ureg_KILP(ureg)
> -#define _PK2H(dst, src) ureg_PK2H(ureg, dst, _src(src))
> -#define _PK2US(dst, src) ureg_PK2US(ureg, dst, _src(src))
> -#define _PK4B(dst, src) ureg_PK4B(ureg, dst, _src(src))
> -#define _PK4UB(dst, src) ureg_PK4UB(ureg, dst, _src(src))
> -#define _RFL(dst, src0, src1) ureg_RFL(ureg, dst, _src(src0), _src(src1))
> -#define _SEQ(dst, src0, src1) ureg_SEQ(ureg, dst, _src(src0), _src(src1))
> -#define _SFL(dst, src0, src1) ureg_SFL(ureg, dst, _src(src0), _src(src1))
> -#define _SGT(dst, src0, src1) ureg_SGT(ureg, dst, _src(src0), _src(src1))
> -#define _SIN(dst, src) ureg_SIN(ureg, dst, _src(src))
> -#define _SLE(dst, src0, src1) ureg_SLE(ureg, dst, _src(src0), _src(src1))
> -#define _SNE(dst, src0, src1) ureg_SNE(ureg, dst, _src(src0), _src(src1))
> -#define _STR(dst, src0, src1) ureg_STR(ureg, dst, _src(src0), _src(src1))
> -#define _TEX(dst, target, src0, src1) ureg_TEX(ureg, dst,
> TGSI_TEXTURE_##target, _src(src0), _src(src1))
> -#define _TXD(dst, target, src0, src1, src2, src3) ureg_TXD(ureg, dst,
> TGSI_TEXTURE_##target, src0, _src(src1), _src(src2), _src(src3))
> -#define _TXP(dst, target, src0, src1) ureg_TXP(ureg, dst,
> TGSI_TEXTURE_##target, _src(src0), _src(src1))
> -#define _UP2H(dst, src) ureg_UP2H(ureg, dst, _src(src))
> -#define _UP2US(dst, src) ureg_UP2US(ureg, dst, _src(src))
> -#define _UP4B(dst, src) ureg_UP4B(ureg, dst, _src(src))
> -#define _UP4UB(dst, src) ureg_UP4UB(ureg, dst, _src(src))
> -#define _X2D(dst, src0, src1, src2) ureg_X2D(ureg, dst, _src(src0),
> _src(src1), _src(src2))
> -#define _ARA(dst, src) ureg_ARA(ureg, dst, _src(src))
> -#define _ARR(dst, src) ureg_ARR(ureg, dst, _src(src))
> -#define _BRA(src) ureg_BRA(ureg, _src(src))
> -#define _CAL(label) ureg_CAL(ureg, label)
> -#define _RET() ureg_RET(ureg)
> -#define _SSG(dst, src) ureg_SSG(ureg, dst, _src(src))
> -#define _CMP(dst, src0, src1, src2) ureg_CMP(ureg, dst, _src(src0),
> _src(src1), _src(src2))
> -#define _SCS(dst, src) ureg_SCS(ureg, dst, _src(src))
> -#define _TXB(dst, target, src0, src1) ureg_TXB(ureg, dst,
> TGSI_TEXTURE_##target, _src(src0), _src(src1))
> -#define _NRM(dst, src) ureg_NRM(ureg, dst, _src(src))
> -#define _DIV(dst, src0, src1) ureg_DIV(ureg, dst, _src(src0), _src(src1))
> -#define _DP2(dst, src0, src1) ureg_DP2(ureg, dst, _src(src0), _src(src1))
> -#define _TXL(dst, target, src0, src1) ureg_TXL(ureg, dst,
> TGSI_TEXTURE_##target, _src(src0), _src(src1))
> -#define _BRK() ureg_BRK(ureg)
> -#define _IF(src, label) ureg_IF(ureg, _src(src), label)
> -#define _BGNFOR(dst, src) ureg_BGNFOR(ureg, dst, _src(src))
> -#define _REP(src) ureg_REP(ureg, _src(src))
> -#define _ELSE(label) ureg_ELSE(ureg, label)
> -#define _ENDIF() ureg_ENDIF(ureg)
> -#define _ENDFOR(dst) ureg_ENDFOR(ureg, dst)
> -#define _ENDREP() ureg_ENDREP(ureg)
> -#define _PUSHA(src) ureg_PUSHA(ureg, _src(src))
> -#define _POPA(dst) ureg_POPA(ureg, dst)
> -#define _CEIL(dst, src) ureg_CEIL(ureg, dst, _src(src))
> -#define _I2F(dst, src) ureg_I2F(ureg, dst, _src(src))
> -#define _NOT(dst, src) ureg_NOT(ureg, dst, _src(src))
> -#define _TRUNC(dst, src) ureg_TRUNC(ureg, dst, _src(src))
> -#define _SHL(dst, src0, src1) ureg_SHL(ureg, dst, _src(src0), _src(src1))
> -#define _SHR(dst, src0, src1) ureg_SHR(ureg, dst, _src(src0), _src(src1))
> -#define _AND(dst, src0, src1) ureg_AND(ureg, dst, _src(src0), _src(src1))
> -#define _OR(dst, src0, src1) ureg_OR(ureg, dst, _src(src0), _src(src1))
> -#define _MOD(dst, src0, src1) ureg_MOD(ureg, dst, _src(src0), _src(src1))
> -#define _XOR(dst, src0, src1) ureg_XOR(ureg, dst, _src(src0), _src(src1))
> -#define _SAD(dst, src0, src1, src2) ureg_SAD(ureg, dst, _src(src0),
> _src(src1), _src(src2))
> -#define _TXF(dst, target, src0, src1) ureg_TXF(ureg, dst,
> TGSI_TEXTURE_##target, _src(src0), _src(src1))
> -#define _TXQ(dst, target, src0, src1) ureg_TXQ(ureg, dst,
> TGSI_TEXTURE_##target, _src(src0), _src(src1))
> -#define _CONT() ureg_CONT(ureg)
> -#define _EMIT() ureg_EMIT(ureg)
> -#define _ENDPRIM() ureg_ENDPRIM(ureg)
> -#define _BGNLOOP(label) ureg_BGNLOOP(ureg, label)
> -#define _BGNSUB() ureg_BGNSUB(ureg)
> -#define _ENDLOOP(label) ureg_ENDLOOP(ureg, label)
> -#define _ENDSUB() ureg_ENDSUB(ureg)
> -#define _NOP() ureg_NOP(ureg)
> -#define _NRM4(dst, src) ureg_NRM4(ureg, dst, _src(src))
> -#define _CALLNZ(src) ureg_CALLNZ(ureg, _src(src))
> -#define _IFC(src) ureg_IFC(ureg, _src(src))
> -#define _BREAKC(src) ureg_BREAKC(ureg, _src(src))
> -#define _KIL(src) ureg_KIL(ureg, _src(src))
> -#define _END() ureg_END(ureg)
> -
>  #endif
> +
> --
> 1.6.3.3
>
>


-- 
Luca Barbieri
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freedesktop.org/archives/nouveau/attachments/20091231/8ca05b1f/attachment-0001.html 


More information about the Nouveau mailing list