aboutsummaryrefslogtreecommitdiff
path: root/gcc/d/dmd
diff options
context:
space:
mode:
authorIain Buclaw <ibuclaw@gdcproject.org>2020-06-05 17:50:49 +0200
committerIain Buclaw <ibuclaw@gdcproject.org>2020-06-05 17:52:57 +0200
commit5905cbdbcf6d760303ca87f27e04824f26976de4 (patch)
tree16ea452b43613d027a78c18b033f7659f0cdbbbf /gcc/d/dmd
parent300452d7bf1d3a0ff3f7585a1166f3d473c70556 (diff)
downloadgcc-5905cbdbcf6d760303ca87f27e04824f26976de4.zip
gcc-5905cbdbcf6d760303ca87f27e04824f26976de4.tar.gz
gcc-5905cbdbcf6d760303ca87f27e04824f26976de4.tar.bz2
d: Merge upstream dmd 56f0a65c4.
Updates the Target interface, removing static from all members, so all field accesses and member function calls go through a single global 'target'. Information relating to extern ABI are now in TargetC, TargetCPP, and TargetObjC for each supported language respectively. Reviewed-on: https://github.com/dlang/dmd/pull/11228 gcc/d/ChangeLog: * dmd/MERGE: Merge upstream dmd 56f0a65c4. * d-builtins.cc (build_frontend_type): Remove static. (d_build_builtins_module): Use target.va_listType() to get front-end type for va_list. (d_init_builtins): Move creation of va_list to Target::va_listType. * d-codegen.cc (build_interface_binfo): Use new target global. (build_vindex_ref): Likewise. (identity_compare_p): Likewise. * d-ctfloat.cc (CTFloat::parse): Likewise. * d-lang.cc (d_init): Likewise. * d-port.cc (Port::isFloat32LiteralOutOfRange): Likewise. (Port::isFloat64LiteralOutOfRange): Likewise. * d-target.cc (define_float_constants): Initialize constants through a reference, instead of setting globals. (Target::_init): Initialize new fields instead of setting globals. (Target::va_listType): Build front-end type from va_list_type_node. (Target::toCppMangle): Renamed to ... (TargetCPP::toMangle): ... this. (Target::cppTypeInfoMangle): Renamed to ... (TargetCPP::typeInfoMangle): ... this. (Target::cppTypeMangle): Renamed to ... (TargetCPP::typeMangle): this. (Target::cppParameterType): Renamed to ... (TargetCPP::parameterType): ... this. Use target.va_listType() to get front-end type for va_list. (Target::cppFundamentalType): Renamed to ... (TargetCPP::fundamentalType): ... this. * d-tree.h (build_frontend_type): Declare. * decl.cc (base_vtable_offset): Use new target global. * typeinfo.cc (layout_classinfo_interfaces): Likewise. (layout_cpp_typeinfo): Likewise. * types.cc (valist_array_p): Use target.va_listType() to get front-end type for va_list. (layout_aggregate_type): Use new target global.
Diffstat (limited to 'gcc/d/dmd')
-rw-r--r--gcc/d/dmd/MERGE2
-rw-r--r--gcc/d/dmd/attrib.c2
-rw-r--r--gcc/d/dmd/constfold.c2
-rw-r--r--gcc/d/dmd/cppmangle.c14
-rw-r--r--gcc/d/dmd/dclass.c12
-rw-r--r--gcc/d/dmd/declaration.c4
-rw-r--r--gcc/d/dmd/dmangle.c2
-rw-r--r--gcc/d/dmd/dstruct.c4
-rw-r--r--gcc/d/dmd/expression.c6
-rw-r--r--gcc/d/dmd/expressionsem.c42
-rw-r--r--gcc/d/dmd/func.c4
-rw-r--r--gcc/d/dmd/hdrgen.c8
-rw-r--r--gcc/d/dmd/mtype.c112
-rw-r--r--gcc/d/dmd/mtype.h4
-rw-r--r--gcc/d/dmd/safe.c4
-rw-r--r--gcc/d/dmd/statementsem.c10
-rw-r--r--gcc/d/dmd/target.h112
17 files changed, 179 insertions, 165 deletions
diff --git a/gcc/d/dmd/MERGE b/gcc/d/dmd/MERGE
index 0a4fb76..f413bd1 100644
--- a/gcc/d/dmd/MERGE
+++ b/gcc/d/dmd/MERGE
@@ -1,4 +1,4 @@
-6d5bffa54f7da21d388d9999e586fd8a11ebcdb1
+56f0a65c493463633a293d71faf37cdf710041ef
The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository.
diff --git a/gcc/d/dmd/attrib.c b/gcc/d/dmd/attrib.c
index 02761ab..184af1f 100644
--- a/gcc/d/dmd/attrib.c
+++ b/gcc/d/dmd/attrib.c
@@ -516,7 +516,7 @@ LinkDeclaration::LinkDeclaration(LINK p, Dsymbols *decl)
: AttribDeclaration(decl)
{
//printf("LinkDeclaration(linkage = %d, decl = %p)\n", p, decl);
- linkage = (p == LINKsystem) ? Target::systemLinkage() : p;
+ linkage = (p == LINKsystem) ? target.systemLinkage() : p;
}
LinkDeclaration *LinkDeclaration::create(LINK p, Dsymbols *decl)
diff --git a/gcc/d/dmd/constfold.c b/gcc/d/dmd/constfold.c
index a0364ef..38e6191 100644
--- a/gcc/d/dmd/constfold.c
+++ b/gcc/d/dmd/constfold.c
@@ -623,7 +623,7 @@ UnionExp Pow(Loc loc, Type *type, Expression *e1, Expression *e2)
// x ^^ y for x < 0 and y not an integer is not defined; so set result as NaN
if (e1->toReal() < CTFloat::zero)
{
- new(&ue) RealExp(loc, Target::RealProperties::nan, type);
+ new(&ue) RealExp(loc, target.RealProperties.nan, type);
}
else
new(&ue) CTFEExp(TOKcantexp);
diff --git a/gcc/d/dmd/cppmangle.c b/gcc/d/dmd/cppmangle.c
index a508022..f39c248 100644
--- a/gcc/d/dmd/cppmangle.c
+++ b/gcc/d/dmd/cppmangle.c
@@ -131,7 +131,7 @@ class CppMangleVisitor : public Visitor
{
// First check the target whether some specific ABI is being followed.
bool isFundamental;
- if (Target::cppFundamentalType(t, isFundamental))
+ if (target.cpp.fundamentalType(t, isFundamental))
return isFundamental;
if (t->ty == Tenum)
{
@@ -672,7 +672,7 @@ class CppMangleVisitor : public Visitor
{
ParamsCppMangle *p = (ParamsCppMangle *)ctx;
CppMangleVisitor *mangler = p->mangler;
- Type *t = Target::cppParameterType(fparam);
+ Type *t = target.cpp.parameterType(fparam);
if (t->ty == Tsarray)
{
// Static arrays in D are passed by value; no counterpart in C++
@@ -803,7 +803,7 @@ public:
return error(t);
// Handle any target-specific basic types.
- if (const char *tm = Target::cppTypeMangle(t))
+ if (const char *tm = target.cpp.typeMangle(t))
{
// Only do substitutions for non-fundamental types.
if (!isFundamentalType(t) || t->isConst())
@@ -862,10 +862,10 @@ public:
case Tuns32: c = 'j'; break;
case Tfloat32: c = 'f'; break;
case Tint64:
- c = (Target::c_longsize == 8 ? 'l' : 'x');
+ c = (target.c.longsize == 8 ? 'l' : 'x');
break;
case Tuns64:
- c = (Target::c_longsize == 8 ? 'm' : 'y');
+ c = (target.c.longsize == 8 ? 'm' : 'y');
break;
case Tint128: c = 'n'; break;
case Tuns128: c = 'o'; break;
@@ -899,7 +899,7 @@ public:
CV_qualifiers(t);
// Handle any target-specific vector types.
- if (const char *tm = Target::cppTypeMangle(t))
+ if (const char *tm = target.cpp.typeMangle(t))
{
buf->writestring(tm);
}
@@ -1030,7 +1030,7 @@ public:
CV_qualifiers(t);
// Handle any target-specific struct types.
- if (const char *tm = Target::cppTypeMangle(t))
+ if (const char *tm = target.cpp.typeMangle(t))
{
buf->writestring(tm);
}
diff --git a/gcc/d/dmd/dclass.c b/gcc/d/dmd/dclass.c
index 754a996..535679e 100644
--- a/gcc/d/dmd/dclass.c
+++ b/gcc/d/dmd/dclass.c
@@ -1048,7 +1048,7 @@ static unsigned membersPlace(BaseClasses *vtblInterfaces, size_t &bi, ClassDecla
assert(b->sym->sizeok == SIZEOKdone);
if (!b->sym->alignsize)
- b->sym->alignsize = Target::ptrsize;
+ b->sym->alignsize = target.ptrsize;
cd->alignmember(b->sym->alignsize, b->sym->alignsize, &offset);
assert(bi < vtblInterfaces->length);
BaseClass *bv = (*vtblInterfaces)[bi];
@@ -1092,16 +1092,16 @@ void ClassDeclaration::finalizeSize()
{
if (interfaces.length == 0)
{
- alignsize = Target::ptrsize;
- structsize = Target::ptrsize; // allow room for __vptr
+ alignsize = target.ptrsize;
+ structsize = target.ptrsize; // allow room for __vptr
}
}
else
{
- alignsize = Target::ptrsize;
- structsize = Target::ptrsize; // allow room for __vptr
+ alignsize = target.ptrsize;
+ structsize = target.ptrsize; // allow room for __vptr
if (!isCPPclass())
- structsize += Target::ptrsize; // allow room for __monitor
+ structsize += target.ptrsize; // allow room for __monitor
}
//printf("finalizeSize() %s, sizeok = %d\n", toChars(), sizeok);
diff --git a/gcc/d/dmd/declaration.c b/gcc/d/dmd/declaration.c
index 5ae8c06..04f7a34 100644
--- a/gcc/d/dmd/declaration.c
+++ b/gcc/d/dmd/declaration.c
@@ -1778,7 +1778,7 @@ void VarDeclaration::setFieldOffset(AggregateDeclaration *ad, unsigned *poffset,
const d_uns64 sz = t->size(loc);
assert(sz != SIZE_INVALID && sz < UINT32_MAX);
unsigned memsize = (unsigned)sz; // size of member
- unsigned memalignsize = Target::fieldalign(t); // size of member for alignment purposes
+ unsigned memalignsize = target.fieldalign(t); // size of member for alignment purposes
offset = AggregateDeclaration::placeField(poffset, memsize, memalignsize, alignment,
&ad->structsize, &ad->alignsize, isunion);
@@ -2220,7 +2220,7 @@ TypeInfoDeclaration::TypeInfoDeclaration(Type *tinfo)
storage_class = STCstatic | STCgshared;
protection = Prot(PROTpublic);
linkage = LINKc;
- alignment = Target::ptrsize;
+ alignment = target.ptrsize;
}
TypeInfoDeclaration *TypeInfoDeclaration::create(Type *tinfo)
diff --git a/gcc/d/dmd/dmangle.c b/gcc/d/dmd/dmangle.c
index 18bdf27..c1a186d 100644
--- a/gcc/d/dmd/dmangle.c
+++ b/gcc/d/dmd/dmangle.c
@@ -421,7 +421,7 @@ public:
return;
case LINKcpp:
- buf->writestring(Target::toCppMangle(d));
+ buf->writestring(target.cpp.toMangle(d));
return;
case LINKdefault:
diff --git a/gcc/d/dmd/dstruct.c b/gcc/d/dmd/dstruct.c
index 5af2745..891d469 100644
--- a/gcc/d/dmd/dstruct.c
+++ b/gcc/d/dmd/dstruct.c
@@ -799,7 +799,7 @@ void AggregateDeclaration::alignmember(
break;
case (structalign_t) STRUCTALIGN_DEFAULT:
- // Alignment in Target::fieldalignsize must match what the
+ // Alignment in target.fieldalignsize must match what the
// corresponding C compiler's default alignment behavior is.
assert(size > 0 && !(size & (size - 1)));
*poffset = (*poffset + size - 1) & ~(size - 1);
@@ -1307,7 +1307,7 @@ void StructDeclaration::finalizeSize()
}
}
- TypeTuple *tt = Target::toArgTypes(type);
+ TypeTuple *tt = target.toArgTypes(type);
size_t dim = tt ? tt->arguments->length : 0;
if (dim >= 1)
{
diff --git a/gcc/d/dmd/expression.c b/gcc/d/dmd/expression.c
index 0b04273..29103c1 100644
--- a/gcc/d/dmd/expression.c
+++ b/gcc/d/dmd/expression.c
@@ -2925,11 +2925,11 @@ void IntegerExp::normalize()
case Tint64: value = (d_int64) value; break;
case Tuns64: value = (d_uns64) value; break;
case Tpointer:
- if (Target::ptrsize == 8)
+ if (target.ptrsize == 8)
value = (d_uns64) value;
- else if (Target::ptrsize == 4)
+ else if (target.ptrsize == 4)
value = (d_uns32) value;
- else if (Target::ptrsize == 2)
+ else if (target.ptrsize == 2)
value = (d_uns16) value;
else
assert(0);
diff --git a/gcc/d/dmd/expressionsem.c b/gcc/d/dmd/expressionsem.c
index cec57d4a..ffcfeb4 100644
--- a/gcc/d/dmd/expressionsem.c
+++ b/gcc/d/dmd/expressionsem.c
@@ -2073,7 +2073,7 @@ public:
* The results of this are highly platform dependent, and intended
* primarly for use in implementing va_arg().
*/
- tded = Target::toArgTypes(e->targ);
+ tded = target.toArgTypes(e->targ);
if (!tded)
goto Lno; // not valid for a parameter
break;
@@ -2295,7 +2295,7 @@ public:
exp->e2 = exp->e2->castTo(sc, Type::tshiftcnt);
}
- if (!Target::isVectorOpSupported(exp->type->toBasetype(), exp->op, exp->e2->type->toBasetype()))
+ if (!target.isVectorOpSupported(exp->type->toBasetype(), exp->op, exp->e2->type->toBasetype()))
{
result = exp->incompatibleTypes();
return;
@@ -3917,7 +3917,7 @@ public:
return;
}
- if (!Target::isVectorOpSupported(tb, exp->op))
+ if (!target.isVectorOpSupported(tb, exp->op))
{
result = exp->incompatibleTypes();
return;
@@ -3941,7 +3941,7 @@ public:
return;
}
- if (!Target::isVectorOpSupported(exp->e1->type->toBasetype(), exp->op))
+ if (!target.isVectorOpSupported(exp->e1->type->toBasetype(), exp->op))
{
result = exp->incompatibleTypes();
return;
@@ -3982,7 +3982,7 @@ public:
return;
}
- if (!Target::isVectorOpSupported(tb, exp->op))
+ if (!target.isVectorOpSupported(tb, exp->op))
{
result = exp->incompatibleTypes();
return;
@@ -4024,7 +4024,7 @@ public:
return;
}
- if (!Target::isVectorOpSupported(e->e1->type->toBasetype(), e->op))
+ if (!target.isVectorOpSupported(e->e1->type->toBasetype(), e->op))
{
result = e->incompatibleTypes();
return;
@@ -6410,7 +6410,7 @@ public:
}
tb1 = exp->e1->type->toBasetype();
- if (!Target::isVectorOpSupported(tb1, exp->op, tb2))
+ if (!target.isVectorOpSupported(tb1, exp->op, tb2))
{
result = exp->incompatibleTypes();
return;
@@ -6543,7 +6543,7 @@ public:
t1 = exp->e1->type->toBasetype();
t2 = exp->e2->type->toBasetype();
- if (!Target::isVectorOpSupported(t1, exp->op, t2))
+ if (!target.isVectorOpSupported(t1, exp->op, t2))
{
result = exp->incompatibleTypes();
return;
@@ -6864,7 +6864,7 @@ public:
exp->type = t1; // t1 is complex
}
}
- else if (!Target::isVectorOpSupported(tb, exp->op, exp->e2->type->toBasetype()))
+ else if (!target.isVectorOpSupported(tb, exp->op, exp->e2->type->toBasetype()))
{
result = exp->incompatibleTypes();
return;
@@ -6964,7 +6964,7 @@ public:
exp->type = t1; // t1 is complex
}
}
- else if (!Target::isVectorOpSupported(tb, exp->op, exp->e2->type->toBasetype()))
+ else if (!target.isVectorOpSupported(tb, exp->op, exp->e2->type->toBasetype()))
{
result = exp->incompatibleTypes();
return;
@@ -7009,7 +7009,7 @@ public:
result = exp;
return;
}
- if (!Target::isVectorOpSupported(tb, exp->op, exp->e2->type->toBasetype()))
+ if (!target.isVectorOpSupported(tb, exp->op, exp->e2->type->toBasetype()))
{
result = exp->incompatibleTypes();
return;
@@ -7091,7 +7091,7 @@ public:
if (exp->checkArithmeticBin())
return setError();
- if (!Target::isVectorOpSupported(exp->e1->type->toBasetype(), exp->op, exp->e2->type->toBasetype()))
+ if (!target.isVectorOpSupported(exp->e1->type->toBasetype(), exp->op, exp->e2->type->toBasetype()))
{
result = exp->incompatibleTypes();
return;
@@ -7191,7 +7191,7 @@ public:
if (exp->checkIntegralBin())
return setError();
- if (!Target::isVectorOpSupported(exp->e1->type->toBasetype(), exp->op, exp->e2->type->toBasetype()))
+ if (!target.isVectorOpSupported(exp->e1->type->toBasetype(), exp->op, exp->e2->type->toBasetype()))
{
result = exp->incompatibleTypes();
return;
@@ -7226,7 +7226,7 @@ public:
if (exp->checkIntegralBin())
return setError();
- if (!Target::isVectorOpSupported(exp->e1->type->toBasetype(), exp->op, exp->e2->type->toBasetype()))
+ if (!target.isVectorOpSupported(exp->e1->type->toBasetype(), exp->op, exp->e2->type->toBasetype()))
{
result = exp->incompatibleTypes();
return;
@@ -7261,7 +7261,7 @@ public:
if (exp->checkIntegralBin())
return setError();
- if (!Target::isVectorOpSupported(exp->e1->type->toBasetype(), exp->op, exp->e2->type->toBasetype()))
+ if (!target.isVectorOpSupported(exp->e1->type->toBasetype(), exp->op, exp->e2->type->toBasetype()))
{
result = exp->incompatibleTypes();
return;
@@ -7320,7 +7320,7 @@ public:
return;
}
- if (!Target::isVectorOpSupported(tb, exp->op, exp->e2->type->toBasetype()))
+ if (!target.isVectorOpSupported(tb, exp->op, exp->e2->type->toBasetype()))
{
result = exp->incompatibleTypes();
return;
@@ -7377,7 +7377,7 @@ public:
return;
}
- if (!Target::isVectorOpSupported(tb, exp->op, exp->e2->type->toBasetype()))
+ if (!target.isVectorOpSupported(tb, exp->op, exp->e2->type->toBasetype()))
{
result = exp->incompatibleTypes();
return;
@@ -7434,7 +7434,7 @@ public:
return;
}
- if (!Target::isVectorOpSupported(tb, exp->op, exp->e2->type->toBasetype()))
+ if (!target.isVectorOpSupported(tb, exp->op, exp->e2->type->toBasetype()))
{
result = exp->incompatibleTypes();
return;
@@ -7756,7 +7756,7 @@ public:
exp->error("%s is not defined for associative arrays", Token::toChars(exp->op));
return setError();
}
- else if (!Target::isVectorOpSupported(t1, exp->op, t2))
+ else if (!target.isVectorOpSupported(t1, exp->op, t2))
{
result = exp->incompatibleTypes();
return;
@@ -7905,7 +7905,7 @@ public:
Type *t1 = exp->e1->type->toBasetype();
Type *t2 = exp->e2->type->toBasetype();
- if (!Target::isVectorOpSupported(t1, exp->op, t2))
+ if (!target.isVectorOpSupported(t1, exp->op, t2))
{
result = exp->incompatibleTypes();
return;
@@ -7958,7 +7958,7 @@ public:
Type *tb1 = exp->e1->type->toBasetype();
Type *tb2 = exp->e2->type->toBasetype();
- if (!Target::isVectorOpSupported(tb1, exp->op, tb2))
+ if (!target.isVectorOpSupported(tb1, exp->op, tb2))
{
result = exp->incompatibleTypes();
return;
diff --git a/gcc/d/dmd/func.c b/gcc/d/dmd/func.c
index 961e84a..807565d 100644
--- a/gcc/d/dmd/func.c
+++ b/gcc/d/dmd/func.c
@@ -902,7 +902,7 @@ void FuncDeclaration::semantic(Scope *sc)
{
//printf("\tintroducing function %s\n", toChars());
introducing = 1;
- if (cd->isCPPclass() && Target::reverseCppOverloads)
+ if (cd->isCPPclass() && target.cpp.reverseOverloads)
{
// with dmc, overloaded functions are grouped and in reverse order
vtblIndex = (int)cd->vtbl.length;
@@ -1553,7 +1553,7 @@ void FuncDeclaration::semantic3(Scope *sc)
if (f->linkage == LINKd || (f->parameters && Parameter::dim(f->parameters)))
{
// Declare _argptr
- Type *t = Type::tvalist;
+ Type *t = target.va_listType(loc, sc);
v_argptr = new VarDeclaration(Loc(), t, Id::_argptr, NULL);
v_argptr->storage_class |= STCtemp;
v_argptr->semantic(sc2);
diff --git a/gcc/d/dmd/hdrgen.c b/gcc/d/dmd/hdrgen.c
index 156f4a6..d61a244 100644
--- a/gcc/d/dmd/hdrgen.c
+++ b/gcc/d/dmd/hdrgen.c
@@ -2212,11 +2212,11 @@ public:
if ((sinteger_t)uval >= 0)
{
dinteger_t sizemax;
- if (Target::ptrsize == 8)
+ if (target.ptrsize == 8)
sizemax = 0xFFFFFFFFFFFFFFFFULL;
- else if (Target::ptrsize == 4)
+ else if (target.ptrsize == 4)
sizemax = 0xFFFFFFFFUL;
- else if (Target::ptrsize == 2)
+ else if (target.ptrsize == 2)
sizemax = 0xFFFFUL;
else
assert(0);
@@ -2358,7 +2358,7 @@ public:
buf->writestring("cast(");
buf->writestring(t->toChars());
buf->writeByte(')');
- if (Target::ptrsize == 8)
+ if (target.ptrsize == 8)
goto L4;
else
goto L3;
diff --git a/gcc/d/dmd/mtype.c b/gcc/d/dmd/mtype.c
index 8223d25..e2511a4 100644
--- a/gcc/d/dmd/mtype.c
+++ b/gcc/d/dmd/mtype.c
@@ -44,9 +44,6 @@ Expression *typeToExpression(Type *t);
Expression *typeToExpressionHelper(TypeQualified *t, Expression *e, size_t i = 0);
Initializer *semantic(Initializer *init, Scope *sc, Type *t, NeedInterpret needInterpret);
-int Tsize_t = Tuns32;
-int Tptrdiff_t = Tint32;
-
/***************************** Type *****************************/
ClassDeclaration *Type::dtypeinfo;
@@ -109,7 +106,6 @@ Type *Type::tvoidptr;
Type *Type::tstring;
Type *Type::twstring;
Type *Type::tdstring;
-Type *Type::tvalist;
Type *Type::basic[TMAX];
unsigned char Type::sizeTy[TMAX];
StringTable Type::stringtable;
@@ -262,21 +258,11 @@ void Type::_init()
tstring = tchar->immutableOf()->arrayOf();
twstring = twchar->immutableOf()->arrayOf();
tdstring = tdchar->immutableOf()->arrayOf();
- tvalist = Target::va_listType();
- if (global.params.isLP64)
- {
- Tsize_t = Tuns64;
- Tptrdiff_t = Tint64;
- }
- else
- {
- Tsize_t = Tuns32;
- Tptrdiff_t = Tint32;
- }
+ const bool isLP64 = global.params.isLP64;
- tsize_t = basic[Tsize_t];
- tptrdiff_t = basic[Tptrdiff_t];
+ tsize_t = basic[isLP64 ? Tuns64 : Tuns32];
+ tptrdiff_t = basic[isLP64 ? Tint64 : Tint32];
thash_t = tsize_t;
}
@@ -3041,7 +3027,7 @@ d_uns64 TypeBasic::size(Loc)
size = 8; break;
case Tfloat80:
case Timaginary80:
- size = Target::realsize; break;
+ size = target.realsize; break;
case Tcomplex32:
size = 8; break;
case Tcomplex64:
@@ -3049,7 +3035,7 @@ d_uns64 TypeBasic::size(Loc)
case Tuns128:
size = 16; break;
case Tcomplex80:
- size = Target::realsize * 2; break;
+ size = target.realsize * 2; break;
case Tvoid:
//size = Type::size(); // error message
@@ -3071,7 +3057,7 @@ d_uns64 TypeBasic::size(Loc)
unsigned TypeBasic::alignsize()
{
- return Target::alignsize(this);
+ return target.alignsize(this);
}
@@ -3125,17 +3111,17 @@ Expression *TypeBasic::getProperty(Loc loc, Identifier *ident, int flag)
case Tcomplex32:
case Timaginary32:
case Tfloat32:
- fvalue = Target::FloatProperties::max;
+ fvalue = target.FloatProperties.max;
goto Lfvalue;
case Tcomplex64:
case Timaginary64:
case Tfloat64:
- fvalue = Target::DoubleProperties::max;
+ fvalue = target.DoubleProperties.max;
goto Lfvalue;
case Tcomplex80:
case Timaginary80:
case Tfloat80:
- fvalue = Target::RealProperties::max;
+ fvalue = target.RealProperties.max;
goto Lfvalue;
}
}
@@ -3200,17 +3186,17 @@ Expression *TypeBasic::getProperty(Loc loc, Identifier *ident, int flag)
case Tcomplex32:
case Timaginary32:
case Tfloat32:
- fvalue = Target::FloatProperties::min_normal;
+ fvalue = target.FloatProperties.min_normal;
goto Lfvalue;
case Tcomplex64:
case Timaginary64:
case Tfloat64:
- fvalue = Target::DoubleProperties::min_normal;
+ fvalue = target.DoubleProperties.min_normal;
goto Lfvalue;
case Tcomplex80:
case Timaginary80:
case Tfloat80:
- fvalue = Target::RealProperties::min_normal;
+ fvalue = target.RealProperties.min_normal;
goto Lfvalue;
}
}
@@ -3227,7 +3213,7 @@ Expression *TypeBasic::getProperty(Loc loc, Identifier *ident, int flag)
case Tfloat32:
case Tfloat64:
case Tfloat80:
- fvalue = Target::RealProperties::nan;
+ fvalue = target.RealProperties.nan;
goto Lfvalue;
}
}
@@ -3244,7 +3230,7 @@ Expression *TypeBasic::getProperty(Loc loc, Identifier *ident, int flag)
case Tfloat32:
case Tfloat64:
case Tfloat80:
- fvalue = Target::RealProperties::infinity;
+ fvalue = target.RealProperties.infinity;
goto Lfvalue;
}
}
@@ -3255,17 +3241,17 @@ Expression *TypeBasic::getProperty(Loc loc, Identifier *ident, int flag)
case Tcomplex32:
case Timaginary32:
case Tfloat32:
- ivalue = Target::FloatProperties::dig;
+ ivalue = target.FloatProperties.dig;
goto Lint;
case Tcomplex64:
case Timaginary64:
case Tfloat64:
- ivalue = Target::DoubleProperties::dig;
+ ivalue = target.DoubleProperties.dig;
goto Lint;
case Tcomplex80:
case Timaginary80:
case Tfloat80:
- ivalue = Target::RealProperties::dig;
+ ivalue = target.RealProperties.dig;
goto Lint;
}
}
@@ -3276,17 +3262,17 @@ Expression *TypeBasic::getProperty(Loc loc, Identifier *ident, int flag)
case Tcomplex32:
case Timaginary32:
case Tfloat32:
- fvalue = Target::FloatProperties::epsilon;
+ fvalue = target.FloatProperties.epsilon;
goto Lfvalue;
case Tcomplex64:
case Timaginary64:
case Tfloat64:
- fvalue = Target::DoubleProperties::epsilon;
+ fvalue = target.DoubleProperties.epsilon;
goto Lfvalue;
case Tcomplex80:
case Timaginary80:
case Tfloat80:
- fvalue = Target::RealProperties::epsilon;
+ fvalue = target.RealProperties.epsilon;
goto Lfvalue;
}
}
@@ -3297,17 +3283,17 @@ Expression *TypeBasic::getProperty(Loc loc, Identifier *ident, int flag)
case Tcomplex32:
case Timaginary32:
case Tfloat32:
- ivalue = Target::FloatProperties::mant_dig;
+ ivalue = target.FloatProperties.mant_dig;
goto Lint;
case Tcomplex64:
case Timaginary64:
case Tfloat64:
- ivalue = Target::DoubleProperties::mant_dig;
+ ivalue = target.DoubleProperties.mant_dig;
goto Lint;
case Tcomplex80:
case Timaginary80:
case Tfloat80:
- ivalue = Target::RealProperties::mant_dig;
+ ivalue = target.RealProperties.mant_dig;
goto Lint;
}
}
@@ -3318,17 +3304,17 @@ Expression *TypeBasic::getProperty(Loc loc, Identifier *ident, int flag)
case Tcomplex32:
case Timaginary32:
case Tfloat32:
- ivalue = Target::FloatProperties::max_10_exp;
+ ivalue = target.FloatProperties.max_10_exp;
goto Lint;
case Tcomplex64:
case Timaginary64:
case Tfloat64:
- ivalue = Target::DoubleProperties::max_10_exp;
+ ivalue = target.DoubleProperties.max_10_exp;
goto Lint;
case Tcomplex80:
case Timaginary80:
case Tfloat80:
- ivalue = Target::RealProperties::max_10_exp;
+ ivalue = target.RealProperties.max_10_exp;
goto Lint;
}
}
@@ -3339,17 +3325,17 @@ Expression *TypeBasic::getProperty(Loc loc, Identifier *ident, int flag)
case Tcomplex32:
case Timaginary32:
case Tfloat32:
- ivalue = Target::FloatProperties::max_exp;
+ ivalue = target.FloatProperties.max_exp;
goto Lint;
case Tcomplex64:
case Timaginary64:
case Tfloat64:
- ivalue = Target::DoubleProperties::max_exp;
+ ivalue = target.DoubleProperties.max_exp;
goto Lint;
case Tcomplex80:
case Timaginary80:
case Tfloat80:
- ivalue = Target::RealProperties::max_exp;
+ ivalue = target.RealProperties.max_exp;
goto Lint;
}
}
@@ -3360,17 +3346,17 @@ Expression *TypeBasic::getProperty(Loc loc, Identifier *ident, int flag)
case Tcomplex32:
case Timaginary32:
case Tfloat32:
- ivalue = Target::FloatProperties::min_10_exp;
+ ivalue = target.FloatProperties.min_10_exp;
goto Lint;
case Tcomplex64:
case Timaginary64:
case Tfloat64:
- ivalue = Target::DoubleProperties::min_10_exp;
+ ivalue = target.DoubleProperties.min_10_exp;
goto Lint;
case Tcomplex80:
case Timaginary80:
case Tfloat80:
- ivalue = Target::RealProperties::min_10_exp;
+ ivalue = target.RealProperties.min_10_exp;
goto Lint;
}
}
@@ -3381,17 +3367,17 @@ Expression *TypeBasic::getProperty(Loc loc, Identifier *ident, int flag)
case Tcomplex32:
case Timaginary32:
case Tfloat32:
- ivalue = Target::FloatProperties::min_exp;
+ ivalue = target.FloatProperties.min_exp;
goto Lint;
case Tcomplex64:
case Timaginary64:
case Tfloat64:
- ivalue = Target::DoubleProperties::min_exp;
+ ivalue = target.DoubleProperties.min_exp;
goto Lint;
case Tcomplex80:
case Timaginary80:
case Tfloat80:
- ivalue = Target::RealProperties::min_exp;
+ ivalue = target.RealProperties.min_exp;
goto Lint;
}
}
@@ -3514,13 +3500,13 @@ Expression *TypeBasic::defaultInit(Loc loc)
case Tfloat32:
case Tfloat64:
case Tfloat80:
- return new RealExp(loc, Target::RealProperties::snan, this);
+ return new RealExp(loc, target.RealProperties.snan, this);
case Tcomplex32:
case Tcomplex64:
case Tcomplex80:
{ // Can't use fvalue + I*fvalue (the im part becomes a quiet NaN).
- complex_t cvalue = complex_t(Target::RealProperties::snan, Target::RealProperties::snan);
+ complex_t cvalue = complex_t(target.RealProperties.snan, target.RealProperties.snan);
return new ComplexExp(loc, cvalue, this);
}
@@ -3730,7 +3716,7 @@ Type *TypeVector::semantic(Loc loc, Scope *sc)
}
TypeSArray *t = (TypeSArray *)basetype;
int sz = (int)t->size(loc);
- switch (Target::isVectorTypeSupported(sz, t->nextOf()))
+ switch (target.isVectorTypeSupported(sz, t->nextOf()))
{
case 0: // valid
break;
@@ -4142,7 +4128,7 @@ Type *TypeSArray::semantic(Loc loc, Scope *sc)
{
Loverflow:
error(loc, "%s size %llu * %llu exceeds 0x%llx size limit for static array",
- toChars(), (unsigned long long)tbn->size(loc), (unsigned long long)d1, Target::maxStaticDataSize);
+ toChars(), (unsigned long long)tbn->size(loc), (unsigned long long)d1, target.maxStaticDataSize);
goto Lerror;
}
@@ -4166,7 +4152,7 @@ Type *TypeSArray::semantic(Loc loc, Scope *sc)
* run on them for the size, since they may be forward referenced.
*/
bool overflow = false;
- if (mulu(tbn->size(loc), d2, overflow) >= Target::maxStaticDataSize || overflow)
+ if (mulu(tbn->size(loc), d2, overflow) >= target.maxStaticDataSize || overflow)
goto Loverflow;
}
}
@@ -4405,14 +4391,14 @@ Type *TypeDArray::syntaxCopy()
d_uns64 TypeDArray::size(Loc)
{
//printf("TypeDArray::size()\n");
- return Target::ptrsize * 2;
+ return target.ptrsize * 2;
}
unsigned TypeDArray::alignsize()
{
// A DArray consists of two ptr-sized values, so align it on pointer size
// boundary
- return Target::ptrsize;
+ return target.ptrsize;
}
Type *TypeDArray::semantic(Loc loc, Scope *sc)
@@ -4604,7 +4590,7 @@ Type *TypeAArray::syntaxCopy()
d_uns64 TypeAArray::size(Loc)
{
- return Target::ptrsize;
+ return target.ptrsize;
}
Type *TypeAArray::semantic(Loc loc, Scope *sc)
@@ -4967,7 +4953,7 @@ Type *TypePointer::semantic(Loc loc, Scope *sc)
d_uns64 TypePointer::size(Loc)
{
- return Target::ptrsize;
+ return target.ptrsize;
}
MATCH TypePointer::implicitConvTo(Type *to)
@@ -5111,7 +5097,7 @@ Type *TypeReference::semantic(Loc loc, Scope *sc)
d_uns64 TypeReference::size(Loc)
{
- return Target::ptrsize;
+ return target.ptrsize;
}
Expression *TypeReference::dotExp(Scope *sc, Expression *e, Identifier *ident, int flag)
@@ -6474,12 +6460,12 @@ Type *TypeDelegate::addStorageClass(StorageClass stc)
d_uns64 TypeDelegate::size(Loc)
{
- return Target::ptrsize * 2;
+ return target.ptrsize * 2;
}
unsigned TypeDelegate::alignsize()
{
- return Target::ptrsize;
+ return target.ptrsize;
}
MATCH TypeDelegate::implicitConvTo(Type *to)
@@ -8148,7 +8134,7 @@ Expression *TypeStruct::defaultInitLiteral(Loc loc)
/* Copy from the initializer symbol for larger symbols,
* otherwise the literals expressed as code get excessively large.
*/
- if (size(loc) > Target::ptrsize * 4U && !needsNested())
+ if (size(loc) > target.ptrsize * 4U && !needsNested())
structinit->useStaticInit = true;
structinit->type = this;
@@ -8401,7 +8387,7 @@ Type *TypeClass::semantic(Loc, Scope *sc)
d_uns64 TypeClass::size(Loc)
{
- return Target::ptrsize;
+ return target.ptrsize;
}
Dsymbol *TypeClass::toDsymbol(Scope *)
diff --git a/gcc/d/dmd/mtype.h b/gcc/d/dmd/mtype.h
index 6b5c297..4efeddd 100644
--- a/gcc/d/dmd/mtype.h
+++ b/gcc/d/dmd/mtype.h
@@ -99,9 +99,6 @@ enum ENUMTY
};
typedef unsigned char TY; // ENUMTY
-extern int Tsize_t;
-extern int Tptrdiff_t;
-
#define SIZE_INVALID (~(d_uns64)0) // error return from size() functions
@@ -193,7 +190,6 @@ public:
static Type *tstring; // immutable(char)[]
static Type *twstring; // immutable(wchar)[]
static Type *tdstring; // immutable(dchar)[]
- static Type *tvalist; // va_list alias
static Type *terror; // for error recovery
static Type *tnull; // for null type
diff --git a/gcc/d/dmd/safe.c b/gcc/d/dmd/safe.c
index bf1bc31..08274af 100644
--- a/gcc/d/dmd/safe.c
+++ b/gcc/d/dmd/safe.c
@@ -58,8 +58,8 @@ bool checkUnsafeAccess(Scope *sc, Expression *e, bool readonly, bool printmsg)
if (v->type->hasPointers() && v->type->toBasetype()->ty != Tstruct)
{
- if ((ad->type->alignment() < (unsigned)Target::ptrsize ||
- (v->offset & (Target::ptrsize - 1))) &&
+ if ((ad->type->alignment() < target.ptrsize ||
+ (v->offset & (target.ptrsize - 1))) &&
sc->func->setUnsafe())
{
if (printmsg)
diff --git a/gcc/d/dmd/statementsem.c b/gcc/d/dmd/statementsem.c
index 3186db7..bfcb4b4 100644
--- a/gcc/d/dmd/statementsem.c
+++ b/gcc/d/dmd/statementsem.c
@@ -1153,7 +1153,7 @@ public:
fs->key = new VarDeclaration(loc, Type::tsize_t, idkey, NULL);
fs->key->storage_class |= STCtemp;
}
- else if (fs->key->type->ty != Tsize_t)
+ else if (fs->key->type->ty != Type::tsize_t->ty)
{
tmp_length = new CastExp(loc, tmp_length, fs->key->type);
}
@@ -1585,8 +1585,8 @@ public:
d_uns64 keysize = taa->index->size();
if (keysize == SIZE_INVALID)
goto Lerror2;
- assert(keysize < UINT64_MAX - Target::ptrsize);
- keysize = (keysize + (Target::ptrsize- 1)) & ~(Target::ptrsize - 1);
+ assert(keysize < UINT64_MAX - target.ptrsize);
+ keysize = (keysize + (target.ptrsize - 1)) & ~(target.ptrsize - 1);
// paint delegate argument to the type runtime expects
if (!fldeTy[i]->equals(flde->type))
{
@@ -3248,7 +3248,7 @@ public:
* try { body } finally { _d_criticalexit(critsec.ptr); }
*/
Identifier *id = Identifier::generateId("__critsec");
- Type *t = Type::tint8->sarrayOf(Target::ptrsize + Target::critsecsize());
+ Type *t = Type::tint8->sarrayOf(target.ptrsize + target.critsecsize());
VarDeclaration *tmp = new VarDeclaration(ss->loc, t, id, NULL);
tmp->storage_class |= STCtemp | STCgshared | STCstatic;
@@ -3829,7 +3829,7 @@ void semantic(Catch *c, Scope *sc)
}
else if (cd->isCPPclass())
{
- if (!Target::cppExceptions)
+ if (!target.cpp.exceptions)
{
error(c->loc, "catching C++ class objects not supported for this target");
c->errors = true;
diff --git a/gcc/d/dmd/target.h b/gcc/d/dmd/target.h
index e8d4d6a..d76a9f8 100644
--- a/gcc/d/dmd/target.h
+++ b/gcc/d/dmd/target.h
@@ -24,55 +24,87 @@ class Type;
class TypeTuple;
struct OutBuffer;
+struct TargetC
+{
+ unsigned longsize; // size of a C 'long' or 'unsigned long' type
+ unsigned long_doublesize; // size of a C 'long double'
+ unsigned criticalSectionSize; // size of os critical section
+};
+
+struct TargetCPP
+{
+ bool reverseOverloads; // with dmc and cl, overloaded functions are grouped and in reverse order
+ bool exceptions; // set if catching C++ exceptions is supported
+ bool twoDtorInVtable; // target C++ ABI puts deleting and non-deleting destructor into vtable
+
+ const char *toMangle(Dsymbol *s);
+ const char *typeInfoMangle(ClassDeclaration *cd);
+ const char *typeMangle(Type *t);
+ Type *parameterType(Parameter *p);
+ bool fundamentalType(const Type *t, bool& isFundamental);
+};
+
+struct TargetObjC
+{
+ bool supported; // set if compiler can interface with Objective-C
+};
+
struct Target
{
- static int ptrsize;
- static int realsize; // size a real consumes in memory
- static int realpad; // 'padding' added to the CPU real size to bring it up to realsize
- static int realalignsize; // alignment for reals
- static bool reverseCppOverloads; // with dmc and cl, overloaded functions are grouped and in reverse order
- static bool cppExceptions; // set if catching C++ exceptions is supported
- static int c_longsize; // size of a C 'long' or 'unsigned long' type
- static int c_long_doublesize; // size of a C 'long double'
- static int classinfosize; // size of 'ClassInfo'
- static unsigned long long maxStaticDataSize; // maximum size of static data
+ // D ABI
+ unsigned ptrsize;
+ unsigned realsize; // size a real consumes in memory
+ unsigned realpad; // 'padding' added to the CPU real size to bring it up to realsize
+ unsigned realalignsize; // alignment for reals
+ unsigned classinfosize; // size of 'ClassInfo'
+ unsigned long long maxStaticDataSize; // maximum size of static data
+
+ // C ABI
+ TargetC c;
+
+ // C++ ABI
+ TargetCPP cpp;
+
+ // Objective-C ABI
+ TargetObjC objc;
template <typename T>
struct FPTypeProperties
{
- static real_t max;
- static real_t min_normal;
- static real_t nan;
- static real_t snan;
- static real_t infinity;
- static real_t epsilon;
-
- static d_int64 dig;
- static d_int64 mant_dig;
- static d_int64 max_exp;
- static d_int64 min_exp;
- static d_int64 max_10_exp;
- static d_int64 min_10_exp;
+ real_t max;
+ real_t min_normal;
+ real_t nan;
+ real_t snan;
+ real_t infinity;
+ real_t epsilon;
+
+ d_int64 dig;
+ d_int64 mant_dig;
+ d_int64 max_exp;
+ d_int64 min_exp;
+ d_int64 max_10_exp;
+ d_int64 min_10_exp;
};
- typedef FPTypeProperties<float> FloatProperties;
- typedef FPTypeProperties<double> DoubleProperties;
- typedef FPTypeProperties<real_t> RealProperties;
+ FPTypeProperties<float> FloatProperties;
+ FPTypeProperties<double> DoubleProperties;
+ FPTypeProperties<real_t> RealProperties;
- static void _init();
+private:
+ Type *tvalist;
+
+public:
+ void _init(const Param& params);
// Type sizes and support.
- static unsigned alignsize(Type* type);
- static unsigned fieldalign(Type* type);
- static unsigned critsecsize();
- static Type *va_listType(); // get type of va_list
- static int isVectorTypeSupported(int sz, Type *type);
- static bool isVectorOpSupported(Type *type, TOK op, Type *t2 = NULL);
+ unsigned alignsize(Type *type);
+ unsigned fieldalign(Type *type);
+ unsigned critsecsize();
+ Type *va_listType(const Loc &loc, Scope *sc); // get type of va_list
+ int isVectorTypeSupported(int sz, Type *type);
+ bool isVectorOpSupported(Type *type, TOK op, Type *t2 = NULL);
// ABI and backend.
- static const char *toCppMangle(Dsymbol *s);
- static const char *cppTypeInfoMangle(ClassDeclaration *cd);
- static const char *cppTypeMangle(Type *t);
- static Type *cppParameterType(Parameter *p);
- static bool cppFundamentalType(const Type *t, bool& isFundamental);
- static LINK systemLinkage();
- static TypeTuple *toArgTypes(Type *t);
+ LINK systemLinkage();
+ TypeTuple *toArgTypes(Type *t);
};
+
+extern Target target;