Commit a1ccbae6 by Iain Buclaw

d: Merge update dmd 799066f49

Removes the implementation of __traits(argTypes), which only supported
x86_64 targets.  The only use of this trait is an unused va_arg()
function, this has been removed as well.

Reviewed-on: https://github.com/dlang/dmd/pull/11022

gcc/d/ChangeLog:

2020-04-13  Iain Buclaw  <ibuclaw@gdcproject.org>

	* Make-lang.in (D_FRONTEND_OBJS): Remove d/argtypes.o.
	* d-target.cc (Target::toArgTypes): New function.

libphobos/ChangeLog:

2020-04-13  Iain Buclaw  <ibuclaw@gdcproject.org>

	* libdruntime/core/stdc/stdarg.d: Remove run-time va_list template.
parent af4c9257
2020-04-13 Iain Buclaw <ibuclaw@gdcproject.org>
* Make-lang.in (D_FRONTEND_OBJS): Remove d/argtypes.o.
* d-target.cc (Target::toArgTypes): New function.
2020-04-10 Iain Buclaw <ibuclaw@gdcproject.org> 2020-04-10 Iain Buclaw <ibuclaw@gdcproject.org>
* d-spec.cc (LIBDRUNTIME): Remove. * d-spec.cc (LIBDRUNTIME): Remove.
......
...@@ -59,7 +59,6 @@ D_FRONTEND_OBJS = \ ...@@ -59,7 +59,6 @@ D_FRONTEND_OBJS = \
d/access.o \ d/access.o \
d/aliasthis.o \ d/aliasthis.o \
d/apply.o \ d/apply.o \
d/argtypes.o \
d/arrayop.o \ d/arrayop.o \
d/attrib.o \ d/attrib.o \
d/blockexit.o \ d/blockexit.o \
......
...@@ -410,3 +410,15 @@ Target::systemLinkage (void) ...@@ -410,3 +410,15 @@ Target::systemLinkage (void)
{ {
return LINKc; return LINKc;
} }
/* Generate a TypeTuple of the equivalent types used to determine if a
function argument of the given type can be passed in registers.
The results of this are highly platform dependent, and intended
primarly for use in implementing va_arg() with RTTI. */
TypeTuple *
Target::toArgTypes (Type *)
{
/* Not implemented, however this is not currently used anywhere. */
return NULL;
}
3e10e2dd29e583f1d94d84de5e4bd858e0303669 799066f498aebcfa420df284cac1f204b1f953a8
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the dlang/dmd repository. merge done from the dlang/dmd repository.
...@@ -22,9 +22,9 @@ ...@@ -22,9 +22,9 @@
#include "statement.h" #include "statement.h"
#include "template.h" #include "template.h"
#include "tokens.h" #include "tokens.h"
#include "target.h"
Type *getTypeInfoType(Loc loc, Type *t, Scope *sc); Type *getTypeInfoType(Loc loc, Type *t, Scope *sc);
TypeTuple *toArgTypes(Type *t);
void unSpeculative(Scope *sc, RootObject *o); void unSpeculative(Scope *sc, RootObject *o);
bool MODimplicitConv(MOD modfrom, MOD modto); bool MODimplicitConv(MOD modfrom, MOD modto);
Expression *resolve(Loc loc, Scope *sc, Dsymbol *s, bool hasOverloads); Expression *resolve(Loc loc, Scope *sc, Dsymbol *s, bool hasOverloads);
...@@ -1303,8 +1303,8 @@ void StructDeclaration::finalizeSize() ...@@ -1303,8 +1303,8 @@ void StructDeclaration::finalizeSize()
} }
} }
TypeTuple *tt = toArgTypes(type); TypeTuple *tt = Target::toArgTypes(type);
size_t dim = tt->arguments->dim; size_t dim = tt ? tt->arguments->dim : 0;
if (dim >= 1) if (dim >= 1)
{ {
assert(dim <= 2); assert(dim <= 2);
......
...@@ -37,7 +37,6 @@ ...@@ -37,7 +37,6 @@
bool typeMerge(Scope *sc, TOK op, Type **pt, Expression **pe1, Expression **pe2); bool typeMerge(Scope *sc, TOK op, Type **pt, Expression **pe1, Expression **pe2);
bool isArrayOpValid(Expression *e); bool isArrayOpValid(Expression *e);
Expression *expandVar(int result, VarDeclaration *v); Expression *expandVar(int result, VarDeclaration *v);
TypeTuple *toArgTypes(Type *t);
bool checkAssignEscape(Scope *sc, Expression *e, bool gag); bool checkAssignEscape(Scope *sc, Expression *e, bool gag);
bool checkParamArgumentEscape(Scope *sc, FuncDeclaration *fdc, Identifier *par, Expression *arg, bool gag); bool checkParamArgumentEscape(Scope *sc, FuncDeclaration *fdc, Identifier *par, Expression *arg, bool gag);
bool checkAccess(AggregateDeclaration *ad, Loc loc, Scope *sc, Dsymbol *smember); bool checkAccess(AggregateDeclaration *ad, Loc loc, Scope *sc, Dsymbol *smember);
...@@ -2074,7 +2073,7 @@ public: ...@@ -2074,7 +2073,7 @@ public:
* The results of this are highly platform dependent, and intended * The results of this are highly platform dependent, and intended
* primarly for use in implementing va_arg(). * primarly for use in implementing va_arg().
*/ */
tded = toArgTypes(e->targ); tded = Target::toArgTypes(e->targ);
if (!tded) if (!tded)
goto Lno; // not valid for a parameter goto Lno; // not valid for a parameter
break; break;
......
...@@ -21,6 +21,7 @@ class Dsymbol; ...@@ -21,6 +21,7 @@ class Dsymbol;
class Expression; class Expression;
class Parameter; class Parameter;
class Type; class Type;
class TypeTuple;
struct OutBuffer; struct OutBuffer;
struct Target struct Target
...@@ -73,4 +74,5 @@ struct Target ...@@ -73,4 +74,5 @@ struct Target
static Type *cppParameterType(Parameter *p); static Type *cppParameterType(Parameter *p);
static bool cppFundamentalType(const Type *t, bool& isFundamental); static bool cppFundamentalType(const Type *t, bool& isFundamental);
static LINK systemLinkage(); static LINK systemLinkage();
static TypeTuple *toArgTypes(Type *t);
}; };
void chkArgTypes(S, V...)()
{
pragma(msg, S);
static if (is(S U == __argTypes))
{
foreach (T; U) { pragma(msg, T); }
static assert(U.length == V.length);
foreach (i, T; U)
static assert(is(V[i] == T));
}
else
static assert(0);
}
void chkSingle(T,U)()
{
struct S { T a; }
chkArgTypes!(S, U)();
}
void chkIdentity(T)()
{
chkSingle!(T,T)();
}
void chkPair(T,U,V)()
{
struct S { T a; U b; }
chkArgTypes!(S, V)();
}
version (X86_64)
{
int main()
{
chkIdentity!byte();
chkIdentity!ubyte();
chkIdentity!short();
chkIdentity!ushort();
chkIdentity!int();
chkIdentity!uint();
chkIdentity!long();
chkIdentity!ulong();
chkSingle!(char,ubyte)();
chkSingle!(wchar,ushort)();
chkSingle!(dchar,uint)();
chkIdentity!float();
chkIdentity!double();
chkIdentity!real();
chkIdentity!(void*)();
chkIdentity!(__vector(byte[16]))();
chkIdentity!(__vector(ubyte[16]))();
chkIdentity!(__vector(short[8]))();
chkIdentity!(__vector(ushort[8]))();
chkIdentity!(__vector(int[4]))();
chkIdentity!(__vector(uint[4]))();
chkIdentity!(__vector(long[2]))();
chkIdentity!(__vector(ulong[2]))();
chkIdentity!(__vector(float[4]))();
chkIdentity!(__vector(double[2]))();
chkPair!(byte,byte,short);
chkPair!(ubyte,ubyte,short);
chkPair!(short,short,int);
chkPair!(int,int,long);
chkPair!(byte,short,int);
chkPair!(short,byte,int);
chkPair!(int,float,long);
chkPair!(float,int,long);
chkPair!(byte,float,long);
chkPair!(float,short,long);
//struct S1 { long a; long b; }
//chkArgTypes!(S1, long, long)();
struct S2 { union { long a; double d; }}
chkArgTypes!(S2, long)();
struct S3 { union { double d; long a; }}
chkArgTypes!(S3, long)();
struct S4 { int a,b,c,d,e; }
chkArgTypes!(S4)();
struct S5 { align(1): char a; int b; }
chkArgTypes!(S5)();
struct S6 { align(1): int a; void* b; }
chkArgTypes!(S5)();
struct S7 { union { void* p; real r; }}
chkArgTypes!(S7)();
struct S8 { union { real r; void* p; }}
chkArgTypes!(S8)();
return 0;
}
}
else
{
int main()
{
return 0;
}
}
2020-04-13 Iain Buclaw <ibuclaw@gdcproject.org>
* libdruntime/core/stdc/stdarg.d: Remove run-time va_list template.
2020-04-10 Iain Buclaw <ibuclaw@gdcproject.org> 2020-04-10 Iain Buclaw <ibuclaw@gdcproject.org>
* d_rules.am (libdgruntime_la_LINK): Move to libdruntime/Makefile.am. * d_rules.am (libdgruntime_la_LINK): Move to libdruntime/Makefile.am.
......
...@@ -50,166 +50,6 @@ version (GNU) ...@@ -50,166 +50,6 @@ version (GNU)
void va_arg(T)(ref va_list ap, ref T parmn); void va_arg(T)(ref va_list ap, ref T parmn);
/*************
* Retrieve and store through parmn the next value that is of TypeInfo ti.
* Used when the static type is not known.
*/
version (X86)
{
///
void va_arg()(ref va_list ap, TypeInfo ti, void* parmn)
{
auto p = ap;
auto tsize = ti.tsize;
ap = cast(va_list)(cast(size_t)p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
parmn[0..tsize] = p[0..tsize];
}
}
else version (X86_64)
{
/// Layout of this struct must match __builtin_va_list for C ABI compatibility
struct __va_list
{
uint offset_regs = 6 * 8; // no regs
uint offset_fpregs = 6 * 8 + 8 * 16; // no fp regs
void* stack_args;
void* reg_args;
}
///
void va_arg()(ref va_list apx, TypeInfo ti, void* parmn)
{
__va_list* ap = cast(__va_list*)apx;
TypeInfo arg1, arg2;
if (!ti.argTypes(arg1, arg2))
{
bool inXMMregister(TypeInfo arg) pure nothrow @safe
{
return (arg.flags & 2) != 0;
}
TypeInfo_Vector v1 = arg1 ? cast(TypeInfo_Vector)arg1 : null;
if (arg1 && (arg1.tsize() <= 8 || v1))
{ // Arg is passed in one register
auto tsize = arg1.tsize();
void* p;
bool stack = false;
auto offset_fpregs_save = ap.offset_fpregs;
auto offset_regs_save = ap.offset_regs;
L1:
if (inXMMregister(arg1) || v1)
{ // Passed in XMM register
if (ap.offset_fpregs < (6 * 8 + 16 * 8) && !stack)
{
p = ap.reg_args + ap.offset_fpregs;
ap.offset_fpregs += 16;
}
else
{
p = ap.stack_args;
ap.stack_args += (tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
stack = true;
}
}
else
{ // Passed in regular register
if (ap.offset_regs < 6 * 8 && !stack)
{
p = ap.reg_args + ap.offset_regs;
ap.offset_regs += 8;
}
else
{
p = ap.stack_args;
ap.stack_args += 8;
stack = true;
}
}
parmn[0..tsize] = p[0..tsize];
if (arg2)
{
if (inXMMregister(arg2))
{ // Passed in XMM register
if (ap.offset_fpregs < (6 * 8 + 16 * 8) && !stack)
{
p = ap.reg_args + ap.offset_fpregs;
ap.offset_fpregs += 16;
}
else
{
if (!stack)
{ // arg1 is really on the stack, so rewind and redo
ap.offset_fpregs = offset_fpregs_save;
ap.offset_regs = offset_regs_save;
stack = true;
goto L1;
}
p = ap.stack_args;
ap.stack_args += (arg2.tsize() + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
}
}
else
{ // Passed in regular register
if (ap.offset_regs < 6 * 8 && !stack)
{
p = ap.reg_args + ap.offset_regs;
ap.offset_regs += 8;
}
else
{
if (!stack)
{ // arg1 is really on the stack, so rewind and redo
ap.offset_fpregs = offset_fpregs_save;
ap.offset_regs = offset_regs_save;
stack = true;
goto L1;
}
p = ap.stack_args;
ap.stack_args += 8;
}
}
auto sz = ti.tsize() - 8;
(parmn + 8)[0..sz] = p[0..sz];
}
}
else
{ // Always passed in memory
// The arg may have more strict alignment than the stack
auto talign = ti.talign();
auto tsize = ti.tsize();
auto p = cast(void*)((cast(size_t)ap.stack_args + talign - 1) & ~(talign - 1));
ap.stack_args = cast(void*)(cast(size_t)p + ((tsize + size_t.sizeof - 1) & ~(size_t.sizeof - 1)));
parmn[0..tsize] = p[0..tsize];
}
}
else
{
assert(false, "not a valid argument type for va_arg");
}
}
}
else version (ARM)
{
///
void va_arg()(ref va_list ap, TypeInfo ti, void* parmn)
{
auto p = *cast(void**) &ap;
auto tsize = ti.tsize();
*cast(void**) &ap += ( tsize + size_t.sizeof - 1 ) & ~( size_t.sizeof - 1 );
parmn[0..tsize] = p[0..tsize];
}
}
else
{
///
void va_arg()(ref va_list ap, TypeInfo ti, void* parmn)
{
static assert(false, "Unsupported platform");
}
}
/*********************** /***********************
* End use of ap. * End use of ap.
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment