[Bf-blender-cvs] [9880a1b3667] functions: printing from Ir cleanup
Jacques Lucke
noreply at git.blender.org
Mon May 13 10:16:35 CEST 2019
Commit: 9880a1b36674dfcb5d43b75167bfd4c1383924bb
Author: Jacques Lucke
Date: Thu May 9 10:57:30 2019 +0200
Branches: functions
https://developer.blender.org/rB9880a1b36674dfcb5d43b75167bfd4c1383924bb
printing from Ir cleanup
===================================================================
M source/blender/functions/backends/llvm/builder.cpp
M source/blender/functions/backends/llvm/builder.hpp
===================================================================
diff --git a/source/blender/functions/backends/llvm/builder.cpp b/source/blender/functions/backends/llvm/builder.cpp
index 30de07bacbe..2b8d91265cb 100644
--- a/source/blender/functions/backends/llvm/builder.cpp
+++ b/source/blender/functions/backends/llvm/builder.cpp
@@ -90,26 +90,21 @@ llvm::Value *CodeBuilder::CreateCallPointer(void *func_ptr,
return this->CreateCallPointer(func_ptr, LLVMValuesRef(args), return_type, function_name);
}
-static void simple_print(const char *str)
+template<typename T> void simple_print(T value)
{
- std::cout << str << std::endl;
+ std::cout << value;
}
void CodeBuilder::CreatePrint(const char *str)
{
this->CreateCallPointer(
- (void *)simple_print, {this->getVoidPtr((void *)str)}, this->getVoidTy());
-}
-
-static void simple_print_float(float value)
-{
- std::cout << value << std::endl;
+ (void *)simple_print<const char *>, {this->getVoidPtr((void *)str)}, this->getVoidTy());
}
void CodeBuilder::CreatePrintFloat(llvm::Value *value)
{
BLI_assert(value->getType()->isFloatTy());
- this->CreateCallPointer((void *)simple_print_float, {value}, this->getVoidTy());
+ this->CreateCallPointer((void *)simple_print<float>, {value}, this->getVoidTy());
}
/* For Loop
diff --git a/source/blender/functions/backends/llvm/builder.hpp b/source/blender/functions/backends/llvm/builder.hpp
index bc97ec9a7fc..6f96531bf80 100644
--- a/source/blender/functions/backends/llvm/builder.hpp
+++ b/source/blender/functions/backends/llvm/builder.hpp
@@ -182,9 +182,6 @@ class CodeBuilder {
return m_builder.CreateICmpULT(a, b);
}
- void CreatePrint(const char *str);
- void CreatePrintFloat(llvm::Value *value);
-
void CreateBr(llvm::BasicBlock *destination_block)
{
m_builder.CreateBr(destination_block);
@@ -390,6 +387,12 @@ class CodeBuilder {
return output;
}
+ /* Print
+ **************************************/
+
+ void CreatePrint(const char *str);
+ void CreatePrintFloat(llvm::Value *value);
+
/* Control Flow Construction
**************************************/
More information about the Bf-blender-cvs
mailing list