summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShih-wei Liao <sliao@google.com>2011-07-19 07:14:38 -0700
committerShih-wei Liao <sliao@google.com>2011-07-19 07:14:38 -0700
commit0783e59a538573e2949aa558cd26e3714f9ffd7e (patch)
treec9eb68bd55ebc3e3769b50f55032c71d81c794aa
parent82a20bd6b8b3e26b04b9fcfe9933e9807177c801 (diff)
Second step in migrating to upstream API.
Change-Id: Iee0456fe7fa45b7907368580b3bada8386cf31dc
-rw-r--r--Android.mk202
-rw-r--r--src/glsl/ir_to_llvm.cpp43
-rw-r--r--src/pixelflinger2/llvm_scanline.cpp10
3 files changed, 228 insertions, 27 deletions
diff --git a/Android.mk b/Android.mk
index e69de29..d959a00 100644
--- a/Android.mk
+++ b/Android.mk
@@ -0,0 +1,202 @@
+# USE_LLVM_EXECUTIONENGINE not fully implemented
+USE_LLVM_EXECUTIONENGINE := false
+# if using libLLVMExecutionEngine,
+# need to add files to several Android.mk in external/llvm, and comment out some stuff in llvm DynamicLibrary.cpp and Intercept.cpp
+
+DEBUG_BUILD := false
+
+LOCAL_PATH := $(call my-dir)
+LLVM_ROOT_PATH := external/llvm
+
+# these are for using llvm::ExecutionEngine, also remove libbcc
+#libLLVMX86CodeGen;libLLVMX86Info;libLLVMBitReader;libLLVMSelectionDAG;libLLVMAsmPrinter;libLLVMJIT;libLLVMCodeGen;libLLVMTarget;libLLVMMC;libLLVMScalarOpts;libLLVMipo;libLLVMTransformUtils;libLLVMCore;libLLVMSupport;libLLVMSystem;libLLVMAnalysis;libLLVMInstCombine;libLLVMipa;libLLVMMCParser;libLLVMExecutionEngine;
+libMesa_STATIC_LIBS := \
+ libLLVMBitReader \
+ libLLVMSelectionDAG \
+ libLLVMAsmPrinter \
+ libLLVMJIT \
+ libLLVMCodeGen \
+ libLLVMTarget \
+ libLLVMMC \
+ libLLVMScalarOpts \
+ libLLVMipo \
+ libLLVMTransformUtils \
+ libLLVMCore \
+ libLLVMSupport \
+ libLLVMSystem \
+ libLLVMAnalysis \
+ libLLVMInstCombine \
+ libLLVMipa \
+ libLLVMMCParser \
+ libLLVMExecutionEngine
+
+libMesa_SRC_FILES := \
+ src/glsl/glcpp/pp.c \
+ src/glsl/glcpp/glcpp-lex.c \
+ src/glsl/glcpp/glcpp-parse.c \
+ src/glsl/ast_expr.cpp \
+ src/glsl/ast_function.cpp \
+ src/glsl/ast_to_hir.cpp \
+ src/glsl/ast_type.cpp \
+ src/glsl/builtin_function.cpp \
+ src/glsl/glsl_lexer.cpp \
+ src/glsl/glsl_parser.cpp \
+ src/glsl/glsl_parser_extras.cpp \
+ src/glsl/glsl_symbol_table.cpp \
+ src/glsl/glsl_types.cpp \
+ src/glsl/hir_field_selection.cpp \
+ src/glsl/ir.cpp \
+ src/glsl/ir_basic_block.cpp \
+ src/glsl/ir_clone.cpp \
+ src/glsl/ir_constant_expression.cpp \
+ src/glsl/ir_expression_flattening.cpp \
+ src/glsl/ir_function.cpp \
+ src/glsl/ir_function_can_inline.cpp \
+ src/glsl/ir_hierarchical_visitor.cpp \
+ src/glsl/ir_hv_accept.cpp \
+ src/glsl/ir_import_prototypes.cpp \
+ src/glsl/ir_print_visitor.cpp \
+ src/glsl/ir_reader.cpp \
+ src/glsl/ir_rvalue_visitor.cpp \
+ src/glsl/ir_set_program_inouts.cpp \
+ src/glsl/ir_validate.cpp \
+ src/glsl/ir_variable.cpp \
+ src/glsl/ir_variable_refcount.cpp \
+ src/glsl/link_functions.cpp \
+ src/glsl/linker.cpp \
+ src/glsl/loop_analysis.cpp \
+ src/glsl/loop_controls.cpp \
+ src/glsl/loop_unroll.cpp \
+ src/glsl/lower_discard.cpp \
+ src/glsl/lower_if_to_cond_assign.cpp \
+ src/glsl/lower_instructions.cpp \
+ src/glsl/lower_jumps.cpp \
+ src/glsl/lower_mat_op_to_vec.cpp \
+ src/glsl/lower_noise.cpp \
+ src/glsl/lower_texture_projection.cpp \
+ src/glsl/lower_variable_index_to_cond_assign.cpp \
+ src/glsl/lower_vec_index_to_cond_assign.cpp \
+ src/glsl/lower_vec_index_to_swizzle.cpp \
+ src/glsl/lower_vector.cpp \
+ src/glsl/main.cpp \
+ src/glsl/opt_algebraic.cpp \
+ src/glsl/opt_constant_folding.cpp \
+ src/glsl/opt_constant_propagation.cpp \
+ src/glsl/opt_constant_variable.cpp \
+ src/glsl/opt_copy_propagation.cpp \
+ src/glsl/opt_dead_code.cpp \
+ src/glsl/opt_dead_code_local.cpp \
+ src/glsl/opt_dead_functions.cpp \
+ src/glsl/opt_discard_simplification.cpp \
+ src/glsl/opt_function_inlining.cpp \
+ src/glsl/opt_if_simplification.cpp \
+ src/glsl/opt_noop_swizzle.cpp \
+ src/glsl/opt_redundant_jumps.cpp \
+ src/glsl/opt_structure_splitting.cpp \
+ src/glsl/opt_swizzle_swizzle.cpp \
+ src/glsl/opt_tree_grafting.cpp \
+ src/glsl/s_expression.cpp \
+ src/glsl/strtod.c \
+ src/glsl/ir_to_llvm.cpp \
+ src/mesa/main/shaderobj.c \
+ src/mesa/program/hash_table.c \
+ src/mesa/program/prog_parameter.cpp \
+ src/mesa/program/symbol_table.c \
+ src/pixelflinger2/buffer.cpp \
+ src/pixelflinger2/format.cpp \
+ src/pixelflinger2/llvm_scanline.cpp \
+ src/pixelflinger2/llvm_texture.cpp \
+ src/pixelflinger2/pixelflinger2.cpp \
+ src/pixelflinger2/raster.cpp \
+ src/pixelflinger2/scanline.cpp \
+ src/pixelflinger2/shader.cpp \
+ src/pixelflinger2/texture.cpp \
+ src/talloc/hieralloc.c
+
+libMesa_C_INCLUDES := \
+ $(LOCAL_PATH) \
+ $(LOCAL_PATH)/src/glsl \
+ $(LOCAL_PATH)/src/mesa \
+ $(LOCAL_PATH)/src/talloc \
+ $(LOCAL_PATH)/src/mapi \
+ $(LOCAL_PATH)/include \
+ frameworks/compile/libbcc/include
+
+# Static library for host
+# ========================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+ifeq ($(DEBUG_BUILD),true)
+LOCAL_CFLAGS += -DDEBUG -UNDEBUG -O0 -g
+else
+LOCAL_CFLAGS += -O3
+endif
+
+LOCAL_MODULE := libMesa
+LOCAL_SRC_FILES := $(libMesa_SRC_FILES)
+
+ifeq ($(USE_LLVM_EXECUTIONENGINE),true)
+LOCAL_CFLAGS += -DUSE_LLVM_EXECUTIONENGINE=1
+LOCAL_STATIC_LIBRARIES := libLLVMX86CodeGen libLLVMX86Info $(libMesa_STATIC_LIBS)
+else
+LOCAL_CFLAGS += -DUSE_LLVM_EXECUTIONENGINE=0
+LOCAL_SHARED_LIBRARIES := libbcc
+endif
+
+LOCAL_C_INCLUDES := $(libMesa_C_INCLUDES)
+
+include $(LLVM_ROOT_PATH)/llvm-host-build.mk
+include $(BUILD_HOST_STATIC_LIBRARY)
+
+
+# Static library for target
+# ========================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+ifeq ($(DEBUG_BUILD),true)
+LOCAL_CFLAGS += -DDEBUG -UNDEBUG -O0 -g
+else
+LOCAL_CFLAGS += -O3
+endif
+
+LOCAL_MODULE := libMesa
+LOCAL_SRC_FILES := $(libMesa_SRC_FILES)
+LOCAL_SHARED_LIBRARIES := libstlport libcutils libdl libutils
+
+ifeq ($(USE_LLVM_EXECUTIONENGINE),true)
+LOCAL_CFLAGS += -DUSE_LLVM_EXECUTIONENGINE=1
+LOCAL_STATIC_LIBRARIES := libLLVMARMCodeGen libLLVMARMInfo libLLVMARMDisassembler libLLVMARMAsmPrinter $(libMesa_STATIC_LIBS)
+else
+LOCAL_CFLAGS += -DUSE_LLVM_EXECUTIONENGINE=0
+LOCAL_SHARED_LIBRARIES += libbcc
+endif
+
+LOCAL_C_INCLUDES := $(libMesa_C_INCLUDES)
+
+include $(LLVM_ROOT_PATH)/llvm-device-build.mk
+include $(BUILD_STATIC_LIBRARY)
+
+# glsl_compiler for host
+# ========================================================
+include $(CLEAR_VARS)
+
+LOCAL_MODULE_TAGS := optional
+
+ifeq ($(DEBUG_BUILD),true)
+LOCAL_CFLAGS += -DDEBUG -UNDEBUG -O0 -g
+endif
+
+LOCAL_MODULE := glsl_compiler
+LOCAL_SRC_FILES := src/glsl/glsl_compiler.cpp
+LOCAL_C_INCLUDES := $(libMesa_C_INCLUDES)
+LOCAL_STATIC_LIBRARIES := libMesa
+
+include $(BUILD_HOST_EXECUTABLE)
+
+# Build children
+# ========================================================
+include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/src/glsl/ir_to_llvm.cpp b/src/glsl/ir_to_llvm.cpp
index a99a58b..387fc08 100644
--- a/src/glsl/ir_to_llvm.cpp
+++ b/src/glsl/ir_to_llvm.cpp
@@ -144,12 +144,12 @@ public:
}
}
- const llvm::Type* llvm_vec_type(const glsl_type* type)
+ llvm::Type* llvm_vec_type(const glsl_type* type)
{
- if(type->is_array())
+ if (type->is_array())
return llvm::ArrayType::get(llvm_type(type->fields.array), type->array_size());
- if(type->is_record())
+ if (type->is_record())
{
std::vector<llvm::Type*> fields;
for (unsigned i = 0; i < type->length; i++)
@@ -158,20 +158,22 @@ public:
fields));
}
- const llvm::Type* base_type = llvm_base_type(type->base_type);
- if(type->vector_elements <= 1)
+ llvm::Type* base_type = (llvm::Type*) llvm_base_type(type->base_type);
+ if (type->vector_elements <= 1) {
return base_type;
- else
+ } else {
return llvm::VectorType::get(base_type, type->vector_elements);
+ }
}
- const llvm::Type* llvm_type(const glsl_type* type)
+ llvm::Type* llvm_type(const glsl_type* type)
{
- const llvm::Type* vec_type = llvm_vec_type(type);
- if(type->matrix_columns <= 1)
+ llvm::Type* vec_type = llvm_vec_type(type);
+ if (type->matrix_columns <= 1) {
return vec_type;
- else
+ } else {
return llvm::ArrayType::get(vec_type, type->matrix_columns);
+ }
}
typedef std::map<ir_variable*, llvm::Value*> llvm_variables_t;
@@ -181,15 +183,13 @@ public:
llvm::Value* llvm_variable(class ir_variable* var)
{
llvm_variables_t::iterator vari = llvm_variables.find(var);
- if(vari != llvm_variables.end())
+ if (vari != llvm_variables.end()) {
return vari->second;
- else
- {
+ } else {
const llvm::Type* type = llvm_type(var->type);
llvm::Value* v = NULL;
- if(fun)
- {
+ if(fun) {
if (ir_var_in == var->mode)
{
assert(var->location >= 0);
@@ -215,9 +215,8 @@ public:
else
v = new llvm::AllocaInst(type, 0, var->name, fun->getEntryBlock().getTerminator());
}
- }
- else // TODO: can anything global be non-constant in GLSL?; fix linkage
- {
+ } else {
+ // TODO: can anything global be non-constant in GLSL?; fix linkage
//printf("var '%s' mode=%d location=%d \n", var->name, var->mode, var->location);
switch(var->mode)
{
@@ -364,7 +363,7 @@ public:
llvm::Value* llvm_intrinsic_unop(ir_expression_operation op, llvm::Value * op0)
{
- const llvm::Type * floatType = llvm::Type::getFloatTy(ctx);
+ llvm::Type * floatType = llvm::Type::getFloatTy(ctx);
const char * name = NULL;
switch (op) {
case ir_unop_sin:
@@ -394,7 +393,7 @@ public:
llvm::Value* llvm_intrinsic_binop(ir_expression_operation op, llvm::Value * op0, llvm::Value * op1)
{
- const llvm::Type * floatType = llvm::Type::getFloatTy(ctx);
+ llvm::Type * floatType = llvm::Type::getFloatTy(ctx);
const char * name = NULL;
switch (op) {
case ir_binop_pow:
@@ -420,7 +419,7 @@ public:
return bld.CreateCall2(function, op0, op1);
}
- llvm::Constant* llvm_imm(const llvm::Type* type, double v)
+ llvm::Constant* llvm_imm(llvm::Type* type, double v)
{
if(type->isVectorTy())
{
@@ -1112,7 +1111,7 @@ public:
args.push_back(llvm_value(arg));
}
- result = bld.CreateCall(llvm_function(ir->get_callee()), args.begin(), args.end());
+ result = bld.CreateCall(llvm_function(ir->get_callee()), llvm::ArrayRef<llvm::Value*>(args));
llvm::AttrListPtr attr;
((llvm::CallInst*)result)->setAttributes(attr);
diff --git a/src/pixelflinger2/llvm_scanline.cpp b/src/pixelflinger2/llvm_scanline.cpp
index a0bd2dc..893b925 100644
--- a/src/pixelflinger2/llvm_scanline.cpp
+++ b/src/pixelflinger2/llvm_scanline.cpp
@@ -420,11 +420,11 @@ Value * GenerateFSBlend(const GGLState * gglCtx, const GGLPixelFormat format, /*
static FunctionType * ScanLineFunctionType(IRBuilder<> & builder)
{
std::vector<Type*> funcArgs;
- const VectorType * vectorType = floatVecType(builder);
- const PointerType * vectorPtr = PointerType::get(vectorType, 0);
- const Type * intType = builder.getInt32Ty();
- const PointerType * intPointerType = PointerType::get(intType, 0);
- const PointerType * bytePointerType = PointerType::get(builder.getInt8Ty(), 0);
+ VectorType * vectorType = floatVecType(builder);
+ PointerType * vectorPtr = PointerType::get(vectorType, 0);
+ Type * intType = builder.getInt32Ty();
+ PointerType * intPointerType = PointerType::get(intType, 0);
+ PointerType * bytePointerType = PointerType::get(builder.getInt8Ty(), 0);
funcArgs.push_back(vectorPtr); // start
funcArgs.push_back(vectorPtr); // step