From patchwork Wed Dec 19 19:17:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 10738043 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E9E5B14DE for ; Wed, 19 Dec 2018 19:28:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF8B61FFBD for ; Wed, 19 Dec 2018 19:28:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C155127D0C; Wed, 19 Dec 2018 19:28:38 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 66F9C1FFBD for ; Wed, 19 Dec 2018 19:28:37 +0000 (UTC) Received: from localhost ([::1]:33786 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhWG-00020F-7L for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Dec 2018 14:28:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45594) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gZhM2-0001XD-PU for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:18:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gZhLy-0000Ux-NO for qemu-devel@nongnu.org; Wed, 19 Dec 2018 14:18:02 -0500 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:43419) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gZhLy-0000Tn-D3; Wed, 19 Dec 2018 14:17:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1545247078; x=1576783078; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=ZOKOtV8+IzFZSdFtM8kg49hAziLkFSBQIROEtvwFlcM=; b=oT9lPGgyhxhOc4rc26s9Vcmc4HWQ+dSpVfNEW6zM0+HIQzB9wk2gcpoK 5EEqfTYb4ZL8LWUDp7UaZct6mhX2bjWw1xzSvizpuv82QffmPbReaW7lo XFoHKjIzWVOYJMcisXFfGdwS5IgGiYYAe0QlBkrVazwoM7zLR0MNueRdN cTBRztBUJBaCINoUZ0vesxBQY15WHfPAWl0AsvoQ1djkcL694eZigWPEh sYlw8g/EerwXBpiF248HCodR/q7Q5iEUlz586AOtzqd2vXRufqPE7Zr7y eCY0MasPqF/1aoiNsg+/EbwPpjtTzwX5tW1UxcN8XehGfVObcU8V93brt g==; X-IronPort-AV: E=Sophos;i="5.56,373,1539619200"; d="scan'208";a="98234213" Received: from mail-sn1nam04lp2054.outbound.protection.outlook.com (HELO NAM04-SN1-obe.outbound.protection.outlook.com) ([104.47.44.54]) by ob1.hgst.iphmx.com with ESMTP; 20 Dec 2018 03:17:57 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=1YCpEkH3DVOoDa4Jvxqsa1PHfQ48fTq9DBKoU8N6nTQ=; b=iLeLtgd31WE8gG3z0VR7emObHOM5xeMuGlowdWX8ansCw80LCb7bFn9aBKkk1Hg82TTuxZYpJQ5l5hjXyy1LWiU4dgQ1bOg3Nfyks82RhK48Gu6DBCRT2dYQMhcTrfCwHpuhfPL8Bw85RmcAVqgrFcpFcOVWKoNx8HBNpQDqz+A= Received: from MWHPR04MB0401.namprd04.prod.outlook.com (10.173.48.18) by MWHPR04MB0718.namprd04.prod.outlook.com (10.172.167.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1425.22; Wed, 19 Dec 2018 19:17:55 +0000 Received: from MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604]) by MWHPR04MB0401.namprd04.prod.outlook.com ([fe80::9067:fb44:66b2:7604%4]) with mapi id 15.20.1446.018; Wed, 19 Dec 2018 19:17:55 +0000 From: Alistair Francis To: "qemu-devel@nongnu.org" , "qemu-riscv@nongnu.org" Thread-Topic: [PATCH v2 09/23] riscv: tcg-target: Add the instruction emitters Thread-Index: AQHUl8+LugcXJHZsUUiqZk02Bc02Cg== Date: Wed, 19 Dec 2018 19:17:55 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-mailer: git-send-email 2.19.1 x-clientproxiedby: BYAPR05CA0045.namprd05.prod.outlook.com (2603:10b6:a03:74::22) To MWHPR04MB0401.namprd04.prod.outlook.com (2603:10b6:300:70::18) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alistair.Francis@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [199.255.44.250] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; MWHPR04MB0718; 6:aZ8wKQHm7QU2WdlBM3UL50wV1CyiY3K24297CgJQf2abSRRZzQRXV36ccHusXBuVeDeyFH/EJXQTCOWIHxTq2kMf8lvJJZ/vRai4iw++nMtpvnthWW1a+LPA/IrttrBRwhZZl6lslvGl7KeVZbM+6MdybdGmY+FGAv2q2UxBvT7OO2RmVJaBp0XB8y3XCArHLCW5J53Fb6AtA4D4YVHCqBMC/HvBJF/jMDgQUlEHO3Ub58bwUrdFCI15O7r825GBNJEZXdt/8tQvnHRYanHGkSwBum+ipU24SSyjmTXz+9zdr1rjKB+VuZAh42RG3s4tRmUBWl59Erp19lZamS7d1aAeAB5uJMpNVtNkQu39qvUiXyLrgRQRd2pqoR6UuJpKWOGmO+lAWzBDqcGxtY2Kih5clh3DbBCpxAWRSQZlqoua+sfphUd8+3wLCQzwFaU/T5Mf7aD8CvEUOoWS+wkEdw==; 5:D7Iq87mdkjbv7vFIttDUPZsnjDkdIOxm81cXsUIJSj6Q5lHpg5fwFS1OzDIDcLP4/qVMF7hs0sIEqZD5QM8q2YqeYTpOaZdWJsdPdtTE8PKYzjBqoEqweaypEldsTPPYRFPzmIBGN1srdoGBeME4sBybP/XAhBUjPQDeBDk7NjU=; 7:w1IJBse7ArNVotZJLm7hhPYEARsEr+RGxxPHOkCGXHPFLY4iPDCD7QnDTsde22PjN86bx1YbYzTKhMmTTCQ9kH+cX4nwU8pNJgnVbFkfHyBp89kxsRJHz+RgvXeDyCuQtxhMvpLJpV+wXtcSdd2RSg== x-ms-office365-filtering-correlation-id: 214eaf44-0ffc-4a72-692d-08d665e6ada3 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:MWHPR04MB0718; x-ms-traffictypediagnostic: MWHPR04MB0718: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(3230021)(999002)(6040522)(2401047)(8121501046)(5005006)(3231475)(944501520)(52105112)(93006095)(93001095)(10201501046)(3002001)(6055026)(149066)(150057)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(20161123560045)(20161123564045)(201708071742011)(7699051)(76991095); SRVR:MWHPR04MB0718; BCL:0; PCL:0; RULEID:; SRVR:MWHPR04MB0718; x-forefront-prvs: 0891BC3F3D x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(346002)(366004)(39860400002)(396003)(136003)(189003)(199004)(256004)(2906002)(11346002)(7736002)(105586002)(106356001)(478600001)(26005)(39060400002)(305945005)(446003)(99286004)(2616005)(316002)(110136005)(81166006)(8936002)(486006)(3846002)(6116002)(5660300001)(4326008)(81156014)(97736004)(186003)(54906003)(14454004)(476003)(25786009)(44832011)(50226002)(52116002)(8676002)(66066001)(6512007)(386003)(76176011)(6506007)(6486002)(53936002)(68736007)(118296001)(2501003)(86362001)(72206003)(102836004)(36756003)(6436002)(71190400001)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:MWHPR04MB0718; H:MWHPR04MB0401.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-microsoft-antispam-message-info: bfWOdBQhEJtLhyCgDEikiTfWJ8NQooyXBHdvOnMxQ8DQ3Rmz9t9/4nBj8L3QBMKWcBujyPCwANM7pTHhmTuFqf9tY0NJTdNxp9fQh6MBCK7vSrMVLs1KQn/vPnhn7eyxnkO+crm7lKU3/Gh0bpEKuh4i9oe8PwgsQf49zi09idQnZttx/LT0Ub6HDmZvKFdbQA+oeN8hyxeVGQ5cBofub9tvrB1gp2C5prj+fnAXYXU7X6E43e+ghg5nFwhSxBHuwKO0lOL9snD2Xq3hCr5O0AUSCETsZGfHq8SYQGNqigXjYM50ZQUPvFqrtpkWsSqu spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 214eaf44-0ffc-4a72-692d-08d665e6ada3 X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Dec 2018 19:17:55.1536 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB0718 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 216.71.153.144 Subject: [Qemu-devel] [PATCH v2 09/23] riscv: tcg-target: Add the instruction emitters X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "alistair23@gmail.com" , "richard.henderson@linaro.org" , Alistair Francis Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Reviewed-by: Richard Henderson --- tcg/riscv/tcg-target.inc.c | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tcg/riscv/tcg-target.inc.c b/tcg/riscv/tcg-target.inc.c index 08838027cd..d198cfd5f7 100644 --- a/tcg/riscv/tcg-target.inc.c +++ b/tcg/riscv/tcg-target.inc.c @@ -374,3 +374,51 @@ static int32_t encode_uj(RISCVInsn opc, TCGReg rd, uint32_t imm) { return opc | (rd & 0x1f) << 7 | encode_ujimm20(imm); } + +/* + * RISC-V instruction emitters + */ + +static void tcg_out_opc_reg(TCGContext *s, RISCVInsn opc, + TCGReg rd, TCGReg rs1, TCGReg rs2) +{ + tcg_out32(s, encode_r(opc, rd, rs1, rs2)); +} + +static void tcg_out_opc_imm(TCGContext *s, RISCVInsn opc, + TCGReg rd, TCGReg rs1, TCGArg imm) +{ + tcg_out32(s, encode_i(opc, rd, rs1, imm)); +} + +static void tcg_out_opc_store(TCGContext *s, RISCVInsn opc, + TCGReg rs1, TCGReg rs2, uint32_t imm) +{ + tcg_out32(s, encode_s(opc, rs1, rs2, imm)); +} + +static void tcg_out_opc_branch(TCGContext *s, RISCVInsn opc, + TCGReg rs1, TCGReg rs2, uint32_t imm) +{ + tcg_out32(s, encode_sb(opc, rs1, rs2, imm)); +} + +static void tcg_out_opc_upper(TCGContext *s, RISCVInsn opc, + TCGReg rd, uint32_t imm) +{ + tcg_out32(s, encode_u(opc, rd, imm)); +} + +static void tcg_out_opc_jump(TCGContext *s, RISCVInsn opc, + TCGReg rd, uint32_t imm) +{ + tcg_out32(s, encode_uj(opc, rd, imm)); +} + +static void tcg_out_nop_fill(tcg_insn_unit *p, int count) +{ + int i; + for (i = 0; i < count; ++i) { + p[i] = encode_i(OPC_ADDI, TCG_REG_ZERO, TCG_REG_ZERO, 0); + } +}