[Bf-blender-cvs] [c090a2f821f] functions: cleanup

Jacques Lucke noreply at git.blender.org
Sun Mar 3 13:53:39 CET 2019


Commit: c090a2f821fdae5e7b5b783078be563655c6558c
Author: Jacques Lucke
Date:   Sun Mar 3 11:07:39 2019 +0100
Branches: functions
https://developer.blender.org/rBc090a2f821fdae5e7b5b783078be563655c6558c

cleanup

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

M	source/blender/functions/backends/llvm/to_tuple_call.cpp
M	source/blender/functions/backends/llvm/to_tuple_call.hpp
M	source/blender/functions/c_wrapper.cpp
M	source/blender/functions/core/function.hpp

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

diff --git a/source/blender/functions/backends/llvm/to_tuple_call.cpp b/source/blender/functions/backends/llvm/to_tuple_call.cpp
index ddb755750e5..53d4ff93d79 100644
--- a/source/blender/functions/backends/llvm/to_tuple_call.cpp
+++ b/source/blender/functions/backends/llvm/to_tuple_call.cpp
@@ -38,7 +38,8 @@ namespace FN {
 	}
 
 	static llvm::Function *insert_tuple_call_function(
-		SharedFunction fn,
+		Function *fn,
+		LLVMGenBody *llvm_body,
 		llvm::Module *module)
 	{
 		llvm::LLVMContext &context = module->getContext();
@@ -86,9 +87,7 @@ namespace FN {
 		}
 
 		LLVMValues output_values;
-		auto body = fn->body<LLVMGenBody>();
-		BLI_assert(body);
-		body->build_ir(builder, input_values, output_values);
+		llvm_body->build_ir(builder, input_values, output_values);
 
 		for (uint i = 0; i < output_values.size(); i++) {
 			llvm::Value *value_byte_addr = lookup_tuple_address(
@@ -134,11 +133,13 @@ namespace FN {
 	};
 
 	TupleCallBody *compile_llvm_to_tuple_call(
-		SharedFunction &fn,
+		LLVMGenBody *llvm_body,
 		llvm::LLVMContext &context)
 	{
+		BLI_assert(llvm_body->has_owner());
+		Function *fn = llvm_body->owner();
 		llvm::Module *module = new llvm::Module(fn->name(), context);
-		llvm::Function *function = insert_tuple_call_function(fn, module);
+		llvm::Function *function = insert_tuple_call_function(fn, llvm_body, module);
 
 		// module->print(llvm::outs(), nullptr);
 
diff --git a/source/blender/functions/backends/llvm/to_tuple_call.hpp b/source/blender/functions/backends/llvm/to_tuple_call.hpp
index 8adb6b393d7..89506828eef 100644
--- a/source/blender/functions/backends/llvm/to_tuple_call.hpp
+++ b/source/blender/functions/backends/llvm/to_tuple_call.hpp
@@ -1,6 +1,6 @@
 #pragma once
 
-#include "FN_core.hpp"
+#include "llvm_gen.hpp"
 #include <llvm/IR/IRBuilder.h>
 
 namespace FN {
@@ -8,7 +8,7 @@ namespace FN {
 	class TupleCallBody;
 
 	TupleCallBody *compile_llvm_to_tuple_call(
-		SharedFunction &fn,
+		LLVMGenBody *llvm_body,
 		llvm::LLVMContext &context);
 
 } /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/c_wrapper.cpp b/source/blender/functions/c_wrapper.cpp
index 34407dffa4e..e13146ff62f 100644
--- a/source/blender/functions/c_wrapper.cpp
+++ b/source/blender/functions/c_wrapper.cpp
@@ -25,7 +25,7 @@ static void playground()
 {
 	SharedFunction fn = Functions::add_floats();
 	llvm::LLVMContext *context = new llvm::LLVMContext();
-	auto body = compile_llvm_to_tuple_call(fn, *context);
+	auto body = compile_llvm_to_tuple_call(fn->body<LLVMGenBody>(), *context);
 
 	Tuple fn_in(fn->signature().input_types());
 	Tuple fn_out(fn->signature().output_types());
diff --git a/source/blender/functions/core/function.hpp b/source/blender/functions/core/function.hpp
index b45016196d4..389ce6a51d4 100644
--- a/source/blender/functions/core/function.hpp
+++ b/source/blender/functions/core/function.hpp
@@ -50,7 +50,7 @@ namespace FN {
 		}
 
 		template<typename T>
-		inline const T *body() const
+		inline T *body() const
 		{
 			return m_bodies.get<T>();
 		}



More information about the Bf-blender-cvs mailing list