[Bf-blender-cvs] [3dae50b] object_nodes: Cleanup: Remove the unnecessary compiler subclasses for final instantiation.

Lukas Tönne noreply at git.blender.org
Tue May 24 12:08:01 CEST 2016


Commit: 3dae50bc4cb61aca74718184a1e6c9970c637120
Author: Lukas Tönne
Date:   Tue May 24 12:07:31 2016 +0200
Branches: object_nodes
https://developer.blender.org/rB3dae50bc4cb61aca74718184a1e6c9970c637120

Cleanup: Remove the unnecessary compiler subclasses for final instantiation.

===================================================================

M	source/blender/blenvm/intern/bvm_api.cc
M	source/blender/blenvm/llvm/llvm_compiler.cc
M	source/blender/blenvm/llvm/llvm_compiler.h
M	source/blender/blenvm/llvm/llvm_compiler_dual.cc

===================================================================

diff --git a/source/blender/blenvm/intern/bvm_api.cc b/source/blender/blenvm/intern/bvm_api.cc
index 5e83d62..d51df61 100644
--- a/source/blender/blenvm/intern/bvm_api.cc
+++ b/source/blender/blenvm/intern/bvm_api.cc
@@ -420,15 +420,15 @@ static void debug_node_graph(blenvm::NodeGraph &graph, FILE *debug_file, const c
 		}
 		case BVM_DEBUG_LLVM_CODE: {
 #ifdef WITH_LLVM
-			DebugLLVMCompiler compiler;
-			compiler.compile_function(label, graph, 2, debug_file);
+			LLVMTextureCompiler compiler;
+			compiler.debug_function(label, graph, 2, debug_file);
 #endif
 			break;
 		}
 		case BVM_DEBUG_LLVM_CODE_UNOPTIMIZED: {
 #ifdef WITH_LLVM
-			DebugLLVMCompiler compiler;
-			compiler.compile_function(label, graph, 0, debug_file);
+			LLVMTextureCompiler compiler;
+			compiler.debug_function(label, graph, 0, debug_file);
 #endif
 			break;
 		}
@@ -596,7 +596,7 @@ struct BVMFunction *BVM_gen_texture_function_llvm(bNodeTree *btree, bool use_cac
 		parse_py_nodes(btree, &graph);
 		graph.finalize();
 		
-		LLVMCompiler compiler;
+		LLVMTextureCompiler compiler;
 		fn = compiler.compile_function(get_ntree_unique_function_name(btree), graph, 2);
 		
 		if (use_cache) {
diff --git a/source/blender/blenvm/llvm/llvm_compiler.cc b/source/blender/blenvm/llvm/llvm_compiler.cc
index deaafc2..cc015ea 100644
--- a/source/blender/blenvm/llvm/llvm_compiler.cc
+++ b/source/blender/blenvm/llvm/llvm_compiler.cc
@@ -427,7 +427,7 @@ llvm::Function *LLVMCompilerBase::declare_node_function(llvm::Module *mod, const
 
 /* ------------------------------------------------------------------------- */
 
-FunctionLLVM *LLVMCompiler::compile_function(const string &name, const NodeGraph &graph, int opt_level)
+FunctionLLVM *LLVMCompilerBase::compile_function(const string &name, const NodeGraph &graph, int opt_level)
 {
 	using namespace llvm;
 	
@@ -493,7 +493,7 @@ class debug_assembly_annotation_writer : public llvm::AssemblyAnnotationWriter
 	/* add implementation here if needed */
 };
 
-void DebugLLVMCompiler::compile_function(const string &name, const NodeGraph &graph, int opt_level, FILE *file)
+void LLVMCompilerBase::debug_function(const string &name, const NodeGraph &graph, int opt_level, FILE *file)
 {
 	using namespace llvm;
 	
diff --git a/source/blender/blenvm/llvm/llvm_compiler.h b/source/blender/blenvm/llvm/llvm_compiler.h
index 813c60c..4579095 100644
--- a/source/blender/blenvm/llvm/llvm_compiler.h
+++ b/source/blender/blenvm/llvm/llvm_compiler.h
@@ -69,6 +69,9 @@ struct LLVMCompilerBase {
 	
 	virtual ~LLVMCompilerBase();
 	
+	FunctionLLVM *compile_function(const string &name, const NodeGraph &graph, int opt_level);
+	void debug_function(const string &name, const NodeGraph &graph, int opt_level, FILE *file);
+	
 	/* XXX TODO some methods are used by static template functions, which require public access ... */
 //protected:
 	LLVMCompilerBase();
@@ -125,7 +128,7 @@ private:
 	static llvm::Module *m_nodes_module;
 };
 
-struct LLVMTextureCompilerImpl : public LLVMCompilerBase {
+struct LLVMTextureCompiler : public LLVMCompilerBase {
 	llvm::Type *get_value_type(const TypeSpec *spec, bool is_constant);
 	llvm::Function *declare_elementary_node_function(llvm::Module *mod, const NodeType *nodetype, const string &name);
 	
@@ -146,14 +149,6 @@ private:
 	static llvm::Module *m_nodes_module;
 };
 
-struct LLVMCompiler : public LLVMTextureCompilerImpl {
-	FunctionLLVM *compile_function(const string &name, const NodeGraph &graph, int opt_level);
-};
-
-struct DebugLLVMCompiler : public LLVMTextureCompilerImpl {
-	void compile_function(const string &name, const NodeGraph &graph, int opt_level, FILE *file);
-};
-
 } /* namespace blenvm */
 
 #endif /* __LLVM_COMPILER_H__ */
diff --git a/source/blender/blenvm/llvm/llvm_compiler_dual.cc b/source/blender/blenvm/llvm/llvm_compiler_dual.cc
index e6a2ad9..91ebb0e 100644
--- a/source/blender/blenvm/llvm/llvm_compiler_dual.cc
+++ b/source/blender/blenvm/llvm/llvm_compiler_dual.cc
@@ -48,14 +48,14 @@
 
 namespace blenvm {
 
-llvm::Module *LLVMTextureCompilerImpl::m_nodes_module = NULL;
+llvm::Module *LLVMTextureCompiler::m_nodes_module = NULL;
 
-llvm::Type *LLVMTextureCompilerImpl::get_value_type(const TypeSpec *spec, bool is_constant)
+llvm::Type *LLVMTextureCompiler::get_value_type(const TypeSpec *spec, bool is_constant)
 {
 	return bvm_get_llvm_type(context(), spec, !is_constant);
 }
 
-bool LLVMTextureCompilerImpl::use_argument_pointer(const TypeSpec *typespec, bool is_constant)
+bool LLVMTextureCompiler::use_argument_pointer(const TypeSpec *typespec, bool is_constant)
 {
 	using namespace llvm;
 	
@@ -90,7 +90,7 @@ bool LLVMTextureCompilerImpl::use_argument_pointer(const TypeSpec *typespec, boo
 	return false;
 }
 
-bool LLVMTextureCompilerImpl::use_elementary_argument_pointer(const TypeSpec *typespec)
+bool LLVMTextureCompiler::use_elementary_argument_pointer(const TypeSpec *typespec)
 {
 	using namespace llvm;
 	
@@ -122,12 +122,12 @@ bool LLVMTextureCompilerImpl::use_elementary_argument_pointer(const TypeSpec *ty
 	return false;
 }
 
-llvm::Constant *LLVMTextureCompilerImpl::create_node_value_constant(const NodeValue *node_value)
+llvm::Constant *LLVMTextureCompiler::create_node_value_constant(const NodeValue *node_value)
 {
 	return bvm_create_llvm_constant(context(), node_value);
 }
 
-llvm::Function *LLVMTextureCompilerImpl::declare_elementary_node_function(llvm::Module *mod, const NodeType *nodetype, const string &name)
+llvm::Function *LLVMTextureCompiler::declare_elementary_node_function(llvm::Module *mod, const NodeType *nodetype, const string &name)
 {
 	using namespace llvm;
 	
@@ -162,7 +162,7 @@ llvm::Function *LLVMTextureCompilerImpl::declare_elementary_node_function(llvm::
 	return func;
 }
 
-bool LLVMTextureCompilerImpl::set_node_function_impl(OpCode op, const NodeType *nodetype,
+bool LLVMTextureCompiler::set_node_function_impl(OpCode op, const NodeType *nodetype,
                                                      llvm::Function *value_func,
                                                      std::vector<llvm::Function*> deriv_funcs)
 {
@@ -217,7 +217,7 @@ bool LLVMTextureCompilerImpl::set_node_function_impl(OpCode op, const NodeType *
 }
 
 template <OpCode op>
-static void define_elementary_functions(LLVMTextureCompilerImpl &C, llvm::Module *mod, const string &nodetype_name)
+static void define_elementary_functions(LLVMTextureCompiler &C, llvm::Module *mod, const string &nodetype_name)
 {
 	using namespace llvm;
 	
@@ -240,7 +240,7 @@ static void define_elementary_functions(LLVMTextureCompilerImpl &C, llvm::Module
 	C.set_node_function_impl(op, nodetype, value_func, deriv_funcs);
 }
 
-void LLVMTextureCompilerImpl::define_dual_function_wrapper(llvm::Module *mod, const string &nodetype_name)
+void LLVMTextureCompiler::define_dual_function_wrapper(llvm::Module *mod, const string &nodetype_name)
 {
 	using namespace llvm;
 	
@@ -345,7 +345,7 @@ void LLVMTextureCompilerImpl::define_dual_function_wrapper(llvm::Module *mod, co
 	builder.CreateRetVoid();
 }
 
-void LLVMTextureCompilerImpl::define_nodes_module()
+void LLVMTextureCompiler::define_nodes_module()
 {
 	using namespace llvm;




More information about the Bf-blender-cvs mailing list