Back to index

cell-binutils  2.17cvs20070401
xtensa-relax.h
Go to the documentation of this file.
00001 /* Table of relaxations for Xtensa assembly.
00002    Copyright 2003, 2004, 2007 Free Software Foundation, Inc.
00003 
00004    This file is part of GAS, the GNU Assembler.
00005 
00006    GAS is free software; you can redistribute it and/or modify
00007    it under the terms of the GNU General Public License as published by
00008    the Free Software Foundation; either version 2, or (at your option)
00009    any later version.
00010 
00011    GAS is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with GAS; see the file COPYING.  If not, write to
00018    the Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
00019    MA 02110-1301, USA.  */
00020 
00021 #ifndef XTENSA_RELAX_H
00022 #define XTENSA_RELAX_H
00023 
00024 #include "xtensa-isa.h"
00025 
00026 
00027 /* Data structures for the table-driven relaxations for Xtensa processors.
00028    See xtensa-relax.c for details.  */
00029 
00030 typedef struct transition_list TransitionList;
00031 typedef struct transition_table TransitionTable;
00032 typedef struct transition_rule TransitionRule;
00033 typedef struct precondition_list PreconditionList;
00034 typedef struct precondition Precondition;
00035 
00036 typedef struct req_or_option_list ReqOrOptionList;
00037 typedef struct req_or_option_list ReqOrOption;
00038 typedef struct req_option_list ReqOptionList;
00039 typedef struct req_option_list ReqOption;
00040 
00041 struct transition_table
00042 {
00043   int num_opcodes;
00044   TransitionList **table;   /* Possible transitions for each opcode.  */
00045 };
00046 
00047 struct transition_list
00048 {
00049   TransitionRule *rule;
00050   TransitionList *next;
00051 };
00052 
00053 struct precondition_list
00054 {
00055   Precondition *precond;
00056   PreconditionList *next;
00057 };
00058 
00059 
00060 /* The required options for a rule are represented with a two-level
00061    structure, with leaf expressions combined by logical ORs at the
00062    lower level, and the results then combined by logical ANDs at the
00063    top level.  The AND terms are linked in a list, and each one can
00064    contain a reference to a list of OR terms.  The leaf expressions,
00065    i.e., the OR options, can be negated by setting the is_true field
00066    to FALSE.  There are two classes of leaf expressions: (1) those
00067    that are properties of the Xtensa configuration and can be
00068    evaluated once when building the tables, and (2) those that depend
00069    of the state of directives or other settings that may vary during
00070    the assembly.  The following expressions may be used in group (1):
00071 
00072    IsaUse*:   Xtensa configuration settings.
00073    realnop:   TRUE if the instruction set includes a NOP instruction.
00074 
00075    There are currently no expressions in group (2), but they are still
00076    supported since there is a good chance they'll be needed again for
00077    something.  */
00078 
00079 struct req_option_list
00080 {
00081   ReqOrOptionList *or_option_terms;
00082   ReqOptionList *next;
00083 };
00084 
00085 struct req_or_option_list
00086 {
00087   char *option_name;
00088   bfd_boolean is_true;
00089   ReqOrOptionList *next;
00090 };
00091 
00092 /* Operand types and constraints on operands:  */
00093 
00094 typedef enum op_type OpType;
00095 typedef enum cmp_op CmpOp;
00096 
00097 enum op_type
00098 {
00099   OP_CONSTANT,
00100   OP_OPERAND,
00101   OP_OPERAND_LOW8,          /* Sign-extended low 8 bits of immed.  */
00102   OP_OPERAND_HI24S,         /* High 24 bits of immed,
00103                                plus 0x100 if low 8 bits are signed.  */
00104   OP_OPERAND_F32MINUS,             /* 32 - immed.  */
00105   OP_OPERAND_LOW16U,        /* Low 16 bits of immed.  */
00106   OP_OPERAND_HI16U,         /* High 16 bits of immed.  */
00107   OP_LITERAL,
00108   OP_LABEL
00109 };
00110 
00111 enum cmp_op
00112 {
00113   OP_EQUAL,
00114   OP_NOTEQUAL,
00115 };
00116 
00117 struct precondition
00118 {
00119   CmpOp cmp;
00120   int op_num;
00121   OpType typ;               /* CONSTANT: op_data is a constant.
00122                                OPERAND: operand op_num must equal op_data.
00123                                Cannot be LITERAL or LABEL.  */
00124   int op_data;
00125 };
00126 
00127 
00128 typedef struct build_op BuildOp;
00129 
00130 struct build_op
00131 {
00132   int op_num;
00133   OpType typ;
00134   unsigned op_data;         /* CONSTANT: op_data is the value to encode.
00135                                OPERAND: op_data is the field in the
00136                                source instruction to take the value from
00137                                and encode in the op_num field here.
00138                                LITERAL or LABEL: unused.  */
00139   BuildOp *next;
00140 };
00141 
00142 typedef struct build_instr BuildInstr;
00143 typedef enum instr_type InstrType;
00144 
00145 enum instr_type
00146 {
00147   INSTR_INSTR,
00148   INSTR_LITERAL_DEF,
00149   INSTR_LABEL_DEF
00150 };
00151 
00152 struct build_instr
00153 {
00154   InstrType typ;
00155   xtensa_opcode opcode;            /* Unused for LITERAL_DEF or LABEL_DEF.  */
00156   BuildOp *ops;
00157   BuildInstr *next;
00158 };
00159 
00160 struct transition_rule
00161 {
00162   xtensa_opcode opcode;
00163   PreconditionList *conditions;
00164   ReqOptionList *options;
00165   BuildInstr *to_instr;
00166 };
00167 
00168 typedef int (*transition_cmp_fn) (const TransitionRule *,
00169                               const TransitionRule *);
00170 
00171 extern TransitionTable *xg_build_simplify_table (transition_cmp_fn);
00172 extern TransitionTable *xg_build_widen_table (transition_cmp_fn);
00173 
00174 extern bfd_boolean xg_has_userdef_op_fn (OpType);
00175 extern long xg_apply_userdef_op_fn (OpType, long);
00176 
00177 #endif /* !XTENSA_RELAX_H */