aboutsummaryrefslogtreecommitdiff
path: root/sim/mips
AgeCommit message (Collapse)AuthorFilesLines
2022-12-27sim: mips: hoist "multi" igen rules up to common buildsMike Frysinger3-124/+103
Since these are the last mips igen rules, we can clean up a number of bits in the local Makefile.in.
2022-12-27sim: mips: hoist "m16" igen rules up to common buildsMike Frysinger3-82/+88
2022-12-27sim: mips: hoist "single" igen rules up to common buildsMike Frysinger3-48/+52
2022-12-27sim: mips: rename "igen" generation mode to "single"Mike Frysinger2-34/+34
The naming in here has grown organically and is confusing to follow. Originally there was only one set of rules for generating code from the igen sources, so calling it "tmp-igen" and such made sense. But when other multigen modes were added ("m16" & "multi") which also used igen, it's not clear what's common igen and what's specific to this generation mode. So rename the set of rules from "igen" to "single" so it's easier to follow.
2022-12-27sim: mips: hoist itable igen rules up to common buildsMike Frysinger2-35/+50
Since this rule is pretty simple, hoist it up to the common build.
2022-12-27sim: mips: unify itable generation (a bit)Mike Frysinger2-34/+22
The m16 & multi targets generate itable once even when all the other modules are generated multiple times. The default igen target will generate itable with everything else out of convenience. This means flags are passed which don't affect the generated itable there. We can unify the itable generation by making sure the right -F/-M filter variables are passed down. Since there's already a dedicated rule & variable in the multi build mode, generalize that and switch the m16 & igen builds over too. I spent a lot of time staring at this code, building for diff mips targets, and exploring all the shell code paths. I think this is safe, but only time (and users) will really tell.
2022-12-27sim: mips: rename multi_flags to igen_itable_flagsMike Frysinger2-9/+9
This variable is only used to generate the itable files. In preparation for merging the itable logic among all ports, rename "multi_flags" to a more appropriate "igen_itable_flags" variable. There should be no real chagnes here otherwise.
2022-12-27sim: mips: drop unused micromips igen logicMike Frysinger2-155/+0
This code appears to be unused since it was first merged. When micromips was enabled, it was via the "MULTI" config, not the "MICROMIPS" config, and the multi configs have sep vars. Since nothing sets SIM_MIPS_GEN=MICROMIPS in the config, all of this should be unreachable, so punt it to simplify. Further, the SIM_MIPS_MICROMIPS16_FLAGS & SIM_MIPS_MICROMIPS_FLAGS settings rely on sim_mips_micromips{,16}_{filter,machine} variables that are never set in the configure script.
2022-12-25sim: mips: move distclean settings to common buildMike Frysinger2-4/+3
This was missed when mips/configure was merged into the top-level.
2022-12-25sim: smp: plumb igen flag down to all usersMike Frysinger2-6/+4
While mips has respected sim_igen_smp at configure time (which was always empty since it defaulted smp to off), no other igen port did. Move this to a makefile variable and plumb it through the common IGEN_RUN variable instead so everyone gets it by default. We also clean up some redundant -N0 setting with multirun mips.
2022-12-25sim: cpu: change default init to handle all cpusMike Frysinger1-1/+1
All the runtimes were only initializing a single CPU. When SMP is enabled, things quickly crash as none of the other CPU structs are setup. Change the default from 0 to the compile time value.
2022-12-24sim: mips: clean up a bit after mips/configure removalMike Frysinger2-5/+3
Now that there is no subdir configure script, we can clean up some logic that was spread between the files.
2022-12-24sim: mips: move igen settings to top-level configureMike Frysinger4-3634/+278
This is the last bit of logic that exists in the mips configure script, so move it to the top-level configure to kill it off. We still have to move the Makefile.in igen logic to local.mk, but this is a required first step for that.
2022-12-24sim: mips: namespace igen configure varsMike Frysinger3-209/+218
To prepare moving this logic to the top-level configure, the vars need to be namespaced. Do that here to make it easier to review. Basically sim_xxx -> SIM_MIPS_XXX when a var is exported from the configure script to the Makefile, and sim_xxx -> sim_mips_xxx when the var is internal in the configure script.
2022-12-24sim: mips: add igen recursive depMike Frysinger1-0/+3
Make sure the igen tool exists before trying to compile the mips subdir. This happens to work when mips has a subconfigure, but hits a race condition when that is removed.
2022-12-24sim: mips: drop unused ENGINE_ISSUE_POSTFIX_HOOKMike Frysinger2-8/+0
Nothing defines this, and it isn't called in all the engine runtimes, so drop it entirely to avoid confusion.
2022-12-24sim: igen: drop move-if-changed usageMike Frysinger1-178/+83
Now that igen itself has this logic, drop these custom build rules to greatly simplify.
2022-12-22sim: move bfd.h include out of sim-main.hMike Frysinger1-1/+0
Not all arches include this in sim-main.h, and the ones that do don't actually use bfd defines in the sim-main.h header. Prune it to make sim-main.h simpler so we can kill it off entirely in the future. We add the include to the files that utilize e.g. bfd_vma though.
2022-12-22sim: mips: trim redundant igen settingsMike Frysinger2-18/+0
These variables are setting the same value as the defaults. Trim this redundant logic to make it easier to see the real differences so we can try to keep unifying cases.
2022-12-22sim: mips: merge mips64* with existing multi-run buildMike Frysinger2-10/+4
Change the default (unhandled) mips64* targets to use the existing mips64 multi-run build. It already handles the formats, we just have to list the mips8000 bfd for it.
2022-12-22sim: mips: merge mips64vr5000 with existing multi-run buildMike Frysinger2-8/+2
The existing mips64vr-* multi-run build already handles mips5000 targets, so reuse that for mips64vr5* targets too. This moves more logic from build-time to runtime so we can have a single binary that supports many targets.
2022-12-22sim: mips: switch from SIM_ADDR to address_wordMike Frysinger2-31/+13
The latter type matches the address size configured for this sim. Also take the opportunity to simplify printf logic by leveraging PRI* macros.
2022-12-22sim: mips: merge mips64vr4300 with existing multi-run buildMike Frysinger2-8/+2
The existing mips64vr-* multi-run build already handles mips4300 targets, so reuse that for mips64vr43* targets too. This moves more logic from build-time to runtime so we can have a single binary that supports many targets.
2022-12-21sim: mips: match target on cpu settingsMike Frysinger2-26/+26
We don't need to enforce larger target settings when the only thing the sim should care about is the CPU target. So reduce most of the target matches to only check the CPU.
2022-12-21sim: mips: move fpu bitsize defines to top-level configureMike Frysinger5-69/+16
This drops support for the --enable-sim-float configure option, but it's not clear anyone ever actually used that. Eventually we'll want this to be a runtime option anyways.
2022-12-21sim: mips: move bitsize defines to top-level configureMike Frysinger5-97/+18
Since the msb value is always defined as the wordsize-1, stop hardcoding that value directly, and use a CPP value instead.
2022-12-21sim: mips: move subtarget defines to top-level configureMike Frysinger4-41/+35
We want to kill off mips/configure entirely. Move this small part out now to get started.
2022-12-21sim: mips: always resolve active bfd mach dynamicallyMike Frysinger3-106/+3
Don't assume that the default bfd that we configured for is the one that is always active when running a program. We already have access to the real runtime value, so use it directly. This simplifies the code quite a bit, and will make it easier to support multiple mach's in a single binary.
2022-12-21sim: build: hoist lists of hw devices upMike Frysinger2-2/+5
We need these in the top-level to generate libsim.a, but also in the subdirs to generate hw-config.h. Move it to the local.mk, and pass it down when running recursive make. This avoids duplication, and makes it available to both. We can simplify this once we move the various steps up to the top-level too.
2022-12-21sim: enable common sim_cpu usage everywhereMike Frysinger1-2/+0
All ports should be migrated now. Drop the SIM_HAVE_COMMON_SIM_CPU knob and require it be used everywhere now.
2022-12-21sim: mips: invert sim_cpu storageMike Frysinger2-73/+90
2022-11-08sim: mips: call Unpredictable instead of setting bogus values [PR sim/29276]Mike Frysinger1-2/+2
The intention of this code seems to be to indicate that this insn should not be used and produces undefined behavior, so instead of setting registers to bogus values, call Unpredictable. This fixes build warnings due to 32-bit/64-bit type conversions, and outputs a log message for users at runtime instead of silent corruption. Bug: https://sourceware.org/PR29276
2022-11-05sim: run: move linking into top-levelMike Frysinger1-0/+25
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-04sim: mips: simplify fpu configure logicMike Frysinger2-22/+14
The configure code always defaults to HARD_FLOATING_POINT, so inline that value and drop redundant target checks as a result.
2022-11-02sim: common: change sim_{fetch,store}_register helpers to use void* buffersMike Frysinger1-4/+4
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-2/+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-15/+15
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-23sim: mips/ppc/riscv: re-add AC_CANONICAL_SYSTEM [PR sim/29439]Mike Frysinger2-0/+162
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-05-13sim: remove use of PTRAlan Modra1-2/+2
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-02-21sim: gdbinit: hoist setup to common codeMike Frysinger1-9/+0
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-04sim: mips: Add simulator support for mips32r6/mips64r6Faraz Shahbazker11-70/+2147
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-04sim: Allow toggling of quiet NaN-bit semanticsFaraz Shahbazker3-3/+7
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-01-06sim: mips: migrate to standard uintXX_t typesMike Frysinger17-1083/+1083
Move off the sim-specific unsignedXX types and to the standard uintXX_t types that C11 provides.
2022-01-01sim: mips: clean up bad style/whitespaceMike Frysinger23-345/+345
This doesn't fix all the problems, but grabs a bunch of the more obvious ones.
2022-01-01Automatic Copyright Year update after running gdb/copyright.pyJoel Brobecker21-21/+21
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-16sim: mips/or1k: drop redundant arg to bitsize macroMike Frysinger2-4/+2
These are just using the default behavior for the 3rd arg, so drop it to make it more clear. This also makes them match all other ports that only use the first 2 arguments.
2021-11-28sim: drop unused gentmap & nltvals.def logicMike Frysinger1-1/+1
Now that all ports have switched to target-newlib-* files, there's no need for these files & generating things at build time. So punt the logic and make target-newlib-syscall a hard requirement.
2021-11-25sim: mips: avoid _ namespaceMike Frysinger1-3/+3
Some C libraries export _P symbols in their headers (like older newlib and its ctype.h), so use P_ instead to avoid conflicts.
2021-11-15sim: split program path out of argv vectorMike Frysinger1-5/+1
We use the program argv to both find the program to run (argv[0]) and to hold the arguments to the program. Most of the time this is fine, but if we want to let programs specify argv[0] independently (which is possible in standard *NIX programs), this double duty doesn't work. So let's split the path to the program to run out into a separate field by itself. This simplifies the various sim_open funcs too. By itself, this code is more of a logical cleanup than something that is super useful. But it will open up customization of argv[0] in a follow up commit. Split the changes to make it easier to review.
2021-11-06sim: mips: use sim_fpu_to{32,64}u to fix build warningsTiezhu Yang2-7/+4
Since the first argument type is unsigned32 or unsigned64, just use sim_fpu_to{32,64}u instead of sim_fpu_to{32,64}i to fix the following build warnings: CC cp1.o .../sim/mips/cp1.c: In function 'convert': .../sim/mips/cp1.c:1425:32: warning: pointer targets in passing argument 1 of 'sim_fpu_to32i' differ in signedness [-Wpointer-sign] status |= sim_fpu_to32i (&result32, &wop, round); ^~~~~~~~~ In file included from .../sim/mips/sim-main.h:67, from .../sim/mips/cp1.c:46: .../sim/mips/../common/sim-fpu.h:270:22: note: expected 'signed32 *' {aka 'int *'} but argument is of type 'unsigned32 *' {aka 'unsigned int *'} INLINE_SIM_FPU (int) sim_fpu_to32i (signed32 *i, const sim_fpu *f, ^~~~~~~~~~~~~ .../sim/mips/cp1.c:1429:32: warning: pointer targets in passing argument 1 of 'sim_fpu_to64i' differ in signedness [-Wpointer-sign] status |= sim_fpu_to64i (&result64, &wop, round); ^~~~~~~~~ In file included from .../sim/mips/sim-main.h:67, from .../sim/mips/cp1.c:46: .../sim/mips/../common/sim-fpu.h:274:22: note: expected 'signed64 *' {aka 'long int *'} but argument is of type 'unsigned64 *' {aka 'long unsigned int *'} INLINE_SIM_FPU (int) sim_fpu_to64i (signed64 *i, const sim_fpu *f, ^~~~~~~~~~~~~ .../sim/mips/cp1.c: In function 'convert_ps': .../sim/mips/cp1.c:1528:34: warning: pointer targets in passing argument 1 of 'sim_fpu_to32i' differ in signedness [-Wpointer-sign] status_u |= sim_fpu_to32i (&res_u, &wop_u, round); ^~~~~~ In file included from .../sim/mips/sim-main.h:67, from .../sim/mips/cp1.c:46: .../sim/mips/../common/sim-fpu.h:270:22: note: expected 'signed32 *' {aka 'int *'} but argument is of type 'unsigned32 *' {aka 'unsigned int *'} INLINE_SIM_FPU (int) sim_fpu_to32i (signed32 *i, const sim_fpu *f, ^~~~~~~~~~~~~ .../sim/mips/cp1.c:1529:34: warning: pointer targets in passing argument 1 of 'sim_fpu_to32i' differ in signedness [-Wpointer-sign] status_l |= sim_fpu_to32i (&res_l, &wop_l, round); ^~~~~~ In file included from .../sim/mips/sim-main.h:67, from .../sim/mips/cp1.c:46: .../sim/mips/../common/sim-fpu.h:270:22: note: expected 'signed32 *' {aka 'int *'} but argument is of type 'unsigned32 *' {aka 'unsigned int *'} INLINE_SIM_FPU (int) sim_fpu_to32i (signed32 *i, const sim_fpu *f, ^~~~~~~~~~~~~ Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>