Skip to content

Commit

Permalink
Merge branch 'intrinsics' of https://github.com/braddr/dmd into bradd…
Browse files Browse the repository at this point in the history
…r-intrinsics
  • Loading branch information
WalterBright committed Apr 3, 2011
2 parents aba26e9 + 9f8fea5 commit b35f0a6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/builtin.c
Expand Up @@ -44,15 +44,15 @@ enum BUILTIN FuncDeclaration::isBuiltin()
static const char FeZe [] = "FNaNbNfeZe"; // @safe pure nothrow real function(real)
static const char FeZe2[] = "FNaNbNeeZe"; // @trusted pure nothrow real function(real)

//printf("FuncDeclaration::isBuiltin() %s\n", toChars());
//printf("FuncDeclaration::isBuiltin() %s, %d\n", toChars(), builtin);
if (builtin == BUILTINunknown)
{
builtin = BUILTINnot;
if (parent && parent->isModule())
{
// If it's in the std.math package
if (parent->ident == Id::math &&
parent->parent && parent->parent->ident == Id::std &&
parent->parent && (parent->parent->ident == Id::std || parent->parent->ident == Id::core) &&
!parent->parent->parent)
{
//printf("deco = %s\n", type->deco);
Expand Down
1 change: 1 addition & 0 deletions src/idgen.c
Expand Up @@ -284,6 +284,7 @@ Msgtable msgtable[] =

// Builtin functions
{ "std" },
{ "core" },
{ "math" },
{ "sin" },
{ "cos" },
Expand Down
38 changes: 37 additions & 1 deletion src/toir.c
Expand Up @@ -488,6 +488,18 @@ int intrinsic_op(char *name)
#ifdef DMDV2
static const char *core_namearray[] =
{
"4math3cosFNaNbNfeZe",
"4math3sinFNaNbNfeZe",
"4math4fabsFNaNbNfeZe",
"4math4rintFNaNbNfeZe",
"4math4sqrtFNaNbNfdZd",
"4math4sqrtFNaNbNfeZe",
"4math4sqrtFNaNbNffZf",
"4math4yl2xFNaNbNfeeZe",
"4math5ldexpFNaNbNfeiZe",
"4math6rndtolFNaNbNfeZl",
"4math6yl2xp1FNaNbNfeeZe",

"5bitop2btFNaNbxPkkZi",
"5bitop3bsfFNaNbkZi",
"5bitop3bsrFNaNbkZi",
Expand All @@ -504,6 +516,18 @@ int intrinsic_op(char *name)
};
static const char *core_namearray64[] =
{
"4math3cosFNaNbNfeZe",
"4math3sinFNaNbNfeZe",
"4math4fabsFNaNbNfeZe",
"4math4rintFNaNbNfeZe",
"4math4sqrtFNaNbNfdZd",
"4math4sqrtFNaNbNfeZe",
"4math4sqrtFNaNbNffZf",
"4math4yl2xFNaNbNfeeZe",
"4math5ldexpFNaNbNfeiZe",
"4math6rndtolFNaNbNfeZl",
"4math6yl2xp1FNaNbNfeeZe",

"5bitop2btFNaNbxPmmZi",
"5bitop3bsfFNaNbmZi",
"5bitop3bsrFNaNbmZi",
Expand All @@ -520,6 +544,18 @@ int intrinsic_op(char *name)
};
static unsigned char core_ioptab[] =
{
OPcos,
OPsin,
OPabs,
OPrint,
OPsqrt,
OPsqrt,
OPsqrt,
OPyl2x,
OPscale,
OPrndtol,
OPyl2xp1,

OPbt,
OPbsf,
OPbsr,
Expand Down Expand Up @@ -589,7 +625,7 @@ int intrinsic_op(char *name)
}
#ifdef DMDV2
if (length > 12 &&
name[8] == 'b' &&
(name[8] == 'm' || name[8] == 'b') &&
!memcmp(name, "_D4core", 7))
{
int i = binary(name + 7, I64 ? core_namearray64 : core_namearray, sizeof(core_namearray) / sizeof(char *));
Expand Down

0 comments on commit b35f0a6

Please sign in to comment.