aboutsummaryrefslogtreecommitdiff
path: root/sim/ppc
AgeCommit message (Collapse)AuthorFilesLines
2021-07-06sim: ppc: add missing empty targetsDan Streetman1-0/+12
These are copied from sim/common/Make-common.in. On ppc the build fails without at least the 'info' target, e.g.: Making info in ppc make[4]: Entering directory '/<<BUILDDIR>>/gdb-10.2.2974.g5b45e89f56d+21.10.20210510155809/build/default/sim/ppc' make[4]: *** No rule to make target 'info'. Stop.
2021-07-01sim: unify reserved instruction bits settingsMike Frysinger5-40/+7
Move these options up to the common dir so we only test & export them once across all ports. The setting only affects igen based ports, and they were turning this on by default, so keep the default in place.
2021-06-30sim: ppc: unify (most) compiler warnings with common codeMike Frysinger3-5/+73
Copy most of the common build warning logic over from the common code to help keep code behavior a bit consistent, and turn them on by default. We disable a few flags for now until we can clean the code up.
2021-06-29sim: ppc: fix printf warningsMike Frysinger3-2/+16
This code hits some format-zero-length warnings, so hack the code like we did in the common layers.
2021-06-20sim: move sim-inline to the common codeMike Frysinger4-79/+7
This will allow us to build the common code with the same inline settings as the arch subdirs, and only do the test once.
2021-06-19sim: ppc: rename inline defines to match common codeMike Frysinger6-52/+64
Use the same basic names as the common sim inline logic so we can merge the two. We don't do that here, just prepare for it. The common code seems to be based on the ppc version but with slightly different names as it was cleaned up & generalized. I *think* these concepts are the same, so binding them together is OK, but maybe I'm misreading them. If so, can always tweak them later. REVEAL_MODULE -> H_REVEALS_MODULE INLINE_MODULE -> C_REVEALS_MODULE
2021-06-19sim: unify gettext/intl probing logicMike Frysinger5-99/+6
Move these options up to the common dir so we only test & export them once across all ports.
2021-06-19sim: unify toolchain probing logicMike Frysinger4-288/+20
Move these options up to the common dir so we only test & export them once across all ports.
2021-06-19sim: unify bfd library dependency testing logicMike Frysinger6-433/+245
Move these options up to the common dir so we only test & export them once across all ports.
2021-06-18sim: unify -Werror build settingsMike Frysinger4-48/+6
Move these options up to the common dir so we only test & export them once across all ports. It also enables -Werror usage on the common files we've been pulling out of arch subdirs.
2021-06-18sim: create a makefile fragment to pass common settings downMike Frysinger2-0/+7
As we merge settings from subdirs into the common configure, we sometimes need to keep the settings working in both dirs. Create a makefile fragment to pass them down so we don't have to run the checks twice. For now, the file is empty, but we'll start moving logic in shortly.
2021-06-18sim: split sim-signal.h include outMike Frysinger2-1/+4
The sim-basics.h is too big and includes too many things. This leads to some arch's sim-main.h having circular loop issues with defs, and makes it hard to separate out common objects from arch-specific defs. By splitting up sim-basics.h and killing off sim-main.h, it'll make it easier to separate out the two.
2021-06-17sim: overhaul & unify endian settings managementMike Frysinger4-46/+6
The m4 macro has 2 args: the "wire" settings (which represents the hardwired port behavior), and the default settings (which are used if nothing else is specified). If none are specified, the arch is expected to support both, and the value will be probed based on the user runtime options or the input program. Only two arches today set the default value (bpf & mips). We can probably let this go as it only shows up in one scenario: the sim is invoked, but with no inputs, and no user endian selection. This means bpf will not behave like the other arches: an error is shown and forces the user to make a choice. If an input program is used though, we'll still switch the default to that. This allows us to remove the WITH_DEFAULT_TARGET_BYTE_ORDER setting. For the ports that set a "wire" endian, move it to the runtime init of the respective sim_open calls. This allows us to change the WITH_TARGET_BYTE_ORDER to purely a user-selected configure setting if they want to force a specific endianness. With all the endian logic moved to runtime selection, we can move the configure call up to the common dir so we only process it once across all ports. The ppc arch was picking the wire endian based on the target used, but since we weren't doing that for other biendian arches, we can let this go too. We'll rely on the input selecting the endian, or make the user decide.
2021-06-17sim: ppc: avoid "PAGE_SIZE" nameMike Frysinger3-4/+9
This define is used for a particular target and depends on the simulated CPU hardware. It has no relation to the host CPU that the sim is running on. So rename the common "PAGE_SIZE" here to better reflect its usage and avoid conflicts with system headers.
2021-06-16sim: drop obsolete AC_EXEEXT callMike Frysinger3-5/+5
The current autoconf 2.69 defines this to nothing because the logic in AC_PROG_CC takes care of it all the time now. Delete the call.
2021-06-16sim: ppc: use common sim-assert settingMike Frysinger4-38/+5
The common sim code already sets this up for us, so no need to duplicate the logic.
2021-06-16sim: ppc: convert to bfd_endianMike Frysinger11-59/+75
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. This was done for all the other ports years ago, so catch ppc up.
2021-06-16sim: ppc: replace local __attribute__ fallbackMike Frysinger3-15/+7
The common ansidecl.h provides fallbacks for these so we don't need to.
2021-06-16sim: ppc: use common ATTRIBUTE_PRINTF macrosMike Frysinger6-5/+23
Use the common ansidecl.h macros to replace our ad-hoc printf attributes.
2021-06-16sim: ppc: use common ATTRIBUTE_PACKED macroMike Frysinger3-6/+12
Drop local packed attribute with the common ansidecl.h define.
2021-06-16sim: ppc: replace local NORETURN macros with common oneMike Frysinger4-6/+12
Drop local NORETURN macro with the common ansidecl.h ATTRIBUTE_NORETURN define.
2021-06-16sim: ppc: replace local UNUSED macros with common oneMike Frysinger5-96/+97
Drop local UNUSED macro with the common ansidecl.h ATTRIBUTE_UNUSED define.
2021-06-16sim: ppc: replace local CONCAT macros with common onesMike Frysinger6-16/+12
Drop local copies of CONCAT macros that the common ansidecl.h provides.
2021-06-16sim: ppc: change bool variable name to booleanMike Frysinger2-1/+5
This is a reserved type with stdbool.h.
2021-06-16sim: ppc: drop host endian configure optionMike Frysinger12-928/+474
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. This was done for all the other ports years ago, so catch ppc up.
2021-06-13sim: ppc: use common version.o tooMike Frysinger2-7/+10
The common version.o we're building can be used for the ppc subdir, so switch it over too.
2021-06-12sim: erc32/ppc: fix handling of $EXEEXTMike Frysinger2-3/+7
2021-06-12sim: overhaul alignment settings managementMike Frysinger4-36/+6
Currently, the sim-config module will abort if alignment settings haven't been specified by the port's configure.ac. This is a bit weird when we've allowed SIM_AC_OPTION_ALIGNMENT to seem like it's optional to use. Thus everyone invokes it. There are 4 alignment settings, but really only 2 matters: strict and nonstrict. The "mixed" setting is just the default ("unset"), and "forced" isn't used directly by anyone (it's available as a runtime option for some ports). The m4 macro has 2 args: the "wire" settings (which represents the hardwired port behavior), and the default settings (which are used if nothing else is specified). If none are specified, then the build won't work (see above as if SIM_AC_OPTION_ALIGNMENT wasn't called). If default settings are provided, then that is used, but we allow the user to override at runtime. Otherwise, the "wire" settings are used and user runtime options to change are ignored. Most ports specify a default, or set the "wire" to nonstrict. A few set "wire" to strict, but it's not clear that's necessary as it doesn't make the code behavior, by default, any different. It might make things a little faster, but we should provide the user the choice of the compromises to make: force a specific mode at compile time for faster runtime, or allow the choice at runtime. More likely it seems like an oversight when these ports were initially created, and/or copied & pasted from existing ports. With all that backstory, let's get to what this commit does. First kill off the idea of a compile-time default alignment and set it to nonstrict in the common code. For any ports that want strict alignment by default, that code is moved to sim_open while initializing the sim. That means WITH_DEFAULT_ALIGNMENT can be completely removed. Moving the default alignment to the runtime also allows removal of setting the "wire" settings at configure time. Which allows removing of all arguments to SIM_AC_OPTION_ALIGNMENT and moving that call to common code. The macro logic can be reworked to not pass WITH_ALIGNMENT as -D CPPFLAG and instead move it to config.h. All of these taken together mean we can hoist the macro up to the top level and share it among all sims so behavior is consistent among all the ports.
2021-06-12sim: unify bug & package settingsMike Frysinger5-75/+11
Move these options up to the common dir so we only test & export them once across all ports. The AC_INIT macro does a lot of the heavy lifting already which allows further simplification.
2021-06-12sim: unify debug/stdio/trace/profile build settingsMike Frysinger4-76/+19
Move these options up to the common dir so we only test & export them once across all ports. The ppc code needs a little extra care with its trace settings as it's not exactly the same API as the common code. The other knobs are the same though.
2021-06-12sim: ppc: unify header & function & type tests tooMike Frysinger4-1072/+7
Since ppc now shares a config.h with the top-level, move all of its relevant settings up a level. The ppc port tests a lot more funcs, but that's because its syscall emulation is a lot more complete. We'll probably utilize some of these in the common code too.
2021-06-12sim: ppc: unify env settings tooMike Frysinger6-45/+23
The ppc port doesn't share a lot of the common logic, but there are a few bits that bleed across. Have it use the common configure for environment settings too to avoid duplicate define errors after the recent unification with the other ports.
2021-06-09sim: cleanup obsolete NULL fallbackMike Frysinger6-20/+8
We require C11 which defines NULL, so drop the inconsistent set of fallback defines in the codebase.
2021-05-29sim: ppc: enable -Wno-format for mingw targetsMike Frysinger3-0/+13
This mirrors what we do for other builds already.
2021-05-29sim: ppc: avoid shadowing errnoMike Frysinger5-16/+16
If the OS headers define the "errno" symbol, it breaks some of these funcs that were using "int errno" itself. Rename local vars to "err" to avoid that, and delete the old "extern int errno".
2021-05-29sim: leverage gnulibMike Frysinger2-1/+5
We use getline, so leverage gnulib to provide fallback implementation.
2021-05-20sim: ppc: fix Wpointer-sign warningTom de Vries1-1/+1
When compiling with --enable-werror and CFLAGS="-O0 -g -Wall", we run into: ... src/sim/ppc/hw_memory.c: In function 'hw_memory_init_address': src/sim/ppc/hw_memory.c:194:75: error: pointer targets in passing \ argument 4 of 'device_find_integer_array_property' differ in signedness \ [-Werror=pointer-sign] int nr_cells = device_find_integer_array_property(me, "available", 0, &dummy); ^ ... Fix this by changing the type of dummy.
2021-05-19sim: ppc: fix some Wenum-compare warningsTom de Vries1-2/+2
When compiling with --enable-werror and CFLAGS="-O0 -g -Wall", we run into: ... src/sim/ppc/hw_phb.c: In function 'hw_phb_attach_address': src/sim/ppc/hw_phb.c:315:12: error: comparison between \ 'attach_type {aka enum _attach_type}' and \ 'enum <anonymous>' [-Werror=enum-compare] if (type != hw_phb_normal_decode ^~ ... Fix this by casting type to hw_phb_decode.
2021-05-19sim: ppc: fix Wnonnull warningTom de Vries1-2/+1
When compiling with --enable-werror and CFLAGS="-O0 -g -Wall", we run into: ... src/sim/ppc/emul_netbsd.c: In function 'do_gettimeofday': src/sim/ppc/emul_netbsd.c:770:16: error: null argument where non-null \ required (argument 1) [-Werror=nonnull] int status = gettimeofday((t_addr != 0 ? &t : NULL), ^~~~~~~~~~~~ ... Fix this by unconditionally passing &t as first argument.
2021-05-19sim: ppc: fix some more Wunused-function warningsTom de Vries1-2/+2
When compiling with --enable-werror and CFLAGS="-O0 -g -Wall", we run into: ... In file included from src/sim/ppc/cpu.h:26:0, from src/sim/ppc/mon.c:25, from src/sim/ppc/inline.c:64, from idecode.c:26: src/sim/ppc/device.h:788:8: error: 'device_event_queue_deschedule' \ declared 'static' but never defined [-Werror=unused-function] (void) device_event_queue_deschedule ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... This seems to be caused by the fact that the function is declared using INLINE_EVENT instead of INLINE_DEVICE. Fix this and a similar error in the same file.
2021-05-19sim: ppc: fix some Wunused-function warningsTom de Vries1-84/+84
When compiling with --enable-werror and CFLAGS="-O0 -g -Wall", we run into: ... In file included from src/sim/ppc/cpu.h:251:0, from src/sim/ppc/emul_generic.h:24, from src/sim/ppc/emul_generic.c:24: src/sim/ppc/cpu.c:76:1: error: 'cpu_create' defined but not used \ [-Werror=unused-function] cpu_create(psim *system, ^~~~~~~~~~ ... The function is defined as: ... INLINE_CPU\ (cpu *) cpu_create(psim *system, ... which expands to: ... static cpu * __attribute__((__unused__)) cpu_create(psim *system, ... The problem is that gcc does not associate the attribute to the function. I've filed a PR about this ( PR gcc/100670 ), which may or may not be valid. Work around/fix this by modifying the INLINE_* definitions in inline.h to move UNUSED to the start such that we have: ... __attribute__((__unused__)) static cpu * cpu_create(psim *system, ...
2021-05-16sim: switch config.h usage to defs.hMike Frysinger9-9/+50
The defs.h header will take care of including the various config.h headers. For now, it's just config.h, but we'll add more when we integrate gnulib in. This header should be used instead of config.h, and should be the first include in every .c file. We won't rely on the old behavior where we expected files to include the port's sim-main.h which then includes the common sim-basics.h which then includes config.h. We have a ton of code that includes things before sim-main.h, and it sometimes needs to be that way. Creating a dedicated header avoids the ordering mess and implicit inclusion that shows up otherwise.
2021-05-15sim: ppc: clean up various warningsMike Frysinger22-54/+122
A random grab bag of minor fixes to enable -Werror for this port. Cast address vars to long when the format was using %l. Use %zu with sizeof operations. Add const to a bunch of strings. Trim unused variables. Fix sizeof call to calculate target storage and not the pointer itself.
2021-05-14sim: create header namespaceMike Frysinger6-9/+17
The gdb/callback.h & gdb/remote-sim.h headers have nothing to do with gdb and are really definitions for the libsim API under the sim/ tree. While gdb uses those headers as a client, it's not specific to it. So create a new sim/ namespace and move the headers there.
2021-04-22Do not check for sys/time.h or sys/times.hTom Tromey3-9/+7
This updates the sim so that it unconditionally uses sys/time.h. This is in agreement with existing code, and a recent change to BFD. I also think that sys/times.h is never needed by the sim, so this patch removes the check and the one spot that was conditionally including it. sim/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * m4/sim_ac_common.m4 (SIM_AC_COMMON): Don't check for sys/time.h or sys/times.h. sim/aarch64/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/arm/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/avr/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/bfin/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/bpf/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/common/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * sim-utils.c: Update includes. sim/cr16/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * simops.c: Update includes. * configure, config.in: Rebuild. sim/cris/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * rvdummy.c: Update includes. * dv-rv.c: Update includes. * configure, config.in: Rebuild. sim/d10v/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/erc32/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/example-synacor/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/frv/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/ft32/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/h8300/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/iq2000/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/lm32/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/m32c/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/m32r/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/m68hc11/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/mcore/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/microblaze/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/mips/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/mn10300/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/moxie/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/msp430/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/or1k/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/ppc/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * mon.c: Update includes. * emul_unix.c: Update includes. (do_unix_gettimeofday): Update condition. sim/pru/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/riscv/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/rl78/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/rx/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild. sim/sh/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * interp.c: Update includes. * configure, config.in: Rebuild. sim/v850/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * configure, config.in: Rebuild.
2021-04-22Add stamp files for generated files in sim/ppcTom Tromey2-2/+13
This changes the sim/ppc Makefile to use the stamp file idiom for a couple of generated files, avoiding extra rebuilds. sim/ppc/ChangeLog 2021-04-22 Tom Tromey <tom@tromey.com> * Makefile.in (stamp-vals, stamp-map): New targets. (targ-vals.h, targ-map.c): Update. (clean): Remove files.
2021-04-08Add system includes in simTom Tromey2-0/+5
This updates various parts of the sim to include missing system headers. I made the includes unconditional, because other parts of the tree are already doing this. 2021-04-08 Tom Tromey <tom@tromey.com> * traps.c: Include stdlib.h. * cris-tmpl.c: Include stdlib.h. sim/erc32/ChangeLog 2021-04-08 Tom Tromey <tom@tromey.com> * func.c: Include sys/time.h. sim/frv/ChangeLog 2021-04-08 Tom Tromey <tom@tromey.com> * traps.c: Include stdlib.h. * registers.c: Include stdlib.h. * profile.c: Include stdlib.h. * memory.c: Include stdlib.h. * interrupts.c: Include stdlib.h. * frv.c: Include stdlib.h. * cache.c: Include stdlib.h. sim/iq2000/ChangeLog 2021-04-08 Tom Tromey <tom@tromey.com> * iq2000.c: Include stdlib.h. sim/m32r/ChangeLog 2021-04-08 Tom Tromey <tom@tromey.com> * traps.c: Include stdlib.h. * m32r.c: Include stdlib.h. sim/ppc/ChangeLog 2021-04-08 Tom Tromey <tom@tromey.com> * emul_unix.c: Include time.h.
2021-04-08sim: set ASAN_OPTIONS=detect_leaks=0 when running igen and opc2cSimon Marchi2-2/+12
The igen/dgen and opc2c tools leak their heap-allocated memory (on purpose) at program exit, which makes AddressSanitizer fail the tool execution. This breaks the build, as it makes the tool return a non-zero exit code. Fix that by disabling leak detection through the setting of that environment variable. I also changed the opc2c rules for m32c to go through a temporary file. What happened is that the failing opc2c would produce an incomplete file (probably because ASan exits the process before stdout is flushed). This meant that further make attempts didn't try to re-create the file, as it already existed. A "clean" was therefore necessary. This can also happen in regular builds if the user interrupts the build (^C) in the middle of the opc2c execution and tries to resume it. Going to a temporary file avoids this issue. sim/m32c/ChangeLog: * Makefile.in: Set ASAN_OPTIONS when running opc2c. sim/mips/ChangeLog: * Makefile.in: Set ASAN_OPTIONS when running igen. sim/mn10300/ChangeLog: * Makefile.in: Set ASAN_OPTIONS when running igen. sim/ppc/ChangeLog: * Makefile.in: Set ASAN_OPTIONS when running igen. sim/v850/ChangeLog: * Makefile.in: Set ASAN_OPTIONS when running igen. Change-Id: I00f21d4dc1aff0ef73471925d41ce7c23e83e082
2021-04-03sim: add preliminary support for --enable-targetsMike Frysinger2-0/+9
This doesn't actually create one `run` program like other projects, but creates multiple `run-$arch` targets. While it might not seem that useful initially, this has some nice properties: - Allows us to quickly build all sim targets in a single tree. - Positions us better for converting targets over to a proper multitarget build+install. We don't have the ability to actually run tests against them, but that's due to a limitation in gas: it doesn't support multitarget. If that ever changes, we should be able to turn on our tests too. We can improve the test framework to fallback to a system toolchain if available to help mitigate that.
2021-03-13sim: rename BUILD_LDFLAGS to LDFLAGS_FOR_BUILDMike Frysinger2-2/+8
The rest of the binutils tree renamed this variable many years ago.