Use optimized array operators implemented in druntime

This commit is contained in:
Alexey Prokhin
2012-02-11 15:15:28 +04:00
parent e0dc95052b
commit f2ed2e96b0
5 changed files with 31 additions and 13 deletions

View File

@@ -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.
*/