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) {