Mike Frysinger [Fri, 22 Dec 2023 00:57:14 +0000 (19:57 -0500)]
sim: tighten up generated decode tables
The use of /* fall through */ with consective case statements doesn't
really add any value, and when generating large files, can take up a
lot of space. In the case of cris, it alone adds ~20k, or ~10%.
Also trim the space before the : with case statements.
Mike Frysinger [Fri, 22 Dec 2023 00:43:43 +0000 (19:43 -0500)]
sim: avoid shadowing vars when decoding insns
When generating switch decode tables, the switch statements all use
the same variable name "val". This causes nested switches to shadow
earlier ones. Use the existing "switch-num" to generate unique names
when nesting since it's otherwise unused.
Previously we'd have:
...
{
unsigned int val = (((insn >> 4) & (255 << 0)));
switch (val)
{
...
case 15 :
{
unsigned int val = (((insn >> 12) & (15 << 0)));
switch (val)
{
...
Leading to:
.../sim/cris/decodev10.c: In function ‘crisv10f_decode’:
.../sim/cris/decodev10.c:351:24: error: declaration of ‘val’ shadows a previous local [-Werror=shadow=compatible-local]
351 | unsigned int val = (((insn >> 12) & (15 << 0)));
| ^~~
.../sim/cris/decodev10.c:331:20: note: shadowed declaration is here
331 | unsigned int val = (((insn >> 4) & (255 << 0)));
| ^~~
Now we have:
...
{
unsigned int val0 = (((insn >> 4) & (255 << 0)));
switch (val0)
{
...
case 15 :
{
unsigned int val1 = (((insn >> 12) & (15 << 0)));
switch (val1)
{
...
Mike Frysinger [Thu, 21 Dec 2023 04:26:13 +0000 (23:26 -0500)]
sim: mark local insn var as unused [PR sim/31181]
Some insns are fully decoded by the time they execute here, and don't
need to extract any more fields. This leads to the local insn var
being unused which triggers compiler warnings. Mark it as unused so
we don't require ports to stub it themselves.
Tom Tromey [Tue, 22 Aug 2023 17:47:52 +0000 (11:47 -0600)]
Enable the Guile compiler
This patch changes cgen so that the Guile compiler can be used.
Mainly this is done by using eval-when to ensure that files are loaded
during the compilation process. However, "-s" handling and
srcdir-setting are also cleaned up, using Guile's (current-filename)
feature.
The main benefit of using the compiler is that it is much faster, once
the scripts have been compiled. Also it simplifies the use of cgen,
as users don't need to remember to set an environment variable before
invoking it.
Tom Tromey [Sat, 19 Aug 2023 17:41:37 +0000 (11:41 -0600)]
Load macros before uses
This hoists the various calls to 'load' to an earlier spot in
read.scm. Without this patch, the call to logit
/cmd-define-rtl-version would not be expanded, leading to a mysterious
error about trying to 'apply' a syntax transformer. That is, this is
another situation where the old code assumed that macro expansion
could be interleaved with evaluation.
Tom Tromey [Sat, 19 Aug 2023 17:41:34 +0000 (11:41 -0600)]
Nuke cgen-call-with-debugging and cgen-debugging-stack-start
cgen-call-with-debugging and cgen-debugging-stack-start are ostensibly
just for Guile, but I don't think they provide much value with more
recent versions of Guile. This patch removes them.
Tom Tromey [Sat, 19 Aug 2023 17:41:31 +0000 (11:41 -0600)]
Invalid code in rtx-traverse.scm
The Guile compiler pointed out a 3-argument call to cons in
rtx-traverse.scm. Presumably this code is never run, but this patch
replaces it with what I think is the correct form.
Tom Tromey [Sat, 19 Aug 2023 17:41:28 +0000 (11:41 -0600)]
Hack cos.scm to work with new Guile
cos.scm calls procedure->memoizing-macro, which no longer exists in Guile.
This patch hacks around this by having the member accessors always use
the "slow" path. In practice, with Guile 3.0, this is still fast
enough on my machine.
Longer term this code should all be removed in favor of GOOPS.
Tom Tromey [Sat, 19 Aug 2023 17:41:23 +0000 (11:41 -0600)]
Remove let bindings of macros
rtx-funcs.scm assumes that it can let-bind to macros and the right
thing will happen. However, this is not correct according to more
recent versions of Guile, which more cleanly separate the expansion
and evaluation phases.
Remove the bindings and simply refer to the wordier names.
Alan Modra [Thu, 10 Aug 2023 02:34:17 +0000 (12:04 +0930)]
sim: update to reduce generated file differences
Put binutils-gdb commit db7858e227f3 (Mike Frysinger 2015-06-12) and 13a590ca65f7 (Mike Frysinger 2017-02-13) in the source rather than
generated files.
Mike Frysinger [Tue, 1 Nov 2022 14:44:30 +0000 (20:29 +0545)]
sim-cpu: move cpu_data inside arch-specific cpu state
The cgen ports store their data inside sim_cpu which, currently, is
defined uniquely for every sim arch port. We're changing that in the
sim world so that there is a single common sim_cpu, but this requires
moving the arch-specific data (including this cgen data) into a new
struct that is accessed via the common sim_cpu structure.
That is all hidden behind a new @ARCH@_SIM_CPU macro, so add that call
to the CPU_CGEN_HW macro that is generated here.
word-length relies in base-len (sum of length of all fields
in bitrange objects that conform the instruction), word-value
and word-mask are not using the offset entry in the bitrange
object to calculate the accurate values when constant fields
are provided (ifld-constant? #t), so one more argument
is passed to those procedures to be used in the compute.
Regression tests to the following targets were done:
2021-09-15 Guillermo E. Martinez <guillermo.e.martinez@oracle.com>
* ifield.scm: word-len has a relative value depending of word-offset
value, method field-value use word-offset parameter.
* insn.scm: remove condition ifld-beyond-base? in insn-base-value
procedure to allow field access when its offset is different to zero.
* utils.scm: word-value/work-mask accept an offset as argument to
compute the mask and get the value when offset is different that zero.
Mike Frysinger [Sun, 27 Jun 2021 03:26:58 +0000 (23:26 -0400)]
sim-decode: include cgen-mem & cgen-ops
The bpf & cris ports use functions from both of these APIs, so include
them here for all ports just in case (and since there isn't an API for
ports to declare specific additional headers they need).
Mike Frysinger [Sun, 31 Jan 2021 21:40:48 +0000 (16:40 -0500)]
sim: rename TRACE_EXTRACT to CGEN_TRACE_EXTRACT
As was done for other touch points in the sim project, add a CGEN_
prefix to namespace it away from the common code. The generated
files have already been updated years ago.
Alan Modra [Thu, 13 Jun 2019 01:45:07 +0000 (11:15 +0930)]
Update to autotools used by binutils
When cgen source is installed in the top source directory of
binutils-gdb and configuring with --enable-maintainer-mode
--enable-cgen-maint=yes it is somewhat annoying to regenerate cgen
files without differences due to using different autotools.
Particularly so since the generated files in the git repository don't
all use the same autotools.
This patch fixes that by modernising the source a little and
regenerating with autoconf-2.69 and automake-1.15.1.
Note that doc/stamp-vti and doc/version.texi contain dates taken from
your checked out doc/cgen.texi file time stamp. So in order to
regenerate these files consistently it is necessary to
touch --date=xxx doc/cgen.texi
with the date taken from the last doc/cgen.texi commit.
Stafford Horne [Sat, 1 Jun 2019 07:26:29 +0000 (16:26 +0900)]
gen-doc: Updates for latest cpu definitions
Doc generation was no longer working due to several issues.
- openrisc.cpu no longer exists (its not cpu/or1k.cpu in binutils-gdb)
- Relavive paths for archfile no longer work due to wrong cwd.
- Many architectures have been added and removed.
I have be able to get this working and added all the architectures I
could get working with the below changes. I have posted the results
here:
http://shorne.noip.me/downloads/gen-doc/
ChangeLog:
yyyy-mm-dd Stafford Horne <shorne@gmail.com>
* gen-all-doc (archs): Add new archs and update locations.
(archfile): Prepend cgendir.
(index.html gen): Change name openrisc to or1k.
* html.scm (gen-html-trailer): Change redhat.com to
sourceware.org.
Stafford Horne [Sat, 1 Jun 2019 07:26:28 +0000 (16:26 +0900)]
cgen: Add unordered compare operation
On OpenRISC we have added FPU unordered comparison operations (NaN
detection). This patch adds the unordered operation which will generate
c hooks to be implemented in simulators.
An unordered comparison can now be defined as:
; Compare unordered (set flag if either r1 or r2 is NaN)
(set BI flag (unordered WI r1 r2))
; Compare unordered, greater than or equal
(set BI flag (or (unordered WI r1 r2)
(ge WI r1 r2)))
ChangeLog:
yyyy-mm-dd Stafford Horne <shorne@gmail.com>
* rtl-c.scm (unordered): New comparison operation.
* rtx-funcs.scm (unordered): New rtx node.
Jose E. Marchesi [Tue, 14 May 2019 18:09:25 +0000 (20:09 +0200)]
cgen: partial support for 64-bit wide fields in 32-bit hosts
Hi people!
This patch adds support for having 64-bit wide fields working in
32-bit hosts. This is not a complete solution, but it is enough for
supporting:
- Defining a 64-bit h-sint in your .cpu file.
- Using that hardware to define an operand featuring as index a
64-bit wide multi-ifield.
Note that the current CGEN support in binutils provides
cgen_{extract,insert}_normal functions that get `long' values, hence
the need for the operand to be indexed by a multi-ifield.
This is used by an eBPF binutils port which I will be upstreaming this
week. All other CGEN-based ports currently in binutils are not
impacted by this change.
Eventually, we shall make the "portable" INT/UINT modes (and
associated hardwares s-int/s-uint) to work properly in 32-bit hosts
when holding 64-bit values.
I have a tentative large patch attempting that, including changes in
binutils's opcodes CGEN support, that I will send for comments soon,
but in the meanwhile I would really appreciate if this gets into cgen.
(Without this patch applied, the eBPF assembler doesn't work properly
in 32-bit hosts.)
Thanks!
2019-05-14 Jose E. Marchesi <jose.marchesi@oracle.com>
* opcodes.scm (gen-ifield-default-type): Use int64_t for fields
wider than 32-bits.
(/gen-parse-number): Use u?int64_t for > 32-bit modes.
(gen-ifield-value-decl): Fix call to gen-ifield-default-type.
(<ifield>, gen-insert): Likewise.
(<ifield>, gen-extract): Likewise.
* opc-asmdis.scm (char): Likewise.
Alan Modra [Sat, 3 Mar 2018 01:31:31 +0000 (01:31 +0000)]
binutils opcodes error messages
This patch is aimed at making binutils/opcodes files comply with the
GNU coding standard regarding error messages, that is, they should
start with the program name followed by a colon, then a lower case
message. Accomplished by calling opcodes_error_handler to output the
program name (and final '\n'), rather than calling fprintf.
Alan Modra [Thu, 13 Apr 2017 11:58:48 +0000 (11:58 +0000)]
PR 20946
* desc-cpu.scm (lookup_mach_via_bfd_name): Return NULL if the name
could not be matched.
(@arch@_cgen_cpu_open): Allow for lookup_mach_via_bfd_name returning
Mike Frysinger [Mon, 9 May 2016 21:50:25 +0000 (21:50 +0000)]
cgen: sim: Updates to sim files to match gdb types
The types like MACH and MODEL have changes to SIM_MACH and SIM_MODEL
make updates to match these changes. This way people dont have to
manually update the generated files in GDB.
Nick Clifton [Wed, 3 Nov 2010 17:02:34 +0000 (17:02 +0000)]
* cpu/xstormy16.cpu (alignfix-mem-far): New macro. Like
alignfix-mem, but works with 32-bit addresses.
(set-alignfix-mem-far): New macro. Like set-alignfix-mem but
works with 32-bit addresses.
(movfgrgri, movfgrgripostinc, movfgrgripredec, movfgrgrii,
movfgrgriipostinc, movfgrgriipredec): Use alignfix-mem-far.
(movfgrigr, movfgripostincgr, movfgripredecgr): Use
set-alignfix-mem-far.
(movfgrgriipostinc, movfgriipostincgr): Propagate addition to
source register into base register.
(movfgrgriipredec, movfgriipredecgr): Propagate subtraction from
source register into base register.
* xstormy16-sem.cxx: Regenerate.
* testutils.inc (pass): Update parameter layout for write syscall.
(fail): Likewise.
* movgrgrii.cgs: Fix endianness typo in assertion.
* movgrgriipostinc.cgs: Likewise.
* movgrgriipredec.cgs: Likewise.
* movgrgripostinc.cgs: Likewise.
* movgrgripredec.cgs: Likewise.
* movgrigr.cgs: Likewise.
* movgriipostincgr.cgs: Likewise.
* movgripostincgr.cgs: Likewise.
* movgripredecgr.cgs: Likewise.
* rrcgrgr.cgs: Rotate only inserts carry flag once.
* rrcgrimm4.cgs: Likewise.
* movfgrgriipostinc.cgs: New test. Checks MOVF load with post increment.
* movfgrgriipredec.cgs: New test. Checks MOVF load with pre decrement.
* movfgriipostincgr.cgs: New test. Checks MOVF store with post increment.
* movfgriipostincgr.cgs: New test. Checks MOVF store with pre decrement.
Doug Evans [Thu, 28 Jan 2010 04:45:15 +0000 (04:45 +0000)]
* pmacros.scm: Follow commenting convention. Replace change to
$pmacro to %pmacro. $pmacro is confusing with $ in assembler syntax.
(/pmacro-orig-prefix, /pmacro-prefix): New globals.
Doug Evans [Mon, 25 Jan 2010 00:40:29 +0000 (00:40 +0000)]
* utils-cgen.scm (<location>): Define using new define-class.
(<ident>, <source-ident>, <context>): Ditto.
* cos.scm (/object-string): New function.
(/object-error): Use it.
(/object-count-true): New function
(object-copy-top): Delete. All callers changed to call object-copy.
(/parse-member-list, /build-getter-defs, /build-setter-defs): New fns.
(define-class, define-interface, define-method): New macros.
(define-getters, define-setters, vmake): Moved here ...
* utils-cgen.scm: ... from here.
Doug Evans [Wed, 6 Jan 2010 05:05:13 +0000 (05:05 +0000)]
* mode.scm (<mode>) Rename member non-mode-c-type to c-type.
All uses updated.
(mode:non-mode-c-type): Delete.
(mode:c-type): Update.
* rtl-c.scm (s-shop): Fix casting of DI mode values.