From patchwork Fri Mar 15 15:49:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Dapp X-Patchwork-Id: 1057123 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-497965-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=linux.ibm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="l9zDI/r1"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44LVQj4Tbbz9s00 for ; Sat, 16 Mar 2019 02:50:18 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:date:mime-version:content-type:message-id; q=dns; s= default; b=IDpWzJkhGAYTJC5aGtwcEoA2KTxAK5kn5PPkyAnyPiDhN4hh5pRMW /YiazskFFchwbfDrD7G4862Zd2DZ7pjVhb5QdrZ1Miq3Ob9x5unN07+u6MtQ5hX5 RCAc8mroLujbnzHWFMoTcrfaot/HiJpWsumQrhHUgw/26o14V4wH+U= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:date:mime-version:content-type:message-id; s= default; bh=JokV2/kqbnbrysDgoHtF220/bVE=; b=l9zDI/r1BP2JAvvYNw6D Q++V6k01I1UrajxQAyNYQj24uah3flES9a9nNEAASbs32Km+UwFrLVwI5UpAIsbl t3gmkCZNkMazCKponlW25aqcubsEPGsrrL3RwzFZW8g4x3ccO1tLG5vjgTXVWNHc Kmsho90Q2ggAZg+BKAVcmPI= Received: (qmail 97105 invoked by alias); 15 Mar 2019 15:50:11 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 97092 invoked by uid 89); 15 Mar 2019 15:50:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, KHOP_DYNAMIC, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=algn, DTV, fa, dtv X-HELO: mx0a-001b2d01.pphosted.com Received: from mx0b-001b2d01.pphosted.com (HELO mx0a-001b2d01.pphosted.com) (148.163.158.5) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 15 Mar 2019 15:50:07 +0000 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x2FFnFC8122668 for ; Fri, 15 Mar 2019 11:50:05 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2r8eegtc2n-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 15 Mar 2019 11:50:03 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 15 Mar 2019 15:50:02 -0000 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 15 Mar 2019 15:50:00 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x2FFnxPd26607792 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 15 Mar 2019 15:49:59 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EF2BB52067; Fri, 15 Mar 2019 15:49:58 +0000 (GMT) Received: from oc6142347168.ibm.com (unknown [9.145.167.58]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTPS id 8E0775204E; Fri, 15 Mar 2019 15:49:58 +0000 (GMT) From: Robin Dapp Subject: [RFC] D support for S/390 To: GCC Patches , ibuclaw@gdcproject.org Date: Fri, 15 Mar 2019 16:49:58 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.5.0 MIME-Version: 1.0 x-cbid: 19031515-0028-0000-0000-000003547E90 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19031515-0029-0000-0000-000024130FBE Message-Id: <4514fe28-8acb-f0fd-510b-6568fda8bf4c@linux.ibm.com> Hi, during the last few days I tried to get D running on s390x (apparently the first Big Endian platform to try it?). I did not yet go through the code systematically and add a version(SystemZ) in every place where it might be needed but rather tried to fix test failures as they arose. After enabling the architecture in the configure files and adding TLS support (see initial.diff) the test suite showed 200 something failures. Including big endian handling in some test cases (tests.diff), the number of failures went down to ~130. Some more involved cases are left: dmd/constfold.c handles 'a' ~ "abc" but fails because 'a' is treated as int64 and only the first bytes are memcpy'd into the result buffer. When using a similar logic as used for "abc" ~ a. This works but seems a rather hacky approach (cat.diff). An even more hacky fix I applied for libdruntime/rt/aaA.d (align.diff) where algn = 0 is passed to the talign function. I suppose it shouldn't ever be called with algn = 0 but the alignment should be set somewhere else initially? Another problem is printing of characters. std.uni.isGraphical returns false for standard ASCII characters because of the trie traversal or rather the final lookup in memory via PackedPtr cast(inout(T))(cast(U*) origin)[idx] This gets the first byte but should get the last byte on Big Endian. A simple + ubyte[] buf = nativeToLittleEndian (origin[idx]); + auto val = cast(inout(T))(buf.peek!U()); helps here, but has two problems: - peek!U() apparently does not work in CTFE and subsequently all compile-time unit tests fail. - simpleIndex() is called in other places and also does the wrong thing return cast(T)((origin[q] >> bits*r) & mask) Refraining from peek!... I tried working around it by extracting bytes and reversing the order but this seems to hacky to create a diff :) I got it to work for test28.d:test39() but the unit tests still fail. Is there a way to debug the compile-time unit tests easily? What's the preferred method to do "the right thing" even at compile time? Any other things that should be looked at? Any comments to the diffs so far? Regards Robin diff --git a/gcc/testsuite/gdc.dg/simd.d b/gcc/testsuite/gdc.dg/simd.d index 812b36649aa..a46bf53fb13 100644 --- a/gcc/testsuite/gdc.dg/simd.d +++ b/gcc/testsuite/gdc.dg/simd.d @@ -1576,7 +1576,10 @@ ubyte[16] foounsto() void testOPvecunsto() { auto a = foounsto(); - assert(a == [0, 0, 64, 65, 0, 0, 64, 65, 0, 0, 64, 65, 0, 0, 64, 65]); + version(littleEndian) + assert(a == [0, 0, 64, 65, 0, 0, 64, 65, 0, 0, 64, 65, 0, 0, 64, 65]); + version(bigEndian) + assert(a == [65, 64, 0, 0, 65, 64, 0, 0, 65, 64, 0, 0, 65, 64, 0, 0]); } /*****************************************/ diff --git a/gcc/testsuite/gdc.test/runnable/mars1.d b/gcc/testsuite/gdc.test/runnable/mars1.d index 1f4e55d9ac4..91d93dbf81e 100644 --- a/gcc/testsuite/gdc.test/runnable/mars1.d +++ b/gcc/testsuite/gdc.test/runnable/mars1.d @@ -238,13 +238,13 @@ void test13023(ulong n) struct U { int a; union { char c; int d; } long b; } -U f = { b:3, d:2, a:1 }; +U f = { b:3, d:0x22222222, a:1 }; void testU() { assert(f.b == 3); - assert(f.d == 2); - assert(f.c == 2); + assert(f.d == 0x22222222); + assert(f.c == 0x22); assert(f.a == 1); assert(f.sizeof == 16); assert(U.sizeof == 16); diff --git a/gcc/testsuite/gdc.test/runnable/test12.d b/gcc/testsuite/gdc.test/runnable/test12.d index 7656de70af6..f38c94dcd23 100644 --- a/gcc/testsuite/gdc.test/runnable/test12.d +++ b/gcc/testsuite/gdc.test/runnable/test12.d @@ -624,7 +624,10 @@ int hoge(S29 s) { char[10] b; printf("%x\n", s); sprintf(b.ptr, "%x", s); +version(littleEndian) assert(b[0 .. 7] == "4030201"); +version(bigEndian) + assert(b[0 .. 7] == "1020304"); return 0; } diff --git a/gcc/testsuite/gdc.test/runnable/test23.d b/gcc/testsuite/gdc.test/runnable/test23.d index ee17be0b00f..120ee3d380c 100644 --- a/gcc/testsuite/gdc.test/runnable/test23.d +++ b/gcc/testsuite/gdc.test/runnable/test23.d @@ -565,7 +565,10 @@ void test25() auto str3 = cast(wchar[3])("defghi"); writefln("str3: ", (cast(char[])str3).length , " : ", (cast(char[])str3)); - assert(cast(char[])str3 == "d\000e\000f\000"c); + version(littleEndian) + assert(cast(char[])str3 == "d\000e\000f\000"c); + version(bigEndian) + assert(cast(char[])str3 == "\000d\000e\000f"c); } /*******************************************/ diff --git a/gcc/testsuite/gdc.test/runnable/test4.d b/gcc/testsuite/gdc.test/runnable/test4.d index f008da6da72..ff6f6d407ed 100644 --- a/gcc/testsuite/gdc.test/runnable/test4.d +++ b/gcc/testsuite/gdc.test/runnable/test4.d @@ -254,6 +254,16 @@ else version(ARM) assert(TRECT6.BottomRight.offsetof == 16); assert(TRECT6.foo2.offsetof == 24); } +else version(SystemZ) +{ + assert(TRECT6.Left.offsetof == 8); + assert(TRECT6.Top.offsetof == 12); + assert(TRECT6.Right.offsetof == 16); + assert(TRECT6.Bottom.offsetof == 20); + assert(TRECT6.TopLeft.offsetof == 8); + assert(TRECT6.BottomRight.offsetof == 16); + assert(TRECT6.foo2.offsetof == 24); +} else { assert(TRECT6.Left.offsetof == 4);