From nobody Thu Oct 2 10:13:45 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1545772211322816.9521248848507; Tue, 25 Dec 2018 13:10:11 -0800 (PST) Received: from localhost ([127.0.0.1]:43129 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbtxl-0003gA-J3 for importer@patchew.org; Tue, 25 Dec 2018 16:10:05 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49773) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gbtky-0004dX-UY for qemu-devel@nongnu.org; Tue, 25 Dec 2018 15:56:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gbtkv-0007JG-Q7 for qemu-devel@nongnu.org; Tue, 25 Dec 2018 15:56:52 -0500 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]:34964) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gbtkv-0007I4-K7 for qemu-devel@nongnu.org; Tue, 25 Dec 2018 15:56:49 -0500 Received: by mail-pf1-x434.google.com with SMTP id z9so7082249pfi.2 for ; Tue, 25 Dec 2018 12:56:49 -0800 (PST) Received: from cloudburst.home (c211-28-135-144.sunsh3.vic.optusnet.com.au. [211.28.135.144]) by smtp.gmail.com with ESMTPSA id t21sm48501628pgg.24.2018.12.25.12.56.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 25 Dec 2018 12:56:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=2kk2RtqH5Y2OH8LK3MZLJEzAO8vv0yWS95UQWvhwMlg=; b=A6OTVBx7oHWPdUhrNnzF1SHKyAEIlXGVTfHkZXYQ9nbyzQAjZWuIdxNmLdUK+GYbJT PHEinlGaRGP0DTJu9AXUiFWN2I/I9okHJhJu7DYA1LYnA3uu38u7ShPO0hdei7+aUGe2 1+Zx/PWqgct6f6tJyQ98d1C036JmoIl5ZiKi4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2kk2RtqH5Y2OH8LK3MZLJEzAO8vv0yWS95UQWvhwMlg=; b=A4il38MSgNldPcPAitkYyP4LE1TmFnsMllIP4Torf+UY4xlqJc2zyicNab6K1ezF+m vSy11/y6gbtQSBptqc0N0LweX7YCP4TZzZXrgyDliVuCkSPnwdlzoaVC8Wx88piEZCtJ hOEJqdCrDo28/CcmTXol+Ng821HQ6D16aAQJuBm72LkqOe2FyqEPQ4dVuPkQmES78pTy L64Z7CY/FMmYO854W24V2L3l1jOXnmooaUSeWx/iQJBab8mWk2Xx2bjCagoxCZyHfaPd L5lf6K8qJpJRdxG/pftEkjtFDz8K7R/Cshu4iFne3Cr+a8+FKKD5+AuIptj6DYwbTn8j TvHg== X-Gm-Message-State: AA+aEWaoc4nXMioHMJZi5CycSjTQ5zKYBXtuisVb48xN5w8IcCkkeL5z 5us+u8LKiwTbvXRPlqMEoO41/GgCPvM= X-Google-Smtp-Source: ALg8bN7SWr7efJOQw3EyAnJ2ArMSz8PInr4VwrPhX5YIodsPXx4Rm11RcTTKiYScvTFb26EWLxxVcA== X-Received: by 2002:a62:7a8b:: with SMTP id v133mr18135581pfc.159.1545771408294; Tue, 25 Dec 2018 12:56:48 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 26 Dec 2018 07:54:56 +1100 Message-Id: <20181225205529.10874-10-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181225205529.10874-1-richard.henderson@linaro.org> References: <20181225205529.10874-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::434 Subject: [Qemu-devel] [PULL 09/42] tcg/riscv: 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: peter.maydell@linaro.org, Michael Clark , Alistair Francis Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Alistair Francis Signed-off-by: Alistair Francis Signed-off-by: Michael Clark Reviewed-by: Richard Henderson Message-Id: Signed-off-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, uin= t32_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 =3D 0; i < count; ++i) { + p[i] =3D encode_i(OPC_ADDI, TCG_REG_ZERO, TCG_REG_ZERO, 0); + } +} --=20 2.17.2