summaryrefslogtreecommitdiff
path: root/gcc/config/mmix
diff options
context:
space:
mode:
authorhp <hp@138bc75d-0d04-0410-961f-82ee72b054a4>2002-01-05 04:03:36 +0000
committerhp <hp@138bc75d-0d04-0410-961f-82ee72b054a4>2002-01-05 04:03:36 +0000
commit5bd2c01e5d4a50a14fbce96ab7bd8f1d5f330c12 (patch)
tree5c9c7a976d5bf6612a0a74ec84f16266e97a7623 /gcc/config/mmix
parentd61c8c034fbe57a787622084a6291dbdc1793c2b (diff)
downloadgcc-5bd2c01e5d4a50a14fbce96ab7bd8f1d5f330c12.tar.gz
* doc/invoke.texi (Option Summary) <MMIX Options>: Document
-mbranch-predict, -mreg-stack-fill-bug-workaround and their negatives. (MMIX Options): Ditto. Fix item/itemx typo for -mno-zero-extend. * config/mmix/mmix.c (mmix_target_asm_function_prologue): Rework kludge for pre-october-14th mmix versions to handle new-found bug with PUSHJ/PUSHGO and the register stack. * config/mmix/mmix.h (struct machine_function): Rename member has_call_value_without_parameters to has_call_without_parameters. All referers changed. (TARGET_MASK_REG_STACK_FILL_BUG, TARGET_DEFAULT TARGET_MASK_BRANCH_PREDICT): New macros. (TARGET_SWITCHES): New options -mreg-stack-fill-bug-workaround, -mno-reg-stack-fill-bug-workaround. * config/mmix/mmix.md ("call"): Set struct machine member has_call_without_parameters. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@48558 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/config/mmix')
-rw-r--r--gcc/config/mmix/mmix.c58
-rw-r--r--gcc/config/mmix/mmix.h14
-rw-r--r--gcc/config/mmix/mmix.md8
3 files changed, 64 insertions, 16 deletions
diff --git a/gcc/config/mmix/mmix.c b/gcc/config/mmix/mmix.c
index b23365a8c93..5f9b4a8f387 100644
--- a/gcc/config/mmix/mmix.c
+++ b/gcc/config/mmix/mmix.c
@@ -967,19 +967,51 @@ mmix_target_asm_function_prologue (stream, locals_size)
mmix_highest_saved_stack_register = regno;
- /* FIXME: A kludge for the MMIXware ABI. The return value comes back in
- L of the caller, not just the register number of the X field of
- PUSH{J,GO}. So we need to make L agree with that number if there's a
- function call in this function that returns a value but takes no
- parameters (if there were parameters, L would be set to at least the
- first parameter register, $16). A real solution includes a pass to
- test that settings of $15 (MMIX_RETURN_VALUE_REGNUM for the MMIXware
- ABI) dominate all function calls that return a value. This could be
- done in the planned machine_dep_reorg pass to rename all registers. */
- if (! TARGET_ABI_GNU && cfun->machine->has_call_value_without_parameters)
- fprintf (stream, "\tSET %s,%s\n",
- reg_names[MMIX_RETURN_VALUE_REGNUM],
- reg_names[MMIX_RETURN_VALUE_REGNUM]);
+ /* FIXME: Remove this when a corrected mmix version is released.
+
+ This kludge is a work-around for a presumed bug in the mmix simulator
+ (reported to knuth-bug), all versions up and including "Version of 14
+ October 2001". When the circular register stack fills up, the parts
+ that would be overwritten need to be written to memory. If the
+ "filling" instruction is a PUSHJ or PUSHGO, rL == 0 afterwards. That
+ precise condition (rS == rO && rL == 0) is the same as for an empty
+ register stack, which means no more data is written to memory for
+ that round. A hack is to remove the "&& L!=0" from "@<Increase
+ rL@>=" in mmix-sim.w: the register stack isn't empty under normal
+ circumstances, unless SAVE or UNSAVE is used, interrupts are enabled
+ or cases where rS == rO and rL is explicitly written to 0 as in
+ "PUT rL,0".
+
+ A workaround is to make sure PUSHJ or PUSHGO isn't filling up the
+ register stac. This is accomplished if $16 or higher is written
+ before the function call. This doesn't happen from a leaf functions
+ of course. For the MMIXware ABI, this can't happen if all called
+ functions have parameters, because parameters start at $16.
+ Otherwise, and for the GNU ABI, if any register $16 and up is used,
+ we can see if it's mentioned before any function-call without
+ parameters. This isn't too important; the bug will probably be fixed
+ soon and there's an option to not emit the work-around code. The
+ call-with-parameters kludge wouldn't be there if it hadn't been for
+ it being left-over from a previous mmix version.
+
+ The actual code makes sure any register stack fill happens as early
+ as in the function prologue with a "SET $16,$16" (essentially a nop
+ except for the effects on the register stack). */
+ if (TARGET_REG_STACK_FILL_BUG
+ && ((TARGET_ABI_GNU && !leaf_function_p ())
+ || (!TARGET_ABI_GNU
+ && cfun->machine->has_call_without_parameters)))
+ {
+ /* We don't have a specific macro or derivable expression for the
+ first non-call-saved register. If we need it in other places
+ than here (which is temporary code anyway), such a macro should
+ be added. */
+ int flush_regno
+ = TARGET_ABI_GNU ? mmix_highest_saved_stack_register + 2 : 16;
+
+ fprintf (stream, "\tSET %s,%s\n",
+ reg_names[flush_regno], reg_names[flush_regno]);
+ }
}
/* TARGET_ASM_FUNCTION_EPILOGUE. */
diff --git a/gcc/config/mmix/mmix.h b/gcc/config/mmix/mmix.h
index bcc96f7c06a..32fa0e9300a 100644
--- a/gcc/config/mmix/mmix.h
+++ b/gcc/config/mmix/mmix.h
@@ -90,7 +90,7 @@ extern struct rtx_def *mmix_compare_op1;
mmix.md too. */
struct machine_function
{
- int has_call_value_without_parameters;
+ int has_call_without_parameters;
int has_landing_pad;
};
@@ -157,6 +157,7 @@ extern int target_flags;
#define TARGET_MASK_KNUTH_DIVISION 16
#define TARGET_MASK_TOPLEVEL_SYMBOLS 32
#define TARGET_MASK_BRANCH_PREDICT 64
+#define TARGET_MASK_REG_STACK_FILL_BUG 128
/* FIXME: Get rid of this one. */
#define TARGET_LIBFUNC (target_flags & TARGET_MASK_LIBFUNCS)
@@ -166,8 +167,11 @@ extern int target_flags;
#define TARGET_KNUTH_DIVISION (target_flags & TARGET_MASK_KNUTH_DIVISION)
#define TARGET_TOPLEVEL_SYMBOLS (target_flags & TARGET_MASK_TOPLEVEL_SYMBOLS)
#define TARGET_BRANCH_PREDICT (target_flags & TARGET_MASK_BRANCH_PREDICT)
+#define TARGET_REG_STACK_FILL_BUG \
+ (target_flags & TARGET_MASK_REG_STACK_FILL_BUG)
-#define TARGET_DEFAULT TARGET_MASK_BRANCH_PREDICT
+#define TARGET_DEFAULT \
+ (TARGET_MASK_BRANCH_PREDICT | TARGET_MASK_REG_STACK_FILL_BUG)
/* FIXME: Provide a way to *load* the epsilon register. */
#define TARGET_SWITCHES \
@@ -198,6 +202,12 @@ extern int target_flags;
N_("Use P-mnemonics for branches statically predicted as taken")}, \
{"no-branch-predict", -TARGET_MASK_BRANCH_PREDICT, \
N_("Don't use P-mnemonics for branches")}, \
+ {"reg-stack-fill-bug-workaround", TARGET_MASK_REG_STACK_FILL_BUG, \
+ N_("Work around inconsistent behavior when a PUSHJ or PUSHGO\
+ instruction fills the register stack")}, \
+ {"no-reg-stack-fill-bug-workaround", -TARGET_MASK_REG_STACK_FILL_BUG,\
+ N_("Don't work around inconsistent behavior when a PUSHJ or PUSHGO\
+ instruction fills the register stack")}, \
{"", TARGET_DEFAULT, ""}}
/* Unfortunately, this must not reference anything in "mmix.c". */
diff --git a/gcc/config/mmix/mmix.md b/gcc/config/mmix/mmix.md
index 7d1ae48401a..08ee0b309a4 100644
--- a/gcc/config/mmix/mmix.md
+++ b/gcc/config/mmix/mmix.md
@@ -995,6 +995,12 @@ DIVU %1,%1,%2\;GET %0,:rR\;NEGU %2,0,%0\;CSNN %0,$255,%2")
error too. */
if (operands[2] == NULL_RTX)
operands[2] = const0_rtx;
+
+ /* FIXME: Documentation bug: operands[3] (operands[2] for 'call') is the
+ *next* argument register, not the number of arguments in registers. */
+ cfun->machine->has_call_without_parameters
+ |= REG_P (operands[2]) && REGNO (operands[2]) == MMIX_FIRST_ARG_REGNUM;
+
operands[4] = gen_rtx_REG (DImode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM);
}")
@@ -1020,7 +1026,7 @@ DIVU %1,%1,%2\;GET %0,:rR\;NEGU %2,0,%0\;CSNN %0,$255,%2")
/* FIXME: Documentation bug: operands[3] (operands[2] for 'call') is the
*next* argument register, not the number of arguments in registers. */
- cfun->machine->has_call_value_without_parameters
+ cfun->machine->has_call_without_parameters
|= REG_P (operands[3]) && REGNO (operands[3]) == MMIX_FIRST_ARG_REGNUM;
operands[5] = gen_rtx_REG (DImode, MMIX_INCOMING_RETURN_ADDRESS_REGNUM);