Skip to content

Commit 378ff28

Browse files
committed
Pass LLVMBuildUtils to LLVMCodeAnalyzer
1 parent 9baa20a commit 378ff28

File tree

6 files changed

+249
-234
lines changed

6 files changed

+249
-234
lines changed

src/engine/internal/llvm/llvmcodeanalyzer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ static const std::unordered_set<LLVMInstruction::Type> BEGIN_LOOP_INSTRUCTIONS =
1212

1313
static const std::unordered_set<LLVMInstruction::Type> LIST_WRITE_INSTRUCTIONS = { LLVMInstruction::Type::AppendToList, LLVMInstruction::Type::InsertToList, LLVMInstruction::Type::ListReplace };
1414

15+
LLVMCodeAnalyzer::LLVMCodeAnalyzer(const LLVMBuildUtils &utils) :
16+
m_utils(utils)
17+
{
18+
}
19+
1520
void LLVMCodeAnalyzer::analyzeScript(const LLVMInstructionList &script) const
1621
{
1722
std::unordered_set<LLVMInstruction *> typeAssignedInstructions;

src/engine/internal/llvm/llvmcodeanalyzer.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,16 @@
88
namespace libscratchcpp
99
{
1010

11+
class LLVMBuildUtils;
1112
class LLVMInstructionList;
1213
class LLVMInstruction;
1314

1415
class LLVMCodeAnalyzer
1516
{
1617
public:
18+
LLVMCodeAnalyzer(const LLVMBuildUtils &utils);
19+
LLVMCodeAnalyzer(const LLVMCodeAnalyzer &) = delete;
20+
1721
void analyzeScript(const LLVMInstructionList &script) const;
1822

1923
private:
@@ -50,6 +54,8 @@ class LLVMCodeAnalyzer
5054
bool isProcedureCall(const LLVMInstruction *ins) const;
5155

5256
Compiler::StaticType writeType(LLVMInstruction *ins) const;
57+
58+
const LLVMBuildUtils &m_utils;
5359
};
5460

5561
} // namespace libscratchcpp

src/engine/internal/llvm/llvmcodebuilder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ LLVMCodeBuilder::LLVMCodeBuilder(LLVMCompilerContext *ctx, BlockPrototype *proce
2828
m_module(ctx->module()),
2929
m_builder(m_llvmCtx),
3030
m_utils(ctx, m_builder, codeType),
31+
m_codeAnalyzer(m_utils),
3132
m_procedurePrototype(procedurePrototype),
3233
m_defaultWarp(procedurePrototype ? procedurePrototype->warp() : false),
3334
m_warp(m_defaultWarp),

0 commit comments

Comments
 (0)