Skip to content

Commit 0e92dc8

Browse files
committed
LLVMCodeBuilder: Make createOp() universal
1 parent 361fbb0 commit 0e92dc8

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/dev/engine/internal/llvmcodebuilder.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -454,22 +454,22 @@ void LLVMCodeBuilder::addListContents(List *list)
454454

455455
void LLVMCodeBuilder::createAdd()
456456
{
457-
createOp(Step::Type::Add, 2);
457+
createOp(Step::Type::Add, Compiler::StaticType::Number, 2);
458458
}
459459

460460
void LLVMCodeBuilder::createSub()
461461
{
462-
createOp(Step::Type::Sub, 2);
462+
createOp(Step::Type::Sub, Compiler::StaticType::Number, 2);
463463
}
464464

465465
void LLVMCodeBuilder::createMul()
466466
{
467-
createOp(Step::Type::Mul, 2);
467+
createOp(Step::Type::Mul, Compiler::StaticType::Number, 2);
468468
}
469469

470470
void LLVMCodeBuilder::createDiv()
471471
{
472-
createOp(Step::Type::Div, 2);
472+
createOp(Step::Type::Div, Compiler::StaticType::Number, 2);
473473
}
474474

475475
void LLVMCodeBuilder::beginIfStatement()
@@ -844,7 +844,7 @@ llvm::Value *LLVMCodeBuilder::removeNaN(llvm::Value *num)
844844
return m_builder.CreateSelect(isNaN, llvm::ConstantFP::get(m_ctx, llvm::APFloat(0.0)), num);
845845
}
846846

847-
void LLVMCodeBuilder::createOp(Step::Type type, size_t argCount)
847+
void LLVMCodeBuilder::createOp(Step::Type type, Compiler::StaticType retType, size_t argCount)
848848
{
849849
Step step(type);
850850

@@ -856,7 +856,7 @@ void LLVMCodeBuilder::createOp(Step::Type type, size_t argCount)
856856

857857
m_tmpRegs.erase(m_tmpRegs.end() - argCount, m_tmpRegs.end());
858858

859-
auto ret = std::make_shared<Register>(Compiler::StaticType::Number);
859+
auto ret = std::make_shared<Register>(retType);
860860
ret->isRawValue = true;
861861
step.functionReturnReg = ret;
862862
m_regs[m_currentFunction].push_back(ret);

src/dev/engine/internal/llvmcodebuilder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,8 @@ class LLVMCodeBuilder : public ICodeBuilder
135135
llvm::Type *getType(Compiler::StaticType type);
136136
llvm::Value *removeNaN(llvm::Value *num);
137137

138-
void createOp(Step::Type type, size_t argCount);
138+
void createOp(Step::Type type, Compiler::StaticType retType, size_t argCount);
139+
llvm::Value *createValue(std::shared_ptr<Register> reg);
139140

140141
llvm::FunctionCallee resolveFunction(const std::string name, llvm::FunctionType *type);
141142
llvm::FunctionCallee resolve_value_init();

0 commit comments

Comments
 (0)