Commit: d8815d5b4102aaafcb9c801c8a78b1dce7d67e12
Author: Jacques Lucke
Date:   Mon Mar 4 14:12:01 2019 +0100
Branches: functions
https://developer.blender.org/rBd8815d5b4102aaafcb9c801c8a78b1dce7d67e12

cleanup naming of function bodies and derive functions

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

M       source/blender/functions/CMakeLists.txt
M       source/blender/functions/FN_llvm.hpp
A       source/blender/functions/backends/llvm/build_ir_body.cpp
R082    source/blender/functions/backends/llvm/llvm_gen.hpp     
source/blender/functions/backends/llvm/build_ir_body.hpp
M       source/blender/functions/backends/llvm/compiled_body.cpp
M       source/blender/functions/backends/llvm/compiled_body.hpp
M       source/blender/functions/backends/llvm/from_tuple_call.cpp
M       source/blender/functions/backends/llvm/from_tuple_call.hpp
D       source/blender/functions/backends/llvm/llvm_gen.cpp
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
M       source/blender/functions/functions/scalar_math.cpp
M       source/blender/functions/functions/vectors.cpp

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

diff --git a/source/blender/functions/CMakeLists.txt 
b/source/blender/functions/CMakeLists.txt
index d9adf6899ce..0ac2a584a4b 100644
--- a/source/blender/functions/CMakeLists.txt
+++ b/source/blender/functions/CMakeLists.txt
@@ -54,8 +54,8 @@ set(SRC
        backends/llvm/initialize.cpp
        backends/llvm/llvm_types.hpp
        backends/llvm/llvm_types.cpp
-       backends/llvm/llvm_gen.hpp
-       backends/llvm/llvm_gen.cpp
+       backends/llvm/build_ir_body.hpp
+       backends/llvm/build_ir_body.cpp
        backends/llvm/to_tuple_call.hpp
        backends/llvm/to_tuple_call.cpp
        backends/llvm/from_tuple_call.hpp
diff --git a/source/blender/functions/FN_llvm.hpp 
b/source/blender/functions/FN_llvm.hpp
index ebdaf347f45..8027d1b808d 100644
--- a/source/blender/functions/FN_llvm.hpp
+++ b/source/blender/functions/FN_llvm.hpp
@@ -2,7 +2,7 @@
 
 #include "backends/llvm/initialize.hpp"
 #include "backends/llvm/llvm_types.hpp"
-#include "backends/llvm/llvm_gen.hpp"
+#include "backends/llvm/build_ir_body.hpp"
 #include "backends/llvm/to_tuple_call.hpp"
 #include "backends/llvm/from_tuple_call.hpp"
 #include "backends/llvm/compiled_body.hpp"
\ No newline at end of file
diff --git a/source/blender/functions/backends/llvm/build_ir_body.cpp 
b/source/blender/functions/backends/llvm/build_ir_body.cpp
new file mode 100644
index 00000000000..ecc690ea282
--- /dev/null
+++ b/source/blender/functions/backends/llvm/build_ir_body.cpp
@@ -0,0 +1,16 @@
+#include "build_ir_body.hpp"
+
+namespace FN {
+
+       const char *LLVMBuildIRBody::identifier_in_composition()
+       {
+               return "LLVM Gen Body";
+       }
+
+       void LLVMBuildIRBody::free_self(void *value)
+       {
+               LLVMBuildIRBody *v = (LLVMBuildIRBody *)value;
+               delete v;
+       }
+
+} /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/backends/llvm/llvm_gen.hpp 
b/source/blender/functions/backends/llvm/build_ir_body.hpp
similarity index 82%
rename from source/blender/functions/backends/llvm/llvm_gen.hpp
rename to source/blender/functions/backends/llvm/build_ir_body.hpp
index 0105b71ca50..262ac5ce3a5 100644
--- a/source/blender/functions/backends/llvm/llvm_gen.hpp
+++ b/source/blender/functions/backends/llvm/build_ir_body.hpp
@@ -8,12 +8,12 @@ namespace FN {
        using LLVMValues = SmallVector<llvm::Value *>;
        using LLVMTypes = BLI::SmallVector<llvm::Type *>;
 
-       class LLVMGenerateIRBody : public FunctionBody {
+       class LLVMBuildIRBody : public FunctionBody {
        public:
                static const char *identifier_in_composition();
                static void free_self(void *value);
 
-               virtual ~LLVMGenerateIRBody() {};
+               virtual ~LLVMBuildIRBody() {};
 
                virtual void build_ir(
                        llvm::IRBuilder<> &builder,
diff --git a/source/blender/functions/backends/llvm/compiled_body.cpp 
b/source/blender/functions/backends/llvm/compiled_body.cpp
index a1e66646224..b2b384c72bb 100644
--- a/source/blender/functions/backends/llvm/compiled_body.cpp
+++ b/source/blender/functions/backends/llvm/compiled_body.cpp
@@ -6,18 +6,18 @@
 
 namespace FN {
 
-       const char *CompiledLLVMBody::identifier_in_composition()
+       const char *LLVMCompiledBody::identifier_in_composition()
        {
                return "Compiled LLVM Body";
        }
 
-       void CompiledLLVMBody::free_self(void *value)
+       void LLVMCompiledBody::free_self(void *value)
        {
-               CompiledLLVMBody *v = (CompiledLLVMBody *)value;
+               LLVMCompiledBody *v = (LLVMCompiledBody *)value;
                delete v;
        }
 
-       static CompiledLLVMBody *compile_llvm_body(
+       static LLVMCompiledBody *compile_body(
                SharedFunction &fn,
                llvm::LLVMContext &context)
        {
@@ -47,7 +47,7 @@ namespace FN {
                llvm::BasicBlock *bb = llvm::BasicBlock::Create(context, 
"entry", function);
                llvm::IRBuilder<> builder(bb);
 
-               LLVMGenerateIRBody *gen_body = fn->body<LLVMGenerateIRBody>();
+               LLVMBuildIRBody *gen_body = fn->body<LLVMBuildIRBody>();
                BLI_assert(gen_body);
 
                LLVMValues output_values;
@@ -61,23 +61,17 @@ namespace FN {
                builder.CreateRet(return_value);
 
                auto compiled = CompiledLLVM::FromIR(module, function);
-               return new CompiledLLVMBody(std::move(compiled));
+               return new LLVMCompiledBody(std::move(compiled));
        }
 
-       bool try_ensure_CompiledLLVMBody(
+       void derive_CompiledLLVMBody_from_LLVMBuildIRBody(
                SharedFunction &fn,
                llvm::LLVMContext &context)
        {
-               if (fn->body<CompiledLLVMBody>() != nullptr) {
-                       return true;
-               }
-
-               if (fn->body<LLVMGenerateIRBody>() != nullptr) {
-                       fn->add_body(compile_llvm_body(fn, context));
-                       return true;
-               }
+               BLI_assert(fn->has_body<LLVMBuildIRBody>());
+               BLI_assert(!fn->has_body<LLVMCompiledBody>());
 
-               return false;
+               fn->add_body(compile_body(fn, context));
        }
 
 } /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/backends/llvm/compiled_body.hpp 
b/source/blender/functions/backends/llvm/compiled_body.hpp
index c35e8556cf9..3b660eb27d0 100644
--- a/source/blender/functions/backends/llvm/compiled_body.hpp
+++ b/source/blender/functions/backends/llvm/compiled_body.hpp
@@ -12,17 +12,17 @@ namespace llvm {
 
 namespace FN {
 
-       class CompiledLLVMBody : public FunctionBody {
+       class LLVMCompiledBody : public FunctionBody {
        private:
                std::unique_ptr<CompiledLLVM> m_compiled;
 
-               CompiledLLVMBody() = default;
+               LLVMCompiledBody() = default;
 
        public:
                static const char *identifier_in_composition();
                static void free_self(void *value);
 
-               CompiledLLVMBody(std::unique_ptr<CompiledLLVM> compiled)
+               LLVMCompiledBody(std::unique_ptr<CompiledLLVM> compiled)
                        : m_compiled(std::move(compiled)) {}
 
                void *function_ptr()
@@ -31,7 +31,7 @@ namespace FN {
                }
        };
 
-       bool try_ensure_CompiledLLVMBody(
+       void derive_CompiledLLVMBody_from_LLVMBuildIRBody(
                SharedFunction &fn,
                llvm::LLVMContext &context);
 
diff --git a/source/blender/functions/backends/llvm/from_tuple_call.cpp 
b/source/blender/functions/backends/llvm/from_tuple_call.cpp
index 1d9f202c2ee..095af521f77 100644
--- a/source/blender/functions/backends/llvm/from_tuple_call.cpp
+++ b/source/blender/functions/backends/llvm/from_tuple_call.cpp
@@ -25,7 +25,7 @@ namespace FN {
                body->call(*fn_in, *fn_out);
        }
 
-       class TupleCallLLVM : public LLVMGenerateIRBody {
+       class TupleCallLLVM : public LLVMBuildIRBody {
        private:
                TupleCallBody *m_tuple_call;
                SharedTupleMeta m_in_meta;
@@ -148,10 +148,13 @@ namespace FN {
                }
        };
 
-       LLVMGenerateIRBody *llvm_body_for_tuple_call(
-               TupleCallBody *tuple_call_body)
+       void derive_LLVMBuildIRBody_from_TupleCallBody(
+               SharedFunction &fn)
        {
-               return new TupleCallLLVM(tuple_call_body);
+               BLI_assert(fn->has_body<TupleCallBody>());
+               BLI_assert(!fn->has_body<LLVMBuildIRBody>());
+
+               fn->add_body(new TupleCallLLVM(fn->body<TupleCallBody>()));
        }
 
 } /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/backends/llvm/from_tuple_call.hpp 
b/source/blender/functions/backends/llvm/from_tuple_call.hpp
index cd4c2a3c6fc..4025cf70798 100644
--- a/source/blender/functions/backends/llvm/from_tuple_call.hpp
+++ b/source/blender/functions/backends/llvm/from_tuple_call.hpp
@@ -1,13 +1,14 @@
 #pragma once
 
-#include "llvm_gen.hpp"
-#include <llvm/IR/IRBuilder.h>
+#include "FN_core.hpp"
 
-namespace FN {
+namespace llvm {
+       class LLVMContext;
+}
 
-       class TupleCallBody;
+namespace FN {
 
-       LLVMGenerateIRBody *llvm_body_for_tuple_call(
-               TupleCallBody *tuple_call_body);
+       void derive_LLVMBuildIRBody_from_TupleCallBody(
+               SharedFunction &fn);
 
 } /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/backends/llvm/llvm_gen.cpp 
b/source/blender/functions/backends/llvm/llvm_gen.cpp
deleted file mode 100644
index 106b6c7473a..00000000000
--- a/source/blender/functions/backends/llvm/llvm_gen.cpp
+++ /dev/null
@@ -1,16 +0,0 @@
-#include "llvm_gen.hpp"
-
-namespace FN {
-
-       const char *LLVMGenerateIRBody::identifier_in_composition()
-       {
-               return "LLVM Gen Body";
-       }
-
-       void LLVMGenerateIRBody::free_self(void *value)
-       {
-               LLVMGenerateIRBody *v = (LLVMGenerateIRBody *)value;
-               delete v;
-       }
-
-} /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/backends/llvm/to_tuple_call.cpp 
b/source/blender/functions/backends/llvm/to_tuple_call.cpp
index 3d79888d717..5071d1a5507 100644
--- a/source/blender/functions/backends/llvm/to_tuple_call.cpp
+++ b/source/blender/functions/backends/llvm/to_tuple_call.cpp
@@ -129,7 +129,7 @@ namespace FN {
                SharedFunction &fn,
                llvm::LLVMContext &context)
        {
-               auto *body = fn->body<CompiledLLVMBody>();
+               auto *body = fn->body<LLVMCompiledBody>();
                return compile_ir_to_tuple_call(fn, context, [&fn, body](
                                llvm::IRBuilder<> &builder,
                                const LLVMValues &inputs,
@@ -152,7 +152,7 @@ namespace FN {
                SharedFunction &fn,
                llvm::LLVMContext &context)
        {
-               auto *body = fn->body<LLVMGenerateIRBody>();
+               auto *body = fn->body<LLVMBuildIRBody>();
                return compile_ir_to_tuple_call(fn, context, [body](
                                llvm::IRBuilder<> &builder,
                                const LLVMValues &inputs,
@@ -162,25 +162,24 @@ namespace FN {
                        });
        }
 
-       bool try_ensure_TupleCallBody(
+       void derive_TupleCallBody_from_LLVMBuildIRBody(
                SharedFunction &fn,
                llvm::LLVMContext &context)
        {
-               if (fn->body<TupleCallBody>() != nullptr) {
-                       return true;
-               }
+               BLI_assert(fn->has_body<LLVMBuildIRBody>());
+               BLI_assert(!fn->has_body<TupleCallBody>());
 
-               if (fn->body<CompiledLLVMBody>() != nullptr) {
-                       fn->add_body(build_from_compiled(fn, context));
-                       return true;
-               }
+               fn->add_body(build_from_ir_generator(fn, context));
+       }
 
-               if (fn->body<LLVMGenerateIRBody>() != nullptr) {
-                       fn->add_body(build_from_ir_generator(fn, context));
-                       return true;
-               }
+       void derive_TupleCallBody_from_CompiledLLVMBody(
+               SharedFunction &fn,
+               llvm::LLVMContext &context)
+       {
+               BLI_assert(fn->has_body<LLVMCompiledBody>());
+               BLI_assert(!fn->has_body<TupleCallBody>());
 
-               return false;
+               fn->add_body(build_from_compiled(fn, context));
        }
 
 } /* namespace FN */
\ No newline at end of file
diff --git a/source/blender/functions/backends/llvm/to_tuple_call.hpp 
b/source/blender/functions/backends/llvm/to_tuple_call.hpp
index 016126d992f..6efd3e335bb 100644
--- a/source/blender/functions/backends/llvm/to_tuple_call.hpp
+++ b/source/blender/functions/backends/llvm/to_tuple_call.hpp
@@ -1,13 +1,18 @@
 #pra

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to