summaryrefslogtreecommitdiff
path: root/gcc/ssa-range-stmt.h
blob: 4c3de26c5410a4461ec7a4b8ed252dd94b0c996e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* Header file for ssa-range generator stmt msummary.
   Copyright (C) 2017 Free Software Foundation, Inc.
   Contributed by Andrew MacLeod <amacleod@redhat.com>.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */

#ifndef GCC_SSA_RANGE_STMT_H
#define GCC_SSA_RANGE_STMT_H

#include "range.h"
#include "range-op.h"

/* This class is used summarize expressions that are supported by the
   irange_operator class.  

   A gimple stmt can be summarized and cached if it is supported.

   And expression can also be resolved to a range if required information
   is provided.  */



class range_stmt
{
private:
  gimple *g;
  tree_code code;
  tree op1, op2;
  tree ssa1, ssa2;
  bool validate_operands ();
  void from_stmt (gimple *s);
  class irange_operator *handler() const;
public:
  range_stmt ();
  range_stmt (gimple *stmt);
  range_stmt &operator= (gimple *stmt);

  bool valid () const;
  gimple *get_gimple () const;
  tree_code get_code () const;

  tree operand1 () const;
  tree operand2 () const;

  tree ssa_operand1 () const;
  tree ssa_operand2 () const;

  bool logical_expr_p (tree type) const;
  bool logical_expr (irange& r, const irange& lhs, const irange& op1_true,
  		     const irange& op1_false, const irange& op2_true,
		     const irange& op2_false);
  bool fold (irange& res) const;
  bool fold (irange& res, tree name, const irange& name_range) const;
  bool fold (irange& res, const irange& r1) const;
  bool fold (irange& res, const irange& r1, const irange& r2) const;
  bool op1_irange (irange& r, const irange& lhs_range) const;
  bool op1_irange (irange& r, const irange& lhs_range,
		   const irange& op2_range) const;
  bool op2_irange (irange& r, const irange& lhs_range,
		   const irange& op1_range) const;


  void dump (FILE *f) const;
};

bool get_operand_range (irange& r, tree op);

inline gimple *
range_stmt::get_gimple () const
{
  return g;
}

inline bool
range_stmt::valid () const
{
  return g != NULL;
}

inline tree_code
range_stmt::get_code () const
{
  return code;
}

inline tree
range_stmt::operand1 () const
{
  return op1;
}

inline tree
range_stmt::operand2 () const
{
  return op2;
}

inline tree
range_stmt::ssa_operand1() const
{
  return ssa1;
}

inline tree
range_stmt::ssa_operand2 () const
{
  return ssa2;
}

static inline
tree valid_irange_ssa (tree t)
{
  if (t && TREE_CODE (t) == SSA_NAME)
    {
      tree type = TREE_TYPE (t);
      if (INTEGRAL_TYPE_P (type) || POINTER_TYPE_P (type))
        return t;
    }
  return NULL_TREE;
}

#endif /* GCC_SSA_RANGE_STMT_H */