Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implement runtime va_arg implementation for ARM/ARM_EABI platforms.

  • Loading branch information...
commit 03e34f8124eb1c607ffee11630c8ec6809b8f52c 1 parent 496b782
@ibuclaw ibuclaw authored
View
4 gcc/d/ChangeLog
@@ -1,5 +1,8 @@
2012-08-30 Iain Buclaw <ibuclaw@ubuntu.com>
+ * d-lang.cc(d_init): Remove 'Thumb' identifier for ARM as 16bit
+ platforms aren't supported. Add ARM_EABI identifier.
+
* d-decls.cc(TypeInfoDeclaration::toSymbol): Mark all typeinfo decls
as 'used'.
* d-glue.cc(one_elem_array): Remove.
@@ -8,6 +11,7 @@
handle use of declarations marked with comdat, extern or static.
(ObjectFile::doSimpleFunction): Mark function as 'used'.
* dt.cc(dt2node): Clean-up indentation.
+
* Make-lang.in: Fix issue with cross-compiler configuration.
2012-08-29 Iain Buclaw <ibuclaw@ubuntu.com>
View
8 gcc/d/d-lang.cc
@@ -261,11 +261,9 @@ d_init (void)
VersionCondition::addPredefinedGlobalIdent (D_VENDOR_VERSYM);
#endif
-#ifdef TARGET_THUMB
- if (TARGET_THUMB)
- VersionCondition::addPredefinedGlobalIdent ("Thumb");
- else
- VersionCondition::addPredefinedGlobalIdent ("Arm");
+#ifdef TARGET_ARM
+ if (TARGET_AAPCS_BASED)
+ VersionCondition::addPredefinedGlobalIdent("ARM_EABI");
#endif
if (BYTES_BIG_ENDIAN)
View
35 libphobos/libdruntime/core/stdc/stdarg.d
@@ -55,6 +55,9 @@ version( GNU )
* Retrieve and store through parmn the next value that is of TypeInfo ti.
* Used when the static type is not known.
*/
+ void va_arg()(ref va_list ap, TypeInfo ti, void* parmn);
+
+
version( X86_64 )
{
// Layout of this struct must match __gnuc_va_list for C ABI compatibility
@@ -86,7 +89,7 @@ version( GNU )
bool stack = false;
auto offset_fpregs_save = ap.offset_fpregs;
auto offset_regs_save = ap.offset_regs;
-L1:
+ L1:
if (inXMMregister(arg1) || v1)
{ // Passed in XMM register
if (ap.offset_fpregs < (6 * 8 + 16 * 8) && !stack)
@@ -179,6 +182,36 @@ L1:
}
}
}
+ else version( ARM )
+ {
+ version( ARM_EABI )
+ {
+ // Layout of this struct must match __gnuc_va_list for C ABI compatibility
+ struct __va_list
+ {
+ void* ptr;
+ }
+
+ void va_arg()(ref va_list apx, TypeInfo ti, void* parmn)
+ {
+ __va_list* ap = cast(__va_list*)apx;
+ auto p = ap.ptr;
+ auto tsize = ti.tsize();
+ ap.ptr = cast(va_list)( cast(void*) p + ( ( 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)
+ {
+ auto p = ap;
+ auto tsize = ti.tsize();
+ ap = cast(va_list)( cast(void*) p + ( ( 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)
View
63 libphobos/std/format.d
@@ -4666,6 +4666,17 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
va.stack_args = p;
argptr = *cast(va_list*) &va;
}
+ else version(ARM)
+ {
+ version(ARM_EABI)
+ {
+ __va_list va;
+ va.ptr = p;
+ argptr = cast(va_list) va;
+ }
+ else
+ argptr = p;
+ }
else
{
static if (is(va_list == void*))
@@ -4720,6 +4731,16 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
va.stack_args = pkey;
argptr = *cast(va_list*) &va;
}
+ else version (ARM)
+ {
+ version (ARM_EABI)
+ { __va_list va;
+ va.ptr = pkey;
+ argptr = cast(va_list) va;
+ }
+ else
+ argptr = cast(va_list) pkey;
+ }
else
{
static if (is(va_list == void*))
@@ -4741,6 +4762,16 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
va2.stack_args = pvalue;
argptr = *cast(va_list*) &va2;
}
+ else version (ARM)
+ {
+ version (ARM_EABI)
+ { __va_list va2;
+ va.ptr = pvalue;
+ argptr = cast(va_list) va2;
+ }
+ else
+ argptr = cast(va_list) pvalue;
+ }
else
{
static if (is(va_list == void*))
@@ -4893,10 +4924,17 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
goto Lcomplex;
case Mangle.Tsarray:
- version (X86_64)
- putArray((cast(__va_list*)argptr).stack_args, (cast(TypeInfo_StaticArray)ti).len, cast()(cast(TypeInfo_StaticArray)ti).next);
- else version (X86)
+ version (X86)
putArray(argptr, (cast(TypeInfo_StaticArray)ti).len, cast()(cast(TypeInfo_StaticArray)ti).next);
+ else version (X86_64)
+ putArray((cast(__va_list*)argptr).stack_args, (cast(TypeInfo_StaticArray)ti).len, cast()(cast(TypeInfo_StaticArray)ti).next);
+ else version (ARM)
+ {
+ version (ARM_EABI)
+ putArray((cast(__va_list)argptr).ptr, (cast(TypeInfo_StaticArray)ti).len, cast()(cast(TypeInfo_StaticArray)ti).next);
+ else
+ putArray(argptr, (cast(TypeInfo_StaticArray)ti).len, cast()(cast(TypeInfo_StaticArray)ti).next);
+ }
else
{
static if (is(va_list == void*))
@@ -5024,11 +5062,28 @@ void doFormat(void delegate(dchar) putc, TypeInfo[] arguments, va_list argptr)
}
s = tis.xtoString(p);
}
- else version(PPC)
+ else version (PPC)
{ // Structs are pass-by-reference in V4 ABI
void* p = va_arg!(void*)(argptr);
s = tis.xtoString(p);
}
+ else version (ARM)
+ {
+ void* p;
+ version (ARM_EABI)
+ {
+ auto talign = tis.talign();
+ __va_list* ap = cast(__va_list*)&argptr;
+ p = ap.ptr;
+ ap.ptr += (tis.tsize() + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
+ }
+ else
+ {
+ p = argptr;
+ argptr += (tis.tsize() + size_t.sizeof - 1) & ~(size_t.sizeof - 1);
+ }
+ s = tis.xtoString(p);
+ }
else
{
static if (is(va_list == void*))
Please sign in to comment.
Something went wrong with that request. Please try again.