[Mesa-dev] [PATCH 5/9] nir: move shader_enums.[ch] to compiler

Emil Velikov emil.l.velikov at gmail.com
Wed Nov 25 13:31:59 PST 2015


From: Emil Velikov <emil.velikov at collabora.com>

This way one can reuse it in glsl, nir or other compiler infrastructure
without pulling nir as dependency.

Signed-off-by: Emil Velikov <emil.velikov at collabora.com>
---
 Android.mk                                     |  1 +
 src/SConscript                                 |  1 +
 src/compiler/Android.mk                        | 44 ++++++++++++++++++++++++++
 src/compiler/Makefile.am                       | 21 +++++++++++-
 src/compiler/Makefile.sources                  |  4 ++-
 src/compiler/SConscript                        | 22 +++++++++++++
 src/{glsl/nir => compiler}/shader_enums.c      |  0
 src/{glsl/nir => compiler}/shader_enums.h      |  0
 src/gallium/auxiliary/nir/tgsi_to_nir.c        |  3 +-
 src/gallium/drivers/freedreno/ir3/ir3_nir.h    |  1 -
 src/gallium/drivers/freedreno/ir3/ir3_shader.h |  3 +-
 src/glsl/Android.mk                            |  2 ++
 src/glsl/Makefile.am                           |  8 ++++-
 src/glsl/Makefile.sources                      |  4 +--
 src/glsl/nir/nir.h                             |  2 +-
 src/glsl/nir/nir_print.c                       |  2 +-
 src/mesa/main/mtypes.h                         |  2 +-
 17 files changed, 108 insertions(+), 12 deletions(-)
 create mode 100644 src/compiler/Android.mk
 create mode 100644 src/compiler/SConscript
 rename src/{glsl/nir => compiler}/shader_enums.c (100%)
 rename src/{glsl/nir => compiler}/shader_enums.h (100%)

diff --git a/Android.mk b/Android.mk
index ed160fb..9b140a7 100644
--- a/Android.mk
+++ b/Android.mk
@@ -86,6 +86,7 @@ ifneq ($(strip $(MESA_GPU_DRIVERS)),)
 SUBDIRS := \
 	src/loader \
 	src/mapi \
+	src/compiler \
 	src/glsl \
 	src/mesa \
 	src/util \
diff --git a/src/SConscript b/src/SConscript
index 106b87d..8acf9b0 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -5,6 +5,7 @@ if env['platform'] == 'windows':
     SConscript('getopt/SConscript')
 
 SConscript('util/SConscript')
+SConscript('compiler/SConscript')
 SConscript('glsl/SConscript')
 
 if env['hostonly']:
diff --git a/src/compiler/Android.mk b/src/compiler/Android.mk
new file mode 100644
index 0000000..8ebd497
--- /dev/null
+++ b/src/compiler/Android.mk
@@ -0,0 +1,44 @@
+# Mesa 3-D graphics library
+#
+# Copyright (C) 2015 Intel Corporation
+#
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+
+LOCAL_PATH := $(call my-dir)
+
+include $(LOCAL_PATH)/Makefile.sources
+
+# ---------------------------------------
+# Build libmesa_compiler
+# ---------------------------------------
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := $(LIBCOMPILER_FILES)
+
+LOCAL_C_INCLUDES := \
+	$(MESA_TOP)/src/mapi \
+	$(MESA_TOP)/src/mesa \
+	$(MESA_TOP)/src/gallium/include \
+	$(MESA_TOP)/src/gallium/auxiliary
+
+LOCAL_MODULE := libmesa_compiler
+
+include $(MESA_COMMON_MK)
+include $(BUILD_STATIC_LIBRARY)
diff --git a/src/compiler/Makefile.am b/src/compiler/Makefile.am
index 8ed8205..d4d482f 100644
--- a/src/compiler/Makefile.am
+++ b/src/compiler/Makefile.am
@@ -22,4 +22,23 @@
 
 include Makefile.sources
 
-EXTRA_DIST = $(LIBCOMPILER_FILES)
+AM_CPPFLAGS = \
+	-I$(top_srcdir)/include \
+	-I$(top_srcdir)/src \
+	-I$(top_srcdir)/src/mapi \
+	-I$(top_srcdir)/src/mesa/ \
+	-I$(top_srcdir)/src/gallium/include \
+	-I$(top_srcdir)/src/gallium/auxiliary \
+	$(DEFINES)
+
+AM_CFLAGS = \
+	$(VISIBILITY_CFLAGS) \
+	$(MSVC2013_COMPAT_CFLAGS)
+
+AM_CXXFLAGS = \
+	$(VISIBILITY_CXXFLAGS) \
+	$(MSVC2013_COMPAT_CXXFLAGS)
+
+noinst_LTLIBRARIES = libcompiler.la
+
+libcompiler_la_SOURCES = $(LIBCOMPILER_FILES)
diff --git a/src/compiler/Makefile.sources b/src/compiler/Makefile.sources
index f154062..73e1771 100644
--- a/src/compiler/Makefile.sources
+++ b/src/compiler/Makefile.sources
@@ -1,2 +1,4 @@
 LIBCOMPILER_FILES = \
-	builtin_type_macros.h
+	builtin_type_macros.h \
+	shader_enums.c \
+	shader_enums.h
diff --git a/src/compiler/SConscript b/src/compiler/SConscript
new file mode 100644
index 0000000..412da0e
--- /dev/null
+++ b/src/compiler/SConscript
@@ -0,0 +1,22 @@
+Import('*')
+
+env = env.Clone()
+
+env.MSVC2013Compat()
+
+env.Prepend(CPPPATH = [
+    '#include',
+    '#src',
+    '#src/mapi',
+    '#src/mesa',
+    '#src/gallium/include',
+    '#src/gallium/auxiliary',
+])
+
+sources = env.ParseSourceList('Makefile.sources', 'LIBCOMPILER_FILES')
+
+compiler = env.ConvenienceLibrary(
+    target = 'compiler',
+    source = sources
+)
+Export('compiler')
diff --git a/src/glsl/nir/shader_enums.c b/src/compiler/shader_enums.c
similarity index 100%
rename from src/glsl/nir/shader_enums.c
rename to src/compiler/shader_enums.c
diff --git a/src/glsl/nir/shader_enums.h b/src/compiler/shader_enums.h
similarity index 100%
rename from src/glsl/nir/shader_enums.h
rename to src/compiler/shader_enums.h
diff --git a/src/gallium/auxiliary/nir/tgsi_to_nir.c b/src/gallium/auxiliary/nir/tgsi_to_nir.c
index 86c2ffa..3301175 100644
--- a/src/gallium/auxiliary/nir/tgsi_to_nir.c
+++ b/src/gallium/auxiliary/nir/tgsi_to_nir.c
@@ -22,12 +22,13 @@
  * IN THE SOFTWARE.
  */
 
+#include "compiler/shader_enums.h"
+
 #include "util/ralloc.h"
 #include "glsl/nir/nir.h"
 #include "glsl/nir/nir_control_flow.h"
 #include "glsl/nir/nir_builder.h"
 #include "glsl/list.h"
-#include "glsl/nir/shader_enums.h"
 
 #include "nir/tgsi_to_nir.h"
 #include "tgsi/tgsi_parse.h"
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_nir.h b/src/gallium/drivers/freedreno/ir3/ir3_nir.h
index 9950782..f3d3075 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_nir.h
+++ b/src/gallium/drivers/freedreno/ir3/ir3_nir.h
@@ -30,7 +30,6 @@
 #define IR3_NIR_H_
 
 #include "glsl/nir/nir.h"
-#include "glsl/nir/shader_enums.h"
 
 bool ir3_nir_lower_if_else(nir_shader *shader);
 
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_shader.h b/src/gallium/drivers/freedreno/ir3/ir3_shader.h
index 5d1cccb..d9bc768 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_shader.h
+++ b/src/gallium/drivers/freedreno/ir3/ir3_shader.h
@@ -29,8 +29,9 @@
 #ifndef IR3_SHADER_H_
 #define IR3_SHADER_H_
 
+#include "compiler/shader_enums.h"
+
 #include "pipe/p_state.h"
-#include "glsl/nir/shader_enums.h"
 
 #include "ir3.h"
 #include "disasm.h"
diff --git a/src/glsl/Android.mk b/src/glsl/Android.mk
index f63b7da..9cbb9a3 100644
--- a/src/glsl/Android.mk
+++ b/src/glsl/Android.mk
@@ -44,6 +44,8 @@ LOCAL_C_INCLUDES := \
 	$(MESA_TOP)/src/gallium/include \
 	$(MESA_TOP)/src/gallium/auxiliary
 
+LOCAL_STATIC_LIBRARIES := libmesa_compiler
+
 LOCAL_MODULE := libmesa_glsl
 
 include $(LOCAL_PATH)/Android.gen.mk
diff --git a/src/glsl/Makefile.am b/src/glsl/Makefile.am
index 33a34e4..225ec27 100644
--- a/src/glsl/Makefile.am
+++ b/src/glsl/Makefile.am
@@ -137,7 +137,10 @@ glcpp_glcpp_LDADD =					\
 	$(top_builddir)/src/libglsl_util.la		\
 	-lm
 
-libglsl_la_LIBADD = libglcpp.la
+libglsl_la_LIBADD = \
+	$(top_builddir)/src/compiler/libcompiler.la \
+	libglcpp.la
+
 libglsl_la_SOURCES =					\
 	glsl_lexer.cpp					\
 	glsl_parser.cpp					\
@@ -147,6 +150,9 @@ libglsl_la_SOURCES =					\
 	$(NIR_GENERATED_FILES)
 
 
+libnir_la_LIBADD = \
+	$(top_builddir)/src/compiler/libcompiler.la
+
 libnir_la_SOURCES =					\
 	$(NIR_FILES)					\
 	$(NIR_GENERATED_FILES)
diff --git a/src/glsl/Makefile.sources b/src/glsl/Makefile.sources
index fa6ed3c..73df60e 100644
--- a/src/glsl/Makefile.sources
+++ b/src/glsl/Makefile.sources
@@ -83,9 +83,7 @@ NIR_FILES = \
 	nir/nir_vla.h \
 	nir/nir_worklist.c \
 	nir/nir_worklist.h \
-	nir/nir_types.cpp \
-	nir/shader_enums.h \
-	nir/shader_enums.c
+	nir/nir_types.cpp
 
 # libglsl
 
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index 524717a..e69b3c8 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -35,7 +35,7 @@
 #include "util/set.h"
 #include "util/bitset.h"
 #include "nir_types.h"
-#include "shader_enums.h"
+#include "compiler/shader_enums.h"
 #include <stdio.h>
 
 #include "nir_opcodes.h"
diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c
index c98a047..de1f34c 100644
--- a/src/glsl/nir/nir_print.c
+++ b/src/glsl/nir/nir_print.c
@@ -26,7 +26,7 @@
  */
 
 #include "nir.h"
-#include "shader_enums.h"
+#include "compiler/shader_enums.h"
 #include <stdio.h>
 #include <stdlib.h>
 
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index d425571..7f0abe7 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -42,7 +42,7 @@
 #include "main/config.h"
 #include "glapi/glapi.h"
 #include "math/m_matrix.h"	/* GLmatrix */
-#include "glsl/nir/shader_enums.h"
+#include "compiler/shader_enums.h"
 #include "main/formats.h"       /* MESA_FORMAT_COUNT */
 
 
-- 
2.6.2



More information about the mesa-dev mailing list