Skip to content

Commit 276222f

Browse files
committed
Remove stop without sync instruction
1 parent daba5a4 commit 276222f

File tree

10 files changed

+6
-49
lines changed

10 files changed

+6
-49
lines changed

include/scratchcpp/compiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,9 @@ class LIBSCRATCHCPP_EXPORT Compiler
149149
void warp();
150150

151151
void createYield();
152+
152153
void createStop();
153154
void createThreadStop();
154-
void createStopWithoutSync();
155155

156156
void invalidateTarget();
157157

src/engine/compiler.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -711,16 +711,6 @@ void Compiler::createThreadStop()
711711
impl->builder->createThreadStop();
712712
}
713713

714-
/*!
715-
* Creates a stop script without synchronization instruction.\n
716-
* Use this if synchronization is not possible at the stop point.
717-
* \note Only use this when everything is synchronized, e. g. after a function call.
718-
*/
719-
void Compiler::createStopWithoutSync()
720-
{
721-
impl->builder->createStopWithoutSync();
722-
}
723-
724714
/*!
725715
* Creates a sprite/stage invalidation point.\n
726716
* Use this if synchronization is not possible because the target has been deleted.

src/engine/internal/icodebuilder.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ class ICodeBuilder
100100

101101
virtual void createStop() = 0;
102102
virtual void createThreadStop() = 0;
103-
virtual void createStopWithoutSync() = 0;
104103

105104
virtual void invalidateTarget() = 0;
106105

src/engine/internal/llvm/instructions/control.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,6 @@ ProcessResult Control::process(LLVMInstruction *ins)
6464
ret.next = buildThreadStop(ins);
6565
break;
6666

67-
case LLVMInstruction::Type::StopWithoutSync:
68-
ret.next = buildStopWithoutSync(ins);
69-
break;
70-
7167
case LLVMInstruction::Type::InvalidateTarget:
7268
ret.next = buildInvalidateTarget(ins);
7369
break;
@@ -345,23 +341,19 @@ LLVMInstruction *Control::buildEndLoop(LLVMInstruction *ins)
345341
LLVMInstruction *Control::buildStop(LLVMInstruction *ins)
346342
{
347343
m_utils.syncVariables();
348-
return buildStopWithoutSync(ins);
349-
}
350-
351-
LLVMInstruction *Control::buildThreadStop(LLVMInstruction *ins)
352-
{
353-
m_utils.syncVariables();
354-
m_builder.CreateBr(m_utils.endThreadBranch());
355344

345+
m_builder.CreateBr(m_utils.endBranch());
356346
llvm::BasicBlock *nextBranch = llvm::BasicBlock::Create(m_utils.llvmCtx(), "", m_utils.function());
357347
m_builder.SetInsertPoint(nextBranch);
358348

359349
return ins->next;
360350
}
361351

362-
LLVMInstruction *Control::buildStopWithoutSync(LLVMInstruction *ins)
352+
LLVMInstruction *Control::buildThreadStop(LLVMInstruction *ins)
363353
{
364-
m_builder.CreateBr(m_utils.endBranch());
354+
m_utils.syncVariables();
355+
m_builder.CreateBr(m_utils.endThreadBranch());
356+
365357
llvm::BasicBlock *nextBranch = llvm::BasicBlock::Create(m_utils.llvmCtx(), "", m_utils.function());
366358
m_builder.SetInsertPoint(nextBranch);
367359

src/engine/internal/llvm/instructions/control.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ class Control : public InstructionGroup
2828
LLVMInstruction *buildEndLoop(LLVMInstruction *ins);
2929
LLVMInstruction *buildStop(LLVMInstruction *ins);
3030
LLVMInstruction *buildThreadStop(LLVMInstruction *ins);
31-
LLVMInstruction *buildStopWithoutSync(LLVMInstruction *ins);
3231
LLVMInstruction *buildInvalidateTarget(LLVMInstruction *ins);
3332
};
3433

src/engine/internal/llvm/llvmcodebuilder.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -573,12 +573,6 @@ void LLVMCodeBuilder::createThreadStop()
573573
m_instructions.addInstruction(ins);
574574
}
575575

576-
void LLVMCodeBuilder::createStopWithoutSync()
577-
{
578-
auto ins = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::StopWithoutSync, m_loopCondition);
579-
m_instructions.addInstruction(ins);
580-
}
581-
582576
void LLVMCodeBuilder::invalidateTarget()
583577
{
584578
auto ins = std::make_shared<LLVMInstruction>(LLVMInstruction::Type::InvalidateTarget, m_loopCondition);

src/engine/internal/llvm/llvmcodebuilder.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ class LIBSCRATCHCPP_TEST_EXPORT LLVMCodeBuilder : public ICodeBuilder
114114

115115
void createStop() override;
116116
void createThreadStop() override;
117-
void createStopWithoutSync() override;
118117

119118
void invalidateTarget() override;
120119

src/engine/internal/llvm/llvminstruction.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ struct LLVMInstruction
7878
EndLoop,
7979
Stop,
8080
ThreadStop,
81-
StopWithoutSync,
8281
InvalidateTarget,
8382
CallProcedure,
8483
ProcedureArg

test/compiler/compiler_test.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,20 +1687,6 @@ TEST_F(CompilerTest, CreateThreadStop)
16871687
compile(m_compiler.get(), block.get());
16881688
}
16891689

1690-
TEST_F(CompilerTest, CreateStopWithoutSync)
1691-
{
1692-
1693-
auto block = std::make_shared<Block>("", "");
1694-
1695-
block->setCompileFunction([](Compiler *compiler) -> CompilerValue * {
1696-
EXPECT_CALL(*m_builder, createStopWithoutSync());
1697-
compiler->createStopWithoutSync();
1698-
return nullptr;
1699-
});
1700-
1701-
compile(m_compiler.get(), block.get());
1702-
}
1703-
17041690
TEST_F(CompilerTest, InvalidateTarget)
17051691
{
17061692

test/mocks/codebuildermock.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ class CodeBuilderMock : public ICodeBuilder
8989

9090
MOCK_METHOD(void, createStop, (), (override));
9191
MOCK_METHOD(void, createThreadStop, (), (override));
92-
MOCK_METHOD(void, createStopWithoutSync, (), (override));
9392

9493
MOCK_METHOD(void, invalidateTarget, (), (override));
9594

0 commit comments

Comments
 (0)