OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [hw-doloop.h] - Blame information for rev 791

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 684 jeremybenn
/* Code to analyze doloop loops in order for targets to perform late
2
   optimizations converting doloops to other forms of hardware loops.
3
   Copyright (C) 2011 Free Software Foundation, Inc.
4
 
5
This file is part of GCC.
6
 
7
GCC is free software; you can redistribute it and/or modify it under
8
the terms of the GNU General Public License as published by the Free
9
Software Foundation; either version 3, or (at your option) any later
10
version.
11
 
12
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13
WARRANTY; without even the implied warranty of MERCHANTABILITY or
14
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15
for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with GCC; see the file COPYING3.  If not see
19
<http://www.gnu.org/licenses/>.  */
20
 
21
/* We need to keep a vector of loops */
22
typedef struct hwloop_info_d *hwloop_info;
23
DEF_VEC_P (hwloop_info);
24
DEF_VEC_ALLOC_P (hwloop_info,heap);
25
 
26
/* Information about a loop we have found (or are in the process of
27
   finding).  */
28
struct GTY (()) hwloop_info_d
29
{
30
  /* loop number, for dumps */
31
  int loop_no;
32
 
33
  /* Next loop in the graph. */
34
  hwloop_info next;
35
 
36
  /* Vector of blocks only within the loop, including those within
37
     inner loops.  */
38
  VEC (basic_block, heap) *blocks;
39
 
40
  /* Same information in a bitmap.  */
41
  bitmap block_bitmap;
42
 
43
  /* Vector of inner loops within this loop.  Includes loops of every
44
     nesting level.  */
45
  VEC (hwloop_info, heap) *loops;
46
 
47
  /* All edges that jump into the loop.  */
48
  VEC(edge, gc) *incoming;
49
 
50
  /* The ports currently using this infrastructure can typically
51
     handle two cases: all incoming edges have the same destination
52
     block, or all incoming edges have the same source block.  These
53
     two members are set to the common source or destination we found,
54
     or NULL if different blocks were found.  If both are NULL the
55
     loop can't be optimized.  */
56
  basic_block incoming_src;
57
  basic_block incoming_dest;
58
 
59
  /* First block in the loop.  This is the one branched to by the loop_end
60
     insn.  */
61
  basic_block head;
62
 
63
  /* Last block in the loop (the one with the loop_end insn).  */
64
  basic_block tail;
65
 
66
  /* The successor block of the loop.  This is the one the loop_end insn
67
     falls into.  */
68
  basic_block successor;
69
 
70
  /* The last instruction in the tail.  */
71
  rtx last_insn;
72
 
73
  /* The loop_end insn.  */
74
  rtx loop_end;
75
 
76
  /* The iteration register.  */
77
  rtx iter_reg;
78
 
79
  /* The new label placed at the beginning of the loop. */
80
  rtx start_label;
81
 
82
  /* The new label placed at the end of the loop. */
83
  rtx end_label;
84
 
85
  /* The length of the loop.  */
86
  int length;
87
 
88
  /* The nesting depth of the loop.  Innermost loops are given a depth
89
     of 1.  Only successfully optimized doloops are counted; if an inner
90
     loop was marked as bad, it does not increase the depth of its parent
91
     loop.
92
     This value is valid when the target's optimize function is called.  */
93
  int depth;
94
 
95
  /* True if we can't optimize this loop.  */
96
  bool bad;
97
 
98
  /* True if we have visited this loop during the optimization phase.  */
99
  bool visited;
100
 
101
  /* The following values are collected before calling the target's optimize
102
     function and are not valid earlier.  */
103
 
104
  /* Record information about control flow: whether the loop has calls
105
     or asm statements, whether it has edges that jump out of the loop,
106
     or edges that jump within the loop.  */
107
  bool has_call;
108
  bool has_asm;
109
  bool jumps_within;
110
  bool jumps_outof;
111
 
112
  /* True if there is an instruction other than the doloop_end which uses the
113
     iteration register.  */
114
  bool iter_reg_used;
115
  /* True if the iteration register lives past the doloop instruction.  */
116
  bool iter_reg_used_outside;
117
 
118
  /* Hard registers set at any point in the loop, except for the loop counter
119
     register's set in the doloop_end instruction.  */
120
  HARD_REG_SET regs_set_in_loop;
121
};
122
 
123
/* A set of hooks to be defined by a target that wants to use the reorg_loops
124
   functionality.
125
 
126
   reorg_loops is intended to handle cases where special hardware loop
127
   setup instructions are required before the loop, for example to set
128
   up loop counter registers that are not exposed to the register
129
   allocator, or to inform the hardware about loop bounds.
130
 
131
   reorg_loops performs analysis to discover loop_end patterns created
132
   by the earlier loop-doloop pass, and sets up a hwloop_info
133
   structure for each such insn it finds.  It then tries to discover
134
   the basic blocks containing the loop by tracking the lifetime of
135
   the iteration register.
136
 
137
   If a valid loop can't be found, the FAIL function is called;
138
   otherwise the OPT function is called for each loop, visiting
139
   innermost loops first and ascending.  */
140
struct hw_doloop_hooks
141
{
142
  /* Examine INSN.  If it is a suitable doloop_end pattern, return the
143
     iteration register, which should be a single hard register.
144
     Otherwise, return NULL_RTX.  */
145
  rtx (*end_pattern_reg) (rtx insn);
146
  /* Optimize LOOP.  The target should perform any additional analysis
147
     (e.g. checking that the loop isn't too long), and then perform
148
     its transformations.  Return true if successful, false if the
149
     loop should be marked bad.  If it returns false, the FAIL
150
     function is called.  */
151
  bool (*opt) (hwloop_info loop);
152
  /* Handle a loop that was marked bad for any reason.  This could be
153
     used to split the doloop_end pattern.  */
154
  void (*fail) (hwloop_info loop);
155
};
156
 
157
extern void reorg_loops (bool, struct hw_doloop_hooks *);

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.