1 /* Table of relaxations for Xtensa assembly.
2    Copyright 2003 Free Software Foundation, Inc.
3 
4    This file is part of GAS, the GNU Assembler.
5 
6    GAS is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 2, or (at your option)
9    any later version.
10 
11    GAS is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 
16    You should have received a copy of the GNU General Public License
17    along with GAS; see the file COPYING.  If not, write to
18    the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
19    MA 02111-1307, USA.  */
20 
21 #ifndef XTENSA_RELAX_H
22 #define XTENSA_RELAX_H
23 
24 #include "xtensa-isa.h"
25 
26 
27 /* Data structures for the table-driven relaxations for Xtensa processors.
28    See xtensa-relax.c for details.  */
29 
30 typedef struct transition_list TransitionList;
31 typedef struct transition_table TransitionTable;
32 typedef struct transition_rule TransitionRule;
33 typedef struct precondition_list PreconditionList;
34 typedef struct precondition Precondition;
35 
36 struct transition_table
37 {
38   int num_opcodes;
39   TransitionList **table;	/* Possible transitions for each opcode.  */
40 };
41 
42 struct transition_list
43 {
44   TransitionRule *rule;
45   TransitionList *next;
46 };
47 
48 struct precondition_list
49 {
50   Precondition *precond;
51   PreconditionList *next;
52 };
53 
54 
55 /* Operand types and constraints on operands:  */
56 
57 typedef enum op_type OpType;
58 typedef enum cmp_op CmpOp;
59 
60 enum op_type
61 {
62   OP_CONSTANT,
63   OP_OPERAND,
64   OP_OPERAND_LOW8,		/* Sign-extended low 8 bits of immed.  */
65   OP_OPERAND_HI24S,		/* high 24 bits of immed,
66 				   plus 0x100 if low 8 bits are signed.  */
67   OP_OPERAND_F32MINUS,		/* 32 - immed.  */
68   OP_LITERAL,
69   OP_LABEL
70 };
71 
72 enum cmp_op
73 {
74   OP_EQUAL,
75   OP_NOTEQUAL,
76 };
77 
78 struct precondition
79 {
80   CmpOp cmp;
81   int op_num;
82   OpType typ;			/* CONSTANT: op_data is a constant.
83 				   OPERAND: operand op_num must equal op_data.
84 				   Cannot be LITERAL or LABEL.  */
85   int op_data;
86 };
87 
88 typedef struct build_op BuildOp;
89 
90 struct build_op
91 {
92   int op_num;
93   OpType typ;
94   unsigned op_data;		/* CONSTANT: op_data is the value to encode.
95 				   OPERAND: op_data is the field in the
96 				   source instruction to take the value from
97 				   and encode in the op_num field here.
98 				   LITERAL or LABEL: op_data is the ordinal
99 				   that identifies the appropriate one, i.e.,
100 				   there can be more than one literal or
101 				   label in an expansion.  */
102   BuildOp *next;
103 };
104 
105 typedef struct build_instr BuildInstr;
106 typedef enum instr_type InstrType;
107 
108 enum instr_type
109 {
110   INSTR_INSTR,
111   INSTR_LITERAL_DEF,
112   INSTR_LABEL_DEF
113 };
114 
115 struct build_instr
116 {
117   InstrType typ;
118   unsigned id;			/* LITERAL_DEF or LABEL_DEF: an ordinal to
119 				   identify which one.  */
120   xtensa_opcode opcode;		/* unused for LITERAL_DEF or LABEL_DEF.  */
121   BuildOp *ops;
122   BuildInstr *next;
123 };
124 
125 struct transition_rule
126 {
127   xtensa_opcode opcode;
128   PreconditionList *conditions;
129   BuildInstr *to_instr;
130 };
131 
132 extern TransitionTable *xg_build_simplify_table
133   PARAMS ((void));
134 extern TransitionTable *xg_build_widen_table
135   PARAMS ((void));
136 
137 extern bfd_boolean xg_has_userdef_op_fn
138   PARAMS ((OpType));
139 extern long xg_apply_userdef_op_fn
140   PARAMS ((OpType, long));
141 
142 #endif /* !XTENSA_RELAX_H */
143