From patchwork Wed Jun 13 12:55:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 138463 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp694613lji; Wed, 13 Jun 2018 06:03:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKfnO/Vwgs12vRn2AEUOdBNQagVo+xeZ7BRB0eu8VK1l/w6nqXEvuRYSWVs+WIiZeK09rHm X-Received: by 2002:ac8:2ee5:: with SMTP id i34-v6mr4191337qta.390.1528895010123; Wed, 13 Jun 2018 06:03:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528895010; cv=none; d=google.com; s=arc-20160816; b=BTbGaDJqedGhNi3VHzXxHhE7aZYkx9nFEODuo6FaQE1H+GuQNHZEPi4A8W9cvbksCI yHatstNcu8wEc5PpNKc/LkYydb6PUQhZzPBYbw++ypyVlDdd84B2G9KthHfpXo6Rdb3d Gm3xsvDmTbMXhkMsL6J3lWndrYTcmuZS07x8zqLgVmnjyk0rzAqsYDZogkXQnvuZ9n5B 2yckxAXrifoPOf/WzCP81X8TEAZYpe+7JoK7rpQcxu1XzvVnPy4z6p7hv0WHueDPlkhG L9V6tWMShzy71Pf43NbYMVUgZLWc2+3zAnfmYcPHCa7BegMV2t8DES6z8yvUqs63TfMa HLtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=yGIXH0KQMm00dKEL2Etwd2IPZwUNEDVV+bNKLpa67ZE=; b=di78c/tqjKXIBS7z5kDa3kOYgaHGn6A4qDtZ1HSEyPxNmUDMlkcLa8hWx3Zgg5a7Re zvDIi7VtAD0aeiMJXOkMXrURQrQqQcq7TtDqShEq0FNcZ7duiVo3wEtoc/hq9CtMwpc9 P7OlRNcHe02IOX7SCfiphiNoksznWUXh7MkMTx0hesoCUGrjp5YKYQu/vNM3g8HTWQ1O MB06a3zwk5oIp6EnJxM4Hi/RsdQk4oyvAHkiAsoOluLPXXdz1lh6zTDUiA5fku7xfk0P xK502FuSfT4JY3Z5gfNRnsZ80FS+VmIpzjnyirfYMvkv8wwbIpfuN6G/CkUQd0FLWG6i liag== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=e8GmGeWV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id y12-v6si2455547qtn.77.2018.06.13.06.03.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 13 Jun 2018 06:03:30 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=e8GmGeWV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:34034 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fT5Qv-0000Ex-Ik for patch@linaro.org; Wed, 13 Jun 2018 09:03:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50470) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fT5Jt-0002fd-7E for qemu-devel@nongnu.org; Wed, 13 Jun 2018 08:56:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fT5Js-0005DK-D5 for qemu-devel@nongnu.org; Wed, 13 Jun 2018 08:56:13 -0400 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]:35117) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fT5Js-0005CY-6I for qemu-devel@nongnu.org; Wed, 13 Jun 2018 08:56:12 -0400 Received: by mail-wr0-x234.google.com with SMTP id l10-v6so2673820wrn.2 for ; Wed, 13 Jun 2018 05:56:11 -0700 (PDT) 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 :mime-version:content-transfer-encoding; bh=yGIXH0KQMm00dKEL2Etwd2IPZwUNEDVV+bNKLpa67ZE=; b=e8GmGeWVF0Sg5hV1iNY0UVSJJxqeK7ITd2BbFCZ7BnP/DK/KCJ7SUvmNzo2sXMXydk jRz39SeFBIg99/8dTQ/8v14SiqyKemTw7jzE2N/JZ0x9MB06M/G2HFAtRYunN2pFCmex jvO/QUaoQ5cs47A/Q+aCFUbxpLBBsCiBCMdeg= 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:mime-version:content-transfer-encoding; bh=yGIXH0KQMm00dKEL2Etwd2IPZwUNEDVV+bNKLpa67ZE=; b=V7O60hLBkhtpPT7Websv24tPNT5ZmweYnPxhDZ/wFxVqljPg5dUXdPmPt90mtTN51p rGMe5ZXpzQK8jZIPfelgmSo9OmGa8a0EEziN8nteho/AtGRyAz0ox76AdbrU3LD6p6lE cUjdMk9OfdG9Yog8SuU/QABsQESYxpsWWmPYImWHqn7h0ZV8ziyPhGvE+CwIT/myJFP9 to7dk9avOO3uyrTL7vzhfW4GD3pv+JOEbtpImDlm2EPR3huT8hzkgAZHOAZGKiVzwIhU 1d91FigURJhMNU4zmsuAoF5isFyV0QbwRqvjiqi3IXDk9ncLyfzsbk8qhS/bt2uVD9LL THog== X-Gm-Message-State: APt69E11nCbeq8hr9BKIGuvo93lb0QqrYecffJvOIBw+CYmKnB3p9fID +iIw++cR+3PH/fltqt17LD6YSQ== X-Received: by 2002:adf:fb92:: with SMTP id a18-v6mr3914657wrr.278.1528894571083; Wed, 13 Jun 2018 05:56:11 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id h8-v6sm1776348wmb.32.2018.06.13.05.56.04 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 13 Jun 2018 05:56:07 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id A10ED3E121A; Wed, 13 Jun 2018 13:56:01 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Wed, 13 Jun 2018 13:55:48 +0100 Message-Id: <20180613125601.14371-10-alex.bennee@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180613125601.14371-1-alex.bennee@linaro.org> References: <20180613125601.14371-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::234 Subject: [Qemu-devel] [RISU PATCH v3 09/22] risugen: use fewer insns for aarch64 immediate load 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: =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-arm@nongnu.org, richard.henderson@linaro.org, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson Signed-off-by: Alex Bennée --- risugen_arm.pm | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) -- 2.17.1 diff --git a/risugen_arm.pm b/risugen_arm.pm index 83e521d..485e94e 100644 --- a/risugen_arm.pm +++ b/risugen_arm.pm @@ -261,15 +261,13 @@ sub write_mov_rr($$) sub write_mov_ri16($$$) { - # Write 16 bits of immediate to register, using either MOVW or MOVT + # Write 16 bits of immediate to register. my ($rd, $imm, $is_movt) = @_; - die "write_mov_ri16: immediate $imm out of range\n" if (($imm & 0xffff0000) != 0); - if ($is_aarch64) { - # Use MOVZ 0x52800000. is_movt means MOVK of high bits */ - insn32(0xd2800000 | ($is_movt << 29) | ($is_movt ? 16 << 17 : 0) | ($imm << 5) | $rd); + die "write_mov_ri16: invalid operation for this arch.\n" if ($is_aarch64); + die "write_mov_ri16: immediate $imm out of range\n" if (($imm & 0xffff0000) != 0); - } elsif ($is_thumb) { + if ($is_thumb) { # enc T3 my ($imm4, $i, $imm3, $imm8) = (($imm & 0xf000) >> 12, ($imm & 0x0800) >> 11, @@ -287,16 +285,24 @@ sub write_mov_ri16($$$) sub write_mov_ri($$) { - # We always use a MOVW/MOVT pair, for simplicity. - # on aarch64, we use a MOVZ/MOVK pair. my ($rd, $imm) = @_; - write_mov_ri16($rd, ($imm & 0xffff), 0); my $highhalf = ($imm >> 16) & 0xffff; - write_mov_ri16($rd, $highhalf, 1) if $highhalf; - if ($is_aarch64 && $imm < 0) { - # sign extend to allow small negative imm constants - write_sxt32($rd, $rd); + if ($is_aarch64) { + if ($imm < 0) { + # MOVN + insn32(0x92800000 | ((~$imm & 0xffff) << 5) | $rd); + # MOVK, LSL 16 + insn32(0xf2a00000 | ($highhalf << 5) | $rd) if $highhalf != 0xffff; + } else { + # MOVZ + insn32(0x52800000 | (($imm & 0xffff) << 5) | $rd); + # MOVK, LSL 16 + insn32(0xf2a00000 | ($highhalf << 5) | $rd) if $highhalf != 0; + } + } else { + write_mov_ri16($rd, ($imm & 0xffff), 0); + write_mov_ri16($rd, $highhalf, 1) if $highhalf; } }