Skip to content

Commit ba37c7f

Browse files
committed
Drop LLVMLoopScope
It was used by the old type analysis algorithm.
1 parent baa3435 commit ba37c7f

13 files changed

+1908
-2018
lines changed

src/engine/internal/llvm/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ target_sources(scratchcpp
1717
llvmtypes.h
1818
llvmfunctions.cpp
1919
llvmfunctions.h
20-
llvmloopscope.h
2120
llvmtypeanalyzer.cpp
2221
llvmtypeanalyzer.h
2322
llvmcompilercontext.cpp

src/engine/internal/llvm/llvmcodebuilder.cpp

Lines changed: 30 additions & 98 deletions
Large diffs are not rendered by default.

src/engine/internal/llvm/llvmcodebuilder.h

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ namespace libscratchcpp
2323

2424
class LLVMCompilerContext;
2525
class LLVMConstantRegister;
26-
class LLVMLoopScope;
2726

2827
class LLVMCodeBuilder : public ICodeBuilder
2928
{
@@ -127,8 +126,6 @@ class LLVMCodeBuilder : public ICodeBuilder
127126
void createListMap();
128127
void pushScopeLevel();
129128
void popScopeLevel();
130-
void pushLoopScope(bool buildPhase);
131-
void popLoopScope();
132129

133130
std::string getMainFunctionName(BlockPrototype *procedurePrototype);
134131
llvm::FunctionType *getMainFunctionType(BlockPrototype *procedurePrototype);
@@ -159,7 +156,6 @@ class LLVMCodeBuilder : public ICodeBuilder
159156
LLVMRegister *createOp(LLVMInstruction::Type type, Compiler::StaticType retType, const Compiler::ArgTypes &argTypes = {}, const Compiler::Args &args = {});
160157
LLVMRegister *createOp(const LLVMInstruction &ins, Compiler::StaticType retType, Compiler::StaticType argType, const Compiler::Args &args);
161158
LLVMRegister *createOp(const LLVMInstruction &ins, Compiler::StaticType retType, const Compiler::ArgTypes &argTypes = {}, const Compiler::Args &args = {});
162-
LLVMLoopScope *currentLoopScope() const;
163159

164160
void createValueStore(LLVMRegister *reg, llvm::Value *targetPtr, Compiler::StaticType sourceType, Compiler::StaticType targetType);
165161
void createReusedValueStore(LLVMRegister *reg, llvm::Value *targetPtr, Compiler::StaticType sourceType, Compiler::StaticType targetType);
@@ -203,16 +199,10 @@ class LLVMCodeBuilder : public ICodeBuilder
203199
int m_defaultArgCount = 0;
204200
Compiler::CodeType m_codeType = Compiler::CodeType::Script;
205201

206-
long m_loopScope = -1; // index
207-
std::vector<std::shared_ptr<LLVMLoopScope>> m_loopScopes;
208-
long m_loopScopeCounter = 0; // replacement for m_loopScopes size in build phase
209-
std::vector<long> m_loopScopeTree;
210202
bool m_loopCondition = false; // whether we're currently compiling a loop condition
211203
std::vector<LLVMInstruction *> m_variableInstructions;
212204
std::vector<LLVMInstruction *> m_listInstructions;
213205
std::vector<std::vector<llvm::Value *>> m_stringHeap; // scopes
214-
215-
std::shared_ptr<ExecutableCode> m_output;
216206
};
217207

218208
} // namespace libscratchcpp

src/engine/internal/llvm/llvminstruction.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ namespace libscratchcpp
1010
{
1111

1212
class BlockPrototype;
13-
class LLVMLoopScope;
1413

1514
struct LLVMInstruction
1615
{
@@ -81,9 +80,8 @@ struct LLVMInstruction
8180
ProcedureArg
8281
};
8382

84-
LLVMInstruction(Type type, LLVMLoopScope *loopScope, bool loopCondition) :
83+
LLVMInstruction(Type type, bool loopCondition) :
8584
type(type),
86-
loopScope(loopScope),
8785
loopCondition(loopCondition)
8886
{
8987
}
@@ -98,7 +96,6 @@ struct LLVMInstruction
9896
List *workList = nullptr; // for lists
9997
BlockPrototype *procedurePrototype = nullptr;
10098
size_t procedureArgIndex = 0;
101-
LLVMLoopScope *loopScope = nullptr;
10299
bool loopCondition = false; // whether the instruction is part of a loop condition
103100

104101
// Linked list

src/engine/internal/llvm/llvmlistptr.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#pragma once
44

55
#include <scratchcpp/compiler.h>
6-
#include <unordered_map>
76

87
namespace llvm
98
{
@@ -15,7 +14,6 @@ class Value;
1514
namespace libscratchcpp
1615
{
1716

18-
class LLVMLoopScope;
1917
class LLVMInstruction;
2018

2119
struct LLVMListPtr
@@ -24,9 +22,6 @@ struct LLVMListPtr
2422
llvm::Value *dataPtr = nullptr;
2523
llvm::Value *sizePtr = nullptr;
2624
llvm::Value *allocatedSizePtr = nullptr;
27-
28-
// Used in build phase to check the type safety of lists in loops
29-
std::unordered_map<LLVMLoopScope *, std::vector<LLVMInstruction *>> loopListWrites; // loop scope, write instructions
3025
};
3126

3227
} // namespace libscratchcpp

src/engine/internal/llvm/llvmloopscope.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/engine/internal/llvm/llvmvariableptr.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#pragma once
44

55
#include <scratchcpp/compiler.h>
6-
#include <unordered_map>
76

87
namespace llvm
98
{
@@ -15,7 +14,6 @@ class Value;
1514
namespace libscratchcpp
1615
{
1716

18-
class LLVMLoopScope;
1917
class LLVMInstruction;
2018

2119
struct LLVMVariablePtr
@@ -24,9 +22,6 @@ struct LLVMVariablePtr
2422
llvm::Value *heapPtr = nullptr;
2523
bool onStack = false;
2624
bool changed = false;
27-
28-
// Used in build phase to check the type safety of variables in loops
29-
std::unordered_map<LLVMLoopScope *, std::vector<LLVMInstruction *>> loopVariableWrites; // loop scope, write instructions
3025
};
3126

3227
} // namespace libscratchcpp

0 commit comments

Comments
 (0)