1. 16 Jan, 2019 1 commit
    • Pavel I. Kryukov's avatar
      Do not expand macros to 'defined' · 7516c26f
      Pavel I. Kryukov authored
      Expanding a macro which contains 'defined' PP keyword is UB.  It causes
      a compilation failure when -Wexpansion-to-defined is used.
      2019-01-16  Pavel I. Kryukov  <kryukov@frtk.ru>
      	* sim-arange.c: eliminate DEFINE_NON_INLINE_P
  2. 15 Jan, 2019 1 commit
    • Simon Marchi's avatar
      sim: Fix definition of SIM_ARANGE_INLINE · dc7e8184
      Simon Marchi authored
      If HAVE_INLINE is false, SIM_ARANGE_INLINE is currently defined as
          #define SIM_ARANGE_INLINE EXTERN
      However, EXTERN is not defined anywhere, leading to errors such as:
          In file included from
                           from /mipt-mips/simulator/export/gdb/sim-main.h:13,
                           from /mipt-mips/simulator/export/gdb/gdb_interface.cpp:7:
          /mipt-mips/simulator/../../sim/common/sim-arange.h:71:27: error: ‘EXTERN’
          does not name a type; did you mean ‘EUSERS’?
           #define SIM_ARANGE_INLINE EXTERN
          /mipt-mips/simulator/../../sim/common/sim-arange.h:76:1: note: in expansion
          of macro ‘SIM_ARANGE_INLINE’
           SIM_ARANGE_INLINE int
      I (Simon) have reproduced the problem by simply removing the HAVE_INLINE
      definition.  This was originally reported by Pavel I. Kryukov
      	* sim-arange.h (SIM_ARANGE_INLINE): Change EXTERN to extern.
  3. 18 Dec, 2018 1 commit
    • Andrew Burgess's avatar
      sim: Don't overwrite stored errno in sim_syscall_multi · c5ebe0ff
      Andrew Burgess authored
      The host syscall callback mechanism should take care of updating the
      errcode within the CB_SYSCALL struct, and we should not be adjusting
      the error code once the syscall has completed.  We especially, should
      not be rewriting the syscall errcode based on the value of errno some
      time after running the host syscall, as there is no guarantee that
      errno has not be overwritten.
      To perform a syscall we call cb_syscall (in syscall.c).  To return
      from cb_syscall control passes through one of two exit paths these are
      labeled FinishSyscall and ErrorFinish and are reached using goto
      statements scattered throughout the cb_syscall function.
      In FinishSyscall we store the syscall result in 'sc->result', and the
      error code is transated to target encoding, and stored in
      In ErrorFinish, we again store the syscall result in 'sc->result', and
      fill in 'sc->errcode' by fetching the actual errno from the host with
      the 'cb->get_errno' callback.
      In both cases 'sc->errcode' will have been filled in with an
      appropriate value.
      Further, if we look at a specific syscall example, CB_SYS_open, in
      this case the first thing we do is fetch the path to open from the
      target with 'get_path', if this fails then the errcode is returned,
      and we jump to FinishSyscall.  Notice that in this case, no host
      syscall may have been performed, for example a failure to read the
      path to open out of simulated memory can return EINVAL without
      performing any host syscall.  Given that no host syscall has been
      performed, reading the host errno makes absolutely no sense.
      This commit removes from sim_syscall_multi the rewriting of
      sc->errcode based on the value of errno, and instead relies on the
      value stored in the cb_syscall.
      	* sim-syscall.c (sim_syscall_multi): Don't update sc->errcode at
      	this point, it should have already been set in cb_syscall.
  4. 05 Oct, 2018 1 commit
    • Richard Henderson's avatar
      or1k: Add the l.muld, l.muldu, l.macu, l.msbu insns · 07f5f4c6
      Richard Henderson authored
      Also fix the incorrect definitions of multiply and divide carry and
      overflow float.
      Changes to the instructions are made in the .cpu file, then we
      regenerate the binutils and sim files.
      The changes also required a few fixups for tests and additional sim helpers.
      yyyy-mm-dd  Richard Henderson  <rth@twiddle.net>
      	    Stafford Horne  <shorne@gmail.com>
      	* or1korbis.cpu (insn-opcode-mac): Add opcodes for MACU and MSBU.
      	(insn-opcode-alu-regreg): Add opcodes for MULD and MULDU.
      	(l-mul): Fix overflow support and indentation.
      	(l-mulu): Fix overflow support and indentation.
      	(l-muld, l-muldu, l-msbu, l-macu): New instructions.
      	(l-div); Remove incorrect carry behavior.
      	(l-divu): Fix carry and overflow behavior.
      	(l-mac): Add overflow support.
      	(l-msb, l-msbu): Add carry and overflow support.
      yyyy-mm-dd  Richard Henderson  <rth@twiddle.net>
      	    Stafford Horne  <shorne@gmail.com>
      	* or1k-desc.c: Regenerate.
      	* or1k-desc.h: Regenerate.
      	* or1k-opc.c: Regenerate.
      	* or1k-opc.h: Regenerate.
      	* or1k-opinst.c: Regenerate.
      yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>
      	* cgen-ops.h (ADDCFDI): New function, add carry flag DI variant.
      	(ADDOFDI): New function, add overflow flag DI variant.
      	(SUBCFDI): New function, subtract carry flag DI variant.
      	(SUBOFDI): New function, subtract overflow flag DI variant.
      yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>
      	* or1k/cpu.h: Regenerate.
      	* or1k/decode.c: Regenerate.
      	* or1k/decode.h: Regenerate.
      	* or1k/model.c: Regenerate.
      	* or1k/sem-switch.c: Regenerate.
      	* or1k/sem.c: Regenerate:
      yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>
      	* div.S: Fix tests to match correct overflow/carry semantics.
      	* mul.S: Likewise.
      yyyy-mm-dd  Stafford Horne  <shorne@gmail.com>
      	* testsuite/gas/or1k/allinsn.s: Add instruction tests for
      	l.muld, l.muldu, l.macu, l.msb, l.msbu.
      	* testsuite/gas/or1k/allinsn.d: Add test results for new
  5. 28 Sep, 2018 1 commit
    • Компан, Вячеслав Олегович's avatar
      Change "xor" name in cpu_core to allow building with iso646.h or C++ compiler · 2283a210
      This code was introduced back in 1998, and C99 appeared next year,
      defining the `xor` as an 'alternative keyword' if iso646.h is
      included. Moreover, C++98 defines it on the language level. As a
      result, the code is not buildable with C++ compiler or if iso646.h is
      included beforehand.
      According to comment, `sim_cpu_core` is mostly a clone of `sim_core`,
      so I renamed it to `byte_xor` as it's called in `sim_core`.
      	* sim-core.h (sim_cpu_core): Rename cpu_core.xor to
      	* sim-core.c (sim_core_set_xor): Likewise.
      	(sim_core_xor_read_buffer): Likewise.
      	(sim_core_xor_write_buffer): Likewise.
  6. 12 Dec, 2017 2 commits
    • Peter Gavin's avatar
      sim: cgen: add MUL2OFSI and MUL1OFSI functions (needed for OR1K l.mul[u]) · 58884b0e
      Peter Gavin authored
      2017-12-12  Peter Gavin  <pgavin@gmail.com>
      	    Stafford Horne  <shorne@gmail.com>
      	* cgen-ops.h (MUL2OFSI): New function, 2's complement overflow
      	(MUL1OFSI): New function, 1's complement overflow flag.
    • Peter Gavin's avatar
      sim: cgen: add remainder functions (needed for OR1K lf.rem.[sd]) · 07b95864
      Peter Gavin authored
      * sim/common/ChangeLog:
      2017-12-12  Peter Gavin  <pgavin@gmail.com>
      	    Stafford Horne <shorne@gmail.com>
      	* cgen-accfp.c (remsf, remdf): New function.
      	(cgen_init_accurate_fpu): Add remsf and remdf.
      	* cgen-fpu.h (cgen_fp_ops): Add remsf, remdf, remxf and remtf.
      	* sim-fpu.c (sim_fpu_rem): New function.
      	* sim-fpu.h (sim_fpu_status_invalid_irx): New enum.
      	(sim_fpu_rem): New function.
      	(sim_fpu_print_status): Add case for sim_fpu_status_invalid_irx.
  7. 06 Sep, 2017 1 commit
    • John Baldwin's avatar
      Honor an existing CC_FOR_BUILD in the environment for sim. · 5c887dd5
      John Baldwin authored
      This matches the equivalent bits in bfd/acinclude.m4
      	* configure.ac: Honor existing CC_FOR_BUILD in environment.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* acinclude.m4 (SIM_AC_COMMON) Honor existing CC_FOR_BUILD in
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
      	* configure: Regenerate.
  8. 24 May, 2017 1 commit
    • Yao Qi's avatar
      Refactor disassembler selection · 003ca0fd
      Yao Qi authored
      Nowadays, opcodes/disassemble.c:disassembler selects the proper
      disassembler according to ABFD only.  However, it actually
      selects disassemblers according to arch, mach, endianess, and
      abfd.  This patch adds them to the parameters of disassembler,
      so that its caller can still select disassemblers in case that
      abfd is NULL (a typical case in GDB).
      There isn't any functionality change.
      2017-05-24  Yao Qi  <yao.qi@linaro.org>
      	* objdump.c (disassemble_data): Caller update.
      2017-05-24  Yao Qi  <yao.qi@linaro.org>
      	* dis-asm.h (disassembler): Update declaration.
      2017-05-24  Yao Qi  <yao.qi@linaro.org>
      	* disassemble.c (disassembler): Add arguments a, big and mach.
      	Use them.
      2017-05-24  Yao Qi  <yao.qi@linaro.org>
      	* sim-trace.c (trace_disasm): Caller update.
  9. 15 Aug, 2016 1 commit
    • Mike Frysinger's avatar
      sim: unify symbol table handling · 5357150c
      Mike Frysinger authored
      The common sim tracing code already handles loading and tracking of
      symbols from the target program so that it can show symbol info in
      trace/disassembly calls.  Once we touch up the trace code and add a
      few API callbacks, ports don't need to do loading and searching of
      symbol tables themselves anymore.
  10. 14 Aug, 2016 1 commit
  11. 13 Aug, 2016 1 commit
  12. 04 Feb, 2016 1 commit
  13. 17 Jan, 2016 2 commits
    • Joel Brobecker's avatar
      Minor comment fixes in sim/common/sim-fpu.c. · f749ed60
      Joel Brobecker authored
      This patch makes a fair number of fixes in the various comments of
      sim-fpu.c, mostly to either better conform to the GNU Coding Standards
      (sentences start with a capital letter, end with a period), or to
      fix spelling mistakes.
              * sim-fpu.c: Minor comment fixes throughout.
    • Joel Brobecker's avatar
      minor reformatting in sim/common/sim-fpu.c. · 3c8e93b7
      Joel Brobecker authored
      This patch just makes a copy of formatting changes to better conform
      with the GNU Coding Style.
              * sim-fpu.c (print_bits): Minor reformatting (no code change).
              (sim_fpu_map): Likewise.
  14. 11 Jan, 2016 1 commit
  15. 10 Jan, 2016 8 commits
    • Mike Frysinger's avatar
      sim: move many common settings from CPPFLAGS to config.h · ce39bd38
      Mike Frysinger authored
      Rather than stuffing the command line with a bunch of -D flags, start
      moving things to config.h which is managed by autoheader.  This makes
      the makefile a bit simpler and the build output tighter, and it makes
      the migration to automake easier as there are fewer vars to juggle.
      We'll want to move the other options out too, but it'll take more work.
    • Mike Frysinger's avatar
      sim: drop unused SIM_AC_OPTION_PACKAGES · e19418e0
      Mike Frysinger authored
      This was imported from the ppc sim, but that was only used to control
      a single file, and that is already governed by the hw models.  There's
      no need to have a sep configure option here, especially since none of
      the other sims are using it.  Even when the code is enabled, there's
      no runtime overhead.
    • Mike Frysinger's avatar
      sim: allow the environment configure option everywhere · 16f7876d
      Mike Frysinger authored
      Currently ports have to call SIM_AC_OPTION_ENVIRONMENT explicitly in
      order to make the configure flag available.  There's no real reason
      to not allow this flag for all ports, so move it to the common sim
      macro.  This way we get standard behavior across all ports too.
    • Mike Frysinger's avatar
      sim: allow the assert configure option everywhere · 35656e95
      Mike Frysinger authored
      Currently ports have to call SIM_AC_OPTION_ASSERT explicitly in order
      to make the configure flag available, which none of them do.  There's
      no real reason to not allow this flag for all ports, so move it to the
      common sim macro.  This way we get standard behavior across all ports.
    • Mike Frysinger's avatar
      sim: drop targ-vals.def->nltvals.def indirection · 99d8e879
      Mike Frysinger authored
      We don't have alternative nltvals.def files, so always symlinking
      the targ-vals.def file to it doesn't gain us anything.  It does
      make the build more complicated though and a pain to convert to
      something newer (like automake).  Drop the symlinking entirely.
      In the future, we'll want to explode this file anyways into the
      respective arch dirs so things can be selected dynamically at
      runtime, so it's not like we'll be bringing this back.
    • Mike Frysinger's avatar
      sim: allow the inline configure option everywhere · 347fe5bb
      Mike Frysinger authored
      Currently ports have to call SIM_AC_OPTION_INLINE explicitly in order
      to make the configure flag available.  There's no real reason to not
      allow this flag for all ports, so move it to the common sim macro.
      This way we get standard behavior across all ports too.
    • Mike Frysinger's avatar
      sim: drop --enable-sim-{regparm,stdcall} options · 0dc73ef7
      Mike Frysinger authored
      These options were never exposed for most sims (just the ppc one),
      and they are really only useful on 32-bit x86 systems.  Considering
      modern systems tend to be 64-bit x86_64 and how well modern compilers
      are at optimizing code, these have outlived their usefulness.
    • Mike Frysinger's avatar
      sim: drop --enable-sim-cflags option · 22be3fbe
      Mike Frysinger authored
      No other sub directory provides such a configuration option, so
      drop it from the sim dir as well.  This cleans up a good bit of
      code in the process.
      If people want to use custom flags for just the sim, they can
      still run configure+make by hand in the sim subdir and use the
      normal CFLAGS settings.
  16. 09 Jan, 2016 1 commit
    • Mike Frysinger's avatar
      sim: drop common/cconfig.h in favor of a single config.h · 936df756
      Mike Frysinger authored
      The common subdir sets up a cconfig.h file to hold checks for the common
      code.  In practice, most files still end up using config.h instead which
      just leads to confusion.
      Merge all the configure checks that went into cconfig.h into SIM_AC_COMMON
      so we can drop the cconfig.h file altogether.  Now there is only a single
      config.h file like normal.
  17. 07 Jan, 2016 2 commits
  18. 05 Jan, 2016 3 commits
  19. 04 Jan, 2016 3 commits
    • Mike Frysinger's avatar
      sim: parse_args: polish getopt error message · 8d7d784e
      Mike Frysinger authored
      The cris sim hit a few failures after the recent getopt logic, and the
      expected output showed a few ways we can improve things to better match
      other utils.
    • Mike Frysinger's avatar
      sim: punt x86-specific bswap logic · 9bbf6f91
      Mike Frysinger authored
      The compiler/C library should produce reasonable code for htonl/ntohl,
      and at least glibc tries pretty hard to always produce good code for
      them.  This logic only had support for 32-bit x86 systems anymore, and
      it's unlikely people were even opting into this, so drop it all.
    • Mike Frysinger's avatar
      sim: parse_args: display getopt error ourselves · 77cf2ef5
      Mike Frysinger authored
      Fix a long standing todo where we let getopt write directly to stderr
      when an invalid option is passed.  Use the sim io funcs instead as they
      go through the filtered callbacks that gdb wants.
  20. 03 Jan, 2016 5 commits
    • Mike Frysinger's avatar
      sim: clean up some more device detritus · 61971b86
      Mike Frysinger authored
      Clean up some more remains of WITH_DEVICES that escaped notice.
      We also clean up GETTWI/SETTWI defines in a few ports where they
      were copied & pasted and are unused as they happen to be near the
      device code.
    • Mike Frysinger's avatar
      sim: use libiberty countargv in more places · 34fed699
      Mike Frysinger authored
      A bunch of places open code the countargv implementation, or outright
      duplicate it (as count_argc).  Replace all of those w/countargv.
    • Mike Frysinger's avatar
      sim: nrun: use lbasename · aba6f46b
      Mike Frysinger authored
    • Mike Frysinger's avatar
      sim: drop host endian configure option · 0cb8d851
      Mike Frysinger authored
      The --enable-sim-hostendian flag was purely so people had an escape route
      for when cross-compiling.  This is because historically, AC_C_BIGENDIAN
      did not work in those cases.  That was fixed a while ago though, so we can
      require that macro everywhere now and simplify a good bit of code.
    • Mike Frysinger's avatar
      sim: convert to bfd_endian · 1ac72f06
      Mike Frysinger authored
      Rather than re-invent endian defines, as well as maintain our own list
      of OS & arch-specific includes, punt all that logic in favor of the bfd
      ones already set up and maintained elsewhere.  We already rely on the
      bfd library, so leveraging the endian aspect should be fine.
  21. 02 Jan, 2016 1 commit
    • Mike Frysinger's avatar
      sim: delete dead current_state globals · d47f5b30
      Mike Frysinger authored
      The global current_state handle to the current simulator state is a
      design idea that was half implemented, but never really cleaned up.
      The point was to have a global variable pointing to the state so that
      funcs could more quickly & easily access the state anywhere.  We've
      instead moved in the direction of passing state around everywhere and
      don't have any intention of moving back.
      I also can't find any references to gdb using this variable, or to
      cgen related "dump_regs" functions, both of which were used in the
      comments related to this code.
  22. 30 Dec, 2015 1 commit