Skip to content

Commit 33a6930

Browse files
committed
Add integer support to string instructions
1 parent e43091b commit 33a6930

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/engine/internal/llvm/instructions/string.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ LLVMInstruction *String::buildStringChar(LLVMInstruction *ins)
8585
const auto &arg1 = ins->args[0];
8686
const auto &arg2 = ins->args[1];
8787
llvm::Value *str = m_utils.castValue(arg1.second, arg1.first);
88-
llvm::Value *index = m_builder.CreateFPToSI(m_utils.castValue(arg2.second, arg2.first), m_builder.getInt64Ty());
88+
llvm::Value *index = m_utils.castValue(arg2.second, arg2.first, LLVMBuildUtils::NumberType::Int);
8989
llvm::PointerType *charPointerType = m_builder.getInt16Ty()->getPointerTo();
9090
llvm::StructType *stringPtrType = m_utils.compilerCtx()->stringPtrType();
9191

@@ -131,6 +131,8 @@ LLVMInstruction *String::buildStringLength(LLVMInstruction *ins)
131131
llvm::Value *sizeField = m_builder.CreateStructGEP(stringPtrType, str, 1);
132132
llvm::Value *size = m_builder.CreateLoad(m_builder.getInt64Ty(), sizeField);
133133
ins->functionReturnReg->value = m_builder.CreateSIToFP(size, m_builder.getDoubleTy());
134+
ins->functionReturnReg->intValue = size;
135+
ins->functionReturnReg->isInt = m_builder.getInt1(true);
134136

135137
return ins->next;
136138
}

0 commit comments

Comments
 (0)