[Bf-blender-cvs] [989c2691ac0] functions: improve ir loop constructs
Jacques Lucke
noreply at git.blender.org
Mon May 13 10:16:31 CEST 2019
Commit: 989c2691ac05f8729ca65b3ccf8fe1b9e2288f7b
Author: Jacques Lucke
Date: Thu May 9 10:31:22 2019 +0200
Branches: functions
https://developer.blender.org/rB989c2691ac05f8729ca65b3ccf8fe1b9e2288f7b
improve ir loop constructs
===================================================================
M source/blender/functions/backends/llvm/builder.cpp
M source/blender/functions/backends/llvm/builder.hpp
M source/blender/functions/functions/auto_vectorization.cpp
===================================================================
diff --git a/source/blender/functions/backends/llvm/builder.cpp b/source/blender/functions/backends/llvm/builder.cpp
index 9a9dfa66254..87adc230bc5 100644
--- a/source/blender/functions/backends/llvm/builder.cpp
+++ b/source/blender/functions/backends/llvm/builder.cpp
@@ -115,7 +115,7 @@ void CodeBuilder::CreatePrintFloat(llvm::Value *value)
/* For Loop
******************************************/
-LLVMForLoopData CodeBuilder::CreateForLoop(std::string name)
+IRConstruct_ForLoop CodeBuilder::CreateForLoop(std::string name)
{
auto entry_block = this->NewBlockInFunction(name + " Entry");
auto condition_block = this->NewBlockInFunction(name + " Condition");
@@ -127,36 +127,36 @@ LLVMForLoopData CodeBuilder::CreateForLoop(std::string name)
this->CreateBr(entry_block);
- return LLVMForLoopData(entry_builder, condition_builder, body_builder);
+ return IRConstruct_ForLoop(entry_builder, condition_builder, body_builder);
}
-CodeBuilder LLVMForLoopData::finalize(llvm::Value *condition)
+llvm::BasicBlock *IRConstruct_ForLoop::finalize(llvm::Value *condition)
{
m_entry.CreateBr(m_condition_entry);
m_body.CreateBr(m_condition_entry);
auto after_block = m_entry.NewBlockInFunction("After Loop");
m_condition.CreateCondBr(condition, m_body_entry, after_block);
- return CodeBuilder(after_block);
+ return after_block;
}
/* Iterations Loop
**************************************/
-LLVMIterationsLoopData CodeBuilder::CreateNIterationsLoop(llvm::Value *iterations,
- std::string name)
+IRConstruct_IterationsLoop CodeBuilder::CreateNIterationsLoop(llvm::Value *iterations,
+ std::string name)
{
BLI_assert(iterations->getType()->isIntegerTy());
- LLVMForLoopData loop = this->CreateForLoop(name);
+ IRConstruct_ForLoop loop = this->CreateForLoop(name);
CodeBuilder &condition_builder = loop.condition_builder();
llvm::PHINode *current_iteration = condition_builder.CreatePhi(iterations->getType(), 2);
- return LLVMIterationsLoopData(loop, iterations, current_iteration);
+ return IRConstruct_IterationsLoop(loop, iterations, current_iteration);
}
-CodeBuilder LLVMIterationsLoopData::finalize()
+llvm::BasicBlock *IRConstruct_IterationsLoop::finalize()
{
CodeBuilder &entry_builder = m_loop.entry_builder();
CodeBuilder &condition_builder = m_loop.condition_builder();
diff --git a/source/blender/functions/backends/llvm/builder.hpp b/source/blender/functions/backends/llvm/builder.hpp
index 8b8109a8ffa..16d55f48ce9 100644
--- a/source/blender/functions/backends/llvm/builder.hpp
+++ b/source/blender/functions/backends/llvm/builder.hpp
@@ -10,8 +10,8 @@ using LLVMTypes = BLI::SmallVector<llvm::Type *>;
using LLVMValuesRef = ArrayRef<llvm::Value *>;
class LLVMTypeInfo;
-class LLVMForLoopData;
-class LLVMIterationsLoopData;
+class IRConstruct_ForLoop;
+class IRConstruct_IterationsLoop;
template<typename T> static llvm::ArrayRef<T> to_llvm_array_ref(const SmallVector<T> &vector)
{
@@ -392,11 +392,11 @@ class CodeBuilder {
/* Control Flow Construction
**************************************/
- LLVMForLoopData CreateForLoop(std::string name = "");
- LLVMIterationsLoopData CreateNIterationsLoop(llvm::Value *iterations, std::string name = "");
+ IRConstruct_ForLoop CreateForLoop(std::string name = "");
+ IRConstruct_IterationsLoop CreateNIterationsLoop(llvm::Value *iterations, std::string name = "");
};
-class LLVMForLoopData {
+class IRConstruct_ForLoop {
private:
CodeBuilder m_entry;
CodeBuilder m_condition;
@@ -406,7 +406,7 @@ class LLVMForLoopData {
llvm::BasicBlock *m_body_entry;
public:
- LLVMForLoopData(CodeBuilder entry, CodeBuilder condition, CodeBuilder body)
+ IRConstruct_ForLoop(CodeBuilder entry, CodeBuilder condition, CodeBuilder body)
: m_entry(entry),
m_condition(condition),
m_body(body),
@@ -430,19 +430,19 @@ class LLVMForLoopData {
return m_body;
}
- CodeBuilder finalize(llvm::Value *condition);
+ llvm::BasicBlock *finalize(llvm::Value *condition);
};
-class LLVMIterationsLoopData {
+class IRConstruct_IterationsLoop {
private:
- LLVMForLoopData m_loop;
+ IRConstruct_ForLoop m_loop;
llvm::Value *m_iterations;
llvm::PHINode *m_current_iteration;
public:
- LLVMIterationsLoopData(LLVMForLoopData loop,
- llvm::Value *iterations,
- llvm::PHINode *current_iteration)
+ IRConstruct_IterationsLoop(IRConstruct_ForLoop loop,
+ llvm::Value *iterations,
+ llvm::PHINode *current_iteration)
: m_loop(loop), m_iterations(iterations), m_current_iteration(current_iteration)
{
}
@@ -457,7 +457,7 @@ class LLVMIterationsLoopData {
return m_current_iteration;
}
- CodeBuilder finalize();
+ llvm::BasicBlock *finalize();
};
} /* namespace FN */
diff --git a/source/blender/functions/functions/auto_vectorization.cpp b/source/blender/functions/functions/auto_vectorization.cpp
index 424c03ffa32..7e6cd9e1d17 100644
--- a/source/blender/functions/functions/auto_vectorization.cpp
+++ b/source/blender/functions/functions/auto_vectorization.cpp
@@ -86,7 +86,7 @@ class AutoVectorizationGen : public LLVMBuildIRBody {
this->store_computed_values_in_output_lists(
body_builder, main_outputs, output_data_pointers, iteration);
- builder.SetInsertPoint(loop.finalize().GetInsertBlock());
+ builder.SetInsertPoint(loop.finalize());
this->free_input_lists(builder, interface);
}
More information about the Bf-blender-cvs
mailing list