mirror of
https://github.com/ldc-developers/ldc.git
synced 2025-05-02 16:11:08 +03:00
Use optimized array operators implemented in druntime
This commit is contained in:
parent
e0dc95052b
commit
f2ed2e96b0
5 changed files with 31 additions and 13 deletions
|
@ -32,6 +32,24 @@ extern int binary(const char *p , const char **tab, int high);
|
|||
*/
|
||||
|
||||
AA *arrayfuncs;
|
||||
#else
|
||||
int binary(const char *p , const char **tab, int high)
|
||||
{
|
||||
int i = 0, j = high, k, l;
|
||||
do
|
||||
{
|
||||
k = (i + j) / 2;
|
||||
l = strcmp(p, tab[k]);
|
||||
if (!l)
|
||||
return k;
|
||||
else if (l < 0)
|
||||
j = k;
|
||||
else
|
||||
i = k + 1;
|
||||
}
|
||||
while (i != j);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**********************************************
|
||||
|
@ -139,7 +157,6 @@ Expression *BinExp::arrayOp(Scope *sc)
|
|||
FuncDeclaration *fd = (FuncDeclaration *)*pfd;
|
||||
if (!fd)
|
||||
{
|
||||
#if IN_DMD
|
||||
/* Some of the array op functions are written as library functions,
|
||||
* presumably to optimize them with special CPU vector instructions.
|
||||
* List those library functions here, in alpha order.
|
||||
|
@ -316,7 +333,6 @@ Expression *BinExp::arrayOp(Scope *sc)
|
|||
if (strcmp(name, libArrayopFuncs[i]) == 0)
|
||||
assert(0);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
/* Not in library, so generate it.
|
||||
* Construct the function body:
|
||||
|
@ -369,8 +385,17 @@ Expression *BinExp::arrayOp(Scope *sc)
|
|||
fd->semantic2(sc);
|
||||
fd->semantic3(sc);
|
||||
sc->pop();
|
||||
#if IN_DMD
|
||||
}
|
||||
#if IN_LLVM
|
||||
else
|
||||
{ /* In library, refer to it.
|
||||
*/
|
||||
Parameters *fparams = new Parameters();
|
||||
buildArrayLoop(fparams);
|
||||
fd = FuncDeclaration::genCfunc(fparams, type, ident);
|
||||
fd->isArrayOp = 2;
|
||||
}
|
||||
#else
|
||||
else
|
||||
{ /* In library, refer to it.
|
||||
*/
|
||||
|
|
|
@ -1562,7 +1562,7 @@ bool mustDefineSymbol(Dsymbol* s)
|
|||
if (fd->semanticRun < 4)
|
||||
return false;
|
||||
|
||||
if (fd->isArrayOp)
|
||||
if (fd->isArrayOp == 1)
|
||||
return true;
|
||||
|
||||
if (global.params.useAvailableExternally && fd->availableExternally) {
|
||||
|
|
|
@ -33,7 +33,7 @@ static Module* getDefinedModule(Dsymbol* s)
|
|||
// array operations as well
|
||||
else if (FuncDeclaration* fd = s->isFuncDeclaration())
|
||||
{
|
||||
if (fd->isArrayOp)
|
||||
if (fd->isArrayOp == 1)
|
||||
return gIR->dmodule;
|
||||
}
|
||||
// otherwise use the symbol's module
|
||||
|
|
|
@ -267,7 +267,7 @@ LLGlobalValue::LinkageTypes DtoLinkage(Dsymbol* sym)
|
|||
if (fdecl->availableExternally && mustDefineSymbol(sym))
|
||||
return llvm::GlobalValue::AvailableExternallyLinkage;
|
||||
// array operations are always template linkage
|
||||
if (fdecl->isArrayOp)
|
||||
if (fdecl->isArrayOp == 1)
|
||||
return templateLinkage;
|
||||
// template instances should have weak linkage
|
||||
// but only if there's a body, and it's not naked
|
||||
|
|
|
@ -56,13 +56,6 @@ file(GLOB_RECURSE DCRT_D ${RUNTIME_DC_DIR}/*.d)
|
|||
file(GLOB_RECURSE LDC_D ${RUNTIME_DIR}/src/ldc/*.d)
|
||||
list(REMOVE_ITEM DCRT_D
|
||||
${RUNTIME_DC_DIR}/alloca.d
|
||||
${RUNTIME_DC_DIR}/arraybyte.d
|
||||
${RUNTIME_DC_DIR}/arraycast.d
|
||||
${RUNTIME_DC_DIR}/arraycat.d
|
||||
${RUNTIME_DC_DIR}/arraydouble.d
|
||||
${RUNTIME_DC_DIR}/arrayfloat.d
|
||||
${RUNTIME_DC_DIR}/arrayreal.d
|
||||
${RUNTIME_DC_DIR}/arrayshort.d
|
||||
${RUNTIME_DC_DIR}/critical_.d
|
||||
${RUNTIME_DC_DIR}/deh.d
|
||||
${RUNTIME_DC_DIR}/deh2.d
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue