[Bf-blender-cvs] [d42a384] object_nodes: Extended debug printing modes to the LLVM code.

Lukas Tönne noreply at git.blender.org
Tue Apr 12 10:19:42 CEST 2016


Commit: d42a384296fb34e90e07ed25c32b9477864c853f
Author: Lukas Tönne
Date:   Tue Apr 12 10:12:19 2016 +0200
Branches: object_nodes
https://developer.blender.org/rBd42a384296fb34e90e07ed25c32b9477864c853f

Extended debug printing modes to the LLVM code.

The LLVM IR code can be dumped either in raw form or optimized.
It is stored as a raw text file.

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

M	release/scripts/nodes/bvm_debug.py
M	source/blender/blenvm/BVM_api.h
M	source/blender/blenvm/CMakeLists.txt
M	source/blender/blenvm/compile/bvm_codegen.cc
M	source/blender/blenvm/compile/bvm_codegen.h
M	source/blender/blenvm/compile/bvm_codegen_debug.cc
M	source/blender/blenvm/intern/bvm_api.cc
M	source/blender/blenvm/llvm/CMakeLists.txt
M	source/blender/blenvm/llvm/llvm_codegen.cc
M	source/blender/blenvm/llvm/llvm_codegen.h
M	source/blender/makesrna/intern/rna_nodetree.c

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

diff --git a/release/scripts/nodes/bvm_debug.py b/release/scripts/nodes/bvm_debug.py
index c6d1520..8ecd594 100644
--- a/release/scripts/nodes/bvm_debug.py
+++ b/release/scripts/nodes/bvm_debug.py
@@ -23,6 +23,7 @@ import bpy
 from bpy.types import Operator, Panel
 from bpy.props import EnumProperty
 
+txtfile = '/tmp/bvm_nodes.txt'
 dotfile = '/tmp/bvm_nodes.dot'
 imgfile = '/tmp/bvm_nodes.svg'
 dotformat = 'svg'
@@ -43,16 +44,22 @@ class BVMNodeGraphvizOperator(Operator):
     debug_mode = enum_property_copy(bpy.types.NodeTree.bl_rna.functions['bvm_debug_graphviz'].parameters['debug_mode'])
 
     def execute(self, context):
-        if hasattr(context, "debug_nodetree"):
-            ntree = context.debug_nodetree
-            ntree.bvm_debug_graphviz(dotfile, self.function_type, self.debug_mode, label=ntree.name)
-        else:
+        if not hasattr(context, "debug_nodetree"):
             return {'CANCELLED'}
+
+        ntree = context.debug_nodetree
+
+        if (self.debug_mode in {'NODES', 'NODES_UNOPTIMIZED', 'BVM_CODE'}):
+            ntree.bvm_debug_graphviz(dotfile, self.function_type, self.debug_mode, label=ntree.name)
+
+            process = subprocess.Popen(['dot', '-T'+dotformat, '-o', imgfile, dotfile])
+            process.wait()
         
-        process = subprocess.Popen(['dot', '-T'+dotformat, '-o', imgfile, dotfile])
-        process.wait()
-        
-        subprocess.Popen(['xdg-open', imgfile])
+            subprocess.Popen(['xdg-open', imgfile])
+        else:
+            ntree.bvm_debug_graphviz(txtfile, self.function_type, self.debug_mode, label=ntree.name)
+            
+            subprocess.Popen(['xdg-open', txtfile])
         
         return {'FINISHED'}
 
@@ -77,9 +84,15 @@ def draw_depshow_op(layout, ntree):
     props = col.operator(BVMNodeGraphvizOperator.bl_idname, text="Nodes (unoptimized)")
     props.function_type = funtype
     props.debug_mode = 'NODES_UNOPTIMIZED'
-    props = col.operator(BVMNodeGraphvizOperator.bl_idname, text="Code")
+    props = col.operator(BVMNodeGraphvizOperator.bl_idname, text="BVM Code")
+    props.function_type = funtype
+    props.debug_mode = 'BVM_CODE'
+    props = col.operator(BVMNodeGraphvizOperator.bl_idname, text="LLVM Code")
+    props.function_type = funtype
+    props.debug_mode = 'LLVM_CODE'
+    props = col.operator(BVMNodeGraphvizOperator.bl_idname, text="LLVM Code (unoptimized)")
     props.function_type = funtype
-    props.debug_mode = 'CODEGEN'
+    props.debug_mode = 'LLVM_CODE_UNOPTIMIZED'
 
 class BVMNodeGraphvizPanel(Panel):
     bl_idname = "node.bvm_graphviz_panel"
diff --git a/source/blender/blenvm/BVM_api.h b/source/blender/blenvm/BVM_api.h
index df8550d..7847404 100644
--- a/source/blender/blenvm/BVM_api.h
+++ b/source/blender/blenvm/BVM_api.h
@@ -110,7 +110,9 @@ void BVM_context_free(struct BVMEvalContext *context);
 typedef enum BVMDebugMode {
 	BVM_DEBUG_NODES,
 	BVM_DEBUG_NODES_UNOPTIMIZED,
-	BVM_DEBUG_CODEGEN,
+	BVM_DEBUG_BVM_CODE,
+	BVM_DEBUG_LLVM_CODE,
+	BVM_DEBUG_LLVM_CODE_UNOPTIMIZED,
 } BVMDebugMode;
 
 /* ------------------------------------------------------------------------- */
diff --git a/source/blender/blenvm/CMakeLists.txt b/source/blender/blenvm/CMakeLists.txt
index 60bbf90..b5208e4 100644
--- a/source/blender/blenvm/CMakeLists.txt
+++ b/source/blender/blenvm/CMakeLists.txt
@@ -23,14 +23,6 @@
 #
 # ***** END GPL LICENSE BLOCK *****
 
-add_subdirectory(bvm)
-add_subdirectory(compile)
-
-if(WITH_LLVM)
-	add_subdirectory(llvm)
-	add_definitions(-DWITH_LLVM)
-endif()
-
 set(INC
 	.
 	bvm
@@ -92,4 +84,18 @@ else()
 	endif()
 endif()
 
+if(WIN32 AND MSVC)
+	set(RTTI_DISABLE_FLAGS "/GR- -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
+elseif(CMAKE_COMPILER_IS_GNUCC OR (CMAKE_C_COMPILER_ID MATCHES "Clang"))
+	set(RTTI_DISABLE_FLAGS "-fno-rtti -DBOOST_NO_RTTI -DBOOST_NO_TYPEID")
+endif()
+
+add_subdirectory(bvm)
+add_subdirectory(compile)
+
+if(WITH_LLVM)
+	add_subdirectory(llvm)
+	add_definitions(-DWITH_LLVM)
+endif()
+
 blender_add_lib(bf_blenvm "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/blenvm/compile/bvm_codegen.cc b/source/blender/blenvm/compile/bvm_codegen.cc
index 59c67d2..82eedd7 100644
--- a/source/blender/blenvm/compile/bvm_codegen.cc
+++ b/source/blender/blenvm/compile/bvm_codegen.cc
@@ -40,12 +40,12 @@
 
 namespace blenvm {
 
-Compiler::Compiler()
+BVMCompilerBase::BVMCompilerBase()
 {
 	stack_users.resize(BVM_STACK_SIZE, 0);
 }
 
-Compiler::~Compiler()
+BVMCompilerBase::~BVMCompilerBase()
 {
 }
 
@@ -59,7 +59,7 @@ static bool is_parent_block(const NodeBlock *parent, const NodeBlock *block)
 	return false;
 }
 
-void Compiler::calc_node_dependencies(const NodeInstance *node, BlockDependencyMap &block_deps_map)
+void BVMCompilerBase::calc_node_dependencies(const NodeInstance *node, BlockDependencyMap &block_deps_map)
 {
 	if (node_deps_map.find(node) != node_deps_map.end())
 		return;
@@ -91,7 +91,7 @@ void Compiler::calc_node_dependencies(const NodeInstance *node, BlockDependencyM
 	}
 }
 
-void Compiler::calc_block_dependencies(const NodeBlock *block, BlockDependencyMap &block_deps_map)
+void BVMCompilerBase::calc_block_dependencies(const NodeBlock *block, BlockDependencyMap &block_deps_map)
 {
 	if (block_deps_map.find(block) != block_deps_map.end())
 		return;
@@ -103,7 +103,7 @@ void Compiler::calc_block_dependencies(const NodeBlock *block, BlockDependencyMa
 	}
 }
 
-void Compiler::calc_symbol_scope(const NodeGraph &graph)
+void BVMCompilerBase::calc_symbol_scope(const NodeGraph &graph)
 {
 	{
 		BlockDependencyMap block_deps_map;
@@ -128,7 +128,7 @@ void Compiler::calc_symbol_scope(const NodeGraph &graph)
 	}
 }
 
-StackIndex Compiler::find_stack_index(int size) const
+StackIndex BVMCompilerBase::find_stack_index(int size) const
 {
 	int unused = 0;
 	
@@ -148,7 +148,7 @@ StackIndex Compiler::find_stack_index(int size) const
 	return BVM_STACK_INVALID;
 }
 
-StackIndex Compiler::assign_stack_index(const TypeDesc &typedesc)
+StackIndex BVMCompilerBase::assign_stack_index(const TypeDesc &typedesc)
 {
 	int stack_size = EvalStack::stack_size(typedesc.size());
 	
@@ -161,7 +161,7 @@ StackIndex Compiler::assign_stack_index(const TypeDesc &typedesc)
 	return stack_offset;
 }
 
-void Compiler::get_local_arg_indices(const NodeInstance *node, const NodeBlock *local_block)
+void BVMCompilerBase::get_local_arg_indices(const NodeInstance *node, const NodeBlock *local_block)
 {
 	for (int i = 0; i < node->num_outputs(); ++i) {
 		ConstOutputKey output = node->output(i);
@@ -173,7 +173,7 @@ void Compiler::get_local_arg_indices(const NodeInstance *node, const NodeBlock *
 	}
 }
 
-void Compiler::resolve_node_block_symbols(const NodeBlock *block)
+void BVMCompilerBase::resolve_node_block_symbols(const NodeBlock *block)
 {
 	assert(block_info.find(block) == block_info.end());
 	block_info[block] = BlockInfo();
@@ -225,14 +225,14 @@ void Compiler::resolve_node_block_symbols(const NodeBlock *block)
 	}
 }
 
-void Compiler::resolve_symbols(const NodeGraph &graph)
+void BVMCompilerBase::resolve_symbols(const NodeGraph &graph)
 {
 	/* recursively assign stack indices to outputs */
 	resolve_node_block_symbols(&graph.main_block());
 }
 
 
-void Compiler::push_constant(const NodeValue *value) const
+void BVMCompilerBase::push_constant(const NodeValue *value) const
 {
 	BLI_assert(value != NULL);
 	switch (value->typedesc().base_type()) {
@@ -294,7 +294,7 @@ void Compiler::push_constant(const NodeValue *value) const
 	}
 }
 
-void Compiler::codegen_value(const NodeValue *value, StackIndex offset) const
+void BVMCompilerBase::codegen_value(const NodeValue *value, StackIndex offset) const
 {
 	switch (value->typedesc().base_type()) {
 		case BVM_FLOAT: {
@@ -410,7 +410,7 @@ static OpCode ptr_release_opcode(const TypeDesc &typedesc)
 	return OP_NOOP;
 }
 
-int Compiler::codegen_node_block(const NodeBlock &block)
+int BVMCompilerBase::codegen_node_block(const NodeBlock &block)
 {
 	int entry_point = current_address();
 	BlockInfo &info = block_info[&block];
@@ -522,7 +522,7 @@ int Compiler::codegen_node_block(const NodeBlock &block)
 	return entry_point;
 }
 
-int Compiler::codegen_graph(const NodeGraph &graph)
+int BVMCompilerBase::codegen_graph(const NodeGraph &graph)
 {
 	calc_symbol_scope(graph);
 	
diff --git a/source/blender/blenvm/compile/bvm_codegen.h b/source/blender/blenvm/compile/bvm_codegen.h
index 9261c68..6ffa1c8 100644
--- a/source/blender/blenvm/compile/bvm_codegen.h
+++ b/source/blender/blenvm/compile/bvm_codegen.h
@@ -59,14 +59,14 @@ typedef std::map<const NodeBlock *, OutputSet> BlockDependencyMap;
 
 typedef std::vector<int> StackUsers;
 
-struct Compiler {
+struct BVMCompilerBase {
 	struct BlockInfo {
 		int entry_point;
 	};
 	typedef std::map<const NodeBlock*, BlockInfo> BlockInfoMap;
 	
-	Compiler();
-	virtual ~Compiler();
+	BVMCompilerBase();
+	virtual ~BVMCompilerBase();
 	
 protected:
 	void calc_node_dependencies(const NodeInstance *node, BlockDependencyMap &block_deps_map);
@@ -110,7 +110,7 @@ protected:
 	MEM_CXX_CLASS_ALLOC_FUNCS("BVM:BVMCompiler")
 };
 
-struct BVMCompiler : public Compiler {
+struct BVMCompiler : public BVMCompilerBase {
 	BVMCompiler();
 	~BVMCompiler();
 	
@@ -134,11 +134,11 @@ private:
 	FunctionBVM *fn;
 };
 
-struct DebugGraphvizCompiler : public Compiler {
-	DebugGraphvizCompiler();
-	~DebugGraphvizCompiler();
+struct DebugGraphvizBVMCompiler : public BVMCompilerBase {
+	DebugGraphvizBVMCompiler();
+	~DebugGraphvizBVMCompiler();
 	
-	void compile_function(const NodeGraph &graph, FILE *m_file, const string &label);
+	void compile_function(const NodeGraph &graph, FILE *file, const string &label);
 	
 protected:
 	void push_opcode(OpCode op) const;
diff --git a/source/blender/blenvm/compile/bvm_codegen_debug.cc b/source/blender/blenvm/compile/bvm_codegen_debug.cc
index f8990b3..e3fb534 100644
--- a/source/blender/blenvm/compile/bvm_codegen_debug.cc
+++ b/source/blender/blenvm/compile/bvm_codegen_debug.cc
@@ -87,7 +87,7 @@ inline void print_gap(FILE *f)
 	debug_fprintf(f, "</TR>" NL);
 }
 
-DebugGraphvizCompiler::DebugGraphvizCompiler() :
+DebugGraphvizBVMCompiler::DebugGraphvizBVMCompiler() :
     m_file(NULL),
     m_current_address(0),
     m_current_opnode(NULL),
@@ -95,11 +95,11

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list