diff options
| author | _ov4 <ov4@ov4.org> | 2026-10-20 11:57:16 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-10-20 11:57:16 +0000 |
| commit | 62b605c6c0ea13e9763c0a0115464007b13a8831 (patch) | |
| tree | 53c27965f5a365682e0d79fd96e25b228ecb9dca /lib/CodeGen/ArrayParameters.cc | |
| parent | bfe2e75d7e3b372e55369677028429990c49bc54 (diff) | |
refactor(strings): replace compiler builtins with the STRING library
Construct literals as STRING values and route string operations through
ordinary library functions and operators. Preserve value ownership in
records, arrays, constants and file I/O.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'lib/CodeGen/ArrayParameters.cc')
| -rw-r--r-- | lib/CodeGen/ArrayParameters.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/CodeGen/ArrayParameters.cc b/lib/CodeGen/ArrayParameters.cc index 3359c66..a5f0beb 100644 --- a/lib/CodeGen/ArrayParameters.cc +++ b/lib/CodeGen/ArrayParameters.cc @@ -51,6 +51,28 @@ void ArrayHandler::bindArrayParameter(const std::string &Name, false); FunctionCallee MemcpyFunc = TheModule->getOrInsertFunction("memcpy", MemcpyType); Builder->CreateCall(MemcpyFunc, {Copy, DataPtr, TotalBytes}); + if (CG.containsString(ElemInfo)) { + auto *F = Builder->GetInsertBlock()->getParent(); + auto *Index = CG.CreateEntryBlockAlloca(F, Type::getInt64Ty(*TheContext), "copy_index"); + auto *Check = BasicBlock::Create(*TheContext, "copy_check", F); + auto *Body = BasicBlock::Create(*TheContext, "copy_element", F); + auto *Done = BasicBlock::Create(*TheContext, "copy_done", F); + Builder->CreateStore(Builder->getInt64(0), Index); + Builder->CreateBr(Check); + Builder->SetInsertPoint(Check); + Value *I = Builder->CreateLoad(Builder->getInt64Ty(), Index); + Builder->CreateCondBr(Builder->CreateICmpULT(I, TotalElements), Body, Done); + Builder->SetInsertPoint(Body); + std::vector<size_t> Transfers; + Value *Source = Builder->CreateGEP(ElemInfo->LLVMType, DataPtr, I); + Value *Value = CG.copyClassValue(ElemInfo, Source, Transfers); + if (!Value) return; + Builder->CreateStore(Value, Builder->CreateGEP(ElemInfo->LLVMType, Copy, I)); + CG.transferObjects(Transfers); + Builder->CreateStore(Builder->CreateAdd(I, Builder->getInt64(1)), Index); + Builder->CreateBr(Check); + Builder->SetInsertPoint(Done); + } Ptr = Copy; } |
