Line data Source code
1 : /* Declarations for interface to insn recognizer and insn-output.cc.
2 : Copyright (C) 1987-2026 Free Software Foundation, Inc.
3 :
4 : This file is part of GCC.
5 :
6 : GCC is free software; you can redistribute it and/or modify it under
7 : the terms of the GNU General Public License as published by the Free
8 : Software Foundation; either version 3, or (at your option) any later
9 : version.
10 :
11 : GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12 : WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 : FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 : for more details.
15 :
16 : You should have received a copy of the GNU General Public License
17 : along with GCC; see the file COPYING3. If not see
18 : <http://www.gnu.org/licenses/>. */
19 :
20 : #ifndef GCC_RECOG_H
21 : #define GCC_RECOG_H
22 :
23 : /* For enum tree_code ERROR_MARK. */
24 : #include "tree.h"
25 :
26 : /* An operand reference of the form %[N] or %[MODIFIER:N[,N...]]. */
27 368 : struct bracketed_operand
28 : {
29 : string_slice modifier;
30 : auto_vec<unsigned long, 2> opnums;
31 : };
32 :
33 : extern bool parse_bracketed_operand (const char **, bracketed_operand &);
34 :
35 : /* Random number that should be large enough for all purposes. Also define
36 : a type that has at least MAX_RECOG_ALTERNATIVES + 1 bits, with the extra
37 : bit giving an invalid value that can be used to mean "uninitialized". */
38 : #define MAX_RECOG_ALTERNATIVES 35
39 : typedef uint64_t alternative_mask; /* Keep in sync with genattrtab.cc. */
40 :
41 : /* A mask of all alternatives. */
42 : #define ALL_ALTERNATIVES ((alternative_mask) -1)
43 :
44 : /* A mask containing just alternative X. */
45 : #define ALTERNATIVE_BIT(X) ((alternative_mask) 1 << (X))
46 :
47 : /* Types of operands. */
48 : enum op_type {
49 : OP_IN,
50 : OP_OUT,
51 : OP_INOUT
52 : };
53 :
54 : #ifndef GENERATOR_FILE
55 : struct operand_alternative
56 : {
57 : /* Pointer to the beginning of the constraint string for this alternative,
58 : for easier access by alternative number. */
59 : const char *constraint;
60 :
61 : /* The register class valid for this alternative (possibly NO_REGS). */
62 : enum reg_class cl : 16;
63 :
64 : /* "Badness" of this alternative, computed from number of '?' and '!'
65 : characters in the constraint string. */
66 : unsigned int reject : 16;
67 :
68 : /* -1 if no matching constraint was found, or an operand number. */
69 : int matches : 8;
70 : /* The same information, but reversed: -1 if this operand is not
71 : matched by any other, or the operand number of the operand that
72 : matches this one. */
73 : int matched : 8;
74 :
75 : /* Bit ID is set if the constraint string includes a register constraint with
76 : register filter ID. Use test_register_filters (REGISTER_FILTERS, REGNO)
77 : to test whether REGNO is a valid start register for the operand. */
78 : unsigned int register_filters : MAX (NUM_REGISTER_FILTERS, 1);
79 :
80 : /* Bit ID is set if the constraint string includes a dependent
81 : register constraint with dependent-filter id ID. */
82 : unsigned int dependent_filters : MAX (NUM_DEPENDENT_FILTERS, 1);
83 :
84 : /* Nonzero if '&' was found in the constraint string. */
85 : unsigned int earlyclobber : 1;
86 : /* Nonzero if TARGET_MEM_CONSTRAINT was found in the constraint
87 : string. */
88 : unsigned int memory_ok : 1;
89 : /* Nonzero if 'p' was found in the constraint string. */
90 : unsigned int is_address : 1;
91 : /* Nonzero if 'X' was found in the constraint string, or if the constraint
92 : string for this alternative was empty. */
93 : unsigned int anything_ok : 1;
94 : };
95 :
96 : /* Return the class for operand I of alternative ALT, taking matching
97 : constraints into account. */
98 :
99 : inline enum reg_class
100 186849872 : alternative_class (const operand_alternative *alt, int i)
101 : {
102 186849872 : return alt[i].matches >= 0 ? alt[alt[i].matches].cl : alt[i].cl;
103 : }
104 :
105 : /* Return the mask of register filters that should be applied to operand I
106 : of alternative ALT, taking matching constraints into account. */
107 :
108 : inline unsigned int
109 96305556 : alternative_register_filters (const operand_alternative *alt, int i)
110 : {
111 96305556 : return (alt[i].matches >= 0
112 96305556 : ? alt[alt[i].matches].register_filters
113 85902366 : : alt[i].register_filters);
114 : }
115 :
116 : /* Return the mask of dynamic register filters that should be applied to
117 : operand I of alternative ALT, taking matching constraints into
118 : account. */
119 :
120 : inline unsigned int
121 : alternative_dependent_filters (const operand_alternative *alt, int i)
122 : {
123 0 : return (alt[i].matches >= 0
124 : ? alt[alt[i].matches].dependent_filters
125 : : alt[i].dependent_filters);
126 : }
127 : #endif
128 :
129 : /* A class for substituting one rtx for another within an instruction,
130 : or for recursively simplifying the instruction as-is. Derived classes
131 : can record or filter certain decisions. */
132 :
133 : class insn_propagation : public simplify_context
134 : {
135 : public:
136 : /* Assignments for RESULT_FLAGS.
137 :
138 : UNSIMPLIFIED is true if a substitution has been made inside an rtx
139 : X and if neither X nor its parent expressions could be simplified.
140 :
141 : FIRST_SPARE_RESULT is the first flag available for derived classes. */
142 : static const uint16_t UNSIMPLIFIED = 1U << 0;
143 : static const uint16_t FIRST_SPARE_RESULT = 1U << 1;
144 :
145 : insn_propagation (rtx_insn *);
146 : insn_propagation (rtx_insn *, rtx, rtx, bool = true);
147 : bool apply_to_pattern (rtx *);
148 : bool apply_to_rvalue (rtx *);
149 : bool apply_to_note (rtx *);
150 :
151 : /* Return true if we should accept a substitution into the address of
152 : memory expression MEM. Undoing changes OLD_NUM_CHANGES and up restores
153 : MEM's original address. */
154 0 : virtual bool check_mem (int /*old_num_changes*/,
155 0 : rtx /*mem*/) { return true; }
156 :
157 : /* Note that we've simplified OLD_RTX into NEW_RTX. When substituting,
158 : this only happens if a substitution occurred within OLD_RTX.
159 : Undoing OLD_NUM_CHANGES and up will restore the old form of OLD_RTX.
160 : OLD_RESULT_FLAGS is the value that RESULT_FLAGS had before processing
161 : OLD_RTX. */
162 0 : virtual void note_simplification (int /*old_num_changes*/,
163 : uint16_t /*old_result_flags*/,
164 0 : rtx /*old_rtx*/, rtx /*new_rtx*/) {}
165 :
166 : private:
167 : bool apply_to_mem_1 (rtx);
168 : bool apply_to_lvalue_1 (rtx);
169 : bool apply_to_rvalue_1 (rtx *);
170 : bool apply_to_pattern_1 (rtx *);
171 :
172 : public:
173 : /* The instruction that we are simplifying or propagating into. */
174 : rtx_insn *insn;
175 :
176 : /* If FROM is nonnull, we're replacing FROM with TO, otherwise we're
177 : just doing a recursive simplification. */
178 : rtx from;
179 : rtx to;
180 :
181 : /* The number of times that we have replaced FROM with TO. */
182 : unsigned int num_replacements;
183 :
184 : /* A bitmask of flags that describe the result of the simplificiation;
185 : see above for details. */
186 : uint16_t result_flags : 16;
187 :
188 : /* True if we should unshare TO when making the next substitution,
189 : false if we can use TO itself. */
190 : uint16_t should_unshare : 1;
191 :
192 : /* True if we should call check_mem after substituting into a memory. */
193 : uint16_t should_check_mems : 1;
194 :
195 : /* True if we should call note_simplification after each simplification. */
196 : uint16_t should_note_simplifications : 1;
197 :
198 : /* For future expansion. */
199 : uint16_t spare : 13;
200 :
201 : /* Gives the reason that a substitution failed, for debug purposes. */
202 : const char *failure_reason;
203 : };
204 :
205 : /* Try to replace FROM with TO in INSN. SHARED_P is true if TO is shared
206 : with other instructions, false if INSN can use TO directly. */
207 :
208 71056687 : inline insn_propagation::insn_propagation (rtx_insn *insn, rtx from, rtx to,
209 : bool shared_p)
210 71056687 : : insn (insn),
211 71056687 : from (from),
212 71056687 : to (to),
213 71056687 : num_replacements (0),
214 71056687 : result_flags (0),
215 71056687 : should_unshare (shared_p),
216 71056687 : should_check_mems (false),
217 71056687 : should_note_simplifications (false),
218 71056687 : spare (0),
219 71056687 : failure_reason (nullptr)
220 : {
221 : }
222 :
223 : /* Try to simplify INSN without performing a substitution. */
224 :
225 3548117 : inline insn_propagation::insn_propagation (rtx_insn *insn)
226 3548117 : : insn_propagation (insn, NULL_RTX, NULL_RTX)
227 : {
228 : }
229 :
230 : /* An RAII class that temporarily undoes part of the current change group.
231 : The sequence:
232 :
233 : {
234 : ...;
235 : undo_recog_changes undo (NUM);
236 : STMTS;
237 : }
238 :
239 : executes STMTS with all the changes numbered NUM and up temporarily
240 : reverted. STMTS must not try to add to the current change group.
241 :
242 : Nested uses are supported, but each nested NUM must be no greater than
243 : outer NUMs. */
244 :
245 : class undo_recog_changes
246 : {
247 : public:
248 : undo_recog_changes (int);
249 : ~undo_recog_changes ();
250 :
251 2794136896 : static bool is_active () { return s_num_changes != 0; }
252 :
253 : private:
254 : int m_old_num_changes;
255 :
256 : static int s_num_changes;
257 : };
258 :
259 : extern void init_recog (void);
260 : extern void init_recog_no_volatile (void);
261 : extern bool check_asm_operands (rtx);
262 : extern int asm_operand_ok (rtx, const char *, const char **);
263 : extern bool validate_change (rtx, rtx *, rtx, bool);
264 : extern bool validate_unshare_change (rtx, rtx *, rtx, bool);
265 : extern bool validate_change_xveclen (rtx, rtx *, int, bool);
266 : extern bool canonicalize_change_group (rtx_insn *insn, rtx x);
267 : extern bool insn_invalid_p (rtx_insn *, bool);
268 : extern bool verify_changes (int);
269 : extern void confirm_change_group (void);
270 : extern bool apply_change_group (void);
271 : extern int num_validated_changes (void);
272 : extern void cancel_changes (int);
273 : extern bool constrain_operands (int, alternative_mask);
274 : extern bool constrain_operands_cached (rtx_insn *, int);
275 : extern bool memory_address_addr_space_p (machine_mode, rtx, addr_space_t,
276 : code_helper = ERROR_MARK);
277 : #define memory_address_p(mode,addr) \
278 : memory_address_addr_space_p ((mode), (addr), ADDR_SPACE_GENERIC)
279 : extern bool strict_memory_address_addr_space_p (machine_mode, rtx, addr_space_t,
280 : code_helper = ERROR_MARK);
281 : #define strict_memory_address_p(mode,addr) \
282 : strict_memory_address_addr_space_p ((mode), (addr), ADDR_SPACE_GENERIC)
283 : extern bool validate_replace_rtx_subexp (rtx, rtx, rtx_insn *, rtx *);
284 : extern bool validate_replace_rtx (rtx, rtx, rtx_insn *);
285 : extern bool validate_replace_rtx_part (rtx, rtx, rtx *, rtx_insn *);
286 : extern bool validate_replace_rtx_part_nosimplify (rtx, rtx, rtx *, rtx_insn *);
287 : extern void validate_replace_rtx_group (rtx, rtx, rtx_insn *);
288 : extern void validate_replace_src_group (rtx, rtx, rtx_insn *);
289 : extern bool validate_simplify_insn (rtx_insn *insn);
290 : extern int num_changes_pending (void);
291 : extern bool reg_fits_class_p (const_rtx, reg_class_t, int, machine_mode);
292 : extern bool valid_insn_p (rtx_insn *);
293 :
294 : extern bool offsettable_memref_p (rtx);
295 : extern bool offsettable_nonstrict_memref_p (rtx);
296 : extern bool offsettable_address_addr_space_p (int, machine_mode, rtx,
297 : addr_space_t);
298 : #define offsettable_address_p(strict,mode,addr) \
299 : offsettable_address_addr_space_p ((strict), (mode), (addr), \
300 : ADDR_SPACE_GENERIC)
301 : extern bool mode_dependent_address_p (rtx, addr_space_t);
302 :
303 : extern int recog (rtx, rtx_insn *, int *);
304 : #ifndef GENERATOR_FILE
305 : inline int recog_memoized (rtx_insn *insn);
306 : #endif
307 : extern void add_clobbers (rtx, int);
308 : extern bool added_clobbers_hard_reg_p (int);
309 : extern void insn_extract (rtx_insn *);
310 : extern void extract_insn (rtx_insn *);
311 : extern void extract_constrain_insn (rtx_insn *insn);
312 : extern void extract_constrain_insn_cached (rtx_insn *);
313 : extern void extract_insn_cached (rtx_insn *);
314 : #ifndef GENERATOR_FILE
315 : extern void preprocess_constraints (int, int, const char **,
316 : operand_alternative *, rtx **);
317 : extern const operand_alternative *preprocess_insn_constraints (unsigned int);
318 : #endif
319 : extern void preprocess_constraints (rtx_insn *);
320 : extern rtx_insn *peep2_next_insn (int);
321 : extern bool peep2_regno_dead_p (int, int);
322 : extern bool peep2_reg_dead_p (int, rtx);
323 : #ifdef HARD_CONST
324 : extern rtx peep2_find_free_register (int, int, const char *,
325 : machine_mode, HARD_REG_SET *);
326 : #endif
327 : extern rtx_insn *peephole2_insns (rtx, rtx_insn *, int *);
328 :
329 : extern bool store_data_bypass_p (rtx_insn *, rtx_insn *);
330 : extern bool if_test_bypass_p (rtx_insn *, rtx_insn *);
331 :
332 : extern void copy_frame_info_to_split_insn (rtx_insn *, rtx_insn *);
333 :
334 : #ifndef GENERATOR_FILE
335 : /* Try recognizing the instruction INSN,
336 : and return the code number that results.
337 : Remember the code so that repeated calls do not
338 : need to spend the time for actual rerecognition.
339 :
340 : This function is the normal interface to instruction recognition.
341 : The automatically-generated function `recog' is normally called
342 : through this one. */
343 :
344 : inline int
345 17911915635 : recog_memoized (rtx_insn *insn)
346 : {
347 17911915635 : if (INSN_CODE (insn) < 0)
348 754926039 : INSN_CODE (insn) = recog (PATTERN (insn), insn, 0);
349 17911915635 : return INSN_CODE (insn);
350 : }
351 : #endif
352 :
353 : /* Skip chars until the next ',' or the end of the string. This is
354 : useful to skip alternatives in a constraint string. */
355 : inline const char *
356 3323529997 : skip_alternative (const char *p)
357 : {
358 3323529997 : const char *r = p;
359 10307835049 : while (*r != '\0' && *r != ',')
360 6984305052 : r++;
361 3323529997 : if (*r == ',')
362 3089329438 : r++;
363 3323529997 : return r;
364 : }
365 :
366 : /* Nonzero means volatile operands are recognized. */
367 : extern int volatile_ok;
368 :
369 : /* RAII class for temporarily setting volatile_ok. */
370 :
371 : class temporary_volatile_ok
372 : {
373 : public:
374 4627221 : temporary_volatile_ok (int value) : save_volatile_ok (volatile_ok)
375 : {
376 4627221 : volatile_ok = value;
377 : }
378 :
379 4627221 : ~temporary_volatile_ok () { volatile_ok = save_volatile_ok; }
380 :
381 : private:
382 : temporary_volatile_ok (const temporary_volatile_ok &);
383 : int save_volatile_ok;
384 : };
385 :
386 : /* Set by constrain_operands to the number of the alternative that
387 : matched. */
388 : extern int which_alternative;
389 :
390 : /* True for inline asm operands with - constraint modifier. */
391 : extern bool raw_constraint_p;
392 :
393 : /* The following vectors hold the results from insn_extract. */
394 :
395 : struct recog_data_d
396 : {
397 : recog_data_d () = default;
398 : recog_data_d (const recog_data_d &) = delete;
399 : recog_data_d (const recog_data_d &&) = delete;
400 :
401 : /* It is very tempting to make the 5 operand related arrays into a
402 : structure and index on that. However, to be source compatible
403 : with all of the existing md file insn constraints and output
404 : templates, we need `operand' as a flat array. Without that
405 : member, making an array for the rest seems pointless. */
406 :
407 : /* Gives value of operand N. */
408 : rtx operand[MAX_RECOG_OPERANDS];
409 :
410 : /* Gives location where operand N was found. */
411 : rtx *operand_loc[MAX_RECOG_OPERANDS];
412 :
413 : /* Gives the constraint string for operand N. */
414 : const char *constraints[MAX_RECOG_OPERANDS];
415 :
416 : /* Nonzero if operand N is a match_operator or a match_parallel. */
417 : char is_operator[MAX_RECOG_OPERANDS];
418 :
419 : /* Gives the mode of operand N. */
420 : machine_mode operand_mode[MAX_RECOG_OPERANDS];
421 :
422 : /* Gives the type (in, out, inout) for operand N. */
423 : enum op_type operand_type[MAX_RECOG_OPERANDS];
424 :
425 : /* Gives location where the Nth duplicate-appearance of an operand
426 : was found. This is something that matched MATCH_DUP. */
427 : rtx *dup_loc[MAX_DUP_OPERANDS];
428 :
429 : /* Gives the operand number that was duplicated in the Nth
430 : duplicate-appearance of an operand. */
431 : char dup_num[MAX_DUP_OPERANDS];
432 :
433 : /* ??? Note that these are `char' instead of `unsigned char' to (try to)
434 : avoid certain lossage from K&R C, wherein `unsigned char' default
435 : promotes to `unsigned int' instead of `int' as in ISO C. As of 1999,
436 : the most common places to bootstrap from K&R C are SunOS and HPUX,
437 : both of which have signed characters by default. The only other
438 : supported natives that have both K&R C and unsigned characters are
439 : ROMP and Irix 3, and neither have been seen for a while, but do
440 : continue to consider unsignedness when performing arithmetic inside
441 : a comparison. */
442 :
443 : /* The number of operands of the insn. */
444 : char n_operands;
445 :
446 : /* The number of MATCH_DUPs in the insn. */
447 : char n_dups;
448 :
449 : /* The number of alternatives in the constraints for the insn. */
450 : char n_alternatives;
451 :
452 : /* True if insn is ASM_OPERANDS. */
453 : bool is_asm;
454 :
455 : /* In case we are caching, hold insn data was generated for. */
456 : rtx_insn *insn;
457 : };
458 :
459 : extern struct recog_data_d *recog_data_ptr;
460 : #define recog_data (*recog_data_ptr)
461 :
462 : #ifndef GENERATOR_FILE
463 : /* RAII class for saving/restoring recog_data. */
464 :
465 : class recog_state_saver
466 : {
467 : recog_data_d m_tmp_recog_data;
468 : public:
469 : recog_state_saver ();
470 : ~recog_state_saver ();
471 :
472 : recog_data_d *saved_recog_data_ptr;
473 : int saved_alternative;
474 : };
475 :
476 134364769 : inline recog_state_saver::recog_state_saver ()
477 134364769 : : saved_recog_data_ptr (recog_data_ptr),
478 134364769 : saved_alternative (which_alternative)
479 : {
480 134364769 : m_tmp_recog_data.insn = nullptr;
481 134364769 : recog_data_ptr = &m_tmp_recog_data;
482 : }
483 :
484 134364769 : inline recog_state_saver::~recog_state_saver ()
485 : {
486 134364769 : recog_data_ptr = saved_recog_data_ptr;
487 134364769 : which_alternative = saved_alternative;
488 : }
489 :
490 : extern const operand_alternative *recog_op_alt;
491 :
492 : /* Return a pointer to an array in which index OP describes the constraints
493 : on operand OP of the current instruction alternative (which_alternative).
494 : Only valid after calling preprocess_constraints and constrain_operands. */
495 :
496 : inline const operand_alternative *
497 106810656 : which_op_alt ()
498 : {
499 106810656 : gcc_checking_assert (IN_RANGE (which_alternative, 0,
500 : recog_data.n_alternatives - 1));
501 106810656 : return &recog_op_alt[which_alternative * recog_data.n_operands];
502 : }
503 : #endif
504 :
505 : /* A table defined in insn-output.cc that give information about
506 : each insn-code value. */
507 :
508 : typedef bool (*insn_operand_predicate_fn) (rtx, machine_mode);
509 : typedef const char * (*insn_output_fn) (rtx *, rtx_insn *);
510 :
511 : struct insn_gen_fn
512 : {
513 : typedef void (*stored_funcptr) (void);
514 :
515 : template<typename ...Ts>
516 108801907 : rtx_insn *operator() (Ts... args) const
517 : {
518 : typedef rtx_insn *(*funcptr) (decltype ((void) args, NULL_RTX)...);
519 108801907 : return ((funcptr) func) (args...);
520 : }
521 :
522 : // This is for compatibility of code that invokes functions like
523 : // (*funcptr) (arg)
524 : insn_gen_fn operator * (void) const { return *this; }
525 :
526 : // The wrapped function pointer must be public and there must not be any
527 : // constructors. Otherwise the insn_data_d struct initializers generated
528 : // by genoutput.cc will result in static initializer functions, which defeats
529 : // the purpose of the generated insn_data_d array.
530 : stored_funcptr func;
531 : };
532 :
533 : struct insn_operand_data
534 : {
535 : const insn_operand_predicate_fn predicate;
536 :
537 : const char *const constraint;
538 :
539 : machine_mode const mode : 16;
540 :
541 : const char strict_low;
542 :
543 : const char is_operator;
544 :
545 : const char eliminable;
546 :
547 : const char allows_mem;
548 : };
549 :
550 : /* Legal values for insn_data.output_format. Indicate what type of data
551 : is stored in insn_data.output. */
552 : #define INSN_OUTPUT_FORMAT_NONE 0 /* abort */
553 : #define INSN_OUTPUT_FORMAT_SINGLE 1 /* const char * */
554 : #define INSN_OUTPUT_FORMAT_MULTI 2 /* const char * const * */
555 : #define INSN_OUTPUT_FORMAT_FUNCTION 3 /* const char * (*)(...) */
556 :
557 : struct insn_data_d
558 : {
559 : const char *const name;
560 :
561 : /* How to print the insn. OUTPUT_FORMAT says which member is live. The
562 : constructors let genoutput write the member's value directly, and pick
563 : the member from its type. */
564 : union insn_output_u
565 : {
566 : const char *single;
567 : const char *const *multi;
568 : insn_output_fn function;
569 :
570 : constexpr insn_output_u () : single (nullptr) {}
571 : constexpr insn_output_u (const char *s) : single (s) {}
572 : constexpr insn_output_u (const char *const *m) : multi (m) {}
573 : constexpr insn_output_u (insn_output_fn f) : function (f) {}
574 : } output;
575 : const insn_gen_fn genfun;
576 : const struct insn_operand_data *const operand;
577 :
578 : const char n_generator_args;
579 : const char n_operands;
580 : const char n_dups;
581 : const char n_alternatives;
582 : const char output_format;
583 : };
584 :
585 : extern const struct insn_data_d insn_data[];
586 : extern int peep2_current_count;
587 :
588 : #ifndef GENERATOR_FILE
589 : #include "insn-codes.h"
590 :
591 : /* An enum of boolean attributes that may only depend on the current
592 : subtarget, not on things like operands or compiler phase. */
593 : enum bool_attr {
594 : BA_ENABLED,
595 : BA_PREFERRED_FOR_SPEED,
596 : BA_PREFERRED_FOR_SIZE,
597 : BA_LAST = BA_PREFERRED_FOR_SIZE
598 : };
599 :
600 : /* Target-dependent globals. */
601 : struct target_recog {
602 : bool x_initialized;
603 : alternative_mask x_bool_attr_masks[NUM_INSN_CODES][BA_LAST + 1];
604 : operand_alternative *x_op_alt[NUM_INSN_CODES];
605 : };
606 :
607 : extern struct target_recog default_target_recog;
608 : #if SWITCHABLE_TARGET
609 : extern struct target_recog *this_target_recog;
610 : #else
611 : #define this_target_recog (&default_target_recog)
612 : #endif
613 :
614 : alternative_mask get_enabled_alternatives (rtx_insn *);
615 : alternative_mask get_preferred_alternatives (rtx_insn *);
616 : alternative_mask get_preferred_alternatives (rtx_insn *, basic_block);
617 : bool check_bool_attrs (rtx_insn *);
618 :
619 : void recog_init ();
620 :
621 : /* This RAII class can help to undo tentative insn changes on failure.
622 : When an object of the class goes out of scope, it undoes all group
623 : changes that have been made via the validate_change machinery and
624 : not yet confirmed via confirm_change_group.
625 :
626 : For example:
627 :
628 : insn_change_watermark watermark;
629 : validate_change (..., true); // A
630 : ...
631 : if (test)
632 : // Undoes change A.
633 : return false;
634 : ...
635 : validate_change (..., true); // B
636 : ...
637 : if (test)
638 : // Undoes changes A and B.
639 : return false;
640 : ...
641 : confirm_change_group ();
642 :
643 : Code that wants to avoid this behavior can use keep ():
644 :
645 : insn_change_watermark watermark;
646 : validate_change (..., true); // A
647 : ...
648 : if (test)
649 : // Undoes change A.
650 : return false;
651 : ...
652 : watermark.keep ();
653 : validate_change (..., true); // B
654 : ...
655 : if (test)
656 : // Undoes change B, but not A.
657 : return false;
658 : ...
659 : confirm_change_group (); */
660 : class insn_change_watermark
661 : {
662 : public:
663 113791949 : insn_change_watermark () : m_old_num_changes (num_validated_changes ()) {}
664 : ~insn_change_watermark ();
665 15717253 : void keep () { m_old_num_changes = num_validated_changes (); }
666 :
667 : private:
668 : int m_old_num_changes;
669 : };
670 :
671 113791949 : inline insn_change_watermark::~insn_change_watermark ()
672 : {
673 113791949 : if (m_old_num_changes < num_validated_changes ())
674 45461785 : cancel_changes (m_old_num_changes);
675 113791949 : }
676 :
677 : #endif
678 :
679 : #endif /* GCC_RECOG_H */
|