arrays.cpp: Move copySlice to avoid forward decl

This commit is contained in:
David Nadlinger 2015-07-26 19:28:01 +02:00
parent 68c0df413e
commit 7c40e12a40

View file

@ -25,7 +25,6 @@
#include "ir/irmodule.h" #include "ir/irmodule.h"
static void DtoSetArray(DValue* array, LLValue* dim, LLValue* ptr); static void DtoSetArray(DValue* array, LLValue* dim, LLValue* ptr);
static void copySlice(Loc& loc, LLValue* dstarr, LLValue* sz1, LLValue* srcarr, LLValue* sz2);
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
@ -202,6 +201,24 @@ static Type *DtoArrayElementType(Type *arrayType)
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
static void copySlice(Loc& loc, LLValue* dstarr, LLValue* sz1, LLValue* srcarr, LLValue* sz2)
{
if (global.params.useAssert || gIR->emitArrayBoundsChecks())
{
LLValue* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_array_slice_copy");
gIR->CreateCallOrInvoke4(fn, dstarr, sz1, srcarr, sz2);
}
else
{
// We might have dstarr == srcarr at compile time, but as long as
// sz1 == 0 at runtime, this would probably still be legal (the C spec
// is unclear here).
DtoMemCpy(dstarr, srcarr, sz1);
}
}
//////////////////////////////////////////////////////////////////////////////////////////
// Determine whether t is an array of structs that need a postblit. // Determine whether t is an array of structs that need a postblit.
static bool arrayNeedsPostblit(Type *t) static bool arrayNeedsPostblit(Type *t)
{ {
@ -563,24 +580,6 @@ void initializeArrayLiteral(IRState* p, ArrayLiteralExp* ale, LLValue* dstMem)
} }
} }
//////////////////////////////////////////////////////////////////////////////////////////
static void copySlice(Loc& loc, LLValue* dstarr, LLValue* sz1, LLValue* srcarr, LLValue* sz2)
{
if (global.params.useAssert || gIR->emitArrayBoundsChecks())
{
LLValue* fn = LLVM_D_GetRuntimeFunction(loc, gIR->module, "_d_array_slice_copy");
gIR->CreateCallOrInvoke4(fn, dstarr, sz1, srcarr, sz2);
}
else
{
// We might have dstarr == srcarr at compile time, but as long as
// sz1 == 0 at runtime, this would probably still be legal (the C spec
// is unclear here).
DtoMemCpy(dstarr, srcarr, sz1);
}
}
////////////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////
LLConstant* DtoConstSlice(LLConstant* dim, LLConstant* ptr, Type *type) LLConstant* DtoConstSlice(LLConstant* dim, LLConstant* ptr, Type *type)
{ {