[Bf-blender-cvs] [39d4e0182cd] functions: use string ref in llvm ir builder
Jacques Lucke
noreply at git.blender.org
Wed May 15 11:43:19 CEST 2019
Commit: 39d4e0182cd99bb19680ba8b2b1cdbf63bce88e6
Author: Jacques Lucke
Date: Wed May 15 11:39:25 2019 +0200
Branches: functions
https://developer.blender.org/rB39d4e0182cd99bb19680ba8b2b1cdbf63bce88e6
use string ref in llvm ir builder
===================================================================
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 dc3e47ef0af..b2993ff3ee9 100644
--- a/source/blender/functions/backends/llvm/builder.cpp
+++ b/source/blender/functions/backends/llvm/builder.cpp
@@ -80,15 +80,15 @@ static void assert_impl(bool value, const char *message)
}
}
-void CodeBuilder::CreateAssert(llvm::Value *condition, std::string message)
+void CodeBuilder::CreateAssert(llvm::Value *condition, const char *message)
{
llvm::Value *condition_as_byte = this->CreateCastIntTo8(condition, false);
- llvm::Value *message_ptr = this->getInt8Ptr(message.c_str());
+ llvm::Value *message_ptr = this->getInt8Ptr(message);
this->CreateCallPointer(
(void *)assert_impl, {condition_as_byte, message_ptr}, this->getVoidTy(), "Assert");
}
-void CodeBuilder::CreateAssertFalse(std::string message)
+void CodeBuilder::CreateAssertFalse(const char *message)
{
llvm::Value *condition = this->getInt1(false);
this->CreateAssert(condition, message);
@@ -137,7 +137,7 @@ void CodeBuilder::CreatePrintfWithStacktrace(llvm::Value *context_ptr,
/* For Loop
******************************************/
-IRConstruct_ForLoop CodeBuilder::CreateForLoop(std::string name)
+IRConstruct_ForLoop CodeBuilder::CreateForLoop(StringRef name)
{
auto entry_block = this->NewBlockInFunction(name + " Entry");
auto condition_block = this->NewBlockInFunction(name + " Condition");
@@ -166,7 +166,7 @@ void IRConstruct_ForLoop::finalize(CodeBuilder &after_builder, llvm::Value *cond
**************************************/
IRConstruct_IterationsLoop CodeBuilder::CreateNIterationsLoop(llvm::Value *iterations,
- std::string name)
+ StringRef name)
{
BLI_assert(iterations->getType()->isIntegerTy());
@@ -194,7 +194,7 @@ void IRConstruct_IterationsLoop::finalize(CodeBuilder &after_builder)
/* If Then Else
************************************/
-IRConstruct_IfThenElse CodeBuilder::CreateIfThenElse(llvm::Value *condition, std::string name)
+IRConstruct_IfThenElse CodeBuilder::CreateIfThenElse(llvm::Value *condition, StringRef name)
{
auto then_block = this->NewBlockInFunction(name + " Then");
auto else_block = this->NewBlockInFunction(name + " Else");
diff --git a/source/blender/functions/backends/llvm/builder.hpp b/source/blender/functions/backends/llvm/builder.hpp
index 43249388c39..d02340ae774 100644
--- a/source/blender/functions/backends/llvm/builder.hpp
+++ b/source/blender/functions/backends/llvm/builder.hpp
@@ -167,15 +167,16 @@ class CodeBuilder {
/* Create new blocks
**************************************/
- llvm::BasicBlock *NewBlockInFunction(std::string name)
+ llvm::BasicBlock *NewBlockInFunction(StringRef name)
{
- auto *new_block = llvm::BasicBlock::Create(this->getContext(), name, this->GetFunction());
+ auto *new_block = llvm::BasicBlock::Create(
+ this->getContext(), name.data(), this->GetFunction());
return new_block;
}
- CodeBuilder NewBuilderInNewBlock(std::string name)
+ CodeBuilder NewBuilderInNewBlock(StringRef name)
{
- return CodeBuilder(this->NewBlockInFunction(name));
+ return CodeBuilder(this->NewBlockInFunction(name.data()));
}
/* Misc
@@ -435,8 +436,8 @@ class CodeBuilder {
return output;
}
- void CreateAssert(llvm::Value *condition, std::string message = "");
- void CreateAssertFalse(std::string message = "");
+ void CreateAssert(llvm::Value *condition, const char *message = "");
+ void CreateAssertFalse(const char *message = "");
/* Print
**************************************/
@@ -449,9 +450,9 @@ class CodeBuilder {
/* Control Flow Construction
**************************************/
- IRConstruct_ForLoop CreateForLoop(std::string name = "");
- IRConstruct_IterationsLoop CreateNIterationsLoop(llvm::Value *iterations, std::string name = "");
- IRConstruct_IfThenElse CreateIfThenElse(llvm::Value *condition, std::string name = "");
+ IRConstruct_ForLoop CreateForLoop(StringRef name = "");
+ IRConstruct_IterationsLoop CreateNIterationsLoop(llvm::Value *iterations, StringRef name = "");
+ IRConstruct_IfThenElse CreateIfThenElse(llvm::Value *condition, StringRef name = "");
};
class IRConstruct_ForLoop {
More information about the Bf-blender-cvs
mailing list