[Bf-blender-cvs] [33360f7c968] nodes_playground: generateModule function

Jacques Lucke noreply at git.blender.org
Sun Jan 6 17:25:28 CET 2019


Commit: 33360f7c96888d3af562f8c74425b21c89e0a18b
Author: Jacques Lucke
Date:   Fri Jan 4 10:44:54 2019 +0100
Branches: nodes_playground
https://developer.blender.org/rB33360f7c96888d3af562f8c74425b21c89e0a18b

generateModule function

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

M	source/blender/modifiers/intern/node_compiler.cpp
M	source/blender/modifiers/intern/node_compiler.hpp
M	source/blender/modifiers/intern/node_compiler_testing.cpp

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

diff --git a/source/blender/modifiers/intern/node_compiler.cpp b/source/blender/modifiers/intern/node_compiler.cpp
index ce44523c8a1..a5eb57f664e 100644
--- a/source/blender/modifiers/intern/node_compiler.cpp
+++ b/source/blender/modifiers/intern/node_compiler.cpp
@@ -49,6 +49,17 @@ std::string Node::debug_id() const
 	return ss.str();
 }
 
+llvm::Module *DataFlowGraph::generateModule(
+	std::string module_name, std::string function_name,
+	SocketArraySet &inputs, SocketArraySet &outputs)
+{
+	assert(outputs.size() > 0);
+	llvm::LLVMContext &context = outputs[0].type()->getContext();
+	llvm::Module *module = new llvm::Module(module_name, context);
+	this->generateFunction(module, function_name, inputs, outputs);
+	return module;
+}
+
 llvm::Function *DataFlowGraph::generateFunction(
 	llvm::Module *module, std::string name,
 	SocketArraySet &inputs, SocketArraySet &outputs)
diff --git a/source/blender/modifiers/intern/node_compiler.hpp b/source/blender/modifiers/intern/node_compiler.hpp
index a336591b99c..dc2766dcc82 100644
--- a/source/blender/modifiers/intern/node_compiler.hpp
+++ b/source/blender/modifiers/intern/node_compiler.hpp
@@ -140,6 +140,10 @@ struct DataFlowGraph {
 	std::vector<Node *> nodes;
 	LinkSet links;
 
+	llvm::Module *generateModule(
+		std::string module_name, std::string function_name,
+		SocketArraySet &inputs, SocketArraySet &outputs);
+
 	llvm::Function *generateFunction(
 		llvm::Module *module, std::string name,
 		SocketArraySet &inputs, SocketArraySet &outputs);
diff --git a/source/blender/modifiers/intern/node_compiler_testing.cpp b/source/blender/modifiers/intern/node_compiler_testing.cpp
index fc48e6d7797..6960d9c834c 100644
--- a/source/blender/modifiers/intern/node_compiler_testing.cpp
+++ b/source/blender/modifiers/intern/node_compiler_testing.cpp
@@ -94,11 +94,10 @@ void run_tests()
 	graph.links.links.push_back(NC::Link(add1->Output(0), add3->Input(0)));
 	graph.links.links.push_back(NC::Link(add2->Output(0), add3->Input(1)));
 
-	llvm::Module *module = new llvm::Module("test", context);
 
 	NC::SocketArraySet inputs = { in1->Output(0), in2->Output(0) };
 	NC::SocketArraySet outputs = { add3->Output(0), add1->Input(0) };
-	graph.generateFunction(module, "HelloWorld", inputs, outputs);
+	llvm::Module *module = graph.generateModule("MyModule", "MyFunction", inputs, outputs);
 
 	module->print(llvm::outs(), nullptr);



More information about the Bf-blender-cvs mailing list