aboutsummaryrefslogtreecommitdiff
path: root/sim/ppc
AgeCommit message (Collapse)AuthorFilesLines
2022-11-11sim: ppc: rename ppc-instructions to powerpc.igenMike Frysinger4-6/+6
To make it clear this is an input to the igen tool, rename it with an igen extension. This matches the other files in the ppc dir (altivec & e500 igen files), and the other igen ports (mips, mn10300, v850).
2022-11-10sim: ppc: drop old makefile fragmentMike Frysinger1-3/+0
Support for these files was dropped almost 30 years ago, but the ppc arch was missed. Clean that up now too.
2022-11-10sim: ppc: drop support for dgen -L optionMike Frysinger1-5/+1
Nothing passes this to dgen, and even if it did, nothing would happen because the generated spreg.[ch] files don't include any references back to the original data table. So drop it to simplify.
2022-11-10sim: ppc: collapse is_readonly & length switch tables heavilyMike Frysinger1-7/+15
Since we know we'll return 0 by default, we don't have to output case statements for readonly or length fields whose values are also zero. This is the most common case by far and thus generates a much smaller switch table in the end.
2022-11-10sim: ppc: collapse is_valid switch table moreMike Frysinger1-1/+4
Instead of writing: case 1: return 1; case 2: return 1; ...etc... Output a single return so we get: case 1: case 2: case ... return 1; This saves ~100 lines of code. Hopefully the compiler was already smart enough to optimize to the same code, but if not, this probably helps there too :).
2022-11-10sim: ppc: pull default switch return outMike Frysinger1-2/+1
This saves a single line for the same result. By itself, it's not interesting, but we can further optimize the generated output and completely omit the switch table in some cases. Which we'll do in follow up commits.
2022-11-10sim: ppc: constify spreg tableMike Frysinger1-2/+2
This internal table is only ever read, so constify it.
2022-11-10sim: ppc: drop obsolete USE_WIN32API checkMike Frysinger4-27/+0
This controls only one thing: how to call mkdir(). The gnulib code already has a mkdir module that provides this exact logic for us, so punt the code entirely.
2022-11-09sim: ppc: add missing parens with e500 macroMike Frysinger1-16/+16
This macro expansion was missing a set of outer-most parenthesis which some compilers would complain about depending on how the macro is used. This is just standard good macro hygiene too.
2022-11-09sim: ppc: drop useless linking of helper toolsMike Frysinger1-1/+1
We've never run these helper programs directly. The igen program includes the relevant source files directly and runs the code that way. So stop wasting developer CPU time linking programs that are never run. We leave the rules in place for people who need to test and debug the specific bits of code every now & then.
2022-11-06sim: build: respect AM_MAKEFLAGS when entering subdirsMike Frysinger1-1/+1
This doesn't matter right now, but it will as we add more flags to the recursive make step to pass state down.
2022-11-05sim: run: move linking into top-levelMike Frysinger2-14/+17
Automake will run each subdir individually before moving on to the next one. This means that the linking phase, a single threaded process, will not run in parallel with anything else. When we have to link ~32 ports, that's 32 link steps that don't take advantage of parallel systems. On my really old 4-core system, this cuts a multi-target build from ~60 sec to ~30 sec. We eventually want to move all compile+link steps to this common dir anyways, so might as well move linking now for a nice speedup. We use noinst_PROGRAMS instead of bin_PROGRAMS because we're taking care of the install ourselves rather than letting automake process it.
2022-11-05sim: build: add uninstall supportMike Frysinger1-0/+1
This never worked before, but adding it to the common top-level dir is pretty easy to do now that we're unified.
2022-11-05sim: build: move install steps to the top-levelMike Frysinger1-14/+1
We still have to maintain custom install rules due to how we rename arch-specific files with an arch prefix in their name, but we can at least unify the logic in the common dir.
2022-11-05sim: ppc: drop unused /dev/zero logicMike Frysinger4-84/+1
Nothing in the tree checks this option, or has checked for decades. The pre-cvs-import ChangeLog suggests this was added & removed back then, but can't be sure as that history doesn't exist in the VCS.
2022-11-05sim: ppc: delete unused host bitsize settingsMike Frysinger4-32/+2
Nothing checks this define anywhere, so drop all the logic. We don't want this to be a configure option in the first place as all such usage should be automatic & following proper types.
2022-11-05sim: ppc: inline the sim-packages optionMike Frysinger4-63/+12
This has only ever had a single option that's enabled by default. The objects it adds are pretty small and don't add overhead at runtime if it isn't used, so just enable it all the time to make the build code simpler.
2022-11-04sim: build: switch to bfd & opcodes libtool linker scriptsMike Frysinger1-5/+4
Now that we use libtool to link, we don't need to duplicate all the libs that bfd itself uses. This simplifies the configure & Makefile.
2022-11-04sim: build: switch to libtool for linkingMike Frysinger1-1/+2
The top-level already sets up a libtool script for the host, so use that when linking rather than invoking CC directly. This will also happen when we (someday) move the building to pure automake.
2022-11-03sim: ppc: include copyright & license in --versionMike Frysinger1-0/+5
This makes it match the other sim run programs and GNU tools.
2022-11-03sim: ppc: drop use of DATE & TIMEMike Frysinger1-6/+0
No other tool does this, sim or otherwise, and it makes the ppc build non-reproducible. Drop it to simplify & make reproducible.
2022-11-03sim: move common flags to default AM_CPPFLAGSMike Frysinger1-1/+1
Since all host files we compile use these settings, move them out of libcommon.a and into the default AM_CPPFLAGS. This has the effect of dropping the custom per-target automake rules. Currently it saves us ~150 lines, but since it's about ~8 lines per object, the overhead will increase quite a bit as we merge more files into a single build. This also changes the object output names, so we have to tweak the rules that were pulling in the common objects when linking.
2022-11-02sim: common: change sim_{fetch,store}_register helpers to use void* buffersMike Frysinger1-3/+2
When reading/writing arbitrary data to the system's memory, the unsigned char pointer type doesn't make that much sense. Switch it to void so we align a bit with standard C library read/write functions, and to avoid having to sprinkle casts everywhere.
2022-10-31sim: reg: constify store helperMike Frysinger1-1/+2
These functions only read from memory, so mark the pointer as const.
2022-10-31sim: common: change sim_read & sim_write to use void* buffersMike Frysinger1-2/+2
When reading/writing arbitrary data to the system's memory, the unsigned char pointer type doesn't make that much sense. Switch it to void so we align a bit with standard C library read/write functions, and to avoid having to sprinkle casts everywhere.
2022-10-29sim, sim/{m32c,ppc,rl78}: Use getopt_longTsukasa OI2-5/+10
Because of a Libiberty hack, getopt on GNU libc (2.25 or earlier) is currently unusable on sim, causing a regression on CentOS 7. This is caused as follows: 1. If HAVE_DECL_GETOPT is defined (getopt declaration with known prototype is detected while configuration), a declaration of getopt in "include/getopt.h" is suppressed. The author started to define HAVE_DECL_GETOPT in sim with the commit 340aa4f6872c ("sim: Check known getopt definition existence"). 2. GNU libc (2.25 or earlier)'s <unistd.h> includes <getopt.h> with a special purpose macro defined to declare only getopt function but due to include path (not tested while configuration), it causes <unistd.h> to include Libiberty's "include/getopt.h". 3. If both 1. and 2. are satisfied, despite that <unistd.h> tries to declare getopt by including <getopt.h>, "include/getopt.h" does not do so, causing getopt function undeclared. Getting rid of "include/getopt.h" (e.g. renaming this header file) is the best solution to avoid hacking but as a short-term solution, this commit replaces getopt with getopt_long under sim/.
2022-10-24sim/ppc: fix for operator precedence warning from clangAndrew Burgess1-1/+1
In the ppc simulator, clang was warning about some code like this: busy_ptr->nr_writebacks = 1 + (PPC_ONE_BIT_SET_P(out_vmask)) ? 1 : 2; The warning was: operator '?:' has lower precedence than '+'; '+' will be evaluated first I suspect that this is not the original authors intention. PPC_ONE_BIT_SET_P is going to be 0 or 1, so if we evaluate the '+' first, the condition will always be non-zero, so true. The whole expression could then be simplified to just '1', which doesn't make much sense. I suspect the answer the author was expecting was either 2 or 3. Why they didn't just write: busy_ptr->nr_writebacks = (PPC_ONE_BIT_SET_P(out_vmask)) ? 2 : 3; I have no clue, however, to keep the structure of the code unchanged, I've updated things to: busy_ptr->nr_writebacks = 1 + (PPC_ONE_BIT_SET_P (out_vmask) ? 1 : 2); which silences the warning from clang, and is, I am guessing, what the original author intended.
2022-10-24sim/ppc: initialize a memory buffer in all casesAndrew Burgess1-1/+1
In the ppc simulator's do_fstat function, which provides the fstat call for the simulator, if the fstat is going to fail then we currently write an uninitialized buffer into the simulated target. In theory, I think this is fine, we also write the error status into the simulated target, so, given that the fstat has failed, the target shouldn't be relying on the buffer contents. However, writing an uninitialized buffer means we might leak simulator private data into the simulated target, which is probably a bad thing. Plus it probably makes life easier if something consistent, like all zeros, is written rather than random junk, which might look like a successful call (except for the error code). So, in this commit, I initialize the stat buffer to zero before it is potentially used. If the stat call is not made then the buffer will be left initialized as all zeros.
2022-10-24sim/ppc: don't try to print an uninitialized variableAndrew Burgess1-2/+3
The ppc simulator, in sim_create_inferior, tries to print the function local entry_point variable before the variable is initialized. In this commit, I defer the debug print line until the variable has been initialized.
2022-10-23sim: mips/ppc/riscv: re-add AC_CANONICAL_SYSTEM [PR sim/29439]Mike Frysinger2-0/+133
These configure scripts check $target and change behavior. They shouldn't be doing that, but until we can rework the sim to change behavior based on the input ELF, restore AC_CANONICAL_SYSTEM to these so that $target is correctly populated. This was lost in the d3562f83a7b8a1ae6e333cd5561419d3da18fcb4 ("sim: unify toolchain probing logic") refactor as the logic was hoisted up to the common code. But the fact the vars weren't passed down to the sub-configure scripts was missed. Bug: https://sourceware.org/PR29439
2022-10-19sim/ppc: mark device_error function as ATTRIBUTE_NORETURNAndrew Burgess1-1/+1
The device_error function always ends up calling the error function, which is itself marked as ATTRIBUTE_NORETURN, so it makes sense that device_error should also be marked ATTRIBUTE_NORETURN. Doing this resolves a few warnings from hw_ide.c about possibly uninitialized variables - the variables are only uninitialized after passing through a call to device_error, which obviously means the variables are never really used uninitialized, the simulation will terminate with the device_error call.
2022-10-19sim/ppc: fix warnings related to printf format stringsAndrew Burgess4-30/+19
This commit is a follow on to: commit 182421c9d2eea8c4877d983a2124e591f0aca710 Date: Tue Oct 11 15:02:08 2022 +0100 sim/ppc: fixes for arguments to printf style functions where commit 182421c9d2ee addressed issues with printf format arguments that were causing the compiler to give an error, this commit addresses issues that caused the compiler to emit a warning. This commit is mostly either changing the format string to match the argument, or in some cases, excess, unused arguments are removed.
2022-10-12sim/ppc: Fix core_find_mapping diagnosticsTsukasa OI1-1/+1
Because "%p" is the pointer conversion specifier to print a pointer in an implementation-defined manner, the result with format string containing "0x%p" can be strange. For instance, core_map_find_mapping prints error containing "0x0x...." (processor is not NULL) or "0x(null)" (processor is NULL) on glibc. This commit replaces "0x%p" with "%p" to prevent unpredictable behavior.
2022-10-12sim/ppc: fixes for arguments to printf style functionsAndrew Burgess5-8/+10
After the recent series of fixes to mark more functions in the simulator with ATTRIBUTE_PRINTF, there were some build failures in the ppc sim due, in some cases, to bugs with the arguments being passed, and in other cases, the issues were (maybe) less serious, with arguments being the wrong size, or type, for the printf format being used. This commit fixes all of the issues that I ran into. In each case I selected the easiest solution to the problem, which is usually just casting the argument to the correct type. If anyone later on thinks the print format should change, please feel free to do that. What we have here should keep the simulator basically working as it does currently, which is my goal with this commit.
2022-10-11sim: Remove self-assignmentsTsukasa OI1-2/+0
Clang generates a warning if there is a redundant self-assignment ("-Wself-assign"). On the default configuration, it causes a build failure (unless "--disable-werror" is specified). This commit removes redundant self-assignments from two files.
2022-10-11sim/ppc: Add ATTRIBUTE_PRINTFTsukasa OI3-8/+7
Clang generates a warning if the format string of a printf-like function is not a literal ("-Wformat-nonliteral"). On the default configuration, it causes a build failure (unless "--disable-werror" is specified). To avoid warnings on the printf-like wrapper, it requires proper __attribute__((format)) and we have ATTRIBUTE_PRINTF macro for this reason. This commit adds ATTRIBUTE_PRINTF to the printf-like functions. For the error function defined in sim_calls.c, the ATTRIBUTE_NORETURN has been moved to the function declaration.
2022-09-27sim: Link ZSTD_LIBSFangrui Song1-1/+1
This fixes linker errors in a `../../configure --enable-targets --enable-sim; make all-gdb` build.
2022-05-13sim: remove use of PTRAlan Modra3-7/+7
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-03-24sim: fix “alligned” typosReuben Thomas2-2/+2
Change-Id: Ifd574e38524dd4f1cf0fc003e0c5c7499abc84a0
2022-01-06sim: ppc: migrate to standard uintXX_t typesMike Frysinger37-1343/+1332
Drop the sim-specific unsignedXX types and move to the standard uintXX_t types that C11 provides.
2022-01-01sim: ppc: drop natural typesMike Frysinger4-31/+10
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-01Automatic Copyright Year update after running gdb/copyright.pyJoel Brobecker11-11/+11
This commit brings all the changes made by running gdb/copyright.py as per GDB's Start of New Year Procedure. For the avoidance of doubt, all changes in this commits were performed by the script.
2021-12-09sim: use ## for automake commentsMike Frysinger1-16/+16
The ## marker tells automake to not include the comment in its generated output, so use that in most places where the comment only makes sense in the inputs.
2021-11-28sim: nltvals: pull target syscalls out into a dedicated source fileMike Frysinger1-32/+4
Like we just did for pulling out the errno map, pull out the syscall maps into a dedicated common file. Most newlib ports are using the same syscall map, but not all, which means we have to do a bit more work to migrate. This commit adds the maps and switches the ports using the common default syscall table over to it. Ports using unique syscall tables are still using the old targ-map.c logic. Switching common ports over is easy by checking NL_TARGET, but the ppc code needs a bit more cleanup here hence its larger diff.
2021-11-19sim: install various doc filesMike Frysinger1-0/+19
2021-11-06sim: ppc: switch to libiberty environ.hMike Frysinger1-2/+2
Drop our compat code and assume environ exists to simplify. We did this for all other targets already, but ppc was missed.
2021-11-06sim: clarify license text via COPYING fileMike Frysinger2-1155/+0
The project has been using GPL v3 for a while now in the source files, and the arm & ppc ports have carried a copy of the COPYING file. Lets move those up to the top sim dir like other projects to make it clear. Also drop the ppc/COPYING.LIB as it's not really referenced by any source as everything is GPL v3.
2021-11-03sim: ppc: inline common sim-fpu.c logicMike Frysinger3-33/+2
We will never bother building w/out a ../common/ sim directory, so drop ancient logic supporting that method.
2021-11-03sim: ppc: switch to common builds for callback objectsMike Frysinger3-37/+6
We don't need to build this anymore ourselves since the common build includes it and produces the same object code. We also need to pull in the split constant modules after the refactoring and pulling them out of nltvals.def & targ-map.o. This doesn't matter for the sim directly, but does for gdb and other users of libsim. We also delete some conditional source tree logic since we already require this be the "new" combined tree with a ../common/ dir. This has been the case for decades at this point.
2021-11-01sim: ppc: fix the printf fix for 32-bit systemsMike Frysinger1-1/+1
The time delta is a 64-bit value too.