/* This file contains the definitions and documentation for the
   Register Transfer Expressions (rtx's) that make up the
   Register Transfer Language (rtl) used in the Back End of the GNU compiler.
   Copyright (C) 1987 Free Software Foundation, Inc.

This file is part of GNU CC.

GNU CC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY.  No author or distributor
accepts responsibility to anyone for the consequences of using it
or for whether it serves any particular purpose or works at all,
unless he says so in writing.  Refer to the GNU CC General Public
License for full details.

Everyone is granted permission to copy, modify and redistribute
GNU CC, but only under the conditions described in the
GNU CC General Public License.   A copy of this license is
supposed to have been given to you along with GNU CC so you
can know your rights and responsibilities.  It should be in a
file named COPYING.  Among other things, the copyright notice
and this notice must be preserved on all copies.  */


/* Expression definitions and descriptions for all targets are in this file.
   Some will not be used for some targets.

   The fields in the cpp macro call "DEF_RTL_EXPR()"
   are used to create declarations in the C source of the compiler.

   The fields are:

   1.  The internal name of the rtx used in the C source.
   It is a tag in the enumeration "enum rtx_code" defined in "rtl.h".
   By convention these are in UPPER_CASE.

   2.  The name of the rtx in the external ASCII format read by
   rtl.read_rtl(), and printed by rtl.print_rtl().
   These names are stored in rtl.rtx_name[].
   By convention these are the internal (field 1) names in lower_case.

   3.  The print format, and type of each rtx->fld[] (field) in this rtx.
   These formats are stored in rtl.rtx_format[].
   The meaning of the formats is documented in front of this array in rtl.c
   
   */

/* ---------------------------------------------------------------------
   Expressions (and "meta" expressions) used for structuring the
   rtl representation of a program.
   --------------------------------------------------------------------- */

/* an expression code name unknown to the reader */
DEF_RTL_EXPR(UNKNOWN, "UnKnown", "*")

/* (NIL) is used by rtl reader and printer to represent a null pointer.  */

DEF_RTL_EXPR(NIL, "nil", "*")

/* ----------------------------------------------------------------------
   Expressions types used for things in the instruction chain.

   All formats must start with "iuu" to handle the chain.
   Each insn expression holds an rtl instruction and its semantics
   during back-end processing.
   See macros's in "rtl.h" for the meaning of each rtx->fld[].

   ---------------------------------------------------------------------- */

/* An instruction that cannot jump.  */
DEF_RTL_EXPR(INSN, "insn", "iuueiee")

/* An instruction that can possibly jump.
   Fields ( rtx->fld[] ) have exact same meaning as INSN's
   except field 3 is also used in jump.c to point to the label jumped to. 
   Field 7 is used in jump.c as the JUMP_LABEL.  */
DEF_RTL_EXPR(JUMP_INSN, "jump_insn", "iuueiee0")

/* An instruction that can possibly call a subroutine
   but which will not change which instruction comes next
   in the current function.
   Fields ( rtx->fld[] ) have exact same meaning as INSN's.  */
DEF_RTL_EXPR(CALL_INSN, "call_insn", "iuueiee")

/* A marker that indicates that control will not flow through.  */
DEF_RTL_EXPR(BARRIER, "barrier", "iuu")

/* Holds a label that is followed by instructions.
   Operand:
   3: is a number that is unique in the entire compilation.
   4: is used in jump.c for the use-count of the label.
   and in flow.c to point to the chain of label_ref's to this label.  */
DEF_RTL_EXPR(CODE_LABEL, "code_label", "iuui0")
     
/* Say where in the code a source line starts, for symbol table's sake.
   Contains a filename and a line number.  Line numbers <= 0 are special:
   0 is used in a dummy placed at the front of every function
      just so there will never be a need to delete the first insn;
   -1 indicates a dummy; insns to be deleted by flow analysis and combining
      are really changed to NOTEs with a number of -1.
   -2 means beginning of a name binding contour; output N_LBRAC.
   -3 means end of a contour; output N_RBRAC.  */
DEF_RTL_EXPR(NOTE, "note", "iuusi")

/* ----------------------------------------------------------------------
   Top level constituents of INSN, JUMP_INSN and CALL_INSN.
   ---------------------------------------------------------------------- */
   
/* Several operations to be done in parallel.  */
DEF_RTL_EXPR(PARALLEL, "parallel", "E")

/* A string that is passed through to the assembler as input.
     One can obviously pass comments through by using the
     assembler comment syntax.
     These occur in an insn all by themselves as the PATTERN.
     */
DEF_RTL_EXPR(ASM_INPUT, "asm_input", "s")

/* Vector of addresses, stored as full words.  */
/* Each element is a LABEL_REF to a CODE_LABEL whose address we want.  */
DEF_RTL_EXPR(ADDR_VEC, "addr_vec", "E")

/* Vector of address differences X0 - BASE, X1 - BASE, ...
   First operand is BASE; the vector contains the X's.
   The machine mode of this rtx says how much space to leave
   for each difference.  */
/* Appears inside a DEFINE_DATA.  */
DEF_RTL_EXPR(ADDR_DIFF_VEC, "addr_diff_vec", "eE")

/* ----------------------------------------------------------------------
   Misc. special purpose expression types.
   ---------------------------------------------------------------------- */

/* Appears only in machine descriptions.
   Means use the function named by the second arg (the string)
   as a predicate; if matched, store the structure that was matched
   in the operand table at index specified by the first arg (the integer).
   If the second arg is the null string, the structure is just stored.

   A third string argument indicates to the register allocator restrictions
   on where the operand can be allocated.

   If the target needs no restriction on any instruction this field should
   be the null string.

   The string is prepended by:
   '=' to indicate the operand is only written to.
   '+' to indicate the operand is both read and written to.

   Each character in the string represents an allocatable class for an operand.
   'g' indicates the operand can be any valid class.
   'i' indicates the operand can be immeadiate (in the instruction) data.
   'r' indicates the operand can be in a register.
   'm' indicates the operand can be in memory.
   'o' a subset of the 'm' class.  Those memory addressing modes that
       can be offset at compile time (have a constant added to them).

   Other characters indicate target dependent operand classes and
   are described in each target's machine description.

   For instructions with more than one operand, sets of classes can be
   separated by a comma to indicate the appropriate multi-operand constraints.
   There must be a 1 to 1 correspondence between these sets of classes in
   all operands for an instruction.
   */
DEF_RTL_EXPR(MATCH_OPERAND, "match_operand", "iss")

/* Appears only in machine descriptions.
   Means match only something equal to what is stored in the operand table
   at the index specified by the argument.  */
DEF_RTL_EXPR(MATCH_DUP, "match_dup", "i")

/* Appears only in machine descriptions.
   Defines the pattern for one kind of instruction.
   Operand:
   0: names this instruction.
   If the name is the null string, the instruction is in the
   machine description just to be recognized, and will never be emitted by
   the tree to rtl expander.
   1: is the pattern.
   2: is currently not used.
   3: is the action to execute if this pattern is matched.
      If this assembler code template starts with a * if is a fragment of
      C code to run to decide on a template to use.  Otherwise, it is the
      template to use.
   */
DEF_RTL_EXPR(DEFINE_INSN, "define_insn", "sEss")

/* Refers to the address of its argument.
   This appears only in machine descriptions, indicating that
   any expression that would be acceptable as the operand of MEM
   should be matched.  */
DEF_RTL_EXPR(ADDRESS, "address", "e")

/* a linked list of expressions */
DEF_RTL_EXPR(EXPR_LIST, "expr_list", "ee")

/* a linked list of instructions.
   The insns are represented in print by their uids.  */
DEF_RTL_EXPR(INSN_LIST, "insn_list", "ue")

/* ----------------------------------------------------------------------
   Expressions used for attributing execution effects.
   ---------------------------------------------------------------------- */

/* for memory mapped i/o ports.
   2 or more succesive writes or reads should NOT be optimized out.
   This rtx is nested around each use of an volatile address.
   e.g. (volatile (mem 97))  */
DEF_RTL_EXPR(VOLATILE, "volatile", "e")

/* The opposite of volatile.
   This says that the argument is something whose value will
   never change within one function.
   This can tell various things that they can save the trouble
   of preserving the current value of that thing, and just use
   its current value whenever is convenient.
   The idea is to use this around REG rtx's that are links in
   the static chain.  */
DEF_RTL_EXPR(UNCHANGING, "unchanging", "e")
     
/* ----------------------------------------------------------------------
   At the top level of an instruction (perhaps under PARALLEL).
   ---------------------------------------------------------------------- */

/* Assignment.
   Operand 1 is the location (REG, MEM, PC, CC0 or whatever) assigned to.
   Operand 2 is the value stored there.
   ALL assignment must use SET.
   Instructions that do multiple assignments must use multiple SET,
   under PARALLEL.  */
DEF_RTL_EXPR(SET, "set", "ee")

/* Indicate something is used in a way that we don't want to explain.
   For example, subroutine calls will use the register
   in which the static chain is passed.  */
DEF_RTL_EXPR(USE, "use", "e")

/* Indicate something is clobbered in a way that we don't want to explain.
   For example, subroutine calls will clobber some physical registers
   (the ones that are by convention not saved).  */
DEF_RTL_EXPR(CLOBBER, "clobber", "e")

/* Call a subroutine.
   Operand 1 is the address to call.
   Operand 2 is the number of arguments.  */

DEF_RTL_EXPR(CALL, "call", "ee")

/* Return from a subroutine.  */

DEF_RTL_EXPR(RETURN, "return", "")

/* ----------------------------------------------------------------------
   Primitive values for use in expressions.
   ---------------------------------------------------------------------- */

/* numeric integer constant */
DEF_RTL_EXPR(CONST_INT, "const_int", "i")

/* numeric double constant.
   The double is stored in two "integer" operands.
   The third operand is the MEM that stores this constant in memory.
   The fourth is used to chain together these rtx's for uniquization.  */
DEF_RTL_EXPR(CONST_DOUBLE, "const_double", "iie00")

/* This is used to encapsulate an expression whose value is constant
   (such as the sum of a SYMBOL_REF and a CONST_INT) so that it will be
   recognized as a constant operand rather than by arithmetic instructions.  */

DEF_RTL_EXPR(CONST, "const", "e")


/* program counter.  Ordinary jumps are represented
   by a SET whose first operand is (PC).  */
DEF_RTL_EXPR(PC, "pc", "")

/* A register.  The "operand" is the register number, accessed
   with the REGNO macro.  If this number is less than FIRST_PSEUDO_REGISTER
   than a hardware register is being referred to.  */
DEF_RTL_EXPR(REG, "reg", "i")

/* One word of a multi-word value.
   The first operand is the complete value; the second says which word.
   The WORDS_BIG_ENDIAN flag controls whether word number 0
   (as numbered in a SUBREG) is the most or least significant word.

   This is also used to refer to a value in a different machine mode.
   For example, it can be used to refer to a SImode value as if it were
   Qimode, or vice versa.  Then the word number is always 0.  */
DEF_RTL_EXPR(SUBREG, "subreg", "ei")

/* This one-argument rtx is used for move instructions
   that are guaranteed to alter only the low part of a destination.
   Thus, (SET (SUBREG:HI (REG...)) (MEM:HI ...))
   has an unspecified effect on the high part of REG,
   but (SET (STRICT_LOW_PART (SUBREG:HI (REG...))) (MEM:HI ...))
   is guaranteed to alter only the bits of REG that are in HImode.

   The actual instruction used is probably the same in both cases,
   but the register constraints may be tighter when STRICT_LOW_PART
   is in use.  */

DEF_RTL_EXPR(STRICT_LOW_PART, "strict_low_part", "e")

/* A memory location; operand is the address.
   Can be nested inside a VOLATILE.  */
DEF_RTL_EXPR(MEM, "mem", "e")

/* Reference to an assembler label in the code for this function.
   The operand is a CODE_LABEL found in the insn chain.
   The unprinted fields 1 and 2 are used in flow.c for the
   LABEL_NEXTREF and CONTAINING_INSN.  */
DEF_RTL_EXPR(LABEL_REF, "label_ref", "u00")

/* Reference to a named label: the string that is the first operand,
   with `_' added implicitly in front.
   Exception: if the first character explicitly given is `*',
   to give it to the assembler, remove the `*' and do not add `_'.  */
DEF_RTL_EXPR(SYMBOL_REF, "symbol_ref", "s")

/* The condition code register is represented, in our imagination,
   as a register holding a value that can be compared to zero.
   In fact, the machine has already compared them and recorded the
   results; but instructions that look at the condition code
   pretend to be looking at the entire value and comparing it.  */
DEF_RTL_EXPR(CC0, "cc0", "")

/* =====================================================================
   A QUEUED expression really points to a member of the queue of instructions
   to be output later for postincrement/postdecrement.
   QUEUED expressions never become part of instructions.
   When a QUEUED expression would be put into an instruction,
   instead either the incremented variable or a copy of its previous
   value is used.
   
   Operands are:
   0. the variable to be incremented (a REG rtx).
   1. the incrementing instruction, or 0 if it hasn't been output yet.
   2. A REG rtx for a copy of the old value of the variable, or 0 if none yet.
   3. the body to use for the incrementing instruction
   4. the next QUEUED expression in the queue.
   ====================================================================== */

DEF_RTL_EXPR(QUEUED, "queued", "eeeee")

/* ----------------------------------------------------------------------
   Expressions for operators in an rtl pattern
   ---------------------------------------------------------------------- */

/* if_then_else.  This is used in representing ordinary
   conditional jump instructions.
     Operand:
     0:  condition
     1:  then expr
     2:  else expr */
DEF_RTL_EXPR(IF_THEN_ELSE, "if_then_else", "eee")

/* plus */
DEF_RTL_EXPR(PLUS, "plus", "ee")

/* Operand 0 minus operand 1.  */
DEF_RTL_EXPR(MINUS, "minus", "ee")

/* Minus operand 0.  */
DEF_RTL_EXPR(NEG, "neg", "e")

DEF_RTL_EXPR(MULT, "mult", "ee")

/* Operand 0 divided by operand 1.  */
DEF_RTL_EXPR(DIV, "div", "ee")
/* Remainder of operand 0 divided by operand 1.  */
DEF_RTL_EXPR(MOD, "mod", "ee")

/* Unsigned multiply and divide.  */

DEF_RTL_EXPR(UMULT, "umult", "ee")
DEF_RTL_EXPR(UDIV, "udiv", "ee")
DEF_RTL_EXPR(UMOD, "umod", "ee")

/* Bitwise operations.  */
DEF_RTL_EXPR(AND, "and", "ee")

DEF_RTL_EXPR(IOR, "ior", "ee")

DEF_RTL_EXPR(XOR, "xor", "ee")

DEF_RTL_EXPR(NOT, "not", "e")

/* Operand:
     0:  value to be shifted.
     1:  number of bits.
   ASHIFT and LSHIFT are distinguished because on some machines
   these allow a negative operand and shift right in that case.  */
DEF_RTL_EXPR(LSHIFT, "lshift", "ee")
DEF_RTL_EXPR(ASHIFT, "ashift", "ee")
DEF_RTL_EXPR(ROTATE, "rotate", "ee")

/* Right shift operations, for machines where these are not the same
   as left shifting with a negative argument.  */

DEF_RTL_EXPR(ASHIFTRT, "ashiftrt", "ee")
DEF_RTL_EXPR(LSHIFTRT, "lshiftrt", "ee")
DEF_RTL_EXPR(ROTATERT, "rotatert", "ee")

/* These unary operations are used to represent incrementation
   and decrementation as they occur in memory addresses.
   The amount of increment or decrement are not represented
   because they can be understood from the machine-mode of the
   containing MEM.  These operations exist in only two cases:
   1. pushes onto the stack.
   2. created automatically by the life_analysis pass in flow.c.  */
DEF_RTL_EXPR(PRE_DEC, "pre_dec", "e")
DEF_RTL_EXPR(PRE_INC, "pre_inc", "e")
DEF_RTL_EXPR(POST_DEC, "post_dec", "e")
DEF_RTL_EXPR(POST_INC, "post_inc", "e")

/* Comparison operations.  The ordered comparisons exist in two
   flavors, signed and unsigned.  */
DEF_RTL_EXPR(NE, "ne", "ee")
DEF_RTL_EXPR(EQ, "eq", "ee")
DEF_RTL_EXPR(GE, "ge", "ee")
DEF_RTL_EXPR(GT, "gt", "ee")
DEF_RTL_EXPR(LE, "le", "ee")
DEF_RTL_EXPR(LT, "lt", "ee")
DEF_RTL_EXPR(GEU, "geu", "ee")
DEF_RTL_EXPR(GTU, "gtu", "ee")
DEF_RTL_EXPR(LEU, "leu", "ee")
DEF_RTL_EXPR(LTU, "ltu", "ee")

/* Represents the result of sign-extending the sole operand.
   The machine modes of the operand and of the SIGN_EXTEND expression
   determine how much sign-extension is going on.  */
DEF_RTL_EXPR(SIGN_EXTEND, "sign_extend", "e")

/* Similar for zero-extension (such as unsigned short to int).  */
DEF_RTL_EXPR(ZERO_EXTEND, "zero_extend", "e")

/* Similar but here the operand has a wider mode.  */
DEF_RTL_EXPR(TRUNCATE, "truncate", "e")

/* Similar for extending floating-point values (such as SFmode to DFmode).  */
DEF_RTL_EXPR(FLOAT_EXTEND, "float_extend", "e")
DEF_RTL_EXPR(FLOAT_TRUNCATE, "float_truncate", "e")

/* Conversion of fixed point operand to floating point value.  */
DEF_RTL_EXPR(FLOAT, "float", "e")

/* Conversion of floating point operand to fixed point value.  */
DEF_RTL_EXPR(FIX, "fix", "e")

/* Absolute value */
DEF_RTL_EXPR(ABS, "abs", "e")

/* Square root */
DEF_RTL_EXPR(SQRT, "sqrt", "e")

/* Reference to a signed bit-field of specified size and position.
   Operand 0 is the memory unit (usually SImode or QImode) which
   contains the field's first bit.  Operand 1 is the width, in bits.
   Operand 2 is the number of bits in the memory unit before the
   first bit of this field.
   If BITS_BIG_ENDIAN is defined, the first bit is the msb and
   operand 2 counts from the msb of the memory unit.
   Otherwise, the first bit is the lsb and operand 2 counts from
   the lsb of the memory unit.  */
DEF_RTL_EXPR(SIGN_EXTRACT, "sign_extract", "eee")

/* Similar for unsigned bit-field.  */
DEF_RTL_EXPR(ZERO_EXTRACT, "zero_extract", "eee")

/*
Local variables:
mode:c
version-control: t
End:
*/
