Skip to content

Commit

Permalink
LLVMCodeBuilder: Store list read/write instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
adazem009 committed Jan 18, 2025
1 parent c1674b2 commit 0fdcc76
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/engine/internal/llvm/llvmcodebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1319,6 +1319,7 @@ CompilerValue *LLVMCodeBuilder::addListItem(List *list, CompilerValue *index)
ins->functionReturnReg = ret.get();

m_instructions.push_back(ins);
m_listInstructions.push_back(m_instructions.back());
return addReg(ret, ins);
}

Expand All @@ -1330,6 +1331,7 @@ CompilerValue *LLVMCodeBuilder::addListItemIndex(List *list, CompilerValue *item
if (m_listPtrs.find(list) == m_listPtrs.cend())
m_listPtrs[list] = LLVMListPtr();

m_listInstructions.push_back(m_instructions.back());
return createOp(ins, Compiler::StaticType::Number, Compiler::StaticType::Unknown, { item });
}

Expand All @@ -1341,6 +1343,7 @@ CompilerValue *LLVMCodeBuilder::addListContains(List *list, CompilerValue *item)
if (m_listPtrs.find(list) == m_listPtrs.cend())
m_listPtrs[list] = LLVMListPtr();

m_listInstructions.push_back(m_instructions.back());
return createOp(ins, Compiler::StaticType::Bool, Compiler::StaticType::Unknown, { item });
}

Expand Down Expand Up @@ -1593,6 +1596,8 @@ void LLVMCodeBuilder::createListAppend(List *list, CompilerValue *item)

if (m_listPtrs.find(list) == m_listPtrs.cend())
m_listPtrs[list] = LLVMListPtr();

m_listInstructions.push_back(m_instructions.back());
}

void LLVMCodeBuilder::createListInsert(List *list, CompilerValue *index, CompilerValue *item)
Expand All @@ -1603,6 +1608,8 @@ void LLVMCodeBuilder::createListInsert(List *list, CompilerValue *index, Compile

if (m_listPtrs.find(list) == m_listPtrs.cend())
m_listPtrs[list] = LLVMListPtr();

m_listInstructions.push_back(m_instructions.back());
}

void LLVMCodeBuilder::createListReplace(List *list, CompilerValue *index, CompilerValue *item)
Expand All @@ -1613,6 +1620,8 @@ void LLVMCodeBuilder::createListReplace(List *list, CompilerValue *index, Compil

if (m_listPtrs.find(list) == m_listPtrs.cend())
m_listPtrs[list] = LLVMListPtr();

m_listInstructions.push_back(m_instructions.back());
}

void LLVMCodeBuilder::beginIfStatement(CompilerValue *cond)
Expand Down
1 change: 1 addition & 0 deletions src/engine/internal/llvm/llvmcodebuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ class LLVMCodeBuilder : public ICodeBuilder
std::vector<long> m_loopScopeTree;
bool m_loopCondition = false; // whether we're currently compiling a loop condition
std::vector<std::shared_ptr<LLVMInstruction>> m_variableInstructions;
std::vector<std::shared_ptr<LLVMInstruction>> m_listInstructions;
std::vector<std::vector<llvm::Value *>> m_heap; // scopes

std::shared_ptr<ExecutableCode> m_output;
Expand Down

0 comments on commit 0fdcc76

Please sign in to comment.