Skip to content

Commit 693c464

Browse files
committed
LLVMCodeBuilder: Store list read/write instructions
1 parent c1674b2 commit 693c464

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/engine/internal/llvm/llvmcodebuilder.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1319,6 +1319,7 @@ CompilerValue *LLVMCodeBuilder::addListItem(List *list, CompilerValue *index)
13191319
ins->functionReturnReg = ret.get();
13201320

13211321
m_instructions.push_back(ins);
1322+
m_listInstructions.push_back(m_instructions.back());
13221323
return addReg(ret, ins);
13231324
}
13241325

@@ -1330,7 +1331,9 @@ CompilerValue *LLVMCodeBuilder::addListItemIndex(List *list, CompilerValue *item
13301331
if (m_listPtrs.find(list) == m_listPtrs.cend())
13311332
m_listPtrs[list] = LLVMListPtr();
13321333

1333-
return createOp(ins, Compiler::StaticType::Number, Compiler::StaticType::Unknown, { item });
1334+
auto ret = createOp(ins, Compiler::StaticType::Number, Compiler::StaticType::Unknown, { item });
1335+
m_listInstructions.push_back(m_instructions.back());
1336+
return ret;
13341337
}
13351338

13361339
CompilerValue *LLVMCodeBuilder::addListContains(List *list, CompilerValue *item)
@@ -1341,7 +1344,9 @@ CompilerValue *LLVMCodeBuilder::addListContains(List *list, CompilerValue *item)
13411344
if (m_listPtrs.find(list) == m_listPtrs.cend())
13421345
m_listPtrs[list] = LLVMListPtr();
13431346

1344-
return createOp(ins, Compiler::StaticType::Bool, Compiler::StaticType::Unknown, { item });
1347+
auto ret = createOp(ins, Compiler::StaticType::Bool, Compiler::StaticType::Unknown, { item });
1348+
m_listInstructions.push_back(m_instructions.back());
1349+
return ret;
13451350
}
13461351

13471352
CompilerValue *LLVMCodeBuilder::addListSize(List *list)
@@ -1593,6 +1598,8 @@ void LLVMCodeBuilder::createListAppend(List *list, CompilerValue *item)
15931598

15941599
if (m_listPtrs.find(list) == m_listPtrs.cend())
15951600
m_listPtrs[list] = LLVMListPtr();
1601+
1602+
m_listInstructions.push_back(m_instructions.back());
15961603
}
15971604

15981605
void LLVMCodeBuilder::createListInsert(List *list, CompilerValue *index, CompilerValue *item)
@@ -1603,6 +1610,8 @@ void LLVMCodeBuilder::createListInsert(List *list, CompilerValue *index, Compile
16031610

16041611
if (m_listPtrs.find(list) == m_listPtrs.cend())
16051612
m_listPtrs[list] = LLVMListPtr();
1613+
1614+
m_listInstructions.push_back(m_instructions.back());
16061615
}
16071616

16081617
void LLVMCodeBuilder::createListReplace(List *list, CompilerValue *index, CompilerValue *item)
@@ -1613,6 +1622,8 @@ void LLVMCodeBuilder::createListReplace(List *list, CompilerValue *index, Compil
16131622

16141623
if (m_listPtrs.find(list) == m_listPtrs.cend())
16151624
m_listPtrs[list] = LLVMListPtr();
1625+
1626+
m_listInstructions.push_back(m_instructions.back());
16161627
}
16171628

16181629
void LLVMCodeBuilder::beginIfStatement(CompilerValue *cond)

src/engine/internal/llvm/llvmcodebuilder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ class LLVMCodeBuilder : public ICodeBuilder
238238
std::vector<long> m_loopScopeTree;
239239
bool m_loopCondition = false; // whether we're currently compiling a loop condition
240240
std::vector<std::shared_ptr<LLVMInstruction>> m_variableInstructions;
241+
std::vector<std::shared_ptr<LLVMInstruction>> m_listInstructions;
241242
std::vector<std::vector<llvm::Value *>> m_heap; // scopes
242243

243244
std::shared_ptr<ExecutableCode> m_output;

0 commit comments

Comments
 (0)