From patchwork Tue Nov 27 21:06:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10701403 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 583E3109C for ; Tue, 27 Nov 2018 21:08:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 490D12B8AB for ; Tue, 27 Nov 2018 21:08:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3CD892BEC0; Tue, 27 Nov 2018 21:08: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 4F88E2BEA7 for ; Tue, 27 Nov 2018 21:08:28 +0000 (UTC) Received: from localhost ([::1]:44469 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkap-00057u-FQ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:08:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35873) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkZJ-0002x4-Kr for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:06:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkZG-0003Yr-Ex for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:06:53 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:22155) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkZG-0003Xy-6F; Tue, 27 Nov 2018 16:06:50 -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=1543352811; x=1574888811; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=mF4O0+bfADNh8fzyDt27zpjmLYs6qg05LJuV8MMK3Jo=; b=n3M81PSa0PdDtzirfIiwBoECt60Ua7sQFLuU0uGdF2ZuAh1mvFwNnECj R4NTnnEfZ1L1GmDLqW0rPk5rPesl3Dg2QFFwc3MAdhL/Hb1oK2ShGctuy wtjlQoJXN0IIDxsdW2F/ON9cwyIeWIrbwdBDGWn1Wf2S0VyqrcpZvsoMx n3t/khrr+UnPQCNrrh4bspQfFf8tTPO7Udi3W6PCyGTogNJhIp/3xZ3+x 8wG44unguRyEEBYZFGnSuVYWTaUoCE/P/Lt8eQh/5GrniFaUthr3Qrpbp FoimHF+XeGo2Bz/GgREPu5ZqC14J4Qvg2+WTs6v/C6FWwD8v4xLFfpLHl w==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="96433549" Received: from mail-sn1nam04lp0087.outbound.protection.outlook.com (HELO NAM04-SN1-obe.outbound.protection.outlook.com) ([216.32.180.87]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:06:47 +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=EaZGw4deS5CnBw4vx0tn0n86CwDZnZpXwautlJJltlc40RGb+lzPI6RjxnmYwyMHEdUo4ZN09uMyllZCtR40yFsUAc0gOatpRFhu3CE5PxMi7I9Wrxnk0aSTS7xcL8TUdRBqlQD1G8Lb6lhO2poJhq1O7HyJwJ/JdZ4nl1gs/9w= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0943.namprd04.prod.outlook.com (10.174.174.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.19; Tue, 27 Nov 2018 21:06:45 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:06:45 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 01/24] elf.h: Add the RISCV ELF magic numbers Thread-Index: AQHUhpUaPn1fUwK+HUqXbGkEA5TunA== Date: Tue, 27 Nov 2018 21:06:45 +0000 Message-ID: <29787dcf10591f4f1dfc637ea61634dec7b6d260.1543352682.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: BYAPR11CA0081.namprd11.prod.outlook.com (2603:10b6:a03:f4::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; MWHPR04MB0943; 6:kkQm06MwSO228RdB7s+o7ECO26v87ZRk8mL2+BobUFcTLniDeYUBEjlPh08xNUD36VStuJeJzKHFrBkpDiUcqMJ16CSg6A2xZAbcwhf0eWryk+K+OKwcajiAfuD4Bi3Lu3SHxIJ9zdANgsUtIraXQX/NHuvEA1pHZl9bJLunJOCEEZrjDg7Ar51VzP8VX+tEos00t6jlhgXuZXQkPKmKUf21UO/5rcGmfwsEeIZDMT7cLKuSTbJE2TNc94kgpPFcgEQXAGS6hXGQ22qyvEnFqi2BR/Mc/7IhvYooO+KNLUuuk3CBv4XFiAfD3HE/k7MXvY3hH9Uv3k/rGlFwhLPWq1Fd9ScAS4KfqeDe7BEqYFRnuz0hOzMJ6M298aNBWml6hA1bPH9cfEpQV3lpVcPl7dSTrI6OBbQOy19Oqwhd0QLSmd+G2o7oALtOQQjybRESA5jT9v9CQ3m/3HC/rTUH2g==; 5:yz7se4vE5UqEQZVPyiGKTSOK08iaijjpRUn6KuyuZUQwxsdhGLNDXxzEcJf5ybVNC7dloWXcFj7drsB8JovzjEcckmRnZK/e9DfHmtTLHOgdQuHQiemkdhiI/dQuVyAyGuih/a+pwDsYvmndvm3g5aCbEZqnaSN3q4xRIH4l0Oo=; 7:J+9ZuszkvZppHcTWSXBMrPDRtmdrCuodY0E0HOcamubfQo54SKIzvmlxVwNS1ha/H13k9X8ht/YV/rJaAsV3mUrIUoZAYaB3O3w1t3e4LwSq16dm/PyHfCCtYnK5IihjpzZMsYuux3UOux+fI0lpXQ== x-ms-office365-filtering-correlation-id: 5c0a4faf-d030-4455-e64c-08d654ac3cb2 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0943; x-ms-traffictypediagnostic: MWHPR04MB0943: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3231443)(944501410)(52105112)(3002001)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0943; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0943; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(39860400002)(346002)(366004)(376002)(136003)(189003)(199004)(14454004)(97736004)(5660300001)(2501003)(4326008)(81156014)(81166006)(8936002)(256004)(6512007)(316002)(53936002)(8676002)(39060400002)(110136005)(217873002)(7736002)(305945005)(118296001)(575784001)(36756003)(3846002)(86362001)(6116002)(54906003)(11346002)(68736007)(99286004)(76176011)(52116002)(2616005)(446003)(72206003)(66066001)(26005)(486006)(44832011)(71200400001)(71190400001)(386003)(6486002)(50226002)(6436002)(25786009)(102836004)(186003)(476003)(105586002)(6506007)(2906002)(106356001)(478600001); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0943; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: frflz+KvXSGClKPW5dURCqWzNWRav7Ekh8ZSUZHrL2trqxx042gdPdrz0Cno7lbunpRGOS+aCARzYRj/eONwqYneVIRLMGrgIEPV9GA/GS1zATclHf+Pt286VJAeI8HbfHthdLkYApnCTbA3fBAuSkmgRVweH+HzyZQ1Qg8cBahU5VzVz3HIZlVUehEIkw4FTnPx+JNKOzRgYHBMeHQIYyXAcBQNW2oo2SzEQPwWLh4g0KC6r2yabKzHz+xdOA1GfrsVK0/RFOIabjLsjfmdtx7WXgrrdaB/ppBRGNDsXXA6Dwvv+L0OB0N4Tp72dOEoOSs+t7P+cCtAlzGvzZh0vAPWCcdxg5ctDITcU7E67ZI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5c0a4faf-d030-4455-e64c-08d654ac3cb2 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:06:45.1938 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0943 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.144 Subject: [Qemu-devel] [RFC v2 01/24] 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 Tue Nov 27 21:06:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10701405 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 9D9CC14BD for ; Tue, 27 Nov 2018 21:08:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AE3B2BE23 for ; Tue, 27 Nov 2018 21:08:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8A9CE2BE30; Tue, 27 Nov 2018 21:08: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 20C482BE23 for ; Tue, 27 Nov 2018 21:08:39 +0000 (UTC) Received: from localhost ([::1]:44470 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkb0-0005IX-91 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:08:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkZQ-0002zg-N8 for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:07:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkZN-0003at-Hw for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:07:00 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:54720) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkZN-0003aW-9E; Tue, 27 Nov 2018 16:06:57 -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=1543352906; x=1574888906; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=9FjaewiIWv3DlY/L+0Jr3j1n+bRh59qBen4rVUzH5uU=; b=fukD0hoC8hrKh6Md2IOYEGITlLmvRGKVCHlW2+whwYXbrvdrMtY+VY9B WJ6648AJgiLluhz2Uyj1nf46Jq43vgHp+BBv5e5USWminuZvjJLQ6gfVb sFvz+R4KwYRnO6CI3msZ6v6gNk3WAJj12GA7E6htrcwBNJKOclp6PWKkV bbhDIDJUs/T9pyA754aRRnUwpJB7nWhVY7IeRf+F1Q/A40RjmOIRKRc56 Mt7IKOMPxYwTsAvTFYIUs3hdacXQnbkcss93v0+WZsxqEyHw7ZyFEpSSX hea6PcR76n9GxkIKggwY9IWLl4nKhKRN7AOioDcQVEj2bj1KqC4pKa5xb Q==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="193052734" Received: from mail-by2nam05lp0242.outbound.protection.outlook.com (HELO NAM05-BY2-obe.outbound.protection.outlook.com) ([216.32.181.242]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:08:24 +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=9FjaewiIWv3DlY/L+0Jr3j1n+bRh59qBen4rVUzH5uU=; b=OhSnm5vOUiMJlgwyAF7wrBxlcllCx/nwMAY1w1nbqYTw4NMF48N95rvJTsDqEMstwuatwR/5lFc+mP3BmyvGVueSODo0GtMcHtbex7KQWdK0HYr8rEc8nQ5CNIhmd6t9gd4mz5TRjNeOxwB5RVNZYj5DsgTkAe8s+DWxDxf83Jc= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0943.namprd04.prod.outlook.com (10.174.174.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.19; Tue, 27 Nov 2018 21:06:54 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:06:54 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 02/24] linux-user: Add host dependency for RISC-V 32-bit Thread-Index: AQHUhpUfSQy+cgquQU61b2U0puOaXQ== Date: Tue, 27 Nov 2018 21:06:54 +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: BYAPR11CA0096.namprd11.prod.outlook.com (2603:10b6:a03:f4::37) 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; MWHPR04MB0943; 6:SXNGrI8i3JzWwL9UAXYXU4QuuIjzx+DqoZLcFwHlR77T/Q3dCDXaO9BxLx5N6XxDpQcx3NNmoQ23u7QyA7yARA9EUq29XVPajS28lFnAarSFTfpih5/MA01UQaYODuOIHDY1/W6rgbvXxRsHRkcfgieGWB2y9jihta2K1PLkOaUQrBg0namy2KsJw6TCyHoiGhdmIjBItYFWixhU0vKkEd2ql+dm5Zd9YKUBXKrNUvQelaW8KVp0aPRc61iODKRzQoAmchMCeWIas65yojbfbCMRPKwQmUSo629FggsWYnDfjhFz/zwWLpzMRDJHHnf6tYrIc582trd3MpSQdL8C+M6SSEVWTWnhfxb4vRrK5HVtBQF89Aq811WCE7IRydYWkMVLqrjmEbDCRje6ldmd7967VyG3tHZIrzOW0p/wxUGJiiGvjfilNgwSb/+zfcWkE3qdjTkUW9nalWpA9oI4aQ==; 5:38srLB1VH+4eULIAMwWltzvzIJISU04i7gYAij5ZlkE/uZNJ5+uqCPhoHC9bwM1aIlLDlRMcni3bfhZFFCZqZ2KG0E3qOgsVSqMedwj920D2XsI6mRSTKMwhueS9T6IRNEzepNQ5WoQMumH2Ot6jNZ5tMmMPagh2nomBVB1MH2E=; 7:PrObd/pWvJ8PR5vlD9ijKc7ql0Jn5YLB1YJevCF5hpqDXYGQXkKA/sStb1N+3Su5q34E6HED4i2cOd+5b9eUyY+jLpURZmHhaOJ306thzS9LEyyGHzx7rq62xd0bxQhHPVMWAcj4CTNl/eA6/4zUug== x-ms-office365-filtering-correlation-id: 7cfda542-2731-45b9-aeb3-08d654ac4206 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0943; x-ms-traffictypediagnostic: MWHPR04MB0943: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3231443)(944501410)(52105112)(3002001)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0943; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0943; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(39860400002)(346002)(366004)(376002)(136003)(189003)(199004)(14454004)(97736004)(5660300001)(2501003)(4326008)(81156014)(81166006)(8936002)(256004)(6512007)(316002)(53936002)(8676002)(39060400002)(110136005)(7736002)(305945005)(118296001)(36756003)(3846002)(86362001)(6116002)(54906003)(11346002)(68736007)(99286004)(76176011)(52116002)(2616005)(446003)(72206003)(66066001)(26005)(486006)(44832011)(71200400001)(71190400001)(386003)(6486002)(50226002)(6436002)(25786009)(102836004)(186003)(476003)(105586002)(6506007)(2906002)(106356001)(478600001); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0943; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: VsWhOsTxpEmlsrXByqcDEWy9HyEeaZY1sdV66UMWGC6wpy5tYF953+IgOaJm/KkPDgpMtCYHlj5ah5C3rWGp+yYSza8COge3tDgQTUTspTquDn/9nI62YYKxfMdCps/zrBRaYj9NCSDlxbfU+Aof4JnrI/Ed8CNqc4HA48cO2rMufK8V39kqvWo5OxU5EKd7M2RsLxIHtP2ZpcMpr+m5IHF3o8TMjMTVfukZTcoRTeo77HSPEfbZdxo0ND8xe0C+vjQe0OGvyh9we5pRkcYjTUUCtGMI01C8AZZVg94UtOZFZECbw6ouhwW9AeQyGvssvPLSMAkHVdwGzcp+4Nmj8W6OxQFhK4zInD9VKFCMgZc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7cfda542-2731-45b9-aeb3-08d654ac4206 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:06:54.1627 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0943 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 68.232.143.124 Subject: [Qemu-devel] [RFC v2 02/24] 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 --- linux-user/host/riscv32/hostdep.h | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 linux-user/host/riscv32/hostdep.h 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 Tue Nov 27 21:07:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10701411 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 DFD6B109C for ; Tue, 27 Nov 2018 21:11:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D0A022C819 for ; Tue, 27 Nov 2018 21:11:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C56E12C82C; Tue, 27 Nov 2018 21:11:29 +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 490EE2C819 for ; Tue, 27 Nov 2018 21:11:29 +0000 (UTC) Received: from localhost ([::1]:44491 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkdk-0007dv-92 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:11:28 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkZc-00036i-4D for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:07:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkZY-0003fG-VU for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:07:12 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:12604) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkZY-0003eP-Dh; Tue, 27 Nov 2018 16:07:08 -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=1543352829; x=1574888829; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=muuHqix0+OSrOzgGMh6gAE6a9JiMOf60o3iU9lL6gks=; b=l2bsJ5PpCQgTD/8j8/nIC570gwxb09q9TTycLkkCO6rdRvvBYYnwvDSW PMDC07Pn72hpaUvz12rshw8oxDbDf0M90Tab3BK0Jpy67oOA0f5iM/siC V3G4/JseqS+l2j2bqiElne07KOOECY88ETSY5MKBBCV//Z9mPmdlX2s3I 9f8DfWRIKXcdrCvmaTH+KnP65aBrlz2wizxpnPmR0Ci2gxbLsK3pb72JI OcEyjpUlxICith8pEr/kTsMziZlERvOKtFMvPP5AMHHCuknwUL4DScgIh BvXJdbxCHXtA3AqY85T/qTgwKxxtTsyfPgEwWs0fulGrPMQQZmMqUksnq A==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="95244762" Received: from mail-by2nam05lp0247.outbound.protection.outlook.com (HELO NAM05-BY2-obe.outbound.protection.outlook.com) ([216.32.181.247]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:07: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=muuHqix0+OSrOzgGMh6gAE6a9JiMOf60o3iU9lL6gks=; b=jY5LYhFMby6ERe0SvpasKoT2KfdCTfi6OYeQOxCjCbRMrRXOswcNNf1MVlQRKr1w0PC9nFdekixPNwqJnsqcBIfM9P1cBMJbGP2dLXNhFbO7N6iJ3u6GDKYQ+GXe3uI+8N/aGiLcUbR9vRJG/f0XyQCbloNOup63pEF4va9f2P8= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0993.namprd04.prod.outlook.com (10.174.250.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.14; Tue, 27 Nov 2018 21:07:03 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:07:03 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 03/24] linux-user: Add host dependency for RISC-V 64-bit Thread-Index: AQHUhpUlDLgbiRBgtkS9xTuANjCimA== Date: Tue, 27 Nov 2018 21:07:03 +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: BYAPR11CA0103.namprd11.prod.outlook.com (2603:10b6:a03:f4::44) 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; MWHPR04MB0993; 6:RYLSZ8bz/Kq3EOs3YefCpzTuHvyJW+McTAWykxGS5JnfNhbU9ZVcNfkKHj57C8P2ST5wDtxJoqhmTcORVYYqOtxdZdtDvKPaXlK4nH0TOlJpHqyPZD46rjwzlgVE2yyqsAyEgRYVKbaHz+ZZXGpKzFhOjny4NnxSDvl9Tie5vUGsCEOzf8Z5j5asYEtCKLtSC4S+tFQ7G2w/pwWfuo5oHhZ5pRXdgrrm212/PF6F5hX/u+YquyyWUVNfdKoAVE9V+46mJmjNsHFzjLiYQtkp+79cka5HBRtMK7j+r+2jW7RnYg1Dpg8//ZwYu/7IlT+vmwQL2+dFK/Huxmkyf3iX+A3soaAN5wmwG6rcHBmr+8S/30zV6hjJ99TuvOA5cBly78eVlRUOW7wU/T9QqGVf9GXpF0cE1q3CF24Ey1FQp5aZqkCn5MbD26u6Ci++zJZx06obnQxhImGk518qx8btIg==; 5:1kjX7OnRntc9USYX/1eE43usNNTy2ARZBDi8/eVLLRwzRFklIkJSFgw8A4o0FnJyMFqm5aaH/rEUybw7Qh2a+8Kyms0dI0vimR/cLEkHS1ujkwtqIxVxuxI0Dy8GAjtRK8T+T6PjNSSiZCuZ/suBQv/a970JMXtBA7Yi9i9NpZE=; 7:65BuTfD1lbqSoAUgr1AoStzmSnhPZlZCWdD56+u5jYfFWQb4+QzS3WNod0buF6MR6fm7Aw51IZF6Q4mSYiYt7IHbJlBNy9+rKG6qksTBfiFuC5efVoLcDP0xjtyW1VAHnm3FEBtojedU931h9xSgvQ== x-ms-office365-filtering-correlation-id: 4b4700f9-4b02-4430-0093-08d654ac4764 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0993; x-ms-traffictypediagnostic: MWHPR04MB0993: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231443)(944501410)(52105112)(93006095)(93001095)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0993; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0993; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(376002)(346002)(396003)(136003)(366004)(189003)(199004)(7736002)(97736004)(305945005)(54906003)(316002)(110136005)(8676002)(50226002)(3846002)(6116002)(81166006)(81156014)(8936002)(6512007)(478600001)(39060400002)(6436002)(72206003)(6486002)(53936002)(105586002)(25786009)(118296001)(106356001)(2501003)(5660300001)(66066001)(4326008)(76176011)(68736007)(486006)(6506007)(476003)(99286004)(386003)(44832011)(26005)(11346002)(446003)(2616005)(14454004)(2906002)(86362001)(186003)(256004)(52116002)(71200400001)(36756003)(71190400001)(102836004); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0993; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: MouL85c/gnCuAV/xXyzaR65UgHaHsJlFwL2WWCG1yh8FdPIxTCYE0QURdDqxJoRT5G7jg40QxeLWbQBN2eekiapLK/zn28gev0kpJBaiF8AyZlklEJMsjkUFxaK06OZyg2VHZA6vWyppH9QMcq3H6aJXf1nkSGsE7/TPMXVoRidv699tBvsFxnee9PTp52FUD9gkNINMybCR5h0DWbpFJ07fBQ1/Fl6U6W3mSsHumr+PmhcQo+jL94R1c7FKrMCWEh41EtSewu6+Gzf0oxHoalwqqTfNdktH7aHG8bTtv5Y5LoS22WyasXWVJjPIeC5FU3tqRLJ9HGmkhiOnxZNjzXfUoNnNQrODDNAIR58qOfk= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b4700f9-4b02-4430-0093-08d654ac4764 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:07:03.1785 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0993 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.154.42 Subject: [Qemu-devel] [RFC v2 03/24] 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 --- linux-user/host/riscv64/hostdep.h | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 linux-user/host/riscv64/hostdep.h 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 Tue Nov 27 21:07:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10701409 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 32E09109C for ; Tue, 27 Nov 2018 21:11:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 258362C816 for ; Tue, 27 Nov 2018 21:11:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23E872C81D; Tue, 27 Nov 2018 21:11: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 EAFF32C816 for ; Tue, 27 Nov 2018 21:11:26 +0000 (UTC) Received: from localhost ([::1]:44490 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkdh-0007d5-Rn for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:11:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35999) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkZj-0003Br-FJ for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:07:22 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkZg-0003hR-AT for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:07:19 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:63027) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkZg-0003h7-1L; Tue, 27 Nov 2018 16:07: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=1543352836; x=1574888836; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=2S7rrauxjQHW78NG9LVvSqZTCkNXnKASIbbFBeT4g4o=; b=dPB4uTR8NyCLhcFYjL5mpfbpE6C4LeZ2FVfXKYZI3mj4XTCOJaaUrm/N F7y+1lq4FDVRzNkm8VW+2EK2tWplsLhXbv6PT/Zsj3tfaSm9olUK8Bton 6hN0wrkgFv67JCZskqijJLLupoNTE1+dTDa5ugEkZBMq4QdUkjLaVL6eS zV1InVb65mf1dZz4KG2YAtNXKcumb1uyWbCusdn8W4fWrdgJ7BnAk4Xmd fjRl4CrDlll/IMONkS1AULDJbcBgJUwvb3OBVasZG7pqAiDsXEECfet6o 7JhCs/GGQN2zwpBkM86rrJ89JfbqHAP7p0eDXPst8qHCCeAqnSUnUy5mV g==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="96969342" Received: from mail-dm3nam03lp0020.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([207.46.163.20]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:07:14 +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=Y/LSf1nKagI9fjecvYB6X9dpKcCtykwaFthNVLxPni8J30OrmeJtYXtXRuwG6vKAoW5wUc73DqyrX1b4st89RzKeCN+9tOP1znMedm/e5XHy1kE6Kpbift3Mjmn5ZM39dUeWXkCImAwOuyWinO8fl0qfvW2r+bXjMvYQdKSGIaA= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0993.namprd04.prod.outlook.com (10.174.250.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.14; Tue, 27 Nov 2018 21:07:12 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:07:12 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 04/24] exec: Add RISC-V GCC poison macro Thread-Index: AQHUhpUqtozLRoIRm0yxp7YwsN1Ltw== Date: Tue, 27 Nov 2018 21:07:12 +0000 Message-ID: <6c83513fa2b810507f426dfd2f1d4a85999f3fb2.1543352682.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: BYAPR01CA0045.prod.exchangelabs.com (2603:10b6:a03:94::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; MWHPR04MB0993; 6:CZliFG9zKUQvw0++trqoLFlH73PgSHxcwz4q+Z/SRVf4LgCWhelowZaGVcY8zmnTCa81iEzOZ2hmldupiFwi48f1gXh1eaPaCGRLWFQgGihoqoHbjtTx+lJy8dcBKD6nN1qjpRDKYxTGzptefjdjl8NwWJYeW5++WZ33LkikYy8VyNHbNB1T45sHRwSQzrmTOXcNr9l1xU4+DH8WkEGndCzJpl6TqxHtDiUYmlgv/X5Q38GlOV4jV5+OIAf6CvLjdyZu0qhD0pZLu+QCgrcZIT6Ksx1hug7wwREV+Fw8aP8ZhFZBseIL0NILP7H/kdjAv/NilBDv9wcqD+RRo2d9pUeQNaBQcd+B3gnMWNF5faU9y9W3cTcz059rBJO++dsHrH2GO0Pwx9q+M2v/9oAF3yYgLxi91x4KigpZKovW7fbQcPBIVfrigUDM1HG1JjeKsF9WKc9vnhNLvkwtQ8cblg==; 5:WC026zG5E/X5ukk56AXqN3R6eZ/D50lntTfO0ArbP7KGjV9iunRxMS15/uOlDluBenk94lKPbWU/WOBmtaGnNuJBZO/wK5x8EdrZyCE68JKdjYwbV89ld2ltt9C9+KNl5RgpRefy3MJ/KKrfdypNz0IOnp2JbJf7sGobnqChXps=; 7:ZRmarKeQCHCvN0qzFnUMSPfU8aUq16MSXIuodoinhW3pjgPhhE6hh5i7bR8b++Ze9SGNtDmiU44HwQba07cacMkyLQSZmaSrkG2j4kgnhwCpWbH4l3B4UK8rJ6UYrHSvAqY/252q8+XONioyJY3i+Q== x-ms-office365-filtering-correlation-id: 9e392781-1909-4615-5123-08d654ac4ce0 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0993; x-ms-traffictypediagnostic: MWHPR04MB0993: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231443)(944501410)(52105112)(93006095)(93001095)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0993; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0993; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(376002)(346002)(396003)(136003)(366004)(189003)(199004)(7736002)(97736004)(305945005)(54906003)(316002)(110136005)(8676002)(50226002)(3846002)(6116002)(81166006)(81156014)(8936002)(6512007)(478600001)(39060400002)(6436002)(72206003)(6486002)(53936002)(105586002)(25786009)(118296001)(106356001)(2501003)(5660300001)(66066001)(4326008)(76176011)(68736007)(486006)(6506007)(476003)(99286004)(386003)(44832011)(26005)(11346002)(446003)(2616005)(14454004)(2906002)(86362001)(186003)(256004)(52116002)(71200400001)(36756003)(71190400001)(102836004); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0993; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: BTd0juwvdPOSgilL+wnoJk38KryuO8u6MwFveu6sC0R+iMYg92irIyoEBLnIKWCvHeL1wokdUV8ydgxsIpLV9Rp2ojWUVK++2umuy4bSlldj0vGVPyppY4SjLTXvg6loRnTP1a0fj1H628VjeHNJfzZ5WZ5VwtHsg8xhLrzgQsuRT3wBQpCACzS5HXc1irhP0J3be8GOmxOorL+tEVlmGeRZnLPl8Z1Af3+ZbCPWt1juemRV4jUC6Pj9CiE513mvroABtcaaG2qD/dLmhE+aBeUaMq4rhQgxIbHR9SY3dBrqjP7PT3tKQRIfdc1rSD1IZC/owe7bfi1VyWHVRssh1/zqvipkkC8+UIrEEXIhAKw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9e392781-1909-4615-5123-08d654ac4ce0 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:07:12.4287 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0993 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.154.45 Subject: [Qemu-devel] [RFC v2 04/24] 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 Tue Nov 27 21:07:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10701423 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 9942A15A7 for ; Tue, 27 Nov 2018 21:14:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1C23F2B37B for ; Tue, 27 Nov 2018 21:14:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0D1032B395; Tue, 27 Nov 2018 21:14:20 +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 5EDF82B37B for ; Tue, 27 Nov 2018 21:14:19 +0000 (UTC) Received: from localhost ([::1]:44506 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkgU-0002ev-3z for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:14:18 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36025) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkZr-0003Gx-BM for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:07:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkZo-0003k6-5B for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:07:27 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:22206) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkZn-0003ji-Rd; Tue, 27 Nov 2018 16:07:24 -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=1543352844; x=1574888844; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=WDaPr+ZejoaBi2m+8wAqMED2iqVQokZPkvaikiDT4zw=; b=cU4FOQYHqM1gCpvpJGFkB0Vi2spHKAxIsDMr3M8dBVwNz1yGDe1of5hs PNtbWJAf3TllWbr0WV4c0821K+JP+8BcdKoQyqWU0J5WMmotLVJpB3LyG 95N/0Lrt4znX4WfnBiqmdQ+bKCU5e2OjkgoiZJqya2mKhKy2wzKTZqA9H eTeG5nKKmJI+MNqYsD7J4D8+7QEecrVlzqDD2NkBafjtQWc9Ch/TvoDlO OefMSzgrTrQ3Ykf9EH1QUEys7WIkNsd+xyIUS51+Cg+BXUQhQylMOXa6C fBfVzjoYxDfH5fwCGt67XINvJ7VkKgBeYlsk+FwqQIPRJoIy9I7o9FTu7 Q==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="96433584" Received: from mail-by2nam05lp0241.outbound.protection.outlook.com (HELO NAM05-BY2-obe.outbound.protection.outlook.com) ([216.32.181.241]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:07:23 +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=SwjABlZvCNL4A1rXm/uYjZ/YNH5E0Jeb/UjXcy7z8qo=; b=SJdrJPHMSbnP1AYjwmbAPv2fGrCP1Jbpusw2IS2+pljREOFYw3aaqZR1PIb1ibuYRC47Uw01XI++bwVxRiYCsCymPcplU1wusWR9MbRcljH1HCMcgCxZ0DS48vSTzFfc4VHG1h79XeaLaVlHnwq6i4rK1aQN/dVzYooRfkxLkmA= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0943.namprd04.prod.outlook.com (10.174.174.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.19; Tue, 27 Nov 2018 21:07:21 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:07:21 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 05/24] riscv: Add the tcg-target header file Thread-Index: AQHUhpUvcZzi1dMAgk2psrdjTfRoVQ== Date: Tue, 27 Nov 2018 21:07:21 +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: BYAPR01CA0049.prod.exchangelabs.com (2603:10b6:a03:94::26) 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; MWHPR04MB0943; 6:2uhzgkhNeKGT/rX2vIGIaTnTeI1MKfdT60MW6gZWU6+7Y41BBtrFsYwrjP8Jd9f1q6SeG+PZlh32Z6yXfUPdEsZuqvzrQlr6LZLNeMKRd+0NtF3OcpWG2Qn1pKI1Bs06fREAt0qbFoK0jy8nZQBMHytyTjOr2d0l70SXVPhBdk4Wbs8For2fnrq5of1SIig1vDz3dMKG68eUMzG719FdEvDxzQJg0sfXBi8KrJDUnhK5nKqWt03xzMZOlYGK7uroKpGjJNSqKbkZ0q/tdczadqDygM/Bk+RngNY/0eJVfYLzJ9uRr1yn2j6P+pqUvfr9XpplCe0pmPjQxP1JYoOJNZqJyRaUZOum58i0y8t1ejo9YZfwbaWxTC723Sh3KrsoxC4vRqIyvwxbe85PqXAX0bMNkmvcLkZtRVXoqoCmSCtLJ1qdcqfw4Jv4vVa7HMUSbW7jQFTHT7IyOXGCGyWgGg==; 5:8FsidXlYKiLjAgJjosH0IQ3FZvMinzg2H2E2HD48qZ7CBGEAhhXlRuOj4uRLkarXcP2WdmTVzjyPw/1EmYzea+LeIXEYfRRDqedXpqW34PnCd7H8Xh35ZjYx9dlXDYi6Q2cTgLLPWztExS8mxiv+aEL2YEo59mLkP4KVel7G/HI=; 7:XcnIuiF2MEXZuaYJs8A12LkautiJ+3rDZzLnoEiayfCo6ZSZynWswr/eqlPh1Ae9RpsjDiZ98w2UDXUpELGj+gKpx5OCjOvP9L+33z7rTXF9ZPZk2kUC5ebrRTD+QOKW2WgXJOv9tUc8XwN4jyM23A== x-ms-office365-filtering-correlation-id: 58ffb872-4044-4141-2dbb-08d654ac5228 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0943; x-ms-traffictypediagnostic: MWHPR04MB0943: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3231443)(944501410)(52105112)(3002001)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0943; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0943; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(39860400002)(346002)(366004)(376002)(136003)(189003)(199004)(14454004)(97736004)(5660300001)(2501003)(4326008)(81156014)(81166006)(8936002)(14444005)(256004)(6512007)(316002)(53936002)(8676002)(39060400002)(110136005)(7736002)(305945005)(118296001)(36756003)(3846002)(86362001)(6116002)(54906003)(11346002)(68736007)(99286004)(76176011)(52116002)(2616005)(446003)(72206003)(66066001)(26005)(486006)(44832011)(71200400001)(71190400001)(386003)(6486002)(50226002)(6436002)(25786009)(102836004)(186003)(476003)(105586002)(6506007)(2906002)(106356001)(478600001); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0943; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: 8mX/C4dKnIEZuMPTVMkFnuLKhI8g910wXMExpSbwVSpmZPSh81NccSE1rFEWEBWnZipzgxehlvM/A4gxxJTNvku77cEEAZDJlmWJznrnTfEexpb2bXU/HHYh7s0Q/L0wvXUTP9rxVZI37W/UQMwBNdH4O89o+7pHjI1ZIN9OfXJiWq8OatTRkDbPAwqBGztjHWjf+rbyHxqM0Atcv/AMpmqg5CC0mUpNhfHn+EE+hBc4lNQE2xn8juSPrGrzeldf4RekA0yxelIseYS8AS7JAFoPjasx0q0ugri7WJFIpbVCFkAh48UrrA5Hqspu0gd/7+rh62xBUjdQyxSugc8MNOAITQZXdL/lV3FmCpD084I= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 58ffb872-4044-4141-2dbb-08d654ac5228 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:07:21.3820 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0943 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.144 Subject: [Qemu-devel] [RFC v2 05/24] 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 --- tcg/riscv/tcg-target.h | 173 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 173 insertions(+) create mode 100644 tcg/riscv/tcg-target.h diff --git a/tcg/riscv/tcg-target.h b/tcg/riscv/tcg-target.h new file mode 100644 index 0000000000..76ce2acfb5 --- /dev/null +++ b/tcg/riscv/tcg-target.h @@ -0,0 +1,173 @@ +/* + * 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); +} + +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 + +#endif From patchwork Tue Nov 27 21:07:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10701415 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 3774715A7 for ; Tue, 27 Nov 2018 21:12:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 286C42C85E for ; Tue, 27 Nov 2018 21:12:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CC5A2C84D; Tue, 27 Nov 2018 21:12:06 +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 71DAA2C844 for ; Tue, 27 Nov 2018 21:12:04 +0000 (UTC) Received: from localhost ([::1]:44493 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkeJ-00088W-JN for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:12:03 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRka0-0003Py-HU for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:07:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkZx-0003nq-BK for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:07:36 -0500 Received: from esa6.hgst.iphmx.com ([216.71.154.45]:63041) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkZx-0003mu-2n; Tue, 27 Nov 2018 16:07:33 -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=1543352853; x=1574888853; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=u/Vt+IIb5Gpjehiq3oPEaWMoNbsRMl/tlVklhYt3MS0=; b=aPKsVqdprkoX/4KYH2FNck1/M0vMrgI3gZWudSKFxhV4/a4sHqf5yrNR ZhCin1n7OVhCWS7YQ0rfbms3J3nysugfR1SeE1v3RnoHnGKrqRs/0Qv3L ZjGiK8W+DhzW09GIj+ZbBRqeGjrdGfIjHpikQzW+97v2ftqQHGSsBtm8+ JfOd2QQQiiYBpUss6LTyGdpvF4KQp+lfHW25Mt3eAQoRdAW7Um3FgStuQ olXpJcJoyPxdFKAVqeiUdT+Xy3PGGy1gWXcLzWjLwsXtaP9M6ZdsX+MIp Im5NQ3//nO7Xl79NBFhC6w4Wcly2XRWYunXTSaoOek0NrJKI2akD7n9SV A==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="96969382" Received: from mail-dm3nam03lp0023.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([207.46.163.23]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:07: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=AVo7lhLu8qkvrxmlIjQlr17Le39ZoR9LDsw4XPcvenw=; b=N+SeNbzq/coUnvzEE9e+A86KKILn4p8eADs4wk3ws7RsvlMI+wqpdQiw/HM9y9ehdf3klMMNbWgXcBAYRVdYBWsK+ZZmwy4icv71cDQELoO9S61g8ptH1RuLCQTeKXwtw0fQLzuNKv8+DlekzO46EWDRZ7tRfgS8fFPNjHa9dTU= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0993.namprd04.prod.outlook.com (10.174.250.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.14; Tue, 27 Nov 2018 21:07:30 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:07:30 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 06/24] riscv: Add the tcg target registers Thread-Index: AQHUhpU114k+ywjHMkKu1Bq/dhSwaQ== Date: Tue, 27 Nov 2018 21:07:30 +0000 Message-ID: <373429c7267117de35a56c6ec16405f5097b40c8.1543352682.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: BYAPR01CA0043.prod.exchangelabs.com (2603:10b6:a03:94::20) 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; MWHPR04MB0993; 6:ied725rpfAuontoz5TuIgQ9vYufrd5G6e2V8DpLylI3NEgSqlK71gwaD4qzkvvULd+u/kSpCmxALnXHEWjmXjNcXxNe5iM23TLLf9ZVc1nWObl1k9PqUj9C0yPI5YNuahWB6FJaVyG4wd+WTtjNm3wcuB6FYm1xo+0AUhnlf8Y9gIXbTOhO1hXOaPSK/poaWSqhOIdtfbroULvFBJ7V11aNwlGeyy2aqgOpkhutIruN69cldugi0Ka0i3tDBmfJdzoAIopS1liR71mQq3oNsDK3gEA11jzZyixmxd6VIhTN7az/6MLPSEoIpj49DWwCsyKLkzil4D//S97++7TrTy7LOdxxk/C/D1PosXNjJploqCTfDfeu5mKbXOrNUB7hRQuzGeJuQ8iThnLpW2YD440kBZKoOaZCLy4fET3oWCEOiL4h2IdxXG45oYQTYbsmsbAhY8FNAwT9APanZOmLk8A==; 5:QodBJz4th/k3RNKk3+Ph7jaL1Q3OSMsA1FHFv8Q7EadfuolspQkc4kpm6CxYtLhJr1W1ln6/D7U1ZRGyPxWcvchBn4dZvsB+Ss4sLbFjGuJ5LE3+HmbUlnTWFQBn8/rKEgkvOGaJiXZrKQ4QRfBnmY4WS8jdp2ubczrXnUSvbMU=; 7:jS6+IR5qWoPL2tMIEdEmLFwPDo3+VwhfQkt+8MGJC0vJzuYkvc8ZdQdEm26G4tWYuE+CKoyIa0QfmFrAelKfOVXyybvpGvFR5y4CLoepb3YclrDnt/VhYp1qlV/cq2/IcooMm9ZqEr9mmqlem17emQ== x-ms-office365-filtering-correlation-id: 24b298c9-7ac0-4342-f622-08d654ac577b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0993; x-ms-traffictypediagnostic: MWHPR04MB0993: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231443)(944501410)(52105112)(93006095)(93001095)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0993; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0993; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(376002)(346002)(396003)(136003)(366004)(189003)(199004)(7736002)(97736004)(305945005)(54906003)(316002)(110136005)(8676002)(50226002)(3846002)(6116002)(81166006)(81156014)(8936002)(6512007)(478600001)(39060400002)(6436002)(72206003)(6486002)(53936002)(105586002)(25786009)(118296001)(106356001)(2501003)(5660300001)(66066001)(4326008)(76176011)(68736007)(486006)(6506007)(476003)(99286004)(386003)(44832011)(26005)(11346002)(446003)(2616005)(14454004)(2906002)(86362001)(14444005)(186003)(256004)(52116002)(71200400001)(36756003)(71190400001)(102836004); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0993; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: OiI/OPL6GTRXhfo/f4Jl3kpPvaiW18hLbGjw0IRIlp9Wk8ZnOzgX99jzypiv+mvxSNuW/cHizm5A2hypROYRje0i5UwYv2/q4GipWc/wJyDEvCW3FEfJ9J12Chgb6kMM6KMt6RNwUruKADt1baPZw2BjF82BMCGwH36poY/SZW68HGFLNwgFAp2+S4G9sdiSXBnXaQXdc3VKKqPDLSsRQj1HhtHBknLYKrnRjuUxBsCRFkZT60UjrRB+Pc2FqgV2nRRDFCUWa8EIOGxEreZNvjAHld3r6u+GLlXkdmYqYVVdbr6WcO3G3NGOIDWRIOqLOIb5zafuInHjevfe96GbEEECKVYfR1wenNWvLCtmvPk= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 24b298c9-7ac0-4342-f622-08d654ac577b X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:07:30.0853 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0993 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.154.45 Subject: [Qemu-devel] [RFC v2 06/24] 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 | 116 +++++++++++++++++++++++++++++++++++++ 1 file changed, 116 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..a4a1579440 --- /dev/null +++ b/tcg/riscv/tcg-target.inc.c @@ -0,0 +1,116 @@ +/* + * 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. + */ + +#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 Tue Nov 27 21:07: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: 10701413 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 BB1F015A7 for ; Tue, 27 Nov 2018 21:11:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC4A02C81D for ; Tue, 27 Nov 2018 21:11:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A05232C83D; Tue, 27 Nov 2018 21:11: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 144642C83E for ; Tue, 27 Nov 2018 21:11:40 +0000 (UTC) Received: from localhost ([::1]:44492 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkdv-0007oi-70 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:11:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36225) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkaA-0003gZ-Vn for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:07:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRka7-0003x3-QX for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:07:46 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:36108) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRka7-0003rl-GT; Tue, 27 Nov 2018 16:07: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=1543352863; x=1574888863; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=Myg9gtTWqUSXFmM8elYUIAKJ+C2gtfPiur3HWAZEky4=; b=n1mx6hTg0kG5PjTN5hf8bV5/fBCU4r3uzZsTZQ3pPTW2IFkG1lAaGgDO 0TkaYz7eP7CWyG68DWMnFe1zyZmsXs4jpjXUuHDpGhh0iFYOx1mFlsWNh DS/hb5P4Ts8ECZKjqqjJdMsSEUEBLMIisF6QRyV+bhyM1KcBEQUgsOZIZ 6u+n4v0p3092FF2huKyjmrWD/8cEqDq0KorAkpv7o02zjEutWXA8rUYGv sOzUUdjNlHjv7qhbvqsIgS+8XIXuFI3zRumhReYD7InBbX3WTOzB6bjY2 7Y15guXqUAzz7F1KZHOn5tEMk+f0dhn3vI/KbzmEb9tDMl0RsrQ2Z9y+8 g==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="100064193" Received: from mail-by2nam05lp0248.outbound.protection.outlook.com (HELO NAM05-BY2-obe.outbound.protection.outlook.com) ([216.32.181.248]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:07:42 +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=HXbvBmC1y3yd9T33qVgOeq1Oxbk48BW2SusKKajDNIQ=; b=IUgKQD9mB4eSxk7BQOB0E/U9rU8cwrvO/btI+Gm/DemDwE3XyZuBiqLN7z8vdayAEBZgST5iG61XYace49i6jR6IJqZP23nfm+O0fIzDC8QoM6hqHDhpAGCglTjP4C+MEgi/iw5CqUS3O2dBfr61Uzj+n9UkYNx3Z3Zmz126f5I= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0943.namprd04.prod.outlook.com (10.174.174.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.19; Tue, 27 Nov 2018 21:07:39 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:07:39 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 07/24] riscv: tcg-target: Add support for the constraints Thread-Index: AQHUhpU6jZvKaoGksEiOj28Hgi38Ow== Date: Tue, 27 Nov 2018 21:07:39 +0000 Message-ID: <67303db03721ef2e4d9737379312681543a0ba0c.1543352682.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: BYAPR01CA0046.prod.exchangelabs.com (2603:10b6:a03:94::23) 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; MWHPR04MB0943; 6:mvYYTv7ArhWBvYXodc574LMGrLobCyxgSF12S+pkT6GDs7oVPK05CI6WXxV6yWrRtan0YQQSsV3GnckJc7STtUsyCUcFruuyrXPgvFX0fY4+L+wABO0znbXudp+Z6zsUx3ZcrZTmfeKTuM8RBoM7uKCVF3pEQ5CL8Wyn3faN5/J16oeXux+4bGkt3Tkq+ztGauqu7Sp2dw75/sT9yX1wvbgztAx/eG9aDkN7PoSs8ALXhGy0wjmXZgvt2BI7hjcbFMW4sl95Cwy2jIyFnrtrXMc2xC8ThUb7O5ZIz+XDMCGDPMR7aLk6bbwA/tuiw/cADyRRVbZBYYiGzLPq/lB2sP5nw/vQwC3VI9qnRvUjUG82bWRBp+jiI1wWZSHRvHTi94gFVZt1oajbUMfG22hxHZsklWGYwbWNV6jQZqclp6fM+IrtpE05ekJAjaBrIG0xrr5CvxrIXgbaBc1d5drZmQ==; 5:dTCv0TjBMWix/LxfnM1iuW1Jsg/8Dbt/1vIm13/mvBLoFO5MDB8lU/5RNxvVqYPVY+ux9qke2Q/FSKGhxLF/Kut19HCPKLHtiWpeK4ca9tAvQdTh53a+lrdH/6orjZbmBLo14yreHTNP4fdqAk7jk5Xm43yYRyUDl5f5lLr4dZs=; 7:x4Rem8M6iPCdxLxXkIQLGjMPebG88xMbI4uiCRPhOlwAs4aUxQtk5y+cyiE3Ho8fMiuLZZ2VEbI0gx5YGjtbVYxZpgDtx3oilP159zsxJvseTvmJoiiqM1QX/SOfy5BG4xKxw6GG6ol0yFrSK0X2eA== x-ms-office365-filtering-correlation-id: 41dbab30-c366-483f-46ba-08d654ac5cf8 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0943; x-ms-traffictypediagnostic: MWHPR04MB0943: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3231443)(944501410)(52105112)(3002001)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0943; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0943; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(39860400002)(346002)(366004)(376002)(136003)(189003)(199004)(14454004)(97736004)(5660300001)(2501003)(4326008)(81156014)(81166006)(8936002)(256004)(6512007)(316002)(53936002)(8676002)(39060400002)(110136005)(7736002)(305945005)(118296001)(36756003)(3846002)(86362001)(6116002)(54906003)(11346002)(68736007)(99286004)(76176011)(52116002)(2616005)(446003)(72206003)(66066001)(26005)(486006)(44832011)(71200400001)(71190400001)(386003)(6486002)(50226002)(6436002)(25786009)(102836004)(186003)(476003)(105586002)(6506007)(2906002)(106356001)(478600001); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0943; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: WDjx/gBEKh4vWZ8tfWhzwvYlIBCJ/XAy5zZS5TKDvp6LKtri8WyIPzSgYJHBzsle7FZUuBcL7fuH12cN5AROf64vIPBbTxQSRo/ukJWQfcHu0scXDZ4PA9yAsvxY0MGkn1jKtwPxJ7f5MMfqF0jBr33x5UwITDiqdlERDtM3CEwlg7e3rVQ8AxMUjklspbDV9AABNodBf3z835BXvSa1mxxGydN6YncaNa5YoSnITXXhhvEad45ozGbyUd+1wI6p55DE9BjZ3/fdHj1rW5BZUTRw0yJnd3D6tSb6prb0WPN/lj+OWaaT4puOEQXQMdoirlaD+rmu4ovibhW2TTYO9jUL+EBeEqR4Jg5oj16+fvI= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 41dbab30-c366-483f-46ba-08d654ac5cf8 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:07:39.4136 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0943 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.141 Subject: [Qemu-devel] [RFC v2 07/24] 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 Reviewed-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 138 +++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index a4a1579440..5719af3c08 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -114,3 +114,141 @@ 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 + +/* 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 '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 == sextract32(val, 0, 12)) { + return 1; + } + if ((ct & TCG_CT_CONST_N12) && val == sextract32(-val, 0, 12)) { + return 1; + } + return 0; +} + +/* + * RISC-V Base ISA opcodes (IM) + */ + +typedef enum { + OPC_ADD = 0x33, + OPC_ADDI = 0x13, + OPC_ADDIW = 0x1b, + OPC_ADDW = 0x3b, + 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_DIVUW = 0x200503b, + OPC_DIVW = 0x200403b, + 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_MULW = 0x200003b, + OPC_OR = 0x6033, + OPC_ORI = 0x6013, + OPC_REM = 0x2006033, + OPC_REMU = 0x2007033, + OPC_REMUW = 0x200703b, + OPC_REMW = 0x200603b, + OPC_SB = 0x23, + OPC_SD = 0x3023, + OPC_SH = 0x1023, + OPC_SLL = 0x1033, + OPC_SLLI = 0x1013, + OPC_SLLIW = 0x101b, + OPC_SLLW = 0x103b, + OPC_SLT = 0x2033, + OPC_SLTI = 0x2013, + OPC_SLTIU = 0x3013, + OPC_SLTU = 0x3033, + OPC_SRA = 0x40005033, + OPC_SRAI = 0x40005013, + OPC_SRAIW = 0x4000501b, + OPC_SRAW = 0x4000503b, + OPC_SRL = 0x5033, + OPC_SRLI = 0x5013, + OPC_SRLIW = 0x501b, + OPC_SRLW = 0x503b, + OPC_SUB = 0x40000033, + OPC_SUBW = 0x4000003b, + OPC_SW = 0x2023, + OPC_XOR = 0x4033, + OPC_XORI = 0x4013, + OPC_FENCE_RW_RW = 0x0330000f, + OPC_FENCE_R_R = 0x0220000f, + OPC_FENCE_W_R = 0x0120000f, + OPC_FENCE_R_W = 0x0210000f, + OPC_FENCE_W_W = 0x0110000f, + OPC_FENCE_R_RW = 0x0230000f, + OPC_FENCE_RW_W = 0x0310000f, +} RISCVInsn; From patchwork Tue Nov 27 21:07: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: 10701427 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 BC21B15A7 for ; Tue, 27 Nov 2018 21:14:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 591D42B38B for ; Tue, 27 Nov 2018 21:14:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CDF02B395; Tue, 27 Nov 2018 21:14:34 +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 8A4E22B3BC for ; Tue, 27 Nov 2018 21:14:31 +0000 (UTC) Received: from localhost ([::1]:44508 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkgg-0002oi-KU for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:14:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36283) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkaL-00043f-5W for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:07:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkaG-00041u-8Y for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:07:56 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:13550) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkaG-00041P-01; Tue, 27 Nov 2018 16:07:52 -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=1543352871; x=1574888871; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=65pGOu6sDsIxToOzDZFuLeKZfHZkjGYEDkPXlkFtKMM=; b=ma1Io0BXkD8EpKeR6WKsFu0qttqpc+eMaZUgUJLq7ksaxd92eOIwPcH7 rJbFVwDCsgFAEeCCPjMnM3HxHUuy6lbiZ97Lw/JP8PFaDWeVeud5wl+Bd 5VyIl6jOpGZvupAp1BQZECcs8P8wNgr3vJEuLxRZirK8e18ObR01VwaGv OWq6K6vrWPNvN8UhM+yGG9fGUzlmDUk6NCuvzhkkcNVu45U/eP9wsYSOj 3WBVwoPxH3gU014/lUSDLuJRRW+/T85W+7n7MOWpHp/8scoClQZI9XXrg 2FfYZiy2ziCSTC3GyB/StR+7c2hQWn7rQxGhc9c5rqCYx6yA98q8cLf3b g==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="199812216" Received: from mail-by2nam05lp0240.outbound.protection.outlook.com (HELO NAM05-BY2-obe.outbound.protection.outlook.com) ([216.32.181.240]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:07:50 +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=IH54vgu7uHZX4bslauXRMqm0Z4tUChYP53L6iS/jAqU=; b=m7UJ4nV4KJGnkXfuYny6i4RADToiZhbEC3zdEDKgdAjDJ55HM0gLibFjYXrmFEzd8lBhb1vYtmig0TZmD7wpfkobYfSpdU0YJd8aL2WDIxF8NNzz8T9Z7lvSzjxjcuYywUfZpTIYGAtzB6Sup4c8yOej9DVn7m26IM2X4/HvGGw= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0943.namprd04.prod.outlook.com (10.174.174.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.19; Tue, 27 Nov 2018 21:07:49 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:07:49 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 08/24] riscv: tcg-target: Add the immediate encoders Thread-Index: AQHUhpVApDesU1dCp0yat8nOQRJJ0Q== Date: Tue, 27 Nov 2018 21:07:49 +0000 Message-ID: <0ee380a9ce2d7290523b5d06597c74ea14ff4174.1543352682.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: BYAPR07CA0035.namprd07.prod.outlook.com (2603:10b6:a02:bc::48) 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; MWHPR04MB0943; 6:6/sclif7Pb7/HYly/KCQUsYs6nIL81nDvqu86UEDtwvFpXpq3sR2xZLlrgINhwXD1D31TBc7Lt8HQ8swxRiDr6LKDrcQR23WQz6zxGpjEDtWlNRteNAyGC579g1En8rMWYPAMB4qnnFgVIKkzjtwL8OrByzZlZ9xrxMDCjq1/C9EL+8xT6Mm/sU0rDckIern/iFhChHEFmF4oRMrrQRZ+AYzbpXuqlabH5GGWqkVl9oS3I3zzkNFhYLplXS2FsP2tkmaG+plZeaHXawh3JZe7/CgGHnq1CRjd8wORhsBrJIXDSfP9de9RXEAN1bjuTWzgRjaYUcrM/ER/A7pCqDGwnls3AVvSgVKV7HPlK8bOTgizrbAuKJ6poOiMogvPA2+GmhRyKusN5fXZ9o2HDxQpZdTYvoeTqHxTE52RQu6mtCHzjTPHNpAM3kgCAJJIFvp9YZaCSziTeHiSS+JTHCiFA==; 5:Sfo+Z7LqhMc1DK7j3zzZzecFxjLHxthpLmOCkpmC6KgPcB9eMAa2V1YwM5e03pWBgW6PaYikCtPEdQXSu9AXsU/RhIZshxO9nDqoTQXbhe4wcc6Tc2XYnzYJFn1UUx5zxpv/36zmTRFY3TJaY0KJDJk8zMNqlLy6/rBDHDXAgis=; 7:UqMXwprNGKtaX3FDoDrx+vLI2pK0eA3vLPDRCy/DlQDdBfu+1zyjxbZkk7jJKgMcnNOYopy3R5ZIE8HPbLhOWwKcCzTt/HbHFwFWCz1gIocp496lVGVkFl65Y3ABYYh93dnDsCE4DDYo89GJy3ouJQ== x-ms-office365-filtering-correlation-id: 58b773ef-c467-4aaf-baa0-08d654ac62d8 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0943; x-ms-traffictypediagnostic: MWHPR04MB0943: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3231443)(944501410)(52105112)(3002001)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0943; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0943; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(39860400002)(346002)(366004)(376002)(136003)(189003)(199004)(14454004)(97736004)(5660300001)(2501003)(4326008)(81156014)(81166006)(8936002)(256004)(6512007)(316002)(53936002)(8676002)(39060400002)(110136005)(7736002)(305945005)(118296001)(36756003)(3846002)(86362001)(6116002)(54906003)(11346002)(68736007)(99286004)(76176011)(52116002)(2616005)(446003)(72206003)(66066001)(26005)(486006)(44832011)(71200400001)(71190400001)(386003)(6486002)(50226002)(6436002)(25786009)(102836004)(186003)(476003)(105586002)(6506007)(2906002)(106356001)(478600001)(14773001); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0943; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: O+Z5fhPoG0wlrdkFHZYD05wePN7/QDbfxRwpK+pHkbptyHJdvgT6TDJeAO0HENi26eZ09A7UldIU6x3ZRmsaR+9BfPAqeyHYk15k7p+kow+cslKWPyF/Wor+uMh48IHCISfNa8LJlp4JLT3ckosa+1pRXEodnvfVpxuugM4MMN9evOoz4Puy1cUibHljN3BUCNsUSeYQLcsi5HXlVsI3BFGEBku4u+WVbkOU5bgXv7J70gsuDUcMCKX9e5PZT8/f+9Xz1HsC91qItIgBBrY3g5uBoa17hsHFspoaL/B9q78uFYVSEnCjtMSKWnBnJzcRxAc0X7sHxnIAZYkA/IgRGqgbvs7tnUYNey4OHngS1cw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 58b773ef-c467-4aaf-baa0-08d654ac62d8 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:07:49.2107 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0943 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 68.232.141.245 Subject: [Qemu-devel] [RFC v2 08/24] 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 Reviewed-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 105 +++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index 5719af3c08..c659c4de39 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -252,3 +252,108 @@ typedef enum { OPC_FENCE_R_RW = 0x0230000f, OPC_FENCE_RW_W = 0x0310000f, } 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_ujimm12(uint32_t imm) +{ + int32_t ret = 0; + + ret |= (imm & 0x100000) << 11; + ret |= (imm & 0xffe) << 20; + ret |= (imm & 0x800) << 9; + ret |= imm & 0xff000; + + return ret; +} + +static int32_t encode_uj(RISCVInsn opc, TCGReg rd, uint32_t imm) +{ + return opc | (rd & 0x1f) << 7 | encode_ujimm12(imm); +} + +void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, + uintptr_t addr) +{ + intptr_t offset = (intptr_t)addr - (intptr_t)jmp_addr; + tcg_debug_assert(offset == (int32_t)offset); + + int32_t hi20 = ((offset + 0x800) >> 12) << 12; + int32_t lo12 = offset - hi20; + + atomic_set((uint32_t *)jmp_addr, encode_uimm20(hi20)); + atomic_set((uint32_t *)jmp_addr + 4, encode_imm12(lo12)); + + flush_icache_range(jmp_addr, jmp_addr + 8); +} From patchwork Tue Nov 27 21:07:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10701461 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 6C023109C for ; Tue, 27 Nov 2018 21:24:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B144528620 for ; Tue, 27 Nov 2018 21:24:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A575A28CBB; Tue, 27 Nov 2018 21:24: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 81B0928620 for ; Tue, 27 Nov 2018 21:24:01 +0000 (UTC) Received: from localhost ([::1]:44567 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkps-0003gv-L0 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:24:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36368) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkaa-0004kJ-Kd for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:08:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkaX-00049W-Fm for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:08:12 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:13562) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkaX-00047w-7D; Tue, 27 Nov 2018 16:08:09 -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=1543352889; x=1574888889; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=sidNXU5yVM+7IqPohoBeW2p2HhG15ntJbitTAMuLA18=; b=iYhXmkaXjgJyVyKnr5lt2LIcWC+l5XCoJ1xn2TS7X+TZKluJ4NyONHRR 3jFhJUZRtcne9k+jWubJ0ROPxTV97m8Wt/zCppc6eAkoKYp6JxYY8pyvU 5GAC3W2jh9wIZTvkdloLp/vSan6Q3+Fmi0mgFwAQ8GJTWK8XEBLdI6VO5 UuIr5LAAoqzOwVcRW3aUC84KpybOWQHWSEDum89pZK0KVSO1bvCH8/M5z F9LW1DkULLbp3CWXd4EkQrPvfTCfTrlSKWhAp7T0+stKJF0iEDaTb6dw0 ceFcq0wCwH4KYASTfjmtJoEMoHVVAczdTlTewrF/AoiY4m0Snz63Cjdj7 w==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="199812224" Received: from mail-by2nam05lp0243.outbound.protection.outlook.com (HELO NAM05-BY2-obe.outbound.protection.outlook.com) ([216.32.181.243]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:07:59 +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=t9cw4SFWlVxaaORXxIiFgpHRQymXQ849web67No3N9Y=; b=XcmTsJrJWtuQWZ3A+V/L8pSKJkwz7GKyKcQf+hZL2IwSnoOCR3b5ob4x1uq02NaxP8Rhy5DKQN/Sbvs/cDod8x+ft1cpOxvx8xqHY0uiZpQwNE1hl9Po/fNE7CthZqWE7JbmOFoqKSvmgs+82rTmm5SBFY53FpfmKcy30lSESi8= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0943.namprd04.prod.outlook.com (10.174.174.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.19; Tue, 27 Nov 2018 21:07:58 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:07:58 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 09/24] riscv: tcg-target: Add the instruction emitters Thread-Index: AQHUhpVGMzq5Z3IDFkSDRVNXRu38xg== Date: Tue, 27 Nov 2018 21:07:58 +0000 Message-ID: <9075ac8fdc90ead4b5e27fd598b8b51679d454a6.1543352682.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) 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; MWHPR04MB0943; 6:+fc6/fGHQmQsQXpTsDXG4DLdU6AkagG8XlDnFbVVY/yghKUqOFsYVesp2AwQykqe772EB/39qXKy+hS15fBzSEZaNg5nLHxsogXUxe5QAKtOgCzr6s1iDUnBFl3i4MmmXclrHdFCPGXb1lFjxcgTQqgjczLaGXp/eq6zqHX3eGb1iqVpZJgODyjEPdzW/IptSXPIDSjE/2dE5PozmZHB3mtTQXQsV75rJDvfDAjX9qwIOeSP4k5dDXptzJKi/4Af0adjzhINZ7LdH7CYQxkUEdW0prEgi6JKbFmGIl3qFG3L9EvZGTcLKIY4EPA++CoUrcVYFQ+yeo0ehX3mhAuZ+hre0pid7whW3ewWxaITHR3xBWJUo6F5l6I4tNMirXThD28fQvGjdoFZjnCF4FMuMPs6fl9u9HXQh7Z64BATYOz30xleYvtw9vsEzOE3RyaJLywRjchMIxv/8p8qIoCTCA==; 5:8vtIQpALrvuhwe4AqQB79L9LjmRQQXwj1yCogajBCGsdBSxgxdIC4x2isH+3JZr19jDMbQWfz2dSWFB8zdeGibRB4UyV32XsrLI4pq0cvoNj0s9AGhQFawDXk9o3bMUlm0nJZzH9SMR55giWFVSNw9+zxyFQdHvnGrQCSJRtrD0=; 7:t90/xx4TcUCPmnjYJ52cutfCWemu3pcOqGWT8AQE2BuaZxFFkUMvtJu4s5Y5RMuWlMfSg0ZQg+gaXXMKkeHSja4ErbBlU8/5xO9UcTWVaRTed2fegJ0C/yFK1VCXZvCKCoNNd1Yg/9Ixgq4B5mhYVg== x-ms-office365-filtering-correlation-id: 314ae4d6-ecf4-45c1-4536-08d654ac686f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0943; x-ms-traffictypediagnostic: MWHPR04MB0943: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(3231443)(944501410)(52105112)(3002001)(93006095)(93001095)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0943; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0943; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(39860400002)(346002)(366004)(376002)(136003)(189003)(199004)(14454004)(97736004)(5660300001)(2501003)(4326008)(81156014)(81166006)(8936002)(256004)(6512007)(316002)(53936002)(8676002)(39060400002)(110136005)(7736002)(305945005)(118296001)(36756003)(3846002)(86362001)(6116002)(54906003)(11346002)(68736007)(99286004)(76176011)(52116002)(2616005)(446003)(72206003)(66066001)(26005)(486006)(44832011)(71200400001)(71190400001)(386003)(6486002)(50226002)(6436002)(25786009)(102836004)(186003)(476003)(105586002)(6506007)(2906002)(106356001)(478600001); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0943; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: F3ze0K8MH6Wei5xmvu4MFqaaxewye3KUS0Mtlv9g/SyNwCg7Y8/DkFzSaWAdSJYAOeBy1O4bOv+zOKs61JEagMlQiZUispIjOHUBJkK5U/kPhgZFjxeGcC1pMehNlyk42lSd5geRB/n91R8xWzYUd+kzSZYEvvvM9RWMEnP3eGD3RhJg2ku0cTha0QY53jbLKZK+sK7XQFILDDRbqqwDwQhC3TuFBcBND3iKE5HHFHDev4Yq4I3p4bGElofm+8UgH6KXmTmM/UaoII0xYzkNBfgwUnXHP1zsKyZh97l7sBwAyDM8FhLTD1p36VY19o89LxXCCji5gmKZf+lYPjrTsW4Nqbqb+QPHs3s1+NFvaew= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 314ae4d6-ecf4-45c1-4536-08d654ac686f X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:07:58.5703 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0943 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 68.232.141.245 Subject: [Qemu-devel] [RFC v2 09/24] 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 | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index c659c4de39..ca7ae8939a 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -343,6 +343,46 @@ static int32_t encode_uj(RISCVInsn opc, TCGReg rd, uint32_t imm) return opc | (rd & 0x1f) << 7 | encode_ujimm12(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)); +} + void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, uintptr_t addr) { From patchwork Tue Nov 27 21:08: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: 10701445 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 218BB109C for ; Tue, 27 Nov 2018 21:17:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 137302B6D0 for ; Tue, 27 Nov 2018 21:17:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 074A12B70E; Tue, 27 Nov 2018 21:17:33 +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 851252B6D0 for ; Tue, 27 Nov 2018 21:17:32 +0000 (UTC) Received: from localhost ([::1]:44530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkjb-0005DH-OT for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:17:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkah-00051C-JY for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:08:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkae-0004CY-EX for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:08:19 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:22255) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkae-0004CB-4f; Tue, 27 Nov 2018 16:08: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=1543352897; x=1574888897; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=rsKWTZTHuoukCFTBN1vOEzRx8KiTPQL+tMziNr6ucFY=; b=O4MfQmZWCQ07yvmO2Nqq10oHA4xtLxhS0v/WnXU/op0fMvhfuTlSi4fz q68K7a4x+3mjEpgUN+ZMhQQvaADs3FwFypLOCemhTeLVU02v1/EiEFPqM MtbJYEwy4cy3imWJzHOmADDij07vJ/XQhLzliLeFDJLd209yIQo1s4Vsr REC2CgaF86qroi/kFddvwZbZKAhD286pxq72jM/vvF1mTZhPK9q9cTVYc +EikGNRtDpqRyqP/G18StNU9l7THMwgrqviwYRh9Q5wiCTe2k7WNLYXNi YbYImrJDi9InitTs/eTqWZfB59Aq6FZl/X/cRwJgYVcsojl6OVHIazUO3 g==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="96433626" Received: from mail-sn1nam01lp0116.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.116]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:08:10 +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=48HaPkXlLxvHRTjV679saDRjMSXKF4GIL+lZYJLe7/0=; b=MAFIco0XIxapWhwjb+6DS99na9Eu7Oh4Gkhbw/4hQjtkbIiLq7LezVtFX6MuwE9o9ATYlKjwOqnEgsxz3FnQ88FQMFPhYIqFdAQZHfpgLqCp6HFhNO/fePdHbh/hNfLRHCW9v41pYIRNPrmG46fJN/6roErcRQN0aAkyuNhpR9U= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0993.namprd04.prod.outlook.com (10.174.250.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.14; Tue, 27 Nov 2018 21:08:07 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:08:07 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 10/24] riscv: tcg-target: Add the relocation functions Thread-Index: AQHUhpVLQbzCo17JnEenYhr1xg+3Dg== Date: Tue, 27 Nov 2018 21:08:07 +0000 Message-ID: <6e20c8377a588dcb44a1d8ef9efc07499663f59e.1543352682.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: BYAPR03CA0023.namprd03.prod.outlook.com (2603:10b6:a02:a8::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; MWHPR04MB0993; 6:yvbQtiBfaGkUE4m5r6Eh90WKVSD+ilA/Fm9CQNvJG14ziOqooGwRq4iD1UgSPm1/e2oh84P6LX0gRnDAGUwkqDS4ATsOjdDfnL8GVwi+zFxXYgK5a46bqT3Tt8rCB/FfT/7Y3/bn9XZNvE+LGvxMJ1wBOeUbbQM9zkqdAzexr7Kb3cjIWZxuLZ4XBUPgxWqV96kkRrhPra4A6fQ1bXwGNjUByVw2uYESADO69Y+tsX7y0o0N3kJg6fBkgU9QjYKhzPJ63PwxndTtcHR1bMKmRas33R2sbqO1NGyOdKDOxaGIKH49IeRoiFCdgQuXTpXwoHletLuVAI9RCrW3RnhAx7p+EhUeakKvgp29S325GSYQXdSZe5TL1m574f4YAuqBW7oURiUbdZPn44Wg8g5cHGL4dIve5VHXBf+sWyeHmA3dIL6eEjbOnbN6zrlrzskX4hH30wJmwgkWd7CvN1NQIQ==; 5:hdNVi3aT8z3kbt5NiSL4VBhJ7kuF7OP6+aE5e3dgSCmAWtM1TxBYJ+qNFVNZzF9W+PyCeC9t0zZ0kWuOPrdLBbEXKgG9TYBXz22GXgK1yZ9j5dSEIaX069Kckhs39PiDTwXT7mg106edS/AxihOF5lmUlaH3FpFhaVsIXfod+bQ=; 7:rDmksfrl89KjtCh3hG+Sdbau1nXYk8d6qxwdUsyuq8UoOFMKcbneS0rbgegtqPATfAGU98E72uPd1xyUeKPoTpXOYxY7qCDy8b6BJ7blwy+bUbBxXP+xlJaiyI5Q0dGFamv6xe7fagGLvx9WNpNlTw== x-ms-office365-filtering-correlation-id: 75437977-6791-46aa-e546-08d654ac6dda x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0993; x-ms-traffictypediagnostic: MWHPR04MB0993: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231443)(944501410)(52105112)(93006095)(93001095)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0993; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0993; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(376002)(346002)(396003)(136003)(366004)(189003)(199004)(7736002)(97736004)(305945005)(54906003)(316002)(110136005)(8676002)(50226002)(3846002)(6116002)(81166006)(81156014)(8936002)(6512007)(478600001)(39060400002)(6436002)(72206003)(6486002)(53936002)(105586002)(25786009)(118296001)(106356001)(2501003)(5660300001)(66066001)(4326008)(76176011)(68736007)(486006)(6506007)(476003)(99286004)(386003)(44832011)(26005)(11346002)(446003)(2616005)(14454004)(2906002)(86362001)(186003)(256004)(52116002)(71200400001)(36756003)(71190400001)(102836004); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0993; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: QY0fPlyICiaObRpNEDj7qvmoN2jX/MfFAY4KCBx4KyPX+o5UeuMHE6hni9366D/PIqD9VDzbpdKdok/R/5o7Pw8ACsxClS33AS5peVP1Xs01z4DP4YdONVUJhgLSxXEACko1fcpnBzR8Qd+mlRN+ako+FS3vPp/fRO+EE3IWMzOMnaZWkSzRztUJOrm47vuwi+7j142n2qCRiDsYodLnILrQjW3Mk72oo4kiK44xoUzf/wLqPBgOLDv8aP2DyicsGcna4lSsb8bcF7FaosNA2xWsdJoaaKlDpf+yw4OkWYZg9AF4fOMg/7lLwWLtvnT+Eo4LMggnQD5/aRfsvA9WNuRiYewHYMVAikFgHE2AHmY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 75437977-6791-46aa-e546-08d654ac6dda X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:08:07.6330 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0993 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.144 Subject: [Qemu-devel] [RFC v2 10/24] 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 Reviewed-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index ca7ae8939a..9c48679f11 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -383,6 +383,57 @@ static void tcg_out_opc_jump(TCGContext *s, RISCVInsn opc, tcg_out32(s, encode_uj(opc, rd, imm)); } +/* + * Relocations + */ + +static void reloc_sbimm12(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +{ + intptr_t offset = (intptr_t)target - (intptr_t)code_ptr; + tcg_debug_assert(offset == sextract32(offset, 1, 12) << 1); + + code_ptr[0] |= encode_sbimm12(offset); +} + +static void reloc_jimm20(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +{ + intptr_t offset = (intptr_t)target - (intptr_t)code_ptr; + tcg_debug_assert(offset == sextract32(offset, 1, 20) << 1); + + code_ptr[0] |= encode_ujimm12(offset); +} + +static void reloc_call(tcg_insn_unit *code_ptr, tcg_insn_unit *target) +{ + intptr_t offset = (intptr_t)target - (intptr_t)code_ptr; + tcg_debug_assert(offset == (int32_t)offset); + + int32_t hi20 = ((offset + 0x800) >> 12) << 12; + int32_t lo12 = offset - hi20; + + code_ptr[0] |= encode_uimm20(hi20); + code_ptr[1] |= encode_imm12(lo12); +} + +static void patch_reloc(tcg_insn_unit *code_ptr, int type, + intptr_t value, intptr_t addend) +{ + tcg_debug_assert(addend == 0); + switch (type) { + case R_RISCV_BRANCH: + reloc_sbimm12(code_ptr, (tcg_insn_unit *)value); + break; + case R_RISCV_JAL: + reloc_jimm20(code_ptr, (tcg_insn_unit *)value); + break; + case R_RISCV_CALL: + reloc_call(code_ptr, (tcg_insn_unit *)value); + break; + default: + tcg_abort(); + } +} + void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, uintptr_t addr) { From patchwork Tue Nov 27 21:08:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10701467 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 B5AFE14D6 for ; Tue, 27 Nov 2018 21:26:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A04A52C2B7 for ; Tue, 27 Nov 2018 21:26:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 921732C42C; Tue, 27 Nov 2018 21:26:52 +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 F25932C2B7 for ; Tue, 27 Nov 2018 21:26:51 +0000 (UTC) Received: from localhost ([::1]:44589 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRksd-0005ps-56 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:26:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36485) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkal-00055A-II for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:08:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkai-0004EU-Cv for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:08:23 -0500 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:13571) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkai-0004Dy-4K; Tue, 27 Nov 2018 16:08:20 -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=1543352900; x=1574888900; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=4O8cCIcIoB+r1qlanjPGyCNQCuRovZFWhSZsWpsByNw=; b=H9wBwI9/jvb+MBGEoRGaac/wvEQ7kScR80biVpfPTLC/x8gZAwfkjeLD u1IZ+46HwOtMJ4RVvWEEIPRShAgemj2mziLQZoHbEnHYOh0JorjD+ythk LBviFhgtTSE8Swd6MzcbrFZemWaWaCoklI7hwzXwpU9WZVNK/GO2XUrAM tE42M1bSWjNqxjy7LOYXNwM9UssUeWU9XL4vUVhHSqADTPPFnLGyzkkur CTP8yXvBNx0KcCp/XzDJNxdpr7h4iE3QiWC2Jl6uC60msGamRajaRK9js KyM0W5XID8dt2okJegRW/Eo2co5ROAXK4dBUo004RhOYez33s4NHZF+pU w==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="199812232" Received: from mail-sn1nam01lp0115.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.115]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:08:18 +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=fpFseMVfEdh1wMPg/f1SN0jOOTDO42FbQ+odUEqXNE8=; b=Wk3hiUB1cgyFFmoGBG7QCItEVVGMPZvQMxKH9BXVhCQn+eFMDukqBOuBBqPH013QbP2r130te8G5vtYZmBcycIAmAbR6D0/BHRIKvoo9+0oN9lQjpfI3c0M59/pUTiKxz828C/65EaHptjz+H4fRf6icu+U5f6ccyfqH/703jcw= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0993.namprd04.prod.outlook.com (10.174.250.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.14; Tue, 27 Nov 2018 21:08:16 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:08:16 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 11/24] riscv: tcg-target: Add the mov and movi instruction Thread-Index: AQHUhpVQwXainwMUpE2PB1hrnNnoPg== Date: Tue, 27 Nov 2018 21:08:16 +0000 Message-ID: <51221791beb40b25309805b1c76db0004f26f64e.1543352682.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: BYAPR03CA0004.namprd03.prod.outlook.com (2603:10b6:a02:a8::17) 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; MWHPR04MB0993; 6:Ua7PonV529ZNYc/WP081SP+Z9v9OQ6sOedwQaks3BtRKm3NlWO0GKiJjYhEajndc7CIBP1zmVGrWvEJXxpIOk691UMVZa2WGJ2mHu8UgyCyX8lPZF1F2m51CREpya5fLYZvcguG8Uac6wj09Cm/ZSS40GXzDjKT18I6bbGnNetZj1p4513MYiEXNt/rScketUjuwwyQMJJ8kEKsf8ZEZg5JnywNziLWCObtZvrE3xhzyrceBMKVIRCNq7cwqh7AXPTvmMFqsEKPxFb/mfh0vmuLSfirUCY0itiU9RmXlyvoEde3kwNh4mS9YCapJKNT6easyyY3jdEX0UazIUBjFt32Za6H6nPsxt/4quZlQzHimy3Mfm5aY0QEkt/lN91jazEyPSX2OzktRW8xTN0BbqU7eo9kpcTF8rgkbncHzrEmz6Rm5TCMcl6b7+Cr6zt6hXu3ptYKaYcDutGuNlbh6AQ==; 5:meZL/rkNq3dUiAkNQIZDmyJeytAPf5qu2Sn9cl50XacHKjHjL69NQ2QN0i+M0MWbrBnWYql0SDLqxYFMue78kgHkdezjVUdL7ReZTc4LuZW6cBFGSxxBdKtFBd8zVrW7Y+nMNf2hRHcX6vwvJ5iHUWLCPzG/Yph25d2C3p8wl+I=; 7:/F7R2fYaqNVIqxMJ+MpllHlJrmaZBG3LZqv2nwKeXjdXu6AgR5/u9Dp1Gcsf734KS9Dwf1hRTY2n/Ut4gmFIYL0pnvm1DE5NF5/fH/vmZ7B28RtldoL20tPdn+sCuDgYMssNRdHgfEKmdprPGJb5ww== x-ms-office365-filtering-correlation-id: 3aee63e3-77ce-4509-100a-08d654ac7331 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0993; x-ms-traffictypediagnostic: MWHPR04MB0993: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231443)(944501410)(52105112)(93006095)(93001095)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0993; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0993; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(376002)(346002)(396003)(136003)(366004)(189003)(199004)(7736002)(97736004)(305945005)(54906003)(316002)(110136005)(8676002)(50226002)(3846002)(6116002)(81166006)(81156014)(8936002)(6512007)(478600001)(39060400002)(6436002)(72206003)(6486002)(53936002)(105586002)(25786009)(118296001)(106356001)(2501003)(5660300001)(66066001)(4326008)(76176011)(68736007)(486006)(6506007)(476003)(99286004)(386003)(44832011)(26005)(11346002)(446003)(2616005)(14454004)(2906002)(86362001)(186003)(256004)(52116002)(71200400001)(36756003)(71190400001)(102836004); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0993; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: B72H2aVvJdLRStcJhKLbvjlBaAU5U8MmzlWb/nZSzoDC3TahHc/Juu7sbVbcH8V05/XsKy9Wf/wOiU4ZNkWLOPGKgzspuWdDc4ctvXIuaiczvS/HpXE9hqX5xLMq8sXvUiyBqFcWh0+s0q3dYeX9afoVNS5fH5EzTZnSsoxFqV9af98G1EcJnTMLQEKEm5SSWyzz0U0Q7OvrlCEqT3FFY7H0AlfGXdM+XQieGlIfypOyr+xrvCn0Rh4MQdH95sRAQbQpYaAdgjSZTzIn+Vr6EbgTGq8k0RUkHgDQfkleWIpiB4wPrczTykn3Skr7RsRVmgxnKdcNnoFuqhIZtJhNJuCVhNRhnCZxGEkrcCqMQdg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3aee63e3-77ce-4509-100a-08d654ac7331 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:08:16.6801 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0993 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 68.232.141.245 Subject: [Qemu-devel] [RFC v2 11/24] 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 --- tcg/riscv/tcg-target.inc.c | 78 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index 9c48679f11..e5a07b146f 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -434,6 +434,84 @@ static void patch_reloc(tcg_insn_unit *code_ptr, int type, } } +/* + * 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) +{ +#if TCG_TARGET_REG_BITS == 64 + tcg_target_long lo = sextract64(val, 0, 12); +#else + tcg_target_long lo = sextract32(val, 0, 12); +#endif + tcg_target_long hi = val - lo; + int shift; + tcg_target_long tmp; + + RISCVInsn add32_op = TCG_TARGET_REG_BITS == 64 ? OPC_ADDIW : OPC_ADDI; + +#if TCG_TARGET_REG_BITS == 64 + ptrdiff_t offset = tcg_pcrel_diff(s, (void *)val); +#endif + + 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, add32_op, rd, rd, lo); + } + + return; + } + + /* We can only be here if TCG_TARGET_REG_BITS != 32 */ + if (offset == sextract64(offset, 1, 31) << 1) { + tcg_out_opc_upper(s, OPC_AUIPC, rd, 0); + tcg_out_opc_imm(s, OPC_ADDI, rd, rd, 0); + reloc_call(s->code_ptr - 2, (tcg_insn_unit *)val); + return; + } + + shift = ctz64(val); + tmp = val >> shift; + + if (tmp == sextract64(tmp, 0, 12)) { + tcg_out_opc_imm(s, OPC_ADDI, rd, TCG_REG_ZERO, 1); + tcg_out_opc_imm(s, OPC_SLLI, rd, rd, ctz64(val)); + } else if (!(val >> 31 == 0 || val >> 31 == -1)) { + shift = ctz64(hi); + hi >>= shift; + tcg_out_movi(s, type, rd, hi); + tcg_out_opc_imm(s, OPC_SLLI, rd, rd, shift); + if (lo != 0) { + tcg_out_opc_imm(s, OPC_ADDI, rd, rd, lo); + } + } else { + if (hi != 0) { + tcg_out_opc_upper(s, OPC_LUI, rd, hi); + } + if (lo != 0) { + tcg_out_opc_imm(s, add32_op, rd, hi == 0 ? TCG_REG_ZERO : rd, lo); + } + } +} + void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, uintptr_t addr) { From patchwork Tue Nov 27 21:08:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10701429 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 92E67109C for ; Tue, 27 Nov 2018 21:16:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 832332B3A5 for ; Tue, 27 Nov 2018 21:16:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 76E142B49D; Tue, 27 Nov 2018 21:16:01 +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 7F6D92B3A5 for ; Tue, 27 Nov 2018 21:15:59 +0000 (UTC) Received: from localhost ([::1]:44523 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRki6-00048O-EZ for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:15:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36554) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkau-0005Ea-3q for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:08:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkaq-0004Id-VQ for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:08:32 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:36157) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkaq-0004IC-NA; Tue, 27 Nov 2018 16:08:28 -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=1543352908; x=1574888908; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=kWzsfn7e42RqPjkeVspLL5gBVbw9RfDVIbRNtvkFikg=; b=aQ9zxxRMok8TzOEWbjJj7Ne2E6+xjGz4z+xxBu0jVKgv6JjPOKpHgvig wReBYGCOjedgnckEwKRWSmthCFOWmIAP7MEjnhc5HXcFs1yLWsr48hrct K4dFgAmYUG+9XJ5NZswiZMlsJW+Rvle7myBz7qvcQo10CCBy610fZ0qUs eaqIMcVlthfUkPnYc4GyorRCHRgmkrZyHpbIEgo8+Timi8NIFXVL8d3sN T560/dC3M2cxmFeJ+Z3siAhwkwboA/FdbuJI3FSGO1C+/0C+Z6nXf+Q29 9xHWIR8DglqraPfuYwhozokO57TxjV4v/QZiYFzNgol/9fW9UH7X/a38j w==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="100064239" Received: from mail-sn1nam01lp0111.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.111]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:08:27 +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=qPCEwl0VpsZF0JfYNkMNtX518Kw1GdKBdU9uLOOPO2o=; b=TSjcppTT2b0RLNY7BzdDFaGFpuA7z5+kxoAvxEOLkGNumJo7+nhBXhBW0ZbyoE7DAo9YY13BP2r1cQDdecYIR/+pqu2FB5WRhTYC8S02r8Xlxm8sU+WwedscnhOOjvUaif54RVyMOd3Ou6u3KzEZveKsU45Fyc+s3GMXI/ujwEw= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0993.namprd04.prod.outlook.com (10.174.250.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.14; Tue, 27 Nov 2018 21:08:25 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:08:25 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 12/24] riscv: tcg-target: Add the extract instructions Thread-Index: AQHUhpVWuHl43aL1XU2YEtdPFb5dhw== Date: Tue, 27 Nov 2018 21:08:25 +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: BYAPR03CA0021.namprd03.prod.outlook.com (2603:10b6:a02:a8::34) 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; MWHPR04MB0993; 6:bk0bk+1XCNn3uMGiEi1GxK61c9+D5UK/MM8DJIUq9SKO5+w8RXAF1XQKDYAHqF/GZKXlZcfCihot573XkR5pXZHYfAARK9NdUH59KoUSVxeok21RKpXuVD7phsSzIoZ8zkgVn5wzTV3YETuL6hwkzmGCD/CN55UzEuGjgbsqPJETENKtkGHtgtAWslafpHlWfKLQuzIM3aDOYgKwpMl+bAb0LNLuCyVHB6TcPlXZVdTxRcnG8mE9IkSwO84S/ChF1OjggQoXMP72Z8p9Y1gp9dtvh9mlPl8qMp9xd1H/RaxH7/dvdQpgdYoO80V1PQRgwxCM0sxNh0btqg35yspDM8GGVMAO7eLD8N7CowL7CaMvzgeqznnPOOLsuY5+gT+GQ2F26MabXdug1HXfxoZ07VLMfv8B1kCGBmeSWASeC690y/ZjO7ocIYBf1tKuPK8m62xYVXUIjLSizUFzsKN8bA==; 5:wsxquLjGr81oahtdyTXYasjv+Ni9QBMhEYT2lxdqvfCM5fHl/niKKk4ehUDrixbpNUpHh0kkM71OYgzhfHTGJvNsntPlQZcroYvG+bEWEvGQMhgVhz9/XdScFQ6PFt2PdIivIsRAiT5u6P4ariFe0UviQWqe96HYw8mKmBHvyUg=; 7:EJg2q13GucFXV8iWN/UqMSGNXzEV8kD8bRdDZQHsXx9UJKK/ey7j/x9sLTlMEzJzs7pR0pz9ag0WWp4rw5GsO0lNVEech5H2S0F7kdypX848mEodTAia24nbGRHdfBgQvuDt6zEt9sjMfj6DAfmkwA== x-ms-office365-filtering-correlation-id: 709bca48-e944-40b7-eb5b-08d654ac7897 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0993; x-ms-traffictypediagnostic: MWHPR04MB0993: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231443)(944501410)(52105112)(93006095)(93001095)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0993; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0993; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(376002)(346002)(396003)(136003)(366004)(189003)(199004)(7736002)(97736004)(305945005)(54906003)(316002)(110136005)(8676002)(50226002)(3846002)(6116002)(81166006)(81156014)(8936002)(6512007)(478600001)(39060400002)(6436002)(72206003)(6486002)(53936002)(105586002)(25786009)(118296001)(106356001)(2501003)(5660300001)(66066001)(4326008)(76176011)(68736007)(486006)(6506007)(476003)(99286004)(386003)(44832011)(26005)(11346002)(446003)(2616005)(14454004)(2906002)(86362001)(186003)(256004)(52116002)(71200400001)(36756003)(71190400001)(102836004); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0993; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: N7WYKcKoVo2m2aEjRKXyeQUUwa/WfUDrRB9/pU+FM+H2IjjG1DSU+JjVBI9jsBgTtaNrE0/pke43mpBbrK/ekmrPvafo4MW05ZOrQ2TL5IRh7nUv+zCkiNtx+PFeBjoCo30kCd5GrOUrnCfcDbYoHiOUocBS4c9IllBSM+9hWWH4iw/ICNWvvBavrDrEqkMAjoAv68qpIJ+BsXzuXjHnn2hJolOmVOT8nspwnzE/Ty3npWvoU0swBmkqUY/2PBHI5bC0z2Si0iKngURFqw+Ap2HIe3tQf3uE61Fld6OdawzmrC3ySJA0FnMRv/fDlWbEIjtJ2EPVbKca6TaSkSYVuYAnnVJzsXZ+cHxhcf0mdkc= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 709bca48-e944-40b7-eb5b-08d654ac7897 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:08:25.6177 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0993 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.141 Subject: [Qemu-devel] [RFC v2 12/24] 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 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 e5a07b146f..4291a00962 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -512,6 +512,40 @@ static void tcg_out_movi(TCGContext *s, TCGType type, TCGReg rd, } } +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_SLLI, ret, arg, TCG_TARGET_REG_BITS - 16); + tcg_out_opc_imm(s, OPC_SRLI, ret, ret, TCG_TARGET_REG_BITS - 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_SLLI, ret, arg, TCG_TARGET_REG_BITS - 8); + tcg_out_opc_imm(s, OPC_SRAI, ret, ret, TCG_TARGET_REG_BITS - 8); +} + +static void tcg_out_ext16s(TCGContext *s, TCGReg ret, TCGReg arg) +{ + tcg_out_opc_imm(s, OPC_SLLI, ret, arg, TCG_TARGET_REG_BITS - 16); + tcg_out_opc_imm(s, OPC_SRAI, ret, ret, TCG_TARGET_REG_BITS - 16); +} + +static void tcg_out_ext32s(TCGContext *s, TCGReg ret, TCGReg arg) +{ + tcg_out_opc_imm(s, OPC_ADDIW, ret, arg, 0); +} + void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, uintptr_t addr) { From patchwork Tue Nov 27 21:08:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10701455 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 5D00013AD for ; Tue, 27 Nov 2018 21:21:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 49BC52C5FB for ; Tue, 27 Nov 2018 21:21:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A1F52C632; Tue, 27 Nov 2018 21:21:00 +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 A9DD32C5FB for ; Tue, 27 Nov 2018 21:20:59 +0000 (UTC) Received: from localhost ([::1]:44553 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkmw-0000MB-Qs for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:20:58 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36614) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkb3-0005M5-79 for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:08:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkb0-0004bI-1t for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:08:41 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:22278) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkaz-0004Ym-OA; Tue, 27 Nov 2018 16:08: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=1543352918; x=1574888918; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=I/5IfTT9gps4DoMkUtIB+szKuZrEgyAE6cqGLgaezho=; b=XNcGvVbWOtB32uio6s2hCnqfcNS3u/Hggr31DXlEg1SKaoBJUlxOQduv CunvIDCKSKSlh76yi02ii7F+PBVB3YUupJZaRdi8Vn+o1tH73PlIFeGXI Si8kLfSW2SgOiThvGynUOe12S0JhYGqQzh4gSpzCqZqxNezp8oT5F0KY+ UQHKQhLy/qDyTKIaDFaWZgUqzD6nFoiENoiZbHX3hy1LvfRkqmFcK7JVS Q/11y7kSDsmirAyujO3HVCj/3/vUvEecJchMSEXaSP9hFTHyu3A+rgMN/ /cMOM/rC/iLFLzZ/0KCFEmWG9YSl0kPAA+mEx2OaKZ5xk1nwp6JN8/xQk Q==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="96433671" Received: from mail-sn1nam01lp0118.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.118]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:08:37 +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=wjuOyakSxlhQYR0lHVFt0UvMtLCrA5E6QzHaLF5S4Mo=; b=DRNXmkFY5ZJY4bUv6fUYXNVVYUyn2YVCMSo2vK3ubxnREcAUtyYLxAuZxrNb9vK0nV0BXIXo6LS2VbvaP9UOOsdg9LJ0Ax3m/5Wu5V+g1FIcWGvUDuOrFNmMKCBaprwDhoLT4PKu7ClO42heCRWuAIbnR5vEbrzeB7KaLLwDeDU= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0993.namprd04.prod.outlook.com (10.174.250.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.14; Tue, 27 Nov 2018 21:08:34 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:08:34 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 13/24] riscv: tcg-target: Add the out load and store instructions Thread-Index: AQHUhpVbpjUDxAI5uk2WiJOfYvpYqw== Date: Tue, 27 Nov 2018 21:08:34 +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: BYAPR03CA0008.namprd03.prod.outlook.com (2603:10b6:a02:a8::21) 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; MWHPR04MB0993; 6:gRwY1P3bCvGgWnIuAjCr5eUVOIP9XUsBbcsuDL5Rl19BYZfPqHYK7Mp8vdcxuOQisi/uLb5aP6M1TQ6NjOv3Ttwq8WM/ScIzR78omooCV/ZgRf5AS54qJHHE6YcWZsfMGM3i0Qo0jOhyqc8NShzZgZj6VPRiw9IMJ5T5L2/Vhdx/4mF+3iv9mOVPUf0I80NVzXqvnpQOZJIkfrAsjJr/tIIIyu+mvJ/HYjJw6QUnLuxOJq35OEjBa/ZLpGgdqWm0Gg2SFdhsCcyFmCo1Ql01174b9lwgqsk6AlUQSyrb+uEQfCqyUgI8WNCIo+JeAzcqY0Hn9h5P9sIoBZS+nbdZNQzP0R4yab3AWmU0ViiPL+KXiRibBscgUm9DoA72saJhHpYXAdHFl7PfY+0c1ygzmRPjh8X1UV7gGf3g8Usbcp7TDeZ/XnV+IDusP17+1Zq2fMf+qIJjQpH+gkuf9U5k5Q==; 5:LiClUUahwekIng5pjimZomLAPc21QyOoMfHJbOI9MXouPNjen5x0Vc+mSPe/yYIstiPhaIJ5b95VMrj5V068CtV9s9Ltw6v9Ker3TemIv6472AhMktNRchXEF3T1QnjEERx/ySzsKWownWgiGVXjOaDggUoGGsUZ03tB6oGKHNg=; 7:JeMAreSiiiu83hPGYVYNLsavp/H//gIsms9HLdCfUABtcU6R3BFZsSNpyU/kPF5T6j25TgPWU5Nq5S+lezG6wcUF/6Fr2PfmNICbFENZClpmQ/6vfAC3MuxhhTS8lO4k6Uc5oaaDenPdrVlvlFNHOA== x-ms-office365-filtering-correlation-id: 6ca05593-2e51-49da-787c-08d654ac7df0 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0993; x-ms-traffictypediagnostic: MWHPR04MB0993: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231443)(944501410)(52105112)(93006095)(93001095)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0993; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0993; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(376002)(346002)(396003)(136003)(366004)(189003)(199004)(7736002)(97736004)(305945005)(54906003)(316002)(110136005)(8676002)(50226002)(3846002)(6116002)(81166006)(81156014)(8936002)(6512007)(478600001)(39060400002)(6436002)(72206003)(6486002)(53936002)(105586002)(25786009)(118296001)(106356001)(2501003)(5660300001)(66066001)(4326008)(76176011)(68736007)(486006)(6506007)(476003)(99286004)(386003)(44832011)(26005)(11346002)(446003)(2616005)(14454004)(2906002)(86362001)(186003)(256004)(52116002)(71200400001)(36756003)(71190400001)(102836004); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0993; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: uj/4ZsuTupN/6xIOql3MhTCSGZcLISZmPI95AveQGpZfG2Cl2O2Jq0kOLdGLBERlbj+auw9NX8q1oxlkAFAMHRmNlw9r310a4TpVJCQ9QNkH7g5XGc4fLobc7od+nyv4nTE4AMJ9xW0Xs1U6wSXQyj65CqWrb8TM84I2qzQQ4fsGEi8L1RTm6mlcxELaxn2JMR4Hh9Qb2j+iqmFsb68XmEb0ORxfO59Hl/pvwZnpbMGIK/ZTWblLNwmTggL1QCQqQHyXtSzHV2XhyV61LNNJPGy/vyvigmC48G9yVNmW+j+bJKV0lXCOA5OhxI5xjM3w7WZiYF91Sah6dZ8Z7c1Euu9c6ON8iRetVMblKCcOjuk= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6ca05593-2e51-49da-787c-08d654ac7df0 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:08:34.6023 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0993 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.144 Subject: [Qemu-devel] [RFC v2 13/24] 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 Reviewed-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 60 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index 4291a00962..cac4a4b615 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -546,6 +546,66 @@ 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) +{ +#if TCG_TARGET_REG_BITS == 64 + int32_t imm12 = sextract64(offset, 0, 12); +#else + int32_t imm12 = sextract32(offset, 0, 12); +#endif + if (offset != imm12) { + 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; +} + void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, uintptr_t addr) { From patchwork Tue Nov 27 21:08: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: 10701447 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 F3F8D13AD for ; Tue, 27 Nov 2018 21:18:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0A142C2F1 for ; Tue, 27 Nov 2018 21:18:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D02212C316; Tue, 27 Nov 2018 21:18: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 1FD9B2C2F1 for ; Tue, 27 Nov 2018 21:18:39 +0000 (UTC) Received: from localhost ([::1]:44535 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkkf-00074Y-VH for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:18:38 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkbC-0005TT-TZ for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:08:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkb9-0004p1-AS for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:08:50 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:22284) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkb8-0004oQ-VC; Tue, 27 Nov 2018 16:08:47 -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=1543352927; x=1574888927; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=HoY6Fv8fyrFF5yqgnX7k6847Pu3Ad0uBaNLAkPNw0eI=; b=Thq6DSLauI3tBMeZoeeFHZoyfDLSuYhgjBF74GmNN2o8+kzjprku+91i vlnqm7zO1L02CMEKNdHpkT/G+7AlIQimivHgwUExmZlBQL0C0M22Pid6H K9508DHK0AojxU7nw92EilQNXCmQ/ynMxE+yW0AWxd80uhji8xDK3SVGK pRMuJP7xa/O26XsWpH2lqOVpEsWQGF0Hu1YW98BXEHhtQ5OCffZJpaoMs 7mYy8JdhMJ04EdBtMfU4Lp5xpQGe9p23TrXge68DhpFKXcDwV7TfQ6Kdq W4cbquax/33qVjdCh704wrJgWl4fhdO/inbRJ94KL6l3t5myIi5N1oRsg w==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="96433684" Received: from mail-sn1nam02lp0015.outbound.protection.outlook.com (HELO NAM02-SN1-obe.outbound.protection.outlook.com) ([216.32.180.15]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:08:46 +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=ydmynCYXFSp7hM8kI8rBjsK/YjhIekDSjItp360N86E=; b=L5Su76qwtPCslS6Zf9OxC4Yt3AfEM12IF16pREHwJqzoSZaFhaFf+cjT7VjugvaEolx7mPdOtDEvWv6Agaqd4N37PCCWZedsLbkp5llTPnBjM6leUexCA7HayPM/msn3enjN/xr5nZb6XxbHp78yqHrHzrH91DyKn26wrCUDOiU= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB1121.namprd04.prod.outlook.com (10.173.51.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.19; Tue, 27 Nov 2018 21:08:43 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:08:43 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 14/24] riscv: tcg-target: Add branch and jump instructions Thread-Index: AQHUhpVh+5oytiNHXEysTr15uNa0MA== Date: Tue, 27 Nov 2018 21:08: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: BYAPR03CA0016.namprd03.prod.outlook.com (2603:10b6:a02:a8::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; MWHPR04MB1121; 6:hQ6k4mPJ3xoChfSeHQihiC7D/1L7BkuWrzGY4cJ/9Q08jWX2q1eR0+CxFbq+BUl1/ILBS5H8s/ckimI7y63A109fE7rBSeMQ7ctYWyLHGVAsdikRG7s7y2tSi5dDI+JESsojjtNDyWUvFoTgW/BPj/FljmVBgZd1Jwl/lU0pNw18/lM/0pOZiZpth+44zGPzrD8j1K9FbKVs+w2wcv77hXL2Fk0OLHK7MVkFMPbHAba9G8jGB401484FGF/RsFxLYWY1Rytqru+6rTw0t4Qm6SEbaxMiFkr4b6LxNzx5D01XrSKjbPztJfhdXmaBeDgLOpMdPIjJrJXBzetPmVFImotcOC0qrP90+Fq+36ZLys1QzOLEhKHPlicm450VHgbx07YYJj8r0bsoCaAC/200T3pXTQ/DgtUgkHwmE49MWL0LTznlY0w25nR7G18rIVE59nyAMb5htt09R+oujv9IHw==; 5:a13WSld9/nHaSWY+smNdZ/Qo6Oq5EOu6mz1FURNARPpFGunROsW4+hMEQrvlHTMJbVJuA94QiaBx2eE0Zc9fuavo3bbd1a0/ZnXSDXghMEVOnKrdg7nTYR/f5pBd9eoBvllFgs7f0RQjp+QlgSUef8f++neUOmWfQpJP7cdX5X8=; 7:PQe2L0KBYu6Xlk0f2+m2fVHx0ixaouljZcTVD1mbQhAIS06waQ7osipMQnDG/X8ELqjxbVcTcF1BMMm3xP+slO01cqlaylDKp4IwkLPgzktJfrvDGkrirdEZVuBHPUFl5Bp2xHS2ngxfcVTifaw8Zw== x-ms-office365-filtering-correlation-id: 01ccc500-2bdf-455f-f16b-08d654ac8354 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB1121; x-ms-traffictypediagnostic: MWHPR04MB1121: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231443)(944501410)(52105112)(93006095)(93001095)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB1121; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB1121; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(136003)(39860400002)(376002)(346002)(366004)(199004)(189003)(186003)(2501003)(26005)(256004)(25786009)(36756003)(86362001)(6506007)(102836004)(386003)(71190400001)(105586002)(71200400001)(97736004)(2906002)(76176011)(3846002)(6116002)(72206003)(52116002)(99286004)(106356001)(118296001)(8676002)(50226002)(39060400002)(4326008)(110136005)(316002)(6436002)(7736002)(53936002)(44832011)(6512007)(54906003)(476003)(478600001)(305945005)(66066001)(446003)(11346002)(6486002)(81166006)(5660300001)(81156014)(8936002)(14454004)(486006)(68736007)(2616005); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB1121; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: EH+fNQYkKukXcitSmum3YLCOUAd7JoEz4BOffipk4PBGRWIe/0b8Ve3XYeSLga0u4wRsQVnnJrs7uMkwuXLwHxVWisIDy68Ytii0/NrTZ0ZhhFzVoIfdqo01YCWTTsdevCdrpcnt6WsYxVl+kmwU6cW6PZCmcel8kiwwMEIQjqMfZ5qZGo0BqQDlRC4ppm91quQnMPUotog5G2F2wlBPTmt30nXHu82qyYpZybZaiBaYd8k1gaAOve4filOoiFyy6QYyqleVPFPIxjtmeoLFsXMVJ5Qe9toZbjPm9KFioFwZOvv+BT0xzChvAXuURdwXU8QDSkc23NNi5fU/0iKbRzmTM8rXZZ9KE9YQxKt1Cto= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 01ccc500-2bdf-455f-f16b-08d654ac8354 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:08:43.6962 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1121 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.144 Subject: [Qemu-devel] [RFC v2 14/24] 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 --- tcg/riscv/tcg-target.inc.c | 141 +++++++++++++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index cac4a4b615..97831bfb9d 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -606,6 +606,147 @@ static bool tcg_out_sti(TCGContext *s, TCGType type, TCGArg val, return false; } +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; + bool swap = tcg_brcond_to_riscv[cond].swap; + + tcg_out_opc_branch(s, op, swap ? arg2 : arg1, swap ? arg1 : arg2, 0); + + tcg_debug_assert(op != 0); + + if (l->has_value) { + reloc_sbimm12(s->code_ptr - 1, l->u.value_ptr); + } else { + tcg_out_reloc(s, s->code_ptr - 1, R_RISCV_BRANCH, l, 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 == sextract64(offset, 0, 26)); + tcg_out_opc_jump(s, OPC_JAL, TCG_REG_ZERO, offset); +} + +static inline void tcg_out_goto_long(TCGContext *s, tcg_insn_unit *target) +{ + ptrdiff_t offset = tcg_pcrel_diff(s, target); + + if (offset == sextract64(offset, 0, 26)) { + tcg_out_opc_jump(s, OPC_JAL, TCG_REG_ZERO, offset); + } else { + tcg_out_movi(s, TCG_TYPE_I64, TCG_REG_TMP0, (intptr_t)target); + tcg_out_opc_jump(s, OPC_JAL, TCG_REG_TMP0, 0); + } +} + +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); + if (offset == sextract64(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 == sextract64(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); + reloc_call(s->code_ptr - 2, arg); + } else if (TCG_TARGET_REG_BITS == 64) { + /* far jump: 64-bit */ + tcg_target_long imm = sextract64((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); +} + void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, uintptr_t addr) { From patchwork Tue Nov 27 21:08: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: 10701471 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 A294D14D6 for ; Tue, 27 Nov 2018 21:29:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 91C782C257 for ; Tue, 27 Nov 2018 21:29:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 85E972C25A; Tue, 27 Nov 2018 21:29:15 +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 912992C257 for ; Tue, 27 Nov 2018 21:29:14 +0000 (UTC) Received: from localhost ([::1]:44606 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkuv-0000Gj-IU for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:29:13 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36799) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkbL-0005Zr-Ot for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:09:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkbI-0004tF-II for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:08:59 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:54878) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkbI-0004sX-76; Tue, 27 Nov 2018 16:08:56 -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=1543352954; x=1574888954; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=tQRG14xkKjYTpNjeoc0Nj4oIFEs3WK6oqNPZJEZQh50=; b=ZJtCMHF0nhhNvCTBwBTyxUI/0VVMPa1cVM6VpBrOUh8fmuMF8Omr8vOR 0eBcDLyXGn+Fp2QzNreF24zsTwXM0eesuMo4BOV78LYTKmDEoZDrYaQol Jvgd+Z4Nh6um1JXpqI7Fv8q3KBhcrJvf8AkW+IvLCEhcSJXk8rC1lkHbf v1xezDRMTU+HXHM23HFdFfol/I3DapUwOlfauayEUJx7dNc7XqZWazqw3 u2jH8YuywD6SI1Ukdv+HYfGTORiZMuou/1ZSzv+1NUfXtUpF5PxdAT3l3 V/vruqq0Ff6lffnab0uLbMbE8bieglSYl8dM+BKfXABDmh9BpDAGc/SSY A==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="193052841" Received: from mail-sn1nam02lp0021.outbound.protection.outlook.com (HELO NAM02-SN1-obe.outbound.protection.outlook.com) ([216.32.180.21]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:09: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=eHwaDDDPX44wG5Tcd+ei/aePZXQb7d5Ebf8+0XUbCPU=; b=onzQYklS9KYmjIuih8pZYJfbJDB2DIpglBQWtnWIrlel7xgd35tRQekB6WVCr+7wA4I2DN4fGXMMYBDXvaK/2C0aTOp0zTz/VYMv2ce+nXWWowBmJ1W3uNtgE/HTQRY98UqBstriJiFGtFkRZ4vGZXpXZkMIN7Ifq3cToIAqSEM= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB1121.namprd04.prod.outlook.com (10.173.51.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.19; Tue, 27 Nov 2018 21:08:52 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:08:52 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 15/24] riscv: tcg-target: Add slowpath load and store instructions Thread-Index: AQHUhpVmqv8/IUOGkUavhisHE2Uc3g== Date: Tue, 27 Nov 2018 21:08:52 +0000 Message-ID: <653c85e3b65137352800f540eb195dc801159084.1543352682.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: BYAPR03CA0001.namprd03.prod.outlook.com (2603:10b6:a02:a8::14) 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; MWHPR04MB1121; 6:JV0yQg/809hR1oBZUZJ/sKM2RR4RNYquuqD0PiU19dgYcjvAb/Lqdz384CdvtJ3Vt6Vaq9ijEWFgv6s6qyiI4iULWdrtvyIb1s5b+Iir0+oOr/aWFYBgFKG8n7OQ3TMzeyJukFdetfypofSceJk8S9H7hknaotVOuLXY0qdwm8CnTiQ517LuTPZPsK6vGgNLo6qgHLUscOKeJd1JNpQKdYdBLMbZtIsZKpncMRIpl0USS5H1Zb6jBRo1iNstC3l8dkLJo/as6m47OMqP3haL1l+UN4JxtgSDqZ5W9ZsLrRUuEfyWACb1kcGgh1+63V6rS6odXVG1ZpsKjix6smef58VCfYbmKNEjamZ8gBAUWJ0WuGQul7mJAcVqtmepMOIycnUAwkkxWs44oiId4saHL0yWmtqUd+FrQO/OKB+s1ibP/tR4z7fHewGQWFSw06kI4aCuxHmI9ejEORES10ftWQ==; 5:/7KAqYJk+7vtGqSg0y1whu83eUlN+cYwAUHEIZRwjhYYoA0ycwg35covBhA5h9EhQW474pVSRmJg0W0897kwyyGntCdUm3/KveztfEO8FIXE2D0i4EAyxiTelkox/viAFn8yNdBKJhQFYdPnguIT+gj4UN/CpnDd32lYceu4zcQ=; 7:IG9wPahKbULuzFbXASEGH/mgZCs5CyAj2BJm5F2LWCZbKK7r1IIcYQWiI8VC4i58Ptg2oFJTzrqBS1g7jV4uhWlEGPoc6YLokbpIlZnrGBTXGDBoYoXueQBCK9oLZTd2lgrxkTUx9KDfdRsgOxs51A== x-ms-office365-filtering-correlation-id: b23df7c6-477a-48cf-92be-08d654ac88a1 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB1121; x-ms-traffictypediagnostic: MWHPR04MB1121: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231443)(944501410)(52105112)(93006095)(93001095)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB1121; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB1121; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(136003)(39860400002)(376002)(346002)(366004)(199004)(189003)(186003)(2501003)(26005)(256004)(25786009)(36756003)(86362001)(966005)(6506007)(102836004)(386003)(71190400001)(105586002)(71200400001)(97736004)(2906002)(76176011)(3846002)(6116002)(72206003)(52116002)(99286004)(106356001)(118296001)(8676002)(50226002)(39060400002)(4326008)(110136005)(316002)(6436002)(7736002)(53936002)(44832011)(6512007)(54906003)(6306002)(476003)(478600001)(305945005)(66066001)(446003)(11346002)(6486002)(81166006)(5660300001)(81156014)(8936002)(14454004)(486006)(68736007)(2616005); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB1121; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: PgCfx0jjH+K2hP+2MKsjBm4MpAwUphOLcJwBOT5MecnlJwSmzn1YoXWaD5A7Z2P0ImBn3HHmhbBa3XUADxbQ47Frl/0ciC69Ad+9XpuwAZyv1ntA18f6iRjflko6t6/MAZ4wZkslgjqp6yHqbQ2r3wwk+vhuxgml6jlEmmGSek0Uu0g1K6Ue9Y+EWNxO+DLO5u01R2UyOWBdzvsCFKEn4KGNdUX5HR1pbQ44FvTw5pUqv67aybYlJ70TVbsjccQtxaMWL/WvpxWFx6K1pczd4ULcNRej8hLWa3FHjkRrNOf86WmqthWN0wiicRbTEzmAjp0EUm3ucmFefuHzqSMrFivzt8Iw6urgAQBWrDiH61c= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: b23df7c6-477a-48cf-92be-08d654ac88a1 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:08:52.5714 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1121 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 68.232.143.124 Subject: [Qemu-devel] [RFC v2 15/24] 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 --- tcg/riscv/tcg-target.inc.c | 244 +++++++++++++++++++++++++++++++++++++ 1 file changed, 244 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index 97831bfb9d..4f3a6de52c 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -747,6 +747,250 @@ 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) +{ + static const RISCVInsn fence[] = { + [0 ... TCG_MO_ALL] = OPC_FENCE_RW_RW, + [TCG_MO_LD_LD] = OPC_FENCE_R_R, + [TCG_MO_ST_LD] = OPC_FENCE_W_R, + [TCG_MO_LD_ST] = OPC_FENCE_R_W, + [TCG_MO_ST_ST] = OPC_FENCE_W_W, + }; + tcg_out32(s, fence[a0 & TCG_MO_ALL]); +} + +/* + * 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); + int addend_offset = (offsetof(CPUTLBEntry, addend)) - + (is_load ? offsetof(CPUTLBEntry, addr_read) + : offsetof(CPUTLBEntry, addr_write)); + 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; + TCGReg cmpr; + + /* 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 - sextract32(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 { + 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_cmp_op, TCG_REG_TMP2, base, add_off); + + /* Clear the non-page, non-alignment bits from the address. */ + if (mask == sextract64(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); + /* 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 */ + reloc_sbimm12(l->label_ptr[0], s->code_ptr); + + /* 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 */ + reloc_sbimm12(l->label_ptr[0], s->code_ptr); + + /* 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 */ + void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, uintptr_t addr) { From patchwork Tue Nov 27 21:09:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10701475 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 AB658109C for ; Tue, 27 Nov 2018 21:31:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DC7F2C632 for ; Tue, 27 Nov 2018 21:31:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9232F2C75E; Tue, 27 Nov 2018 21:31:24 +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 E32842C632 for ; Tue, 27 Nov 2018 21:31:23 +0000 (UTC) Received: from localhost ([::1]:44626 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkx1-0001q0-3f for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:31:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36844) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkbU-0005hm-8K for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:09:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkbR-0004wL-2W for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:09:08 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:54888) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkbQ-0004w2-Qi; Tue, 27 Nov 2018 16:09:05 -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=1543352967; x=1574888967; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=VwlyRhhN9GLNopdQABeiP+ZEY2McK3i2uvgVaZK+ig4=; b=N0L1TNnbClFj4P1hsP+PJrH7bNxy+R1TBd9YmervRM7/OelB9vMgSeGO Y+AU3IOIzpwSlQngFkWeBhckE+oH9y2F+98DfV1JyixV82EDEabPRz242 zJIn8pub2HrNWNGCZxySWXPpmSHZL8/eHABpvuQs7uF/GITv/lxaD7NLJ EM7EUknvp310FrILGvZQXBoO/89vfrbpyipruSPf/ENeXtcIWTUFIgOIu MZTmEz767Yrhms5JFXBl9qcbyD6NYiERdJAVKlgyfNvDLOYyqOKT36ZJK Y9vTIqTCzl7goFgIVZkWIb43IwQBm0SRoi8Etvn3jUWwYRbN6EI6O4awh Q==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="193052852" Received: from mail-sn1nam02lp0020.outbound.protection.outlook.com (HELO NAM02-SN1-obe.outbound.protection.outlook.com) ([216.32.180.20]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:09: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=m8osda2amt5pgnIZfJFH6H+0IA1KXDN7NXTJ0df7/s8=; b=P5qBGvtYnRT3ifRGxGdFMbfnsRzKe0+HUm/Z+7CxzySzK/ck86AlOf0vBunz3qG3lUqI7KFlN3LQj+dJDoZoRN9wjyYgk45X7tJMHX0lZ+AYY/XSuALdj+hfYtUh9lfW5f6L0snyVMmG0ynu59XsfJ20iuKPkgkkzoGpLjRU09o= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB1121.namprd04.prod.outlook.com (10.173.51.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.19; Tue, 27 Nov 2018 21:09:01 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:09:01 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 16/24] riscv: tcg-target: Add direct load and store instructions Thread-Index: AQHUhpVrN8WK4hC+y0O/caohQayecA== Date: Tue, 27 Nov 2018 21:09:01 +0000 Message-ID: <16a81c50540d8852facdc5d9dde3a79288314a6c.1543352682.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: BYAPR08CA0002.namprd08.prod.outlook.com (2603:10b6:a03:100::15) 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; MWHPR04MB1121; 6:hP5w40C/seKrG0e54o9QJNzfktfzxTtLM5vwRYVywKKhDGmAF6UcFNVcS/u61cbCavTHDIdSFEjiV0qn1zE0ztRHLGtyCmHx3wbAUl5F99SLdAmMzdZ5lYpUqyeQCFdYBkeLygNtH0kemgbePzR+7sFdjzul0F628AGMKkgIvB574pOgSmAIkvHmcVM4zwjcMsM7u+RAe5CmCQ5vBkZBXs3nGDYKuh8Mg1Owr3lpEnRBggbgFWPvdDxDfc7sknNpy7MWC35ECkXJwSoZLqEUdnGx5BMCqa3Mc252qebLrCRod5gQ0OgtrcEGWa1NkQwAdtt/d41A0LgiX0zcTxJWxPXNIxayoFkBVr9aGaGLmJI1Gui9e2GvnFi87P97sOtBRZkOSYn7duG/wBice+BYmCamEaX4Gur/UCl+BvWUYT/CWG0L5j2mzvt1krM6jwpC9pHgAiepxp+oJLExScRBug==; 5:ciwg+ZyeyJrH1rlte0IiB9xzJOC6vx8XKc8NP80AQM2F6/DcwfLb0JtslF5PZCk9zZWDHqj1qctVjc7L/7jmcfYOUiEwpivyYMQXr4vTxtmXCTQ04Ue/6RnTcNnh9UeWBlyogxqvja/pj/f7q37BTGRC2bDb785avSWrhHGYoDs=; 7:yDObPSsgHDp+pU02aP2xDR6Qm7zu2caqZ1SJitEpvfINcdMgV7yGGA7eFSw3dSDhnJganvoisiM/ChgdIlL1whVWUir/rHYiAd+i+dkNE7OZxb7L07JrJbHinZazeacwKXyU16TeMMubkTncKnsbxA== x-ms-office365-filtering-correlation-id: 1a25d3ee-542b-4282-966b-08d654ac8df0 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB1121; x-ms-traffictypediagnostic: MWHPR04MB1121: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231443)(944501410)(52105112)(93006095)(93001095)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB1121; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB1121; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(979002)(396003)(136003)(39860400002)(376002)(346002)(366004)(199004)(189003)(186003)(2501003)(26005)(256004)(25786009)(36756003)(86362001)(6506007)(102836004)(386003)(71190400001)(105586002)(71200400001)(97736004)(2906002)(76176011)(3846002)(6116002)(72206003)(52116002)(99286004)(106356001)(118296001)(8676002)(50226002)(39060400002)(4326008)(110136005)(316002)(6436002)(7736002)(53936002)(44832011)(6512007)(54906003)(476003)(478600001)(305945005)(66066001)(446003)(11346002)(6486002)(81166006)(5660300001)(81156014)(8936002)(14454004)(486006)(68736007)(2616005)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB1121; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: ucrJpu76lb184auzk8MuotLS6uOxIPwI27S0LArrBBoR04zxmWZmRGzku7zejhXuSd4AtEIv14CFx6uFqvtY2YVhI26EEARvrW26O+76QQ4rIqbjAlTmCBpVeqlfvpgz14UlnueqcdDuYA/MvQxi/RNJn+l6/I+FW5UP8EmEBqdRfU8ltFx930p0mX3aM9S8K6k+lj9lFPL2WpxpgIfnknaZaqkEIOv8YSk3GNIEXJGkv1iUWG0dTAfAZa4w33N4L0JKqHK93AXf8O5Gs0bMPk/ZN4y8dHrP83gtQwpwexPopHSoz+ptyO6J4I4aCb+X+Gn5A0WOGOsDo7Vr+f5iVX5Br+DZphDyBB678BF5d44= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a25d3ee-542b-4282-966b-08d654ac8df0 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:09:01.5091 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1121 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 68.232.143.124 Subject: [Qemu-devel] [RFC v2 16/24] 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 --- tcg/riscv/tcg-target.inc.c | 162 ++++++++++++++++++++++++++++++++++++- 1 file changed, 158 insertions(+), 4 deletions(-) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index 4f3a6de52c..e3b5f48848 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -816,14 +816,10 @@ static void tcg_out_tlb_load(TCGContext *s, TCGReg addrl, ? 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); - int addend_offset = (offsetof(CPUTLBEntry, addend)) - - (is_load ? offsetof(CPUTLBEntry, addr_read) - : offsetof(CPUTLBEntry, addr_write)); 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; - TCGReg cmpr; /* We don't support oversize guests */ if (TCG_TARGET_REG_BITS < TARGET_LONG_BITS) { @@ -991,6 +987,164 @@ static void tcg_out_qemu_st_slow_path(TCGContext *s, TCGLabelQemuLdst *l) } #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 +} + void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, uintptr_t addr) { From patchwork Tue Nov 27 21:09:10 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10701451 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 E455D109C for ; Tue, 27 Nov 2018 21:20:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D335C2B473 for ; Tue, 27 Nov 2018 21:20:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C52032C5FB; Tue, 27 Nov 2018 21:20:21 +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 B1DDF2B473 for ; Tue, 27 Nov 2018 21:20:20 +0000 (UTC) Received: from localhost ([::1]:44549 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkmJ-0008II-LA for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:20:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36901) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkbc-0005ov-Hk for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:09:19 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkbZ-0004zf-Ae for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:09:16 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:36196) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkbY-0004z4-Vn; Tue, 27 Nov 2018 16:09:13 -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=1543352953; x=1574888953; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=44P7/ZEgIDSKJXq6xfwxbQw5XDctSoFb2ufwhXiUqlY=; b=dknFKzXUgt74rXjIy80kMoE+HHmjf5OVt1ael/+TgmQXTBNiwmtQiEfh GE6h2mBHbPQTIJBoawBJtaRP/CikAXzUpwWKA8/p2Eff7NnB/3NOiApB3 VXbO6ci8hPN5bqCsUQtTrJrr5iEgIX0diKKAUbBCu8X1I9iMDde4SaMGr cUclt8Bl3ChOr3gMXjQHcBjg+DAH6Jq2Do2vyQBW0AXFVwkUg+r4rPKxQ qHdNIvWTQheNogwe/0TaIELfj3UXVolNuX6PcNM+ywqWa1hxgQM1ip34m Mt6VMOCpfOmQpBg3MkRKf2eCIDPZ85Lrl/0hUqzcycOVI3TU08l1lCzj+ w==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="100064274" Received: from mail-by2nam01lp0178.outbound.protection.outlook.com (HELO NAM01-BY2-obe.outbound.protection.outlook.com) ([216.32.181.178]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:09: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=OtkL7BnLR/uDkkBkDonzbvHBGjMEqhngOHFQhlH0uZM=; b=gzQl138I54M5zkneSxlsh+w9d8TJRt+HVs1iOGJh07LpG5PehfXLclEC/MYUwYNGVOWisn/aXtYiYgHy0w0Txgp/e2mnB7w0knrqkU4sXfKTUdFarUi8VxOyqxAtBr+4el1tV3u86CCmcR1lHHi40CTXvIIaSrlyLnak29bxlsU= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0639.namprd04.prod.outlook.com (10.172.166.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.15; Tue, 27 Nov 2018 21:09:10 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:09:10 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 17/24] riscv: tcg-target: Add the out op decoder Thread-Index: AQHUhpVwZCzwZtyI8USCrlDnjzEvCw== Date: Tue, 27 Nov 2018 21:09:10 +0000 Message-ID: <880230df9c7126169fc9a9d7fee09eb9d48c3880.1543352682.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: BYAPR08CA0002.namprd08.prod.outlook.com (2603:10b6:a03:100::15) 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; MWHPR04MB0639; 6:FMLma1yxT3TtuWW5VwmFaPbGJtrnz0Jbm/Sp39ICuUuSCNScKs9JS0ttvsiE5AMdkNN0Vs1mXsSup1KkTER9EvHlbv4tRudu3Uh3kpLmMSzksXvmuzp77ntpTV6TGOTOoPrDHxUnp8vR9Tt8p73O23pd2aTN604aEYGkbhX5TsyGnxQLDxdlU4NfSUJ/e4p3KAswq6H3ZclJpbB2pTcJgcthFKEwNlHuyT732dFfLqqGx8TkAIZP67w/jUEQbSwoEn19zkoYBi7GyRk98l10qLSF3C4rt2uB/EHBMQ0c/DBuKtvhuL7cwihHM8iNhDIyoQelwCH9l9P7YAOP/0qWaraREz2M9ZrI+x3lIK5KRuII2mRro39vO/1Sb01x45twqdiUydga/hWpfLqzacd+kJ+3ih9ahdjEVCLu6M5EHdK+bH7ath2vg6hvF4dYKqULt9IZ61Ke2pj1U1Siqw2+pg==; 5:dJQYejy2e2NTT0990xt/aGFYsXEmF9h9L/cSog/m4l3CLcyEiuglJPWEEYYzdGEof5/Ua51+XEfPzlUqqYp742UR2RR31F6xJFlSb7Rg+pwT6pmut10TVVD2oLkcHCvkreQEO6NSLx7uaq7NXESIdpt6UAK+fHAP76w36VCKCis=; 7:J+n240sXX5gT7TU9bvXDB9nmaBY9MX+vxh5iewefAfg+M8dEdyX/SQKA3cviXJOdWwZjhzpNZ4iB9GTb1C22YAqxNzoPmz/otd7d3SKLrUA5a1NMz4wtKBtS2WW+TywGc4fu3mWGWyXYiC6Oa4G0iQ== x-ms-office365-filtering-correlation-id: 3f46a399-1966-4d0b-7845-08d654ac9338 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0639; x-ms-traffictypediagnostic: MWHPR04MB0639: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231443)(944501410)(52105112)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0639; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0639; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(136003)(376002)(346002)(396003)(366004)(199004)(189003)(86362001)(6436002)(53946003)(53936002)(97736004)(6512007)(2906002)(66066001)(8676002)(8936002)(81166006)(81156014)(50226002)(54906003)(110136005)(5660300001)(316002)(118296001)(7736002)(2501003)(6486002)(68736007)(305945005)(36756003)(478600001)(72206003)(4744004)(71190400001)(71200400001)(52116002)(76176011)(6116002)(386003)(6506007)(102836004)(44832011)(2616005)(476003)(3846002)(26005)(186003)(486006)(14454004)(99286004)(446003)(25786009)(106356001)(39060400002)(105586002)(256004)(11346002)(4326008); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0639; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: bYPoNimt1N3IUiARusBFi/uZrJgcQPPNPPiIgXq0KWIf6vzdmOa7GudryhpDIkYfuy2yPeTCzNYI3KIX7AT4zpoM6yTADgxI83kXPdCwEH7dV/KofUYZ8LMMuSD4DWGGZx5w2gLMitCFWq8UxCD2CMmnpBKhMuOMCFFZEBWHm2yG/RW/6UA7Zobp5ld5VKgvvzG/p/dr8r8Tv1zW2AT66Wk+vucepNNzvgdzjiimFAVfY2IdmfwwPOeMGA2KURwYKYv2IXwEQuTZG4j/SXmjSheyr9KhMfC7B1aGF7k2Y2J73QdUTIIBTJRN4WbY4XtczbUJ9o48nM8hzw2POFNzBO1RDWuqc2tHBxZSruOA98Q= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f46a399-1966-4d0b-7845-08d654ac9338 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:09:10.3687 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0639 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.141 Subject: [Qemu-devel] [RFC v2 17/24] 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 Reviewed-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 472 +++++++++++++++++++++++++++++++++++++ 1 file changed, 472 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index e3b5f48848..d5fd7ca854 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -1145,6 +1145,478 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, bool is_64) #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]; + const bool is32bit = TCG_TARGET_REG_BITS == 32; + + switch (opc) { + case INDEX_op_exit_tb: + /* Reuse the zeroing that exists for goto_ptr. */ + if (a0 == 0) { + tcg_out_goto_long(s, s->code_gen_epilogue); + } else { + tcg_out_movi(s, TCG_TYPE_PTR, TCG_REG_A0, a0); + tcg_out_goto_long(s, tb_ret_addr); + } + break; + + case INDEX_op_goto_tb: + if (s->tb_jmp_insn_offset) { + /* direct jump method */ + s->tb_jmp_insn_offset[a0] = tcg_current_code_size(s); + /* should align on 64-bit boundary for atomic patching */ + tcg_out_opc_upper(s, OPC_AUIPC, TCG_REG_TMP0, 0); + tcg_out_opc_imm(s, OPC_JALR, TCG_REG_ZERO, TCG_REG_TMP0, 0); + } else { + /* 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); + } + s->tb_jmp_reset_offset[a0] = tcg_current_code_size(s); + 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, is32bit ? OPC_ADDI : OPC_ADDIW, a0, a1, a2); + } else { + tcg_out_opc_reg(s, is32bit ? OPC_ADD : 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, is32bit ? OPC_ADDI : OPC_ADDIW, a0, a1, -a2); + } else { + tcg_out_opc_reg(s, is32bit ? OPC_SUB : 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, is32bit ? OPC_SUB : OPC_SUBW, a0, TCG_REG_ZERO, a1); + break; + case INDEX_op_neg_i64: + tcg_out_opc_imm(s, OPC_SUB, a0, TCG_REG_ZERO, a1); + break; + + case INDEX_op_mul_i32: + tcg_out_opc_reg(s, is32bit ? OPC_MUL : 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, is32bit ? OPC_DIV : 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, is32bit ? OPC_DIVU : 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, is32bit ? OPC_REM : 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, is32bit ? OPC_REMU : 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, is32bit ? OPC_SLLI : OPC_SLLIW, a0, a1, a2); + } else { + tcg_out_opc_reg(s, is32bit ? OPC_SLL : 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, is32bit ? OPC_SRLI : OPC_SRLIW, a0, a1, a2); + } else { + tcg_out_opc_reg(s, is32bit ? OPC_SRL : 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, is32bit ? OPC_SRAI : OPC_SRAIW, a0, a1, a2); + } else { + tcg_out_opc_reg(s, is32bit ? OPC_SRA : 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_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_ext_i32_i64: + tcg_out_ext32s(s, a0, a1); + break; + + case INDEX_op_mulsh_i32: + case INDEX_op_mulsh_i64: + tcg_out_opc_imm(s, OPC_MULH, a0, a1, a2); + break; + + case INDEX_op_muluh_i32: + case INDEX_op_muluh_i64: + tcg_out_opc_imm(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" } }; + + 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_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_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; + } +} + void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, uintptr_t addr) { From patchwork Tue Nov 27 21:09: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: 10701465 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 7EAE0109C for ; Tue, 27 Nov 2018 21:26:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C2DE2C2B7 for ; Tue, 27 Nov 2018 21:26:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5C4192C42C; Tue, 27 Nov 2018 21:26: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 B9BC62C2B7 for ; Tue, 27 Nov 2018 21:26:39 +0000 (UTC) Received: from localhost ([::1]:44587 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRksR-0005hc-13 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:26:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36997) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkbl-0005vx-NN for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:09:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkbi-00053y-Bs for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:09:25 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:36212) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkbi-00053G-2m; Tue, 27 Nov 2018 16:09:22 -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=1543352962; x=1574888962; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=tu4KubrJthdndQ0xqyeHd3DzahtX/3r37vfVnXaI1bo=; b=C5a/TFKGeaYS1nq58ur0BDbQDrUwNZpkQcJS5oy1eb5KQZu8zY4gj7mr YO25YXGun++8mloWkzTW/acEdrQI1aBx55mp5Lg42KWNMSbUQKM3LDfrh 8IqAbpu0/0u9hDh0VdlPKV+GU0rVeeb72f7JhamDgu0l6CTe0oaDYj4pb 33Kg2SuEIE4FvkB6O0vpcgO11ILChTTqXIoRI6OzzeUHl8SlHuif/8R4P aUbx8cNAu1oKBFvm9WqdfjjHlAr62aw9hGlnKv6/dsyzuqRaskWkoIega Y7xUdE/xLEoGH08a9RsWE5mq4akSOMdAqdX6CsV4S58UhY960M709P+Ib w==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="100064282" Received: from mail-cys01nam02lp0050.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([207.46.163.50]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:09: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=ipxbCc4wnnWwN7HdTTtEL6Lf7WTe+OjAJEs7R0rwVps=; b=S2ODdhFe6lLR94YmulbcyiYzMWxhXTC0Ybyvkn5une6Vqm06c3X2BlIAddT6BA1xECKOYpzIRyH65ZGmjM4Eo8TOfrQqgobRR8SEov9LZH/IUwnYXDibuAgYqPjENFtMAL0SvUzlrYizfdoCSiE0au2QZKqAAREpjvoaWf2zkRc= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0639.namprd04.prod.outlook.com (10.172.166.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.15; Tue, 27 Nov 2018 21:09:19 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:09:19 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 18/24] riscv: tcg-target: Add the prologue generation and register the JIT Thread-Index: AQHUhpV2/7lATafQn02vG87pMsokbA== Date: Tue, 27 Nov 2018 21:09:19 +0000 Message-ID: <445bbf96c17c4bdb0857fe03707a8911d4b5fec2.1543352682.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: BYAPR08CA0030.namprd08.prod.outlook.com (2603:10b6:a03:100::43) 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; MWHPR04MB0639; 6:dUarxLvJF7hA1IN7LAOGir68oMBvXbm07MdCIeRYHvmruzp0jtXFV04TgiOaqpBhJ1QgWg/LqaJMG0ea7GOXZuk0diH0Necge2GrSGDw62KhDVh92UIQN7+yIDi9HzCQyeRKYEZpxbRY+UEPlb3yiKQrlrBefog9g5Fk6A0egogvDsHqpk9znzB7I3iZzy2/b+QNAT5l/bDl3VsEmz+tfDeyFtGC9y38eEjGH01FIhzZ85NSQZIEtgK3vNFFGGTQW/Jdu+xi4t8fHmZ4KzxpRDPshwH7bCCURAnEE1P+oRZcVpmGjD4JnMquM+z+3NZ+1fI5Fgs7g1twPwjxyI1vlWb3SdWWenyECntG3zUdNsr6/KBe7q967wg5tBKzCBYFAgybDMVrd+3v7I6CEKWCdcnYG48uJIjDRY6it4Azd4wpzLrQ7lLirzeuFoJQYXkXYuGF6RCOI1Ox/41iaD20WQ==; 5:T3bdYihg/1qkwzricoPnLxOKDwmB8eO8+xNnDQkG090W7VFY+DcJRqod4zFYDsdtJsJKNNjzSgrXb08ypvKwOX7uF90dTDUZoBBRXbse/ETvFOGw5PRB7JjcGdhRefHggqevdNPBDsVl488DzngP1gwKa4UpoTRdVwtTOpmRaig=; 7:9wU55c7PpIg6/NFzj2nsjRy+f3aJQJul1sEFLbg0FWpKDvVgmZWuaDK7Hvu5vkxjjBhU/q5ktFIOSoDGgpoQ+/EntkMhSz3g/syMmh9r1aI2/FOTZRq78wr7NmdLj1hKY/CkDd/bfek8TgNbme/7IQ== x-ms-office365-filtering-correlation-id: 49a64bf0-77da-4366-8995-08d654ac989a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0639; x-ms-traffictypediagnostic: MWHPR04MB0639: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231443)(944501410)(52105112)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0639; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0639; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(136003)(376002)(346002)(396003)(366004)(199004)(189003)(86362001)(6436002)(53936002)(97736004)(6512007)(2906002)(66066001)(8676002)(8936002)(81166006)(81156014)(50226002)(54906003)(110136005)(5660300001)(316002)(118296001)(7736002)(2501003)(6486002)(68736007)(305945005)(36756003)(478600001)(72206003)(71190400001)(71200400001)(52116002)(76176011)(6116002)(386003)(6506007)(102836004)(44832011)(2616005)(476003)(3846002)(26005)(186003)(486006)(14454004)(99286004)(446003)(25786009)(106356001)(39060400002)(105586002)(256004)(11346002)(4326008); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0639; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: hFSSNjPXbvlAj0/nfcibHEeClbQdSh26bCnUTGqmj3SSsnpA12OjXdYyL07kCiYSw0hZNvon1+pvTgnbdDY5rPI/pOjp8nw6V4WkTS9IDQhYr++zqXVlCWmUJlkBe+WZcTwvB3uoPdK/yxKoH+rkWeYrBH7y0UQIrfL5oqe/lmSkigf8lpj/7DyvrzXare6JUk/pvv4SZ+Z/Rp/Q6CwSgcOJzhHWXnvB5gglcJNH/bg2vHSQtDhOMp5bBG3gLeEhFUftixC9UFiSY+tKrZyiH2dv4yUscpWTmA6nfZDdgpMl5sS3PqxssZJnThZ/S3Lww4l7n9t7LmbG4bTTCislftd9b9wW+NyHC9TVXKzqMTY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49a64bf0-77da-4366-8995-08d654ac989a X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:09:19.3689 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0639 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.141 Subject: [Qemu-devel] [RFC v2 18/24] 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 d5fd7ca854..51961ade81 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -1617,6 +1617,72 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) } } +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); +} + void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, uintptr_t addr) { @@ -1631,3 +1697,48 @@ void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, flush_icache_range(jmp_addr, jmp_addr + 8); } + +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 Tue Nov 27 21:09: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: 10701477 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 0127915A7 for ; Tue, 27 Nov 2018 21:34:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC4662B6A4 for ; Tue, 27 Nov 2018 21:34:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D099D2BD4B; Tue, 27 Nov 2018 21:34:03 +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 536742BB20 for ; Tue, 27 Nov 2018 21:34:03 +0000 (UTC) Received: from localhost ([::1]:44638 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkza-0004jU-EP for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:34:02 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37074) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkbu-000663-JQ for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:09:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkbr-00058t-Ek for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:09:34 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:36228) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkbr-00058J-6U; Tue, 27 Nov 2018 16:09:31 -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=1543352971; x=1574888971; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=0UJUMZAl5jWUNS4qw735kIQJ999GrnWsP68bPYu4/H8=; b=fxv3+SmHmLhxhuOKoutTuqlYyoQhscVYZMSUKB+Eo3uGsPd+p9o8Gf3R 5s/yBZze9oKaUamZ30MtdJ6FxvIyXbNLgXs/5QaHDDmgDGQgFZQh4mtxI YzrXxRVEaZYZXkw5QL94Yk2IFrktxDB+uTqbSaGEiUjXVrT/BLwlhULQm EKH43yRzE0yQtuBBVxhiD8GLmNAvMjA8dWfvsELgC2+3S3eLXtmoHecIf 1CSJslNjf9B6Mo4Zi9znMP4XfasNaTKQ0bg6ykm/BPyDv0xtfKdptRj9j 8KiC4nMqBomRqpJtur4VVbYcPlhYRAZkRZ9yg7efLNTGNNgwxwayHCNys w==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="100064290" Received: from mail-cys01nam02lp0047.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([207.46.163.47]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:09: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=LEwwl76sQ3rvSMuy6XlwCt2DjvO80qZGSgZ8MyIb1aY=; b=XS29v+qaGhUPVrklAI+SVg29Osile13oO6UNI/CTRruYkNtLK3tuIFTOI/J2l3bbxtTf2Ima/bX1SEr0OrPvFMViNLCSHgXi/LlsfM35UXJKGAtYizbIB/F3F1OTRSKH5koBD0rAS8RwdM4a05Xt/M7OkufoUzlwqgHec8xKSpU= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0639.namprd04.prod.outlook.com (10.172.166.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.15; Tue, 27 Nov 2018 21:09:28 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:09:28 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 19/24] riscv: tcg-target: Add the target init code Thread-Index: AQHUhpV7+CvNYo28S06WJ/kBCvoxXw== Date: Tue, 27 Nov 2018 21:09:28 +0000 Message-ID: <7beac896a4d4ffd873c24a74f7f7be4118ba7e5d.1543352682.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: BYAPR08CA0017.namprd08.prod.outlook.com (2603:10b6:a03:100::30) 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; MWHPR04MB0639; 6:BhRXB7WpEhxr+m3BY6YyakRE2xDR616eWUDzOVuQk3sa/us3CIEUNJIYLBlxJN7Zm8Rmy9E0VhhyvNm+Zm5QtBdCbz3x67YIybJyBqnZypLLDNGIPiQCAJ7h1a17tItF7JD7Bya7BG0jvZIFlOS9Jo/w0KwHhr8SLrKWjhfCO6VOE6SKqvExG31ILgTIB4Se4dFkbMHPf3EH5q7Gc5KrN92+F6K0Xicz9QEFO1mRMNzpdhR1DjE/QyecNOilVIaSj06aZhTFY9Hzs8cOSQvxIBGve9ZzV8bm9Mr00/bDbqALw7a9ASQbQIEOPbprLC5jBkCFEkYpj6mftrNKJfSOQ0ocXbBEVAlFfCfT+/mzc8KYjQeujRPnsV/nCTdXz5Br8KYJvNCRfbZGv+yya47dSw6xSkx/+Y9WYLqFOUCSTmp4+Ur4Ptw8drpRCjuBlAomLktkb4lQzkVh9NCrGwzZDw==; 5:m/adKryTbJSSxa6a7knTZRmuQcRcAUt+LMEltIYYeGva2yEvyRWXQmuAJ7becnj78OL7vJZ7DT/PFqoA1xRN82r42hI46NrPVhxsf4xhtT+2JKYbid0H/HlIHmuJJNgoXhFRqSO+svV3a8Sq+lsGjrw9igs0KuUZqfuKcwuZvEU=; 7:LRtJ7q4H1zHDUUeC56sSBvUm/EDK6RZYohBMrwt76FtklaanEjyKAhJmYBp9jhAsZl/Fuy/IUmmlaUHSwWp9ycQ52MKEdAHVQ2yC3PVdVXujHmUYHI5PsLldUwR0f96l0C8sWWfXxh8Sy092gTXG8w== x-ms-office365-filtering-correlation-id: 574510df-458d-4349-b312-08d654ac9e0f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0639; x-ms-traffictypediagnostic: MWHPR04MB0639: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231443)(944501410)(52105112)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0639; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0639; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(136003)(376002)(346002)(396003)(366004)(199004)(189003)(86362001)(6436002)(53936002)(97736004)(6512007)(2906002)(66066001)(8676002)(8936002)(81166006)(81156014)(50226002)(54906003)(110136005)(5660300001)(316002)(575784001)(118296001)(7736002)(2501003)(6486002)(68736007)(305945005)(36756003)(478600001)(72206003)(71190400001)(71200400001)(52116002)(76176011)(6116002)(386003)(6506007)(102836004)(44832011)(2616005)(476003)(3846002)(26005)(186003)(486006)(14454004)(99286004)(446003)(25786009)(106356001)(39060400002)(105586002)(256004)(11346002)(4326008); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0639; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: L9hbSZs/rvocYueSCZwcyPmV7KDoqKz6jSxXeSSgUHe9ltEnO7S/zlnZpCkll74yYc5WNe4Zn5TmC7d4ZiI3T8e3A+s3NN4CpikctrNKBhyJu3hAqbzf5pd52B5oznC8CZwXZWH1gJH8GweHFVKdJEc8etqDtnolWiIHuLSGL68CzzSTyHswy+31xN2u1B5aY/d7bHSwrx2pNRL+aCl9jOWadirPZIOSj7yO663MHFWFvV0+IIqwy3KlmnfUtt9EN8sLbl4+ZZARkHQYaUoBAvxjtDtQNSFORU++4ynjNVxhEEP0y+EEQ310H2ONDHROtNlcCZ12UnsorWUe4PE/cgq/+CM3iUCDqwXi+7cWAew= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 574510df-458d-4349-b312-08d654ac9e0f X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:09:28.4784 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0639 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.141 Subject: [Qemu-devel] [RFC v2 19/24] 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 51961ade81..13756f6d0d 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -1683,6 +1683,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); +} + void tb_target_set_jmp_target(uintptr_t tc_ptr, uintptr_t jmp_addr, uintptr_t addr) { From patchwork Tue Nov 27 21:09:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10701459 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 62A7A13AD for ; Tue, 27 Nov 2018 21:23:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51E4328620 for ; Tue, 27 Nov 2018 21:23:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 463D52899E; Tue, 27 Nov 2018 21:23:42 +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 0603028620 for ; Tue, 27 Nov 2018 21:23:41 +0000 (UTC) Received: from localhost ([::1]:44565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkpY-0003Rl-87 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:23:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37118) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkc4-0006Cz-Ot for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:09:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkc1-0005ER-Jg for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:09:44 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:36239) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkc1-0005Dt-Ae; Tue, 27 Nov 2018 16:09:41 -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=1543352981; x=1574888981; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=d/vgDPhfzdcDSncbcj6SM70p3CgdU/kMp06loHl8EIc=; b=i7sA8uL6NMLzKNpdI7a17hvQefhkLyZOeY+qIk0HNIz1ABLwcqhl7SAg x5bZcy7CjAbTndfEFuuTQVIMNz/KlngXnVqjU92+vz/rS0DyB3YU7ZmIB plRbLEzsyCh+ZhxgLYPnegPE0TrI/oVXs/AWeyOLD0hS6E5v3zYfLZQPJ Rw2OI1gf/5Dr797J/M2S99IUTK5whwtnKm8H4fezb62unTZBaJvxlbrR3 gxNu2gSE9GIwB2csdhDHHl+gc3+avDU8M29qRuMSRukV9C//SffZc+bVB jrnK8MJjFIRdVuy9nbUAjMG0yqFWkauuf6f8fATe0itrOvoFIPrcOHi7i A==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="100064295" Received: from mail-cys01nam02lp0049.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([207.46.163.49]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:09:40 +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=MQOq+Pa+/vkRLMRAopVIeS0QFVaKTd42ScRtg/8FWjMsQDrrutTIjdt0it7AfiEHyEEk00Lt5ilMU9/Tccmo3YS5jiAcV5O9MkCCHv+y+YeYsQB0wqR7umtqkEuQ9ubdjMGhv4+3ngVC5s+p+rq27kK1o7OlleGogjerR8cth4U= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0639.namprd04.prod.outlook.com (10.172.166.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.15; Tue, 27 Nov 2018 21:09:37 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:09:37 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 20/24] tcg: Add RISC-V cpu signal handler Thread-Index: AQHUhpWBQP2olYvJR0ORlHHTlMtJsQ== Date: Tue, 27 Nov 2018 21:09:37 +0000 Message-ID: <22c9e4baa12177154ce8a357c40d2126b917478c.1543352682.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: BYAPR08CA0025.namprd08.prod.outlook.com (2603:10b6:a03:100::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; MWHPR04MB0639; 6:TBZlBVRxuQq05cFdwoHUtD0+Udsfc7ZXXR2bRPw04ZSbDMdTG84baQDnT0JHiYLCj5Zx/mJrkjqK1xas0co4uSK/A4HlxWou6VjoqcMuw/EBQYJUsLNpNo+ntW2As1JRBpy/NSeyKJoyn8PQ+u4SWbXrRLKBDxhoaZDUtZQU9jT1G6dIemZelucW+na4XoRz6LWaQUbltI8j22ag580PDyXckdX2D30eUAxiwUyzHHdlh0e+V243vwPZjtqspSpBI9WZMvNRSDUjyqkm3H0AA+xlURSaKMJvxkj5faHw07sH6Lx5PlRLfoGnt4ailAi4kvPsSlTXArBB0qIaAiNtAtaKIpCP84ZwQOh2lp3ZOsFxiSliJUpk92u5jbvidM/wkcHBPvS3vSGNiStHfc7PMLZOsFpE24E0aNJvTWd988tp7KZsOoG8KhMDx/12OJjmLDG/2oUrfviDvO1STmv34w==; 5:6VGCY8W4S4yf3jLqrHoEKhk4/mnregBasouBN4fJOetjVJS7abH7icSyWPmv2DdHJXArg9erHvpZ+0btsyfOYiE63lEy+xdRLMf2RvZutTchq4QFEggMR9N2HuarMS23XCyTW+aDztOMTy/PzQ4O7Cibieqt8CMzVEO9tAiCXyo=; 7:mEqTlgmYGz8mJa2bMaKB9eVgOTa2dG6zVufPWFEzHNczGNlck5M3iZK2HCGQsBmcbl/ZiNxsjI/R55quc1KNbfNMqXDzCM3ICtQ/ulCP7ugGU+pyOzTL1tY9CiabczAjLvRMYykZkBx9PZCJg0XliQ== x-ms-office365-filtering-correlation-id: 6dbce0c4-4b32-4290-8e67-08d654aca376 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0639; x-ms-traffictypediagnostic: MWHPR04MB0639: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231443)(944501410)(52105112)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0639; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0639; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(136003)(376002)(346002)(396003)(366004)(199004)(189003)(86362001)(6436002)(53936002)(97736004)(6512007)(2906002)(66066001)(8676002)(8936002)(81166006)(81156014)(50226002)(54906003)(110136005)(5660300001)(316002)(118296001)(7736002)(2501003)(6486002)(68736007)(305945005)(36756003)(478600001)(72206003)(71190400001)(71200400001)(52116002)(76176011)(6116002)(386003)(6506007)(102836004)(44832011)(2616005)(476003)(3846002)(26005)(186003)(486006)(14454004)(99286004)(446003)(25786009)(106356001)(14444005)(39060400002)(105586002)(256004)(11346002)(4326008); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0639; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: kVXx2ZWlZ7wiRnUFdw2BCgTCjoY0W9miTIcKpgebwr00DI8koIzJC6JGFdb7ELxZdsNG0P86rn/smdZuoz3o8VLF2u43PnFifltvLqoE9BqWhpXAlPxqEImFg0L65vVPoS7Br88mfvFSmcLQIrLBygZGRCONS/OLut+WkdTzq3X+fvq5czbcwHDm3k5+DbCLCteKSXBZUzntizZclCYVmzhh0nV13MLJa56ElDJtZaokugAcFu+TBr8CZXzqEsmFA1fPYBW2hDAv7A6lcFQ/pBJHCWrijo6vrxPUk7dpOTwLCRAt61OIfJ7O6sbB3uJM5UmwPlwDQFMk/wl1dmCXk2tLInbm9BinrKmLrrhA8c4= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6dbce0c4-4b32-4290-8e67-08d654aca376 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:09:37.5255 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0639 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.141 Subject: [Qemu-devel] [RFC v2 20/24] 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 Tue Nov 27 21:09:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10701457 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 84EF4109C for ; Tue, 27 Nov 2018 21:22:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7016C2C5B0 for ; Tue, 27 Nov 2018 21:22:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 644A62C6A2; Tue, 27 Nov 2018 21:22:08 +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 DBC282C5B0 for ; Tue, 27 Nov 2018 21:22:07 +0000 (UTC) Received: from localhost ([::1]:44556 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRko3-00016f-2h for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:22:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkcC-0006Jv-Vj for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:09:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkc9-0005I0-Qy for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:09:52 -0500 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:36247) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkc9-0005HY-Ie; Tue, 27 Nov 2018 16:09:49 -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=1543352989; x=1574888989; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=yrSrE4qAUim+nOJj4KJyO/SejAJJqLQ6qEkpXfylgC8=; b=qdESDO5uLeKFqlLI9iL0abwQXLxy9nY4WPPdliCu0jiyjcYQd7j/7i3p QdX5xRGuzpKTXuxnBjP1b2ziY3fgZltZoH5KaUSWMXD+mYCGk2VZLEh1O yMXVqwgqOknE/Gh3ZEkJfZeKb6C1gn0Fm4V2s9E+qd/AqSocVdBwETNL6 kwmtkQnjmBYdMIJIjma9TOHWtIJB6+XOuPt0kO705vQpjlTeYbi6n6S6Z 4kgx7sssrMK42EHLq9eR9l3lBIqlJ8euh5scl1vah48VSX73MBmCuBvN/ 2ScuMSCNpGRC5kKZcPyqNdmwc4VC4lLUOwpmA3EgZv2bDWvvdYL5KJjyp Q==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="100064303" Received: from mail-cys01nam02lp0055.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([207.46.163.55]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:09:48 +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=DAMb7CF6B0YzMBTKr1T44NtzDsWGjypJdpskH3i5Tpw=; b=Io5MSeRfNzUUNWh6zwC6g41sqnbYDn99AkR0WwMO2XaCkM9TWDXezDSvSBBFEjKZdDj/86bfZ2EescrhcGQcR1aj0FyyxNFEzFUps3Odx13AYkYcPxnC48QzMVK7debMb7LSdV+8IDqSg3qxBZ8x76PX83gPnrmw4yRrajmcd+s= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0639.namprd04.prod.outlook.com (10.172.166.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.15; Tue, 27 Nov 2018 21:09:47 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:09:47 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 21/24] dias: Add RISC-V support Thread-Index: AQHUhpWGDiLJClrwj0aAmV9FBKES8A== Date: Tue, 27 Nov 2018 21:09:47 +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: BYAPR08CA0033.namprd08.prod.outlook.com (2603:10b6:a03:100::46) 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; MWHPR04MB0639; 6:ylByPdxGNWvmF42nsHS6Ar1/voeVO4KbMLJc/iVYphGVa5v0Z/aVu6Ut10nGf2UGJHyOK2rEepdJT0r2LKe92hmlGQm8J7Yvla/vQgyKoHPYaydaLKilEQbSiMtdnCWZ8PlVtDDUDLIKYfoZL+5SxaF8MB8dWdTqsbfHUGKWNjwusqTM2qnf0CUfdOfowIMKDUIr/1DKtribm/nBWdFn7swHVsKfkts1DrlYQ/dGztGa0Io+NDAIMbU1aJGGZ1joYtIAM5tzoEBLXKgSQqs9cMMeMslaCO7qKZKnNO8NkwdRXSKt8FFY2PE+d5Ri1hgYhxUDxAedSzOEenOG1q8frkdM7NcbNl5k9WUS9X0rSD5GtSrrCMEG23O1I6tdVCbWNPKKRThNAwR8xfpw6Omt/T4Zk/glgW7ShcalrMOt4Olzh7WfJtPUlYj6zYDbajexUe8Hik6qtXn6DSI6hlB+7g==; 5:y0jFA7KGRuXUIz6LW2e54DtAYkWDu9mnY445UGzEu+IhPg2x3YqH78nLj8mRJuvxanDIRt0VWluV8KDN/gg2Rjd+8KgMX0I1cRJev2sXvRlOryvJZvQfqOsx7LUTu/Uj0mfAjZS7SxWWcsycDJd+ntDugurcrVfkGvPzyRr3XRc=; 7:MpeQhZuw5ekNwoM9dzSW9hQchoxDg/sdPgBdnEVSW3kgBoylQQ0n29p5GFaFDclhuP7xvW/7/zg5+c7UD7Rq10xGmqkPk0lzYGiJeDRBsB2K6KXjbIORZvsW8+2klDnJdu3jRwWgjPFFskIKG1GIgA== x-ms-office365-filtering-correlation-id: 2368c5f6-1ad9-44e4-4021-08d654aca914 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0639; x-ms-traffictypediagnostic: MWHPR04MB0639: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231443)(944501410)(52105112)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0639; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0639; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(136003)(376002)(346002)(396003)(366004)(199004)(189003)(86362001)(6436002)(53936002)(97736004)(6512007)(2906002)(66066001)(8676002)(8936002)(81166006)(81156014)(50226002)(54906003)(110136005)(5660300001)(316002)(118296001)(7736002)(2501003)(6486002)(68736007)(305945005)(36756003)(478600001)(72206003)(71190400001)(71200400001)(52116002)(76176011)(6116002)(386003)(6506007)(102836004)(44832011)(2616005)(476003)(3846002)(26005)(186003)(486006)(14454004)(99286004)(446003)(25786009)(106356001)(39060400002)(105586002)(256004)(11346002)(4326008); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0639; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: ibHNhEFtXnrK3mhepbwWfK4ACitnYhlcsuNJk8dVgcvBRjkEvQZ8QGG6OwehFQI6Kn2LRhHzSBkcBD9Uzqv3HjwnUjRnl4mhAH4mA7SEkNWELD6WUDnwaE6HoAdq+c8OGtxgK4UGBgCZVEXMH/f8BWtmcw0ftZoNgOvfiCQDfKKMmH2ji6oU90V75C19mWg126IrxOrVXtKjDYFgkGbKc84/Q5Wl8SSmG8KwppNTKmZRS9sfKlLkhiqIDkWa10AA7Y4pI45TRKW7CkCPHxxmFamHufelJ77k4w3aSIKr85k4E4PyYGs/ijh7QlB+l25iQsi6puFtzmKOsZXFtzHrf5OmmxFt0pGQcSYwKLedPjk= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2368c5f6-1ad9-44e4-4021-08d654aca914 X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:09:47.0101 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0639 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.141 Subject: [Qemu-devel] [RFC v2 21/24] 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 5325b7e6be..82a408f272 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) + 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 Tue Nov 27 21:09:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10701469 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 F125A109C for ; Tue, 27 Nov 2018 21:29:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E28ED2C257 for ; Tue, 27 Nov 2018 21:29:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D725D2C25A; Tue, 27 Nov 2018 21:29:10 +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 310712C257 for ; Tue, 27 Nov 2018 21:29:05 +0000 (UTC) Received: from localhost ([::1]:44605 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkum-000092-Ch for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:29:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkcN-0006SU-Qo for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:10:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkcK-0005ND-LT for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:10:03 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:54962) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkcK-0005Mm-DK; Tue, 27 Nov 2018 16:10:00 -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=1543353006; x=1574889006; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=SXEW3aOejaXUGG6wDVeW0kLHIEXsykZD8i0pCB2KA1M=; b=LGBdNusNDdhMETGft2PiDsUdjLfdY4GTtJ77fIjEopI+oG/YCXmR/zUa 5bmpYouJGMNXvBJFRe84Al3ET4UjUf7hh5VUftAvJ/i48MvlG0YzKT0aa 7N5rdW6R36AmwCWDXfAldxgrSnysyKMmn5znmwnwOZIFBndHuG/jGFMZe h5tntSzWWNDZZ0Dwu8pkt4xR38uCnczNHZXnY5BaJfVUF38d8h+RHU4Qv ysF/wpD94KHqOyP0Fm9jdtKKcDU5sA8e/XRKJDQoJ0DzKdf4+58+2P082 mGOVH2WDNAwUDrCwnGwrWM5DQuZzaSukYUpcqNIN+BxX56rowLCF7tURI w==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="193052895" Received: from mail-sn1nam02lp0018.outbound.protection.outlook.com (HELO NAM02-SN1-obe.outbound.protection.outlook.com) ([216.32.180.18]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:10:04 +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=v7qIDjAgAlaBEWjkL3cMYCuqfpkT5Kjm0BHkVpNKu6Q=; b=X2JZTL7CXNfJCfxj0PcYmkssHQX3tk1IApHTWMEVBQrqkjGyK+l/blbiFbPwxDbPi0SP2bxm79LzXJPAOUs1iM/w5gfHzC70cqnduQ7ksYcGPkcJk6MDE0AWpm1A88ZysMMqdcC7c30dgocd31gxZ0PwS2BBaakQrBlZPl8e5Tw= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB1121.namprd04.prod.outlook.com (10.173.51.23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.19; Tue, 27 Nov 2018 21:09:56 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:09:56 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 22/24] configure: Add support for building RISC-V host Thread-Index: AQHUhpWMWzNp2Vlrik2YQfI9WfxEsg== Date: Tue, 27 Nov 2018 21:09:56 +0000 Message-ID: <5382fea4f91a7b73adb2d4e5e7318c30bd7d83ce.1543352682.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: BYAPR08CA0004.namprd08.prod.outlook.com (2603:10b6:a03:100::17) 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; MWHPR04MB1121; 6:nUsIJgcobSMBdxKlYd2TO6h3ARLbf7ikha61iiBwrOMyugHfsdnWPqjEYcaaNpMcz2v3IClBpjCcgy1w2YURGVsBoCSTcUpspq3MNrk+hvttSZACp8ef3FOuA15ROYiZXyBPlCQ5FYKXb4ClbdAfWPU2w8U9s7OpjpsYQz4AZp/kZRZkrQwLjPw1eolptKtcB11Q5mY9KdcYq9AaxpJEmvPRpvlwSbqSJicGK8XDIqk/TVaGcSbRGr6fDxQMjKIFLcDiGgqPxo6FmLBVnH1FDYYCVYQZwjVmKA9w5yOf0Cg/09Z1cUJZBK47AAR/wOKfv6asvEjsS0P5hwALZc0HslqI2adR8zyG0ow2GF7QcFyIDboJWrjJ999aRsM0DrEZtrR69l8dRis6RPVj30zynDdiE3DYMDh6mmHGdj1aN7mccIMiLaqumI6E/SaYglXShu17ld5lL2r8o06CDlUWAg==; 5:R4l8DhLtj2Hgv0//EltsiSw4IF2Fy92SUsV35ovWfzr5YRkMbfNrEIexUzZM9o0SRCQgNWXeBy9C3P7HTvFxjNhBUUVXuHBHiTj01qlZYkOAob7ZpTAbjRbsL5/oBJxzkxG/A074DL9XlCr1yrlMzmuMShzryTTinw1p3aI9/OM=; 7:e7ARUOM9hmX07efzPtpQi337iWzT1f4INh9xg8Gawe14QKKsK7IcFaAZFeuMAh3IX5KI6s0ePSQloCdKIk6ug/1EBf9jnAPq5q/8YY1adLrFZ+qfZCzgPd5Bcq55b2VrbE121GQyZuoRjoLOmjMFdg== x-ms-office365-filtering-correlation-id: 16320a8d-71bd-4b66-1a2b-08d654acae9a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB1121; x-ms-traffictypediagnostic: MWHPR04MB1121: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231443)(944501410)(52105112)(93006095)(93001095)(10201501046)(3002001)(6055026)(148016)(149066)(150057)(6041310)(20161123560045)(20161123562045)(20161123558120)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB1121; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB1121; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(136003)(39860400002)(376002)(346002)(366004)(199004)(189003)(186003)(2501003)(26005)(256004)(25786009)(36756003)(86362001)(6506007)(102836004)(386003)(71190400001)(105586002)(71200400001)(97736004)(2906002)(76176011)(3846002)(6116002)(72206003)(52116002)(99286004)(106356001)(118296001)(8676002)(50226002)(39060400002)(4326008)(110136005)(316002)(6436002)(7736002)(53936002)(44832011)(6512007)(54906003)(476003)(478600001)(305945005)(66066001)(446003)(11346002)(6486002)(81166006)(5660300001)(81156014)(8936002)(14454004)(486006)(68736007)(2616005); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB1121; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: 4ZB5IGjJmIb31OhUcVEN7jrWEUKUXLcJbLYCbcN4LvyQ/p/fBvSSUP08IBbOpBFbpxm1RvD/WFajAtwf5uhfj6OLYe+Jc0dYxJJ6vxCBm8lQzIrOcVW3nYjQCfrX1QTzbtA1BULO3xaNAizyPmq1HK2te6RIoz33M45NpRXYh9Ee47/eNg2iy+CMhtVGQHq9bQJUxbKOV+/pzQtW0F/bKFmYfxH8QVxbDmA9rO/SY0HxxxQ3ukijELyWQkgP+b5VKpNsVRzkmsY6ku9wUYNSuc3qWlXq0HFr04fC3a55eQz2o5mq0o5Og48JVmoN6O1tuJRmbgrZaYgyU6D0N6dX5827nH0tur2iPHnzX1D+hbg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 16320a8d-71bd-4b66-1a2b-08d654acae9a X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:09:56.2446 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1121 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 68.232.143.124 Subject: [Qemu-devel] [RFC v2 22/24] 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 0a3c6a72c3..fb52954368 100755 --- a/configure +++ b/configure @@ -709,6 +709,12 @@ elif check_define __s390__ ; then else cpu="s390" fi +elif check_define __riscv ; then + if check_define _LP64 ; then + cpu="riscv64" + elif check_define _ILP32 ; then + cpu="riscv32" + fi elif check_define __arm__ ; then cpu="arm" elif check_define __aarch64__ ; then @@ -721,7 +727,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" @@ -6900,6 +6906,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 @@ -7397,7 +7405,7 @@ for i in $ARCH $TARGET_BASE_ARCH ; do ppc*) disas_config "PPC" ;; - riscv) + riscv*) disas_config "RISCV" ;; s390*) From patchwork Tue Nov 27 21:10:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10701463 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 8AA93109C for ; Tue, 27 Nov 2018 21:25:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7BCAD2C2B7 for ; Tue, 27 Nov 2018 21:25:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6EE862C42C; Tue, 27 Nov 2018 21:25:51 +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 BF89D2C2B7 for ; Tue, 27 Nov 2018 21:25:50 +0000 (UTC) Received: from localhost ([::1]:44586 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkrd-00057m-Ij for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:25:49 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37288) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkcV-0006dT-FH for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:10:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkcS-0005T8-8z for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:10:11 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:12810) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkcR-0005RC-Vs; Tue, 27 Nov 2018 16:10:08 -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=1543353009; x=1574889009; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=IsndXcf98N9AecauFztAnNmKZpPG0GGaJWujY/ofxGU=; b=LLlN+HkUmYsCrxfIxRYX5ASGAkEFji3cxaHEE4uCDloNDHhGDTIvNz9q uGcNXhCUe+8i2o5RCwVEhszG74lIJ/mA1mE4nKGLmSUvLiagNA7PizqNx dT+Woj4VHRzsldfHZbka5rWBb1PPZoDA/ntbw434A/Gw5O2g3sPmeNA22 qhOgdZN5HYfLSQheVVRLaXKsgnx35Gh7oK+i5BZiBebkPEfXQ3ZuLamlz BAAN666x+TIFw/tNB16rvmlP8zYNcKQEDIQ/ZnZQWN5RoggU4f6TzDgh5 dHEpgp6UIVW7ZQJBwYQjOWEdFrgE+IJ4zJV1XYTCWFccOnIkoAJuSlp3G Q==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="95245114" Received: from mail-cys01nam02lp0047.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([207.46.163.47]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:10: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=EpbkAQIFjMBaniYPvk9XCab82If7MVn9Kqxs2xSgllQ=; b=gKdDR45gDLD8bGgyeaGoeiMG92fLIPPvDYwnZjXc0VcWIxLTyR2Xe1vncQJOmheVSqcR2ZG5aqNG/drGkPB/z62a0shTX43g0Qrjdg7PdH+G5EEHooan14vX3SAaVqNawa9w0BU4IZLbG1EJgoLkzmWWCLTG3kwXZoM1GLAE0fA= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0639.namprd04.prod.outlook.com (10.172.166.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.15; Tue, 27 Nov 2018 21:10:05 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:10:05 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 23/24] WIP: Add missing instructions Thread-Index: AQHUhpWRsL6s+JdvB0eLwjeD9gbEcg== Date: Tue, 27 Nov 2018 21:10:05 +0000 Message-ID: <46fe7e6cef5c03c2165feaf400cca797ee1b10f9.1543352682.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: BYAPR11CA0097.namprd11.prod.outlook.com (2603:10b6:a03:f4::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; MWHPR04MB0639; 6:+c5o1zJK1Lq1AKD4G1FCZrEjjh5kQg4rX4MPGYnJhZ1MV9PoAYtIA2yBdJbb166JFkc6YyEP1Yj6UCFNNzQLYZ54sVkElI5gfjbE4jNpPah9YREKkK9qbAUWe+mLzJs18XUlxyPC/SaB5ofiJr62HCTPEmze0b9xgwpO0MH6oRlzUGtVdaSu9FFbgOqz3B9INDYQSzcdVWosogPRxTImNRg60oZM44fIvY18M4Ce3kmTVtsEI76pd7YCB6TwOn7xb6fg/oTqsQPnnapKlePVqGh9D2xH+5Pk92YzN02Jeu5lOTauliW5rIHEi7V+J5mbmQGhip7sViaSrQ1vEG5x+q4xcM4PVK8Pv7tWANKO+o/pemykT458H2MH6Exe5Xrrq9QLfXuA86lTlaHk5PUbXQ0q8D9qBhRq/8p3lxSg9J1Tj5AuVDGuWxLEhthwFl8hOrWbjYh9cGrYORTJCScqkA==; 5:rZPD87WQcL1+j2QlPljHMpfrBS6RPIKY1Yf2idq9wgZvK4TfZFz9151oyTYG+NIbWzN+/Sk/stzApFfn5GPpz9HurznUfkZKZ3IeJmfeUq37rwFnRdr8paAmn6fKesYofnk6gBFQpzSEmH4xoOMW2j8Q6jafLUrFF51IVBaO2TQ=; 7:CQlVCaPX949cKk3CobchMVQrEokq0x3pOJp3Z6e0KZOABEEQnq3s87nUflMcuWqbg33S2KFpUzHSNJJDPlRxobMF01eoVfo5Fjy5QodaTSh9rbYa2dQVlV1RTWuurBT4/fZIx+vE5PcG88yNQ/Z6kA== x-ms-office365-filtering-correlation-id: b6fcbc7d-f347-4e01-e28d-08d654acb3ed x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0639; x-ms-traffictypediagnostic: MWHPR04MB0639: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231443)(944501410)(52105112)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0639; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0639; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(136003)(376002)(346002)(396003)(366004)(199004)(189003)(86362001)(6436002)(53936002)(97736004)(6512007)(2906002)(66066001)(8676002)(8936002)(81166006)(81156014)(50226002)(54906003)(110136005)(5660300001)(316002)(575784001)(118296001)(7736002)(2501003)(6486002)(68736007)(305945005)(36756003)(478600001)(72206003)(71190400001)(71200400001)(52116002)(76176011)(6116002)(386003)(6506007)(102836004)(44832011)(2616005)(476003)(3846002)(26005)(186003)(486006)(14454004)(99286004)(446003)(25786009)(106356001)(14444005)(39060400002)(105586002)(256004)(11346002)(4326008); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0639; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: OToH6bX6xgpmY3jtGA0wKiGPkGfkbQ5nALaVOYwkpaUlRcs40N/7GZvAkVb3s0zBhmChAPi6PGhtmJnDHJtrx79tmJ+Hh0P6XfDOGjahp5V80+SV/391FCYb2fOjAI6qEmaTTxfk1fFLLKujNrZmOg+256M06XZyAAdA6HlXVGgys9VlAzOnmuGgsniFO0X4do6Jk5dEj4TL076N7x4TwSfrcKkPvIFlFPuFD+7HEfVWj7M0Z+mXJyr1sx7V2WIg4nGocBs32wjowIaKLM69DvwcV6uYyzJKg+io1KsC+Kapw52CQMErdqmRAlavSNBMtgOFlGnTWnlGA3oWKMGHj03Or/C8e+tjdlBeeM2qQII= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: b6fcbc7d-f347-4e01-e28d-08d654acb3ed X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:10:05.2604 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0639 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.154.42 Subject: [Qemu-devel] [RFC v2 23/24] WIP: Add missing 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 --- tcg/riscv/tcg-target.inc.c | 77 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index 13756f6d0d..b8e9c0e126 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -606,6 +606,57 @@ 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, + TCGReg bl, TCGReg bh, + bool cbl, bool cbh, bool is_sub) +{ + /* FIXME: This is just copied from MIPS */ + 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_ADDI), 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; + } + + if (is_sub) { + if (cbl) { + tcg_out_opc_imm(s, OPC_SLLI, TCG_REG_TMP0, al, bl); + tcg_out_opc_imm(s, OPC_ADDI, rl, al, -bl); + } else { + tcg_out_opc_reg(s, OPC_SLLI, 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_SLLI, TCG_REG_TMP0, rl, bl); + } else if (rl == al && rl == bl) { + tcg_out_opc_imm(s, OPC_SRLI, TCG_REG_TMP0, al, 31); + tcg_out_opc_reg(s, OPC_ADDI, rl, al, bl); + } else { + tcg_out_opc_reg(s, OPC_ADDI, rl, al, bl); + tcg_out_opc_reg(s, OPC_SLLI, TCG_REG_TMP0, rl, (rl == bl ? al : bl)); + } + tcg_out_opc_reg(s, OPC_ADDI, rh, th, TCG_REG_TMP0); + } +} + static const struct { RISCVInsn op; bool swap; @@ -1384,6 +1435,18 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, } break; + case INDEX_op_add2_i32: + 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); + break; + + case INDEX_op_sub2_i32: + 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); + break; + case INDEX_op_brcond_i32: case INDEX_op_brcond_i64: tcg_out_brcond(s, a2, a0, a1, arg_label(args[3])); @@ -1439,6 +1502,8 @@ static void tcg_out_op(TCGContext *s, TCGOpcode opc, 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; @@ -1505,6 +1570,8 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) = { .args_ct_str = { "LZ", "LZ", "L" } }; static const TCGTargetOpDef LZ_LZ_L_L = { .args_ct_str = { "LZ", "LZ", "L", "L" } }; + static const TCGTargetOpDef rZ_rZ_rZ_rZ_rZ_rZ + = { .args_ct_str = { "rZ", "rZ", "rZ", "rZ", "rZ", "rZ" } }; switch (op) { case INDEX_op_goto_ptr: @@ -1537,6 +1604,8 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) 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; @@ -1593,6 +1662,14 @@ static const TCGTargetOpDef *tcg_target_op_def(TCGOpcode op) case INDEX_op_brcond_i64: return &rZ_rZ; + case INDEX_op_add2_i32: + case INDEX_op_add2_i64: + return &rZ_rZ_rZ_rZ_rZ_rZ; + + case INDEX_op_sub2_i32: + case INDEX_op_sub2_i64: + return &rZ_rZ_rZ_rZ_rZ_rZ; + case INDEX_op_brcond2_i32: return &rZ_rZ_rZ_rZ; From patchwork Tue Nov 27 21:10:14 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10701473 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 D302C109C for ; Tue, 27 Nov 2018 21:31:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3CDA2C350 for ; Tue, 27 Nov 2018 21:31:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B83682C6E0; Tue, 27 Nov 2018 21:31:16 +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 18D2A2C3B0 for ; Tue, 27 Nov 2018 21:31:15 +0000 (UTC) Received: from localhost ([::1]:44625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkws-0001kd-O8 for patchwork-qemu-devel@patchwork.kernel.org; Tue, 27 Nov 2018 16:31:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37340) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRkcd-0006kK-QH for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:10:23 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRkca-0005cb-LA for qemu-devel@nongnu.org; Tue, 27 Nov 2018 16:10:19 -0500 Received: from esa4.hgst.iphmx.com ([216.71.154.42]:12818) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRkca-0005c5-DG; Tue, 27 Nov 2018 16:10: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=1543353017; x=1574889017; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=tM9S6FFamfvguqaAqsSCQlJpZ7RJ5gKQRVMGDPvJ4dc=; b=qVrgG1o95afM7+hkREoaA7EpxQu0J+Bzldn9GfHdcXx2+dNAGtkXOBwz JXT1kzzNAqbYrpHzB+bSrpqQKobh8445haiLT4uxrCl1SKU1/xllwYOyQ oqdGDkjBjJc84t9+kaDwf+eGuKbx+wIzhoJBu3CXCMajII0Ve0gKBTZUz XmKFYnscftvEOb9XezfYzs4nIKjjora4sN7V3vH3oihi498UrJPuh8uDu mbBK4tBnJNHJXnlkMmxR3ZH/pFD2OF+SBZVv0G5V6DLgBysk/LW0KN0RL xV+uxLfyzMrCASY+Vuds20SqLAYDm9WTFCODlDvfIaJ2KjivHC1XIgz1S g==; X-IronPort-AV: E=Sophos;i="5.56,287,1539619200"; d="scan'208";a="95245123" Received: from mail-cys01nam02lp0056.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([207.46.163.56]) by ob1.hgst.iphmx.com with ESMTP; 28 Nov 2018 05:10:16 +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=JnH/rIm/y+JPKn0AaeUFk3MlciNvUPdvDG9Sl/8lHjw=; b=KsHeHm/lR+geU3ga0XRjEahiC+NeUyzDE2WY2X07iA+GzH1GKeUoon+nla9/KvDVSTd1THd53UNNxOi1ptEShweUWrcXCRwhUxBsFBqk8KqxfXGnharrgkJ6r7lvS9eIMwp6TQbdbWPZXe8aa8JOdLcwRdLJ90mG5SjMAobEUng= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0639.namprd04.prod.outlook.com (10.172.166.140) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.15; Tue, 27 Nov 2018 21:10:14 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::d13d:19d3:fc93:2ec5%9]) with mapi id 15.20.1361.019; Tue, 27 Nov 2018 21:10:14 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [RFC v2 24/24] WIP: Try to patch longer branches Thread-Index: AQHUhpWWy3SawqbdpkanLuroTrMpKg== Date: Tue, 27 Nov 2018 21:10:14 +0000 Message-ID: <287a8dbdfa046fc269b0f238076f25157733c66a.1543352682.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: BYAPR11CA0083.namprd11.prod.outlook.com (2603:10b6:a03:f4::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.250] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0639; 6:s+b1uNm6qHumWHJG8sJgZzsKI1HEZRiWyIFipXIak4/K4B3cl12DeMLyglXhRlwRqHv1IP0a8YTXK0gqcGMq5uso+TpULMG/DwgGflNmgWgMUZtfymt7SdfZIw0jga8Y7D+AolHhwT8QmuzeuqF9SnU9gP7NavJjWkKgmZD5Y0g0yLcGlN12I7EASVnDZkcED3g8rPkIuZEQJFJyMMjLDXbfhEX8EsUUTfHGb/kF2s1MFR8mGuunLp5BrNjb57sVPOr9Rlv/IFslhFtIblxvHd2JW9NYmvYfJCCV5b+m9ZVq9AvM2o0zn/DMkXUCTTEomvol2meCgDECpGoziIKMrIYxgy8fFZzPqtJOd1av5lxHq4ikTAxxUQFu+OUetScQjUni8P1ALk8xIzvSyxqwqVXjeRtVp9AA8BmsK7ObHRuSN+egFkBcCV33fIdM3qopLoq50VdOYqEzzPlTUSZjkA==; 5:prYTplPMNFQ6lsacTvZ8wxrh21kVUIQlbaxO0fsLK7a0JVpc9vTTDm4lcoqoyD5+cYrr5jnBbvASDNHgyYuC/7zE14jBLlrkZHDNw79rQPva3/V7LybyKD4M6yIt62Rbt0JpDhT6UcyYTtmodJ8jqR64JTaiol6cbAFCfYFL+0M=; 7:Ui5P+XqSfK1a3CKE6HNjfjkRd5jZf3Q2AGpBla1Ung1QJeU17Yvo+z0yUI5a4u89xNJISsAVoJpwDR18fGXyW2/tIiPSsjbFf6FkNZXOez2SJiZ5aXMi4pQv+BdQKJPe0yRKodVnq7wm4L3sK7/biA== x-ms-office365-filtering-correlation-id: a6d32fb0-ea16-4a8f-980a-08d654acb92e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(5600074)(711020)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0639; x-ms-traffictypediagnostic: MWHPR04MB0639: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(10201501046)(93006095)(93001095)(3231443)(944501410)(52105112)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0639; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0639; x-forefront-prvs: 086943A159 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(39860400002)(136003)(376002)(346002)(396003)(366004)(199004)(189003)(86362001)(6436002)(53936002)(97736004)(6512007)(2906002)(66066001)(8676002)(8936002)(81166006)(81156014)(50226002)(54906003)(110136005)(5660300001)(316002)(575784001)(118296001)(7736002)(2501003)(6486002)(68736007)(305945005)(36756003)(478600001)(72206003)(71190400001)(71200400001)(52116002)(76176011)(6116002)(386003)(6506007)(102836004)(44832011)(2616005)(476003)(3846002)(26005)(186003)(486006)(14454004)(99286004)(446003)(25786009)(106356001)(39060400002)(105586002)(256004)(11346002)(4326008)(148743002); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0639; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-microsoft-antispam-message-info: 784eICLysSv4z5tFQXSwePq2POgu8CmP3iAaM8ZCnXcHmE23G2ZmrS4aIwRmV41GyJkPbp7lfgyjK8tkPpgOVgHPvpjk8F4ATiSocaPqXKzqEZjnHonmePa2v02BHPD0qM674bPsfqxSseW10EH6ZrMg/Vyo04rMapl/Ve9GSJVMqp7cUVvhYgKI0xJWZKSK/tQ+hkpmHwyjjbjsioN38nmc806K8DbiGI4RB3IrQjDvrrwcWz5zwsrzenwocm0K+RS0MGjoiun49ZTWPsavDkRD/T/4CEB7YT5rqYRKGL8e+R4RV87FGBereeSkJwaRc4hilUMw6fGymifrMjDor5eJmCyPwFc2zynUyKNF830= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6d32fb0-ea16-4a8f-980a-08d654acb92e X-MS-Exchange-CrossTenant-originalarrivaltime: 27 Nov 2018 21:10:14.0106 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0639 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.154.42 Subject: [Qemu-devel] [RFC v2 24/24] WIP: Try to patch longer branches 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 --- tcg/riscv/tcg-target.inc.c | 44 +++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index b8e9c0e126..cf1680935a 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -418,10 +418,37 @@ static void reloc_call(tcg_insn_unit *code_ptr, tcg_insn_unit *target) static void 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: - reloc_sbimm12(code_ptr, (tcg_insn_unit *)value); + diff = value - (uintptr_t)code_ptr; +#if TCG_TARGET_REG_BITS == 64 + short_jmp = diff == sextract64(diff, 0, 12); +#else + short_jmp = diff == sextract32(diff, 0, 12); +#endif + if (short_jmp) { + reloc_sbimm12(code_ptr, (tcg_insn_unit *)value); + } else { + /* Invert the condition */ + insn = insn ^ (1 << 12); + /* Clear the offset */ + insn &= 0xFFF; + /* Set the offset to the PC + 8 */ + insn |= ((unsigned int)(code_ptr + 8)) << 12; + + /* Move forward */ + code_ptr++; + insn = *code_ptr; + + /* Overwrite the NOP with jal x0,value */ + insn = encode_uj(OPC_JAL, TCG_REG_ZERO, value); + } break; case R_RISCV_JAL: reloc_jimm20(code_ptr, (tcg_insn_unit *)value); @@ -677,16 +704,27 @@ static void tcg_out_brcond(TCGContext *s, TCGCond cond, TCGReg arg1, TCGReg arg2, TCGLabel *l) { RISCVInsn op = tcg_brcond_to_riscv[cond].op; + intptr_t diff; bool swap = tcg_brcond_to_riscv[cond].swap; + bool short_jmp; + + tcg_debug_assert(op != 0); tcg_out_opc_branch(s, op, swap ? arg2 : arg1, swap ? arg1 : arg2, 0); - tcg_debug_assert(op != 0); + diff = l->u.value_ptr - (uintptr_t)s->code_gen_ptr; +#if TCG_TARGET_REG_BITS == 64 + short_jmp = diff == sextract64(diff, 0, 12); +#else + short_jmp = diff == sextract32(diff, 0, 12); +#endif - if (l->has_value) { + if (l->has_value && short_jmp) { reloc_sbimm12(s->code_ptr - 1, l->u.value_ptr); } else { tcg_out_reloc(s, s->code_ptr - 1, R_RISCV_BRANCH, l, 0); + /* NOP to allow patching later */ + tcg_out_opc_imm(s, OPC_ADDI, TCG_REG_ZERO, TCG_REG_ZERO, 0); } }