Commit Graph

4563 Commits

Author SHA1 Message Date
Alan Modra
29136be7df Don't use BFD_VMA_FMT in gdb and sim
Like commit b82817674f, this replaces BFD_VMA_FMT "x" in sim/ with
PRIx64 and casts to promote bfd_vma to uint64_t.  The one file using
BFD_VMA_FMT in gdb/ instead now uses hex_string, and a typo in the
warning message is fixed.
2022-08-06 08:03:16 +09:30
Sergei Trofimovich
33b90f59f3 sim: fix BFD_VMA format arguments on 32-bit hosts [PR gdb/29184]
Noticed format mismatch when attempted to build gdb on i686-linux-gnu
in --enable-64-bit-bfd mode:

    sim/../../sim/cris/sim-if.c:576:28:
        error: format '%lx' expects argument of type 'long unsigned int',
        but argument 4 has type 'bfd_size_type' {aka 'long long unsigned int'} [-Werror=format=]
      576 |       sim_do_commandf (sd, "memory region 0x%" BFD_VMA_FMT "x,0x%lx",
          |                            ^~~~~~~~~~~~~~~~~~~
      577 |          interp_load_addr, interpsiz);
          |                            ~~~~~~~~~
          |                            |
          |                            bfd_size_type {aka long long unsigned int}

While at it fixed format string for time-related types.
2022-06-15 23:12:56 +01:00
Alan Modra
845cbaa9ff sim: remove use of PTR
PTR will soon disappear from ansidecl.h.  Remove uses in sim.  Where
a PTR cast is used in assignment or function args to a void* I've
simply removed the unnecessary (in C) cast rather than replacing with
(void *).
2022-05-13 14:32:54 +09:30
Jeff Law
477904ca75 Fix for v850e divq instruction
This is the last of the correctness fixes I've been carrying around for the
v850.

Like the other recent fixes, this is another case where we haven't been as
careful as we should WRT host vs target types.   For the divq instruction
both operands are 32 bit types.  Yet in the simulator code we convert them
from unsigned int to signed long by assignment.  So 0xfffffffb (aka -5)
turns into 4294967291 and naturally that changes the result of our division.

The fix is simple, insert a cast to int32_t to force interpretation as a
signed value.

Testcase for the simulator is included.  It has a trivial dependency on the
bins patch.
2022-04-06 11:10:40 -04:00
Jeff Law
49fffa58f7 Fix "bins" simulation for v850e3v5
I've been carrying this for a few years.   One test in the GCC testsuite is
failing due to a bug in the handling of the v850e3v5 instruction "bins".

When the "bins" instruction specifies a 32bit bitfield size, the simulator
exhibits undefined behavior by trying to shift a 32 bit quantity by 32 bits.
In the case of a 32 bit shift, we know what the resultant mask should be.  So
we can just set it.

That seemed better than using 1UL for the constant (on a 32bit host unsigned
long might still just be 32 bits) or needlessly forcing everything to
long long types.

Thankfully the case where this shows up is only bins <src>, 0, 32, <dest>
which would normally be encoded as a simple move.

	* testsuite/v850/allinsns.exp: Add v850e3v5.
	* testsuite/v850/bins.cgs: New test.
	* v850/simops.c (v850_bins): Avoid undefined behavior on left shift.
2022-04-06 11:06:53 -04:00
Andrew Burgess
7b01c1cc1d sim: fixes for libopcodes styled disassembler
In commit:

  commit 60a3da00bd
  Date:   Sat Jan 22 11:38:18 2022 +0000

      objdump/opcodes: add syntax highlighting to disassembler output

I broke several sim/ targets by forgetting to update their uses of the
libopcodes disassembler to take account of the new styled printing.

These should all be fixed by this commit.

I've not tried to add actual styled output to the simulator traces,
instead, the styled print routines just ignore the style and print the
output unstyled.
2022-04-04 22:41:24 +01:00
Jeff Law
5321c31bc7 Fix for MUL instruction on the v850
* sim/v850/simops.c (Multiply64): Properly test if we need to
	negate either of the operands.

	* sim/testsuite/v850/mul.cgs: New test.
2022-03-29 20:08:35 -04:00
Mike Frysinger
7cd7b0641b sim: add arch/.gdbinit stub scripts
Make it easy to load the common gdbinit script even when running in
the arch/ subdir instead of the top-level sim dir.
2022-03-28 23:10:34 -04:00
Nick Alcock
caf606c90d libtool.m4: fix the NM="/nm/over/here -B/option/with/path" case
My previous nm patch handled all cases but one -- if the user set NM in
the environment to a path which contained an option, libtool's nm
detection tries to run nm against a copy of nm with the options in it:
e.g. if NM was set to "nm --blargle", and nm was found in /usr/bin, the
test would try to run "/usr/bin/nm --blargle /usr/bin/nm --blargle".
This is unlikely to be desirable: in this case we should run
"/usr/bin/nm --blargle /usr/bin/nm".

Furthermore, as part of this nm has to detect when the passed-in $NM
contains a path, and in that case avoid doing a path search itself.
This too was thrown off if an option contained something that looked
like a path, e.g. NM="nm -B../prev-gcc"; libtool then tries to run
"nm -B../prev-gcc nm" which rarely works well (and indeed it looks
to see whether that nm exists, finds it doesn't, and wrongly concludes
that nm -p or whatever does not work).

Fix all of these by clipping all options (defined as everything
including and after the first " -") before deciding whether nm
contains a path (but not using the clipped value for anything else),
and then removing all options from the path-modified nm before
looking to see whether that nm existed.

NM=my-nm now does a path search and runs e.g.
  /usr/bin/my-nm -B /usr/bin/my-nm

NM=/usr/bin/my-nm now avoids a path search and runs e.g.
  /usr/bin/my-nm -B /usr/bin/my-nm

NM="my-nm -p../wombat" now does a path search and runs e.g.
  /usr/bin/my-nm -p../wombat -B /usr/bin/my-nm

NM="../prev-binutils/new-nm -B../prev-gcc" now avoids a path search:
  ../prev-binutils/my-nm -B../prev-gcc -B ../prev-binutils/my-nm

This seems to be all combinations, including those used by GCC bootstrap
(which, before this commit, fails to bootstrap when configured
--with-build-config=bootstrap-lto, because the lto plugin is now using
--export-symbols-regex, which requires libtool to find a working nm,
while also using -B../prev-gcc to point at the lto plugin associated
with the GCC just built.)

Regenerate all affected configure scripts.

	* libtool.m4 (LT_PATH_NM): Handle user-specified NM with
	options, including options containing paths.
2022-03-25 12:02:35 +00:00
Reuben Thomas
8bd59ec1bb sim: fix a comment typo in sim-load.c
Fix a typo where the documentation refers to a function parameter by the
wrong name.

Change-Id: I99494efe62cd4aa76fb78a0bd5da438d35740ebe
2022-03-24 13:28:50 -04:00
Reuben Thomas
c41524681b sim: fix “alligned” typos
Change-Id: Ifd574e38524dd4f1cf0fc003e0c5c7499abc84a0
2022-03-24 10:34:51 -04:00
Mike Frysinger
216722984f sim: gdbinit: hoist setup to common code
This was left in subdirs because of the dynamic cgen usage.  However,
we can move this breakpoint call to runtime and let gdb detect whether
the symbol exists.
2022-02-21 13:57:33 -05:00
Hans-Peter Nilsson
e94b2738a1 sim/common: Improve sim_dump_memory head comment
As requested by Mike.

	* sim-memopt.c: Improve head comment.
2022-02-16 07:38:44 +01:00
Hans-Peter Nilsson
7443cb7479 sim/testsuite/cris/c/stat3.c: Fix formatting nit
* c/stat3.c (main): Fix formatting nit.
2022-02-16 07:38:38 +01:00
Mike Frysinger
d0b2f561a1 sim: testsuite: cleanup the istarget * logic
Now that the multitarget testing has settled, clean up the cases where
istarget * is used.  This ends up being mostly style unindenting.
2022-02-16 00:36:47 -05:00
Hans-Peter Nilsson
e63f65fea9 sim/testsuite: Default global_cc_os and global_cc_works properly
There was an omission on 3e6dc39ed7 "sim/testsuite: Set
global_cc_os also when no compiler is found"; global_cc_os
wasn't set for other than the primary target, which means
that the "unguarded" use of global_cc_os in
testsuite/cris/c/c.exp caused the dreaded "ERROR: can't read
"global_cc_os": no such variable" when e.g. configuring for
pru-elf and doing "make check-sim".  Better initializing
both variables at the top to default values, rather than
adding another single 'set global_cc_os ""', to reduce the
risk of not setting them properly if or when that
if-statement-chain is made longer.

sim/testsuite:
	* lib/sim-defs.exp (sim_init_toolchain): Default
	global_cc_os and global_cc_works properly, before if-chain.
2022-02-15 23:35:23 +01:00
Hans-Peter Nilsson
234f5865fa sim/testsuite/cris: If failing compilation, mark C tests as errors
...when we know we have a working compiler.  This will reduce
the risk of faulty edits by exposing them rather than hiding
them as "unresolved".  It also harmonizes behavior with that of
run_sim_test.

	* c/c.exp: Mark C tests failing compilation test errors.
2022-02-14 23:53:23 +01:00
Hans-Peter Nilsson
4b0e74fd18 sim/testsuite/cris: Remove faulty use of basename in C tests
Calls to basename were added here as part of commit
e1e1ae6e9b "sim: testsuite: fix objdir handling", but that
commit missed adding "#include <libgen.h>" or the equivalent
GNU extension, see basename(3).  Fixing that shows a logical
error in the change to openpf1.c; the non-/-prefixed
code-path was changed instead of the "/"-prefixed code-path,
which is the one executed after that commit.

For "newlib" these tests failed linking after that commit.
Recent newlib has the (asm-renamed) GNU-extension-variant of
basename, but we're better off not using it at all.

Unfortunately, compilation failures for C tests run by the
machinery in c.exp are currently just marked "unresolved",
in contrast to C and assembler tests run by calling
run_sim_test.

The interaction of calling with the full program-path vs.
use of --sysroot exposes a consistency problem: when
--sysroot is used, argv[0] isn't the path by which the
program can find itself.  It's undecided whether argv[0] for
the program running in the simulator should be edited
(related to the naked argument to the simulator before
passing on to the simulated program) to remove a leading
--sysroot.  Either way, such a change would be out of scope
for this commit.

	* c/stat3.c (mybasename): New macro.  Use it instead of basename.
	* c/openpf1.c: Correct basename-related change and update related
	comment.
2022-02-14 23:53:13 +01:00
Hans-Peter Nilsson
81011383d9 sim: Add sim_dump_memory for debugging
Intended to be called from the debugger tool.

sim/common:
	* sim-memopt.c (sim_dump_memory): New function.
2022-02-14 23:51:15 +01:00
Hans-Peter Nilsson
dc4e1fde36 sim: Fix use of out-of-tree assembler and linker when testing
With commit 7a259895bb "sim: testsuite: expand arch specific
toolchain settings", trying to use out-of-tree ld and as at test-time
broke for the "primary target", like when testing a release-tarball.

Subsequent to that commit, all assembler tests without in-tree-built
tools FAIL, getting errors when trying to call
$(abs_builddir)/../gas/as-new.  But, that isn't the actual culprint;
it's actually it's its immediate predecessor, commit 8996c21067
"sim: testsuite: setup per-port toolchain settings for multitarget
build", which hardcodes in-tree-paths to those tools instead of
considering e.g. $(<X>_FOR_TARGET), the preferred overridable variable
for single-target builds, as set up by the toplevel Makefile.

This commit calls GCC_TARGET_TOOL (a deceptive name; gcc-specific
features aren't used) from toplev/config/acx.m4, somewhat like calls
in toplev/configure.ac but without the NCN_STRICT_CHECK_TARGET_TOOLS
step, for each X to find a value for $(<X>_FOR_TARGET).  N.B.: in-tree
tools still override any ${target}-${tool} found in $PATH, i.e. only
previously broken builds are affected.

The variables $(<X>_FOR_TARGET) are usually overridden by the toplevel
Makefile to the same value or better, but has to be set here too, as
automake "wants" Makefiles to be self-contained (you get an error
pointing out that the variable may be empty).  If it hadn't been for
that, SIM_AC_CHECK_TOOLCHAIN_FOR_PRIMARY_TARGET would not be needed.
This detail should only (positively) affect users invoking "make
check" in sim/ instead of "make check-sim" (or "make check") at the
toplevel.  Now the output from "configure" matches the target tools
actually used by sim at test-time, for the "primary target".

Using $(CC) for "example-" targets CC_FOR_TARGET is not changed, as
that appears to be a deliberate special-case.

Note that all tools still have to be installed and present in
$PATH at configure-time to be properly used at test-time.

sim:
	* m4/sim_ac_toolchain.m4 (SIM_AC_CHECK_TOOLCHAIN_FOR_PRIMARY_TARGET):
	New defun.
	(SIM_TOOLCHAIN_VARS): Call it using AC_REQUIRE, and use variables
	AS_FOR_TARGET, LD_FOR_TARGET and CC_FOR_TARGET instead of hard-coded
	values.
	* Makefile.in, configure: Regenerate.
2022-02-14 23:51:07 +01:00
Hans-Peter Nilsson
e7e980c6fa sim cris: Unbreak --disable-sim-hardware builds
With --disable-sim-hardware (--enable-sim-hardware=no),
whose default was changed to --enable-sim-hardware(=yes) in
commit 34cf511206, building for cris-elf fails as
sim_hw_parse then doesn't exist.

A cris-elf simulator configured for --enable-sim-hardware
(or the default after to the mentioned commit) runs about
2.5x slower than one configured --disable-sim-hardware.
A further 2-5% performance regression was not investigated.

When sim_hw_parse doesn't exist, --cris-900000xx can't be
supported.  The best action here is to remove it completely,
so its absence can be identified through --help, but
avoiding littering the code with "#if WITH_HW".

sim/cris:
	* sim-if.c (cris_options) [WITH_HW]: Conditionalize
	support of option --cris-900000xx.
	(sim_open) [WITH_HW]: Conditionalize sim_hw_parse
	call.
2022-02-14 23:51:02 +01:00
Hans-Peter Nilsson
6f62dbfb12 sim/testsuite/cris: As applicable, require simoption --cris-900000xx
Apply the new run_sim_test option "require" as in "#require
simoption --cris-900000xx" for all tests using that option.
This allows a clean test-suite-run for a build with
--disable-sim-hardware, where that option is not supported,
by skipping those tests as "untested".

sim/testsuite/cris:
	* asm/io1.ms, asm/io2.ms, asm/io3.ms, asm/io6.ms,
	asm/io7.ms: Call "#require: simoption --cris-900000xx".
2022-02-14 23:50:55 +01:00
Hans-Peter Nilsson
81064d7abc sim/testsuite: Support "requires: simoption <--name-of-option>"
Simulator features can be present or not, typically
depending on different-valued configure options, like
--enable-sim-hardware[=off|=on].  To avoid failures in
test-suite-runs when testing such configurations, a new
predicate is needed, as neither "target", "progos" nor
"mach" fits cleanly.

The immediate need was to check for presence of a simulator
option, but rather than a specialized "requires-simoption:"
predicate I thought I'd handle the general (parametrized)
need, so here's a generic predicate machinery and a (first)
predicate to use together with it; checking whether a
particular option is supported, by looking at "run --help"
output.  This was inspired by the check_effective_target_
machinery in the gcc test-suite.

Multiple "requires: <requirement> <parameter>" form a list of
predicates (with parameters), to be used as a conjunction.

sim/testsuite:
	* lib/sim-defs.exp (sim_check_requires_simoption): New function.
	(run_sim_test): Support "requires: <requirement> <parameter>".
2022-02-14 23:50:48 +01:00
Hans-Peter Nilsson
46f238477f sim/testsuite/cris/hw/rv-n-cris/irq1.ms: Disable due to randomness
For reasons that remain largely to be investigated (besides
the apparent lack of synchronization between two processes),
this test fails randomly, with two different sets of common
outputs.  Curiously, that doesn't happen for the other
similar tests.  There's a comment that mentions this, though
that doesn't make it a sustainable part of a test-suite.
(Known-blinking tests should be disabled until fixed.)

sim/testsuite/cris:
	* hw/rv-n-cris/irq1.ms: Disable by use of a never-matched
	"progos" value.
2022-02-14 23:50:42 +01:00
Hans-Peter Nilsson
56ba3848dc sim/testsuite/cris/c: Use -sim3 but only for newlib targets
Commit a39487c668 "sim: cris: use -sim with C tests for cris-elf
targets" caused " -sim" to be appended to CFLAGS_FOR_TARGET for
cris*-*-elf, where testing had until then relied on
"RUNTESTFLAGS=--target_board=cris-sim" being passed when running "make
check-sim", adding the right options.  While "-sim" happens to work,
the baseboard-file cris-sim.exp uses "-sim3" so for consistency use
that instead.

Then commit b42f20d2ac "sim: testsuite: drop most specific istarget
checks" caused " -sim" to be appended for *all* targets, which just
doesn't work.  For example, for crisv32-linux-gnu, that's not a
recognized option and will cause a dejagnu error and further testing
in c.exp will be aborted.

While cris-sim.exp appends "-static" for *-linux-gnu, further changes
in the test-suite have caused "linux"-specific tests to break, so that
part will be tended to separately.

But, save and restore CFLAGS_FOR_TARGET around the modification and
use where needed, to not have the CRIS-specific modification affect a
continuing test-run (possibly for other targets).

sim/testsuite/cris:
	* c/c.exp (CFLAGS_FOR_TARGET): Replace appended option " -sim"
	with " -sim3", but do it conditionally for newlib targets.  Save
	and restore CFLAGS_FOR_TARGET in saved_CFLAGS_FOR_TARGET such
	that it doesn't affect the value of CFLAGS_FOR_TARGET outside
	c.exp.
2022-02-14 23:50:36 +01:00
Hans-Peter Nilsson
3e6dc39ed7 sim/testsuite: Set global_cc_os also when no compiler is found
If we don't set this variable, it doesn't exist, and using "#progos:"
in an assembler-file will cause an error rather than just skipping the
test, viz:

Running /src/sim/testsuite/cris/hw/rv-n-cris/rvc.exp ...
ERROR: tcl error sourcing /src/sim/testsuite/cris/hw/rv-n-cris/rvc.exp.
ERROR: can't read "global_cc_os": no such variable
    while executing
"if { $opts(progos) != "" && $opts(progos) != $global_cc_os } {
	untested $subdir/$name
	return
    }"
    (procedure "run_sim_test" line 102)

Neither the commit introducing progos, nor the top comment
in run_sim_test, mentions progos as intended only for C
tests, or that its use must be gated on $global_cc_works !=
0, so (not) setting it in the no-working-compiler path seems
just overlooked.

Allowing it to be used for assembler tests makes it usable
for e.g. an always-false predicate and in expressions in
.exp files without gating on $global_cc_works != 0.

With this patch, global_cc_os is set to "", just as for "unknown OS".

    sim/testsuite:
	* lib/sim-defs.exp (sim_init_toolchain): Set global_cc_os also when
	no working target C compiler is found.
2022-02-14 23:50:29 +01:00
Hans-Peter Nilsson
3293b4f667 sim/testsuite/cris: Assembler testcase for PRIx32 usage bug
Several C test-cases exposed the bug, but let's have one for
people who test using just the assembler and linker.

	* asm/endmem1.ms: New test.
2022-02-14 23:50:24 +01:00
Hans-Peter Nilsson
9d67b0a097 sim cris: Correct PRIu32 to PRIx32
In 5ee0bc23a6 "sim: clean up bfd_vma printing" there was
an additional introduction of PRIx32 and PRIu32 but just in
sim/cris/sim-if.c.  One type of bug was fixed in commit
d16ce6e4d5 "sim: cris: fix memory setup typos" but one
remained; the PRIu32 usage is wrong, as hex output is
desired; note the 0x prefix.

Without this fix, you'll see output like:
 memory map 0:0x4000..0x5fff (8192 bytes) overlaps 0:0x0..0x16383 (91012 bytes)
 program stopped with signal 6 (Aborted).
for some C programs, like some of the ones in the sim/cris/c
testsuite from where the example is taken (freopen2.c).

The bug behavior was with memory allocation.  With an
attempt to allocate memory using the brk syscall such that
the room up to the next 8192-byte "page boundary" wasn't
sufficient, the simulator memory allocation machinery horked
on a consistency error when trying to allocate a memory
block to raise the "end of the data segment": there was
already memory allocated at that address.

Unfortunately, none of the programs in sim/cris/asm exposed
this bug at the time, but an assembler test-case is
committed after this fix.

sim/cris:
	* sim-if.c (sim_open): Correct PRIu32 to PRIx32.
2022-02-14 23:50:18 +01:00
Faraz Shahbazker
06c441ccef sim: mips: Add simulator support for mips32r6/mips64r6
2022-02-01  Ali Lown  <ali.lown@imgtec.com>
	    Andrew Bennett  <andrew.bennett@imgtec.com>
	    Dragan Mladjenovic  <dragan.mladjenovic@rt-rk.com>
	    Faraz Shahbazker  <fshahbazker@wavecomp.com>

sim/common/ChangeLog:
	* sim-bits.h (EXTEND9, EXTEND18 ,EXTEND19, EXTEND21,
	EXTEND26): New macros.

sim/mips/ChangeLog:
	* Makefile.in (IGEN_INCLUDE): Add mips3264r6.igen.
	* configure: Regenerate.
	* configure.ac: Support mipsisa32r6 and mipsisa64r6.
	(sim_engine_run): Pick simulator model from processor specified
	in e_flags.
	* cp1.c (value_fpr): Handle fmt_dc32.
	(fp_unary, fp_binary): Zero initialize locals.
	(update_fcsr, fp_classify, fp_rint, fp_r6_cmp, inner_fmac,
	fp_fmac, fp_min, fp_max, fp_mina, fp_maxa, fp_fmadd, fp_fmsub):
	New functions.
	(sim_fpu_class_mips_mapping): New.
	* cp1.h (fcsr_ABS2008_mask, fcsr_ABS2008_shift): New define.
	* interp.c (MIPSR6_P): New.
	(load_word): Allow unaligned memory access for MIPSR6.
	* micromips.igen (sc, scd): Adapt to new do_sc* helper signature.
	* mips.igen: Add *r6 models.
	(signal_if_cti, forbiddenslot32): New helpers.
	(delayslot32): Use signal_if_cti.
	(do_sc, do_scd); Add store_ll_bit parameter.
	(sc, scd): Adapt to previous change.
	(nal, beq, bal): New definitions for *r6.
	(sll): Split nop and ssnop cases into ...
	(nop, ssnop): New definitions.
	(loadstore_ea): Use the 32-bit compatibility adressing.
	(cache): Split logic into ...
	(do_cache): New helper.
	(check_fpu): Select IEEE 754-2008 mode for R6.
	(not_word_value, unpredictable, check_mt_hilo, check_mf_hilo,
	check_multi_hilo, check_div_hilo, check_u64, do_dmfc1b, add,
	li, addu, and, andi, bgez, bgtz, blez, bltz, bne, break, dadd,
	daddiu, daddu, dror, dror32, drorv, dsll, dsll32, dsllv, dsra,
	dsra32, dsrav, dsrl, dsrl32, dsub, dsubu, j, jal, jalr,
	jalr.hb, lb, lbu, ld, lh, lhu, lui, lw, lwu, nor, or, ori, ror,
	rorv, sb, sd, sh, sll, sllv, slt, slti, sltiu, sltu, sra, srav,
	srl, srlv, sub, subu, sw, sync, syscall, teq, tge, tgeu, tlt,
	tltu, tne, xor, xori, check_fmt_p, do_load_double,
	do_store_double, abs.FMT, add.FMT, ceil.l.FMT, ceil.w.FMT,
	cfc1, ctc1, cvt.d.FMT, cvt.l.FMT, cvt.w.FMT, div.FMT, dfmc1,
	dmtc1, floor.l.FMT, floor.w.FMT, ldc1, lwc1, mfc1, mov.FMT,
	mtc1, mul.FMT, recip.FMT, round.l.FMT, round.w.FMT, rsqrt.FMT,
	sdc1, sqrt.FMT, sub.FMT, swc1, trunc.l.FMT, trunc.w.FMT, bc0f,
	bc0fl, bc0t, bc0tl, dmfc0, dmtc0, eret, mfc0, mtc0, cop, tlbp,
	tlbr, tlbwi, tlbwr): Enable on *r6 models.
	* mips3264r2.igen (dext, dextm, dextu, di, dins, dinsm, dinsu,
	dsbh, dshd, ei, ext, mfhc1, mthc1, ins, seb, seh, synci, rdhwr,
	wsbh): Likewise.
	* mips3264r6.igen: New file.
	* sim-main.h (FP_formats): Add fmt_dc32.
	(FORBIDDEN_SLOT): New macros.
	(simFORBIDDENSLOT, FP_R6CMP_*, FP_R6CLASS_*): New defines.
	(fp_r6_cmp, fp_classify, fp_rint, fp_min, fp_max, fp_mina,
	fp_maxa, fp_fmadd, fp_fmsub): New declarations.
	(R6Compare, Classify, RoundToIntegralExact, Min, Max, MinA,
	MaxA, FusedMultiplyAdd, FusedMultiplySub): New macros. Wrapping
	previous declarations.

sim/testsuite/mips/ChangeLog:
	* basic.exp: Add r6-*.s tests.
	(run_r6_removed_test): New function.
	(run_endian_tests): New function.
	* hilo-hazard-3.s: Skip for mips*r6.
	* r2-fpu.s: New test.
	* r6-64.s: New test.
	* r6-branch.s: New test.
	* r6-forbidden.s: New test.
	* r6-fpu.s: New test.
	* r6-llsc-dp.s: New test.
	* r6-llsc-wp.s: New test.
	* r6-removed.csv: New test.
	* r6-removed.s: New test.
	* r6.s: New test.
	* utils-r6.inc: New inc.
2022-02-04 19:37:26 -05:00
Faraz Shahbazker
fc3c199fac sim: Add partial support for IEEE 754-2008
2022-02-01  Faraz Shahbazker  <fshahbazker@wavecomp.com>

sim/common/ChangeLog:
	* sim-fpu.c (sim_fpu_minmax_nan): New.
	(sim_fpu_max): Add variant behaviour for IEEE 754-2008.
	(sim_fpu_min): Likewise.
	(sim_fpu_is_un, sim_fpu_is_or): New.
	(sim_fpu_un, sim_fpu_or): New.
	(sim_fpu_is_ieee754_2008, sim_fpu_is_ieee754_1985): New.
	(sim_fpu_set_mode): New.
	(sim_fpu_classify): New.
	* sim-fpu.h (sim_fpu_minmax_nan): New declaration.
	(sim_fpu_un, sim_fpu_or): New declarations.
	(sim_fpu_is_un, sim_fpu_is_or): New declarations.
	(sim_fpu_mode): New enum.
	[sim_fpu_state](current_mode): New field.
	(sim_fpu_current_mode): New define.
	(sim_fpu_is_ieee754_2008): New declaration.
	(sim_fpu_is_ieee754_1985): New declaration.
	(sim_fpu_set_mode): New declaration.
	(sim_fpu_classify): New declaration.
2022-02-04 19:37:26 -05:00
Faraz Shahbazker
b6af5f3a74 sim: Factor out NaN handling in floating point operations
2022-02-01  Faraz Shahbazker  <fshahbazker@wavecomp.com>

sim/common/ChangeLog:
	* sim-fpu.c (sim_fpu_op_nan): New.
	(sim_fpu_add): Factor out NaN operand handling with
	a call to sim_fpu_op_nan.
	(sim_fpu_sub, sim_fpu_mul, sim_fpu_div): Likewise.
	(sim_fpu_rem, sim_fpu_max, sim_fpu_min): Likewise.
	* sim-fpu.h (sim_fpu_op_nan): New declaration.
2022-02-04 19:37:25 -05:00
Faraz Shahbazker
bf484e9348 sim: Allow toggling of quiet NaN-bit semantics
IEEE754-1985 specifies the top bit of the mantissa as an indicator
of signalling vs. quiet NaN, but does not define the precise semantics.
Most architectures treat this bit as indicating quiet NaN, but legacy
(pre-R6) MIPS goes the other way and treats it as signalling NaN.

This used to be controlled by a macro that was only defined for MIPS.
This patch replaces the macro with a variable to track the current
semantics of the NaN bit and allows differentiation between older
(pre-R6) and and newer MIPS cores.

2022-02-01  Faraz Shahbazker  <fshahbazker@wavecomp.com>

sim/common/ChangeLog:
	* sim-fpu.c (_sim_fpu): New.
	(pack_fpu, unpack_fpu): Allow reversal of quiet NaN semantics.
	* sim-fpu.h (sim_fpu_state): New struct.
	(_sim_fpu): New extern.
	(sim_fpu_quiet_nan_inverted): New define.

sim/mips/ChangeLog:
	* cp1.h (fcsr_NAN2008_mask, fcsr_NAN2008_shift): New.
	* mips.igen (check_fpu): Select default quiet NaN mode
	for legacy MIPS.
	* sim-main.h (SIM_QUIET_NAN_NEGATED): Remove.
2022-02-04 19:37:25 -05:00
Mike Frysinger
95e40d770e sim: ppc: migrate to standard uintXX_t types
Drop the sim-specific unsignedXX types and move to the standard uintXX_t
types that C11 provides.
2022-01-06 01:17:39 -05:00
Mike Frysinger
e4c803f5bb sim: common: migrate to standard uintXX_t types
Drop the sim-specific unsignedXX types and move to the standard uintXX_t
types that C11 provides.
2022-01-06 01:17:39 -05:00
Mike Frysinger
9850d2d83e sim: igen: migrate to standard uintXX_t types
Move off the custom local 64-bit types and to the standard uintXX_t
types that C11 provides.
2022-01-06 01:17:38 -05:00
Mike Frysinger
b331e677d7 sim: mips: migrate to standard uintXX_t types
Move off the sim-specific unsignedXX types and to the standard uintXX_t
types that C11 provides.
2022-01-06 01:17:38 -05:00
Mike Frysinger
2875d098a5 sim: cris: migrate to standard uintXX_t types
Move off the sim-specific unsignedXX types and to the standard uintXX_t
types that C11 provides.
2022-01-06 01:17:38 -05:00
Mike Frysinger
1e1e987aed sim: iq2000: migrate to standard uintXX_t types
Move off the sim-specific unsignedXX types and to the standard uintXX_t
types that C11 provides.
2022-01-06 01:17:38 -05:00
Mike Frysinger
c50b7c1b74 sim: synacor: migrate to standard uintXX_t types
Move off the sim-specific unsignedXX types and to the standard uintXX_t
types that C11 provides.
2022-01-06 01:17:38 -05:00
Mike Frysinger
868b6a9d3b sim: msp430: migrate to standard uintXX_t types
Move off the sim-specific unsignedXX types and to the standard uintXX_t
types that C11 provides.
2022-01-06 01:17:38 -05:00
Mike Frysinger
5a33ead2d3 sim: riscv: migrate to standard uintXX_t types
Move off the sim-specific unsignedXX types and to the standard uintXX_t
types that C11 provides.
2022-01-06 01:17:38 -05:00
Mike Frysinger
4650ee9378 sim: bfin: migrate to standard uintXX_t types
Move off the sim-specific unsignedXX types and to the standard uintXX_t
types that C11 provides.
2022-01-06 01:17:38 -05:00
Mike Frysinger
39a5fdbc65 sim: testsuite: migrate to standard uintXX_t types
This old code setup its own uintXX types, but since we require C11
now, we can assume the standard uintXX_t types exist and use them.
2022-01-06 01:17:38 -05:00
Mike Frysinger
4a92dedc59 sim: erc32: migrate to standard uintXX_t types
This old port setup its own uintXX types, but since we require C11
now, we can assume the standard uintXX_t types exist and use them.
2022-01-06 01:17:38 -05:00
Mike Frysinger
74ccc97820 sim: mn10300: migrate to standard uintXX_t types
This old port setup its own uintXX types, but since we require C11
now, we can assume the standard uintXX_t types exist and use them.
2022-01-06 01:17:37 -05:00
Mike Frysinger
436c3d9d7b sim: v850: migrate to standard uintXX_t types
This old port setup its own uintXX types, but since we require C11
now, we can assume the standard uintXX_t types exist and use them.
2022-01-06 01:17:37 -05:00
Mike Frysinger
7606e1a390 sim: m68hc11: migrate to standard uintXX_t types
This old port setup its own uintXX types, but since we require C11
now, we can assume the standard uintXX_t types exist and use them.

Also migrate off the sim-specific unsignedXX types.
2022-01-06 01:17:37 -05:00
Mike Frysinger
eae126cb7e sim: d10v: migrate to standard uintXX_t types
This old port setup its own uintXX types, but since we require C11
now, we can assume the standard uintXX_t types exist and use them.

Also migrate off the sim-specific unsignedXX types.
2022-01-06 01:17:37 -05:00
Mike Frysinger
32267d593a sim: cr16: migrate to standard uintXX_t types
This old port setup its own uintXX types, but since we require C11
now, we can assume the standard uintXX_t types exist and use them.

Also migrate off the sim-specific unsignedXX types.
2022-01-06 01:17:37 -05:00
Mike Frysinger
03b46de590 sim: ppc: drop natural types
These are almost entirely unused.  For the very few places using them,
replace with explicit signed types.  This matches what was done in the
common sim code.
2022-01-01 13:31:34 -05:00