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

Subversion Repositories scarts

[/] [scarts/] [trunk/] [toolchain/] [scarts-gcc/] [gcc-4.1.1/] [gcc/] [tree-flow-inline.h] - Blame information for rev 16

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

Line No. Rev Author Line
1 12 jlechner
/* Inline functions for tree-flow.h
2
   Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
3
   Contributed by Diego Novillo <dnovillo@redhat.com>
4
 
5
This file is part of GCC.
6
 
7
GCC is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2, or (at your option)
10
any later version.
11
 
12
GCC is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
GNU General Public License for more details.
16
 
17
You should have received a copy of the GNU General Public License
18
along with GCC; see the file COPYING.  If not, write to
19
the Free Software Foundation, 51 Franklin Street, Fifth Floor,
20
Boston, MA 02110-1301, USA.  */
21
 
22
#ifndef _TREE_FLOW_INLINE_H
23
#define _TREE_FLOW_INLINE_H 1
24
 
25
/* Inline functions for manipulating various data structures defined in
26
   tree-flow.h.  See tree-flow.h for documentation.  */
27
 
28
/* Initialize the hashtable iterator HTI to point to hashtable TABLE */
29
 
30
static inline void *
31
first_htab_element (htab_iterator *hti, htab_t table)
32
{
33
  hti->htab = table;
34
  hti->slot = table->entries;
35
  hti->limit = hti->slot + htab_size (table);
36
  do
37
    {
38
      PTR x = *(hti->slot);
39
      if (x != HTAB_EMPTY_ENTRY && x != HTAB_DELETED_ENTRY)
40
        break;
41
    } while (++(hti->slot) < hti->limit);
42
 
43
  if (hti->slot < hti->limit)
44
    return *(hti->slot);
45
  return NULL;
46
}
47
 
48
/* Return current non-empty/deleted slot of the hashtable pointed to by HTI,
49
   or NULL if we have  reached the end.  */
50
 
51
static inline bool
52
end_htab_p (htab_iterator *hti)
53
{
54
  if (hti->slot >= hti->limit)
55
    return true;
56
  return false;
57
}
58
 
59
/* Advance the hashtable iterator pointed to by HTI to the next element of the
60
   hashtable.  */
61
 
62
static inline void *
63
next_htab_element (htab_iterator *hti)
64
{
65
  while (++(hti->slot) < hti->limit)
66
    {
67
      PTR x = *(hti->slot);
68
      if (x != HTAB_EMPTY_ENTRY && x != HTAB_DELETED_ENTRY)
69
        return x;
70
    };
71
  return NULL;
72
}
73
 
74
/* Initialize ITER to point to the first referenced variable in the
75
   referenced_vars hashtable, and return that variable.  */
76
 
77
static inline tree
78
first_referenced_var (referenced_var_iterator *iter)
79
{
80
  struct int_tree_map *itm;
81
  itm = first_htab_element (&iter->hti, referenced_vars);
82
  if (!itm)
83
    return NULL;
84
  return itm->to;
85
}
86
 
87
/* Return true if we have hit the end of the referenced variables ITER is
88
   iterating through.  */
89
 
90
static inline bool
91
end_referenced_vars_p (referenced_var_iterator *iter)
92
{
93
  return end_htab_p (&iter->hti);
94
}
95
 
96
/* Make ITER point to the next referenced_var in the referenced_var hashtable,
97
   and return that variable.  */
98
 
99
static inline tree
100
next_referenced_var (referenced_var_iterator *iter)
101
{
102
  struct int_tree_map *itm;
103
  itm = next_htab_element (&iter->hti);
104
  if (!itm)
105
    return NULL;
106
  return itm->to;
107
}
108
 
109
/* Fill up VEC with the variables in the referenced vars hashtable.  */
110
 
111
static inline void
112
fill_referenced_var_vec (VEC (tree, heap) **vec)
113
{
114
  referenced_var_iterator rvi;
115
  tree var;
116
  *vec = NULL;
117
  FOR_EACH_REFERENCED_VAR (var, rvi)
118
    VEC_safe_push (tree, heap, *vec, var);
119
}
120
 
121
/* Return the variable annotation for T, which must be a _DECL node.
122
   Return NULL if the variable annotation doesn't already exist.  */
123
static inline var_ann_t
124
var_ann (tree t)
125
{
126
  gcc_assert (t);
127
  gcc_assert (DECL_P (t));
128
  gcc_assert (!t->common.ann || t->common.ann->common.type == VAR_ANN);
129
 
130
  return (var_ann_t) t->common.ann;
131
}
132
 
133
/* Return the variable annotation for T, which must be a _DECL node.
134
   Create the variable annotation if it doesn't exist.  */
135
static inline var_ann_t
136
get_var_ann (tree var)
137
{
138
  var_ann_t ann = var_ann (var);
139
  return (ann) ? ann : create_var_ann (var);
140
}
141
 
142
/* Return the statement annotation for T, which must be a statement
143
   node.  Return NULL if the statement annotation doesn't exist.  */
144
static inline stmt_ann_t
145
stmt_ann (tree t)
146
{
147
#ifdef ENABLE_CHECKING
148
  gcc_assert (is_gimple_stmt (t));
149
#endif
150
  return (stmt_ann_t) t->common.ann;
151
}
152
 
153
/* Return the statement annotation for T, which must be a statement
154
   node.  Create the statement annotation if it doesn't exist.  */
155
static inline stmt_ann_t
156
get_stmt_ann (tree stmt)
157
{
158
  stmt_ann_t ann = stmt_ann (stmt);
159
  return (ann) ? ann : create_stmt_ann (stmt);
160
}
161
 
162
/* Return the annotation type for annotation ANN.  */
163
static inline enum tree_ann_type
164
ann_type (tree_ann_t ann)
165
{
166
  return ann->common.type;
167
}
168
 
169
/* Return the basic block for statement T.  */
170
static inline basic_block
171
bb_for_stmt (tree t)
172
{
173
  stmt_ann_t ann;
174
 
175
  if (TREE_CODE (t) == PHI_NODE)
176
    return PHI_BB (t);
177
 
178
  ann = stmt_ann (t);
179
  return ann ? ann->bb : NULL;
180
}
181
 
182
/* Return the may_aliases varray for variable VAR, or NULL if it has
183
   no may aliases.  */
184
static inline varray_type
185
may_aliases (tree var)
186
{
187
  var_ann_t ann = var_ann (var);
188
  return ann ? ann->may_aliases : NULL;
189
}
190
 
191
/* Return the line number for EXPR, or return -1 if we have no line
192
   number information for it.  */
193
static inline int
194
get_lineno (tree expr)
195
{
196
  if (expr == NULL_TREE)
197
    return -1;
198
 
199
  if (TREE_CODE (expr) == COMPOUND_EXPR)
200
    expr = TREE_OPERAND (expr, 0);
201
 
202
  if (! EXPR_HAS_LOCATION (expr))
203
    return -1;
204
 
205
  return EXPR_LINENO (expr);
206
}
207
 
208
/* Return the file name for EXPR, or return "???" if we have no
209
   filename information.  */
210
static inline const char *
211
get_filename (tree expr)
212
{
213
  const char *filename;
214
  if (expr == NULL_TREE)
215
    return "???";
216
 
217
  if (TREE_CODE (expr) == COMPOUND_EXPR)
218
    expr = TREE_OPERAND (expr, 0);
219
 
220
  if (EXPR_HAS_LOCATION (expr) && (filename = EXPR_FILENAME (expr)))
221
    return filename;
222
  else
223
    return "???";
224
}
225
 
226
/* Return true if T is a noreturn call.  */
227
static inline bool
228
noreturn_call_p (tree t)
229
{
230
  tree call = get_call_expr_in (t);
231
  return call != 0 && (call_expr_flags (call) & ECF_NORETURN) != 0;
232
}
233
 
234
/* Mark statement T as modified.  */
235
static inline void
236
mark_stmt_modified (tree t)
237
{
238
  stmt_ann_t ann;
239
  if (TREE_CODE (t) == PHI_NODE)
240
    return;
241
 
242
  ann = stmt_ann (t);
243
  if (ann == NULL)
244
    ann = create_stmt_ann (t);
245
  else if (noreturn_call_p (t))
246
    VEC_safe_push (tree, gc, modified_noreturn_calls, t);
247
  ann->modified = 1;
248
}
249
 
250
/* Mark statement T as modified, and update it.  */
251
static inline void
252
update_stmt (tree t)
253
{
254
  if (TREE_CODE (t) == PHI_NODE)
255
    return;
256
  mark_stmt_modified (t);
257
  update_stmt_operands (t);
258
}
259
 
260
static inline void
261
update_stmt_if_modified (tree t)
262
{
263
  if (stmt_modified_p (t))
264
    update_stmt_operands (t);
265
}
266
 
267
/* Return true if T is marked as modified, false otherwise.  */
268
static inline bool
269
stmt_modified_p (tree t)
270
{
271
  stmt_ann_t ann = stmt_ann (t);
272
 
273
  /* Note that if the statement doesn't yet have an annotation, we consider it
274
     modified.  This will force the next call to update_stmt_operands to scan
275
     the statement.  */
276
  return ann ? ann->modified : true;
277
}
278
 
279
/* Delink an immediate_uses node from its chain.  */
280
static inline void
281
delink_imm_use (ssa_use_operand_t *linknode)
282
{
283
  /* Return if this node is not in a list.  */
284
  if (linknode->prev == NULL)
285
    return;
286
 
287
  linknode->prev->next = linknode->next;
288
  linknode->next->prev = linknode->prev;
289
  linknode->prev = NULL;
290
  linknode->next = NULL;
291
}
292
 
293
/* Link ssa_imm_use node LINKNODE into the chain for LIST.  */
294
static inline void
295
link_imm_use_to_list (ssa_use_operand_t *linknode, ssa_use_operand_t *list)
296
{
297
  /* Link the new node at the head of the list.  If we are in the process of
298
     traversing the list, we won't visit any new nodes added to it.  */
299
  linknode->prev = list;
300
  linknode->next = list->next;
301
  list->next->prev = linknode;
302
  list->next = linknode;
303
}
304
 
305
/* Link ssa_imm_use node LINKNODE into the chain for DEF.  */
306
static inline void
307
link_imm_use (ssa_use_operand_t *linknode, tree def)
308
{
309
  ssa_use_operand_t *root;
310
 
311
  if (!def || TREE_CODE (def) != SSA_NAME)
312
    linknode->prev = NULL;
313
  else
314
    {
315
      root = &(SSA_NAME_IMM_USE_NODE (def));
316
#ifdef ENABLE_CHECKING
317
      if (linknode->use)
318
        gcc_assert (*(linknode->use) == def);
319
#endif
320
      link_imm_use_to_list (linknode, root);
321
    }
322
}
323
 
324
/* Set the value of a use pointed to by USE to VAL.  */
325
static inline void
326
set_ssa_use_from_ptr (use_operand_p use, tree val)
327
{
328
  delink_imm_use (use);
329
  *(use->use) = val;
330
  link_imm_use (use, val);
331
}
332
 
333
/* Link ssa_imm_use node LINKNODE into the chain for DEF, with use occurring
334
   in STMT.  */
335
static inline void
336
link_imm_use_stmt (ssa_use_operand_t *linknode, tree def, tree stmt)
337
{
338
  if (stmt)
339
    link_imm_use (linknode, def);
340
  else
341
    link_imm_use (linknode, NULL);
342
  linknode->stmt = stmt;
343
}
344
 
345
/* Relink a new node in place of an old node in the list.  */
346
static inline void
347
relink_imm_use (ssa_use_operand_t *node, ssa_use_operand_t *old)
348
{
349
  /* The node one had better be in the same list.  */
350
  gcc_assert (*(old->use) == *(node->use));
351
  node->prev = old->prev;
352
  node->next = old->next;
353
  if (old->prev)
354
    {
355
      old->prev->next = node;
356
      old->next->prev = node;
357
      /* Remove the old node from the list.  */
358
      old->prev = NULL;
359
    }
360
}
361
 
362
/* Relink ssa_imm_use node LINKNODE into the chain for OLD, with use occurring
363
   in STMT.  */
364
static inline void
365
relink_imm_use_stmt (ssa_use_operand_t *linknode, ssa_use_operand_t *old, tree stmt)
366
{
367
  if (stmt)
368
    relink_imm_use (linknode, old);
369
  else
370
    link_imm_use (linknode, NULL);
371
  linknode->stmt = stmt;
372
}
373
 
374
/* Finished the traverse of an immediate use list IMM by removing it from
375
   the list.  */
376
static inline void
377
end_safe_imm_use_traverse (imm_use_iterator *imm)
378
{
379
 delink_imm_use (&(imm->iter_node));
380
}
381
 
382
/* Return true if IMM is at the end of the list.  */
383
static inline bool
384
end_safe_imm_use_p (imm_use_iterator *imm)
385
{
386
  return (imm->imm_use == imm->end_p);
387
}
388
 
389
/* Initialize iterator IMM to process the list for VAR.  */
390
static inline use_operand_p
391
first_safe_imm_use (imm_use_iterator *imm, tree var)
392
{
393
  /* Set up and link the iterator node into the linked list for VAR.  */
394
  imm->iter_node.use = NULL;
395
  imm->iter_node.stmt = NULL_TREE;
396
  imm->end_p = &(SSA_NAME_IMM_USE_NODE (var));
397
  /* Check if there are 0 elements.  */
398
  if (imm->end_p->next == imm->end_p)
399
    {
400
      imm->imm_use = imm->end_p;
401
      return NULL_USE_OPERAND_P;
402
    }
403
 
404
  link_imm_use (&(imm->iter_node), var);
405
  imm->imm_use = imm->iter_node.next;
406
  return imm->imm_use;
407
}
408
 
409
/* Bump IMM to the next use in the list.  */
410
static inline use_operand_p
411
next_safe_imm_use (imm_use_iterator *imm)
412
{
413
  ssa_use_operand_t *ptr;
414
  use_operand_p old;
415
 
416
  old = imm->imm_use;
417
  /* If the next node following the iter_node is still the one referred to by
418
     imm_use, then the list hasn't changed, go to the next node.  */
419
  if (imm->iter_node.next == imm->imm_use)
420
    {
421
      ptr = &(imm->iter_node);
422
      /* Remove iternode from the list.  */
423
      delink_imm_use (ptr);
424
      imm->imm_use = imm->imm_use->next;
425
      if (! end_safe_imm_use_p (imm))
426
        {
427
          /* This isn't the end, link iternode before the next use.  */
428
          ptr->prev = imm->imm_use->prev;
429
          ptr->next = imm->imm_use;
430
          imm->imm_use->prev->next = ptr;
431
          imm->imm_use->prev = ptr;
432
        }
433
      else
434
        return old;
435
    }
436
  else
437
    {
438
      /* If the 'next' value after the iterator isn't the same as it was, then
439
         a node has been deleted, so we simply proceed to the node following
440
         where the iterator is in the list.  */
441
      imm->imm_use = imm->iter_node.next;
442
      if (end_safe_imm_use_p (imm))
443
        {
444
          end_safe_imm_use_traverse (imm);
445
          return old;
446
        }
447
    }
448
 
449
  return imm->imm_use;
450
}
451
 
452
/* Return true is IMM has reached the end of the immediate use list.  */
453
static inline bool
454
end_readonly_imm_use_p (imm_use_iterator *imm)
455
{
456
  return (imm->imm_use == imm->end_p);
457
}
458
 
459
/* Initialize iterator IMM to process the list for VAR.  */
460
static inline use_operand_p
461
first_readonly_imm_use (imm_use_iterator *imm, tree var)
462
{
463
  gcc_assert (TREE_CODE (var) == SSA_NAME);
464
 
465
  imm->end_p = &(SSA_NAME_IMM_USE_NODE (var));
466
  imm->imm_use = imm->end_p->next;
467
#ifdef ENABLE_CHECKING
468
  imm->iter_node.next = imm->imm_use->next;
469
#endif
470
  if (end_readonly_imm_use_p (imm))
471
    return NULL_USE_OPERAND_P;
472
  return imm->imm_use;
473
}
474
 
475
/* Bump IMM to the next use in the list.  */
476
static inline use_operand_p
477
next_readonly_imm_use (imm_use_iterator *imm)
478
{
479
  use_operand_p old = imm->imm_use;
480
 
481
#ifdef ENABLE_CHECKING
482
  /* If this assertion fails, it indicates the 'next' pointer has changed
483
     since we the last bump.  This indicates that the list is being modified
484
     via stmt changes, or SET_USE, or somesuch thing, and you need to be
485
     using the SAFE version of the iterator.  */
486
  gcc_assert (imm->iter_node.next == old->next);
487
  imm->iter_node.next = old->next->next;
488
#endif
489
 
490
  imm->imm_use = old->next;
491
  if (end_readonly_imm_use_p (imm))
492
    return old;
493
  return imm->imm_use;
494
}
495
 
496
/* Return true if VAR has no uses.  */
497
static inline bool
498
has_zero_uses (tree var)
499
{
500
  ssa_use_operand_t *ptr;
501
  ptr = &(SSA_NAME_IMM_USE_NODE (var));
502
  /* A single use means there is no items in the list.  */
503
  return (ptr == ptr->next);
504
}
505
 
506
/* Return true if VAR has a single use.  */
507
static inline bool
508
has_single_use (tree var)
509
{
510
  ssa_use_operand_t *ptr;
511
  ptr = &(SSA_NAME_IMM_USE_NODE (var));
512
  /* A single use means there is one item in the list.  */
513
  return (ptr != ptr->next && ptr == ptr->next->next);
514
}
515
 
516
/* If VAR has only a single immediate use, return true, and set USE_P and STMT
517
   to the use pointer and stmt of occurrence.  */
518
static inline bool
519
single_imm_use (tree var, use_operand_p *use_p, tree *stmt)
520
{
521
  ssa_use_operand_t *ptr;
522
 
523
  ptr = &(SSA_NAME_IMM_USE_NODE (var));
524
  if (ptr != ptr->next && ptr == ptr->next->next)
525
    {
526
      *use_p = ptr->next;
527
      *stmt = ptr->next->stmt;
528
      return true;
529
    }
530
  *use_p = NULL_USE_OPERAND_P;
531
  *stmt = NULL_TREE;
532
  return false;
533
}
534
 
535
/* Return the number of immediate uses of VAR.  */
536
static inline unsigned int
537
num_imm_uses (tree var)
538
{
539
  ssa_use_operand_t *ptr, *start;
540
  unsigned int num;
541
 
542
  start = &(SSA_NAME_IMM_USE_NODE (var));
543
  num = 0;
544
  for (ptr = start->next; ptr != start; ptr = ptr->next)
545
     num++;
546
 
547
  return num;
548
}
549
 
550
 
551
/* Return the tree pointer to by USE.  */
552
static inline tree
553
get_use_from_ptr (use_operand_p use)
554
{
555
  return *(use->use);
556
}
557
 
558
/* Return the tree pointer to by DEF.  */
559
static inline tree
560
get_def_from_ptr (def_operand_p def)
561
{
562
  return *def;
563
}
564
 
565
/* Return a def_operand_p pointer for the result of PHI.  */
566
static inline def_operand_p
567
get_phi_result_ptr (tree phi)
568
{
569
  return &(PHI_RESULT_TREE (phi));
570
}
571
 
572
/* Return a use_operand_p pointer for argument I of phinode PHI.  */
573
static inline use_operand_p
574
get_phi_arg_def_ptr (tree phi, int i)
575
{
576
  return &(PHI_ARG_IMM_USE_NODE (phi,i));
577
}
578
 
579
 
580
/* Return the bitmap of addresses taken by STMT, or NULL if it takes
581
   no addresses.  */
582
static inline bitmap
583
addresses_taken (tree stmt)
584
{
585
  stmt_ann_t ann = stmt_ann (stmt);
586
  return ann ? ann->addresses_taken : NULL;
587
}
588
 
589
/* Return the PHI nodes for basic block BB, or NULL if there are no
590
   PHI nodes.  */
591
static inline tree
592
phi_nodes (basic_block bb)
593
{
594
  return bb->phi_nodes;
595
}
596
 
597
/* Set list of phi nodes of a basic block BB to L.  */
598
 
599
static inline void
600
set_phi_nodes (basic_block bb, tree l)
601
{
602
  tree phi;
603
 
604
  bb->phi_nodes = l;
605
  for (phi = l; phi; phi = PHI_CHAIN (phi))
606
    set_bb_for_stmt (phi, bb);
607
}
608
 
609
/* Return the phi argument which contains the specified use.  */
610
 
611
static inline int
612
phi_arg_index_from_use (use_operand_p use)
613
{
614
  struct phi_arg_d *element, *root;
615
  int index;
616
  tree phi;
617
 
618
  /* Since the use is the first thing in a PHI argument element, we can
619
     calculate its index based on casting it to an argument, and performing
620
     pointer arithmetic.  */
621
 
622
  phi = USE_STMT (use);
623
  gcc_assert (TREE_CODE (phi) == PHI_NODE);
624
 
625
  element = (struct phi_arg_d *)use;
626
  root = &(PHI_ARG_ELT (phi, 0));
627
  index = element - root;
628
 
629
#ifdef ENABLE_CHECKING
630
  /* Make sure the calculation doesn't have any leftover bytes.  If it does,
631
     then imm_use is likely not the first element in phi_arg_d.  */
632
  gcc_assert (
633
          (((char *)element - (char *)root) % sizeof (struct phi_arg_d)) == 0);
634
  gcc_assert (index >= 0 && index < PHI_ARG_CAPACITY (phi));
635
#endif
636
 
637
 return index;
638
}
639
 
640
/* Mark VAR as used, so that it'll be preserved during rtl expansion.  */
641
 
642
static inline void
643
set_is_used (tree var)
644
{
645
  var_ann_t ann = get_var_ann (var);
646
  ann->used = 1;
647
}
648
 
649
 
650
/*  -----------------------------------------------------------------------  */
651
 
652
/* Return true if T is an executable statement.  */
653
static inline bool
654
is_exec_stmt (tree t)
655
{
656
  return (t && !IS_EMPTY_STMT (t) && t != error_mark_node);
657
}
658
 
659
 
660
/* Return true if this stmt can be the target of a control transfer stmt such
661
   as a goto.  */
662
static inline bool
663
is_label_stmt (tree t)
664
{
665
  if (t)
666
    switch (TREE_CODE (t))
667
      {
668
        case LABEL_DECL:
669
        case LABEL_EXPR:
670
        case CASE_LABEL_EXPR:
671
          return true;
672
        default:
673
          return false;
674
      }
675
  return false;
676
}
677
 
678
/* Set the default definition for VAR to DEF.  */
679
static inline void
680
set_default_def (tree var, tree def)
681
{
682
  var_ann_t ann = get_var_ann (var);
683
  ann->default_def = def;
684
}
685
 
686
/* Return the default definition for variable VAR, or NULL if none
687
   exists.  */
688
static inline tree
689
default_def (tree var)
690
{
691
  var_ann_t ann = var_ann (var);
692
  return ann ? ann->default_def : NULL_TREE;
693
}
694
 
695
/* PHI nodes should contain only ssa_names and invariants.  A test
696
   for ssa_name is definitely simpler; don't let invalid contents
697
   slip in in the meantime.  */
698
 
699
static inline bool
700
phi_ssa_name_p (tree t)
701
{
702
  if (TREE_CODE (t) == SSA_NAME)
703
    return true;
704
#ifdef ENABLE_CHECKING
705
  gcc_assert (is_gimple_min_invariant (t));
706
#endif
707
  return false;
708
}
709
 
710
/*  -----------------------------------------------------------------------  */
711
 
712
/* Return a block_stmt_iterator that points to beginning of basic
713
   block BB.  */
714
static inline block_stmt_iterator
715
bsi_start (basic_block bb)
716
{
717
  block_stmt_iterator bsi;
718
  if (bb->stmt_list)
719
    bsi.tsi = tsi_start (bb->stmt_list);
720
  else
721
    {
722
      gcc_assert (bb->index < 0);
723
      bsi.tsi.ptr = NULL;
724
      bsi.tsi.container = NULL;
725
    }
726
  bsi.bb = bb;
727
  return bsi;
728
}
729
 
730
/* Return a block statement iterator that points to the first non-label
731
   statement in block BB.  */
732
 
733
static inline block_stmt_iterator
734
bsi_after_labels (basic_block bb)
735
{
736
  block_stmt_iterator bsi = bsi_start (bb);
737
 
738
  while (!bsi_end_p (bsi) && TREE_CODE (bsi_stmt (bsi)) == LABEL_EXPR)
739
    bsi_next (&bsi);
740
 
741
  return bsi;
742
}
743
 
744
/* Return a block statement iterator that points to the end of basic
745
   block BB.  */
746
static inline block_stmt_iterator
747
bsi_last (basic_block bb)
748
{
749
  block_stmt_iterator bsi;
750
  if (bb->stmt_list)
751
    bsi.tsi = tsi_last (bb->stmt_list);
752
  else
753
    {
754
      gcc_assert (bb->index < 0);
755
      bsi.tsi.ptr = NULL;
756
      bsi.tsi.container = NULL;
757
    }
758
  bsi.bb = bb;
759
  return bsi;
760
}
761
 
762
/* Return true if block statement iterator I has reached the end of
763
   the basic block.  */
764
static inline bool
765
bsi_end_p (block_stmt_iterator i)
766
{
767
  return tsi_end_p (i.tsi);
768
}
769
 
770
/* Modify block statement iterator I so that it is at the next
771
   statement in the basic block.  */
772
static inline void
773
bsi_next (block_stmt_iterator *i)
774
{
775
  tsi_next (&i->tsi);
776
}
777
 
778
/* Modify block statement iterator I so that it is at the previous
779
   statement in the basic block.  */
780
static inline void
781
bsi_prev (block_stmt_iterator *i)
782
{
783
  tsi_prev (&i->tsi);
784
}
785
 
786
/* Return the statement that block statement iterator I is currently
787
   at.  */
788
static inline tree
789
bsi_stmt (block_stmt_iterator i)
790
{
791
  return tsi_stmt (i.tsi);
792
}
793
 
794
/* Return a pointer to the statement that block statement iterator I
795
   is currently at.  */
796
static inline tree *
797
bsi_stmt_ptr (block_stmt_iterator i)
798
{
799
  return tsi_stmt_ptr (i.tsi);
800
}
801
 
802
/* Returns the loop of the statement STMT.  */
803
 
804
static inline struct loop *
805
loop_containing_stmt (tree stmt)
806
{
807
  basic_block bb = bb_for_stmt (stmt);
808
  if (!bb)
809
    return NULL;
810
 
811
  return bb->loop_father;
812
}
813
 
814
/* Return true if VAR is a clobbered by function calls.  */
815
static inline bool
816
is_call_clobbered (tree var)
817
{
818
  return is_global_var (var)
819
    || bitmap_bit_p (call_clobbered_vars, DECL_UID (var));
820
}
821
 
822
/* Mark variable VAR as being clobbered by function calls.  */
823
static inline void
824
mark_call_clobbered (tree var)
825
{
826
  var_ann_t ann = var_ann (var);
827
  /* If VAR is a memory tag, then we need to consider it a global
828
     variable.  This is because the pointer that VAR represents has
829
     been found to point to either an arbitrary location or to a known
830
     location in global memory.  */
831
  if (ann->mem_tag_kind != NOT_A_TAG && ann->mem_tag_kind != STRUCT_FIELD)
832
    DECL_EXTERNAL (var) = 1;
833
  bitmap_set_bit (call_clobbered_vars, DECL_UID (var));
834
  ssa_call_clobbered_cache_valid = false;
835
  ssa_ro_call_cache_valid = false;
836
}
837
 
838
/* Clear the call-clobbered attribute from variable VAR.  */
839
static inline void
840
clear_call_clobbered (tree var)
841
{
842
  var_ann_t ann = var_ann (var);
843
  if (ann->mem_tag_kind != NOT_A_TAG && ann->mem_tag_kind != STRUCT_FIELD)
844
    DECL_EXTERNAL (var) = 0;
845
  bitmap_clear_bit (call_clobbered_vars, DECL_UID (var));
846
  ssa_call_clobbered_cache_valid = false;
847
  ssa_ro_call_cache_valid = false;
848
}
849
 
850
/* Mark variable VAR as being non-addressable.  */
851
static inline void
852
mark_non_addressable (tree var)
853
{
854
  bitmap_clear_bit (call_clobbered_vars, DECL_UID (var));
855
  TREE_ADDRESSABLE (var) = 0;
856
  ssa_call_clobbered_cache_valid = false;
857
  ssa_ro_call_cache_valid = false;
858
}
859
 
860
/* Return the common annotation for T.  Return NULL if the annotation
861
   doesn't already exist.  */
862
static inline tree_ann_t
863
tree_ann (tree t)
864
{
865
  return t->common.ann;
866
}
867
 
868
/* Return a common annotation for T.  Create the constant annotation if it
869
   doesn't exist.  */
870
static inline tree_ann_t
871
get_tree_ann (tree t)
872
{
873
  tree_ann_t ann = tree_ann (t);
874
  return (ann) ? ann : create_tree_ann (t);
875
}
876
 
877
/*  -----------------------------------------------------------------------  */
878
 
879
/* The following set of routines are used to iterator over various type of
880
   SSA operands.  */
881
 
882
/* Return true if PTR is finished iterating.  */
883
static inline bool
884
op_iter_done (ssa_op_iter *ptr)
885
{
886
  return ptr->done;
887
}
888
 
889
/* Get the next iterator use value for PTR.  */
890
static inline use_operand_p
891
op_iter_next_use (ssa_op_iter *ptr)
892
{
893
  use_operand_p use_p;
894
#ifdef ENABLE_CHECKING
895
  gcc_assert (ptr->iter_type == ssa_op_iter_use);
896
#endif
897
  if (ptr->uses)
898
    {
899
      use_p = USE_OP_PTR (ptr->uses);
900
      ptr->uses = ptr->uses->next;
901
      return use_p;
902
    }
903
  if (ptr->vuses)
904
    {
905
      use_p = VUSE_OP_PTR (ptr->vuses);
906
      ptr->vuses = ptr->vuses->next;
907
      return use_p;
908
    }
909
  if (ptr->mayuses)
910
    {
911
      use_p = MAYDEF_OP_PTR (ptr->mayuses);
912
      ptr->mayuses = ptr->mayuses->next;
913
      return use_p;
914
    }
915
  if (ptr->mustkills)
916
    {
917
      use_p = MUSTDEF_KILL_PTR (ptr->mustkills);
918
      ptr->mustkills = ptr->mustkills->next;
919
      return use_p;
920
    }
921
  if (ptr->phi_i < ptr->num_phi)
922
    {
923
      return PHI_ARG_DEF_PTR (ptr->phi_stmt, (ptr->phi_i)++);
924
    }
925
  ptr->done = true;
926
  return NULL_USE_OPERAND_P;
927
}
928
 
929
/* Get the next iterator def value for PTR.  */
930
static inline def_operand_p
931
op_iter_next_def (ssa_op_iter *ptr)
932
{
933
  def_operand_p def_p;
934
#ifdef ENABLE_CHECKING
935
  gcc_assert (ptr->iter_type == ssa_op_iter_def);
936
#endif
937
  if (ptr->defs)
938
    {
939
      def_p = DEF_OP_PTR (ptr->defs);
940
      ptr->defs = ptr->defs->next;
941
      return def_p;
942
    }
943
  if (ptr->mustdefs)
944
    {
945
      def_p = MUSTDEF_RESULT_PTR (ptr->mustdefs);
946
      ptr->mustdefs = ptr->mustdefs->next;
947
      return def_p;
948
    }
949
  if (ptr->maydefs)
950
    {
951
      def_p = MAYDEF_RESULT_PTR (ptr->maydefs);
952
      ptr->maydefs = ptr->maydefs->next;
953
      return def_p;
954
    }
955
  ptr->done = true;
956
  return NULL_DEF_OPERAND_P;
957
}
958
 
959
/* Get the next iterator tree value for PTR.  */
960
static inline tree
961
op_iter_next_tree (ssa_op_iter *ptr)
962
{
963
  tree val;
964
#ifdef ENABLE_CHECKING
965
  gcc_assert (ptr->iter_type == ssa_op_iter_tree);
966
#endif
967
  if (ptr->uses)
968
    {
969
      val = USE_OP (ptr->uses);
970
      ptr->uses = ptr->uses->next;
971
      return val;
972
    }
973
  if (ptr->vuses)
974
    {
975
      val = VUSE_OP (ptr->vuses);
976
      ptr->vuses = ptr->vuses->next;
977
      return val;
978
    }
979
  if (ptr->mayuses)
980
    {
981
      val = MAYDEF_OP (ptr->mayuses);
982
      ptr->mayuses = ptr->mayuses->next;
983
      return val;
984
    }
985
  if (ptr->mustkills)
986
    {
987
      val = MUSTDEF_KILL (ptr->mustkills);
988
      ptr->mustkills = ptr->mustkills->next;
989
      return val;
990
    }
991
  if (ptr->defs)
992
    {
993
      val = DEF_OP (ptr->defs);
994
      ptr->defs = ptr->defs->next;
995
      return val;
996
    }
997
  if (ptr->mustdefs)
998
    {
999
      val = MUSTDEF_RESULT (ptr->mustdefs);
1000
      ptr->mustdefs = ptr->mustdefs->next;
1001
      return val;
1002
    }
1003
  if (ptr->maydefs)
1004
    {
1005
      val = MAYDEF_RESULT (ptr->maydefs);
1006
      ptr->maydefs = ptr->maydefs->next;
1007
      return val;
1008
    }
1009
 
1010
  ptr->done = true;
1011
  return NULL_TREE;
1012
 
1013
}
1014
 
1015
 
1016
/* This functions clears the iterator PTR, and marks it done.  This is normally
1017
   used to prevent warnings in the compile about might be uninitialized
1018
   components.  */
1019
 
1020
static inline void
1021
clear_and_done_ssa_iter (ssa_op_iter *ptr)
1022
{
1023
  ptr->defs = NULL;
1024
  ptr->uses = NULL;
1025
  ptr->vuses = NULL;
1026
  ptr->maydefs = NULL;
1027
  ptr->mayuses = NULL;
1028
  ptr->mustdefs = NULL;
1029
  ptr->mustkills = NULL;
1030
  ptr->iter_type = ssa_op_iter_none;
1031
  ptr->phi_i = 0;
1032
  ptr->num_phi = 0;
1033
  ptr->phi_stmt = NULL_TREE;
1034
  ptr->done = true;
1035
}
1036
 
1037
/* Initialize the iterator PTR to the virtual defs in STMT.  */
1038
static inline void
1039
op_iter_init (ssa_op_iter *ptr, tree stmt, int flags)
1040
{
1041
#ifdef ENABLE_CHECKING
1042
  gcc_assert (stmt_ann (stmt));
1043
#endif
1044
 
1045
  ptr->defs = (flags & SSA_OP_DEF) ? DEF_OPS (stmt) : NULL;
1046
  ptr->uses = (flags & SSA_OP_USE) ? USE_OPS (stmt) : NULL;
1047
  ptr->vuses = (flags & SSA_OP_VUSE) ? VUSE_OPS (stmt) : NULL;
1048
  ptr->maydefs = (flags & SSA_OP_VMAYDEF) ? MAYDEF_OPS (stmt) : NULL;
1049
  ptr->mayuses = (flags & SSA_OP_VMAYUSE) ? MAYDEF_OPS (stmt) : NULL;
1050
  ptr->mustdefs = (flags & SSA_OP_VMUSTDEF) ? MUSTDEF_OPS (stmt) : NULL;
1051
  ptr->mustkills = (flags & SSA_OP_VMUSTKILL) ? MUSTDEF_OPS (stmt) : NULL;
1052
  ptr->done = false;
1053
 
1054
  ptr->phi_i = 0;
1055
  ptr->num_phi = 0;
1056
  ptr->phi_stmt = NULL_TREE;
1057
}
1058
 
1059
/* Initialize iterator PTR to the use operands in STMT based on FLAGS. Return
1060
   the first use.  */
1061
static inline use_operand_p
1062
op_iter_init_use (ssa_op_iter *ptr, tree stmt, int flags)
1063
{
1064
  gcc_assert ((flags & SSA_OP_ALL_DEFS) == 0);
1065
  op_iter_init (ptr, stmt, flags);
1066
  ptr->iter_type = ssa_op_iter_use;
1067
  return op_iter_next_use (ptr);
1068
}
1069
 
1070
/* Initialize iterator PTR to the def operands in STMT based on FLAGS. Return
1071
   the first def.  */
1072
static inline def_operand_p
1073
op_iter_init_def (ssa_op_iter *ptr, tree stmt, int flags)
1074
{
1075
  gcc_assert ((flags & (SSA_OP_ALL_USES | SSA_OP_VIRTUAL_KILLS)) == 0);
1076
  op_iter_init (ptr, stmt, flags);
1077
  ptr->iter_type = ssa_op_iter_def;
1078
  return op_iter_next_def (ptr);
1079
}
1080
 
1081
/* Initialize iterator PTR to the operands in STMT based on FLAGS. Return
1082
   the first operand as a tree.  */
1083
static inline tree
1084
op_iter_init_tree (ssa_op_iter *ptr, tree stmt, int flags)
1085
{
1086
  op_iter_init (ptr, stmt, flags);
1087
  ptr->iter_type = ssa_op_iter_tree;
1088
  return op_iter_next_tree (ptr);
1089
}
1090
 
1091
/* Get the next iterator mustdef value for PTR, returning the mustdef values in
1092
   KILL and DEF.  */
1093
static inline void
1094
op_iter_next_maymustdef (use_operand_p *use, def_operand_p *def,
1095
                         ssa_op_iter *ptr)
1096
{
1097
#ifdef ENABLE_CHECKING
1098
  gcc_assert (ptr->iter_type == ssa_op_iter_maymustdef);
1099
#endif
1100
  if (ptr->mayuses)
1101
    {
1102
      *def = MAYDEF_RESULT_PTR (ptr->mayuses);
1103
      *use = MAYDEF_OP_PTR (ptr->mayuses);
1104
      ptr->mayuses = ptr->mayuses->next;
1105
      return;
1106
    }
1107
 
1108
  if (ptr->mustkills)
1109
    {
1110
      *def = MUSTDEF_RESULT_PTR (ptr->mustkills);
1111
      *use = MUSTDEF_KILL_PTR (ptr->mustkills);
1112
      ptr->mustkills = ptr->mustkills->next;
1113
      return;
1114
    }
1115
 
1116
  *def = NULL_DEF_OPERAND_P;
1117
  *use = NULL_USE_OPERAND_P;
1118
  ptr->done = true;
1119
  return;
1120
}
1121
 
1122
 
1123
/* Initialize iterator PTR to the operands in STMT.  Return the first operands
1124
   in USE and DEF.  */
1125
static inline void
1126
op_iter_init_maydef (ssa_op_iter *ptr, tree stmt, use_operand_p *use,
1127
                     def_operand_p *def)
1128
{
1129
  gcc_assert (TREE_CODE (stmt) != PHI_NODE);
1130
 
1131
  op_iter_init (ptr, stmt, SSA_OP_VMAYUSE);
1132
  ptr->iter_type = ssa_op_iter_maymustdef;
1133
  op_iter_next_maymustdef (use, def, ptr);
1134
}
1135
 
1136
 
1137
/* Initialize iterator PTR to the operands in STMT.  Return the first operands
1138
   in KILL and DEF.  */
1139
static inline void
1140
op_iter_init_mustdef (ssa_op_iter *ptr, tree stmt, use_operand_p *kill,
1141
                     def_operand_p *def)
1142
{
1143
  gcc_assert (TREE_CODE (stmt) != PHI_NODE);
1144
 
1145
  op_iter_init (ptr, stmt, SSA_OP_VMUSTKILL);
1146
  ptr->iter_type = ssa_op_iter_maymustdef;
1147
  op_iter_next_maymustdef (kill, def, ptr);
1148
}
1149
 
1150
/* Initialize iterator PTR to the operands in STMT.  Return the first operands
1151
   in KILL and DEF.  */
1152
static inline void
1153
op_iter_init_must_and_may_def (ssa_op_iter *ptr, tree stmt,
1154
                               use_operand_p *kill, def_operand_p *def)
1155
{
1156
  gcc_assert (TREE_CODE (stmt) != PHI_NODE);
1157
 
1158
  op_iter_init (ptr, stmt, SSA_OP_VMUSTKILL|SSA_OP_VMAYUSE);
1159
  ptr->iter_type = ssa_op_iter_maymustdef;
1160
  op_iter_next_maymustdef (kill, def, ptr);
1161
}
1162
 
1163
 
1164
/* If there is a single operand in STMT matching FLAGS, return it.  Otherwise
1165
   return NULL.  */
1166
static inline tree
1167
single_ssa_tree_operand (tree stmt, int flags)
1168
{
1169
  tree var;
1170
  ssa_op_iter iter;
1171
 
1172
  var = op_iter_init_tree (&iter, stmt, flags);
1173
  if (op_iter_done (&iter))
1174
    return NULL_TREE;
1175
  op_iter_next_tree (&iter);
1176
  if (op_iter_done (&iter))
1177
    return var;
1178
  return NULL_TREE;
1179
}
1180
 
1181
 
1182
/* If there is a single operand in STMT matching FLAGS, return it.  Otherwise
1183
   return NULL.  */
1184
static inline use_operand_p
1185
single_ssa_use_operand (tree stmt, int flags)
1186
{
1187
  use_operand_p var;
1188
  ssa_op_iter iter;
1189
 
1190
  var = op_iter_init_use (&iter, stmt, flags);
1191
  if (op_iter_done (&iter))
1192
    return NULL_USE_OPERAND_P;
1193
  op_iter_next_use (&iter);
1194
  if (op_iter_done (&iter))
1195
    return var;
1196
  return NULL_USE_OPERAND_P;
1197
}
1198
 
1199
 
1200
 
1201
/* If there is a single operand in STMT matching FLAGS, return it.  Otherwise
1202
   return NULL.  */
1203
static inline def_operand_p
1204
single_ssa_def_operand (tree stmt, int flags)
1205
{
1206
  def_operand_p var;
1207
  ssa_op_iter iter;
1208
 
1209
  var = op_iter_init_def (&iter, stmt, flags);
1210
  if (op_iter_done (&iter))
1211
    return NULL_DEF_OPERAND_P;
1212
  op_iter_next_def (&iter);
1213
  if (op_iter_done (&iter))
1214
    return var;
1215
  return NULL_DEF_OPERAND_P;
1216
}
1217
 
1218
 
1219
/* If there is a single operand in STMT matching FLAGS, return it.  Otherwise
1220
   return NULL.  */
1221
static inline bool
1222
zero_ssa_operands (tree stmt, int flags)
1223
{
1224
  ssa_op_iter iter;
1225
 
1226
  op_iter_init_tree (&iter, stmt, flags);
1227
  return op_iter_done (&iter);
1228
}
1229
 
1230
 
1231
/* Return the number of operands matching FLAGS in STMT.  */
1232
static inline int
1233
num_ssa_operands (tree stmt, int flags)
1234
{
1235
  ssa_op_iter iter;
1236
  tree t;
1237
  int num = 0;
1238
 
1239
  FOR_EACH_SSA_TREE_OPERAND (t, stmt, iter, flags)
1240
    num++;
1241
  return num;
1242
}
1243
 
1244
 
1245
/* Delink all immediate_use information for STMT.  */
1246
static inline void
1247
delink_stmt_imm_use (tree stmt)
1248
{
1249
   ssa_op_iter iter;
1250
   use_operand_p use_p;
1251
 
1252
   if (ssa_operands_active ())
1253
     FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter,
1254
                               (SSA_OP_ALL_USES | SSA_OP_ALL_KILLS))
1255
       delink_imm_use (use_p);
1256
}
1257
 
1258
 
1259
/* This routine will compare all the operands matching FLAGS in STMT1 to those
1260
   in STMT2.  TRUE is returned if they are the same.  STMTs can be NULL.  */
1261
static inline bool
1262
compare_ssa_operands_equal (tree stmt1, tree stmt2, int flags)
1263
{
1264
  ssa_op_iter iter1, iter2;
1265
  tree op1 = NULL_TREE;
1266
  tree op2 = NULL_TREE;
1267
  bool look1, look2;
1268
 
1269
  if (stmt1 == stmt2)
1270
    return true;
1271
 
1272
  look1 = stmt1 && stmt_ann (stmt1);
1273
  look2 = stmt2 && stmt_ann (stmt2);
1274
 
1275
  if (look1)
1276
    {
1277
      op1 = op_iter_init_tree (&iter1, stmt1, flags);
1278
      if (!look2)
1279
        return op_iter_done (&iter1);
1280
    }
1281
  else
1282
    clear_and_done_ssa_iter (&iter1);
1283
 
1284
  if (look2)
1285
    {
1286
      op2 = op_iter_init_tree (&iter2, stmt2, flags);
1287
      if (!look1)
1288
        return op_iter_done (&iter2);
1289
    }
1290
  else
1291
    clear_and_done_ssa_iter (&iter2);
1292
 
1293
  while (!op_iter_done (&iter1) && !op_iter_done (&iter2))
1294
    {
1295
      if (op1 != op2)
1296
        return false;
1297
      op1 = op_iter_next_tree (&iter1);
1298
      op2 = op_iter_next_tree (&iter2);
1299
    }
1300
 
1301
  return (op_iter_done (&iter1) && op_iter_done (&iter2));
1302
}
1303
 
1304
 
1305
/* If there is a single DEF in the PHI node which matches FLAG, return it.
1306
   Otherwise return NULL_DEF_OPERAND_P.  */
1307
static inline tree
1308
single_phi_def (tree stmt, int flags)
1309
{
1310
  tree def = PHI_RESULT (stmt);
1311
  if ((flags & SSA_OP_DEF) && is_gimple_reg (def))
1312
    return def;
1313
  if ((flags & SSA_OP_VIRTUAL_DEFS) && !is_gimple_reg (def))
1314
    return def;
1315
  return NULL_TREE;
1316
}
1317
 
1318
/* Initialize the iterator PTR for uses matching FLAGS in PHI.  FLAGS should
1319
   be either SSA_OP_USES or SAS_OP_VIRTUAL_USES.  */
1320
static inline use_operand_p
1321
op_iter_init_phiuse (ssa_op_iter *ptr, tree phi, int flags)
1322
{
1323
  tree phi_def = PHI_RESULT (phi);
1324
  int comp;
1325
 
1326
  clear_and_done_ssa_iter (ptr);
1327
  ptr->done = false;
1328
 
1329
  gcc_assert ((flags & (SSA_OP_USE | SSA_OP_VIRTUAL_USES)) != 0);
1330
 
1331
  comp = (is_gimple_reg (phi_def) ? SSA_OP_USE : SSA_OP_VIRTUAL_USES);
1332
 
1333
  /* If the PHI node doesn't the operand type we care about, we're done.  */
1334
  if ((flags & comp) == 0)
1335
    {
1336
      ptr->done = true;
1337
      return NULL_USE_OPERAND_P;
1338
    }
1339
 
1340
  ptr->phi_stmt = phi;
1341
  ptr->num_phi = PHI_NUM_ARGS (phi);
1342
  ptr->iter_type = ssa_op_iter_use;
1343
  return op_iter_next_use (ptr);
1344
}
1345
 
1346
 
1347
/* Start an iterator for a PHI definition.  */
1348
 
1349
static inline def_operand_p
1350
op_iter_init_phidef (ssa_op_iter *ptr, tree phi, int flags)
1351
{
1352
  tree phi_def = PHI_RESULT (phi);
1353
  int comp;
1354
 
1355
  clear_and_done_ssa_iter (ptr);
1356
  ptr->done = false;
1357
 
1358
  gcc_assert ((flags & (SSA_OP_DEF | SSA_OP_VIRTUAL_DEFS)) != 0);
1359
 
1360
  comp = (is_gimple_reg (phi_def) ? SSA_OP_DEF : SSA_OP_VIRTUAL_DEFS);
1361
 
1362
  /* If the PHI node doesn't the operand type we care about, we're done.  */
1363
  if ((flags & comp) == 0)
1364
    {
1365
      ptr->done = true;
1366
      return NULL_USE_OPERAND_P;
1367
    }
1368
 
1369
  ptr->iter_type = ssa_op_iter_def;
1370
  /* The first call to op_iter_next_def will terminate the iterator since
1371
     all the fields are NULL.  Simply return the result here as the first and
1372
     therefore only result.  */
1373
  return PHI_RESULT_PTR (phi);
1374
}
1375
 
1376
 
1377
 
1378
/* Return true if VAR cannot be modified by the program.  */
1379
 
1380
static inline bool
1381
unmodifiable_var_p (tree var)
1382
{
1383
  if (TREE_CODE (var) == SSA_NAME)
1384
    var = SSA_NAME_VAR (var);
1385
  return TREE_READONLY (var) && (TREE_STATIC (var) || DECL_EXTERNAL (var));
1386
}
1387
 
1388
/* Return true if REF, an ARRAY_REF, has an INDIRECT_REF somewhere in it.  */
1389
 
1390
static inline bool
1391
array_ref_contains_indirect_ref (tree ref)
1392
{
1393
  gcc_assert (TREE_CODE (ref) == ARRAY_REF);
1394
 
1395
  do {
1396
    ref = TREE_OPERAND (ref, 0);
1397
  } while (handled_component_p (ref));
1398
 
1399
  return TREE_CODE (ref) == INDIRECT_REF;
1400
}
1401
 
1402
/* Return true if REF, a handled component reference, has an ARRAY_REF
1403
   somewhere in it.  */
1404
 
1405
static inline bool
1406
ref_contains_array_ref (tree ref)
1407
{
1408
  gcc_assert (handled_component_p (ref));
1409
 
1410
  do {
1411
    if (TREE_CODE (ref) == ARRAY_REF)
1412
      return true;
1413
    ref = TREE_OPERAND (ref, 0);
1414
  } while (handled_component_p (ref));
1415
 
1416
  return false;
1417
}
1418
 
1419
/* Given a variable VAR, lookup and return a pointer to the list of
1420
   subvariables for it.  */
1421
 
1422
static inline subvar_t *
1423
lookup_subvars_for_var (tree var)
1424
{
1425
  var_ann_t ann = var_ann (var);
1426
  gcc_assert (ann);
1427
  return &ann->subvars;
1428
}
1429
 
1430
/* Given a variable VAR, return a linked list of subvariables for VAR, or
1431
   NULL, if there are no subvariables.  */
1432
 
1433
static inline subvar_t
1434
get_subvars_for_var (tree var)
1435
{
1436
  subvar_t subvars;
1437
 
1438
  gcc_assert (SSA_VAR_P (var));
1439
 
1440
  if (TREE_CODE (var) == SSA_NAME)
1441
    subvars = *(lookup_subvars_for_var (SSA_NAME_VAR (var)));
1442
  else
1443
    subvars = *(lookup_subvars_for_var (var));
1444
  return subvars;
1445
}
1446
 
1447
/* Return the subvariable of VAR at offset OFFSET.  */
1448
 
1449
static inline tree
1450
get_subvar_at (tree var, unsigned HOST_WIDE_INT offset)
1451
{
1452
  subvar_t sv;
1453
 
1454
  for (sv = get_subvars_for_var (var); sv; sv = sv->next)
1455
    if (sv->offset == offset)
1456
      return sv->var;
1457
 
1458
  return NULL_TREE;
1459
}
1460
 
1461
/* Return true if V is a tree that we can have subvars for.
1462
   Normally, this is any aggregate type, however, due to implementation
1463
   limitations ATM, we exclude array types as well.  */
1464
 
1465
static inline bool
1466
var_can_have_subvars (tree v)
1467
{
1468
  /* Volatile variables should never have subvars.  */
1469
  if (TREE_THIS_VOLATILE (v))
1470
    return false;
1471
 
1472
  return (AGGREGATE_TYPE_P (TREE_TYPE (v)) &&
1473
          TREE_CODE (TREE_TYPE (v)) != ARRAY_TYPE);
1474
}
1475
 
1476
 
1477
/* Return true if OFFSET and SIZE define a range that overlaps with some
1478
   portion of the range of SV, a subvar.  If there was an exact overlap,
1479
   *EXACT will be set to true upon return. */
1480
 
1481
static inline bool
1482
overlap_subvar (unsigned HOST_WIDE_INT offset, unsigned HOST_WIDE_INT size,
1483
                subvar_t sv,  bool *exact)
1484
{
1485
  /* There are three possible cases of overlap.
1486
     1. We can have an exact overlap, like so:
1487
     |offset, offset + size             |
1488
     |sv->offset, sv->offset + sv->size |
1489
 
1490
     2. We can have offset starting after sv->offset, like so:
1491
 
1492
           |offset, offset + size              |
1493
     |sv->offset, sv->offset + sv->size  |
1494
 
1495
     3. We can have offset starting before sv->offset, like so:
1496
 
1497
     |offset, offset + size    |
1498
       |sv->offset, sv->offset + sv->size|
1499
  */
1500
 
1501
  if (exact)
1502
    *exact = false;
1503
  if (offset == sv->offset && size == sv->size)
1504
    {
1505
      if (exact)
1506
        *exact = true;
1507
      return true;
1508
    }
1509
  else if (offset >= sv->offset && offset < (sv->offset + sv->size))
1510
    {
1511
      return true;
1512
    }
1513
  else if (offset < sv->offset && (size > sv->offset - offset))
1514
    {
1515
      return true;
1516
    }
1517
  return false;
1518
 
1519
}
1520
 
1521
#endif /* _TREE_FLOW_INLINE_H  */

powered by: WebSVN 2.1.0

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