Re: [Mesa-dev] [PATCH 2/5] nir: use Python to autogenerate opcode information

2015-01-19 Thread Jason Ekstrand
In general, I think I like this.  The CPP was fine and I in general prefer
it when practical but this is probably justified in light of the constant
folding stuff.  Good work on making of look very similar to the old
nir_opcodes.h.  Only 1 comment below.

On Jan 16, 2015 3:46 PM, Connor Abbott cwabbo...@gmail.com wrote:

 Before, we used a system where a file, nir_opcodes.h, defined some macros
that
 were included to generate the enum values and the nir_op_infos structure.
This
 worked pretty well, but for development the error messages were never very
 useful, Python tools couldn't understand the opcode list, and it was
difficult
 to use nir_opcodes.h to do other things like autogenerate a builder API.
Now, we
 store opcode information in nir_opcodes.py, and we have nir_opcodes_c.py
to
 generate the old nir_opcodes.c and nir_opcodes_h.py to generate
nir_opcodes.h,
 which contains all the enum names and gets included into nir.h like
before.  In
 addition to solving the above problems, using Python and Mako to generate
 everything means that it's much easier to add keep information
centralized as we
 add new things like constant propagation that require per-opcode
information.

 Signed-off-by: Connor Abbott cwabbo...@gmail.com
 ---
  src/glsl/Makefile.am  |  15 +-
  src/glsl/Makefile.sources |   6 +-
  src/glsl/nir/.gitignore   |   2 +
  src/glsl/nir/nir.h|   9 -
  src/glsl/nir/nir_opcodes.c|  46 --
  src/glsl/nir/nir_opcodes.h| 366

  src/glsl/nir/nir_opcodes.py   | 377
++
  src/glsl/nir/nir_opcodes_c.py |  56 +++
  src/glsl/nir/nir_opcodes_h.py |  39 +
  9 files changed, 491 insertions(+), 425 deletions(-)
  delete mode 100644 src/glsl/nir/nir_opcodes.c
  delete mode 100644 src/glsl/nir/nir_opcodes.h
  create mode 100644 src/glsl/nir/nir_opcodes.py
  create mode 100644 src/glsl/nir/nir_opcodes_c.py
  create mode 100644 src/glsl/nir/nir_opcodes_h.py

 diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am
 index b2b74a9..b2fe16a 100644
 --- a/src/glsl/Makefile.am
 +++ b/src/glsl/Makefile.am
 @@ -27,6 +27,7 @@ AM_CPPFLAGS = \
 -I$(top_srcdir)/src/glsl/glcpp \
 -I$(top_srcdir)/src/glsl/nir \
 -I$(top_srcdir)/src/gtest/include \
 +   -I$(top_builddir)/src/glsl/nir \
 $(DEFINES)
  AM_CFLAGS = $(VISIBILITY_CFLAGS)
  AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS)
 @@ -207,7 +208,9 @@ BUILT_SOURCES =
   \
 glsl_lexer.cpp  \
 glcpp/glcpp-parse.c \
 glcpp/glcpp-lex.c   \
 -   nir/nir_opt_algebraic.c
 +   nir/nir_opt_algebraic.c \
 +   nir/nir_opcodes.h   \
 +   nir/nir_opcodes.c
  CLEANFILES =   \
 glcpp/glcpp-parse.h \
 glsl_parser.h   \
 @@ -223,3 +226,13 @@ dist-hook:
  nir/nir_opt_algebraic.c: nir/nir_opt_algebraic.py nir/nir_algebraic.py
 $(MKDIR_P) nir; \
 $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opt_algebraic.py  $@
 +
 +nir/nir_opcodes.h: nir/nir_opcodes.py nir/nir_opcodes_h.py
 +   $(MKDIR_P) nir; \
 +   $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opcodes_h.py  $@
 +
 +nir/nir_opcodes.c: nir/nir_opcodes.py nir/nir_opcodes_c.py
 +   $(MKDIR_P) nir; \
 +   $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opcodes_c.py  $@
 +
 +nir/nir.h: nir/nir_opcodes.h
 diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
 index a951ca7..03b4f2e 100644
 --- a/src/glsl/Makefile.sources
 +++ b/src/glsl/Makefile.sources
 @@ -14,7 +14,9 @@ LIBGLCPP_GENERATED_FILES = \
 $(GLSL_BUILDDIR)/glcpp/glcpp-parse.c

  NIR_GENERATED_FILES = \
 -   $(GLSL_BUILDDIR)/nir/nir_opt_algebraic.c
 +   $(GLSL_BUILDDIR)/nir/nir_opt_algebraic.c \
 +   $(GLSL_BUILDDIR)/nir/nir_opcodes.h \
 +   $(GLSL_BUILDDIR)/nir/nir_opcodes.c

  NIR_FILES = \
 $(GLSL_SRCDIR)/nir/nir.c \
 @@ -35,8 +37,6 @@ NIR_FILES = \
 $(GLSL_SRCDIR)/nir/nir_lower_var_copies.c \
 $(GLSL_SRCDIR)/nir/nir_lower_vec_to_movs.c \
 $(GLSL_SRCDIR)/nir/nir_metadata.c \
 -   $(GLSL_SRCDIR)/nir/nir_opcodes.c \
 -   $(GLSL_SRCDIR)/nir/nir_opcodes.h \
 $(GLSL_SRCDIR)/nir/nir_opt_constant_folding.c \
 $(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
 $(GLSL_SRCDIR)/nir/nir_opt_cse.c \
 diff --git a/src/glsl/nir/.gitignore b/src/glsl/nir/.gitignore
 index 6d954fe..4c28193 100644
 --- a/src/glsl/nir/.gitignore
 +++ b/src/glsl/nir/.gitignore
 @@ -1 +1,3 @@
  nir_opt_algebraic.c
 +nir_opcodes.c
 +nir_opcodes.h
 diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
 index 

Re: [Mesa-dev] [PATCH 2/5] nir: use Python to autogenerate opcode information

2015-01-17 Thread Connor Abbott
On Sat, Jan 17, 2015 at 11:42 AM, ahmad luig...@yandex.com wrote:
 hi.

 #! /usr/bin/env python corresponds python 3.x series for some  major distro 
 (arch,fedora ...) and python 2.x for some others.

 python 2.x and python 3.x are not source compatible each other.

 python 3.x not contains xrange funcion anymore.

 range vs xrange only meaningfull for python 2.x.

 http://www.pythoncentral.io/how-to-use-pythons-xrange-and-range/

 Distros that which still use 2.x  series as default python interpreter going 
 to 3.x.

 regargs.
 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Yes... if you look at the part of the patch that modifies Makefile.am,
it's actually called with $(PYTHON) which will be python2 on distro's
where python3 is the default. Unfortunately, on some distros there's
no python2, so #!/usr/bin/env python2 won't work either... you can't
please everyone. So the line you mentioned is more customary than
anything else.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/5] nir: use Python to autogenerate opcode information

2015-01-17 Thread Dylan Baker
On Saturday, January 17, 2015 01:09:45 PM Connor Abbott wrote:
 On Sat, Jan 17, 2015 at 11:42 AM, ahmad luig...@yandex.com wrote:
  hi.
 
  #! /usr/bin/env python corresponds python 3.x series for some  major 
  distro (arch,fedora ...) and python 2.x for some others.
 
  python 2.x and python 3.x are not source compatible each other.
 
  python 3.x not contains xrange funcion anymore.
 
  range vs xrange only meaningfull for python 2.x.
 
  http://www.pythoncentral.io/how-to-use-pythons-xrange-and-range/
 
  Distros that which still use 2.x  series as default python interpreter 
  going to 3.x.
 
  regargs.
  ___
  mesa-dev mailing list
  mesa-dev@lists.freedesktop.org
  http://lists.freedesktop.org/mailman/listinfo/mesa-dev
 
 Yes... if you look at the part of the patch that modifies Makefile.am,
 it's actually called with $(PYTHON) which will be python2 on distro's
 where python3 is the default. Unfortunately, on some distros there's
 no python2, so #!/usr/bin/env python2 won't work either... you can't
 please everyone. So the line you mentioned is more customary than
 anything else.

While I agree with you Conner, when I did a survey for piglit I found
that OSX was the only major OS that didn't provide a python2 symlink,
Arch, Gentoo, Debian, Fedora, and CentOS all did, and Windows doesn't
care about a shbang.

I would actually be in favor of using /usr/bin/python2 anyway,
just because it makes it clear we're using python2, but ultimately
you're right and it doesn't really matter.

It's also been on my todo list to get all of the python in mesa working
with both python2 and python3, but I have too many things to get done.

Dylan

 ___
 mesa-dev mailing list
 mesa-dev@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/mesa-dev
 


signature.asc
Description: This is a digitally signed message part.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/5] nir: use Python to autogenerate opcode information

2015-01-17 Thread ahmad
thats make sense.

regards.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


Re: [Mesa-dev] [PATCH 2/5] nir: use Python to autogenerate opcode information

2015-01-17 Thread ahmad
hi.

#! /usr/bin/env python corresponds python 3.x series for some  major distro 
(arch,fedora ...) and python 2.x for some others. 

python 2.x and python 3.x are not source compatible each other.

python 3.x not contains xrange funcion anymore.

range vs xrange only meaningfull for python 2.x.

http://www.pythoncentral.io/how-to-use-pythons-xrange-and-range/

Distros that which still use 2.x  series as default python interpreter going to 
3.x. 

regargs.
___
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev


[Mesa-dev] [PATCH 2/5] nir: use Python to autogenerate opcode information

2015-01-16 Thread Connor Abbott
Before, we used a system where a file, nir_opcodes.h, defined some macros that
were included to generate the enum values and the nir_op_infos structure. This
worked pretty well, but for development the error messages were never very
useful, Python tools couldn't understand the opcode list, and it was difficult
to use nir_opcodes.h to do other things like autogenerate a builder API. Now, we
store opcode information in nir_opcodes.py, and we have nir_opcodes_c.py to
generate the old nir_opcodes.c and nir_opcodes_h.py to generate nir_opcodes.h,
which contains all the enum names and gets included into nir.h like before.  In
addition to solving the above problems, using Python and Mako to generate
everything means that it's much easier to add keep information centralized as we
add new things like constant propagation that require per-opcode information.

Signed-off-by: Connor Abbott cwabbo...@gmail.com
---
 src/glsl/Makefile.am  |  15 +-
 src/glsl/Makefile.sources |   6 +-
 src/glsl/nir/.gitignore   |   2 +
 src/glsl/nir/nir.h|   9 -
 src/glsl/nir/nir_opcodes.c|  46 --
 src/glsl/nir/nir_opcodes.h| 366 
 src/glsl/nir/nir_opcodes.py   | 377 ++
 src/glsl/nir/nir_opcodes_c.py |  56 +++
 src/glsl/nir/nir_opcodes_h.py |  39 +
 9 files changed, 491 insertions(+), 425 deletions(-)
 delete mode 100644 src/glsl/nir/nir_opcodes.c
 delete mode 100644 src/glsl/nir/nir_opcodes.h
 create mode 100644 src/glsl/nir/nir_opcodes.py
 create mode 100644 src/glsl/nir/nir_opcodes_c.py
 create mode 100644 src/glsl/nir/nir_opcodes_h.py

diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am
index b2b74a9..b2fe16a 100644
--- a/src/glsl/Makefile.am
+++ b/src/glsl/Makefile.am
@@ -27,6 +27,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src/glsl/glcpp \
-I$(top_srcdir)/src/glsl/nir \
-I$(top_srcdir)/src/gtest/include \
+   -I$(top_builddir)/src/glsl/nir \
$(DEFINES)
 AM_CFLAGS = $(VISIBILITY_CFLAGS)
 AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS)
@@ -207,7 +208,9 @@ BUILT_SOURCES = 
\
glsl_lexer.cpp  \
glcpp/glcpp-parse.c \
glcpp/glcpp-lex.c   \
-   nir/nir_opt_algebraic.c
+   nir/nir_opt_algebraic.c \
+   nir/nir_opcodes.h   \
+   nir/nir_opcodes.c
 CLEANFILES =   \
glcpp/glcpp-parse.h \
glsl_parser.h   \
@@ -223,3 +226,13 @@ dist-hook:
 nir/nir_opt_algebraic.c: nir/nir_opt_algebraic.py nir/nir_algebraic.py
$(MKDIR_P) nir; \
$(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opt_algebraic.py  $@
+
+nir/nir_opcodes.h: nir/nir_opcodes.py nir/nir_opcodes_h.py
+   $(MKDIR_P) nir; \
+   $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opcodes_h.py  $@
+
+nir/nir_opcodes.c: nir/nir_opcodes.py nir/nir_opcodes_c.py
+   $(MKDIR_P) nir; \
+   $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opcodes_c.py  $@
+
+nir/nir.h: nir/nir_opcodes.h
diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index a951ca7..03b4f2e 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -14,7 +14,9 @@ LIBGLCPP_GENERATED_FILES = \
$(GLSL_BUILDDIR)/glcpp/glcpp-parse.c
 
 NIR_GENERATED_FILES = \
-   $(GLSL_BUILDDIR)/nir/nir_opt_algebraic.c
+   $(GLSL_BUILDDIR)/nir/nir_opt_algebraic.c \
+   $(GLSL_BUILDDIR)/nir/nir_opcodes.h \
+   $(GLSL_BUILDDIR)/nir/nir_opcodes.c
 
 NIR_FILES = \
$(GLSL_SRCDIR)/nir/nir.c \
@@ -35,8 +37,6 @@ NIR_FILES = \
$(GLSL_SRCDIR)/nir/nir_lower_var_copies.c \
$(GLSL_SRCDIR)/nir/nir_lower_vec_to_movs.c \
$(GLSL_SRCDIR)/nir/nir_metadata.c \
-   $(GLSL_SRCDIR)/nir/nir_opcodes.c \
-   $(GLSL_SRCDIR)/nir/nir_opcodes.h \
$(GLSL_SRCDIR)/nir/nir_opt_constant_folding.c \
$(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
$(GLSL_SRCDIR)/nir/nir_opt_cse.c \
diff --git a/src/glsl/nir/.gitignore b/src/glsl/nir/.gitignore
index 6d954fe..4c28193 100644
--- a/src/glsl/nir/.gitignore
+++ b/src/glsl/nir/.gitignore
@@ -1 +1,3 @@
 nir_opt_algebraic.c
+nir_opcodes.c
+nir_opcodes.h
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index d5fa0e3..890113c 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -532,20 +532,11 @@ typedef struct {
unsigned write_mask : 4; /* ignored if dest.is_ssa is true */
 } nir_alu_dest;
 
-#define OPCODE(name, num_inputs, output_size, output_type, \
-   input_sizes, input_types, algebraic_props) \
-   nir_op_##name,
-
-#define LAST_OPCODE(name) nir_last_opcode = 

Re: [Mesa-dev] [PATCH 2/5] nir: use Python to autogenerate opcode information

2015-01-16 Thread Dylan Baker
Hi Conner, I have a couple of things you should change, and a suggestion
for you below, hopefully it all makes sense.

On Friday, January 16, 2015 04:46:07 PM Connor Abbott wrote:
 Before, we used a system where a file, nir_opcodes.h, defined some macros that
 were included to generate the enum values and the nir_op_infos structure. This
 worked pretty well, but for development the error messages were never very
 useful, Python tools couldn't understand the opcode list, and it was difficult
 to use nir_opcodes.h to do other things like autogenerate a builder API. Now, 
 we
 store opcode information in nir_opcodes.py, and we have nir_opcodes_c.py to
 generate the old nir_opcodes.c and nir_opcodes_h.py to generate nir_opcodes.h,
 which contains all the enum names and gets included into nir.h like before.  
 In
 addition to solving the above problems, using Python and Mako to generate
 everything means that it's much easier to add keep information centralized as 
 we
 add new things like constant propagation that require per-opcode information.
 
 Signed-off-by: Connor Abbott cwabbo...@gmail.com
 ---
  src/glsl/Makefile.am  |  15 +-
  src/glsl/Makefile.sources |   6 +-
  src/glsl/nir/.gitignore   |   2 +
  src/glsl/nir/nir.h|   9 -
  src/glsl/nir/nir_opcodes.c|  46 --
  src/glsl/nir/nir_opcodes.h| 366 
  src/glsl/nir/nir_opcodes.py   | 377 
 ++
  src/glsl/nir/nir_opcodes_c.py |  56 +++
  src/glsl/nir/nir_opcodes_h.py |  39 +
  9 files changed, 491 insertions(+), 425 deletions(-)
  delete mode 100644 src/glsl/nir/nir_opcodes.c
  delete mode 100644 src/glsl/nir/nir_opcodes.h
  create mode 100644 src/glsl/nir/nir_opcodes.py
  create mode 100644 src/glsl/nir/nir_opcodes_c.py
  create mode 100644 src/glsl/nir/nir_opcodes_h.py
 
 diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am
 index b2b74a9..b2fe16a 100644
 --- a/src/glsl/Makefile.am
 +++ b/src/glsl/Makefile.am
 @@ -27,6 +27,7 @@ AM_CPPFLAGS = \
   -I$(top_srcdir)/src/glsl/glcpp \
   -I$(top_srcdir)/src/glsl/nir \
   -I$(top_srcdir)/src/gtest/include \
 + -I$(top_builddir)/src/glsl/nir \
   $(DEFINES)
  AM_CFLAGS = $(VISIBILITY_CFLAGS)
  AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS)
 @@ -207,7 +208,9 @@ BUILT_SOURCES =   
 \
   glsl_lexer.cpp  \
   glcpp/glcpp-parse.c \
   glcpp/glcpp-lex.c   \
 - nir/nir_opt_algebraic.c
 + nir/nir_opt_algebraic.c \
 + nir/nir_opcodes.h   \
 + nir/nir_opcodes.c
  CLEANFILES = \
   glcpp/glcpp-parse.h \
   glsl_parser.h   \
 @@ -223,3 +226,13 @@ dist-hook:
  nir/nir_opt_algebraic.c: nir/nir_opt_algebraic.py nir/nir_algebraic.py
   $(MKDIR_P) nir; \
   $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opt_algebraic.py  $@
 +
 +nir/nir_opcodes.h: nir/nir_opcodes.py nir/nir_opcodes_h.py
 + $(MKDIR_P) nir; \
 + $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opcodes_h.py  $@
 +
 +nir/nir_opcodes.c: nir/nir_opcodes.py nir/nir_opcodes_c.py
 + $(MKDIR_P) nir; \
 + $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opcodes_c.py  $@
 +
 +nir/nir.h: nir/nir_opcodes.h
 diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
 index a951ca7..03b4f2e 100644
 --- a/src/glsl/Makefile.sources
 +++ b/src/glsl/Makefile.sources
 @@ -14,7 +14,9 @@ LIBGLCPP_GENERATED_FILES = \
   $(GLSL_BUILDDIR)/glcpp/glcpp-parse.c
  
  NIR_GENERATED_FILES = \
 - $(GLSL_BUILDDIR)/nir/nir_opt_algebraic.c
 + $(GLSL_BUILDDIR)/nir/nir_opt_algebraic.c \
 + $(GLSL_BUILDDIR)/nir/nir_opcodes.h \
 + $(GLSL_BUILDDIR)/nir/nir_opcodes.c
  
  NIR_FILES = \
   $(GLSL_SRCDIR)/nir/nir.c \
 @@ -35,8 +37,6 @@ NIR_FILES = \
   $(GLSL_SRCDIR)/nir/nir_lower_var_copies.c \
   $(GLSL_SRCDIR)/nir/nir_lower_vec_to_movs.c \
   $(GLSL_SRCDIR)/nir/nir_metadata.c \
 - $(GLSL_SRCDIR)/nir/nir_opcodes.c \
 - $(GLSL_SRCDIR)/nir/nir_opcodes.h \
   $(GLSL_SRCDIR)/nir/nir_opt_constant_folding.c \
   $(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
   $(GLSL_SRCDIR)/nir/nir_opt_cse.c \
 diff --git a/src/glsl/nir/.gitignore b/src/glsl/nir/.gitignore
 index 6d954fe..4c28193 100644
 --- a/src/glsl/nir/.gitignore
 +++ b/src/glsl/nir/.gitignore
 @@ -1 +1,3 @@
  nir_opt_algebraic.c
 +nir_opcodes.c
 +nir_opcodes.h
 diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
 index d5fa0e3..890113c 100644
 --- a/src/glsl/nir/nir.h
 +++ b/src/glsl/nir/nir.h
 @@ -532,20 +532,11 @@ typedef struct {
 unsigned write_mask : 4; /* ignored if dest.is_ssa 

Re: [Mesa-dev] [PATCH 2/5] nir: use Python to autogenerate opcode information

2015-01-16 Thread Connor Abbott
Hi Dylan,

On Fri, Jan 16, 2015 at 7:01 PM, Dylan Baker baker.dyla...@gmail.com wrote:
 Hi Conner, I have a couple of things you should change, and a suggestion
 for you below, hopefully it all makes sense.

 On Friday, January 16, 2015 04:46:07 PM Connor Abbott wrote:
 Before, we used a system where a file, nir_opcodes.h, defined some macros 
 that
 were included to generate the enum values and the nir_op_infos structure. 
 This
 worked pretty well, but for development the error messages were never very
 useful, Python tools couldn't understand the opcode list, and it was 
 difficult
 to use nir_opcodes.h to do other things like autogenerate a builder API. 
 Now, we
 store opcode information in nir_opcodes.py, and we have nir_opcodes_c.py to
 generate the old nir_opcodes.c and nir_opcodes_h.py to generate 
 nir_opcodes.h,
 which contains all the enum names and gets included into nir.h like before.  
 In
 addition to solving the above problems, using Python and Mako to generate
 everything means that it's much easier to add keep information centralized 
 as we
 add new things like constant propagation that require per-opcode information.

 Signed-off-by: Connor Abbott cwabbo...@gmail.com
 ---
  src/glsl/Makefile.am  |  15 +-
  src/glsl/Makefile.sources |   6 +-
  src/glsl/nir/.gitignore   |   2 +
  src/glsl/nir/nir.h|   9 -
  src/glsl/nir/nir_opcodes.c|  46 --
  src/glsl/nir/nir_opcodes.h| 366 
  src/glsl/nir/nir_opcodes.py   | 377 
 ++
  src/glsl/nir/nir_opcodes_c.py |  56 +++
  src/glsl/nir/nir_opcodes_h.py |  39 +
  9 files changed, 491 insertions(+), 425 deletions(-)
  delete mode 100644 src/glsl/nir/nir_opcodes.c
  delete mode 100644 src/glsl/nir/nir_opcodes.h
  create mode 100644 src/glsl/nir/nir_opcodes.py
  create mode 100644 src/glsl/nir/nir_opcodes_c.py
  create mode 100644 src/glsl/nir/nir_opcodes_h.py

 diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am
 index b2b74a9..b2fe16a 100644
 --- a/src/glsl/Makefile.am
 +++ b/src/glsl/Makefile.am
 @@ -27,6 +27,7 @@ AM_CPPFLAGS = \
   -I$(top_srcdir)/src/glsl/glcpp \
   -I$(top_srcdir)/src/glsl/nir \
   -I$(top_srcdir)/src/gtest/include \
 + -I$(top_builddir)/src/glsl/nir \
   $(DEFINES)
  AM_CFLAGS = $(VISIBILITY_CFLAGS)
  AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS)
 @@ -207,7 +208,9 @@ BUILT_SOURCES =  
  \
   glsl_lexer.cpp  \
   glcpp/glcpp-parse.c \
   glcpp/glcpp-lex.c   \
 - nir/nir_opt_algebraic.c
 + nir/nir_opt_algebraic.c \
 + nir/nir_opcodes.h   \
 + nir/nir_opcodes.c
  CLEANFILES = \
   glcpp/glcpp-parse.h \
   glsl_parser.h   \
 @@ -223,3 +226,13 @@ dist-hook:
  nir/nir_opt_algebraic.c: nir/nir_opt_algebraic.py nir/nir_algebraic.py
   $(MKDIR_P) nir; \
   $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opt_algebraic.py  $@
 +
 +nir/nir_opcodes.h: nir/nir_opcodes.py nir/nir_opcodes_h.py
 + $(MKDIR_P) nir; \
 + $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opcodes_h.py  $@
 +
 +nir/nir_opcodes.c: nir/nir_opcodes.py nir/nir_opcodes_c.py
 + $(MKDIR_P) nir; \
 + $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opcodes_c.py  $@
 +
 +nir/nir.h: nir/nir_opcodes.h
 diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
 index a951ca7..03b4f2e 100644
 --- a/src/glsl/Makefile.sources
 +++ b/src/glsl/Makefile.sources
 @@ -14,7 +14,9 @@ LIBGLCPP_GENERATED_FILES = \
   $(GLSL_BUILDDIR)/glcpp/glcpp-parse.c

  NIR_GENERATED_FILES = \
 - $(GLSL_BUILDDIR)/nir/nir_opt_algebraic.c
 + $(GLSL_BUILDDIR)/nir/nir_opt_algebraic.c \
 + $(GLSL_BUILDDIR)/nir/nir_opcodes.h \
 + $(GLSL_BUILDDIR)/nir/nir_opcodes.c

  NIR_FILES = \
   $(GLSL_SRCDIR)/nir/nir.c \
 @@ -35,8 +37,6 @@ NIR_FILES = \
   $(GLSL_SRCDIR)/nir/nir_lower_var_copies.c \
   $(GLSL_SRCDIR)/nir/nir_lower_vec_to_movs.c \
   $(GLSL_SRCDIR)/nir/nir_metadata.c \
 - $(GLSL_SRCDIR)/nir/nir_opcodes.c \
 - $(GLSL_SRCDIR)/nir/nir_opcodes.h \
   $(GLSL_SRCDIR)/nir/nir_opt_constant_folding.c \
   $(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
   $(GLSL_SRCDIR)/nir/nir_opt_cse.c \
 diff --git a/src/glsl/nir/.gitignore b/src/glsl/nir/.gitignore
 index 6d954fe..4c28193 100644
 --- a/src/glsl/nir/.gitignore
 +++ b/src/glsl/nir/.gitignore
 @@ -1 +1,3 @@
  nir_opt_algebraic.c
 +nir_opcodes.c
 +nir_opcodes.h
 diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
 index d5fa0e3..890113c 100644
 --- a/src/glsl/nir/nir.h
 +++ b/src/glsl/nir/nir.h
 @@ 

Re: [Mesa-dev] [PATCH 2/5] nir: use Python to autogenerate opcode information

2015-01-16 Thread Dylan Baker
On Friday, January 16, 2015 10:18:43 PM Connor Abbott wrote:
 Hi Dylan,
 
 On Fri, Jan 16, 2015 at 7:01 PM, Dylan Baker baker.dyla...@gmail.com wrote:
  Hi Conner, I have a couple of things you should change, and a suggestion
  for you below, hopefully it all makes sense.
 
  On Friday, January 16, 2015 04:46:07 PM Connor Abbott wrote:
  Before, we used a system where a file, nir_opcodes.h, defined some macros 
  that
  were included to generate the enum values and the nir_op_infos structure. 
  This
  worked pretty well, but for development the error messages were never very
  useful, Python tools couldn't understand the opcode list, and it was 
  difficult
  to use nir_opcodes.h to do other things like autogenerate a builder API. 
  Now, we
  store opcode information in nir_opcodes.py, and we have nir_opcodes_c.py to
  generate the old nir_opcodes.c and nir_opcodes_h.py to generate 
  nir_opcodes.h,
  which contains all the enum names and gets included into nir.h like 
  before.  In
  addition to solving the above problems, using Python and Mako to generate
  everything means that it's much easier to add keep information centralized 
  as we
  add new things like constant propagation that require per-opcode 
  information.
 
  Signed-off-by: Connor Abbott cwabbo...@gmail.com
  ---
   src/glsl/Makefile.am  |  15 +-
   src/glsl/Makefile.sources |   6 +-
   src/glsl/nir/.gitignore   |   2 +
   src/glsl/nir/nir.h|   9 -
   src/glsl/nir/nir_opcodes.c|  46 --
   src/glsl/nir/nir_opcodes.h| 366 
  
   src/glsl/nir/nir_opcodes.py   | 377 
  ++
   src/glsl/nir/nir_opcodes_c.py |  56 +++
   src/glsl/nir/nir_opcodes_h.py |  39 +
   9 files changed, 491 insertions(+), 425 deletions(-)
   delete mode 100644 src/glsl/nir/nir_opcodes.c
   delete mode 100644 src/glsl/nir/nir_opcodes.h
   create mode 100644 src/glsl/nir/nir_opcodes.py
   create mode 100644 src/glsl/nir/nir_opcodes_c.py
   create mode 100644 src/glsl/nir/nir_opcodes_h.py
 
  diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am
  index b2b74a9..b2fe16a 100644
  --- a/src/glsl/Makefile.am
  +++ b/src/glsl/Makefile.am
  @@ -27,6 +27,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src/glsl/glcpp \
-I$(top_srcdir)/src/glsl/nir \
-I$(top_srcdir)/src/gtest/include \
  + -I$(top_builddir)/src/glsl/nir \
$(DEFINES)
   AM_CFLAGS = $(VISIBILITY_CFLAGS)
   AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS)
  @@ -207,7 +208,9 @@ BUILT_SOURCES =
 \
glsl_lexer.cpp  \
glcpp/glcpp-parse.c \
glcpp/glcpp-lex.c   \
  - nir/nir_opt_algebraic.c
  + nir/nir_opt_algebraic.c \
  + nir/nir_opcodes.h   \
  + nir/nir_opcodes.c
   CLEANFILES = \
glcpp/glcpp-parse.h \
glsl_parser.h   \
  @@ -223,3 +226,13 @@ dist-hook:
   nir/nir_opt_algebraic.c: nir/nir_opt_algebraic.py nir/nir_algebraic.py
$(MKDIR_P) nir; \
$(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opt_algebraic.py  $@
  +
  +nir/nir_opcodes.h: nir/nir_opcodes.py nir/nir_opcodes_h.py
  + $(MKDIR_P) nir; \
  + $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opcodes_h.py  $@
  +
  +nir/nir_opcodes.c: nir/nir_opcodes.py nir/nir_opcodes_c.py
  + $(MKDIR_P) nir; \
  + $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opcodes_c.py  $@
  +
  +nir/nir.h: nir/nir_opcodes.h
  diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
  index a951ca7..03b4f2e 100644
  --- a/src/glsl/Makefile.sources
  +++ b/src/glsl/Makefile.sources
  @@ -14,7 +14,9 @@ LIBGLCPP_GENERATED_FILES = \
$(GLSL_BUILDDIR)/glcpp/glcpp-parse.c
 
   NIR_GENERATED_FILES = \
  - $(GLSL_BUILDDIR)/nir/nir_opt_algebraic.c
  + $(GLSL_BUILDDIR)/nir/nir_opt_algebraic.c \
  + $(GLSL_BUILDDIR)/nir/nir_opcodes.h \
  + $(GLSL_BUILDDIR)/nir/nir_opcodes.c
 
   NIR_FILES = \
$(GLSL_SRCDIR)/nir/nir.c \
  @@ -35,8 +37,6 @@ NIR_FILES = \
$(GLSL_SRCDIR)/nir/nir_lower_var_copies.c \
$(GLSL_SRCDIR)/nir/nir_lower_vec_to_movs.c \
$(GLSL_SRCDIR)/nir/nir_metadata.c \
  - $(GLSL_SRCDIR)/nir/nir_opcodes.c \
  - $(GLSL_SRCDIR)/nir/nir_opcodes.h \
$(GLSL_SRCDIR)/nir/nir_opt_constant_folding.c \
$(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
$(GLSL_SRCDIR)/nir/nir_opt_cse.c \
  diff --git a/src/glsl/nir/.gitignore b/src/glsl/nir/.gitignore
  index 6d954fe..4c28193 100644
  --- a/src/glsl/nir/.gitignore
  +++ b/src/glsl/nir/.gitignore
  @@ -1 +1,3 @@
   

Re: [Mesa-dev] [PATCH 2/5] nir: use Python to autogenerate opcode information

2015-01-16 Thread Connor Abbott
On Fri, Jan 16, 2015 at 10:48 PM, Dylan Baker baker.dyla...@gmail.com wrote:
 On Friday, January 16, 2015 10:18:43 PM Connor Abbott wrote:
 Hi Dylan,

 On Fri, Jan 16, 2015 at 7:01 PM, Dylan Baker baker.dyla...@gmail.com wrote:
  Hi Conner, I have a couple of things you should change, and a suggestion
  for you below, hopefully it all makes sense.
 
  On Friday, January 16, 2015 04:46:07 PM Connor Abbott wrote:
  Before, we used a system where a file, nir_opcodes.h, defined some macros 
  that
  were included to generate the enum values and the nir_op_infos structure. 
  This
  worked pretty well, but for development the error messages were never very
  useful, Python tools couldn't understand the opcode list, and it was 
  difficult
  to use nir_opcodes.h to do other things like autogenerate a builder API. 
  Now, we
  store opcode information in nir_opcodes.py, and we have nir_opcodes_c.py 
  to
  generate the old nir_opcodes.c and nir_opcodes_h.py to generate 
  nir_opcodes.h,
  which contains all the enum names and gets included into nir.h like 
  before.  In
  addition to solving the above problems, using Python and Mako to generate
  everything means that it's much easier to add keep information 
  centralized as we
  add new things like constant propagation that require per-opcode 
  information.
 
  Signed-off-by: Connor Abbott cwabbo...@gmail.com
  ---
   src/glsl/Makefile.am  |  15 +-
   src/glsl/Makefile.sources |   6 +-
   src/glsl/nir/.gitignore   |   2 +
   src/glsl/nir/nir.h|   9 -
   src/glsl/nir/nir_opcodes.c|  46 --
   src/glsl/nir/nir_opcodes.h| 366 
  
   src/glsl/nir/nir_opcodes.py   | 377 
  ++
   src/glsl/nir/nir_opcodes_c.py |  56 +++
   src/glsl/nir/nir_opcodes_h.py |  39 +
   9 files changed, 491 insertions(+), 425 deletions(-)
   delete mode 100644 src/glsl/nir/nir_opcodes.c
   delete mode 100644 src/glsl/nir/nir_opcodes.h
   create mode 100644 src/glsl/nir/nir_opcodes.py
   create mode 100644 src/glsl/nir/nir_opcodes_c.py
   create mode 100644 src/glsl/nir/nir_opcodes_h.py
 
  diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am
  index b2b74a9..b2fe16a 100644
  --- a/src/glsl/Makefile.am
  +++ b/src/glsl/Makefile.am
  @@ -27,6 +27,7 @@ AM_CPPFLAGS = \
-I$(top_srcdir)/src/glsl/glcpp \
-I$(top_srcdir)/src/glsl/nir \
-I$(top_srcdir)/src/gtest/include \
  + -I$(top_builddir)/src/glsl/nir \
$(DEFINES)
   AM_CFLAGS = $(VISIBILITY_CFLAGS)
   AM_CXXFLAGS = $(VISIBILITY_CXXFLAGS)
  @@ -207,7 +208,9 @@ BUILT_SOURCES =   
  \
glsl_lexer.cpp  \
glcpp/glcpp-parse.c \
glcpp/glcpp-lex.c   \
  - nir/nir_opt_algebraic.c
  + nir/nir_opt_algebraic.c \
  + nir/nir_opcodes.h   \
  + nir/nir_opcodes.c
   CLEANFILES = \
glcpp/glcpp-parse.h \
glsl_parser.h   \
  @@ -223,3 +226,13 @@ dist-hook:
   nir/nir_opt_algebraic.c: nir/nir_opt_algebraic.py nir/nir_algebraic.py
$(MKDIR_P) nir; \
$(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opt_algebraic.py  $@
  +
  +nir/nir_opcodes.h: nir/nir_opcodes.py nir/nir_opcodes_h.py
  + $(MKDIR_P) nir; \
  + $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opcodes_h.py  $@
  +
  +nir/nir_opcodes.c: nir/nir_opcodes.py nir/nir_opcodes_c.py
  + $(MKDIR_P) nir; \
  + $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/nir/nir_opcodes_c.py  $@
  +
  +nir/nir.h: nir/nir_opcodes.h
  diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
  index a951ca7..03b4f2e 100644
  --- a/src/glsl/Makefile.sources
  +++ b/src/glsl/Makefile.sources
  @@ -14,7 +14,9 @@ LIBGLCPP_GENERATED_FILES = \
$(GLSL_BUILDDIR)/glcpp/glcpp-parse.c
 
   NIR_GENERATED_FILES = \
  - $(GLSL_BUILDDIR)/nir/nir_opt_algebraic.c
  + $(GLSL_BUILDDIR)/nir/nir_opt_algebraic.c \
  + $(GLSL_BUILDDIR)/nir/nir_opcodes.h \
  + $(GLSL_BUILDDIR)/nir/nir_opcodes.c
 
   NIR_FILES = \
$(GLSL_SRCDIR)/nir/nir.c \
  @@ -35,8 +37,6 @@ NIR_FILES = \
$(GLSL_SRCDIR)/nir/nir_lower_var_copies.c \
$(GLSL_SRCDIR)/nir/nir_lower_vec_to_movs.c \
$(GLSL_SRCDIR)/nir/nir_metadata.c \
  - $(GLSL_SRCDIR)/nir/nir_opcodes.c \
  - $(GLSL_SRCDIR)/nir/nir_opcodes.h \
$(GLSL_SRCDIR)/nir/nir_opt_constant_folding.c \
$(GLSL_SRCDIR)/nir/nir_opt_copy_propagate.c \
$(GLSL_SRCDIR)/nir/nir_opt_cse.c \
  diff --git a/src/glsl/nir/.gitignore b/src/glsl/nir/.gitignore
  index 6d954fe..4c28193 100644
  ---