home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 7
/
FreshFishVol7.bin
/
bbs
/
gnu
/
gcc-2.3.3-src.lha
/
GNU
/
src
/
amiga
/
gcc-2.3.3
/
config
/
pyr.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-02-06
|
22KB
|
864 lines
/* Subroutines for insn-output.c for Pyramid 90x, 9000, and MIServer Series.
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
This file is part of GNU CC.
GNU CC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU CC; see the file COPYING. If not, write to
the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
/* Some output-actions in pyr.md need these. */
#include <stdio.h>
#include "config.h"
#include "rtl.h"
#include "regs.h"
#include "hard-reg-set.h"
#include "real.h"
#include "insn-config.h"
#include "conditions.h"
#include "insn-flags.h"
#include "output.h"
#include "insn-attr.h"
#include "tree.h"
/*
* Do FUNCTION_ARG.
* This cannot be defined as a macro on pyramids, because Pyramid Technology's
* C compiler dies on (several equivalent definitions of) this macro.
* The only way around this cc bug was to make this a function.
* While it would be possible to use a macro version for gcc, it seems
* more reliable to have a single version of the code.
*/
void *
pyr_function_arg(cum, mode, type, named)
CUMULATIVE_ARGS cum;
enum machine_mode mode;
tree type;
{
return (void *)(FUNCTION_ARG_HELPER (cum, mode,type,named));
}
/* Do the hard part of PARAM_SAFE_FOR_REG_P.
* This cannot be defined as a macro on pyramids, because Pyramid Technology's
* C compiler dies on (several equivalent definitions of) this macro.
* The only way around this cc bug was to make this a function.
*/
int
inner_param_safe_helper (type)
tree type;
{
return (INNER_PARAM_SAFE_HELPER(type));
}
/* Return 1 if OP is a non-indexed operand of mode MODE.
This is either a register reference, a memory reference,
or a constant. In the case of a memory reference, the address
is checked to make sure it isn't indexed.
Register and memory references must have mode MODE in order to be valid,
but some constants have no machine mode and are valid for any mode.
If MODE is VOIDmode, OP is checked for validity for whatever mode
it has.
The main use of this function is as a predicate in match_operand
expressions in the machine description.
It is useful to compare this with general_operand(). They should
be identical except for one line.
This function seems necessary because of the non-orthogonality of
Pyramid insns.
For any 2-operand insn, and any combination of operand modes,
if indexing is valid for the isn's second operand, it is invalid
for the first operand to be indexed. */
extern int volatile_ok;
int
nonindexed_operand (op, mode)
register rtx op;
enum machine_mode mode;
{
register RTX_CODE code = GET_CODE (op);
int mode_altering_drug = 0;
if (mode == VOIDmode)
mode = GET_MODE (op);
/* Don't accept CONST_INT or anything similar
if the caller wants something floating. */
if (GET_MODE (op) == VOIDmode && mode != VOIDmode
&& GET_MODE_CLASS (mode) != MODE_INT)
return 0;
if (CONSTANT_P (op))
return ((GET_MODE (op) == VOIDmode || GET_MODE (op) == mode)
&& LEGITIMATE_CONSTANT_P (op));
/* Except for certain constants with VOIDmode, already checked for,
OP's mode must match MODE if MODE specifies a mode. */
if (GET_MODE (op) != mode)
return 0;
while (code == SUBREG)
{
op = SUBREG_REG (op);
code = GET_CODE (op);
#if 0
/* No longer needed, since (SUBREG (MEM...))
will load the MEM into a reload reg in the MEM's own mode. */
mode_altering_drug = 1;
#endif
}
if (code == REG)
return 1;
if (code == CONST_DOUBLE)
return LEGITIMATE_CONSTANT_P (op);
if (code == MEM)
{
register rtx y = XEXP (op, 0);
if (! volatile_ok && MEM_VOLATILE_P (op))
return 0;
GO_IF_NONINDEXED_ADDRESS (y, win);
}
return 0;
win:
if (mode_altering_drug)
return ! mode_dependent_address_p (XEXP (op, 0));
return 1;
}
/* Return non-zero if the rtx OP has an immediate component. An
immediate component or additive term equal to zero is rejected
due to assembler problems. */
int
has_direct_base (op)
rtx op;
{
if ((CONSTANT_ADDRESS_P (op)
&& op != const0_rtx)
|| (GET_CODE (op) == PLUS
&& ((CONSTANT_ADDRESS_P (XEXP (op, 1))
&& XEXP (op, 1) != const0_rtx)
|| (CONSTANT_ADDRESS_P (XEXP (op, 0))
&& XEXP (op, 0) != const0_rtx))))
return 1;
return 0;
}
/* Return zero if the rtx OP has a (scaled) index. */
int
has_index (op)
rtx op;
{
if (GET_CODE (op) == PLUS
&& (GET_CODE (XEXP (op, 0)) == MULT
|| (GET_CODE (XEXP (op, 1)) == MULT)))
return 1;
else
return 0;
}
int swap_operands;
/* weird_memory_memory -- return 1 if OP1 and OP2 can be compared (or
exchanged with xchw) with one instruction. If the operands need to
be swapped, set the global variable SWAP_OPERANDS. This function
silently assumes that both OP0 and OP1 are valid memory references.
*/
int
weird_memory_memory (op0, op1)
rtx op0, op1;
{
RTX_CODE code0, code1;
op0 = XEXP (op0, 0);
op1 = XEXP (op1, 0);
code0 = GET_CODE (op0);
code1 = GET_CODE (op1);
swap_operands = 0;
if (code1 == REG || code1 == SUBREG)
{
return 1;
}
if (code0 == REG || code0 == SUBREG)
{
swap_operands = 1;
return 1;
}
if (has_direct_base (op0) && has_direct_base (op1))
{
if (has_index (op1))
{
if (has_index (op0))
return 0;
swap_operands = 1;
}
return 1;
}
return 0;
}
int
signed_comparison (x, mode)
rtx x;
enum machine_mode mode;
{
return ! TRULY_UNSIGNED_COMPARE_P (GET_CODE (x));
}
extern rtx force_reg ();
rtx test_op0, test_op1;
enum machine_mode test_mode;
/* Sign-extend or zero-extend constant X from FROM_MODE to TO_MODE. */
rtx
extend_const (x, extop, from_mode, to_mode)
rtx x;
RTX_CODE extop;
enum machine_mode from_mode, to_mode;
{
int val;
int negative;
if (from_mode == to_mode)
return x;
if (GET_CODE (x) != CONST_INT)
abort ();
val = INTVAL (x);
negative = val & (1 << (GET_MODE_BITSIZE (from_mode) - 1));
if (GET_MODE_BITSIZE (from_mode) == HOST_BITS_PER_INT)
abort ();
if (negative && extop == SIGN_EXTEND)
val = val | ((-1) << (GET_MODE_BITSIZE (from_mode)));
else
val = val & ~((-1) << (GET_MODE_BITSIZE (from_mode)));
if (GET_MODE_BITSIZE (to_mode) == HOST_BITS_PER_INT)
return gen_rtx (CONST_INT, VOIDmode, val);
return gen_rtx (CONST_INT, VOIDmode,
val & ~((-1) << (GET_MODE_BITSIZE (to_mode))));
}
rtx
ensure_extended (op, extop, from_mode)
rtx op;
RTX_CODE extop;
enum machine_mode from_mode;
{
if (GET_CODE (op) == CONST_INT)
return extend_const (op, extop, from_mode, SImode);
else
return force_reg (SImode, gen_rtx (extop, SImode, op));
}
/* Emit rtl for a branch, as well as any delayed (integer) compare insns.
The compare insn to perform is determined by the global variables
test_op0 and test_op1. */
void
extend_and_branch (extop)
RTX_CODE extop;
{
rtx op0, op1;
RTX_CODE code0, code1;
op0 = test_op0, op1 = test_op1;
if (op0 == 0)
return;
code0 = GET_CODE (op0);
if (op1 != 0)
code1 = GET_CODE (op1);
test_op0 = test_op1 = 0;
if (op1 == 0)
{
op0 = ensure_extended (op0, extop, test_mode);
emit_insn (gen_rtx (SET, VOIDmode, cc0_rtx, op0));
}
else
{
if (CONSTANT_P (op0) && CONSTANT_P (op1))
{
op0 = ensure_extended (op0, extop, test_mode);
op1 = ensure_extended (op1, extop, test_mode);
}
else if (extop == ZERO_EXTEND && test_mode == HImode)
{
/* Pyramids have no unsigned "cmphi" instructions. We need to
zero extend unsigned halfwords into temporary registers. */
op0 = ensure_ext