summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Rusin <zack@tungstengraphics.com>2007-10-22 11:00:28 -0400
committerZack Rusin <zack@tungstengraphics.com>2007-10-24 11:21:04 -0400
commitb04430efd963ca541c435c6c1007feccf5474040 (patch)
treeb1ecf8596d3d48463be58698b61445654b44a304
parentba887517160ab2b5a70e01723ee649db1554775b (diff)
Introduce linux-llvm target. Remove the llvm code from the default build for now.
Cleanup some of the debugging output.
-rw-r--r--Makefile1
-rw-r--r--configs/default25
-rw-r--r--configs/linux-llvm31
-rw-r--r--src/mesa/pipe/llvm/llvmtgsi.cpp50
-rw-r--r--src/mesa/pipe/llvm/llvmtgsi.h11
5 files changed, 78 insertions, 40 deletions
diff --git a/Makefile b/Makefile
index a058e9839f..c4ffea85a2 100644
--- a/Makefile
+++ b/Makefile
@@ -112,6 +112,7 @@ linux-ia64-icc \
linux-ia64-icc-static \
linux-icc \
linux-icc-static \
+linux-llvm \
linux-osmesa \
linux-osmesa16 \
linux-osmesa16-static \
diff --git a/configs/default b/configs/default
index bb8f9a1808..9379833a9c 100644
--- a/configs/default
+++ b/configs/default
@@ -40,6 +40,8 @@ GLUT_LIB = glut
GLW_LIB = GLw
OSMESA_LIB = OSMesa
+LLVM_CFLAGS=-DMESA_NO_LLVM=1
+LLVM_CXXFLAGS=-DMESA_NO_LLVM=1
# Library names (actual file names)
GL_LIB_NAME = lib$(GL_LIB).so
@@ -65,30 +67,9 @@ DRIVER_DIRS = x11 osmesa
# Which subdirs under $(TOP)/progs/ to enter:
PROGRAM_DIRS = demos redbook samples glsl xdemos
-LLVM_VERSION := $(shell llvm-config --version)
-
-ifeq ($(LLVM_VERSION),)
- $(warning Could not find LLVM! Make Sure 'llvm-config' is in the path)
- MESA_NO_LLVM=1
-else
- MESA_NO_LLVM=0
- $(info Using LLVM version: $(LLVM_VERSION))
-endif
-
-ifeq ($(MESA_NO_LLVM),0)
-# LLVM_CFLAGS=`llvm-config --cflags` -DMESA_NO_LLVM=0
- LLVM_CFLAGS=-DMESA_NO_LLVM=0
- LLVM_CXXFLAGS=`llvm-config --cxxflags` -DMESA_NO_LLVM=0 -Wno-long-long
- LLVM_LDFLAGS=`llvm-config --ldflags`
- LLVM_LIBS=`llvm-config --libs`
-else
- LLVM_CFLAGS=-DMESA_NO_LLVM=1
- LLVM_CXXFLAGS=-DMESA_NO_LLVM=1
-endif
-
# Library/program dependencies
#EXTRA_LIB_PATH ?=
-GL_LIB_DEPS = $(LLVM_LDFLAGS) $(LLVM_LIBS) $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread
+GL_LIB_DEPS = $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread
OSMESA_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB)
GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -lm
GLUT_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GLU_LIB) -l$(GL_LIB) $(EXTRA_LIB_PATH) -lX11 -lXmu -lXt -lXi -lm
diff --git a/configs/linux-llvm b/configs/linux-llvm
new file mode 100644
index 0000000000..addefaa511
--- /dev/null
+++ b/configs/linux-llvm
@@ -0,0 +1,31 @@
+# Configuration for debugging on Linux
+
+include $(TOP)/configs/linux
+
+CONFIG_NAME = linux-debug
+
+OPT_FLAGS = -g -ansi -pedantic
+DEFINES += -DDEBUG -DDEBUG_MATH
+
+LLVM_VERSION := $(shell llvm-config --version)
+
+ifeq ($(LLVM_VERSION),)
+ $(warning Could not find LLVM! Make Sure 'llvm-config' is in the path)
+ MESA_NO_LLVM=1
+else
+ MESA_NO_LLVM=0
+ $(info Using LLVM version: $(LLVM_VERSION))
+endif
+
+ifeq ($(MESA_NO_LLVM),0)
+# LLVM_CFLAGS=`llvm-config --cflags` -DMESA_NO_LLVM=0
+ LLVM_CFLAGS=-DMESA_NO_LLVM=0
+ LLVM_CXXFLAGS=`llvm-config --cxxflags` -DMESA_NO_LLVM=0 -Wno-long-long
+ LLVM_LDFLAGS=`llvm-config --ldflags`
+ LLVM_LIBS=`llvm-config --libs`
+else
+ LLVM_CFLAGS=-DMESA_NO_LLVM=1
+ LLVM_CXXFLAGS=-DMESA_NO_LLVM=1
+endif
+
+GL_LIB_DEPS = $(LLVM_LDFLAGS) $(LLVM_LIBS) $(EXTRA_LIB_PATH) -lX11 -lXext -lm -lpthread
diff --git a/src/mesa/pipe/llvm/llvmtgsi.cpp b/src/mesa/pipe/llvm/llvmtgsi.cpp
index 00f8b86efc..e1bb281a94 100644
--- a/src/mesa/pipe/llvm/llvmtgsi.cpp
+++ b/src/mesa/pipe/llvm/llvmtgsi.cpp
@@ -33,9 +33,17 @@
#include <llvm/Bitcode/ReaderWriter.h>
#include <sstream>
+#include <fstream>
#include <iostream>
+struct ga_llvm_prog {
+ void *module;
+ void *function;
+ int num_consts;
+ int id;
+};
+
using namespace llvm;
#include "llvm_base_shader.cpp"
@@ -134,7 +142,7 @@ translate_instruction(llvm::Module *module,
inputs[1] = 0;
inputs[2] = 0;
inputs[3] = 0;
- printf("translate instr START\n");
+
for (int i = 0; i < inst->Instruction.NumSrcRegs; ++i) {
struct tgsi_full_src_register *src = &inst->FullSrcRegisters[i];
llvm::Value *val = 0;
@@ -176,7 +184,6 @@ translate_instruction(llvm::Module *module,
/*if (inputs[0])
instr->printVector(inputs[0]);*/
llvm::Value *out = 0;
- printf("Opcode is %d\n", inst->Instruction.Opcode);
switch (inst->Instruction.Opcode) {
case TGSI_OPCODE_ARL:
break;
@@ -485,7 +492,6 @@ translate_instruction(llvm::Module *module,
case TGSI_OPCODE_KIL:
break;
case TGSI_OPCODE_END:
- printf("translate instr END\n");
return;
break;
default:
@@ -525,7 +531,6 @@ translate_instruction(llvm::Module *module,
fprintf(stderr, "ERROR: unsupported LLVM destination!");
}
}
- printf("translate instr END\n");
}
static llvm::Module *
@@ -590,10 +595,6 @@ tgsi_to_llvm(struct ga_llvm_prog *prog, const struct tgsi_token *tokens)
tgsi_parse_free(&parse);
prog->num_consts = storage.numConsts();
-
- std::cout<<"XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"<<std::endl;
- std::cout<<*mod<<std::endl;
- std::cout<<"YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"<<std::endl;
return mod;
}
@@ -605,9 +606,7 @@ ga_llvm_from_tgsi(struct pipe_context *pipe, const struct tgsi_token *tokens)
struct ga_llvm_prog *ga_llvm =
(struct ga_llvm_prog *)malloc(sizeof(struct ga_llvm_prog));
ga_llvm->id = GLOBAL_ID;
- fprintf(stderr, "----- TGSI Start ---- \n");
tgsi_dump(tokens, 0);
- fprintf(stderr, "----- TGSI End ---- \n");
llvm::Module *mod = tgsi_to_llvm(ga_llvm, tokens);
/* Run optimization passes over it */
@@ -630,6 +629,8 @@ ga_llvm_from_tgsi(struct pipe_context *pipe, const struct tgsi_token *tokens)
Function *func = mod->getFunction("run_vertex_shader");
ga_llvm->function = ee->getPointerToFunctionOrStub(func);
+ ga_llvm_prog_dump(ga_llvm, 0);
+
return ga_llvm;
}
@@ -638,7 +639,6 @@ void ga_llvm_prog_delete(struct ga_llvm_prog *prog)
llvm::Module *mod = static_cast<llvm::Module*>(prog->module);
delete mod;
prog->module = 0;
- prog->engine = 0;
prog->function = 0;
free(prog);
}
@@ -665,3 +665,31 @@ int ga_llvm_prog_exec(struct ga_llvm_prog *prog,
return 0;
}
+
+void ga_llvm_prog_dump(struct ga_llvm_prog *prog, const char *file_prefix)
+{
+ llvm::Module *mod;
+ if (!prog || !prog->module)
+ return;
+
+ mod = static_cast<llvm::Module*>(prog->module);
+
+ if (file_prefix) {
+ std::ostringstream stream;
+ stream << file_prefix;
+ stream << prog->id;
+ stream << ".ll";
+ std::string name = stream.str();
+ std::ofstream out(name.c_str());
+ if (!out) {
+ std::cerr<<"Can't open file : "<<stream.str()<<std::endl;;
+ return;
+ }
+ out << (*mod);
+ out.close();
+ } else {
+ std::cout<<"; ---------- Start shader "<<prog->id<<std::endl;
+ std::cout<<*mod<<std::endl;
+ std::cout<<"; ---------- End shader "<<prog->id<<std::endl;
+ }
+}
diff --git a/src/mesa/pipe/llvm/llvmtgsi.h b/src/mesa/pipe/llvm/llvmtgsi.h
index 1226dc713b..2b9540f747 100644
--- a/src/mesa/pipe/llvm/llvmtgsi.h
+++ b/src/mesa/pipe/llvm/llvmtgsi.h
@@ -12,13 +12,8 @@ struct tgsi_token;
struct tgsi_sampler;
struct pipe_context;
-struct ga_llvm_prog {
- void *module;
- void *engine;
- void *function;
- int num_consts;
- int id;
-};
+struct ga_llvm_prog;
+
struct ga_llvm_prog *
ga_llvm_from_tgsi(struct pipe_context *pipe, const struct tgsi_token *tokens);
@@ -32,6 +27,8 @@ int ga_llvm_prog_exec(struct ga_llvm_prog *prog,
int num_inputs,
int num_attribs);
+void ga_llvm_prog_dump(struct ga_llvm_prog *prog, const char *file_prefix);
+
#if defined __cplusplus
} // extern "C"
#endif