From patchwork Wed Dec 19 19:16:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738041 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C4C636C2 for ; Wed, 19 Dec 2018 19:26:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B4EA327D29 for ; Wed, 19 Dec 2018 19:26:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A80AD27E5A; Wed, 19 Dec 2018 19:26:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 27F9B27D29 for ; Wed, 19 Dec 2018 19:26:46 +0000 (UTC) Received: from localhost ([::1]:33771 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhUT-00006e-8k for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:26:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhL0-0000rn-QY for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:16:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhKv-0008Cu-QL for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:16:58 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:29163) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhKv-0008CX-FM; Wed, 19 Dec 2018 14:16:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247014; x=1576783014; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=mF4O0+bfADNh8fzyDt27zpjmLYs6qg05LJuV8MMK3Jo=; b=dmv0nkhBYcrRw0s4dK+c/7m2XEm23VxoLD9zfskTPZJe5w71OuDxxInM z165K/HUOd30DlxIPnwWGfOqTUcpRa01uro6o5zRiARWqcDArcdhYUbGE NwEjvK1bCtAaSEH8a34XzlK2doCLwGvYtH3Qsq00E2Dx1JnApjepB3g4k bHMaAmUyA3gRgnbuP4wJY4YDz9k9eggUmRg4V0rUpl+ZMmzgC6XwdE7KG pwbXlrtd1/ZwNOrcBr24ZZfvCRKNVoVetYGGxqcoaSTI7OynMKIIIDaox Z6tLy2gVCnWex/4glCq18JS8SCfDOYRipp6gtl3y0wNu8dLRk6/UNpNO9 g==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="97003944" Received: from mail-dm3nam03lp2054.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([104.47.41.54]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:16:25 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pjqulYK6IymM7ZlRic1bd6OprINR9qsdhN20yySqNEE=; b=CIpiv3guRh7lHk2+CrNy11ldMbk8Ixt8dkQbr7qs5/7ursu2juuJJIIwsqhHP9Pj6H9H2pmPofVb4tztNeLbcucT9MuyiG67I6ZVl1FSZT9CMvhCfMYnfD7IwNhH65VH1Sl4it0xfQ3LfZeeEkzSg1U6xw2i4Aaps2ZERFs5xgk= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0271.namprd04.prod.outlook.com (10.169.202.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.20; Wed, 19 Dec 2018 19:16:22 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:16:22 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 01/23] elf.h: Add the RISCV ELF magic numbers Thread-Index: AQHUl89Trg8LjQFUAkiS2dtJaJoUPQ== Date: Wed, 19 Dec 2018 19:16:22 +0000 Message-ID: <02fc0b3a733f5f08eb396bee5afd3d327941f0c9.1545246859.git.alistair.francis@wdc.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR03CA0020.namprd03.prod.outlook.com (2603:10b6:a02:a8::33) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.171] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0271; 6:jllSq9IZO/whWTtOMY/h89LHwldvDoZyaVNvJrwuQdnstLp42qzCB2lCJaMpgvrOTH6i2CSJkt1cjEF4rt3dvRrL/llgj0l721+2zjBkwp/uFsaaeEgTYn93CRj2lgTgE54KwHfLDL94W4hdxI6Din3vmh7Rdj/F0R6rTKlMRjeqNvX1tiW5PPAyfIOw57aptRyBrDwxOLtxI4nzEneY2+m8JWYRFeRLatgwbJCUnVmYSdXFalkGRQCWqL4Aw/eoVG8J37PS6JrXBjElC1D7tLKLj97Yp/ROV5u9fYofoGd3myzwoKJC+sjo9eiEXkUD9XvAWUTpboFiWsG+Rs6dv0lklrz9lSYtsJfY71JBMgJXoL67XWo4ZUKmQsMFeuMgwoEizr/KSSUv0odmDOj4887MPwEMPN7J8+xCfV5EzWU2MvOODJZ0dfWCupFswE/uRZqMRwPo54mwCm2/60IqFQ==; 5:4cM/kUXcjmbb4nFrvT4f2QHB/IngqtaKe0LhlOVQvgSqq7trqlAdYQ2vBaaKdPQdeutsNU34KbivkfKhFKU56tpPe5DM6Zq4i2tdUFPaR3l0MSM7EKc5ICNdq8STejaqBv5W2JRHg9q9JgG5lyxYD/vW3PH/vd+7WeTQWtPZjjE=; 7:NvSIi4ibNLkZEEbxrZUUKUIpuqTBIlmMR4XJif13dHJ91iRhhSMSKXdj8sp30wMOGeki6fLz4EYauh5KLQolO1lZ0eQNiEWj6RXHif1x4whSDD8YHCq3IR+kim/rQK0s12DWPGnUKZtFnRCkaySU0w== x-ms-office365-filtering-correlation-id: 634e7445-cf7f-441b-b73a-08d665e67629 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0271; x-ms-traffictypediagnostic: MWHPR04MB0271: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(5005020)(6040522)(2401047)(8121501046)(93006095)(93001095)(3231475)(944501520)(52105112)(10201501046)(3002001)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0271; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0271; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(136003)(376002)(346002)(39860400002)(396003)(189003)(199004)(26005)(186003)(36756003)(54906003)(3846002)(99286004)(110136005)(25786009)(6116002)(14454004)(97736004)(217873002)(102836004)(256004)(71190400001)(7736002)(71200400001)(5660300001)(305945005)(6506007)(386003)(86362001)(575784001)(105586002)(478600001)(52116002)(316002)(6512007)(8676002)(81166006)(81156014)(118296001)(66066001)(50226002)(53936002)(486006)(44832011)(39060400002)(2616005)(76176011)(446003)(72206003)(106356001)(8936002)(476003)(11346002)(6486002)(68736007)(2501003)(6436002)(4326008)(2906002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0271; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: pf+NXDGAIsguDYubIwKLFfrqsOqxrrKL93iEmrZhL+7ODJ9dHMYOHCkYU/AWK/XLvepehdLRH0BSbyqth4wsm6YwjDjCqtIE+tv4vtIvi+QFP2kThMauPxoUpFdycp9h3VsNN2B8Zlqcr+Jbd8nkjFsAQw9zME6b/Ya7i/5o1Oi3BFwQ3G/X1Ng+v66BnU3SA8wG3c5UIO9MBfSnNcBejxGjx4McsHpFSzeVw2msjSoGo93Vy1QTVMTQ1AOy+GcjKG+1pWmls9Yu2AQim+L4VFBP3QfNWadgjzRK4cTD2WmoNy7UuzBFfrOpocrs7Z2M spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 634e7445-cf7f-441b-b73a-08d665e67629 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:16:22.0924 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0271 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.154.42 Subject: [Qemu-devel] [PATCH v2 01/23] elf.h: Add the RISCV ELF magic numbers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Reviewed-by: Richard Henderson --- include/elf.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/include/elf.h b/include/elf.h index c151164b63..0ac7911b7b 100644 --- a/include/elf.h +++ b/include/elf.h @@ -1338,6 +1338,61 @@ typedef struct { #define R_IA64_DTPREL64LSB 0xb7 /* @dtprel(sym + add), data8 LSB */ #define R_IA64_LTOFF_DTPREL22 0xba /* @ltoff(@dtprel(s+a)), imm22 */ +/* RISC-V relocations. */ +#define R_RISCV_NONE 0 +#define R_RISCV_32 1 +#define R_RISCV_64 2 +#define R_RISCV_RELATIVE 3 +#define R_RISCV_COPY 4 +#define R_RISCV_JUMP_SLOT 5 +#define R_RISCV_TLS_DTPMOD32 6 +#define R_RISCV_TLS_DTPMOD64 7 +#define R_RISCV_TLS_DTPREL32 8 +#define R_RISCV_TLS_DTPREL64 9 +#define R_RISCV_TLS_TPREL32 10 +#define R_RISCV_TLS_TPREL64 11 +#define R_RISCV_BRANCH 16 +#define R_RISCV_JAL 17 +#define R_RISCV_CALL 18 +#define R_RISCV_CALL_PLT 19 +#define R_RISCV_GOT_HI20 20 +#define R_RISCV_TLS_GOT_HI20 21 +#define R_RISCV_TLS_GD_HI20 22 +#define R_RISCV_PCREL_HI20 23 +#define R_RISCV_PCREL_LO12_I 24 +#define R_RISCV_PCREL_LO12_S 25 +#define R_RISCV_HI20 26 +#define R_RISCV_LO12_I 27 +#define R_RISCV_LO12_S 28 +#define R_RISCV_TPREL_HI20 29 +#define R_RISCV_TPREL_LO12_I 30 +#define R_RISCV_TPREL_LO12_S 31 +#define R_RISCV_TPREL_ADD 32 +#define R_RISCV_ADD8 33 +#define R_RISCV_ADD16 34 +#define R_RISCV_ADD32 35 +#define R_RISCV_ADD64 36 +#define R_RISCV_SUB8 37 +#define R_RISCV_SUB16 38 +#define R_RISCV_SUB32 39 +#define R_RISCV_SUB64 40 +#define R_RISCV_GNU_VTINHERIT 41 +#define R_RISCV_GNU_VTENTRY 42 +#define R_RISCV_ALIGN 43 +#define R_RISCV_RVC_BRANCH 44 +#define R_RISCV_RVC_JUMP 45 +#define R_RISCV_RVC_LUI 46 +#define R_RISCV_GPREL_I 47 +#define R_RISCV_GPREL_S 48 +#define R_RISCV_TPREL_I 49 +#define R_RISCV_TPREL_S 50 +#define R_RISCV_RELAX 51 +#define R_RISCV_SUB6 52 +#define R_RISCV_SET6 53 +#define R_RISCV_SET8 54 +#define R_RISCV_SET16 55 +#define R_RISCV_SET32 56 + typedef struct elf32_rel { Elf32_Addr r_offset; Elf32_Word r_info; From patchwork Wed Dec 19 19:16:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738009 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6AD6313AD for ; Wed, 19 Dec 2018 19:19:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C521276D6 for ; Wed, 19 Dec 2018 19:19:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FA122793B; Wed, 19 Dec 2018 19:19:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CF99D276D6 for ; Wed, 19 Dec 2018 19:19:42 +0000 (UTC) Received: from localhost ([::1]:33727 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhNd-0002nE-TC for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:19:41 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45072) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhKf-0000cQ-Il for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:16:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhKc-000859-Cn for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:16:37 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:43313) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhKb-00084W-Um; Wed, 19 Dec 2018 14:16:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545246994; x=1576782994; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=gJgiSuG0iwlK1F/hCf0xcFPSmg0ZPzfNDeuHdD65rtY=; b=NfnqIM36D8k2zVbYMHl/Z3HYsSQLzigVar3HE246e6c7xs1Ob/ev5PES aoCU/kPmQPyh0HnOpeftoXDDtvthiDx/fkwS5TJnUGceQCNcSG/ea2JZo ick+GINWo9R0n5a1TkhfVHKbCtmwibAztIO+oa0LbBIdzpvezTlOB00No 4Y1NkBVfl8Sx1X1K4UzWcX/tYPe766O5f9mktsStkSlRGVeYPV8qdtfNx ubuUBEUm5NGUQNTwn4nsqBb2TQLU25Xnzl+txf3ehyz3emr7+fd7V0maJ hCIDAOBKLDjdO/xvlmdpxD0kV/iYGaKSmak/ZNdO4Oe4wx7iKHmAngD8Z g==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="98234143" Received: from mail-dm3nam03lp2056.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([104.47.41.56]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:16:32 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=16prZPjZjnUkBMlTeKUtbB7sMygQ2Vko46249thdqgs=; b=I41+IH9HI9ozx9Hjas16IAVj8srxWNGHSEPHfTOmibrwnxMrztMYFE0oON4iup9TWQ/ZG2WsCj737zq5h98OEtUCRwMEvEQ7XFExcOJxGJBx3L0mH3OwuyXh1F+h+yHAzfB7tm/cQGDhDodZ5foPC6AiATXsKCFmYsy794z/PQk= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0271.namprd04.prod.outlook.com (10.169.202.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.20; Wed, 19 Dec 2018 19:16:31 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:16:31 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 02/23] linux-user: Add host dependency for RISC-V 32-bit Thread-Index: AQHUl89Z7beZaTJF8k+eCQe3lLLpUg== Date: Wed, 19 Dec 2018 19:16:31 +0000 Message-ID: <76f8f9383a766dbcade883e897dec8cfef669799.1545246859.git.alistair.francis@wdc.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR04CA0017.namprd04.prod.outlook.com (2603:10b6:a03:40::30) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.250] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0271; 6:TeBJr2E9ZWWhrgvve8y6q7AR9iY/1IZRLkXt7AsBGxUwbl9P533jGiz3lPFjjbohbCdonDQ/HV6nogkajfbgso6x9Xs1eKxeq/0FHPL7NP7gHPOldOJKJVTr0XlJ3Ew0LuNbHEFNiLyCbrKDEwYDgTEWbJK35MGFYU1ysmSGaauifnp1MpfYRr3p2QGDNaRz+tcSnIn0RNALAOjvoUj0SgY7FPrmsLNCJmqTOCrU3EWWCB9EilOhoFwbaWbMRgp1bLvlwJKEysNY5/z7x4icReqpghQborY3s7d5BBu5TGuqj8RbZMA4+LjilEMBGSUJ2UqkTPGQsAhVfBsxOWV2eDObZdmMWtdL0fkxSei3Qoug8zJr2HFFmdkLQQgupQkDLF5dJH0c2IyRNHq/r2+CYnzqRasZSd5njqeE9Uje46BqH+hkB1iZzP6LqwR43c/jNd9gqgDhhCrD7uLtP3yWtQ==; 5:g9XkgtoyrZ0I34lSZKBjVsGrB6AMx1+U6MAUJoj/gDLfaSjZZJhFH+KTXQsUCguXHYTKGQ1T+WJYLlVvlVXKUoc4XvTRBv4BnVUoVhFn7YBrzElm3C+FbMchW1YbnmI1SgV5H09p6oYnF6i3iFI1dGuOL8KpI7SvK4+eIwbl0v8=; 7:uglThXQXOyKXttBICUSQRHBx2ROOiIeJ7F1Tv4VwOjdB4KFAPuUHT3f6xuN1S9OqCilae+KRMTMuDFk0HxOK0LBvGmGUYJz7ESnPwCKXwMYqS8zkrVbFYoX1fbddtFm8BZP02MJ2T2AN/OsLedLAkA== x-ms-office365-filtering-correlation-id: a7872934-2117-4200-0ea3-08d665e67b86 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0271; x-ms-traffictypediagnostic: MWHPR04MB0271: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(5005020)(6040522)(2401047)(8121501046)(93006095)(93001095)(3231475)(944501520)(52105112)(10201501046)(3002001)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0271; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0271; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(979002)(366004)(136003)(376002)(346002)(39860400002)(396003)(189003)(199004)(26005)(186003)(36756003)(54906003)(3846002)(99286004)(110136005)(25786009)(6116002)(14454004)(97736004)(102836004)(256004)(71190400001)(7736002)(71200400001)(5660300001)(305945005)(6506007)(386003)(86362001)(105586002)(478600001)(52116002)(316002)(6512007)(8676002)(81166006)(81156014)(118296001)(66066001)(50226002)(53936002)(486006)(44832011)(39060400002)(2616005)(76176011)(446003)(72206003)(106356001)(8936002)(476003)(11346002)(6486002)(68736007)(2501003)(6436002)(4326008)(2906002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0271; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: P7ZU9w7V+4LI0654YWlwBs90ALnmlEF+uuU+6vs1DvzggwYEGiYiW+xKujv6jYhDGKXI/yUFPX7A8nsGYaB+YlowmzjGiHegXPJXOSoSqbC8VgHYfuuEMxTJsA2+G2t4N9LJMdti/TvaGiqVeeLfYLMAXVTWG9aV6BxpfPrpYmGQQnZqo/BdfSzLx0HudxOxXEpVaxoZyacqt6cvBiw0PU3Q33vSbpL3X+zZhz0xPlFF4r+eTvdrqGtyHMSNoL5h9iJqjBfiHnjB6LhUYfwtaiFtxR0To7DOMLob4EWDBus9iZL7BDvoR5PWHS8ALBAJ spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: a7872934-2117-4200-0ea3-08d665e67b86 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:16:31.1572 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0271 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.144 Subject: [Qemu-devel] [PATCH v2 02/23] linux-user: Add host dependency for RISC-V 32-bit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Reviewed-by: Richard Henderson --- MAINTAINERS | 1 + linux-user/host/riscv32/hostdep.h | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 linux-user/host/riscv32/hostdep.h diff --git a/MAINTAINERS b/MAINTAINERS index d676c73f88..7ff561ce3a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -266,6 +266,7 @@ S: Maintained F: target/riscv/ F: hw/riscv/ F: include/hw/riscv/ +F: linux-user/host/riscv32/ F: disas/riscv.c S390 diff --git a/linux-user/host/riscv32/hostdep.h b/linux-user/host/riscv32/hostdep.h new file mode 100644 index 0000000000..adf9edbf2d --- /dev/null +++ b/linux-user/host/riscv32/hostdep.h @@ -0,0 +1,11 @@ +/* + * hostdep.h : things which are dependent on the host architecture + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef RISCV32_HOSTDEP_H +#define RISCV32_HOSTDEP_H + +#endif From patchwork Wed Dec 19 19:16:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738027 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EEA026C2 for ; Wed, 19 Dec 2018 19:23:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB17227D29 for ; Wed, 19 Dec 2018 19:23:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB48027DA4; Wed, 19 Dec 2018 19:23:56 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5024827D29 for ; Wed, 19 Dec 2018 19:23:56 +0000 (UTC) Received: from localhost ([::1]:33753 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhRj-0006BF-Gt for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:23:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhKs-0000j3-9B for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:16:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhKm-0008Ar-O7 for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:16:50 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:43326) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhKm-0008AW-Cl; Wed, 19 Dec 2018 14:16:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247004; x=1576783004; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=7Os3cJyYrHUFl3hWLTP+A+XeM3N4lo13NaEZ826/bDk=; b=gD9yfBTGHIp4wkJcY9/dyFbtOUGOa/IrZm+ELIpH5/QWGRCDAgGvWyxq hnjCUnGrX+iXebupebGh4uxU/DVLnXxa1YlfPzOpEoZmhfygxFU2Na8RT 3OK+NmYLdlESi3t5bLiButIe9WhaJ6NV4vN1+2FhrPp6SlQHSIAIgeqDh oXG2tGDaZ8Jo6n92tgRK5GDSA9DpoG/ZFPSZBJLdvt3/f5EqJ8UiCzdyI l9PsEeNTHWNpTjxehjiyVHs2+R5M7zVJS35qYQZPihDPaMNA7osqr/Rth XLueYb2CoBObDr1umt8FOl8owtu6k0KlDUO6YwQaIIjPqeIP5eZP7q2XA Q==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="98234150" Received: from mail-dm3nam03lp2050.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([104.47.41.50]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:16:43 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uBcd9S0NVzeMrIHhn7w+pxRFA7FwKjCxYFsB/xTxGEY=; b=bAPf1CYzyKVjQ144WIJRQ+qNXFt/W6MLUDZCzW7Q0QyD7os2uAlhgUMKl7VJWgu+0Es18a6AuMsQQrksjO7sh22ggtgJFXEAVWdLh61z8Z4kQkLBcRoJGfmvtnbpizBydNQJ9sa9eHLHhq6aHqlVvee6zv8ZrCNKdGBGBkTpMyc= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0271.namprd04.prod.outlook.com (10.169.202.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.20; Wed, 19 Dec 2018 19:16:41 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:16:41 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 03/23] linux-user: Add host dependency for RISC-V 64-bit Thread-Index: AQHUl89fKWq1gaKU+UusQKDKb8bn9w== Date: Wed, 19 Dec 2018 19:16:41 +0000 Message-ID: <9d777f619840a8dd8e4f3834dcfc3bd28e052ccd.1545246859.git.alistair.francis@wdc.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR04CA0026.namprd04.prod.outlook.com (2603:10b6:a03:40::39) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.250] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0271; 6:tAVWn9/FIjl1xHl36gmjg08QBvPJmCQj9yKlpNyeRr3vAGGzWsnDpfUfb5G8haoUUbsPQ7gqWZR3GW6Y2eqtOOLnV32zbsg/1BoJwHe/WmUtyWemEXaaughrKwuAG+NpyVo0XAXwzGlKcfp3VkFvDbY1KXErInYnD/YdoXRq7ImElxb96W2mrX7alYvj/747YRFycuB65DO6iEluwrkC5RFIpEx75wkYMT3Yah2lvzzuTuehuMCrBWBWuCrm8DA04kJNT+HxNaKStAipoEdsVNh34CH7PSFV4X2mndMqxZRRbVpMGS6a7bxCCpNn8vtWilnSJvxTnnYU9BXogry9JWvvkj1n2Q4YtlSONERNTAYdjwYKdCsnJVR0L1TKQr6j6w2h9ygr9vN7MphGGVIy8rCSXToXqT7I3OrQ1zgU7jCD57HLwacPVGt8nxkoyX0NAYrAsbgaSNYf3E7FIn11Mg==; 5:1VU669IrfRwavR0zXcE47RxdTkz+phCL/vTixweEve/TdOjQPp90jplhfmc7oNYUbVeEqkwkVe4/rq5HnM2GyMvnmKqWRAGlvRL7Hf6iFQdOyOTsUIz/dI7+l6keYQIupqCte2aOWh5F6fg8PWrJTcDAbkNK9R7w2bhbLESjh4U=; 7:2iH9IVdhSN2NkL4AIvrixPnp5PUiGPxyiW/g/rWeI8Exbjb2tpX5EBKtHpY+DO6R8hckGNvMn4pXCdWF4lA7eHBADSz3AVGhjWsmtUxFnSAKkANqpLVkTYRAv+QxVI0anOFubwqCSi2wiXl0/Gor/A== x-ms-office365-filtering-correlation-id: 582206ba-9775-4800-b90b-08d665e681a5 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0271; x-ms-traffictypediagnostic: MWHPR04MB0271: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(5005020)(6040522)(2401047)(8121501046)(93006095)(93001095)(3231475)(944501520)(52105112)(10201501046)(3002001)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0271; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0271; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(136003)(376002)(346002)(39860400002)(396003)(189003)(199004)(26005)(186003)(36756003)(54906003)(3846002)(99286004)(110136005)(25786009)(6116002)(14454004)(97736004)(102836004)(256004)(71190400001)(7736002)(71200400001)(5660300001)(305945005)(6506007)(386003)(86362001)(105586002)(478600001)(52116002)(316002)(6512007)(8676002)(81166006)(81156014)(118296001)(66066001)(50226002)(53936002)(486006)(44832011)(39060400002)(2616005)(76176011)(446003)(72206003)(106356001)(8936002)(476003)(11346002)(6486002)(68736007)(2501003)(6436002)(4326008)(2906002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0271; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: h+Kh4mrpp3bMaTPeOcVTK2VIzWH22KvD3OVwPvQ4W+/qeIJPTCyXqjN4r+0S8IKSOk1xR7xB6PGL2agKCxMcfou6sANvssuVq3Roh/+97DNh+ZjoxPTUcJ7xSPFAuXOmZ/4hWBCejt4g+KSxWeeVbr+ngv/JPEtdLIuTKb2mEFnJ4pC7pOsrSqVnvwGcinP7NuOUfUvbFO7JnKoI/StKICGzkpqr1v5MHsyqI3iTd0ksnYLx/Gmg2PmLB7oPQ207K9WQXK4kRSqOYBIllAIlBB8hUVZ/ANYH42ZAIsXCcYUVO8VcI64S6RnDIAzSDoEB spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 582206ba-9775-4800-b90b-08d665e681a5 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:16:41.5642 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0271 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.144 Subject: [Qemu-devel] [PATCH v2 03/23] linux-user: Add host dependency for RISC-V 64-bit X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Reviewed-by: Richard Henderson --- MAINTAINERS | 1 + linux-user/host/riscv64/hostdep.h | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100644 linux-user/host/riscv64/hostdep.h diff --git a/MAINTAINERS b/MAINTAINERS index 7ff561ce3a..b923f4c1b3 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -267,6 +267,7 @@ F: target/riscv/ F: hw/riscv/ F: include/hw/riscv/ F: linux-user/host/riscv32/ +F: linux-user/host/riscv64/ F: disas/riscv.c S390 diff --git a/linux-user/host/riscv64/hostdep.h b/linux-user/host/riscv64/hostdep.h new file mode 100644 index 0000000000..28467ba00b --- /dev/null +++ b/linux-user/host/riscv64/hostdep.h @@ -0,0 +1,11 @@ +/* + * hostdep.h : things which are dependent on the host architecture + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#ifndef RISCV64_HOSTDEP_H +#define RISCV64_HOSTDEP_H + +#endif From patchwork Wed Dec 19 19:16:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738023 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 021266C2 for ; Wed, 19 Dec 2018 19:23:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E5BDD27D29 for ; Wed, 19 Dec 2018 19:22:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D99A127DA4; Wed, 19 Dec 2018 19:22:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5FB0A27D29 for ; Wed, 19 Dec 2018 19:22:59 +0000 (UTC) Received: from localhost ([::1]:33747 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhQo-0005O3-CY for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:22:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45246) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhL1-0000sE-Fh for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:17:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhKx-0008DM-I2 for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:16:59 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:43340) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhKx-0008D6-8v; Wed, 19 Dec 2018 14:16:55 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247015; x=1576783015; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=2S7rrauxjQHW78NG9LVvSqZTCkNXnKASIbbFBeT4g4o=; b=NFK9m+GJHMiTKVx1VsiFSlEl/ymCKE4Q20oPyq0JXgfmsWUwGCpPhTdj dvDqaQy4iyZyWgLTJahMC/S4pH44+Maewlifhcal14jWe2Z+sG+jjMZXF 2q5LA/eoUX25iOf7SsXfC3Th9jx8B7LrN466mWTaCXZhc2bbyQsImQM1K Nt6YoSqIdxz+JgHX+KRBZGKlVx6VPyMwq3pea8PI6nP5osUxTd0+AxhQ0 yLe9DM9fNIBisOx9CbLBlz8I8Kwk+OWBmZQPyY/gxHEiFFDao5WMxucMK SRXPGy1K/QwQfSKoUsxbnOE/r999xzQCFfxflDWRAjU9oS57azuymSwak g==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="98234158" Received: from mail-dm3nam03lp2056.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([104.47.41.56]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:16:54 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2S7rrauxjQHW78NG9LVvSqZTCkNXnKASIbbFBeT4g4o=; b=C6wR0TUu31ztscmU8SgOdePXwlX7XtJagfx8kOzlC0FY5OH58BZG3avjlX7unW+tKQrpVfDXDg+Thb5iTbZLyg+CtTHgwDmonteaX4m9cpGwYobEulbzn63+peRVzegU5/uC7ySPsGXc95QdVq68Gy59nQseSRJYWh+9IlFw/NM= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0271.namprd04.prod.outlook.com (10.169.202.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.20; Wed, 19 Dec 2018 19:16:52 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:16:52 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 04/23] exec: Add RISC-V GCC poison macro Thread-Index: AQHUl89li/gdJnBMB0WW8FL0tNYH1A== Date: Wed, 19 Dec 2018 19:16:52 +0000 Message-ID: <00d02e34f10b87fd61f8dc69ac93d1eb63df949c.1545246859.git.alistair.francis@wdc.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR04CA0036.namprd04.prod.outlook.com (2603:10b6:a03:40::49) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.250] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0271; 6:y28uSlunvA8IqZuKsELLD83gntRq1UkFhTiapu+Kf03iNoz9DmmzAzoSyepC00yAvqKAuIiW7pwULZiNgqk8yFUg1YrvaTt+IwhcE+Gm+J/DLeqbrCFIOLuMDNaBpJKL4yVIjngl1rjbRaGtPyaqkm9FUfxV5ECMoTor6khW/a6nBsY35gJhH38aygDs7aJRJywRlSY/9d23Wnvgbp7VA2PoOdetRzALFdbNohl8eY+eDuYITYA8P9aDapta/U/3b3Q4w5mcZZT5UGr285M52CWncFG2zHNx5vPZG0e5bvuvxNR1UJEjlxXFpcw5u9ka53ARtpbVcL9f6+D1xj/02mNH6X7ctFEWVy2Rr9XfsPD2fRUqPS0n5B8uvsQt49RD4suARAngG/P8n6Z6SJbXuSPnJDVJ93cPr65Ryn+dalvNh9FpETVn5togetT5yDJaF78B51c9/dzi1zIr+rHveQ==; 5:2wpDBlFMbW4dcNKM1aBU3IivnPI3sTQ5K9x3Sc5oKzJTttJiVhHvt9Nb4ZMD9uxsKbqrMEYUz29DdF2tBXjDuexYFwv6QCR3eKWECbXN55DK+gvFEAYtEtBL6Av03GNAKMDaluy15bjJSODUW3U19xhLButhD6BbLsvvgnTjPUw=; 7:9SKVKOBC1egPPrT25rASxN3fO4+uFsra/MS/04neRszxkGetFnBqW7BPSHlv6uYqVaywL0GFJiqHTaVc4GhH1NqsFIrff74kxPKHt4EPRAGCmSAF3exV60QxejMd0m55bYujvyheDabNZOPqkSQkxQ== x-ms-office365-filtering-correlation-id: a166fc7a-1ee3-42bc-b005-08d665e687fa x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0271; x-ms-traffictypediagnostic: MWHPR04MB0271: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(5005020)(6040522)(2401047)(8121501046)(93006095)(93001095)(3231475)(944501520)(52105112)(10201501046)(3002001)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0271; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0271; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(136003)(376002)(346002)(39860400002)(396003)(189003)(199004)(26005)(186003)(36756003)(54906003)(3846002)(99286004)(110136005)(25786009)(6116002)(14454004)(97736004)(102836004)(256004)(71190400001)(7736002)(71200400001)(5660300001)(305945005)(6506007)(386003)(86362001)(105586002)(478600001)(52116002)(316002)(6512007)(8676002)(81166006)(81156014)(118296001)(66066001)(50226002)(53936002)(486006)(44832011)(39060400002)(2616005)(76176011)(446003)(72206003)(106356001)(8936002)(476003)(11346002)(6486002)(68736007)(2501003)(6436002)(4326008)(2906002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0271; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: ysmKhX7gP8A90MAqrR2Hh1AkviUIRtRO7T+WHrerX0fht4WIAhnSVbAwaaXoYGEyDk9B1vCjOiFmBTSxQC4N9olVxSaQEOb9WzjqwzfWTPsXLWBjCL0ya0I8qbNE5H1fMnga6a8P0vXuTQ6oiHDRM+s3TCf0ZIxGThRVQGvy3hcj743d79uxJmlpPCQ7LiT+cfgCdyTWm3mu+W8skgIuBbuvGLqrhZP89lbyJI5FodgdjDzpdqFjR3ORYpVNpKQoMZ7Yp5wKtAPclByP0O5wANixKwplcgfsjxqB/K613BILgLZsfpAyC3wgtiqkDido spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: a166fc7a-1ee3-42bc-b005-08d665e687fa X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:16:52.1043 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0271 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.144 Subject: [Qemu-devel] [PATCH v2 04/23] exec: Add RISC-V GCC poison macro X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Reviewed-by: Richard Henderson --- include/exec/poison.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/exec/poison.h b/include/exec/poison.h index 32d53789f8..ecdc83c147 100644 --- a/include/exec/poison.h +++ b/include/exec/poison.h @@ -79,6 +79,7 @@ #pragma GCC poison CONFIG_MOXIE_DIS #pragma GCC poison CONFIG_NIOS2_DIS #pragma GCC poison CONFIG_PPC_DIS +#pragma GCC poison CONFIG_RISCV_DIS #pragma GCC poison CONFIG_S390_DIS #pragma GCC poison CONFIG_SH4_DIS #pragma GCC poison CONFIG_SPARC_DIS From patchwork Wed Dec 19 19:17:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738021 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 46E4F6C2 for ; Wed, 19 Dec 2018 19:22:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 362EE27CF3 for ; Wed, 19 Dec 2018 19:22:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2A2A927D29; Wed, 19 Dec 2018 19:22:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E320027CF3 for ; Wed, 19 Dec 2018 19:22:20 +0000 (UTC) Received: from localhost ([::1]:33744 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhQB-0004pl-1k for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:22:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45350) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhLT-00015p-54 for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:17:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhLO-0008UY-1Z for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:17:26 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:43362) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhLN-0008Rd-Kq; Wed, 19 Dec 2018 14:17:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247042; x=1576783042; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=CFuOndEpWy2HA5zn6miKBxcw0xiIsdojXeAtS0gQ6Ag=; b=gDrWDHayoVU4jP0RVlvt5mQE5lpCyi+bANrdaGbenbB9ZehTchDP7qCX j9dXjk2pfGEjc2tOQZszzyxslv3vewthtdnrGDOSOI5c2V5O2/6Hp3oru ZKM8B2Nr4e6sNmZjacOoJcjOR2K3vIOb44LAQXk+MWrVut3GLBOfjygmP rbMho3sareqeoRFXi0+IbLF4yQrBW216PQzXLMAFSznulHAhLySAgjtAn 3uWy5xpzH2CyMO2gsvLJmElD5J9BSLwkwQWjIbOFoED2y9AdprihD+/FA lrhZbljKZlMRhwzD5wOq0z8roJMGA5Y6jrRxdawx1TdidSfxFc6yme9Fn A==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="98234170" Received: from mail-dm3nam03lp2053.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([104.47.41.53]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:17:09 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=YLhlavPLtq0JgKuzjEe8JrYFDN8pVIqAYJ6Itwva4/g=; b=QYlteOoALjax5MMTm4M5Y7q4QPXntc2FvefU82gd3Zu1sqLDyJxN7YYy+ogNIzY9npxxYrMc791PzRFq69mUJe0s62NxSgru9MRVdp5xBYLXhtdxL4Y64Dxj2zgQ2cWiVWZdU3G57FN9s1RGt92na5a6kqKCDgSArWffCHyL78E= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0271.namprd04.prod.outlook.com (10.169.202.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.20; Wed, 19 Dec 2018 19:17:07 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:17:07 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 05/23] riscv: Add the tcg-target header file Thread-Index: AQHUl89vBoL6ECAx5kaxHHUXmSQkDA== Date: Wed, 19 Dec 2018 19:17:07 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR04CA0003.namprd04.prod.outlook.com (2603:10b6:a03:40::16) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.250] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0271; 6:YIOt1TJ1rR0jGfTrFQ8gJ/aPrj7Ixc+go8YWUWPOHrcnrD9Jnff9ozxKLAsa7enx3Ax8gI2Q40wLQxgay2MZrfhxT73Kj3v+AtagVRBCQHzryD46G5xlOkl0LB8mhL2IFDgbMwYB/2+y8H+1p+KI08Zfxw+xsV0bLtP9Ur2o/fSiA5ZmLcCgxQDfXiTVKHyPw7CjkDhR1or7OMVlBU7Zh27gpxWHvUF44Fxg6rAi0ONh0FK9rOtkyjXk2NMKYeegS+zYXh5gf+ipVCo4uYPH+mc0b4p+xb7+234nR8bbLGKIkUC7FsmI/n62d9WTS+2zAlGZ5uyqnivRBTWI9zh+eOxsESX8S5+IpOI1iktNvEbigS9bpsFzUMrYtB1HUkefnUCt3JqB5zU57tMcZRed96qHl5OimpXDBDTJijauD6TP1VcCrFztJ1f4X1CL/xOJXMX20sZhGNu7nvMe8lyCug==; 5:RJzI9Sby1CA+tjhvbVeNIFHHP2j7yauTTO7XUFx3qZYo6EDqvmolUTv0ppiiBwa1LrvkywESQZeWAZkgU91NjyGG/r7OhKkKUvbveS3BhEDN011kNpomy6WiNbjrmT9HAAZQVgP/MTr3g3MUqWhJi20sZfyKdaU7TXRzRSOT0ng=; 7:xMugWc6cg2bttdMdrpfoz98NnpceFGFJR6AdNOkm+ZRIvlV3CEORnMDBpxmzJkwDWI39a5eH3AuuEEqmDAmS+ZHh62p/snwiIGTEtnyv3a5bo2jx3nB54BO8wBt41TUO8d/3yNUVblnT86iGphOq7A== x-ms-office365-filtering-correlation-id: 8fcf5092-b6a0-4ddb-e6a9-08d665e68ebf x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0271; x-ms-traffictypediagnostic: MWHPR04MB0271: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(5005020)(6040522)(2401047)(8121501046)(93006095)(93001095)(3231475)(944501520)(52105112)(10201501046)(3002001)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0271; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0271; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(136003)(376002)(346002)(39860400002)(396003)(189003)(199004)(26005)(14444005)(186003)(36756003)(54906003)(3846002)(99286004)(110136005)(25786009)(6116002)(14454004)(97736004)(102836004)(256004)(71190400001)(7736002)(71200400001)(5660300001)(305945005)(6506007)(386003)(86362001)(105586002)(478600001)(52116002)(316002)(6512007)(8676002)(81166006)(81156014)(118296001)(66066001)(50226002)(53936002)(486006)(44832011)(39060400002)(2616005)(76176011)(446003)(72206003)(106356001)(8936002)(476003)(11346002)(6486002)(68736007)(2501003)(6436002)(4326008)(2906002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0271; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: zo8OMSHgkGWWf2cBZSG35Xo/Nf9kQmvq057HOi6JoXc5kOx9Z7wufbTjagGfSd3s/BSQYYV6guII8aScF7hEpdsVg9rpm+e4S0nn1B+fCzHgjqb4O5iSACDK175dd+fMhP/cWiw+ibcKa81ij4MsyPM/JvWiOusAsbUyPcdD2KoQKGC2saGlB7c1iNkxrvVcfnzb3pWXYPy4922t15fKZlOyANv07e4wkdWKELDd8UCRZa4KbyizouXxEe3koaJs7fQI461YJyyK6iXoANCRH1vQbqBJpPJQqSp/iTFc4koy6GIR4QnAieuK3MuBb226 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8fcf5092-b6a0-4ddb-e6a9-08d665e68ebf X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:17:07.8168 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0271 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.144 Subject: [Qemu-devel] [PATCH v2 05/23] riscv: Add the tcg-target header file X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Reviewed-by: Richard Henderson --- MAINTAINERS | 10 ++- tcg/riscv/tcg-target.h | 177 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 186 insertions(+), 1 deletion(-) create mode 100644 tcg/riscv/tcg-target.h diff --git a/MAINTAINERS b/MAINTAINERS index b923f4c1b3..107bca486b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -268,7 +268,6 @@ F: hw/riscv/ F: include/hw/riscv/ F: linux-user/host/riscv32/ F: linux-user/host/riscv64/ -F: disas/riscv.c S390 M: Richard Henderson @@ -2166,6 +2165,15 @@ S: Odd Fixes F: tcg/ppc/ F: disas/ppc.c +RISC-V +M: Michael Clark +M: Palmer Dabbelt +M: Alistair Francis +L: qemu-riscv@nongnu.org +S: Maintained +F: tcg/riscv/ +F: disas/riscv.c + S390 target M: Richard Henderson S: Maintained diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h new file mode 100644 index 0000000000..60918cacb4 --- /dev/null +++ b/tcg/riscv/tcg-target.h @@ -0,0 +1,177 @@ +/* + * Tiny Code Generator for QEMU + * + * Copyright (c) 2018 SiFive, Inc + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef RISCV_TCG_TARGET_H +#define RISCV_TCG_TARGET_H + +#if __riscv_xlen == 32 +# define TCG_TARGET_REG_BITS 32 +#elif __riscv_xlen == 64 +# define TCG_TARGET_REG_BITS 64 +#endif + +#define TCG_TARGET_INSN_UNIT_SIZE 4 +#define TCG_TARGET_TLB_DISPLACEMENT_BITS 20 +#define TCG_TARGET_NB_REGS 32 + +typedef enum { + TCG_REG_ZERO, + TCG_REG_RA, + TCG_REG_SP, + TCG_REG_GP, + TCG_REG_TP, + TCG_REG_T0, + TCG_REG_T1, + TCG_REG_T2, + TCG_REG_S0, + TCG_REG_S1, + TCG_REG_A0, + TCG_REG_A1, + TCG_REG_A2, + TCG_REG_A3, + TCG_REG_A4, + TCG_REG_A5, + TCG_REG_A6, + TCG_REG_A7, + TCG_REG_S2, + TCG_REG_S3, + TCG_REG_S4, + TCG_REG_S5, + TCG_REG_S6, + TCG_REG_S7, + TCG_REG_S8, + TCG_REG_S9, + TCG_REG_S10, + TCG_REG_S11, + TCG_REG_T3, + TCG_REG_T4, + TCG_REG_T5, + TCG_REG_T6, + + /* aliases */ + TCG_AREG0 = TCG_REG_S0, + TCG_GUEST_BASE_REG = TCG_REG_S1, + TCG_REG_TMP0 = TCG_REG_T6, + TCG_REG_TMP1 = TCG_REG_T5, + TCG_REG_TMP2 = TCG_REG_T4, +} TCGReg; + +/* used for function call generation */ +#define TCG_REG_CALL_STACK TCG_REG_SP +#define TCG_TARGET_STACK_ALIGN 16 +#define TCG_TARGET_CALL_ALIGN_ARGS 1 +#define TCG_TARGET_CALL_STACK_OFFSET 0 + +/* optional instructions */ +#define TCG_TARGET_HAS_goto_ptr 1 +#define TCG_TARGET_HAS_movcond_i32 0 +#define TCG_TARGET_HAS_div_i32 1 +#define TCG_TARGET_HAS_rem_i32 1 +#define TCG_TARGET_HAS_div2_i32 0 +#define TCG_TARGET_HAS_rot_i32 0 +#define TCG_TARGET_HAS_deposit_i32 0 +#define TCG_TARGET_HAS_extract_i32 0 +#define TCG_TARGET_HAS_sextract_i32 0 +#define TCG_TARGET_HAS_add2_i32 1 +#define TCG_TARGET_HAS_sub2_i32 1 +#define TCG_TARGET_HAS_mulu2_i32 0 +#define TCG_TARGET_HAS_muls2_i32 0 +#define TCG_TARGET_HAS_muluh_i32 (TCG_TARGET_REG_BITS == 32) +#define TCG_TARGET_HAS_mulsh_i32 (TCG_TARGET_REG_BITS == 32) +#define TCG_TARGET_HAS_ext8s_i32 1 +#define TCG_TARGET_HAS_ext16s_i32 1 +#define TCG_TARGET_HAS_ext8u_i32 1 +#define TCG_TARGET_HAS_ext16u_i32 1 +#define TCG_TARGET_HAS_bswap16_i32 0 +#define TCG_TARGET_HAS_bswap32_i32 0 +#define TCG_TARGET_HAS_not_i32 1 +#define TCG_TARGET_HAS_neg_i32 1 +#define TCG_TARGET_HAS_andc_i32 0 +#define TCG_TARGET_HAS_orc_i32 0 +#define TCG_TARGET_HAS_eqv_i32 0 +#define TCG_TARGET_HAS_nand_i32 0 +#define TCG_TARGET_HAS_nor_i32 0 +#define TCG_TARGET_HAS_clz_i32 0 +#define TCG_TARGET_HAS_ctz_i32 0 +#define TCG_TARGET_HAS_ctpop_i32 0 +#define TCG_TARGET_HAS_direct_jump 0 +#define TCG_TARGET_HAS_brcond2 1 +#define TCG_TARGET_HAS_setcond2 1 + +#if TCG_TARGET_REG_BITS == 64 +#define TCG_TARGET_HAS_movcond_i64 0 +#define TCG_TARGET_HAS_div_i64 1 +#define TCG_TARGET_HAS_rem_i64 1 +#define TCG_TARGET_HAS_div2_i64 0 +#define TCG_TARGET_HAS_rot_i64 0 +#define TCG_TARGET_HAS_deposit_i64 0 +#define TCG_TARGET_HAS_extract_i64 0 +#define TCG_TARGET_HAS_sextract_i64 0 +#define TCG_TARGET_HAS_extrl_i64_i32 1 +#define TCG_TARGET_HAS_extrh_i64_i32 1 +#define TCG_TARGET_HAS_ext8s_i64 1 +#define TCG_TARGET_HAS_ext16s_i64 1 +#define TCG_TARGET_HAS_ext32s_i64 1 +#define TCG_TARGET_HAS_ext8u_i64 1 +#define TCG_TARGET_HAS_ext16u_i64 1 +#define TCG_TARGET_HAS_ext32u_i64 1 +#define TCG_TARGET_HAS_bswap16_i64 0 +#define TCG_TARGET_HAS_bswap32_i64 0 +#define TCG_TARGET_HAS_bswap64_i64 0 +#define TCG_TARGET_HAS_not_i64 1 +#define TCG_TARGET_HAS_neg_i64 1 +#define TCG_TARGET_HAS_andc_i64 0 +#define TCG_TARGET_HAS_orc_i64 0 +#define TCG_TARGET_HAS_eqv_i64 0 +#define TCG_TARGET_HAS_nand_i64 0 +#define TCG_TARGET_HAS_nor_i64 0 +#define TCG_TARGET_HAS_clz_i64 0 +#define TCG_TARGET_HAS_ctz_i64 0 +#define TCG_TARGET_HAS_ctpop_i64 0 +#define TCG_TARGET_HAS_add2_i64 1 +#define TCG_TARGET_HAS_sub2_i64 1 +#define TCG_TARGET_HAS_mulu2_i64 0 +#define TCG_TARGET_HAS_muls2_i64 0 +#define TCG_TARGET_HAS_muluh_i64 1 +#define TCG_TARGET_HAS_mulsh_i64 1 +#endif + +static inline void flush_icache_range(uintptr_t start, uintptr_t stop) +{ + __builtin___clear_cache((char *)start, (char *)stop); +} + +/* not defined -- call should be eliminated at compile time */ +void tb_target_set_jmp_target(uintptr_t, uintptr_t, uintptr_t); + +#define TCG_TARGET_DEFAULT_MO (0) + +#ifdef CONFIG_SOFTMMU +#define TCG_TARGET_NEED_LDST_LABELS +#endif +#define TCG_TARGET_NEED_POOL_LABELS + +#define TCG_TARGET_HAS_MEMORY_BSWAP 0 + +#endif From patchwork Wed Dec 19 19:17:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10737989 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DAADC6C2 for ; Wed, 19 Dec 2018 19:18:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB2F027853 for ; Wed, 19 Dec 2018 19:18:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BAEB227528; Wed, 19 Dec 2018 19:18:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 09A0027528 for ; Wed, 19 Dec 2018 19:18:57 +0000 (UTC) Received: from localhost ([::1]:33724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhMu-0002DL-SS for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:18:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45353) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhLT-000161-HL for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:17:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhLP-0008Vg-5v for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:17:27 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:29197) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhLO-0008Uv-T2; Wed, 19 Dec 2018 14:17:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247044; x=1576783044; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=Ih4s0j5UAUWM2vvyAEuaXwzWIhBR/JhRlby3oIb/bRg=; b=rCqqlLoQzclv6Py8IU2Q94ex+32QAvxaqaF2L4rxVNR7LHbLDKsyOiGV 7BQj4YR4vyPmRaqnl5aDPGPtkaf5DxhOKbNJF1SLX8PLhV2+b3nrpGegE mGvaov3KIcWi21CCuBnU3tmmdzsC5xjmqeDt4aS0wUvtDTHAsX2K5RVKM poqFGTWwUYpHDmEc7o5R8V3d6JYqiREcTm2Lj9SMLlCbdL1tVJpoXbC/H TzoGT7mxlHQbcM6cUt9LroZp/RTsJvpBCOYN8PisQWyr0TbXNiXnVKfuU 2rHvffqsZwQ74GSHYQrswCtnq/JZ331s0IvhT8551pm+z8ma1jOaq5ew0 w==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="97004147" Received: from mail-dm3nam03lp2057.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([104.47.41.57]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:17:22 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PMkJjGCCwTgm+EjotCUxyhOgpuzIVBUaKRzpR54mzHE=; b=eZt2Z44hsczSumarWM38CrdZnN0+tPOHdJPaDrWYW72D9ljb1iMelUGltoQcX1pYELw4TKVRJIZMMI0zbFR3EcrdaRmldt8p6VL53x4yblUmz63ZoWDw3EBk/NFsfD0isnPwV+19KLqbJiUdRc/d8gBjyZYm2w7/gWWXiKr5WX0= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0271.namprd04.prod.outlook.com (10.169.202.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.20; Wed, 19 Dec 2018 19:17:20 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:17:20 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 06/23] riscv: Add the tcg target registers Thread-Index: AQHUl8924BFC0qdLQ0CyGknjJavDBw== Date: Wed, 19 Dec 2018 19:17:20 +0000 Message-ID: <6e43abaa64361d57b9bc9439820d0e7701f2d47e.1545246859.git.alistair.francis@wdc.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR04CA0011.namprd04.prod.outlook.com (2603:10b6:a03:40::24) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.250] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0271; 6:XVbdcsW6o8n9+otXIEnlothCQeMHtv8+P2M4L9NouIwfkLdeyIw1Rvpq617FBJ/Pl7LsZSzH5hQa4jHL5h9Mnpd8/1H7YWC9xx79qANNdatVgoelA6u7ULS6BBQly6vLUrQeJTL1Whgu5wGan0n4wIt7SykhbI2671+5GiNmQjjqEpjIsF9my5Hwo7M/ck+tyVgEihBop7sQKwCcMxZ6IYZ+8IOTjBJJTa2nCOorrsEpuoLR4AlpWtLWNfdF0t61hVkGkCdYGYd5TCCEKOXtS57kXzWEXqP/KxzKgcM7HoM+HBzVJte1RNsa2yYNYL75qinFtX89IkjSAQx1es6xqOTHLuU4CiuEQZMFKxSqfGt1imEcVwOSeWLOloLw3a7/P/3UYT1o50nWk00yNNpUBBpEjP6Wy4jshkHnoCiX55JLC8rZEJopSjagGFEBjgpEddUK6IB9L5i/MUIflPPA9Q==; 5:oF/qTsX6siOMhMGQ0czzh0rQYy1VpLHXUaNLVVEd/AHb+bsqoXxJ0lS8IObh2tXC2/mQETQfmW7roeh02SjXMHIUoKleW0k6JUckMD63J3/oARnJRG5X7/XFkkJy4IDq0DsuMgrwvR6WMfGWnjiPwru4G4Hn5nvwTISwLM3X3II=; 7:QI9Z76KV4kUAPu3mMAyNuxXROKGDY3eVNss3/b7l3CNXoh2ugoTJgPms8j8Klb6JI1rnJaFtDwpWYkW13xPssWa4RDuMAKcZ9WEq9If1obclsT4FyWcFgZTBMy5dBmdrD3ZKGcrlyPtmaNoWS/eIdA== x-ms-office365-filtering-correlation-id: d4349544-e9fc-4b1c-8728-08d665e698ae x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0271; x-ms-traffictypediagnostic: MWHPR04MB0271: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(5005020)(6040522)(2401047)(8121501046)(93006095)(93001095)(3231475)(944501520)(52105112)(10201501046)(3002001)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0271; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0271; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(136003)(376002)(346002)(39860400002)(396003)(189003)(199004)(26005)(14444005)(186003)(36756003)(54906003)(3846002)(99286004)(110136005)(25786009)(6116002)(14454004)(97736004)(102836004)(256004)(71190400001)(7736002)(71200400001)(5660300001)(305945005)(6506007)(386003)(86362001)(105586002)(478600001)(52116002)(316002)(6512007)(8676002)(81166006)(81156014)(118296001)(66066001)(50226002)(53936002)(486006)(44832011)(39060400002)(2616005)(76176011)(446003)(72206003)(106356001)(8936002)(476003)(11346002)(6486002)(68736007)(2501003)(6436002)(4326008)(2906002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0271; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: 7luMnHSZynlUeA2ff1n8tYz8oNNwIX2EgmojKk5Bl36YBfcr5KrOWtWY80hR+90W7IWFOWbPrFX7CP24G6IyxJ212U+NIoTKaIXsIhvOJzSl/GEDf9db+OGyVMEBxwzxyeTNXXdlhNvs4c/OuPgy6zKQXOfZ2ZizysUPxGLDg9muXufsOdH6CCYqaqciUH6OYNL5J3PNIafT2rGrAuMRp8DrtkzJUBBi5hHz4TFSHJCayuO17pjVMq2AeWsA+z2j3VFDOzp5YOHP1IhUwRugNyasJ0MelggkMYz3IMmjm69RQmJui3PI3oICHyjoMMUd spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: d4349544-e9fc-4b1c-8728-08d665e698ae X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:17:20.0874 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0271 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.154.42 Subject: [Qemu-devel] [PATCH v2 06/23] riscv: Add the tcg target registers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Reviewed-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 118 +++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 tcg/riscv/tcg-target.inc.c diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c new file mode 100644 index 0000000000..6c969e3973 --- /dev/null +++ b/tcg/riscv/tcg-target.inc.c @@ -0,0 +1,118 @@ +/* + * Tiny Code Generator for QEMU + * + * Copyright (c) 2018 SiFive, Inc + * Copyright (c) 2008-2009 Arnaud Patard + * Copyright (c) 2009 Aurelien Jarno + * Copyright (c) 2008 Fabrice Bellard + * + * Based on i386/tcg-target.c and mips/tcg-target.c + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "tcg-pool.inc.c" + +#ifdef CONFIG_DEBUG_TCG +static const char * const tcg_target_reg_names[TCG_TARGET_NB_REGS] = { + "zero", + "ra", + "sp", + "gp", + "tp", + "t0", + "t1", + "t2", + "s0", + "s1", + "a0", + "a1", + "a2", + "a3", + "a4", + "a5", + "a6", + "a7", + "s2", + "s3", + "s4", + "s5", + "s6", + "s7", + "s8", + "s9", + "s10", + "s11", + "t3", + "t4", + "t5", + "t6" +}; +#endif + +static const int tcg_target_reg_alloc_order[] = { + /* Call saved registers */ + /* TCG_REG_S0 reservered for TCG_AREG0 */ + TCG_REG_S1, + TCG_REG_S2, + TCG_REG_S3, + TCG_REG_S4, + TCG_REG_S5, + TCG_REG_S6, + TCG_REG_S7, + TCG_REG_S8, + TCG_REG_S9, + TCG_REG_S10, + TCG_REG_S11, + + /* Call clobbered registers */ + TCG_REG_T0, + TCG_REG_T1, + TCG_REG_T2, + TCG_REG_T3, + TCG_REG_T4, + TCG_REG_T5, + TCG_REG_T6, + + /* Argument registers */ + TCG_REG_A0, + TCG_REG_A1, + TCG_REG_A2, + TCG_REG_A3, + TCG_REG_A4, + TCG_REG_A5, + TCG_REG_A6, + TCG_REG_A7, +}; + +static const int tcg_target_call_iarg_regs[] = { + TCG_REG_A0, + TCG_REG_A1, + TCG_REG_A2, + TCG_REG_A3, + TCG_REG_A4, + TCG_REG_A5, + TCG_REG_A6, + TCG_REG_A7, +}; + +static const int tcg_target_call_oarg_regs[] = { + TCG_REG_A0, + TCG_REG_A1, +}; From patchwork Wed Dec 19 19:17:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738037 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B3ACD6C2 for ; Wed, 19 Dec 2018 19:25:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A423627D29 for ; Wed, 19 Dec 2018 19:25:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9833F27E5A; Wed, 19 Dec 2018 19:25:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E307327D29 for ; Wed, 19 Dec 2018 19:25:49 +0000 (UTC) Received: from localhost ([::1]:33768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhTY-0007nI-Vl for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:25:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45462) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhLj-0001GV-2G for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:17:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhLe-0000Db-2X for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:17:42 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:43386) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhLd-0000CF-OA; Wed, 19 Dec 2018 14:17:37 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247058; x=1576783058; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=eCU3eAPoHbz3xgMfFvlIgMT/7dtwd/EYG10IG5xnEVw=; b=PPltWqh8kqjV3H+XZB3bXzn6ThwX8zMx55KfsfAfwlFfa75rpJ0OWokJ Cqe0KQ4qqyadcDkhS3XrQ+0tMqMeKj4/3N7UNl0vmAqwJ9u/O8ZTgbwEc 51SRouNMvflm5csqdrpLjIPyreqnPc2n9saVNrruWf2R6Y24SU3SV0KZm ZizujD3iywRpWcdP5GO5OlmRyu8utToqMxHaxU/GDh47dfnpbkZh/sGTb OQCYlEDtva1+gaKl9csG1F+tmjjNBjtclJrdoK6TalZ0+wWcqISIk73RH bSLL2wf/yL5xCpYgjzR+JlOHYevHQ5V4R66/YEuNwkfS0Sn1ecdymnvtR g==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="98234189" Received: from mail-dm3nam03lp2058.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([104.47.41.58]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:17:33 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3AbETKu2PI+17kUHagSQCijIltf24uV2q63c5kIj6ak=; b=dCMBg+RXkKKf0eStUj1FVJ537h/QWCniGMEcFs+kQM2qQAjG/94CUA7viSxi3yCoZ8d3ZSEIG00gI1eDDOTWrvMyEk7FxiKX2LaMAzs6uev5UQu4xVstbE6hCAdbtsjngHTaCRfYdtM4V06L5iPkxykQastKHWlfojn1bTPwPsg= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0271.namprd04.prod.outlook.com (10.169.202.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.20; Wed, 19 Dec 2018 19:17:32 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:17:32 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 07/23] riscv: tcg-target: Add support for the constraints Thread-Index: AQHUl899MTcXSK0z6EOz3F+jIxdL2w== Date: Wed, 19 Dec 2018 19:17:32 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR05CA0065.namprd05.prod.outlook.com (2603:10b6:a03:74::42) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.250] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0271; 6:T7v+HxsjqKnqvMIfL6kraI8oevRsomrm3DA2NpTiW5yLIffwbcMhPpYODyScC1vlE5sCWWVM8STNPhSm/oS/9tXgoD+E1iAP90BjZ17IaDrxOigFCw461OUlbiaiVCLHdRLRr31SaM0wPiIr1DqFcLTGSwyDW3Y5lj7xIeTfVZEZM6MicHmHSJ+zEnhRk1/rPqgi9lDag85ml42tazm1hTCk7YPO4V4Nv/RPZJ9t2aHrQ27MQpd6OMQ01J7Hm3G2C7mmw/UhCqtvpu6kvXd0YoJngzzJ/uhRepMNWvqotrYiFWZPVd8zmrzAT9bRZYGQxvYdyPc+2K+24bTr9/QkIFasE1owuUhePe9JrTRNFNIWj9EnJHl1yBZurbpdQKizYBcBBSR9HFkVhBLgqAu6xFjzyityfqeaBsrrxjgezFpfAo5102ljCyRfkW0i3sV54QwfV7RImW4SBP/HqJptgg==; 5:+pkwiE/hRgtIVJkIlckdXKVJ6r4r9qkwga34AaGrFQJjVZVQnNpJ/UX74zh8MruC1m5syZIPWFLR91Fnb6nLObK4wCUQcXtm1Bj69J8BSULf4H4lxORRl/jNDhC/EjWp4OmDQ7fFNEGby//DwWw8Pnz+9AoV190w1oAu3nUZf/s=; 7:OZdJ5cnMXrWC0VWROHfvHPWyvL4RiucqvQTzCamlqGZ1sdC7emdHoFpPMjYDVGSwIf19j948pwNt9Q8XSmzRy7V+a5AiKSueug7Kw5XNtcYMguySZJdNHdhVMz3WcDPL+n/UFGqOvh+l9lOZbD16PA== x-ms-office365-filtering-correlation-id: 228a8822-1435-40d4-c20e-08d665e69fd9 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0271; x-ms-traffictypediagnostic: MWHPR04MB0271: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(5005020)(6040522)(2401047)(8121501046)(93006095)(93001095)(3231475)(944501520)(52105112)(10201501046)(3002001)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0271; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0271; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(136003)(376002)(346002)(39860400002)(396003)(189003)(199004)(26005)(186003)(36756003)(54906003)(3846002)(99286004)(110136005)(25786009)(6116002)(14454004)(97736004)(102836004)(256004)(71190400001)(7736002)(71200400001)(5660300001)(305945005)(6506007)(386003)(86362001)(105586002)(478600001)(52116002)(316002)(6512007)(8676002)(81166006)(81156014)(118296001)(66066001)(50226002)(53936002)(486006)(44832011)(39060400002)(2616005)(76176011)(446003)(72206003)(106356001)(8936002)(476003)(11346002)(6486002)(68736007)(2501003)(6436002)(4326008)(2906002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0271; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: Rm1ZIsnD2Kl7Up/5OJJvYvZx6BwVklM7w9wlzyoNkK1VezNYjyojNdxwrQ1r9cipxtwfkvrOISIaxC7d7u4AJI0bYFqMucotxBYtwrOUPU5oCHv2RKKPBhdI3MG6eT8V+sEsuukK0jcPO8xAPZ9lKrwnqfy6+lK7oSMbrPArXd14iehVQGcBw8wqm+2WZbfXyD4PG5tjRcaTys1bsOINzxgKB0ZvFPB1H1iYw1u86Ws13v1VpGmj5g3IcNLAeHITj+r+0jiXUqpFAxN4ldagENd+3QWjrXdsDGly9C9XH0iIni7wQVh2MWsBvmXAI4Uc spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 228a8822-1435-40d4-c20e-08d665e69fd9 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:17:32.0677 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0271 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.144 Subject: [Qemu-devel] [PATCH v2 07/23] riscv: tcg-target: Add support for the constraints X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Signed-off-by: Richard Henderson Reviewed-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 168 +++++++++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index 6c969e3973..f853d01803 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -116,3 +116,171 @@ static const int tcg_target_call_oarg_regs[] = { TCG_REG_A0, TCG_REG_A1, }; + +#define TCG_CT_CONST_ZERO 0x100 +#define TCG_CT_CONST_S12 0x200 +#define TCG_CT_CONST_N12 0x400 +#define TCG_CT_CONST_M12 0x800 + +static inline tcg_target_long sextreg(tcg_target_long val, int pos, int len) +{ + if (TCG_TARGET_REG_BITS == 32) { + return sextract32(val, pos, len); + } else { + return sextract64(val, pos, len); + } +} + +/* parse target specific constraints */ +static const char *target_parse_constraint(TCGArgConstraint *ct, + const char *ct_str, TCGType type) +{ + switch (*ct_str++) { + case 'r': + ct->ct |= TCG_CT_REG; + ct->u.regs = 0xffffffff; + break; + case 'L': + /* qemu_ld/qemu_st constraint */ + ct->ct |= TCG_CT_REG; + ct->u.regs = 0xffffffff; + /* qemu_ld/qemu_st uses TCG_REG_TMP0 */ +#if defined(CONFIG_SOFTMMU) + tcg_regset_reset_reg(ct->u.regs, tcg_target_call_iarg_regs[0]); + tcg_regset_reset_reg(ct->u.regs, tcg_target_call_iarg_regs[1]); + tcg_regset_reset_reg(ct->u.regs, tcg_target_call_iarg_regs[2]); + tcg_regset_reset_reg(ct->u.regs, tcg_target_call_iarg_regs[3]); + tcg_regset_reset_reg(ct->u.regs, tcg_target_call_iarg_regs[4]); +#endif + break; + case 'I': + ct->ct |= TCG_CT_CONST_S12; + break; + case 'N': + ct->ct |= TCG_CT_CONST_N12; + break; + case 'M': + ct->ct |= TCG_CT_CONST_M12; + break; + case 'Z': + /* we can use a zero immediate as a zero register argument. */ + ct->ct |= TCG_CT_CONST_ZERO; + break; + default: + return NULL; + } + return ct_str; +} + +/* test if a constant matches the constraint */ +static int tcg_target_const_match(tcg_target_long val, TCGType type, + const TCGArgConstraint *arg_ct) +{ + int ct = arg_ct->ct; + if (ct & TCG_CT_CONST) { + return 1; + } + if ((ct & TCG_CT_CONST_ZERO) && val == 0) { + return 1; + } + if ((ct & TCG_CT_CONST_S12) && val == sextreg(val, 0, 12)) { + return 1; + } + if ((ct & TCG_CT_CONST_N12) && -val == sextreg(-val, 0, 12)) { + return 1; + } + if ((ct & TCG_CT_CONST_M12) && val >= -0xfff && val <= 0xfff) { + return 1; + } + return 0; +} + +/* + * RISC-V Base ISA opcodes (IM) + */ + +typedef enum { + OPC_ADD = 0x33, + OPC_ADDI = 0x13, + OPC_AND = 0x7033, + OPC_ANDI = 0x7013, + OPC_AUIPC = 0x17, + OPC_BEQ = 0x63, + OPC_BGE = 0x5063, + OPC_BGEU = 0x7063, + OPC_BLT = 0x4063, + OPC_BLTU = 0x6063, + OPC_BNE = 0x1063, + OPC_DIV = 0x2004033, + OPC_DIVU = 0x2005033, + OPC_JAL = 0x6f, + OPC_JALR = 0x67, + OPC_LB = 0x3, + OPC_LBU = 0x4003, + OPC_LD = 0x3003, + OPC_LH = 0x1003, + OPC_LHU = 0x5003, + OPC_LUI = 0x37, + OPC_LW = 0x2003, + OPC_LWU = 0x6003, + OPC_MUL = 0x2000033, + OPC_MULH = 0x2001033, + OPC_MULHSU = 0x2002033, + OPC_MULHU = 0x2003033, + OPC_OR = 0x6033, + OPC_ORI = 0x6013, + OPC_REM = 0x2006033, + OPC_REMU = 0x2007033, + OPC_SB = 0x23, + OPC_SD = 0x3023, + OPC_SH = 0x1023, + OPC_SLL = 0x1033, + OPC_SLLI = 0x1013, + OPC_SLT = 0x2033, + OPC_SLTI = 0x2013, + OPC_SLTIU = 0x3013, + OPC_SLTU = 0x3033, + OPC_SRA = 0x40005033, + OPC_SRAI = 0x40005013, + OPC_SRL = 0x5033, + OPC_SRLI = 0x5013, + OPC_SUB = 0x40000033, + OPC_SW = 0x2023, + OPC_XOR = 0x4033, + OPC_XORI = 0x4013, + +#if TCG_TARGET_REG_BITS == 64 + OPC_ADDIW = 0x1b, + OPC_ADDW = 0x3b, + OPC_DIVUW = 0x200503b, + OPC_DIVW = 0x200403b, + OPC_MULW = 0x200003b, + OPC_REMUW = 0x200703b, + OPC_REMW = 0x200603b, + OPC_SLLIW = 0x101b, + OPC_SLLW = 0x103b, + OPC_SRAIW = 0x4000501b, + OPC_SRAW = 0x4000503b, + OPC_SRLIW = 0x501b, + OPC_SRLW = 0x503b, + OPC_SUBW = 0x4000003b, +#else + /* Simplify code throughout by defining aliases for RV32. */ + OPC_ADDIW = OPC_ADDI, + OPC_ADDW = OPC_ADD, + OPC_DIVUW = OPC_DIVU, + OPC_DIVW = OPC_DIV, + OPC_MULW = OPC_MUL, + OPC_REMUW = OPC_REMU, + OPC_REMW = OPC_REM, + OPC_SLLIW = OPC_SLLI, + OPC_SLLW = OPC_SLL, + OPC_SRAIW = OPC_SRAI, + OPC_SRAW = OPC_SRA, + OPC_SRLIW = OPC_SRLI, + OPC_SRLW = OPC_SRL, + OPC_SUBW = OPC_SUB, +#endif + + OPC_FENCE = 0x0000000f, +} RISCVInsn; From patchwork Wed Dec 19 19:17:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738051 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9D84814DE for ; Wed, 19 Dec 2018 19:29:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E56027F9F for ; Wed, 19 Dec 2018 19:29:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 82B2D27FA3; Wed, 19 Dec 2018 19:29:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 04EB427F9F for ; Wed, 19 Dec 2018 19:29:32 +0000 (UTC) Received: from localhost ([::1]:33789 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhX9-0002k3-7p for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:29:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhLq-0001Ky-PM for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:17:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhLm-0000HU-Rs for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:17:50 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:43402) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhLm-0000Gq-IC; Wed, 19 Dec 2018 14:17:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247067; x=1576783067; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=MTgOhhUMsT7aZraYP6giKW6HdnX3J1wQteJiYuppo6I=; b=rBl1vv+2ZDt5qN1Nj25ykcsMivgAZMAlE0MbRge+ugn35BmbPtFN7I4M zCRQqHTgqDH/8R3U4pnkmisJDuJVH9eS0Egv6EwnM5czV6TFNWuvVOceQ DL1Bm2egRlh55POJuRram2YgJlWv5vLUVgevCu4Mn6VNfr7BIjUD03SaF TynXhBeQjSdj3yv4Q7HQXh5Tfy8pvyB3bdvcJGzc91hXS4h/cQpxkdtH7 mvSjRPPsH97gokZutT1UzKsEjmLmTz1W1hwBG0+B3WNi+Rnn0smQoa1cQ fhb7FFT/Wwhs1BSO+e8AhDI3xwhTOVB+jdLtCj8dkKNeDwlVeKsHmAe+A w==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="98234202" Received: from mail-dm3nam03lp2056.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([104.47.41.56]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:17:45 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=QDpXuK5hgy3y2w3yrwwpoZTyy72ju0uVWl+Nz7aBGYE=; b=dQRjnFR4iQGHLxcInntptvdGu5Piv+McoS1RFmc/1fla2djYsUN4Y6E1iTK5p8c/gHKucoQhK9fUA5gSPZv/utZ2SMSj3agSASg3vh9gTtoZYjcfowQGjnedbN3+NKZc1piIblJ3Q0wnltJFj2XpA8x/MWJnUdjESpXeZ5sGpPE= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0271.namprd04.prod.outlook.com (10.169.202.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.20; Wed, 19 Dec 2018 19:17:43 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:17:43 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 08/23] riscv: tcg-target: Add the immediate encoders Thread-Index: AQHUl8+EBljUZ+BLu0OVMUCz1MlsmQ== Date: Wed, 19 Dec 2018 19:17:43 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR05CA0049.namprd05.prod.outlook.com (2603:10b6:a03:74::26) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.250] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0271; 6:7xZNZGznaw2+0mT4Rd+XbwZbVGB0YvA7ylZUKeKetsBV4y3/JniGVqeni00EFCGqfBbSuTfzJSHJO3qqhvZx0l7IetvTKio1SEZ66pAZ9ad6JeBz9rHg3UqVKMrQ3bpctENKy2qkZy9oY/yDdHVcRhQgtjlDs2Zol6ndoCLICITir+g6Yknu+VwNLRLbG5+1dVulVTr9UBTlwVA5jrQeol38Z0nn7hh2pIkHazmQ1+Cmby6boVuYnibndlvuvIAPZhB6vvLSA1h4idbHilpyNZDYES7z3R0d9JOOQAivaBa9n0ELqaAyAmc4l7lBDzneqvgNQc4y0ssmnMxeP9ywZyO/FJ/4V32t8F89P5UxntvXt1JkvLWKdx70+WzCZmLYG0F71/MokJ1nMj8IFOBlJJT86D32TwiGHb9yLVQEXvUdXCzZbNaPbPrg6cExqJUouajpVZUgXqfBGSiHjD3lTg==; 5:1FJG1uvS29XeAIKhD/DS0ffxpvxJ70FWceiFg0570gwXKhz6mtISdgXRyUUf4sr6rj+IDZqhP5A/Ki0aVYNO5kS/XJhOcVFGSyRAJOJlaadl8k3Ps/TiVuWisZoqZdlYfT0pKlDa1v0njgroRgRP/BdrEz0hw2n4iGfLbiSldAY=; 7:WY55dkba4gJCqDyzIv5GlQGVL04gCTwE8nfHdDDb/QD3nrCkZjNXoMokbXObjfVM3VRkhMSFA88pRu/LjRgit/5jWUKJY4xJS0eMPXw9v0+8O6y+XRxezUrknmqRGS8gVGGwB4gNUR8MzTbv3UOK0g== x-ms-office365-filtering-correlation-id: 3107c2eb-8758-406a-6d78-08d665e6a6c9 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0271; x-ms-traffictypediagnostic: MWHPR04MB0271: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(5005020)(6040522)(2401047)(8121501046)(93006095)(93001095)(3231475)(944501520)(52105112)(10201501046)(3002001)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123562045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0271; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0271; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(136003)(376002)(346002)(39860400002)(396003)(189003)(199004)(26005)(186003)(36756003)(54906003)(3846002)(99286004)(110136005)(25786009)(6116002)(14454004)(97736004)(102836004)(256004)(71190400001)(7736002)(71200400001)(5660300001)(305945005)(6506007)(386003)(86362001)(575784001)(105586002)(478600001)(52116002)(316002)(6512007)(8676002)(81166006)(81156014)(118296001)(66066001)(50226002)(53936002)(486006)(44832011)(39060400002)(2616005)(76176011)(446003)(72206003)(106356001)(8936002)(476003)(11346002)(6486002)(68736007)(2501003)(6436002)(4326008)(2906002)(14773001); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0271; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: S3fyvPdriZMa6m3esF5Pdyd1UF1TCT4Qbh4gCEJpqO0CH0a9IKl9DKaw0nM/95b46EnPlc0RaZpGPlPQrNi8wqxTONNiw09t6tzHC+22BMtSIiAijCVG5y+8r3eN8dFH0pjrAFUITkqVInORY3nt00QmP29gE5cjlz0nTwt5pKx+xVybclBpuUeI5eTVFzmzZQWehBlW8ukeB+kMv+x3qPKJ8d+k2ADfACjbflrK65vqK7/lejUcxzBQVrCKpMpG5Wfo1enB7GqPTFuvSU61qLXi1AW6ATBraY9McfJuf5zMqfSQPIJyXaNdp89sIn9h spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3107c2eb-8758-406a-6d78-08d665e6a6c9 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:17:43.7268 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0271 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.144 Subject: [Qemu-devel] [PATCH v2 08/23] riscv: tcg-target: Add the immediate encoders X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Signed-off-by: Richard Henderson Reviewed-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 90 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index f853d01803..08838027cd 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -284,3 +284,93 @@ typedef enum { OPC_FENCE = 0x0000000f, } RISCVInsn; + +/* + * RISC-V immediate and instruction encoders (excludes 16-bit RVC) + */ + +/* Type-R */ + +static int32_t encode_r(RISCVInsn opc, TCGReg rd, TCGReg rs1, TCGReg rs2) +{ + return opc | (rd & 0x1f) << 7 | (rs1 & 0x1f) << 15 | (rs2 & 0x1f) << 20; +} + +/* Type-I */ + +static int32_t encode_imm12(uint32_t imm) +{ + return (imm & 0xfff) << 20; +} + +static int32_t encode_i(RISCVInsn opc, TCGReg rd, TCGReg rs1, uint32_t imm) +{ + return opc | (rd & 0x1f) << 7 | (rs1 & 0x1f) << 15 | encode_imm12(imm); +} + +/* Type-S */ + +static int32_t encode_simm12(uint32_t imm) +{ + int32_t ret = 0; + + ret |= (imm & 0xFE0) << 20; + ret |= (imm & 0x1F) << 7; + + return ret; +} + +static int32_t encode_s(RISCVInsn opc, TCGReg rs1, TCGReg rs2, uint32_t imm) +{ + return opc | (rs1 & 0x1f) << 15 | (rs2 & 0x1f) << 20 | encode_simm12(imm); +} + +/* Type-SB */ + +static int32_t encode_sbimm12(uint32_t imm) +{ + int32_t ret = 0; + + ret |= (imm & 0x1000) << 19; + ret |= (imm & 0x7e0) << 20; + ret |= (imm & 0x1e) << 7; + ret |= (imm & 0x800) >> 4; + + return ret; +} + +static int32_t encode_sb(RISCVInsn opc, TCGReg rs1, TCGReg rs2, uint32_t imm) +{ + return opc | (rs1 & 0x1f) << 15 | (rs2 & 0x1f) << 20 | encode_sbimm12(imm); +} + +/* Type-U */ + +static int32_t encode_uimm20(uint32_t imm) +{ + return imm & 0xfffff000; +} + +static int32_t encode_u(RISCVInsn opc, TCGReg rd, uint32_t imm) +{ + return opc | (rd & 0x1f) << 7 | encode_uimm20(imm); +} + +/* Type-UJ */ + +static int32_t encode_ujimm20(uint32_t imm) +{ + int32_t ret = 0; + + ret |= (imm & 0x0007fe) << (21 - 1); + ret |= (imm & 0x000800) << (20 - 11); + ret |= (imm & 0x0ff000) << (12 - 12); + ret |= (imm & 0x100000) << (31 - 20); + + return ret; +} + +static int32_t encode_uj(RISCVInsn opc, TCGReg rd, uint32_t imm) +{ + return opc | (rd & 0x1f) << 7 | encode_ujimm20(imm); +} From patchwork Wed Dec 19 19:17:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738043 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E9E5B14DE for ; Wed, 19 Dec 2018 19:28:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF8B61FFBD for ; Wed, 19 Dec 2018 19:28:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C155127D0C; Wed, 19 Dec 2018 19:28:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 66F9C1FFBD for ; Wed, 19 Dec 2018 19:28:37 +0000 (UTC) Received: from localhost ([::1]:33786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhWG-00020F-7L for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:28:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhM2-0001XD-PU for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:18:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhLy-0000Ux-NO for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:18:02 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:43419) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhLy-0000Tn-D3; Wed, 19 Dec 2018 14:17:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247078; x=1576783078; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=ZOKOtV8+IzFZSdFtM8kg49hAziLkFSBQIROEtvwFlcM=; b=oT9lPGgyhxhOc4rc26s9Vcmc4HWQ+dSpVfNEW6zM0+HIQzB9wk2gcpoK 5EEqfTYb4ZL8LWUDp7UaZct6mhX2bjWw1xzSvizpuv82QffmPbReaW7lo XFoHKjIzWVOYJMcisXFfGdwS5IgGiYYAe0QlBkrVazwoM7zLR0MNueRdN cTBRztBUJBaCINoUZ0vesxBQY15WHfPAWl0AsvoQ1djkcL694eZigWPEh sYlw8g/EerwXBpiF248HCodR/q7Q5iEUlz586AOtzqd2vXRufqPE7Zr7y eCY0MasPqF/1aoiNsg+/EbwPpjtTzwX5tW1UxcN8XehGfVObcU8V93brt g==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="98234213" Received: from mail-sn1nam04lp2054.outbound.protection.outlook.com (HELO NAM04-SN1-obe.outbound.protection.outlook.com) ([104.47.44.54]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:17:57 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1YCpEkH3DVOoDa4Jvxqsa1PHfQ48fTq9DBKoU8N6nTQ=; b=iLeLtgd31WE8gG3z0VR7emObHOM5xeMuGlowdWX8ansCw80LCb7bFn9aBKkk1Hg82TTuxZYpJQ5l5hjXyy1LWiU4dgQ1bOg3Nfyks82RhK48Gu6DBCRT2dYQMhcTrfCwHpuhfPL8Bw85RmcAVqgrFcpFcOVWKoNx8HBNpQDqz+A= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0718.namprd04.prod.outlook.com (10.172.167.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.22; Wed, 19 Dec 2018 19:17:55 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:17:55 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 09/23] riscv: tcg-target: Add the instruction emitters Thread-Index: AQHUl8+LugcXJHZsUUiqZk02Bc02Cg== Date: Wed, 19 Dec 2018 19:17:55 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR05CA0045.namprd05.prod.outlook.com (2603:10b6:a03:74::22) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.250] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0718; 6:aZ8wKQHm7QU2WdlBM3UL50wV1CyiY3K24297CgJQf2abSRRZzQRXV36ccHusXBuVeDeyFH/EJXQTCOWIHxTq2kMf8lvJJZ/vRai4iw++nMtpvnthWW1a+LPA/IrttrBRwhZZl6lslvGl7KeVZbM+6MdybdGmY+FGAv2q2UxBvT7OO2RmVJaBp0XB8y3XCArHLCW5J53Fb6AtA4D4YVHCqBMC/HvBJF/jMDgQUlEHO3Ub58bwUrdFCI15O7r825GBNJEZXdt/8tQvnHRYanHGkSwBum+ipU24SSyjmTXz+9zdr1rjKB+VuZAh42RG3s4tRmUBWl59Erp19lZamS7d1aAeAB5uJMpNVtNkQu39qvUiXyLrgRQRd2pqoR6UuJpKWOGmO+lAWzBDqcGxtY2Kih5clh3DbBCpxAWRSQZlqoua+sfphUd8+3wLCQzwFaU/T5Mf7aD8CvEUOoWS+wkEdw==; 5:D7Iq87mdkjbv7vFIttDUPZsnjDkdIOxm81cXsUIJSj6Q5lHpg5fwFS1OzDIDcLP4/qVMF7hs0sIEqZD5QM8q2YqeYTpOaZdWJsdPdtTE8PKYzjBqoEqweaypEldsTPPYRFPzmIBGN1srdoGBeME4sBybP/XAhBUjPQDeBDk7NjU=; 7:w1IJBse7ArNVotZJLm7hhPYEARsEr+RGxxPHOkCGXHPFLY4iPDCD7QnDTsde22PjN86bx1YbYzTKhMmTTCQ9kH+cX4nwU8pNJgnVbFkfHyBp89kxsRJHz+RgvXeDyCuQtxhMvpLJpV+wXtcSdd2RSg== x-ms-office365-filtering-correlation-id: 214eaf44-0ffc-4a72-692d-08d665e6ada3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0718; x-ms-traffictypediagnostic: MWHPR04MB0718: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(6040522)(2401047)(8121501046)(5005006)(3231475)(944501520)(52105112)(93006095)(93001095)(10201501046)(3002001)(6055026)(149066)(150057)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0718; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0718; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(346002)(366004)(39860400002)(396003)(136003)(189003)(199004)(256004)(2906002)(11346002)(7736002)(105586002)(106356001)(478600001)(26005)(39060400002)(305945005)(446003)(99286004)(2616005)(316002)(110136005)(81166006)(8936002)(486006)(3846002)(6116002)(5660300001)(4326008)(81156014)(97736004)(186003)(54906003)(14454004)(476003)(25786009)(44832011)(50226002)(52116002)(8676002)(66066001)(6512007)(386003)(76176011)(6506007)(6486002)(53936002)(68736007)(118296001)(2501003)(86362001)(72206003)(102836004)(36756003)(6436002)(71190400001)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0718; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: bfWOdBQhEJtLhyCgDEikiTfWJ8NQooyXBHdvOnMxQ8DQ3Rmz9t9/4nBj8L3QBMKWcBujyPCwANM7pTHhmTuFqf9tY0NJTdNxp9fQh6MBCK7vSrMVLs1KQn/vPnhn7eyxnkO+crm7lKU3/Gh0bpEKuh4i9oe8PwgsQf49zi09idQnZttx/LT0Ub6HDmZvKFdbQA+oeN8hyxeVGQ5cBofub9tvrB1gp2C5prj+fnAXYXU7X6E43e+ghg5nFwhSxBHuwKO0lOL9snD2Xq3hCr5O0AUSCETsZGfHq8SYQGNqigXjYM50ZQUPvFqrtpkWsSqu spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 214eaf44-0ffc-4a72-692d-08d665e6ada3 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:17:55.1536 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0718 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.144 Subject: [Qemu-devel] [PATCH v2 09/23] riscv: tcg-target: Add the instruction emitters X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Reviewed-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index 08838027cd..d198cfd5f7 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -374,3 +374,51 @@ static int32_t encode_uj(RISCVInsn opc, TCGReg rd, uint32_t imm) { return opc | (rd & 0x1f) << 7 | encode_ujimm20(imm); } + +/* + * RISC-V instruction emitters + */ + +static void tcg_out_opc_reg(TCGContext *s, RISCVInsn opc, + TCGReg rd, TCGReg rs1, TCGReg rs2) +{ + tcg_out32(s, encode_r(opc, rd, rs1, rs2)); +} + +static void tcg_out_opc_imm(TCGContext *s, RISCVInsn opc, + TCGReg rd, TCGReg rs1, TCGArg imm) +{ + tcg_out32(s, encode_i(opc, rd, rs1, imm)); +} + +static void tcg_out_opc_store(TCGContext *s, RISCVInsn opc, + TCGReg rs1, TCGReg rs2, uint32_t imm) +{ + tcg_out32(s, encode_s(opc, rs1, rs2, imm)); +} + +static void tcg_out_opc_branch(TCGContext *s, RISCVInsn opc, + TCGReg rs1, TCGReg rs2, uint32_t imm) +{ + tcg_out32(s, encode_sb(opc, rs1, rs2, imm)); +} + +static void tcg_out_opc_upper(TCGContext *s, RISCVInsn opc, + TCGReg rd, uint32_t imm) +{ + tcg_out32(s, encode_u(opc, rd, imm)); +} + +static void tcg_out_opc_jump(TCGContext *s, RISCVInsn opc, + TCGReg rd, uint32_t imm) +{ + tcg_out32(s, encode_uj(opc, rd, imm)); +} + +static void tcg_out_nop_fill(tcg_insn_unit *p, int count) +{ + int i; + for (i = 0; i < count; ++i) { + p[i] = encode_i(OPC_ADDI, TCG_REG_ZERO, TCG_REG_ZERO, 0); + } +} From patchwork Wed Dec 19 19:18:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738069 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1DC3F6C5 for ; Wed, 19 Dec 2018 19:31:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0EF532841E for ; Wed, 19 Dec 2018 19:31:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D1FD283A8; Wed, 19 Dec 2018 19:31:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5BABA2842B for ; Wed, 19 Dec 2018 19:31:26 +0000 (UTC) Received: from localhost ([::1]:33791 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhYz-0003BT-Gj for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:31:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45680) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhMY-0001ts-Jh for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:18:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhMS-0000mF-K1 for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:18:34 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:23342) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhMO-0000i9-IY; Wed, 19 Dec 2018 14:18:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247104; x=1576783104; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=7Tj8Pt3ZF5oK4E488kmlAjVWmbuD4GkhbLGcjXlvt6k=; b=nGvuEjrau99vip6IV9IDxpM/z0lRShdqe6ArxhkiD50Ul5blAVUIXIsM v0F7vQ8hpbPp+tb4VSL67m66yZamqTgmGbABWWpZYlnNeh/oQlazbYJGx +5Qs/YShi6Z5bkpqTpiQEqLuq3DD871xi8L/0eHWhgJ+d7vuqB/uZELoB S3DCrAET9lvfKST32e48qFw0qej4lMEYB7Hg/XSoHY4AcngHtuMp7+xwY Y77G9hOG2T6N9eVbJDnmhcK8QBMcnO3OnOXibLsrIIL3KKQUyp/T4tG8Y Nzo3KiJaULUiA6FOMaYLm8Lemc3VW36OvigjeKtdC2LCfDQhIQZg6DJNP g==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="201718412" Received: from mail-sn1nam04lp2055.outbound.protection.outlook.com (HELO NAM04-SN1-obe.outbound.protection.outlook.com) ([104.47.44.55]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:18:07 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Vq2wSdPckp+brXmxestLcMZ5rJimNTVcdfgfkyNolgc=; b=UsUWJs6Eg3gIVhXB4EVTh9pgP4htc2zu+moh7wcbWgqa8CynRlmPJQqVMEXkU3ICztP489ytvV6BA27OGSvOPyKDyXY8Oabe9RbKLEzVHJZZZPCcb3AcaJS42Qiv6ys3WuwkHQJX8NMmIr+hhwbOCZ0Bf8A7qZMP11LqzcVy9TM= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0718.namprd04.prod.outlook.com (10.172.167.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.22; Wed, 19 Dec 2018 19:18:06 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:18:06 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 10/23] riscv: tcg-target: Add the relocation functions Thread-Index: AQHUl8+SixBcxaJmw06d/BdZGnY2tw== Date: Wed, 19 Dec 2018 19:18:06 +0000 Message-ID: <6ac4f4b0d5ea93cb0ee9a3b8b47ee9f7b3711494.1545246859.git.alistair.francis@wdc.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR05CA0061.namprd05.prod.outlook.com (2603:10b6:a03:74::38) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.250] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0718; 6:Yqsd1kn7J/LdGJRvtj78IZuQ8EkHGr+t+uvsnz6iRgARPCOb7fme2FvX4u46sYxmdj6fV3rN0EhlY7jKaQozTlsldJf1Sn7QIGXfnN06pRsfUZibmnzg4rAvhXim/caD4868zgH1uOa9NFCv0xLJrKzVI/ZjSIjJaBOnY0lUuzE0xMLjLdPEXuF0AKg+j/O5kz+Ia0UIRwhv8DiCQsJgQmZJaFK6rKEgp4Ii91YKVBsmPL7p9GAQn7AZ6K8w5NKf2JNeEZ2OQhkFSW+pfVEJARQkR4RXl5t1vgFpNoAWsR8oicm/9X7OVG4Dys+cPdV0A8pK+0r0chuLq0Cqvx+ge5ISmw6dzMzFgGU2cAowEhijeovNlGGVRdK0/8HjsRaKtPi6LaNDktRWx7en2rDLieLoHRsK33kjG4XZANPIjnWhuwzWCtG5hKVFmZbhCMGlJlq/sZ7Fd/OBaF+9OK8MNQ==; 5:sU9rrnWlVd4IKkFr3R+2utZClSVY679dk2KL7p2LB5yuLda/rnjTP4aEXdrr2fa37BkZG+tqCDkja2zBZ3BaoP07ROkbwN690l3DBvyxDEKFdkWX8ajUrCRPS9BgSgnGBdiMCxptf+biQgHnsGGUb/Bi49uOwZouzJCqfeAG1Jk=; 7:4/nepNEYx85ge7NjISHIEFbU8RvPm1reDc//+TtCmrptcueSKiunbZhUqvI/Fgr1rLt/rPn60uy3oreLXHEn5v+WGZvdy+6LeB3zBpD3QnER3x+zCGYsulXTSBoJiCxtmmi9HeKquIy4jP8ffjZ1Hw== x-ms-office365-filtering-correlation-id: 5aff036d-6eae-4336-3a21-08d665e6b455 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0718; x-ms-traffictypediagnostic: MWHPR04MB0718: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(6040522)(2401047)(8121501046)(5005006)(3231475)(944501520)(52105112)(93006095)(93001095)(10201501046)(3002001)(6055026)(149066)(150057)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0718; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0718; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(346002)(366004)(39860400002)(396003)(136003)(189003)(199004)(256004)(2906002)(11346002)(7736002)(105586002)(106356001)(478600001)(26005)(39060400002)(305945005)(446003)(99286004)(2616005)(316002)(110136005)(81166006)(8936002)(486006)(3846002)(6116002)(5660300001)(4326008)(81156014)(97736004)(186003)(54906003)(14454004)(476003)(25786009)(44832011)(50226002)(52116002)(8676002)(66066001)(6512007)(386003)(76176011)(6506007)(6486002)(53936002)(68736007)(118296001)(2501003)(86362001)(72206003)(102836004)(36756003)(6436002)(71190400001)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0718; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: 715eP1yj85diGFpL7gkJN97QFdQCb4I5DS7/0/6Mm7Ue10kt+059OcR1jM7cL0GMBb4EpBcUEwNfddcU6uQrZDFtfXi7aVIUwT1zRe66Wmafe65RDxGUFHQMuMWClVPBgbrrfk+XIHn18EGFky7S+JkpqXttlYGGRthRi0dMJXB68tHaUmpCwfAs6AhVy6YTO1zgMyigUIKVB5LAyOPiGgMtYTLNw+pVH9hPSwjEfv62ng+ffgKHFJ4i/vBERjd6Tvw47mAsFsAWASTENjtNqaI8uPR5rLwBjy0MCmCkfpd3WAmA0U1zfB5e9QVlZP1o spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5aff036d-6eae-4336-3a21-08d665e6b455 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:18:06.4363 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0718 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 68.232.141.245 Subject: [Qemu-devel] [PATCH v2 10/23] riscv: tcg-target: Add the relocation functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 88 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index d198cfd5f7..a26744052f 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -422,3 +422,91 @@ static void tcg_out_nop_fill(tcg_insn_unit *p, int count) p[i] = encode_i(OPC_ADDI, TCG_REG_ZERO, TCG_REG_ZERO, 0); } } + +/* + * Relocations + */ + +static bool reloc_sbimm12(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +{ + intptr_t offset = (intptr_t)target - (intptr_t)code_ptr; + + if (offset == sextreg(offset, 1, 12) << 1) { + code_ptr[0] |= encode_sbimm12(offset); + return true; + } + + return false; +} + +static bool reloc_jimm20(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +{ + intptr_t offset = (intptr_t)target - (intptr_t)code_ptr; + + if (offset == sextreg(offset, 1, 20) << 1) { + code_ptr[0] |= encode_ujimm20(offset); + return true; + } + + return false; +} + +static bool reloc_call(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +{ + intptr_t offset = (intptr_t)target - (intptr_t)code_ptr; + int32_t lo = sextreg(offset, 0, 12); + int32_t hi = offset - lo; + + if (offset == hi + lo) { + code_ptr[0] |= encode_uimm20(hi); + code_ptr[1] |= encode_imm12(lo); + return true; + } + + return false; +} + +static bool patch_reloc(tcg_insn_unit *code_ptr, int type, + intptr_t value, intptr_t addend) +{ + uint32_t insn = *code_ptr; + intptr_t diff; + bool short_jmp; + + tcg_debug_assert(addend == 0); + + switch (type) { + case R_RISCV_BRANCH: + diff = value - (uintptr_t)code_ptr; + short_jmp = diff == sextreg(diff, 0, 12); + if (short_jmp) { + return reloc_sbimm12(code_ptr, (tcg_insn_unit *)value); + } else { + /* Invert the condition */ + insn = insn ^ (1 << 12); + /* Clear the offset */ + insn &= 0x01fff07f; + /* Set the offset to the PC + 8 */ + insn |= encode_sbimm12(8); + + /* Move forward */ + code_ptr[0] = insn; + + /* Overwrite the NOP with jal x0,value */ + diff = value - (uintptr_t)(code_ptr + 1); + insn = encode_uj(OPC_JAL, TCG_REG_ZERO, diff); + code_ptr[1] = insn; + + return true; + } + break; + case R_RISCV_JAL: + return reloc_jimm20(code_ptr, (tcg_insn_unit *)value); + break; + case R_RISCV_CALL: + return reloc_call(code_ptr, (tcg_insn_unit *)value); + break; + default: + tcg_abort(); + } +} From patchwork Wed Dec 19 19:18:17 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738073 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BC23F6C5 for ; Wed, 19 Dec 2018 19:33:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9CC41FE84 for ; Wed, 19 Dec 2018 19:33:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9E17228068; Wed, 19 Dec 2018 19:33:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 19CC61FE84 for ; Wed, 19 Dec 2018 19:33:39 +0000 (UTC) Received: from localhost ([::1]:33823 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhb8-00069b-V6 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:33:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45706) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhMc-0001xE-Tf for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:18:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhMW-0000od-Ly for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:18:38 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:20534) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhMS-0000jI-Up; Wed, 19 Dec 2018 14:18:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247131; x=1576783131; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=3K1t5ycFKANZv8qXhlf1+cRC7lfmjANhZRnlk8JSQgk=; b=dZ/CvS0YD82T4RR6BU0dfIoXVWzf2x9MSufWOUR0GCH2I/VklJOdjfAd NVU4jqAZEanuwhBMDxQUCfDFPVx7nsu4XD1wKmz2r/jBgAexFHz0s5Wif kFFRYm2zZKSpuqGrim4RtoSE3N28v/oCA7dI/2Hyv1dKav8h6BenbyDFF 6rhgXnXX6DPjyLjuLdCHRaC4Qix2jlAQeIXrmxNZF5QwO96vQ1SL8fak5 obf9XDlmjgyy/XlWKZlVjXDdT/5GA4YCFyI7LS2kGzNg2T5482AWMRWhb G1lL23BSBQF7eiN0hRguUI1KWO0Ic5poycfMAOrsqe2FlBP6drgmKbp13 Q==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="194939618" Received: from mail-bl2nam02lp2051.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) ([104.47.38.51]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:18:36 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=81b5rd3nAMjuF+2/kfEvbbwaYyygcyOJWfMpuK5aMe8=; b=Hu9UHPryheoIyC93xpA95UIgcqYydlyo2h5tuxQcnCIlJ0u9S6u23rWmNz5ZDiPJQyg1GmcKSpnN7lzA2fRCgn/nNtOkHf1SfhIDbMng1kL6y/yZvDViKHCgDwwJ71nJa6RGRrRtXiu29/4tY4Q2K4RJ3J8NDlierFAJc2vWh+Y= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0848.namprd04.prod.outlook.com (10.172.168.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1446.19; Wed, 19 Dec 2018 19:18:17 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:18:17 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 11/23] riscv: tcg-target: Add the mov and movi instruction Thread-Index: AQHUl8+Y3mU3RVUjCUabGuNHNB7+YQ== Date: Wed, 19 Dec 2018 19:18:17 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR05CA0070.namprd05.prod.outlook.com (2603:10b6:a03:74::47) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.250] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0848; 6:RBL/ycqOfIWKLVFUWtwUyznTzqg6bRRR+gTiTa5aKTthK/YwAmed8EcMcnQcjuGlN6t7gTixeb23KJ0r6ZW6YfKzAPIolHfbi7cd3Gg+vhdd7lnHL1jiSbjCmsMUmtY7RIqOi4yHTdqRS10IIiIC2PL+oEMX6JDCcG0hSzkLB7DeogUAAy26cw0ie7E3YX7oGK5gqbxS+G5WXRmxmnQ00oG0OcbHkPv+2xz316SBrH/iFaCJAd8DkOz15UWsd4c6fUEEyQSiKl9pKtbXHpj+kofWND0vdw08jCV/cSZc1a3eXDQu1wlRY7ghgiC/nnJWw6u0BwJg7gQccHlRxbE7MEQn/ouJZUj7mcFEW4g0OFOcbtpulB3LQcBDzWnutdLLCu56Skq7LHD0st0PQoOBs29h3EoVfhEcS7L+5jS/8Tmf9f1fE3mdn3E0VwMKeepvt3yw7oEIU7QtpDtW8xmCxQ==; 5:vRYzj7j3CSYHek53vcPTng2+GDGKl4Bmc8BcLOwhw8su8mxJVUfg9gDea9g3Y+FK0/f7GAiaTRMKCv2sN0F0CKH6CLTyIQ5gH0RLjOLHRWeqkhRbB0CTpeBBX7FyLN2Ik4sucyOoeOR9fKIbRLQTayB8t0z6ZZw30Yc2QaQdY7s=; 7:NAToUJETiMPNfkWEHjietjqG0rgJBi0VhGLg/R9ig74exUQRRVoc8Te/+POIvwZU51qCMm23z8T6EUZYyKc9cKr9JyLODS/7DCYXIkb3Wp7+QmOEZ2HZKUApHlbtWd0PhvWIQvrc6bVLCvyXUdjweg== x-ms-office365-filtering-correlation-id: e8b7a079-3fa3-4622-cbc7-08d665e6bae8 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0848; x-ms-traffictypediagnostic: MWHPR04MB0848: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231475)(944501520)(52105112)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0848; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0848; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(39860400002)(396003)(346002)(366004)(376002)(199004)(189003)(6486002)(14454004)(4326008)(72206003)(8936002)(86362001)(2501003)(50226002)(71190400001)(71200400001)(97736004)(6436002)(8676002)(81156014)(81166006)(36756003)(68736007)(25786009)(5660300001)(478600001)(118296001)(105586002)(53936002)(256004)(305945005)(7736002)(6512007)(316002)(44832011)(39060400002)(66066001)(54906003)(110136005)(2906002)(52116002)(6116002)(76176011)(26005)(186003)(102836004)(99286004)(486006)(446003)(476003)(6506007)(11346002)(2616005)(3846002)(106356001)(386003); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0848; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: Rf0tZnZm7RLzwPyPRZwxvfzgJazNvSEibMT2I7+cK+nE/cMGo/TQgtCE8SuNcH4iHfo3dKAQ2AgpxQ5jCaKBvr/grCZneyk9D7r0D/6K7fv5slBG/EqEDGTFpY5bqcfZIKCl4b94BmrY44aKJawpeM8gorBcIT3vV/6Sgf2o+tmwsv8vs4CmKM2la1yi59OxMBg/7+mJcS4nhZ2YuWveebfw8nPlb/xgrXNToteqJYQOdVT8Pn2ul51CTdFORMeSpCFSi76OmWoIwW5xOnksxOtnxiPN4NITMP0gn2rznF0cDvO53NMDFBD5WcBcl6vi spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8b7a079-3fa3-4622-cbc7-08d665e6bae8 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:18:17.4377 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0848 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 68.232.143.124 Subject: [Qemu-devel] [PATCH v2 11/23] riscv: tcg-target: Add the mov and movi instruction X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 86 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index a26744052f..01b4443d6d 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -510,3 +510,89 @@ static bool patch_reloc(tcg_insn_unit *code_ptr, int type, tcg_abort(); } } + +/* + * TCG intrinsics + */ + +static void tcg_out_mov(TCGContext *s, TCGType type, TCGReg ret, TCGReg arg) +{ + if (ret == arg) { + return; + } + switch (type) { + case TCG_TYPE_I32: + case TCG_TYPE_I64: + tcg_out_opc_imm(s, OPC_ADDI, ret, arg, 0); + break; + default: + g_assert_not_reached(); + } +} + +static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, + tcg_target_long val) +{ + tcg_target_long lo, hi, tmp; + int shift, ret; + + if (TCG_TARGET_REG_BITS == 64 && type == TCG_TYPE_I32) { + val = (int32_t)val; + } + + lo = sextreg(val, 0, 12); + if (val == lo) { + tcg_out_opc_imm(s, OPC_ADDI, rd, TCG_REG_ZERO, lo); + return; + } + + hi = val - lo; + if (TCG_TARGET_REG_BITS == 32 || val == (int32_t)val) { + tcg_out_opc_upper(s, OPC_LUI, rd, hi); + if (lo != 0) { + tcg_out_opc_imm(s, OPC_ADDIW, rd, rd, lo); + } + return; + } + + /* We can only be here if TCG_TARGET_REG_BITS != 32 */ + tmp = tcg_pcrel_diff(s, (void *)val); + if (tmp == (int32_t)tmp) { + tcg_out_opc_upper(s, OPC_AUIPC, rd, 0); + tcg_out_opc_imm(s, OPC_ADDI, rd, rd, 0); + ret = reloc_call(s->code_ptr - 2, (tcg_insn_unit *)val); + tcg_debug_assert(ret == true); + return; + } + + /* Look for a single 20-bit section. */ + shift = ctz64(val); + tmp = val >> shift; + if (tmp == sextreg(tmp, 0, 20)) { + tcg_out_opc_upper(s, OPC_LUI, rd, tmp << 12); + if (shift > 12) { + tcg_out_opc_imm(s, OPC_SLLI, rd, rd, shift - 12); + } else { + tcg_out_opc_imm(s, OPC_SRAI, rd, rd, 12 - shift); + } + return; + } + + /* Look for a few high zero bits, with lots of bits set in the middle. */ + shift = clz64(val); + tmp = val << shift; + if (tmp == sextreg(tmp, 12, 20) << 12) { + tcg_out_opc_upper(s, OPC_LUI, rd, tmp); + tcg_out_opc_imm(s, OPC_SRLI, rd, rd, shift); + return; + } else if (tmp == sextreg(tmp, 0, 12)) { + tcg_out_opc_imm(s, OPC_ADDI, rd, TCG_REG_ZERO, tmp); + tcg_out_opc_imm(s, OPC_SRLI, rd, rd, shift); + return; + } + + /* Drop into the constant pool. */ + new_pool_label(s, val, R_RISCV_CALL, s->code_ptr, 0); + tcg_out_opc_upper(s, OPC_AUIPC, rd, 0); + tcg_out_opc_imm(s, OPC_LD, rd, rd, 0); +} From patchwork Wed Dec 19 19:18:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738017 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 928621850 for ; Wed, 19 Dec 2018 19:20:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 83DE821FAC for ; Wed, 19 Dec 2018 19:20:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 77FEE27C2D; Wed, 19 Dec 2018 19:20:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E904221FAC for ; Wed, 19 Dec 2018 19:20:25 +0000 (UTC) Received: from localhost ([::1]:33730 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhOL-0003NY-4Y for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:20:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45738) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhMf-0001yN-BV for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:18:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhMa-0000rA-If for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:18:41 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:23342) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhMY-0000i9-Kq; Wed, 19 Dec 2018 14:18:36 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247114; x=1576783114; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=QRzcbsBz27aGcH/KEjWa1JYC1G2ut/E5sPpXSy4s7wI=; b=Ic3ch4W6YPGaim2vssS8gld5EyikYB+dXSYbSbPrhiId4osawterVFeX FHS/qslu/6Dv9MZxE87/QWCFesX6mOdOvhP3tGltlKYL7/YY1TOdWx3d0 aaWn3+Wopr/4cBVvqqSw1kzEE+dQVR30Ot5bQypKDKwUPANdxSTex/ZYG g2FvjC4xrdFLIHpruGoPcZUTLGzBGCltnyY3vkSCKuGV59NIzqeVgpRWk BM/rV0zQPP8CShtjsg4tXVpoYTNkpf9nH02Uvn0CiK9yxHPJofXiM+6gK YdMHPFW+TDyntsvshyBrXs/fZhEu6p70Yk8BaFRQPIk4fVZb50dPC7DBi g==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="201718430" Received: from mail-bl2nam02lp2057.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) ([104.47.38.57]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:18:30 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wOVcx98vivmKsxuWZBiffJh7ETHu5gPlYgybjhx/PtU=; b=NfHMHyN3QxO0s2GJ9EqLyyJQMpUl/8Qqp4iQ4l9jJ9C2HZNdSWzG+Dxj9aQMhvwxvshZqJc8rYAGjuxRVemQXLMh2+RqQn7xS+VxytgY96pHBirDE5LztNNT5LhkYDDV45ORrT9tqdW6VmeFymYqwSru9YsLFP0eYYN+0tJGNhc= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0848.namprd04.prod.outlook.com (10.172.168.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1446.19; Wed, 19 Dec 2018 19:18:29 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:18:29 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 12/23] riscv: tcg-target: Add the extract instructions Thread-Index: AQHUl8+fqIi9TfbITEaSC9NlFm15Kg== Date: Wed, 19 Dec 2018 19:18:28 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR07CA0023.namprd07.prod.outlook.com (2603:10b6:a02:bc::36) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.171] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0848; 6:f67kUQ2/Lw3Jg3tKfu8tZRHsIEnbp6lMUqErPDVUZ1xtVne7lrg6uIE53t63yUHY1qe9xSGSIBpJHpfGVpcPWpyyRPvzs/hGGUg/Xz2Nmqaz6bNLwOAXxBug3jpm1eBwc3aA3rlvqEWrC+5sXROouyim8snid7wl/AlNImwNjRiIenLSASPbE3pzyb/NVWUjVF5jMbUjyKvwM+Mj/LHBGWZPEosUsTPkvb5AUceGy+p88oqooa4f/r8kt3QtF+ki9Jvxx+WGMvJYPfOFXLF2mzXilahrZ+EF2K6b8s6JdqmEVbnt9YLeW4dodsYnVi8BnT1vhxu2CT1AlNEh5XsA+fUbkX91zBUqxyAf3TTlpDuTtWDn2TBrX4/mqx8YDU6SOpDHj+qEC9lNVahFM4UdFu7ROUsyjQBuiseP03vRi8qatCAYNYY0cJFRtIE4EBY5dz2ntpX9jyNZW3IL9xK9VQ==; 5:Fe8DqlckpIOdn6L9T+ImAlcc81TA89Gabyk8I3XVMTchi62QXhYsFMK6hDFxc71OllaWi/bD+B/elykj7NQp2IK+Gz1vauzRgN2LmIYnvu7YK6Q5jhBwRs3Bvkap3Z8xiFjZ9t1Cv2seVk9o3Jbfe3dwhQexS/6NVw3+JdPusWM=; 7:dblcwJP5hVQmyGYDJwY1jY6ssRhuySqyVRqJeq5sqNwqFCKLCq2M5lSAhuXNdDxEfbpdMbwH4ckBTq1uvNvMqWkMBls/6UdNH0gpXawV7emA51yqhCAp5hwnTzY0VoJ5ctyq0c3eybkJFk6ubW+GSA== x-ms-office365-filtering-correlation-id: ad97e6d6-a792-493e-cb0a-08d665e6c1c9 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0848; x-ms-traffictypediagnostic: MWHPR04MB0848: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231475)(944501520)(52105112)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0848; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0848; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(39860400002)(396003)(346002)(366004)(376002)(199004)(189003)(6486002)(14454004)(4326008)(72206003)(8936002)(86362001)(2501003)(50226002)(71190400001)(71200400001)(97736004)(6436002)(8676002)(81156014)(81166006)(36756003)(68736007)(25786009)(5660300001)(478600001)(118296001)(105586002)(53936002)(256004)(305945005)(7736002)(6512007)(316002)(44832011)(39060400002)(66066001)(54906003)(110136005)(2906002)(52116002)(6116002)(76176011)(26005)(186003)(102836004)(99286004)(486006)(446003)(476003)(6506007)(11346002)(2616005)(3846002)(106356001)(386003); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0848; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: gu1fnjzdzE4fKoaA1KmVfJEpAOqEoa431/HbI9LeA7FIWQQSF/Z2RrsjebNbQwZgKagXygQKGxi/rboSygnOn++W7RqjzqR/xqlbu3JTmgzVjfyE82fjZC9hV7p5sUjsRt4XAYxpD7nblSha5GL7UEPybZhkJx+3FeESCUd9W05i/zSJBqbIjiHdIUXUqKsH0N2dzNkgBkS0qETLMR8EhocJbbWJOMyAU9PNbThHTZx5rjBV8uY5NLle8rXV7DgsC/0Y0KX1fE7swk7RBNtG79qFqTdIEUtlCuvetELjv17H5jUWYQDPLMPY/7HdV5Rr spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: ad97e6d6-a792-493e-cb0a-08d665e6c1c9 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:18:28.9746 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0848 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 68.232.141.245 Subject: [Qemu-devel] [PATCH v2 12/23] riscv: tcg-target: Add the extract instructions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Signed-off-by: Richard Henderson Reviewed-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index 01b4443d6d..48399480b2 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -596,3 +596,37 @@ static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, tcg_out_opc_upper(s, OPC_AUIPC, rd, 0); tcg_out_opc_imm(s, OPC_LD, rd, rd, 0); } + +static void tcg_out_ext8u(TCGContext *s, TCGReg ret, TCGReg arg) +{ + tcg_out_opc_imm(s, OPC_ANDI, ret, arg, 0xff); +} + +static void tcg_out_ext16u(TCGContext *s, TCGReg ret, TCGReg arg) +{ + tcg_out_opc_imm(s, OPC_SLLIW, ret, arg, 16); + tcg_out_opc_imm(s, OPC_SRLIW, ret, ret, 16); +} + +static void tcg_out_ext32u(TCGContext *s, TCGReg ret, TCGReg arg) +{ + tcg_out_opc_imm(s, OPC_SLLI, ret, arg, 32); + tcg_out_opc_imm(s, OPC_SRLI, ret, ret, 32); +} + +static void tcg_out_ext8s(TCGContext *s, TCGReg ret, TCGReg arg) +{ + tcg_out_opc_imm(s, OPC_SLLIW, ret, arg, 24); + tcg_out_opc_imm(s, OPC_SRAIW, ret, ret, 24); +} + +static void tcg_out_ext16s(TCGContext *s, TCGReg ret, TCGReg arg) +{ + tcg_out_opc_imm(s, OPC_SLLIW, ret, arg, 16); + tcg_out_opc_imm(s, OPC_SRAIW, ret, ret, 16); +} + +static void tcg_out_ext32s(TCGContext *s, TCGReg ret, TCGReg arg) +{ + tcg_out_opc_imm(s, OPC_ADDIW, ret, arg, 0); +} From patchwork Wed Dec 19 19:18:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738025 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BFAD514DE for ; Wed, 19 Dec 2018 19:23:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF1A627D29 for ; Wed, 19 Dec 2018 19:23:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0DA227DA4; Wed, 19 Dec 2018 19:23:36 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 63A8E27D29 for ; Wed, 19 Dec 2018 19:23:35 +0000 (UTC) Received: from localhost ([::1]:33749 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhRO-0005u8-Kv for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:23:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45801) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhMl-00023A-Vx for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:18:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhMh-0000wH-VH for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:18:47 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:15907) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhMh-0000uC-K9; Wed, 19 Dec 2018 14:18:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247123; x=1576783123; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=ozKkth5Lpmhh6a1f0RVhVxytCTa1O+2hS5aoA94WNaI=; b=jbxtYcGPpkwWbKf95RxBs1hhLQ//RfKqWAP17TI8UCCdtvL6ODOgl8DP QUYpeU2SONgvmMSInQ1kkkw0zIiFhuC210xmq6Y1s3OSAjSjgRh0BXNSK VVqBtCkkQVHW7zCqPMBPtlgvhzdGbJ9EurLW9AVcjTRjNvdQvxPE/tiVJ Om+yTnAbccbC4DlcydM2JtRdXmYgzZjjeV3Wp0aiAf6KRSmdhu+nWBoLZ PzQn6s15vg/2QgeTFZY1Gkp4iGYdE7nq2lnxfffOpfIM6JuTGAUYYjVhd zsMtUNzfkUlj3AGufW6UwL1oRzi5AGQI8pwlTyRnPEV9bsxtdQR84Vfdm g==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="101923928" Received: from mail-bl2nam02lp2057.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) ([104.47.38.57]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:18:41 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g3EpWwM3+GWAtHAIijlDpPzqHOHH8rmQhOfX7m+NOis=; b=NzjKqoj3lI6dkRHYmkTxizq/4o6oalRwAVWOecCyZ8+IF4H5FGKf+LrgagSf9JyVZQEzVbjliaByPDqisSrys8llbq4oduq1cyt3fOureu2AJ7uJGV9hdcy8dorkE8Be9ZVOQAJLOHBPi9JxhdhpCj5isXI/jIAoUXw/UJNi1oM= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0848.namprd04.prod.outlook.com (10.172.168.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1446.19; Wed, 19 Dec 2018 19:18:39 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:18:39 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 13/23] riscv: tcg-target: Add the out load and store instructions Thread-Index: AQHUl8+lt7Rg9X6Dekaasa8BTHMqAw== Date: Wed, 19 Dec 2018 19:18:39 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR07CA0011.namprd07.prod.outlook.com (2603:10b6:a02:bc::24) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.171] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0848; 6:UlfsiIv+0mCYgOI5RFqghfMVeqjbTrHZGzn1h3ZAooh0WTokDNhszSbQdZ5GhjjsBijZnDCBipxluWCFctpdOgthjsuOMo+vJBIj6gG2zqS0rV47jU422lcfvMob9CUkfxzTdQX7rFmqcbg/aKVY5RFvC68ekSGLnv7dKh/a3RgOihNtPJGclKvjfmw9Xx7uvABnj2qy+wDhxh3V4IJTaAwY3wKdMaXymyB+yhj37kzjInReaUeB/iRWw1S8ufzTowsxq+6JaU7KFHA07ZOLHWe41GKVRgTZE8PVmTBIDKP4m9swxHci8NwICyxzLArBlke6ZdNoUu7eSXwU3FrsVYrhlHNE8xuZKYeVyuxoziHRxcs/pKR6kQAeloRUYEmQbGG6SS6qn6Tx8BpKuWNews/oms+BROT/7/3N5CInV+V6fLlaBKu6qQ1xTc3z7ARV/EZadXgY24Pd0rbR0xaCZg==; 5:tjLv5rpreUC6UakB7jic1I5msqo45m0cGbZOiwF6GX8ySQMhQ4DadI7saj3cz/r3NR8bW2ulQFHcThWG4B/ru9laJgbuUwe7XI92fnZfAWV/FTfqFAmSgGbGk3k+juuBLy3HhFap9+yGYuUN1j3FrI9qvpsM5DyVVjgFOt4pjRQ=; 7:dvYO/BBear+qIs7DqeppFQAuyzrMi3MvTdjH5pGYR3nIAzmMJ0gE/isGhgSMDd8Yi8EbBdoMcUkYyABqZzQCtKmuQPj0ZeoGC789iAXRhpbj4hARis9FseCgsyXn5dKEKwS35egozhEv955y02is1g== x-ms-office365-filtering-correlation-id: c6d20c31-a033-4078-bdc9-08d665e6c80a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0848; x-ms-traffictypediagnostic: MWHPR04MB0848: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231475)(944501520)(52105112)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0848; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0848; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(39860400002)(396003)(346002)(366004)(376002)(199004)(189003)(6486002)(14454004)(4326008)(72206003)(8936002)(86362001)(2501003)(50226002)(71190400001)(71200400001)(97736004)(6436002)(8676002)(81156014)(81166006)(36756003)(68736007)(25786009)(5660300001)(478600001)(118296001)(105586002)(53936002)(256004)(305945005)(7736002)(6512007)(316002)(44832011)(39060400002)(66066001)(54906003)(110136005)(2906002)(52116002)(6116002)(76176011)(26005)(186003)(102836004)(99286004)(486006)(446003)(476003)(6506007)(11346002)(2616005)(3846002)(106356001)(386003); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0848; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: Ei5uMt9Nmc2a1fAFRcOXLrSsykXYk8/xrEbS+licNOsnI7G7ouH8IGV0NHYw4CggyICpLlNjnJGdZC1eWHEEFwluyyp5Kzv9XQQdcEnoMSrRJ2N5md2963ZA1hMWoxqMz+02t0ycEoQN/3rq54JZ9tpTN1sKXa5ptjOmDZuBgKz1OgA398Ymxy8hSqHvC6Arphcss2H66BUnDqSGQ8HxQ804Yk1PwVZlPDIU62b9BLIu4ennLJGC6ijHT0+hDMM8YyeBSIMi44pKaLpBVDy0pfdxcm7d7qTG5GjWbeQzCUer+wRvvg9lbGUMsdqOlWfp spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: c6d20c31-a033-4078-bdc9-08d665e6c80a X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:18:39.4696 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0848 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.141 Subject: [Qemu-devel] [PATCH v2 13/23] riscv: tcg-target: Add the out load and store instructions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Signed-off-by: Richard Henderson Reviewed-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 65 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index 48399480b2..65718df7ad 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -630,3 +630,68 @@ static void tcg_out_ext32s(TCGContext *s, TCGReg ret, TCGReg arg) { tcg_out_opc_imm(s, OPC_ADDIW, ret, arg, 0); } + +static void tcg_out_ldst(TCGContext *s, RISCVInsn opc, TCGReg data, + TCGReg addr, intptr_t offset) +{ + intptr_t imm12 = sextreg(offset, 0, 12); + + if (offset != imm12) { + intptr_t diff = offset - (uintptr_t)s->code_ptr; + + if (addr == TCG_REG_ZERO && diff == (int32_t)diff) { + imm12 = sextreg(diff, 0, 12); + tcg_out_opc_upper(s, OPC_AUIPC, TCG_REG_TMP2, diff - imm12); + } else { + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_TMP2, offset - imm12); + if (addr != TCG_REG_ZERO) { + tcg_out_opc_reg(s, OPC_ADD, TCG_REG_TMP2, TCG_REG_TMP2, addr); + } + } + addr = TCG_REG_TMP2; + } + + switch (opc) { + case OPC_SB: + case OPC_SH: + case OPC_SW: + case OPC_SD: + tcg_out_opc_store(s, opc, addr, data, imm12); + break; + case OPC_LB: + case OPC_LBU: + case OPC_LH: + case OPC_LHU: + case OPC_LW: + case OPC_LWU: + case OPC_LD: + tcg_out_opc_imm(s, opc, data, addr, imm12); + break; + default: + g_assert_not_reached(); + } +} + +static void tcg_out_ld(TCGContext *s, TCGType type, TCGReg arg, + TCGReg arg1, intptr_t arg2) +{ + bool is32bit = (TCG_TARGET_REG_BITS == 32 || type == TCG_TYPE_I32); + tcg_out_ldst(s, is32bit ? OPC_LW : OPC_LD, arg, arg1, arg2); +} + +static void tcg_out_st(TCGContext *s, TCGType type, TCGReg arg, + TCGReg arg1, intptr_t arg2) +{ + bool is32bit = (TCG_TARGET_REG_BITS == 32 || type == TCG_TYPE_I32); + tcg_out_ldst(s, is32bit ? OPC_SW : OPC_SD, arg, arg1, arg2); +} + +static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, + TCGReg base, intptr_t ofs) +{ + if (val == 0) { + tcg_out_st(s, type, TCG_REG_ZERO, base, ofs); + return true; + } + return false; +} From patchwork Wed Dec 19 19:18:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738077 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CABDA1399 for ; Wed, 19 Dec 2018 19:36:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B9D16205A8 for ; Wed, 19 Dec 2018 19:36:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ACC37280B0; Wed, 19 Dec 2018 19:36:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2FD8C205A8 for ; Wed, 19 Dec 2018 19:36:39 +0000 (UTC) Received: from localhost ([::1]:33850 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhe2-0008I4-DI for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:36:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45860) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhMv-0002Ds-Dd for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:19:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhMr-00010I-9N for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:18:57 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:15922) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhMq-0000za-Vt; Wed, 19 Dec 2018 14:18:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247133; x=1576783133; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=s3z5m6AUZR7AsVwduBIK4Ymvnttj1C/wfw10k1m0pWY=; b=GM9dg19juW9xnenVq+uaD0essXR2YF3YuSqXgcXselSm2E4AESSdcdhd EsNSSE9TfahlfkRhywY6+uFcVrizeWLS9qqEPUxfdy1gIBl17YE4sUP87 XjximqmWnhddpdSkY1DJaonCNEl8pzwRTWjEVgLjosCeqKu9j6zh2YL8P vXNnBpOrJ5RmHbDLmrjsOKCDgjBaVkPty38CGTDw0Fhjx1EmSwbnmKfOP Me35azHmr2SPmYdyIgReA3BMVuxbD/KcQCqpmRAH+yMCOW4KFiY4LU1dR LH4mpwbu1YUwwJQWbZRQmlxWXxj0N7WzTqFNZt9um2SHn+/Gp2DWshWtF Q==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="101923937" Received: from mail-bl2nam02lp2052.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) ([104.47.38.52]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:18:51 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=NorqcLcrSzHCYtSJaYTguf6DoNP2ujHYKY7v+RrgHtw=; b=HlX0CWzYLrunXZwNLUS0lmppttYmUF+e9ObwAa5QORs8ILuFi21TCZV0YYdmcb2S17rDeufr0h0DvYW2uWDzbQ5pAZyoJp9D26hCGRKSv5Kn32Ux5QAyDSrAy9ovVl1YoGoa0vY3PNYhy6ZTuav7nQFQrvdS6BhtuU/Whl1ZdKU= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0848.namprd04.prod.outlook.com (10.172.168.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1446.19; Wed, 19 Dec 2018 19:18:49 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:18:49 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 14/23] riscv: tcg-target: Add the add2 and sub2 instructions Thread-Index: AQHUl8+rklGibwjCLkyd53SPuYSnSg== Date: Wed, 19 Dec 2018 19:18:49 +0000 Message-ID: <5665a57809e32b35775e8e98fdab898853af37b8.1545246859.git.alistair.francis@wdc.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR07CA0032.namprd07.prod.outlook.com (2603:10b6:a02:bc::45) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.171] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0848; 6:cP99w3W+QujJbnxaPwKFvOfPHQNHwd5E4mA3wzveQWMfdFDv2Wm+asF8tt6Z3hCmZVw6J+JbqNhW7IEfAM+REO4bWAkN0FkvFphS4L/ydvCsflEMX0UyN9inTSt+bGKBCHzApGLaAmXp0Zh097uciVDltP5pXr9MTk2N87TFWr5uuKRnz+5hawVTj9xYzmDD/4EgCiY6YJwtiuGuYrrlVG52CwC/By6Qvm97WyTn+Zbb/boNPYdD+LYldibgnTLFjScSPT9+v1gKW11A6EaKVs18S4cVzqXG0FJWiaEeVlR4aQabSbHPbovPX4+9a/pdqpkssQrMJdJTLWGZ8odF0v7TvgICrc2JN6CAjQG3m0dNH3/vmiobxnXBATPOhnu80ALBfVT0JxCneE8LpzY7tsCPbJ+UEePncPoIOFJ4dKCETunaRdU9TwbVWDjqpZv5Ia0zMON6SoKnZHuavYa1VA==; 5:QiIFbZeOEDrr54+na031ad4gJglwi248SWLdtqGdjyLmrAycS00LaOG9EncGqmCErP9ZSfXXWF3vrfQ1mKMQprXfwEWWMOhFubdgPuoe7DYn++AYe9ftIBaM0UF+Usem+zd03eZ0F7hbGaxfy3EeJMS7Kp9strJ1cUi/Stxq0Fc=; 7:y3eyt/3an48OLIo++i+OoiZsmWWLr1DW1UcCLIo3TyYXEQmFMWOLt+GuzJtc2rCp8SPpIJYwTREgt9fXw68SktXIfavXvyApZps/vGf+5PwwfpME6cn+0Y0ln3Tr8pV3GyMey30viEONBnUIwxrRjg== x-ms-office365-filtering-correlation-id: 7fcbdee0-b5d0-481c-6b86-08d665e6ce12 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0848; x-ms-traffictypediagnostic: MWHPR04MB0848: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231475)(944501520)(52105112)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0848; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0848; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(39860400002)(396003)(346002)(366004)(376002)(199004)(189003)(6486002)(14454004)(4326008)(72206003)(8936002)(86362001)(2501003)(50226002)(71190400001)(71200400001)(97736004)(6436002)(8676002)(81156014)(81166006)(36756003)(68736007)(25786009)(5660300001)(478600001)(118296001)(105586002)(53936002)(256004)(305945005)(14444005)(7736002)(6512007)(316002)(44832011)(39060400002)(66066001)(54906003)(110136005)(2906002)(52116002)(6116002)(76176011)(26005)(186003)(102836004)(99286004)(486006)(446003)(476003)(6506007)(11346002)(2616005)(3846002)(106356001)(386003); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0848; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: q3qOdSU//NaMDtV38qdLowZ7X20Xn1jyaOgM74yxk5k05LgSSR1Pbm/cpjc5Xc+b+xH5JZP1aYAeyxXqXnN0NZZeONWrxiwD+P1kXbNLXlb/8Szd9oUhAQ7kd55Z/2LDem9Kw4xwY3vh/OqW1Aqr+OABO+3pqWFnHd5804AD5eIicWkgsAc1SiS2cXg2HhXYpAX19ILj951VcM7MLTQtHisajhJ/DXXC4HYo50Y3qgtPoud07lMvXyeXJ37yO1EkFfBFxtRQo2J8JnSMGCW+n/gfV7QSgCihxuOXhPXxkU210nv2p/1GUOS3NaYOz24e spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7fcbdee0-b5d0-481c-6b86-08d665e6ce12 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:18:49.5682 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0848 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.141 Subject: [Qemu-devel] [PATCH v2 14/23] riscv: tcg-target: Add the add2 and sub2 instructions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Reviewed-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 55 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index 65718df7ad..5da850b957 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -695,3 +695,58 @@ static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, } return false; } + +static void tcg_out_addsub2(TCGContext *s, + TCGReg rl, TCGReg rh, + TCGReg al, TCGReg ah, + TCGArg bl, TCGArg bh, + bool cbl, bool cbh, bool is_sub, bool is32bit) +{ + const RISCVInsn opc_add = is32bit ? OPC_ADDW : OPC_ADD; + const RISCVInsn opc_addi = is32bit ? OPC_ADDIW : OPC_ADDI; + const RISCVInsn opc_sub = is32bit ? OPC_SUBW : OPC_SUB; + TCGReg th = TCG_REG_TMP1; + + /* If we have a negative constant such that negating it would + make the high part zero, we can (usually) eliminate one insn. */ + if (cbl && cbh && bh == -1 && bl != 0) { + bl = -bl; + bh = 0; + is_sub = !is_sub; + } + + /* By operating on the high part first, we get to use the final + carry operation to move back from the temporary. */ + if (!cbh) { + tcg_out_opc_reg(s, (is_sub ? opc_sub : opc_add), th, ah, bh); + } else if (bh != 0 || ah == rl) { + tcg_out_opc_imm(s, opc_addi, th, ah, (is_sub ? -bh : bh)); + } else { + th = ah; + } + + /* Note that tcg optimization should eliminate the bl == 0 case. */ + if (is_sub) { + if (cbl) { + tcg_out_opc_imm(s, OPC_SLTIU, TCG_REG_TMP0, al, bl); + tcg_out_opc_imm(s, opc_addi, rl, al, -bl); + } else { + tcg_out_opc_reg(s, OPC_SLTU, TCG_REG_TMP0, al, bl); + tcg_out_opc_reg(s, opc_sub, rl, al, bl); + } + tcg_out_opc_reg(s, opc_sub, rh, th, TCG_REG_TMP0); + } else { + if (cbl) { + tcg_out_opc_imm(s, opc_addi, rl, al, bl); + tcg_out_opc_imm(s, OPC_SLTIU, TCG_REG_TMP0, rl, bl); + } else if (rl == al && rl == bl) { + tcg_out_opc_imm(s, OPC_SLTI, TCG_REG_TMP0, al, 0); + tcg_out_opc_reg(s, opc_addi, rl, al, bl); + } else { + tcg_out_opc_reg(s, opc_add, rl, al, bl); + tcg_out_opc_reg(s, OPC_SLTU, TCG_REG_TMP0, + rl, (rl == bl ? al : bl)); + } + tcg_out_opc_reg(s, opc_add, rh, th, TCG_REG_TMP0); + } +} From patchwork Wed Dec 19 19:19:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738039 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id EEAD814DE for ; Wed, 19 Dec 2018 19:26:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB7F927D29 for ; Wed, 19 Dec 2018 19:26:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC7F427E5A; Wed, 19 Dec 2018 19:26:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1B71827D29 for ; Wed, 19 Dec 2018 19:26:26 +0000 (UTC) Received: from localhost ([::1]:33770 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhU8-0008HH-Ab for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:26:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45932) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhN7-0002NL-EV for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:19:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhN2-0001A5-MC for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:19:09 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:63928) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhN2-00019O-DI; Wed, 19 Dec 2018 14:19:04 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247145; x=1576783145; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=ErPoJQaau3edoJ544xIPnWiQrPP+dqOz4wi3XAA2iWI=; b=QJn9TZZpRBdiIZdyy6yiOYAsBoPVzl4m0PK0Yyp/lfT+Gq/PxjmNx6Wc ywar38biZQZmmW5nSELz5HXan/yp0OvT9FuuelcWTUQfe1GBnW5Rb2JrL 6jiChHLVSvUQlBX9XTs2cMPx9SUE9T8eJKBh0iWAW+V9auFLz0ojN7SYn OjGzypFhJX1HQqSnVp+vU7EC2QSqG/slZPtMvreozH5YNLIq6ImQBvth/ bst4DnVofN/+jvTwwNlkg8BM3t+2sncfgijtnzrLSZiploEOZ+tS/6gxn UJGTaGRXHGedg7OVhbVQuNEhbmqfhvw32b+r3bZUAjF+maQuBEAsKfsVh Q==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="98754887" Received: from mail-bn3nam01lp2054.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([104.47.33.54]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:19:02 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=S1Db0DguRYvina1m2lGJWCwW/jNvK4NyVFIXKPhjEHM=; b=bvm1tfCZGwStA4mEcpYti7bXSyZysxvIhp2agKlNt/y7jDMNq9AJR47LUNsY9gSyPgwGCDAZPOMaFZ5J45Otgg8a3pILQbPqtadVuvCTm3tjxZnh2GD6BDZ1x8hjdjd3JbqFNer/13PQYKbCm7avzZYBIb87wflQr0hN3+zoL0E= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0832.namprd04.prod.outlook.com (10.172.168.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.22; Wed, 19 Dec 2018 19:19:00 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:19:00 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 15/23] riscv: tcg-target: Add branch and jump instructions Thread-Index: AQHUl8+y6ZqYIOqDkECuxmWSixXkyw== Date: Wed, 19 Dec 2018 19:19:00 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR07CA0014.namprd07.prod.outlook.com (2603:10b6:a02:bc::27) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.171] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0832; 6:1W6OIk+tePIMtPNwZtylnivvP/18k2T4gcktVi2TGNXPGMtpdyDw4nfzsa2OAhzvDzUam5pqGRLVH4ZL9uOHLZl3hgNNQjHS810pbCJiACo9LJkpZhR6c8k917rGwNyFlKgcolue6pZ0Y1uDNozlX1ZFnFmpBZUMxdPvT2OJEn6NRYLYY9JVghPbr4eJOaQBJijR0GqM1MzS3oIrMqlZkTvNB/jD0xkbcx31/1YO38Q6hXCLLE+F2/CcnVrfrvnqotrBZAQpuyzQCuULeoxE7ncQ8b+st9j4B8RK2cKlna6UuQiLcfzCsh2P6aETf417QqZlOPNgY5aRIMq7kMWSja22PyE4JZyDwSx8NAiMDbR0TQTimC8h88ViH2v+Ifol7YTr8vAyZaY5prHsaLX8bu0JGDHlGLm8HVrsNAeStQSk9psmmPQiSWqV+vQohxfwSdwfaBYrONNT0hnzGJv/LQ==; 5:GNmcTAiug36rKT/IrTrXThLG9+Uhakx92hC/NmkoL2pQRJIwVC21PPhyfb7JfBIvDoo11/Laanx+537mTAYQtflfB3IOGoBQPdSBwpsZcQESGzKSf4gPJZ85hn2sRSLjP4UfwxC516IERbkrA11hhsdIaSL5vRulY/eetkSJ6tc=; 7:dYuZER57NLok2SQT2SdWnLLpS/qW+kCoz/x+w6ydt1XMwMhDdetBP15Q8j0WcgW6cB9WszBvVo2kr/lzizpW67YrP4n7gQE++3MzAz4euSwEZdKtFEGlm7noqo0EpSqwO6oYOsZR4Up07pZ0ck1BLA== x-ms-office365-filtering-correlation-id: 0fc9165e-3206-417c-7633-08d665e6d4a4 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0832; x-ms-traffictypediagnostic: MWHPR04MB0832: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(5005020)(6040522)(2401047)(8121501046)(3231475)(944501520)(52105112)(93006095)(93001095)(3002001)(10201501046)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0832; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0832; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(39860400002)(366004)(396003)(346002)(136003)(189003)(199004)(6506007)(68736007)(76176011)(386003)(102836004)(476003)(2616005)(44832011)(486006)(97736004)(118296001)(478600001)(316002)(26005)(6346003)(4326008)(110136005)(54906003)(186003)(39060400002)(8676002)(50226002)(81166006)(86362001)(6512007)(52116002)(81156014)(53936002)(71200400001)(99286004)(256004)(71190400001)(8936002)(446003)(11346002)(305945005)(7736002)(106356001)(6486002)(3846002)(6116002)(66066001)(25786009)(5660300001)(2906002)(72206003)(2501003)(14454004)(36756003)(6436002)(105586002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0832; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-microsoft-antispam-message-info: jkc1x//5Xiry8ZQYBrSrGIGZH3Q/eVFioH9lyHgxhqmvwK5OPL4vPKJSx6FQRj33lS5l0pYvc4+UlVIA8MlbkbIy/ywOIg9Fr2tybMWR7F/71uUm4sgtz56ZzOMTYnD0Lj+RaGI16a0YPrlcbptFZZ3Q+ymXeuWeG7HxXL4xxwW6D7aaWkCqQKrrQtD3GMKiNxCkcdGCohtYiLh+R9fzsPesgwZTLVSGH3H1crKMONZDaAe4qjnDm3C64+4DRIRX0DdwegvPyapeOhxNx/8EZmeeW3EDQH2Hg8cdw/6/XfgKd3PyNhp30BNXNa6s51ln spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0fc9165e-3206-417c-7633-08d665e6d4a4 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:19:00.6447 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0832 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.154.45 Subject: [Qemu-devel] [PATCH v2 15/23] riscv: tcg-target: Add branch and jump instructions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 145 +++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index 5da850b957..ecc76c9ef8 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -750,3 +750,148 @@ static void tcg_out_addsub2(TCGContext *s, tcg_out_opc_reg(s, opc_add, rh, th, TCG_REG_TMP0); } } + +static const struct { + RISCVInsn op; + bool swap; +} tcg_brcond_to_riscv[] = { + [TCG_COND_EQ] = { OPC_BEQ, false }, + [TCG_COND_NE] = { OPC_BNE, false }, + [TCG_COND_LT] = { OPC_BLT, false }, + [TCG_COND_GE] = { OPC_BGE, false }, + [TCG_COND_LE] = { OPC_BGE, true }, + [TCG_COND_GT] = { OPC_BLT, true }, + [TCG_COND_LTU] = { OPC_BLTU, false }, + [TCG_COND_GEU] = { OPC_BGEU, false }, + [TCG_COND_LEU] = { OPC_BGEU, true }, + [TCG_COND_GTU] = { OPC_BLTU, true } +}; + +static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGReg arg1, + TCGReg arg2, TCGLabel *l) +{ + RISCVInsn op = tcg_brcond_to_riscv[cond].op; + + tcg_debug_assert(op != 0); + + if (tcg_brcond_to_riscv[cond].swap) { + TCGReg t = arg1; + arg1 = arg2; + arg2 = t; + } + + if (l->has_value) { + intptr_t diff = tcg_pcrel_diff(s, l->u.value_ptr); + if (diff == sextreg(diff, 0, 12)) { + tcg_out_opc_branch(s, op, arg1, arg2, diff); + } else { + /* Invert the conditional branch. */ + tcg_out_opc_branch(s, op ^ (1 << 12), arg1, arg2, 8); + tcg_out_opc_jump(s, OPC_JAL, TCG_REG_ZERO, diff - 4); + } + } else { + tcg_out_reloc(s, s->code_ptr, R_RISCV_BRANCH, l, 0); + tcg_out_opc_branch(s, op, arg1, arg2, 0); + /* NOP to allow patching later */ + tcg_out_opc_imm(s, OPC_ADDI, TCG_REG_ZERO, TCG_REG_ZERO, 0); + } +} + +static void tcg_out_setcond(TCGContext *s, TCGCond cond, TCGReg ret, + TCGReg arg1, TCGReg arg2) +{ + switch (cond) { + case TCG_COND_EQ: + tcg_out_opc_reg(s, OPC_SUB, ret, arg1, arg2); + tcg_out_opc_imm(s, OPC_SLTIU, ret, ret, 1); + break; + case TCG_COND_NE: + tcg_out_opc_reg(s, OPC_SUB, ret, arg1, arg2); + tcg_out_opc_reg(s, OPC_SLTU, ret, TCG_REG_ZERO, ret); + break; + case TCG_COND_LT: + tcg_out_opc_reg(s, OPC_SLT, ret, arg1, arg2); + break; + case TCG_COND_GE: + tcg_out_opc_reg(s, OPC_SLT, ret, arg1, arg2); + tcg_out_opc_imm(s, OPC_XORI, ret, ret, 1); + break; + case TCG_COND_LE: + tcg_out_opc_reg(s, OPC_SLT, ret, arg2, arg1); + tcg_out_opc_imm(s, OPC_XORI, ret, ret, 1); + break; + case TCG_COND_GT: + tcg_out_opc_reg(s, OPC_SLT, ret, arg2, arg1); + break; + case TCG_COND_LTU: + tcg_out_opc_reg(s, OPC_SLTU, ret, arg1, arg2); + break; + case TCG_COND_GEU: + tcg_out_opc_reg(s, OPC_SLTU, ret, arg1, arg2); + tcg_out_opc_imm(s, OPC_XORI, ret, ret, 1); + break; + case TCG_COND_LEU: + tcg_out_opc_reg(s, OPC_SLTU, ret, arg2, arg1); + tcg_out_opc_imm(s, OPC_XORI, ret, ret, 1); + break; + case TCG_COND_GTU: + tcg_out_opc_reg(s, OPC_SLTU, ret, arg2, arg1); + break; + default: + g_assert_not_reached(); + break; + } +} + +static void tcg_out_brcond2(TCGContext *s, TCGCond cond, TCGReg al, TCGReg ah, + TCGReg bl, TCGReg bh, TCGLabel *l) +{ + /* todo */ + g_assert_not_reached(); +} + +static void tcg_out_setcond2(TCGContext *s, TCGCond cond, TCGReg ret, + TCGReg al, TCGReg ah, TCGReg bl, TCGReg bh) +{ + /* todo */ + g_assert_not_reached(); +} + +static inline void tcg_out_goto(TCGContext *s, tcg_insn_unit *target) +{ + ptrdiff_t offset = tcg_pcrel_diff(s, target); + tcg_debug_assert(offset == sextreg(offset, 1, 20) << 1); + tcg_out_opc_jump(s, OPC_JAL, TCG_REG_ZERO, offset); +} + +static void tcg_out_call_int(TCGContext *s, tcg_insn_unit *arg, bool tail) +{ + TCGReg link = tail ? TCG_REG_ZERO : TCG_REG_RA; + ptrdiff_t offset = tcg_pcrel_diff(s, arg); + int ret; + + if (offset == sextreg(offset, 1, 20) << 1) { + /* short jump: -2097150 to 2097152 */ + tcg_out_opc_jump(s, OPC_JAL, link, offset); + } else if (TCG_TARGET_REG_BITS == 32 || + offset == sextreg(offset, 1, 31) << 1) { + /* long jump: -2147483646 to 2147483648 */ + tcg_out_opc_upper(s, OPC_AUIPC, TCG_REG_TMP0, 0); + tcg_out_opc_imm(s, OPC_JALR, link, TCG_REG_TMP0, 0); + ret = reloc_call(s->code_ptr - 2, arg);\ + tcg_debug_assert(ret == true); + } else if (TCG_TARGET_REG_BITS == 64) { + /* far jump: 64-bit */ + tcg_target_long imm = sextreg((tcg_target_long)arg, 0, 12); + tcg_target_long base = (tcg_target_long)arg - imm; + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_TMP0, base); + tcg_out_opc_imm(s, OPC_JALR, link, TCG_REG_TMP0, imm); + } else { + g_assert_not_reached(); + } +} + +static void tcg_out_call(TCGContext *s, tcg_insn_unit *arg) +{ + tcg_out_call_int(s, arg, false); +} From patchwork Wed Dec 19 19:19:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738047 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6BAEE6C2 for ; Wed, 19 Dec 2018 19:29:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5C15727F93 for ; Wed, 19 Dec 2018 19:29:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5047627FA1; Wed, 19 Dec 2018 19:29:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2A9A327F93 for ; Wed, 19 Dec 2018 19:29:18 +0000 (UTC) Received: from localhost ([::1]:33788 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhWv-0002ab-Cz for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:29:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46017) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhNH-0002WT-QF for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:19:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhND-0001FW-7f for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:19:19 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:15944) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhNC-0001Ec-Nh; Wed, 19 Dec 2018 14:19:15 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247155; x=1576783155; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=gVn7rcnfRgyPP4EKZZ2qH2uWqRFb8cHQy61BBP0SGOQ=; b=Qq1IP/V9qE0lgsahI8VjU4Z9+GlByY1jH4gPPAXGSo6JQuZXNWsHX+WH 8PwbOcTx1mUKNgr9Svx2c4UowjDiIz4eB25+ateE3Cuds2KOs0vZ5xkQw Ur5aRgpsHFy7C4oIl2x5jvBH186DV/8hvImhsSkNweVWUG4O6gNQtLguL 3ECbNmVarTqWzXu2iVBDMUiNjYwqOVhut1OGXQz5MzgK2gHeHkBUhA5X2 /SdSwOR5umJ9KwGLSDxAFX3IrqDaCRf2Bsd8CxePrNV6R22bhZ7ypCj8t 1dYjFPfux/pcnEy8KKl6uxhQpTXJyGttNOe663MPDo4ixHLI/qEI0+PwF g==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="101923948" Received: from mail-dm3nam05lp2053.outbound.protection.outlook.com (HELO NAM05-DM3-obe.outbound.protection.outlook.com) ([104.47.49.53]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:19:12 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Tok9lPbHlu65DKMoxMSUn9DifAOFAeklgXKfh/JykL8=; b=LFHMkRhe9ndalKo5ljqVguQXEXVgnfXqaSkoJ7ipQy/SFQC0gO7kV2duylqVKv2V2M9k5gmX2uOU9qvHs+EmvsK4HUFpJC1PChT+/52VCxyuP/M9AEhd6dQvDx11TgdxJl6o9phRthZrGpxBXtH1ZT+FFgnoQ3T5ApQRDujxVrU= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0832.namprd04.prod.outlook.com (10.172.168.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.22; Wed, 19 Dec 2018 19:19:11 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:19:11 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 16/23] riscv: tcg-target: Add slowpath load and store instructions Thread-Index: AQHUl8+4aQ0RipLZ70uNRt+1U+2/JQ== Date: Wed, 19 Dec 2018 19:19:11 +0000 Message-ID: <1a0a7e8f3347764f212c5efa5c07c9be17efdec6.1545246859.git.alistair.francis@wdc.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR07CA0036.namprd07.prod.outlook.com (2603:10b6:a02:bc::49) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.171] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0832; 6:bimJ0ZorFsWh7++2/1mjGMvbCcvw0ceAw70eJGrcIiXJkuTcBIBNri0DoAJrW1fzB59CXV6k8rzX24yfOviwU1gWeVJlp+ehxc955nxodXy2RT4f4FiPcPBU7+cDV0pHplOix7VbZie1nv+MeVpMhU8d7IsyUBvcV10+1S35dcDHTToKS9qoknffjDIszB7bbB1SDNNqzGt+/as6jF1Zs1sP99EdNOnKmZ+NOUxguYC49L53CfsYA8IVeCwdYAQjn2O0h4XRybpG3Yp4Zyclg13WqD0La2gHSO3gVg7+duTzM9vHgEDi827FHi2oVcQC3OsSenphQJVFWYcRtoqQiCLWViVdH6cTrAqSylRlrCnDWay+C0Ewj6FnmWFSBP5mMMCaiXcctY0SxofGewMj3zdFpv+bQ6vdwXg5k3A7sQTqlJ4DY1QRCumE9LApLLINWMb1fj8DAA7Ef5tiGrhHPg==; 5:1G5MdffivKwIW6lXnDHYCf59RHpcHb+tDWp+cRU+r5j2DvwN3arN3tNVQZkOcjLoK8/vVwvXyNjITQYRTzs9mtgKfb/farLTwbnGCdrjB17DLLjUaAL5KjLVGln+hqWsdwBMZ+Kq0TJ/N2UvWGr6XpD16C43x+ozi+DlcM44cFU=; 7:LK70W+PkD+ktTl9+JDRnBvG5pZQr/PmQtUVvPds/cqHb8nVtli1rLt8PeI7TGhge9o86U/BAG+3bSi8x7wurbj7v+GcVjDBydiflkSuEUMgzbvOZoEvj6JQBzVTcb/Q29rOp353WAoVkzszWxW2Fww== x-ms-office365-filtering-correlation-id: 09b69087-4b48-47da-9446-08d665e6db02 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0832; x-ms-traffictypediagnostic: MWHPR04MB0832: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(5005020)(6040522)(2401047)(8121501046)(3231475)(944501520)(52105112)(93006095)(93001095)(3002001)(10201501046)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0832; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0832; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(39860400002)(366004)(396003)(346002)(136003)(189003)(199004)(6506007)(68736007)(76176011)(386003)(102836004)(476003)(2616005)(44832011)(486006)(97736004)(118296001)(478600001)(316002)(26005)(6346003)(4326008)(110136005)(54906003)(186003)(39060400002)(8676002)(50226002)(81166006)(86362001)(6512007)(52116002)(81156014)(6306002)(53936002)(71200400001)(99286004)(256004)(71190400001)(8936002)(446003)(11346002)(305945005)(7736002)(106356001)(6486002)(3846002)(6116002)(66066001)(25786009)(5660300001)(2906002)(72206003)(2501003)(966005)(14454004)(36756003)(6436002)(105586002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0832; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-microsoft-antispam-message-info: QePwzoCla/XTzWkb2AopzMYVrlH4N85cEnZyj4EDOKePDL8Ynp2TqPSs6BorF4VlUtQ08HtrPsFFBlsB+rDH2gpsU5BXneaMB6vn7bPn+nthvwwbrWQI4H34waZon60/0djsHUDh4crg1zowekGtNKuppHW1NnXkKIIQ6xFY/ZrNi1nT+7mnzM8vjFgu9yEktCwo8tVpMKO9eZHsgCZcS8SlkA5gPY6nOGPjgJF59fCrkiYgMJLbvmZEj6N+05TBQFmwTTR5oNItLVUq7LX2iUqODkN4cTo9+DR0v+oG01IglfNRDBI+T8cRfxrD1Ytr spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 09b69087-4b48-47da-9446-08d665e6db02 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:19:11.3679 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0832 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.141 Subject: [Qemu-devel] [PATCH v2 16/23] riscv: tcg-target: Add slowpath load and store instructions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Signed-off-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 256 +++++++++++++++++++++++++++++++++++++ 1 file changed, 256 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index ecc76c9ef8..7216bad086 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -895,3 +895,259 @@ static void tcg_out_call(TCGContext *s, tcg_insn_unit *arg) { tcg_out_call_int(s, arg, false); } + +static void tcg_out_mb(TCGContext *s, TCGArg a0) +{ + tcg_insn_unit insn = OPC_FENCE; + + if (a0 & TCG_MO_LD_LD) { + insn |= 0x02200000; + } + if (a0 & TCG_MO_ST_LD) { + insn |= 0x01200000; + } + if (a0 & TCG_MO_LD_ST) { + insn |= 0x02100000; + } + if (a0 & TCG_MO_ST_ST) { + insn |= 0x02200000; + } + tcg_out32(s, insn); +} + +/* + * Load/store and TLB + */ + +#if defined(CONFIG_SOFTMMU) +#include "tcg-ldst.inc.c" + +/* helper signature: helper_ret_ld_mmu(CPUState *env, target_ulong addr, + * TCGMemOpIdx oi, uintptr_t ra) + */ +static void * const qemu_ld_helpers[16] = { + [MO_UB] = helper_ret_ldub_mmu, + [MO_SB] = helper_ret_ldsb_mmu, + [MO_LEUW] = helper_le_lduw_mmu, + [MO_LESW] = helper_le_ldsw_mmu, + [MO_LEUL] = helper_le_ldul_mmu, +#if TCG_TARGET_REG_BITS == 64 + [MO_LESL] = helper_le_ldsl_mmu, +#endif + [MO_LEQ] = helper_le_ldq_mmu, + [MO_BEUW] = helper_be_lduw_mmu, + [MO_BESW] = helper_be_ldsw_mmu, + [MO_BEUL] = helper_be_ldul_mmu, +#if TCG_TARGET_REG_BITS == 64 + [MO_BESL] = helper_be_ldsl_mmu, +#endif + [MO_BEQ] = helper_be_ldq_mmu, +}; + +/* helper signature: helper_ret_st_mmu(CPUState *env, target_ulong addr, + * uintxx_t val, TCGMemOpIdx oi, + * uintptr_t ra) + */ +static void * const qemu_st_helpers[16] = { + [MO_UB] = helper_ret_stb_mmu, + [MO_LEUW] = helper_le_stw_mmu, + [MO_LEUL] = helper_le_stl_mmu, + [MO_LEQ] = helper_le_stq_mmu, + [MO_BEUW] = helper_be_stw_mmu, + [MO_BEUL] = helper_be_stl_mmu, + [MO_BEQ] = helper_be_stq_mmu, +}; + +static void tcg_out_tlb_load(TCGContext *s, TCGReg addrl, + TCGReg addrh, TCGMemOpIdx oi, + tcg_insn_unit **label_ptr, bool is_load) +{ + TCGMemOp opc = get_memop(oi); + unsigned s_bits = opc & MO_SIZE; + unsigned a_bits = get_alignment_bits(opc); + target_ulong mask; + int mem_index = get_mmuidx(oi); + int cmp_off + = (is_load + ? offsetof(CPUArchState, tlb_table[mem_index][0].addr_read) + : offsetof(CPUArchState, tlb_table[mem_index][0].addr_write)); + int add_off = offsetof(CPUArchState, tlb_table[mem_index][0].addend); + RISCVInsn load_cmp_op = (TARGET_LONG_BITS == 64 ? OPC_LD : + TCG_TARGET_REG_BITS == 64 ? OPC_LWU : OPC_LW); + RISCVInsn load_add_op = TCG_TARGET_REG_BITS == 64 ? OPC_LD : OPC_LW; + TCGReg base = TCG_AREG0; + + /* We don't support oversize guests */ + if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { + g_assert_not_reached(); + } + + /* We don't support unaligned accesses. */ + if (a_bits < s_bits) { + a_bits = s_bits; + } + mask = (target_ulong)TARGET_PAGE_MASK | ((1 << a_bits) - 1); + + + /* Compensate for very large offsets. */ + if (add_off >= 0x1000) { + int adj; + base = TCG_REG_TMP2; + if (cmp_off <= 2 * 0xfff) { + adj = 0xfff; + tcg_out_opc_imm(s, OPC_ADDI, base, TCG_AREG0, adj); + } else { + adj = cmp_off - sextreg(cmp_off, 0, 12); + tcg_debug_assert(add_off - adj >= -0x1000 + && add_off - adj < 0x1000); + + tcg_out_opc_upper(s, OPC_LUI, base, adj); + tcg_out_opc_reg(s, OPC_ADD, base, base, TCG_AREG0); + } + add_off -= adj; + cmp_off -= adj; + } + + /* Extract the page index. */ + if (CPU_TLB_BITS + CPU_TLB_ENTRY_BITS < 12) { + tcg_out_opc_imm(s, OPC_SRLI, TCG_REG_TMP0, addrl, + TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS); + tcg_out_opc_imm(s, OPC_ANDI, TCG_REG_TMP0, TCG_REG_TMP0, + MAKE_64BIT_MASK(CPU_TLB_ENTRY_BITS, CPU_TLB_BITS)); + } else if (TARGET_PAGE_BITS >= 12) { + tcg_out_opc_upper(s, OPC_LUI, TCG_REG_TMP0, + MAKE_64BIT_MASK(TARGET_PAGE_BITS, CPU_TLB_BITS)); + tcg_out_opc_reg(s, OPC_AND, TCG_REG_TMP0, TCG_REG_TMP0, addrl); + tcg_out_opc_imm(s, OPC_SRLI, TCG_REG_TMP0, TCG_REG_TMP0, + CPU_TLB_BITS - CPU_TLB_ENTRY_BITS); + } else { + tcg_out_opc_imm(s, OPC_SRLI, TCG_REG_TMP0, addrl, TARGET_PAGE_BITS); + tcg_out_opc_imm(s, OPC_ANDI, TCG_REG_TMP0, TCG_REG_TMP0, + MAKE_64BIT_MASK(0, CPU_TLB_BITS)); + tcg_out_opc_imm(s, OPC_SLLI, TCG_REG_TMP0, TCG_REG_TMP0, + CPU_TLB_ENTRY_BITS); + } + + /* Add that to the base address to index the tlb. */ + tcg_out_opc_reg(s, OPC_ADD, TCG_REG_TMP2, base, TCG_REG_TMP0); + base = TCG_REG_TMP2; + + /* Load the tlb comparator and the addend. */ + tcg_out_ldst(s, load_cmp_op, TCG_REG_TMP0, base, cmp_off); + tcg_out_ldst(s, load_add_op, TCG_REG_TMP2, base, add_off); + + /* Clear the non-page, non-alignment bits from the address. */ + if (mask == sextreg(mask, 0, 12)) { + tcg_out_opc_imm(s, OPC_ANDI, TCG_REG_TMP1, addrl, mask); + } else { + tcg_out_movi(s, TCG_TYPE_REG, TCG_REG_TMP1, mask); + tcg_out_opc_reg(s, OPC_AND, TCG_REG_TMP1, TCG_REG_TMP1, addrl); + } + + /* Compare masked address with the TLB entry. */ + label_ptr[0] = s->code_ptr; + tcg_out_opc_branch(s, OPC_BNE, TCG_REG_TMP0, TCG_REG_TMP1, 0); + /* NOP to allow patching later */ + tcg_out_opc_imm(s, OPC_ADDI, TCG_REG_ZERO, TCG_REG_ZERO, 0); + /* TODO: Move this out of line + * see: + * https://lists.nongnu.org/archive/html/qemu-devel/2018-11/msg02234.html + */ + + /* TLB Hit - translate address using addend. */ + if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { + tcg_out_ext32u(s, TCG_REG_TMP0, addrl); + addrl = TCG_REG_TMP0; + } + tcg_out_opc_reg(s, OPC_ADD, TCG_REG_TMP0, TCG_REG_TMP2, addrl); +} + +static void add_qemu_ldst_label(TCGContext *s, int is_ld, TCGMemOpIdx oi, + TCGType ext, + TCGReg datalo, TCGReg datahi, + TCGReg addrlo, TCGReg addrhi, + void *raddr, tcg_insn_unit **label_ptr) +{ + TCGLabelQemuLdst *label = new_ldst_label(s); + + label->is_ld = is_ld; + label->oi = oi; + label->type = ext; + label->datalo_reg = datalo; + label->datahi_reg = datahi; + label->addrlo_reg = addrlo; + label->addrhi_reg = addrhi; + label->raddr = raddr; + label->label_ptr[0] = label_ptr[0]; +} + +static void tcg_out_qemu_ld_slow_path(TCGContext *s, TCGLabelQemuLdst *l) +{ + TCGMemOpIdx oi = l->oi; + TCGMemOp opc = get_memop(oi); + TCGReg a0 = tcg_target_call_iarg_regs[0]; + TCGReg a1 = tcg_target_call_iarg_regs[1]; + TCGReg a2 = tcg_target_call_iarg_regs[2]; + TCGReg a3 = tcg_target_call_iarg_regs[3]; + + /* We don't support oversize guests */ + if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { + g_assert_not_reached(); + } + + /* resolve label address */ + patch_reloc(l->label_ptr[0], R_RISCV_BRANCH, (intptr_t) s->code_ptr, 0); + + /* call load helper */ + tcg_out_mov(s, TCG_TYPE_PTR, a0, TCG_AREG0); + tcg_out_mov(s, TCG_TYPE_PTR, a1, l->addrlo_reg); + tcg_out_movi(s, TCG_TYPE_PTR, a2, oi); + tcg_out_movi(s, TCG_TYPE_PTR, a3, (tcg_target_long)l->raddr); + + tcg_out_call(s, qemu_ld_helpers[opc & (MO_BSWAP | MO_SSIZE)]); + tcg_out_mov(s, (opc & MO_SIZE) == MO_64, l->datalo_reg, a0); + + tcg_out_goto(s, l->raddr); +} + +static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) +{ + TCGMemOpIdx oi = l->oi; + TCGMemOp opc = get_memop(oi); + TCGMemOp s_bits = opc & MO_SIZE; + TCGReg a0 = tcg_target_call_iarg_regs[0]; + TCGReg a1 = tcg_target_call_iarg_regs[1]; + TCGReg a2 = tcg_target_call_iarg_regs[2]; + TCGReg a3 = tcg_target_call_iarg_regs[3]; + TCGReg a4 = tcg_target_call_iarg_regs[4]; + + /* We don't support oversize guests */ + if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { + g_assert_not_reached(); + } + + /* resolve label address */ + patch_reloc(l->label_ptr[0], R_RISCV_BRANCH, (intptr_t) s->code_ptr, 0); + + /* call store helper */ + tcg_out_mov(s, TCG_TYPE_PTR, a0, TCG_AREG0); + tcg_out_mov(s, TCG_TYPE_PTR, a1, l->addrlo_reg); + tcg_out_mov(s, TCG_TYPE_PTR, a2, l->datalo_reg); + switch (s_bits) { + case MO_8: + tcg_out_ext8u(s, a2, a2); + break; + case MO_16: + tcg_out_ext16u(s, a2, a2); + break; + default: + break; + } + tcg_out_movi(s, TCG_TYPE_PTR, a3, oi); + tcg_out_movi(s, TCG_TYPE_PTR, a4, (tcg_target_long)l->raddr); + + tcg_out_call(s, qemu_st_helpers[opc & (MO_BSWAP | MO_SSIZE)]); + + tcg_out_goto(s, l->raddr); +} +#endif /* CONFIG_SOFTMMU */ From patchwork Wed Dec 19 19:19:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738083 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 46C021399 for ; Wed, 19 Dec 2018 19:40:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38F4B2846F for ; Wed, 19 Dec 2018 19:40:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2D7CE284C3; Wed, 19 Dec 2018 19:40:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5AA31284B3 for ; Wed, 19 Dec 2018 19:40:44 +0000 (UTC) Received: from localhost ([::1]:33872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhhz-00038I-Gj for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:40:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhNR-0002dm-I4 for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:19:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhNN-0001Lh-5K for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:19:29 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:15956) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhNM-0001Kr-Om; Wed, 19 Dec 2018 14:19:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247165; x=1576783165; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=ZiQsIsNt6bIQgHxW5/lOS4NmjkW37i6K0M1orBgH8Sw=; b=NIg0me9wfESfxtwcnTMx2XEP9SpQ+H/REk92UcKoPu286VBAGnwF4NZ1 Vquw1UbxluhqxIVHFaXyVqDO/X39/elk25+XN13w4P8t/9IcaM5vbU5R9 Q1BCV7ZjuI2n2vsOnwv5E3YjK7RFy0s+brX+Sh6Ia/NAqxF0SxHcydscb z3HJdTPTeXe63w10Qp9/lGrHuvP3W68OFh1KNr/0JzVxhEp7yIldss4VY OTBXnnxKh/GqSK3vj/SzGyf0BrBjJkblZKzYbWzaP9fSAKOJp/nxJBh+w tW/PArKafUsLKm8+dBDJbuJLnJsd8607X+PkmsBYneKNAdowHB2xX2SCZ w==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="101923954" Received: from mail-bn3nam01lp2056.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([104.47.33.56]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:19:22 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PIpJg3WkMCQI5wP5J0nVpdbU3gfCF1LWII+irtnIShU=; b=gL+MjKNDN1Vkg1VoXFxreP+mKfcTqWIMHef1O48xz0QFrVqD/AX/Ov7a/xvyog0L0anlcK4fKB4FV03EdYUYfHqqXccZrsYZbFX/ZXQ1yABYTYErSjnNyOZC0PYaZ+a9dchruqNC9FIKXtGejo3Zlag5A9o7e5lQoAzXqSqG+w0= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0832.namprd04.prod.outlook.com (10.172.168.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.22; Wed, 19 Dec 2018 19:19:21 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:19:21 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 17/23] riscv: tcg-target: Add direct load and store instructions Thread-Index: AQHUl8++cqezP2gMa0iniEvQV0n3Aw== Date: Wed, 19 Dec 2018 19:19:20 +0000 Message-ID: <2e047a95c39c007c66cda024c095e29b0ac4c43e.1545246859.git.alistair.francis@wdc.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR07CA0069.namprd07.prod.outlook.com (2603:10b6:a03:60::46) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.250] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0832; 6:9OC8cF8q4VYLNh1aBdzcxAaHOjYbNmE0iXoZZ5ZagiLnCu9gl773IeqAepqi3d7htCLEY6eunsxEyd4K9GGxtRXeMszFinyArVtwp3ofGsCeK3O3fYMiSv4WmFwlTjT6Sr2yXdQWeUhHX7uRJfHAdVNlQep1mDuRRpeJtC3+NDU5x8QECKj4kmqHoN+lS9ERs8EQZNUTT+WWCNOmyFGoHMIOymeIBA5Qs8ZoHx+as2SXebcfzJlwTKlDAfapiwuxYhe/0V3KS8iLfcgU7TwuSBKvy4rsALelnAu8Tt9ERGOqOn5iOLsaFI72lKrNVJn5HCUH+MTWAZyCn8jhqjdMUzS6HdFVGuG1+e9/NoabqPM6aahrAm4BrgDhQJqtSicaQr0/UaLPQ9HoU5l23aAGkVL0g4knUVy7dRLJKOCWMdluLyeisapLovOFfG7TMLkvsDsieUi54SOuoNgEayaGwA==; 5:nRVh3iNZlmHtN3CK5oEYSuaBZyqXIdW0YCQZ5e+oxOMVwXscqF6vkNbNmmDTAVjAH2Amm8yLAaT0tbS5cwM5YEc1+7RxFnj4AcroWuRoiOXaSSifVozt9p27zWd9SnHTfSErWRMr8cgFnXPlGeIEftlgSyF041WF7CqGOKStTbw=; 7:NPTFHyv+3dtXjhJ36qNRCXeeNhaMfGghTqyuxSUBVIsWS2xS3E5SCMDAtTiAll9yU5fz0sI0Qb1b6gjlE4ILsOfxHlI41CRponwypAx+Q7CRrD/D9cuvJ2tQ+6lYOcJDWhpydqtkg+wKJhyyKm2AxQ== x-ms-office365-filtering-correlation-id: 2638b6f8-e757-45b5-fb7b-08d665e6e0bc x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0832; x-ms-traffictypediagnostic: MWHPR04MB0832: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(5005020)(6040522)(2401047)(8121501046)(3231475)(944501520)(52105112)(93006095)(93001095)(3002001)(10201501046)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0832; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0832; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(39860400002)(366004)(396003)(346002)(136003)(189003)(199004)(6506007)(68736007)(76176011)(386003)(102836004)(476003)(2616005)(44832011)(486006)(97736004)(118296001)(478600001)(316002)(26005)(6346003)(4326008)(110136005)(54906003)(186003)(39060400002)(8676002)(50226002)(81166006)(86362001)(6512007)(52116002)(81156014)(53936002)(71200400001)(99286004)(256004)(71190400001)(8936002)(446003)(11346002)(305945005)(7736002)(106356001)(6486002)(3846002)(6116002)(66066001)(25786009)(5660300001)(2906002)(72206003)(2501003)(14454004)(36756003)(6436002)(105586002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0832; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-microsoft-antispam-message-info: 6EIRSjlKLX6DlLwHPLExb6a1AYVLBLTI8UjIi072P/SQUOMYcwdww0DfOMH0Rj5P8qAfxSM65HHExoc2jTpgTlUHHz3ztFSrWZEO5Wj2OsVulOJR3fI+LjeaCRbpfgRiBTiMA6UNJYKhIr+YhZ2M6/SSF+I74APeKfRqOYsmhyilRAPZEjI07MJBp4SQb7Vwvsa1yTF8eCE6Hl9X7j8QnUVaWhu+PfxspR+sjQchMJ8+pBFHG67Pn99O8hItYTPQAKtN/KzgjnR08dIPDIyoeWeq/VxHoUcPujnlu/e0/LSTyu2GJsJYzBl+xGlQVFW6 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2638b6f8-e757-45b5-fb7b-08d665e6e0bc X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:19:20.9491 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0832 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.141 Subject: [Qemu-devel] [PATCH v2 17/23] riscv: tcg-target: Add direct load and store instructions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Reviewed-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 158 +++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index 7216bad086..154315787c 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -1151,3 +1151,161 @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) tcg_out_goto(s, l->raddr); } #endif /* CONFIG_SOFTMMU */ + +static void tcg_out_qemu_ld_direct(TCGContext *s, TCGReg lo, TCGReg hi, + TCGReg base, TCGMemOp opc, bool is_64) +{ + const TCGMemOp bswap = opc & MO_BSWAP; + + /* We don't yet handle byteswapping, assert */ + g_assert(!bswap); + + switch (opc & (MO_SSIZE)) { + case MO_UB: + tcg_out_opc_imm(s, OPC_LBU, lo, base, 0); + break; + case MO_SB: + tcg_out_opc_imm(s, OPC_LB, lo, base, 0); + break; + case MO_UW: + tcg_out_opc_imm(s, OPC_LHU, lo, base, 0); + break; + case MO_SW: + tcg_out_opc_imm(s, OPC_LH, lo, base, 0); + break; + case MO_UL: + if (TCG_TARGET_REG_BITS == 64 && is_64) { + tcg_out_opc_imm(s, OPC_LWU, lo, base, 0); + break; + } + /* FALLTHRU */ + case MO_SL: + tcg_out_opc_imm(s, OPC_LW, lo, base, 0); + break; + case MO_Q: + /* Prefer to load from offset 0 first, but allow for overlap. */ + if (TCG_TARGET_REG_BITS == 64) { + tcg_out_opc_imm(s, OPC_LD, lo, base, 0); + } else if (lo != base) { + tcg_out_opc_imm(s, OPC_LW, lo, base, 0); + tcg_out_opc_imm(s, OPC_LW, hi, base, 4); + } else { + tcg_out_opc_imm(s, OPC_LW, hi, base, 4); + tcg_out_opc_imm(s, OPC_LW, lo, base, 0); + } + break; + default: + g_assert_not_reached(); + } +} + +static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, bool is_64) +{ + TCGReg addr_regl, addr_regh __attribute__((unused)); + TCGReg data_regl, data_regh; + TCGMemOpIdx oi; + TCGMemOp opc; +#if defined(CONFIG_SOFTMMU) + tcg_insn_unit *label_ptr[1]; +#endif + TCGReg base = TCG_REG_TMP0; + + data_regl = *args++; + data_regh = (TCG_TARGET_REG_BITS == 32 && is_64 ? *args++ : 0); + addr_regl = *args++; + addr_regh = (TCG_TARGET_REG_BITS < TARGET_LONG_BITS ? *args++ : 0); + oi = *args++; + opc = get_memop(oi); + +#if defined(CONFIG_SOFTMMU) + tcg_out_tlb_load(s, addr_regl, addr_regh, oi, label_ptr, 1); + tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); + add_qemu_ldst_label(s, 1, oi, + (is_64 ? TCG_TYPE_I64 : TCG_TYPE_I32), + data_regl, data_regh, addr_regl, addr_regh, + s->code_ptr, label_ptr); +#else + if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { + tcg_out_ext32u(s, base, addr_regl); + addr_regl = base; + } + + if (guest_base == 0) { + tcg_out_opc_reg(s, OPC_ADD, base, addr_regl, TCG_REG_ZERO); + } else { + tcg_out_opc_reg(s, OPC_ADD, base, TCG_GUEST_BASE_REG, addr_regl); + } + tcg_out_qemu_ld_direct(s, data_regl, data_regh, base, opc, is_64); +#endif +} + +static void tcg_out_qemu_st_direct(TCGContext *s, TCGReg lo, TCGReg hi, + TCGReg base, TCGMemOp opc) +{ + const TCGMemOp bswap = opc & MO_BSWAP; + + /* We don't yet handle byteswapping, assert */ + g_assert(!bswap); + + switch (opc & (MO_SSIZE)) { + case MO_8: + tcg_out_opc_store(s, OPC_SB, base, lo, 0); + break; + case MO_16: + tcg_out_opc_store(s, OPC_SH, base, lo, 0); + break; + case MO_32: + tcg_out_opc_store(s, OPC_SW, base, lo, 0); + break; + case MO_64: + if (TCG_TARGET_REG_BITS == 64) { + tcg_out_opc_store(s, OPC_SD, base, lo, 0); + } else { + tcg_out_opc_store(s, OPC_SW, base, lo, 0); + tcg_out_opc_store(s, OPC_SW, base, hi, 4); + } + break; + default: + g_assert_not_reached(); + } +} + +static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) +{ + TCGReg addr_regl, addr_regh __attribute__((unused)); + TCGReg data_regl, data_regh; + TCGMemOpIdx oi; + TCGMemOp opc; +#if defined(CONFIG_SOFTMMU) + tcg_insn_unit *label_ptr[1]; +#endif + TCGReg base = TCG_REG_TMP0; + + data_regl = *args++; + data_regh = (TCG_TARGET_REG_BITS == 32 && is_64 ? *args++ : 0); + addr_regl = *args++; + addr_regh = (TCG_TARGET_REG_BITS < TARGET_LONG_BITS ? *args++ : 0); + oi = *args++; + opc = get_memop(oi); + +#if defined(CONFIG_SOFTMMU) + tcg_out_tlb_load(s, addr_regl, addr_regh, oi, label_ptr, 0); + tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); + add_qemu_ldst_label(s, 0, oi, + (is_64 ? TCG_TYPE_I64 : TCG_TYPE_I32), + data_regl, data_regh, addr_regl, addr_regh, + s->code_ptr, label_ptr); +#else + if (TCG_TARGET_REG_BITS > TARGET_LONG_BITS) { + tcg_out_ext32u(s, base, addr_regl); + addr_regl = base; + } + + if (guest_base == 0) { + tcg_out_opc_reg(s, OPC_ADD, base, addr_regl, TCG_REG_ZERO); + } else { + tcg_out_opc_reg(s, OPC_ADD, base, TCG_GUEST_BASE_REG, addr_regl); + } + tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); +#endif +} From patchwork Wed Dec 19 19:19:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738075 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA5861399 for ; Wed, 19 Dec 2018 19:34:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C9FBE1FE84 for ; Wed, 19 Dec 2018 19:34:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD05D280B0; Wed, 19 Dec 2018 19:34:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A4CCF1FE84 for ; Wed, 19 Dec 2018 19:34:40 +0000 (UTC) Received: from localhost ([::1]:33829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhc7-0006qm-S9 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:34:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46151) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhNb-0002lY-K4 for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:19:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhNW-0001Rn-Gr for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:19:39 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:29337) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhNV-0001QU-W3; Wed, 19 Dec 2018 14:19:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247174; x=1576783174; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=NxJ/LfV29xtF0fi0+/GmpHD5nDmzTuTvMI3SEs6PlbU=; b=MaUMYsJBw+JqyLInTf60S6DN4LAv10naKLt5ypwEOt1CkISyhY+WEH55 HCIB0mLh30qGACLK6gv8WcQhCDWbLTdXGJzZq2l9iCfBYMloxJs6u8Yx6 XXY8MaCRB6MqAgEBtpcs6BetZkDwK/ssrNDyZ59WX45yhsuf5U3B3//qx rnfoeZMMr0INlk5x3qSgYjyXP2gprEjdw+snjBSSfV7ZrPiLr+vzKCYIh AiFNbTU0XQ4ipOgffRJDpQDshG5HYd+Wm81KIyaFJvP/pC5fQNv8999xK dKfmMw04f6E4PfrAhtlMhLQ2xNYO9T262guh7ARcfBcLwD2ySWsNHSQUq w==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="97004248" Received: from mail-bn3nam01lp2054.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([104.47.33.54]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:19:31 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oLgoNnpqXFhOSgcLS/jRQBVRa7ZFSIf7Zf1Z9lECzrg=; b=nlXEun99sOAovXG5BQjh+lrJupRw82d/2XksTRXNvQFcnxzm+794sZ1sQtwFMwws9W4RE2ALbnWFQMXyWfOnGRO74DawVHi7cH9HL6vHp9DtjIoFYFPcAgmhGNNJkfDzZAY9c73hmYDvACFqKYrxr2C1VnrcEwrBowxTbNYnmgI= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0832.namprd04.prod.outlook.com (10.172.168.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.22; Wed, 19 Dec 2018 19:19:30 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:19:30 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 18/23] riscv: tcg-target: Add the out op decoder Thread-Index: AQHUl8/DshA6LoH+J0CkHLQMuP1SHw== Date: Wed, 19 Dec 2018 19:19:29 +0000 Message-ID: <7c47f00cb4a9a777120456e0704b4076a5d943ab.1545246859.git.alistair.francis@wdc.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR02CA0009.namprd02.prod.outlook.com (2603:10b6:a02:ee::22) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.171] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0832; 6:8vXwWhBsfrvxnvKYkNuO1hH8smaz6EcuHS8Uy+N3yIw430Vijgq6SNeCgq30AS6YLsmq7Hczeo/EtpKdohwsc1CtcNO2EdkPU8CDI72TeeKAsfMCUjoATxB5+T9lKvFxhOjwC2x9UL0qAnqKPRA2gOgKFIld/S1rHAN+zJOVL4MrVAiD07NJDjZBXmFNRLa813HMpQ1nso23wQW0bQok3RIWIr+akGphDJ96IRRChei7RkpSrNAKvSfOFUPpnRjC8SBq0kDgWewf6rL+QW0dLe5jzikyg0036PtlzO3bsNQV/bhQuQqQ2bKkWlT45n3PZ67ZTmr1Ce8Vhf2u6SUKYNun2jKmBEG8wnW0l2Y6AMa+zAHWytWwY0UPSnV7f4Ma1KM57t6dknOlog1ZHlN4P66ucNIsRNVMqhrbf4jNsknpQfQueFYu6VunqZ2s8jkulakfS7ro3M+5xqz3Mj95CA==; 5:XOi+FD76KURc9ND6CHqRKcVp2c+jua9HD0aAF/k5n86FarQCLALIiMHtFqt9NfbGPcOwjTWIEfbMkIEd7IwV5EE+pDsiI/FHRJIXAAflyi47OCMsEYv8EhFwTCdFUopJ2kYRnMysf4bDh2WeoVK6GHDXihdShHEe+q9S/owub90=; 7:sgzyMsYf9pHutjKgbOoQSizIs0hSptRhVbkDZ/ufyPKpjCtYeI16dC6+kLwhZB7jhXhLFtbN1D4R0y46pIYUH+FWHGocI+VESEJVbHqYmlMIHjuHdOALz2dMxvrv/YSa7FJG6IPgPQmYpnx1Q7eduw== x-ms-office365-filtering-correlation-id: 3694c66f-592b-401c-964b-08d665e6e61d x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0832; x-ms-traffictypediagnostic: MWHPR04MB0832: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(5005020)(6040522)(2401047)(8121501046)(3231475)(944501520)(52105112)(93006095)(93001095)(3002001)(10201501046)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0832; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0832; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(39860400002)(366004)(396003)(346002)(136003)(189003)(199004)(6506007)(68736007)(76176011)(386003)(102836004)(476003)(2616005)(44832011)(486006)(97736004)(118296001)(478600001)(316002)(26005)(6346003)(4326008)(110136005)(54906003)(186003)(39060400002)(53946003)(8676002)(50226002)(81166006)(86362001)(6512007)(52116002)(81156014)(53936002)(71200400001)(4744004)(99286004)(256004)(71190400001)(8936002)(446003)(11346002)(305945005)(7736002)(106356001)(6486002)(3846002)(6116002)(66066001)(25786009)(5660300001)(2906002)(72206003)(2501003)(14454004)(36756003)(6436002)(105586002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0832; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-microsoft-antispam-message-info: R0U9TD7jSHOGwks8OIwNf1JzsRYX/n7EbTCchxuaXSrfrKQiXvekCFDYzN6Fu69Z4TYZaXnFLs7SUL+wAX1stU0NrhGHlu/2aZBeVXm7TqMm+pUU6XLNNyJwntk6ofUY4NS8xYgEwT36HhV8OMTxRlfzi5Wq46oizcvmJBVIu0H4pQPxfMkvVlXYSy33cVoGVvqc0FVtB101Y5p5qzGAdGWt2XTyenPPrEpl3hiTaYWIbFMeX1yj+SSnhYaXGsiIbXyeesxnF+topXoCLDHo14s1rDTWSoA49jFy1f1VIfJ6PYkkxA6xSGvf3uIkxYkM spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3694c66f-592b-401c-964b-08d665e6e61d X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:19:29.9828 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0832 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.154.42 Subject: [Qemu-devel] [PATCH v2 18/23] riscv: tcg-target: Add the out op decoder X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Signed-off-by: Richard Henderson Reviewed-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 493 +++++++++++++++++++++++++++++++++++++ 1 file changed, 493 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index 154315787c..bab3d1e6d2 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -1309,3 +1309,496 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) tcg_out_qemu_st_direct(s, data_regl, data_regh, base, opc); #endif } + +static tcg_insn_unit *tb_ret_addr; + +static void tcg_out_op(TCGContext *s, TCGOpcode opc, + const TCGArg *args, const int *const_args) +{ + TCGArg a0 = args[0]; + TCGArg a1 = args[1]; + TCGArg a2 = args[2]; + int c2 = const_args[2]; + + switch (opc) { + case INDEX_op_exit_tb: + /* Reuse the zeroing that exists for goto_ptr. */ + if (a0 == 0) { + tcg_out_call_int(s, s->code_gen_epilogue, true); + } else { + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A0, a0); + tcg_out_call_int(s, tb_ret_addr, true); + } + break; + + case INDEX_op_goto_tb: + assert(s->tb_jmp_insn_offset == 0); + /* indirect jump method */ + tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_TMP0, TCG_REG_ZERO, + (uintptr_t)(s->tb_jmp_target_addr + a0)); + tcg_out_opc_imm(s, OPC_JALR, TCG_REG_ZERO, TCG_REG_TMP0, 0); + set_jmp_reset_offset(s, a0); + break; + + case INDEX_op_goto_ptr: + tcg_out_opc_imm(s, OPC_JALR, TCG_REG_ZERO, a0, 0); + break; + + case INDEX_op_br: + tcg_out_reloc(s, s->code_ptr, R_RISCV_JAL, arg_label(a0), 0); + tcg_out_opc_jump(s, OPC_JAL, TCG_REG_ZERO, 0); + break; + + case INDEX_op_ld8u_i32: + case INDEX_op_ld8u_i64: + tcg_out_ldst(s, OPC_LBU, a0, a1, a2); + break; + case INDEX_op_ld8s_i32: + case INDEX_op_ld8s_i64: + tcg_out_ldst(s, OPC_LB, a0, a1, a2); + break; + case INDEX_op_ld16u_i32: + case INDEX_op_ld16u_i64: + tcg_out_ldst(s, OPC_LHU, a0, a1, a2); + break; + case INDEX_op_ld16s_i32: + case INDEX_op_ld16s_i64: + tcg_out_ldst(s, OPC_LH, a0, a1, a2); + break; + case INDEX_op_ld32u_i64: + tcg_out_ldst(s, OPC_LWU, a0, a1, a2); + break; + case INDEX_op_ld_i32: + case INDEX_op_ld32s_i64: + tcg_out_ldst(s, OPC_LW, a0, a1, a2); + break; + case INDEX_op_ld_i64: + tcg_out_ldst(s, OPC_LD, a0, a1, a2); + break; + + case INDEX_op_st8_i32: + case INDEX_op_st8_i64: + tcg_out_ldst(s, OPC_SB, a0, a1, a2); + break; + case INDEX_op_st16_i32: + case INDEX_op_st16_i64: + tcg_out_ldst(s, OPC_SH, a0, a1, a2); + break; + case INDEX_op_st_i32: + case INDEX_op_st32_i64: + tcg_out_ldst(s, OPC_SW, a0, a1, a2); + break; + case INDEX_op_st_i64: + tcg_out_ldst(s, OPC_SD, a0, a1, a2); + break; + + case INDEX_op_add_i32: + if (c2) { + tcg_out_opc_imm(s, OPC_ADDIW, a0, a1, a2); + } else { + tcg_out_opc_reg(s, OPC_ADDW, a0, a1, a2); + } + break; + case INDEX_op_add_i64: + if (c2) { + tcg_out_opc_imm(s, OPC_ADDI, a0, a1, a2); + } else { + tcg_out_opc_reg(s, OPC_ADD, a0, a1, a2); + } + break; + + case INDEX_op_sub_i32: + if (c2) { + tcg_out_opc_imm(s, OPC_ADDIW, a0, a1, -a2); + } else { + tcg_out_opc_reg(s, OPC_SUBW, a0, a1, a2); + } + break; + case INDEX_op_sub_i64: + if (c2) { + tcg_out_opc_imm(s, OPC_ADDI, a0, a1, -a2); + } else { + tcg_out_opc_reg(s, OPC_SUB, a0, a1, a2); + } + break; + + case INDEX_op_and_i32: + case INDEX_op_and_i64: + if (c2) { + tcg_out_opc_imm(s, OPC_ANDI, a0, a1, a2); + } else { + tcg_out_opc_reg(s, OPC_AND, a0, a1, a2); + } + break; + + case INDEX_op_or_i32: + case INDEX_op_or_i64: + if (c2) { + tcg_out_opc_imm(s, OPC_ORI, a0, a1, a2); + } else { + tcg_out_opc_reg(s, OPC_OR, a0, a1, a2); + } + break; + + case INDEX_op_xor_i32: + case INDEX_op_xor_i64: + if (c2) { + tcg_out_opc_imm(s, OPC_XORI, a0, a1, a2); + } else { + tcg_out_opc_reg(s, OPC_XOR, a0, a1, a2); + } + break; + + case INDEX_op_not_i32: + case INDEX_op_not_i64: + tcg_out_opc_imm(s, OPC_XORI, a0, a1, -1); + break; + + case INDEX_op_neg_i32: + tcg_out_opc_reg(s, OPC_SUBW, a0, TCG_REG_ZERO, a1); + break; + case INDEX_op_neg_i64: + tcg_out_opc_reg(s, OPC_SUB, a0, TCG_REG_ZERO, a1); + break; + + case INDEX_op_mul_i32: + tcg_out_opc_reg(s, OPC_MULW, a0, a1, a2); + break; + case INDEX_op_mul_i64: + tcg_out_opc_reg(s, OPC_MUL, a0, a1, a2); + break; + + case INDEX_op_div_i32: + tcg_out_opc_reg(s, OPC_DIVW, a0, a1, a2); + break; + case INDEX_op_div_i64: + tcg_out_opc_reg(s, OPC_DIV, a0, a1, a2); + break; + + case INDEX_op_divu_i32: + tcg_out_opc_reg(s, OPC_DIVUW, a0, a1, a2); + break; + case INDEX_op_divu_i64: + tcg_out_opc_reg(s, OPC_DIVU, a0, a1, a2); + break; + + case INDEX_op_rem_i32: + tcg_out_opc_reg(s, OPC_REMW, a0, a1, a2); + break; + case INDEX_op_rem_i64: + tcg_out_opc_reg(s, OPC_REM, a0, a1, a2); + break; + + case INDEX_op_remu_i32: + tcg_out_opc_reg(s, OPC_REMUW, a0, a1, a2); + break; + case INDEX_op_remu_i64: + tcg_out_opc_reg(s, OPC_REMU, a0, a1, a2); + break; + + case INDEX_op_shl_i32: + if (c2) { + tcg_out_opc_imm(s, OPC_SLLIW, a0, a1, a2); + } else { + tcg_out_opc_reg(s, OPC_SLLW, a0, a1, a2); + } + break; + case INDEX_op_shl_i64: + if (c2) { + tcg_out_opc_imm(s, OPC_SLLI, a0, a1, a2); + } else { + tcg_out_opc_reg(s, OPC_SLL, a0, a1, a2); + } + break; + + case INDEX_op_shr_i32: + if (c2) { + tcg_out_opc_imm(s, OPC_SRLIW, a0, a1, a2); + } else { + tcg_out_opc_reg(s, OPC_SRLW, a0, a1, a2); + } + break; + case INDEX_op_shr_i64: + if (c2) { + tcg_out_opc_imm(s, OPC_SRLI, a0, a1, a2); + } else { + tcg_out_opc_reg(s, OPC_SRL, a0, a1, a2); + } + break; + + case INDEX_op_sar_i32: + if (c2) { + tcg_out_opc_imm(s, OPC_SRAIW, a0, a1, a2); + } else { + tcg_out_opc_reg(s, OPC_SRAW, a0, a1, a2); + } + break; + case INDEX_op_sar_i64: + if (c2) { + tcg_out_opc_imm(s, OPC_SRAI, a0, a1, a2); + } else { + tcg_out_opc_reg(s, OPC_SRA, a0, a1, a2); + } + break; + + case INDEX_op_add2_i32: + tcg_out_addsub2(s, a0, a1, a2, args[3], args[4], args[5], + const_args[4], const_args[5], false, true); + break; + case INDEX_op_add2_i64: + tcg_out_addsub2(s, a0, a1, a2, args[3], args[4], args[5], + const_args[4], const_args[5], false, false); + break; + case INDEX_op_sub2_i32: + tcg_out_addsub2(s, a0, a1, a2, args[3], args[4], args[5], + const_args[4], const_args[5], true, true); + break; + case INDEX_op_sub2_i64: + tcg_out_addsub2(s, a0, a1, a2, args[3], args[4], args[5], + const_args[4], const_args[5], true, false); + break; + + case INDEX_op_brcond_i32: + case INDEX_op_brcond_i64: + tcg_out_brcond(s, a2, a0, a1, arg_label(args[3])); + break; + case INDEX_op_brcond2_i32: + tcg_out_brcond2(s, args[4], a0, a1, a2, args[3], arg_label(args[5])); + break; + + case INDEX_op_setcond_i32: + case INDEX_op_setcond_i64: + tcg_out_setcond(s, args[3], a0, a1, a2); + break; + case INDEX_op_setcond2_i32: + tcg_out_setcond2(s, args[5], a0, a1, a2, args[3], args[4]); + break; + + case INDEX_op_qemu_ld_i32: + tcg_out_qemu_ld(s, args, false); + break; + case INDEX_op_qemu_ld_i64: + tcg_out_qemu_ld(s, args, true); + break; + case INDEX_op_qemu_st_i32: + tcg_out_qemu_st(s, args, false); + break; + case INDEX_op_qemu_st_i64: + tcg_out_qemu_st(s, args, true); + break; + + case INDEX_op_ext8u_i32: + case INDEX_op_ext8u_i64: + tcg_out_ext8u(s, a0, a1); + break; + + case INDEX_op_ext16u_i32: + case INDEX_op_ext16u_i64: + tcg_out_ext16u(s, a0, a1); + break; + + case INDEX_op_ext32u_i64: + case INDEX_op_extu_i32_i64: + tcg_out_ext32u(s, a0, a1); + break; + + case INDEX_op_ext8s_i32: + case INDEX_op_ext8s_i64: + tcg_out_ext8s(s, a0, a1); + break; + + case INDEX_op_ext16s_i32: + case INDEX_op_ext16s_i64: + tcg_out_ext16s(s, a0, a1); + break; + + case INDEX_op_ext32s_i64: + case INDEX_op_extrl_i64_i32: + case INDEX_op_extrh_i64_i32: + case INDEX_op_ext_i32_i64: + tcg_out_ext32s(s, a0, a1); + break; + + case INDEX_op_mulsh_i32: + case INDEX_op_mulsh_i64: + tcg_out_opc_reg(s, OPC_MULH, a0, a1, a2); + break; + + case INDEX_op_muluh_i32: + case INDEX_op_muluh_i64: + tcg_out_opc_reg(s, OPC_MULHU, a0, a1, a2); + break; + + case INDEX_op_mb: + tcg_out_mb(s, a0); + break; + + case INDEX_op_mov_i32: /* Always emitted via tcg_out_mov. */ + case INDEX_op_mov_i64: + case INDEX_op_movi_i32: /* Always emitted via tcg_out_movi. */ + case INDEX_op_movi_i64: + case INDEX_op_call: /* Always emitted via tcg_out_call. */ + default: + g_assert_not_reached(); + } +} + +static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) +{ + static const TCGTargetOpDef r + = { .args_ct_str = { "r" } }; + static const TCGTargetOpDef r_r + = { .args_ct_str = { "r", "r" } }; + static const TCGTargetOpDef rZ_r + = { .args_ct_str = { "rZ", "r" } }; + static const TCGTargetOpDef rZ_rZ + = { .args_ct_str = { "rZ", "rZ" } }; + static const TCGTargetOpDef rZ_rZ_rZ_rZ + = { .args_ct_str = { "rZ", "rZ", "rZ", "rZ" } }; + static const TCGTargetOpDef r_r_ri + = { .args_ct_str = { "r", "r", "ri" } }; + static const TCGTargetOpDef r_r_rI + = { .args_ct_str = { "r", "r", "rI" } }; + static const TCGTargetOpDef r_rZ_rN + = { .args_ct_str = { "r", "rZ", "rN" } }; + static const TCGTargetOpDef r_rZ_rZ + = { .args_ct_str = { "r", "rZ", "rZ" } }; + static const TCGTargetOpDef r_rZ_rZ_rZ_rZ + = { .args_ct_str = { "r", "rZ", "rZ", "rZ", "rZ" } }; + static const TCGTargetOpDef r_L + = { .args_ct_str = { "r", "L" } }; + static const TCGTargetOpDef r_r_L + = { .args_ct_str = { "r", "r", "L" } }; + static const TCGTargetOpDef r_L_L + = { .args_ct_str = { "r", "L", "L" } }; + static const TCGTargetOpDef r_r_L_L + = { .args_ct_str = { "r", "r", "L", "L" } }; + static const TCGTargetOpDef LZ_L + = { .args_ct_str = { "LZ", "L" } }; + static const TCGTargetOpDef LZ_L_L + = { .args_ct_str = { "LZ", "L", "L" } }; + static const TCGTargetOpDef LZ_LZ_L + = { .args_ct_str = { "LZ", "LZ", "L" } }; + static const TCGTargetOpDef LZ_LZ_L_L + = { .args_ct_str = { "LZ", "LZ", "L", "L" } }; + static const TCGTargetOpDef r_r_rZ_rZ_rM_rM + = { .args_ct_str = { "r", "r", "rZ", "rZ", "rM", "rM" } }; + + switch (op) { + case INDEX_op_goto_ptr: + return &r; + + case INDEX_op_ld8u_i32: + case INDEX_op_ld8s_i32: + case INDEX_op_ld16u_i32: + case INDEX_op_ld16s_i32: + case INDEX_op_ld_i32: + case INDEX_op_not_i32: + case INDEX_op_neg_i32: + case INDEX_op_ld8u_i64: + case INDEX_op_ld8s_i64: + case INDEX_op_ld16u_i64: + case INDEX_op_ld16s_i64: + case INDEX_op_ld32s_i64: + case INDEX_op_ld32u_i64: + case INDEX_op_ld_i64: + case INDEX_op_not_i64: + case INDEX_op_neg_i64: + case INDEX_op_ext8u_i32: + case INDEX_op_ext8u_i64: + case INDEX_op_ext16u_i32: + case INDEX_op_ext16u_i64: + case INDEX_op_ext32u_i64: + case INDEX_op_extu_i32_i64: + case INDEX_op_ext8s_i32: + case INDEX_op_ext8s_i64: + case INDEX_op_ext16s_i32: + case INDEX_op_ext16s_i64: + case INDEX_op_ext32s_i64: + case INDEX_op_extrl_i64_i32: + case INDEX_op_extrh_i64_i32: + case INDEX_op_ext_i32_i64: + return &r_r; + + case INDEX_op_st8_i32: + case INDEX_op_st16_i32: + case INDEX_op_st_i32: + case INDEX_op_st8_i64: + case INDEX_op_st16_i64: + case INDEX_op_st32_i64: + case INDEX_op_st_i64: + return &rZ_r; + + case INDEX_op_add_i32: + case INDEX_op_and_i32: + case INDEX_op_or_i32: + case INDEX_op_xor_i32: + case INDEX_op_add_i64: + case INDEX_op_and_i64: + case INDEX_op_or_i64: + case INDEX_op_xor_i64: + return &r_r_rI; + + case INDEX_op_sub_i32: + case INDEX_op_sub_i64: + return &r_rZ_rN; + + case INDEX_op_mul_i32: + case INDEX_op_mulsh_i32: + case INDEX_op_muluh_i32: + case INDEX_op_div_i32: + case INDEX_op_divu_i32: + case INDEX_op_rem_i32: + case INDEX_op_remu_i32: + case INDEX_op_setcond_i32: + case INDEX_op_mul_i64: + case INDEX_op_mulsh_i64: + case INDEX_op_muluh_i64: + case INDEX_op_div_i64: + case INDEX_op_divu_i64: + case INDEX_op_rem_i64: + case INDEX_op_remu_i64: + case INDEX_op_setcond_i64: + return &r_rZ_rZ; + + case INDEX_op_shl_i32: + case INDEX_op_shr_i32: + case INDEX_op_sar_i32: + case INDEX_op_shl_i64: + case INDEX_op_shr_i64: + case INDEX_op_sar_i64: + return &r_r_ri; + + case INDEX_op_brcond_i32: + case INDEX_op_brcond_i64: + return &rZ_rZ; + + case INDEX_op_add2_i32: + case INDEX_op_add2_i64: + case INDEX_op_sub2_i32: + case INDEX_op_sub2_i64: + return &r_r_rZ_rZ_rM_rM; + + case INDEX_op_brcond2_i32: + return &rZ_rZ_rZ_rZ; + + case INDEX_op_setcond2_i32: + return &r_rZ_rZ_rZ_rZ; + + case INDEX_op_qemu_ld_i32: + return TARGET_LONG_BITS <= TCG_TARGET_REG_BITS ? &r_L : &r_L_L; + case INDEX_op_qemu_st_i32: + return TARGET_LONG_BITS <= TCG_TARGET_REG_BITS ? &LZ_L : &LZ_L_L; + case INDEX_op_qemu_ld_i64: + return TCG_TARGET_REG_BITS == 64 ? &r_L + : TARGET_LONG_BITS <= TCG_TARGET_REG_BITS ? &r_r_L + : &r_r_L_L; + case INDEX_op_qemu_st_i64: + return TCG_TARGET_REG_BITS == 64 ? &LZ_L + : TARGET_LONG_BITS <= TCG_TARGET_REG_BITS ? &LZ_LZ_L + : &LZ_LZ_L_L; + + default: + return NULL; + } +} From patchwork Wed Dec 19 19:19:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738045 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DAA376C2 for ; Wed, 19 Dec 2018 19:29:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CAA5E27F8F for ; Wed, 19 Dec 2018 19:29:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE0BD27F91; Wed, 19 Dec 2018 19:29:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 2AC4427F8F for ; Wed, 19 Dec 2018 19:29:02 +0000 (UTC) Received: from localhost ([::1]:33787 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhWf-0002ME-Bo for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:29:01 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46188) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhNj-0002s4-Iz for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:19:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhNf-0001ky-Ho for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:19:47 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:29352) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhNf-0001h7-8K; Wed, 19 Dec 2018 14:19:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247183; x=1576783183; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=3vPFoJPNQi/eJF2e40JeKIaLPr+hYoPgfhUwDa1mM/4=; b=XcJw+CfOb4Z6jpdEvT3HGh397slEEeTuNWoypgwDq/v11vpMOTXvXmqs NakJmOODNiQtsQPuaMxPzL5BSJWVI92kIZLf8Ws9kLDhM8ewTi4qNmZ56 YFkkd50844S3VtQt5k8ZKgc5pxOFBaZpJksgNnw2cCVGAisvxtJrIj0cB USrhM08vj9IWA8aBkTKOvDtKkAyenoTrxPAxdahJvf5PKryRsjodW4HvQ kV2aqjJxhwm3+VPVtc+2dHSBqigHCBUbddF8wVtV3FpLEfDKUiNVqBOgs qKsEcabXQJJPgb6qA6y2P42y8D92uFvQI1/H3UyujBDZGBMyQU8ZiPX3p A==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="97004266" Received: from mail-bn3nam01lp2053.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([104.47.33.53]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:19:41 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jFTwdiIXyeMSeUDmBBDIXrTwF2YlYI4NVSZIsK4aSdw=; b=ZseeC66RaxeNufKiAURPiKIATZGj+1YMUqmlUI2QQXwwJRtJ8BwBTwmYdbyLOqzhedn8WadHVs00si0+lzbv6rKdYvknx19ny7LKiTXoeqc0c0GmlEUJGoZzqo84dVBm92LJAVFBW/CDKYwcOfK9TwRtbXky5sNmg5V0b4UUdsE= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0832.namprd04.prod.outlook.com (10.172.168.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.22; Wed, 19 Dec 2018 19:19:40 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:19:40 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 19/23] riscv: tcg-target: Add the prologue generation and register the JIT Thread-Index: AQHUl8/J3Aj/E5/ipECw4D5l9EIGrw== Date: Wed, 19 Dec 2018 19:19:39 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR02CA0008.namprd02.prod.outlook.com (2603:10b6:a02:ee::21) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.171] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0832; 6:XRHZr3sG314sU4LJSft1mISlndNZxOboy93cPoekzUFhURN7aTwLH8Ank+Ryxc3SD26mgweXD/mLXg24bue2dy8GPlJQVm4Jhkg2NrYxX8NJvDtbRaUDgU+dwfMuFm86Y8Js2nYVg7+B31PnvGUz9OhbAWYYJmikWWvPFzEsqNzTsbQAbiw36MeSAsgNwpr+sgo/lxrdOfI6NcLkK/BCAFmyyqS/sRFo0zoIf+6Rr4xk/nv1IF9uaxAEOJu75kJC1ue0TuIpxkyD/9Rhohdm6nL1CRr+Qgbr+oGprC/H6ZjMNu7WJQUe0rZSzwER5eDMqM9ueZD6XFKPAkBkur0CZZXW1VH434BTxHxXvhUpXKlOXHdJvNGpe282gJPEFOdnsQjQYpXz9qzAdqPGFgmyCt4E8d2qgCKFZ+7ocyUFEZEUvGHDjETTRFrN5OtiyO3z6h5/zUQtSmkP+HiCyNB8ng==; 5:uryDswWfFh4mWsol80vLBpItPMrW4NNwEauKyNsVhGQe28EwgHPD1TaraNS9o+IrtwXTwPwUYISn694XnXirtBNL0OAKJNvZ7YFQStt07oT45le7goJTXc+NWDnuuWnEkHlUTAYmZ/2UtWHoWVFwsXIkVzyerZCLxWoLhfrU0XA=; 7:JF+ClrXQptELI0JPzWSRUxYxlg+PxqT8LW3Al3ZKfb4xsNVLcH186tvcc/JURhNXWLRc4cXxTHvrrrhK9RDsj1ie4MIsSPKIwljksxqe2dOlVcRClzBHbuo136+Iq1asQuNZQoFZQBv2lVI7zQBZhA== x-ms-office365-filtering-correlation-id: 6ca16d60-fd5c-4b3b-22db-08d665e6ec0d x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0832; x-ms-traffictypediagnostic: MWHPR04MB0832: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(5005020)(6040522)(2401047)(8121501046)(3231475)(944501520)(52105112)(93006095)(93001095)(3002001)(10201501046)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0832; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0832; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(39860400002)(366004)(396003)(346002)(136003)(189003)(199004)(6506007)(68736007)(76176011)(386003)(102836004)(476003)(2616005)(44832011)(486006)(97736004)(118296001)(478600001)(316002)(26005)(6346003)(4326008)(110136005)(54906003)(186003)(39060400002)(8676002)(50226002)(81166006)(86362001)(6512007)(52116002)(81156014)(53936002)(71200400001)(99286004)(256004)(71190400001)(8936002)(446003)(11346002)(305945005)(7736002)(106356001)(6486002)(3846002)(6116002)(66066001)(25786009)(5660300001)(2906002)(72206003)(2501003)(14454004)(36756003)(6436002)(105586002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0832; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-microsoft-antispam-message-info: 21QxAJjtFtLXdWArCIifIy4dK9mJjl8mrkohEIG2yzsS7tJ623pOtUfi7w6MkFB6E0JZ6ac6HStASETkhBsceu1HBXsdGqSv+l03fqPUikk9E28DYpIIC2V2ap0t1M+CTaTlXI6hke46hUi0ruC6Ht0wlbejdLLckeWDqwNpvqoIWNWLNiJWe/CwDHJL0z0qjrlAtjz0gC+/zvvpDq3k6NZHORXoDwgyLqFy9UxI75ksfIHFLQo/9OzWOGRQYkYCAoEZno/Q2o0VxKcvnn/yy/ITCKQAySlZDUV101/XnLycURCfnSVVV7lEyeh1WNIA spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ca16d60-fd5c-4b3b-22db-08d665e6ec0d X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:19:39.9003 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0832 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.154.42 Subject: [Qemu-devel] [PATCH v2 19/23] riscv: tcg-target: Add the prologue generation and register the JIT X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Reviewed-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 111 +++++++++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index bab3d1e6d2..bc1a2bc4ab 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -1802,3 +1802,114 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) return NULL; } } + +static const int tcg_target_callee_save_regs[] = { + TCG_REG_S0, /* used for the global env (TCG_AREG0) */ + TCG_REG_S1, + TCG_REG_S2, + TCG_REG_S3, + TCG_REG_S4, + TCG_REG_S5, + TCG_REG_S6, + TCG_REG_S7, + TCG_REG_S8, + TCG_REG_S9, + TCG_REG_S10, + TCG_REG_S11, + TCG_REG_RA, /* should be last for ABI compliance */ +}; + +/* Stack frame parameters. */ +#define REG_SIZE (TCG_TARGET_REG_BITS / 8) +#define SAVE_SIZE ((int)ARRAY_SIZE(tcg_target_callee_save_regs) * REG_SIZE) +#define TEMP_SIZE (CPU_TEMP_BUF_NLONGS * (int)sizeof(long)) +#define FRAME_SIZE ((TCG_STATIC_CALL_ARGS_SIZE + TEMP_SIZE + SAVE_SIZE \ + + TCG_TARGET_STACK_ALIGN - 1) \ + & -TCG_TARGET_STACK_ALIGN) +#define SAVE_OFS (TCG_STATIC_CALL_ARGS_SIZE + TEMP_SIZE) + +/* We're expecting to be able to use an immediate for frame allocation. */ +QEMU_BUILD_BUG_ON(FRAME_SIZE > 0x7ff); + +/* Generate global QEMU prologue and epilogue code */ +static void tcg_target_qemu_prologue(TCGContext *s) +{ + int i; + + tcg_set_frame(s, TCG_REG_SP, TCG_STATIC_CALL_ARGS_SIZE, TEMP_SIZE); + + /* TB prologue */ + tcg_out_opc_imm(s, OPC_ADDI, TCG_REG_SP, TCG_REG_SP, -FRAME_SIZE); + for (i = 0; i < ARRAY_SIZE(tcg_target_callee_save_regs); i++) { + tcg_out_st(s, TCG_TYPE_REG, tcg_target_callee_save_regs[i], + TCG_REG_SP, SAVE_OFS + i * REG_SIZE); + } + +#if !defined(CONFIG_SOFTMMU) + tcg_out_movi(s, TCG_TYPE_PTR, TCG_GUEST_BASE_REG, guest_base); + tcg_regset_set_reg(s->reserved_regs, TCG_GUEST_BASE_REG); +#endif + + /* Call generated code */ + tcg_out_mov(s, TCG_TYPE_PTR, TCG_AREG0, tcg_target_call_iarg_regs[0]); + tcg_out_opc_imm(s, OPC_JALR, TCG_REG_ZERO, tcg_target_call_iarg_regs[1], 0); + + /* Return path for goto_ptr. Set return value to 0 */ + s->code_gen_epilogue = s->code_ptr; + tcg_out_mov(s, TCG_TYPE_REG, TCG_REG_A0, TCG_REG_ZERO); + + /* TB epilogue */ + tb_ret_addr = s->code_ptr; + for (i = 0; i < ARRAY_SIZE(tcg_target_callee_save_regs); i++) { + tcg_out_ld(s, TCG_TYPE_REG, tcg_target_callee_save_regs[i], + TCG_REG_SP, SAVE_OFS + i * REG_SIZE); + } + + tcg_out_opc_imm(s, OPC_ADDI, TCG_REG_SP, TCG_REG_SP, FRAME_SIZE); + tcg_out_opc_imm(s, OPC_JALR, TCG_REG_ZERO, TCG_REG_RA, 0); +} + +typedef struct { + DebugFrameHeader h; + uint8_t fde_def_cfa[4]; + uint8_t fde_reg_ofs[ARRAY_SIZE(tcg_target_callee_save_regs) * 2]; +} DebugFrame; + +#define ELF_HOST_MACHINE EM_RISCV + +static const DebugFrame debug_frame = { + .h.cie.len = sizeof(DebugFrameCIE) - 4, /* length after .len member */ + .h.cie.id = -1, + .h.cie.version = 1, + .h.cie.code_align = 1, + .h.cie.data_align = -(TCG_TARGET_REG_BITS / 8) & 0x7f, /* sleb128 */ + .h.cie.return_column = TCG_REG_RA, + + /* Total FDE size does not include the "len" member. */ + .h.fde.len = sizeof(DebugFrame) - offsetof(DebugFrame, h.fde.cie_offset), + + .fde_def_cfa = { + 12, TCG_REG_SP, /* DW_CFA_def_cfa sp, ... */ + (FRAME_SIZE & 0x7f) | 0x80, /* ... uleb128 FRAME_SIZE */ + (FRAME_SIZE >> 7) + }, + .fde_reg_ofs = { + 0x80 + 9, 12, /* DW_CFA_offset, s1, -96 */ + 0x80 + 18, 11, /* DW_CFA_offset, s2, -88 */ + 0x80 + 19, 10, /* DW_CFA_offset, s3, -80 */ + 0x80 + 20, 9, /* DW_CFA_offset, s4, -72 */ + 0x80 + 21, 8, /* DW_CFA_offset, s5, -64 */ + 0x80 + 22, 7, /* DW_CFA_offset, s6, -56 */ + 0x80 + 23, 6, /* DW_CFA_offset, s7, -48 */ + 0x80 + 24, 5, /* DW_CFA_offset, s8, -40 */ + 0x80 + 25, 4, /* DW_CFA_offset, s9, -32 */ + 0x80 + 26, 3, /* DW_CFA_offset, s10, -24 */ + 0x80 + 27, 2, /* DW_CFA_offset, s11, -16 */ + 0x80 + 1 , 1, /* DW_CFA_offset, ra, -8 */ + } +}; + +void tcg_register_jit(void *buf, size_t buf_size) +{ + tcg_register_jit_int(buf, buf_size, &debug_frame, sizeof(debug_frame)); +} From patchwork Wed Dec 19 19:19:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738085 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4D33514E2 for ; Wed, 19 Dec 2018 19:42:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3485E28517 for ; Wed, 19 Dec 2018 19:42:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2864828526; Wed, 19 Dec 2018 19:42:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9FAAC28517 for ; Wed, 19 Dec 2018 19:42:58 +0000 (UTC) Received: from localhost ([::1]:33886 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhk9-0004Yd-OY for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:42:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhNt-00031J-NO for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:19:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhNp-00021K-PE for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:19:57 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:29366) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhNp-0001z0-Cp; Wed, 19 Dec 2018 14:19:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247193; x=1576783193; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=6dTaVrWDZrdrGhHmsDGhElvsiZxKoK0fM6IP0OO6jNY=; b=Ggr0sixwEmtbTZTkya2Jf9Vw/PmvOpXS0kPxneGrz48+ib333cVsqsLo R86YYBKj+JKCuuQ3QQwsGwP0AHAs6GJ4oonkOwWmS3D6HRSw7tm5GiaZn a9EHC59teXjDrpUR5BpRcKe4zuS2aA3gDM6XuA36QBBnpHQXeXIxVgvRY ary6yWTMpX0sTLtOUwCgxMhoZrQQ8XEJQfWs9eVmfrlVvi0Cz67/PGDMw 0NrSDc+yw7Ds7HjvGvCuvINrf9GZZ+qTHJCQwoJPgViM8CWaoMilh35H/ 47ioCixA/rzigXn8Vef1tHAx5wm1/RbDQDbKGpWiPlq0lMuZltqxQRevp A==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="97004272" Received: from mail-bn3nam01lp2058.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([104.47.33.58]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:19:51 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1Or/TU8JuGF75Hf01ciUsh21qASFfQbIVhGKWJgUeXY=; b=T0PeYSV49/HTJGU9whaIciRYfzieOGu0HbDLRE3tzIAbNBGp9eFEjBbGoNLbTvmqQn4Vvq12rq9/ttwJSg24UQX4D8mPxWjxOOFzLsaTB+rq1b1+DEZxuYJwZesPd+hv03S+/hPBEGkiSF+yjDKBj0cO10IDpegqpFBR23t4RgI= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0832.namprd04.prod.outlook.com (10.172.168.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.22; Wed, 19 Dec 2018 19:19:50 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:19:50 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 20/23] riscv: tcg-target: Add the target init code Thread-Index: AQHUl8/P2QjuKfXVMUazzXJugerYag== Date: Wed, 19 Dec 2018 19:19:49 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR02CA0005.namprd02.prod.outlook.com (2603:10b6:a02:ee::18) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.171] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0832; 6:Koula++WGZSZiMt9ZpYv8nW7sgKkp2w+7HhbE+YEsgVALtgCrs9otSX6el94aC/OVfybwuEj13EGmgiI62QxyoIG31tZLglGAoMUqQUohp9azD+Nf3PQElLMzovCpmc1hTml1mp90MmSQS0Q9L4AgXEUkBg4H7UqJYlBUiNMuTGQ8Cn7d0cecAbHq/ZM3Myh1VOyfBbRSlYJecyssA6zDPwSFodkYb2gQ4EJQNqcO5Qy2tQ+3DcJ6YAVMNLsYhnRkoeXKFqbbOuM81QpyZZwh8SzB3uFuMVl45aCoavkMHPLtlk0Y/1bS0CzLxV1CpMUvL7BTMdSd6WdRYp3kpFiRnvum2Dnmv6XE1Kp73x0BwAIWbPY9WeLQFbRLuJMB1hXs1DrFk9fbxvSi5mftu9ojCnEVaR/dVuXaXdo95H6/fkB3XFtPyJYYrt2ymRoUnSIkjccrNxAm+lLbKh64mnKYQ==; 5:O51DuEY6HA8qBnhQkQHQGsKz2pDU5Z8AFdPPl/myOHjxqplLmM28+Tkj0TTRmKlJPS8etSce4fjRxjiX+WUUN+jZXBVYXqCsM84ab82GykzVe2yxkp6yfghLQJv1wFk5EUyvqZUsHWDi/cOURq86XdrqlriZN0wqfScv63xlhLs=; 7:FWIagoWMVvd6UBozdsDZz7kVYQDxr1jte/c74BLldbHscIhmdmHXNgqTCQWWDBUgu9C3LYWLd5eXp8uTTKdgUqLyxD0Rkox8tRm65z3L/U7nJLEXK/FsxVAEtyU9DHN0o91hlt+IkzAtYf2pDw5UUw== x-ms-office365-filtering-correlation-id: ac09e947-7946-43ca-5605-08d665e6f202 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0832; x-ms-traffictypediagnostic: MWHPR04MB0832: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(5005020)(6040522)(2401047)(8121501046)(3231475)(944501520)(52105112)(93006095)(93001095)(3002001)(10201501046)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0832; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0832; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(39860400002)(366004)(396003)(346002)(136003)(189003)(199004)(6506007)(68736007)(76176011)(386003)(102836004)(476003)(2616005)(44832011)(486006)(97736004)(118296001)(478600001)(316002)(26005)(6346003)(4326008)(110136005)(54906003)(186003)(39060400002)(8676002)(50226002)(81166006)(86362001)(6512007)(52116002)(81156014)(53936002)(71200400001)(99286004)(256004)(71190400001)(8936002)(446003)(11346002)(305945005)(7736002)(106356001)(6486002)(3846002)(6116002)(66066001)(25786009)(5660300001)(2906002)(72206003)(2501003)(14454004)(36756003)(6436002)(105586002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0832; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-microsoft-antispam-message-info: CzpmRQxet3W3l5s1tlEZa5fbuFra1+zmI73boYveWX9NdcQi14pdI7+x2BzDEdMZkenKeEcV9Zvu0m2Xitg1bQ73u0C/k8l9W+y8PDP8GY9y1C98IAlkEzPEQawfxrYLYZ8L02A1wWbAOwepgSJTIJWItOyTDXZQWroLqSOzC1UrbK5/ROFhyURr454mJz5gnO/2hxG1vODoIXgZoZKVDN66SC723fhwBUIsqn/JDNBGk85eZuAnT+ymHYTrZUul3gABkRVAIntbtGu9haRZXvB3moTWH/MUE11Nxvy9xgxN0e8Q5dwka4gT6wz3jYoE spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: ac09e947-7946-43ca-5605-08d665e6f202 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:19:49.8668 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0832 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.154.42 Subject: [Qemu-devel] [PATCH v2 20/23] riscv: tcg-target: Add the target init code X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Reviewed-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index bc1a2bc4ab..f718542d63 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -1869,6 +1869,37 @@ static void tcg_target_qemu_prologue(TCGContext *s) tcg_out_opc_imm(s, OPC_JALR, TCG_REG_ZERO, TCG_REG_RA, 0); } +static void tcg_target_init(TCGContext *s) +{ + tcg_target_available_regs[TCG_TYPE_I32] = 0xffffffff; + if (TCG_TARGET_REG_BITS == 64) { + tcg_target_available_regs[TCG_TYPE_I64] = 0xffffffff; + } + + tcg_target_call_clobber_regs = -1u; + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S0); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S1); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S2); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S3); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S4); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S5); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S6); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S7); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S8); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S9); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S10); + tcg_regset_reset_reg(tcg_target_call_clobber_regs, TCG_REG_S11); + + s->reserved_regs = 0; + tcg_regset_set_reg(s->reserved_regs, TCG_REG_ZERO); + tcg_regset_set_reg(s->reserved_regs, TCG_REG_TMP0); + tcg_regset_set_reg(s->reserved_regs, TCG_REG_TMP1); + tcg_regset_set_reg(s->reserved_regs, TCG_REG_TMP2); + tcg_regset_set_reg(s->reserved_regs, TCG_REG_SP); + tcg_regset_set_reg(s->reserved_regs, TCG_REG_GP); + tcg_regset_set_reg(s->reserved_regs, TCG_REG_TP); +} + typedef struct { DebugFrameHeader h; uint8_t fde_def_cfa[4]; From patchwork Wed Dec 19 19:19:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738071 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7B02514DE for ; Wed, 19 Dec 2018 19:31:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CAF428433 for ; Wed, 19 Dec 2018 19:31:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6AA8628475; Wed, 19 Dec 2018 19:31:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BA0CF28433 for ; Wed, 19 Dec 2018 19:31:58 +0000 (UTC) Received: from localhost ([::1]:33810 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhZV-0004kE-Jj for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:31:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46333) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhO3-000398-9W for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:20:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhNy-0002Ch-VB for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:20:07 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:16010) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhNy-0002BP-LT; Wed, 19 Dec 2018 14:20:02 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247202; x=1576783202; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=d/vgDPhfzdcDSncbcj6SM70p3CgdU/kMp06loHl8EIc=; b=nWV4nodydaTNalT1GQnFvC68Y1WSyhuXr5BIt7rRjYV4GfEyvbPMj1p5 O1RuwxM6dMTwHwOMvK5G6lVDzs0ZDFanloD4xHkM49/WFfma4yrOfv4iV 0npIs7dhcDuaiKetv+gzbAONum70waaOO2gPhbGMtllwoMeMyMyGYPYDd pKhCISfZ7sr+sFHuvXqOKGCJfSZSuX9BRtwTiWzJBl8bbRDCQ+pjT/dzr w3t/lpYXmfo2Bk+M0067G+t/7LpWpzst+r38HL/NrUB1R+EQ5FqCej01i jGdLiPkHVsc7yhq8l3gsTTHjzjLHUzJLkEP0CKOBfNdR4D+bvIrRCeuxK Q==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="101924004" Received: from mail-bn3nam01lp2058.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([104.47.33.58]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:20:01 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yPUJaM0wWZHLTYVfZkTyHnHTkJnpg2ybHbfiWpabKRI=; b=ZplGtExzLXuhzmIi1dD+oFYkvTnwi5/LW6u8zEMUCaZJe96GuIoLmy3a0Rhi8RNNsQKb1ndelSqMBP3PAxgYCMMetpGJGcbVXXdZhdx2KwNhFyz78qAj803UQiLXdRBw5F6651i9CNJNGhTr2PV6aTAQnQqZRS6e8VbbNtQd1Pg= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0832.namprd04.prod.outlook.com (10.172.168.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.22; Wed, 19 Dec 2018 19:19:59 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:19:59 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 21/23] tcg: Add RISC-V cpu signal handler Thread-Index: AQHUl8/Vbe7+X9ITxEaF6HexsGi2mw== Date: Wed, 19 Dec 2018 19:19:59 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR02CA0034.namprd02.prod.outlook.com (2603:10b6:a02:ee::47) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.171] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0832; 6:qMlQtSCqr2rO61dDnVM4rf+6amBxEdi6SXBZDfTYvVByWQ2haslKdEYFV1TMFgmGaMN/gX+cleSFlANpJ7fgpaSFOKOK7jjLKZBtAQPCZ0K+OZRmfcRGDJDPi2iLrm4mqq4YQl1XbX7ox8ND80Sy8TNKtj77QB7Vgv2nqHkDx2RaS/lGKIqtLq15g5wg8pP0D0WjCQf5cX2GpGazaV1A4lXT2KkzUglOPkqU/o65+EbYD0xMCO/ygN/UjvVd+RJGBLAILzB03kY/IKPKuYwpLzCTvI5vxRIg0SketnacZJ97OJcYf5flFxh8aMuqfBEcLrU8lReelAPg1azgncZbvuwUvP2uflhMl75JOHUIcAVWycg5elcOrfUnGfBw/AtNEuaVwKaiZrG3UXnM4zl28TX1vL8BD3OJ8FBzNR9GW+4At8Hjenyuavsx+lvrKNRj+s6kKiyV6wi0iIdgOaYEoA==; 5:uRCFaOi7MkXvhqMWLGBSx6nCLf34fKyRZCoq/zfmWoEXWhm9o/+DWHnJa1hcrJ83Ibqt29MA0Nhq9+cGr0IMgR0L8rqwalgASXb4kgnihihE8hxuwX0chfdGShFuKkEXCsIRoodlcDFcoYKDIu/Arx5tfZocolfWh3UCB8Llm5U=; 7:kuMDEECRwx6nEpOAIVSk56TXf2R5Yi6nTCzIIGTZswv++z8zzW7BX1/7LAgMggH0RP1NIsVLdi5o/5PJQSlBjTVUnkEhRTSJzGir85m0Ckn0KqwyAayI2HcsFaiWIrLInPFN3zRZw86np1GdAuM3uQ== x-ms-office365-filtering-correlation-id: ded837a4-abfb-4c1e-e791-08d665e6f79b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0832; x-ms-traffictypediagnostic: MWHPR04MB0832: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(5005020)(6040522)(2401047)(8121501046)(3231475)(944501520)(52105112)(93006095)(93001095)(3002001)(10201501046)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0832; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0832; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(39860400002)(366004)(396003)(346002)(136003)(189003)(199004)(6506007)(68736007)(76176011)(386003)(102836004)(476003)(2616005)(44832011)(486006)(97736004)(118296001)(478600001)(316002)(26005)(6346003)(4326008)(110136005)(54906003)(186003)(39060400002)(8676002)(50226002)(81166006)(86362001)(6512007)(52116002)(81156014)(53936002)(71200400001)(99286004)(256004)(71190400001)(14444005)(8936002)(446003)(11346002)(305945005)(7736002)(106356001)(6486002)(3846002)(6116002)(66066001)(25786009)(5660300001)(2906002)(72206003)(2501003)(14454004)(36756003)(6436002)(105586002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0832; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-microsoft-antispam-message-info: cBCaGvYIEuEvTzj+dgiFCMpF3LW18sLp47H++dkpwvWHi1Wh7qP/ENsAhYx0DJFLxyjWgBXinNtALzF9fbo8kebLbXiwmdo6u5mSaunN50KC4BYYca7Lwrx3fhHOzh8VY1VsNToFxsZ5ZUIJ1fAa2fZqfnpYO9LkW9UPcRpVc3zgzaIM+HtsZMgDbrBL6Qw9Qm8q2AI2yw9r7t8kCYMMEUiQ47H4cZ2MgOaB3CkUI2f5Jmw6eJA9I01obM6PqGh+siJ7mESSzCQ40CWtyXNccnRCQPejFqWxnVr3dAaVwWxsf3KCtIYSi2e4UDnfi0U4 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: ded837a4-abfb-4c1e-e791-08d665e6f79b X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:19:59.2879 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0832 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.141 Subject: [Qemu-devel] [PATCH v2 21/23] tcg: Add RISC-V cpu signal handler X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark --- accel/tcg/user-exec.c | 75 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/accel/tcg/user-exec.c b/accel/tcg/user-exec.c index cd75829cf2..941295ea49 100644 --- a/accel/tcg/user-exec.c +++ b/accel/tcg/user-exec.c @@ -571,6 +571,81 @@ int cpu_signal_handler(int host_signum, void *pinfo, return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask); } +#elif defined(__riscv) + +int cpu_signal_handler(int host_signum, void *pinfo, + void *puc) +{ + siginfo_t *info = pinfo; + ucontext_t *uc = puc; + greg_t pc = uc->uc_mcontext.__gregs[REG_PC]; + uint32_t insn = *(uint32_t *)pc; + int is_write = 0; + + /* Detect store by reading the instruction at the program + counter. Note: we currently only generate 32-bit + instructions so we thus only detect 32-bit stores */ + switch (((insn >> 0) & 0b11)) { + case 3: + switch (((insn >> 2) & 0b11111)) { + case 8: + switch (((insn >> 12) & 0b111)) { + case 0: /* sb */ + case 1: /* sh */ + case 2: /* sw */ + case 3: /* sd */ + case 4: /* sq */ + is_write = 1; + break; + default: + break; + } + break; + case 9: + switch (((insn >> 12) & 0b111)) { + case 2: /* fsw */ + case 3: /* fsd */ + case 4: /* fsq */ + is_write = 1; + break; + default: + break; + } + break; + default: + break; + } + } + + /* Check for compressed instructions */ + switch (((insn >> 13) & 0b111)) { + case 7: + switch (insn & 0b11) { + case 0: /*c.sd */ + case 2: /* c.sdsp */ + is_write = 1; + break; + default: + break; + } + break; + case 6: + switch (insn & 0b11) { + case 0: /* c.sw */ + case 3: /* c.swsp */ + is_write = 1; + break; + default: + break; + } + break; + default: + break; + } + + return handle_cpu_signal(pc, info, is_write, &uc->uc_sigmask); +} + #else #error host CPU specific signal handler needed From patchwork Wed Dec 19 19:20:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738079 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 16F281399 for ; Wed, 19 Dec 2018 19:37:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0815927FB7 for ; Wed, 19 Dec 2018 19:37:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EFCD228385; Wed, 19 Dec 2018 19:37:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7A2A027FB7 for ; Wed, 19 Dec 2018 19:37:28 +0000 (UTC) Received: from localhost ([::1]:33852 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhep-0000Pa-LU for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:37:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46400) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhOM-0003OV-1C for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:20:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhOD-0002SR-T5 for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:20:23 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:23477) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhOA-0002NO-4U; Wed, 19 Dec 2018 14:20:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247214; x=1576783214; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=dZyIXaB23ol9DPb8iJaaW8AfzMrq5ZbzM2reXdDor2g=; b=Rg/rI3hDZtsGmbw4vmb+lIuwIdNffhyTPzHPl6GkF7oZjBz7gARl+hCL jJhKVrx8eG9+CBATYJtZDO3oyZMgeudP8RkJaPVn0lLrhPS5a8N+MXSX0 yHw4amReBhIaL+csGLSuuc1IEg1OWTzsattQc5kmXH/2W5dtFITo76jbw LxfuX325A8/2UyjqUYC5a/Vt2xGBqYlx9GTZTSW+vekKcN/OAFEZFcGMu Nu237VbGpuKSv3E+W2smAvj9QHYwMY0u2zlUbxoqBWqlgqB9yK1aO08Td ClCmHJOyA53CbyFSPql8Ir5wv/hGE97IlBVx9Dqls3YMgItBBWJOd9Xvh Q==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="201718538" Received: from mail-sn1nam02lp2053.outbound.protection.outlook.com (HELO NAM02-SN1-obe.outbound.protection.outlook.com) ([104.47.36.53]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:20:11 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8FVwTkJOpMmudwtXo3e2FtfvebHWPYIt57WwLmoO1GU=; b=gWOE+S3YRyn/ZH5oJLkoRai5zGLBbq/L7U05nQpGHwApk5Nb3BKHEFu6jB2Mit5aKVYwwzjPgxBn3EuwlgcM45/E7c5xUPO5jk6i848bLEVaYO5kJv2AfUaRtNMrvVy6LBf/pS4ohtwqF3WUt3VZR/SXG6hozXSdKSa0vtp4A5o= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0848.namprd04.prod.outlook.com (10.172.168.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1446.19; Wed, 19 Dec 2018 19:20:09 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:20:09 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 22/23] dias: Add RISC-V support Thread-Index: AQHUl8/b1SDF76zm30ybsLvCas49QQ== Date: Wed, 19 Dec 2018 19:20:09 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR02CA0016.namprd02.prod.outlook.com (2603:10b6:a02:ee::29) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.171] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0848; 6:SCFfBO2+PdCrC9CiTo9pid9+knbPCB074n2q8/Av5HpY70ExpQyBNuBhx/GTkdU3DRvmvBzqVMd6gBf+c1UgI0qfxq+xu+OFqSDXPAfNFWLQ3B6ntwPzoGkfGYiEsA6HxrF1CNS+VmvHYVBkoVK1sV17Mf9Z/GpZ6NTcsdOJR+Otwz7hwsIxZ81XKZBXeoI4FENSpiT1uPQzswdQqSpglC5wj1kutSDaIf552XnvylO8WeyGg4vPaQW0IzC/lcw0OMwv13RBv3GGYC+WCPMY/WA/FFIw/OGcfALRHAtUduCMuVlnk/GOk3AGdAbli2D0ywM5VdQwABqPh28Cfv+oOjPHgRmqNPevoJifwsTGplkSDywEd+L45Ff/tl8i8vtbq+NH7Ula1vD58jShD7OnJf38gDXUujnt/+b5QMlN5cAwzgFxvLkyzCE2AiKAD2k80k/lzUZwj+OnfKAjM6SQEw==; 5:G/ZVTyCd2WLFldZ9YMxM+syuy9XghszzJvOh231XMfwfIBGwS0qvJixn0rytGEbEZk5MsihK6jRymjte9XOZovNBKRo4JxuJ9a3r3Ssu1+MPZ7kobftlSlPS8BHPaZGZ+cXvBRtwtWj0HKV7iul2Xg+8o/TOeBofEjnHWauwZiA=; 7:miEw3J4ateO5du/+JnI7i13N1tX5ZIdM3pN2s2CxMHAo5gmx1xm4e5cBl+PTwkp0+ZzYmlIkyIaRW1Vo2iL9q47miexY1oxtD/sF8M1IH9ta9XvUk9FnRTyD5UhmfwJ8XQf8sbMRLpotV+AlVe2V1A== x-ms-office365-filtering-correlation-id: 3e1793cf-838d-4130-4e09-08d665e6fdc9 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0848; x-ms-traffictypediagnostic: MWHPR04MB0848: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231475)(944501520)(52105112)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0848; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0848; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(39860400002)(396003)(346002)(366004)(376002)(199004)(189003)(6486002)(14454004)(4326008)(72206003)(8936002)(86362001)(2501003)(50226002)(71190400001)(71200400001)(97736004)(6436002)(8676002)(81156014)(81166006)(36756003)(68736007)(25786009)(5660300001)(478600001)(118296001)(105586002)(53936002)(256004)(305945005)(7736002)(6512007)(316002)(44832011)(39060400002)(66066001)(54906003)(110136005)(2906002)(52116002)(6116002)(76176011)(26005)(186003)(102836004)(99286004)(486006)(446003)(476003)(6506007)(11346002)(2616005)(3846002)(106356001)(386003); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0848; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: JqRXrhWqgz2LiozpYPfELGYdKPWZ67Q5dFgYxcPiAtXB8+JibK7kZ14ax05OGwbHMMRyK+Cq7021D6cd4LiWnyy0uww3GrMHoHl6EO4+fTXRwBM4NbPlX/FU3EBAsC/S7JMEeORiwNRS0X/q9yKNVIQaVKN1r1rb83WcAZcHWArgVcLqRd6+cUU83o7/eM65nQqTdGeZez1IB+lfFRFA0z6/WACvZXjXsVra8bWIPwCHVNKRyiKAN0MV+PRUt4iX5/pM7x/mvM/qrJrsE/blF0c34HO9QZpTE9CI6jjXOh1+ANO22UlmLX1B2fXXwF0t spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e1793cf-838d-4130-4e09-08d665e6fdc9 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:20:09.7188 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0848 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 68.232.141.245 Subject: [Qemu-devel] [PATCH v2 22/23] dias: Add RISC-V support X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Reviewed-by: Richard Henderson --- disas.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/disas.c b/disas.c index f9c517b358..d9aa713a40 100644 --- a/disas.c +++ b/disas.c @@ -522,8 +522,14 @@ void disas(FILE *out, void *code, unsigned long size) # ifdef _ARCH_PPC64 s.info.cap_mode = CS_MODE_64; # endif -#elif defined(__riscv__) - print_insn = print_insn_riscv; +#elif defined(__riscv) && defined(CONFIG_RISCV_DIS) +#if defined(_ILP32) || (__riscv_xlen == 32) + print_insn = print_insn_riscv32; +#elif defined(_LP64) + print_insn = print_insn_riscv64; +#else +#error unsupported RISC-V ABI +#endif #elif defined(__aarch64__) && defined(CONFIG_ARM_A64_DIS) print_insn = print_insn_arm_a64; s.info.cap_arch = CS_ARCH_ARM64; From patchwork Wed Dec 19 19:20:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738081 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 807BE14E2 for ; Wed, 19 Dec 2018 19:40:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7142328484 for ; Wed, 19 Dec 2018 19:40:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F266284B1; Wed, 19 Dec 2018 19:40:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D536D28484 for ; Wed, 19 Dec 2018 19:40:29 +0000 (UTC) Received: from localhost ([::1]:33871 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhhl-0002wl-5C for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:40:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46469) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhOS-0003Y5-AY for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:20:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhOO-0002kZ-CX for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:20:32 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:29398) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhOM-0002Xm-8Q; Wed, 19 Dec 2018 14:20:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247226; x=1576783226; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=cifM7+QZSxT+Xm4VrK61LpvQUw0BzuPQTL+3kMoQjTk=; b=PdY/gvHzFg0tw9omG5WejPPzFO9wTI5cx2bP1e7EEyCwv4z5Sj8hQq8y nyBXnoqUui0IwMVtOVe6ppsBXid21uQPxe2Zn1A5shJriurVGpE/prEWW tlCdNqWRps9g/epDSvXAofQwGi9kFxkAtG+BvEmiTEGFuo6z+xAFQpRxx GePfoaPaE1gYSNLwBmDHPNoAA2ba5nV9u4OzTAtF+jcbacZ7vqQtTtKNs ZnOOqwCZIDcUoCWtw2cYJ08jqu6cGDV6p/f3vpTZfbt1LtHppVBKOt4kj T9O/XpMJ4O0B+CjOv+3vdI8D4ZqTE8iJynGx+4oZIQatXbVeEiQiJAF4P A==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="97004300" Received: from mail-bl2nam02lp2059.outbound.protection.outlook.com (HELO NAM02-BL2-obe.outbound.protection.outlook.com) ([104.47.38.59]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:20:20 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hTqWVB/1HVm61WQw746JdeLfa7/qZE4su+fiwonvwkc=; b=fC01SWazCeGntPZUizL0UBax9YQRxZMfPZrRdvwj1D1GFrFPuakpmGxBpJhNB2sI6sJQugjnwqftB5W5by9VsEDuwX3IdTmFGWwdv8x6XlNv0BJp4q/ioNvL/XZ83+7LLONsY3zN3lZ6O5qXec0oQCjnqOv95qyNT2V9y/8jLjM= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0848.namprd04.prod.outlook.com (10.172.168.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1446.19; Wed, 19 Dec 2018 19:20:19 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:20:19 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 23/23] configure: Add support for building RISC-V host Thread-Index: AQHUl8/hq5Ag0gF5fEO7/QC+sBgPkA== Date: Wed, 19 Dec 2018 19:20:19 +0000 Message-ID: <52160afacecc5b109dc43a412fa3e74ddd6277fb.1545246859.git.alistair.francis@wdc.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR03CA0003.namprd03.prod.outlook.com (2603:10b6:a02:a8::16) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.171] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0848; 6:85ZkKIdWN5VVa37kNlKJB90Xz80sa5U76P+HEmGExl6JHZMT4bIB3b/tqghyGMddNDT8W+RN5zl0CCCUTaCL+JEmCWr8K0wo/MuYKnW/cwbza0X5QYzHRpjtvf+JKk5ARXaYJKlMDn4dLRtEJtIa8cgkS+oe2IJGMssp6sjwnDVPQ3SzesNIVVFnDwcXtkgWEQvufmiYJnrrNQdroGG8DstKLQSF6n/TlF4J/Y37ehUd/P4B095SwV7wLXCo1HwOf3NrHPU4SUSs5ucsaHrUFtwaG4ZU6vFaGOhM0AR3Hs2ZnqFEe4ey6r8miuOO0SwiM01P/pVpOwkRbHbqVDeIIIoIGcU7VDWDaP+Ta3hnxwyhao2Ciaa9R4Vc/PKqzihxTFH+xJaXIkwAHT5GUIZ0PindhMisGg3Clm/LtHuZDiP5Mehy/hKb+eJ5nyhXS/vRw9N/3Oneww8h1uoaR2bgGg==; 5:NlSmJzZtJA5XQsRSEABi5Ssbzgehl6/ivW4LOOuob1B3adncdjzHi3KIEuGyf6XgaY59NoiZR6z9kiYluS3F4gbIEpvbfoH1YgWHQC1XvxIlO561xtjTdynTs+CnLDMq5sK6tgEP2pbl7p2CrcvvW+TEY0Mc8OlYqMxlv98b3KU=; 7:f7zsppaeK4OonmLipixEtO/0WQuO37JIyp9xAFB6Te9jasA61TbtqrIq1qZHTTkNu5b2mwOomYZmhS7CLhkytW64vUPOYKaOTc9ijCuC6HosG6QzVO1bJnywDI+x6PT6t1kfkpo2u7eXxLKHjnVYVg== x-ms-office365-filtering-correlation-id: 7c7e54f5-b365-41ca-941b-08d665e7036b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0848; x-ms-traffictypediagnostic: MWHPR04MB0848: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231475)(944501520)(52105112)(6055026)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0848; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0848; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(136003)(39860400002)(396003)(346002)(366004)(376002)(199004)(189003)(6486002)(14454004)(4326008)(72206003)(8936002)(86362001)(2501003)(50226002)(71190400001)(71200400001)(97736004)(6436002)(8676002)(81156014)(81166006)(36756003)(68736007)(25786009)(5660300001)(478600001)(118296001)(105586002)(53936002)(256004)(305945005)(7736002)(6512007)(316002)(44832011)(39060400002)(66066001)(54906003)(110136005)(2906002)(52116002)(6116002)(76176011)(26005)(186003)(102836004)(99286004)(486006)(446003)(476003)(6506007)(11346002)(2616005)(3846002)(106356001)(386003); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0848; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: e30XaBJcvaD6qVBOwRIPUL7Ib+zwQxHtAYc/cdmaK5hnps6OEgmtPkd5om6Xg6gpia0IGTYquqiA3OAYcJLs+5m2isiMroguYI+U4KjWhq2ex1jfZGwVP4DOe1aJRCdPzATQXBCSNDQaOqh5Z96a2wle85+o8AEbj2OBuf70yojEjZ+Bg/6KjlFWhREd5Na8VYDax/278DfzavSn0nVLHadGvhsSAicYxiNCKilaNpDnwV3rEU3rJOF1NzzdfZ6ZgLH0EWHl5Li8PQZx5F93SHeSd8saI7ZPrlAbf99cMhEAXE9oiOCtBxJG5SoeX+32 spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7c7e54f5-b365-41ca-941b-08d665e7036b X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:20:19.0968 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0848 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.154.42 Subject: [Qemu-devel] [PATCH v2 23/23] configure: Add support for building RISC-V host X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Reviewed-by: Richard Henderson --- configure | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 224d3071ac..79375affc1 100755 --- a/configure +++ b/configure @@ -710,6 +710,12 @@ elif check_define __s390__ ; then else cpu="s390" fi +elif check_define __riscv ; then + if check_define _LP64 ; then + cpu="riscv64" + else + cpu="riscv32" + fi elif check_define __arm__ ; then cpu="arm" elif check_define __aarch64__ ; then @@ -722,7 +728,7 @@ ARCH= # Normalise host CPU name and set ARCH. # Note that this case should only have supported host CPUs, not guests. case "$cpu" in - ppc|ppc64|s390|s390x|sparc64|x32) + ppc|ppc64|s390|s390x|sparc64|x32|riscv32|riscv64) cpu="$cpu" supported_cpu="yes" eval "cross_cc_${cpu}=\$host_cc" @@ -6937,6 +6943,8 @@ elif test "$ARCH" = "x86_64" -o "$ARCH" = "x32" ; then QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/i386 $QEMU_INCLUDES" elif test "$ARCH" = "ppc64" ; then QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/ppc $QEMU_INCLUDES" +elif test "$ARCH" = "riscv32" -o "$ARCH" = "riscv64" ; then + QEMU_INCLUDES="-I\$(SRC_PATH)/tcg/riscv $QEMU_INCLUDES" else QEMU_INCLUDES="-iquote \$(SRC_PATH)/tcg/\$(ARCH) $QEMU_INCLUDES" fi @@ -7433,7 +7441,7 @@ for i in $ARCH $TARGET_BASE_ARCH ; do ppc*) disas_config "PPC" ;; - riscv) + riscv*) disas_config "RISCV" ;; s390*)