From patchwork Wed Jun 19 05:04:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Bobek X-Patchwork-Id: 11003347 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 566F514BB for ; Wed, 19 Jun 2019 05:06:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3AF9928B4F for ; Wed, 19 Jun 2019 05:06:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 297AC28B4C; Wed, 19 Jun 2019 05:06:55 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B20D728B4C for ; Wed, 19 Jun 2019 05:06:54 +0000 (UTC) Received: from localhost ([::1]:35160 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdSo9-0005vu-SO for patchwork-qemu-devel@patchwork.kernel.org; Wed, 19 Jun 2019 01:06:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34420) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hdSmT-0003uC-Ie for qemu-devel@nongnu.org; Wed, 19 Jun 2019 01:05:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hdSmR-0001eo-Lv for qemu-devel@nongnu.org; Wed, 19 Jun 2019 01:05:09 -0400 Received: from mail-yb1-xb44.google.com ([2607:f8b0:4864:20::b44]:45565) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hdSmP-0001dC-Ob for qemu-devel@nongnu.org; Wed, 19 Jun 2019 01:05:05 -0400 Received: by mail-yb1-xb44.google.com with SMTP id v104so7061841ybi.12 for ; Tue, 18 Jun 2019 22:05:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2AL1b+nMXBf7cujyRtXqMsJ+EqszwrRf6hdCVJcNcgk=; b=aMb2IimZL2r6VQHh2dR+iKTXQXASyiRNX6y/XDqg2TNVsOxrjyONpkUGNZm37+cW3V Kchl5gvfDBwfDF8ZkQR0Nqiv5Mpvc7yo4OmYX+//t92yQGEjkCOeYJbjv2SiSKDnBJtA Rv/t85GnGnZfWVem42i7OxUkr/WRvjgwUFv9phAea6mMC09lLTKiTHQRdq8vETYw2xF5 Ej2JI1366Rf1zoQIzjkS+XRbvLW9yt2ncHvN0JU1p7rk9g6a7acetr3hxcB4ipEq5icB Rl49pH5zCKcc88P4ljuNyfv5p5k4Fd/cVjoEMilCHeNKv+IFl4bpTHGUVJKeqHELcccL 0dyA== 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=2AL1b+nMXBf7cujyRtXqMsJ+EqszwrRf6hdCVJcNcgk=; b=U6p/oz2Ej0QxvgtTOtL2c8CvBaF5dTpzpmLrMHHjx2Q+yJT5AN203KjsA59FZE6NUH 5MGsMGdezWZvVZIhEr1F93ph8C88V9aImxm+qr75yj6lKduynnnoO/TA8HamBE6xSi5H 5c+4L3fpB0fwyiMPhCn6LPoOxUx1WPs8w7vLcmcndkdxbzAQzsf8QCv8ou43oMkw/XSO rYtpvvRZBz9Iw4u95aXIjFU/5mhTsw07ogCwibUdeVBykj70LsoNIjIlUf+ukE00FtYl WoUP3fDiIf+JTayZOjq1/PZXkfdVQWiBinsochjLvPwbBHWBVc3+vaRAD3NdgJv/s9EA Am6Q== X-Gm-Message-State: APjAAAVuCcRGysE4/xpJaocF+W0Xg0IFyMeoGRi2UKMpQBVhrR9f8J2q p0n4gW57kwLYNkLRCS9XK0GIVq3q X-Google-Smtp-Source: APXvYqyGrJIzp0FKOlN6d7zRMGMNPeugaKgK1XCn5WVhk2jJxDCOyr1DapNBNmvQiB3/oHx2ah2T1w== X-Received: by 2002:a25:e80b:: with SMTP id k11mr4060163ybd.434.1560920704814; Tue, 18 Jun 2019 22:05:04 -0700 (PDT) Received: from localhost.localdomain (67-9-99-67.biz.bhn.net. [67.9.99.67]) by smtp.gmail.com with ESMTPSA id e12sm1714426ywe.85.2019.06.18.22.05.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 18 Jun 2019 22:05:04 -0700 (PDT) From: Jan Bobek To: qemu-devel@nongnu.org Date: Wed, 19 Jun 2019 01:04:43 -0400 Message-Id: <20190619050447.22201-4-jan.bobek@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190619050447.22201-1-jan.bobek@gmail.com> References: <20190619050447.22201-1-jan.bobek@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::b44 Subject: [Qemu-devel] [RISU RFC PATCH v1 3/7] risugen_x86_emit: add module X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jan Bobek , =?utf-8?q?Alex_Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP The helper module risugen_x86_emit.pm exports a single function "parse_emitblock", which serves to capture and return instruction constraints described by "emit" blocks in an x86 configuration file. Signed-off-by: Jan Bobek --- risugen | 2 +- risugen_x86_emit.pm | 85 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 risugen_x86_emit.pm diff --git a/risugen b/risugen index e690b18..fe3d00e 100755 --- a/risugen +++ b/risugen @@ -43,7 +43,7 @@ my @pattern_re = (); # include pattern my @not_pattern_re = (); # exclude pattern # Valid block names (keys in blocks hash) -my %valid_blockname = ( constraints => 1, memory => 1 ); +my %valid_blockname = ( constraints => 1, memory => 1, emit => 1 ); sub parse_risu_directive($$@) { diff --git a/risugen_x86_emit.pm b/risugen_x86_emit.pm new file mode 100644 index 0000000..0e3cc1c --- /dev/null +++ b/risugen_x86_emit.pm @@ -0,0 +1,85 @@ +#!/usr/bin/perl -w +############################################################################### +# Copyright (c) 2019 Linaro Limited +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Eclipse Public License v1.0 +# which accompanies this distribution, and is available at +# http://www.eclipse.org/legal/epl-v10.html +# +# Contributors: +# Jan Bobek - initial implementation +############################################################################### + +# risugen_x86_emit -- risugen_x86's helper module for emit blocks +package risugen_x86_emit; + +use strict; +use warnings; + +use risugen_common; +use risugen_x86_asm; + +our @ISA = qw(Exporter); +our @EXPORT = qw(parse_emitblock); + +my $emit_opts; + +sub rep(%) +{ + my (%opts) = @_; + $emit_opts->{rep} = \%opts; +} + +sub repne(%) +{ + my (%opts) = @_; + $emit_opts->{repne} = \%opts; +} + +sub data16(%) +{ + my (%opts) = @_; + $emit_opts->{data16} = \%opts; +} + +sub rex(%) +{ + my (%opts) = @_; + $emit_opts->{rex} = \%opts; +} + +sub modrm(%) +{ + my (%opts) = @_; + $emit_opts->{modrm} = \%opts; +} + +sub mem(%) +{ + my (%opts) = @_; + $emit_opts->{mem} = \%opts; +} + +sub imm(%) +{ + my (%opts) = @_; + $emit_opts->{imm} = \%opts; +} + +sub parse_emitblock($$) +{ + my ($rec, $insn) = @_; + my $insnname = $rec->{name}; + my $opcode = $insn->{opcode}{value}; + + $emit_opts = {}; + + my $emitblock = $rec->{blocks}{"emit"}; + if (defined $emitblock) { + eval_with_fields($insnname, $opcode, $rec, "emit", $emitblock); + } + + return $emit_opts; +} + +1;