Commit b04430ef authored by Zack Rusin's avatar Zack Rusin

Introduce linux-llvm target. Remove the llvm code from the default build for now.

Cleanup some of the debugging output.
parent ba887517
......@@ -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 \
......
......@@ -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
......
# 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
......@@ -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;
}
}
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment