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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [g++.dg/] [tree-ssa/] [pr16688.C] - Blame information for rev 693

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 693 jeremybenn
/* PR 16688.  Test provided by Wolfgang Bangerth.  The alias analyzer
2
   was aborting when trying to group aliases.  */
3
 
4
/* { dg-do compile } */
5
/* { dg-options "-O2" } */
6
 
7
template
8
struct iterator_traits;
9
 
10
template
11
struct iterator_traits<_Tp*> {
12
    typedef _Tp& reference;
13
};
14
 
15
template struct NI {
16
    _Iterator current;
17
 
18
    typedef typename iterator_traits<_Iterator>::reference reference;
19
 
20
    NI() { }
21
 
22
    NI(const _Iterator& __i) : current(__i) { }
23
 
24
    reference operator*() const { return *current; }
25
 
26
    NI& operator++() { return *this; }
27
 
28
    const _Iterator& base() const { return current; }
29
};
30
 
31
template
32
inline int
33
operator-(const NI<_IteratorL>& __lhs,
34
          const NI<_IteratorR>& __rhs)
35
{ return __lhs.base() - __rhs.base(); }
36
 
37
 
38
template
39
inline _OI
40
__copy_aux(_II __first, _II __last, _OI __result)
41
{
42
  struct __copy {
43
      static _OI
44
      copy(_II __first, _II __last, _OI __result)
45
        {
46
          for (; __first != __last; ++__result, ++__first)
47
            *__result = *__first;
48
          return __result;
49
        }
50
  };
51
 
52
  return __copy::copy(__first, __last, __result);
53
}
54
 
55
struct __copy_normal
56
{
57
    template
58
    static _OI
59
    copy_n(_II __first, _II __last, _OI __result)
60
      {
61
        return __copy_aux(__first, __last, __result);
62
      }
63
};
64
template
65
inline _OutputIterator
66
copy(_InputIterator __first, _InputIterator __last,
67
     _OutputIterator __result)
68
{
69
  return __copy_normal::copy_n(__first, __last, __result);
70
}
71
 
72
template 
73
void uninitialized_fill_n(T,U,V);
74
 
75
 
76
template
77
struct _Vector_base {
78
    struct _Vector_impl {
79
        _Tp* start;
80
        _Tp* finish;
81
        _Tp* end_of_storage;
82
        _Vector_impl() : start(0), finish(0), end_of_storage(0)
83
          { }
84
    } impl;
85
 
86
    _Vector_base(unsigned __n) {
87
      impl.start = allocate(__n);
88
      impl.finish = impl.start;
89
      impl.end_of_storage = impl.start + __n;
90
    }
91
 
92
    ~_Vector_base() {
93
      deallocate(impl.start,
94
                    impl.end_of_storage - impl.start);
95
    }
96
 
97
    _Tp* allocate(unsigned __n);
98
 
99
    void deallocate(_Tp* __p, unsigned __n);
100
 
101
    NI<_Tp*> begin() { return NI<_Tp*> (impl.start); }
102
};
103
 
104
 
105
template
106
struct vector : _Vector_base<_Tp>
107
{
108
    vector(int __n)
109
                    : _Vector_base<_Tp>(__n)
110
      {
111
        uninitialized_fill_n(this->impl.start, __n, _Tp());
112
      }
113
};
114
 
115
 
116
 
117
struct Tensor
118
{
119
    Tensor ();
120
    Tensor (const Tensor &);
121
 
122
    double values[2];
123
};
124
 
125
 
126
inline
127
Tensor::Tensor (const Tensor &p)
128
{
129
  for (unsigned int i=0; i<2; ++i)
130
    values[i] = p.values[i];
131
}
132
 
133
 
134
struct TriaAccessor
135
{
136
    typedef void * AccessorData;
137
 
138
    void copy_from (const TriaAccessor &);
139
    void operator = (const TriaAccessor *);
140
 
141
    TriaAccessor & operator = (const TriaAccessor &);
142
 
143
    bool operator == (const TriaAccessor &) const;
144
 
145
    bool operator != (const TriaAccessor &) const;
146
    void operator ++ ();
147
 
148
    int state () const;
149
    bool used () const;
150
 
151
    int present_level;
152
    int present_index;
153
    int** levels;
154
};
155
 
156
inline int TriaAccessor::state () const {
157
  if ((present_level>=0) && (present_index>=0))
158
    return 0;
159
  else
160
    if ((present_level==-1) && (present_index==-1))
161
      return 1;
162
    else
163
      return 2;
164
}
165
 
166
 
167
inline
168
void TriaAccessor::operator ++ () {
169
  ++this->present_index;
170
 
171
  while (this->present_index >=
172
         static_cast(*this->levels[this->present_level]))
173
    {
174
      ++this->present_level;
175
      this->present_index = 0;
176
 
177
      if (this->present_level >= static_cast(1))
178
        {
179
 
180
          this->present_level = this->present_index = -1;
181
          return;
182
        }
183
    }
184
}
185
 
186
struct MGDoFObjectAccessor : TriaAccessor {};
187
 
188
 
189
 
190
struct TriaRawIterator
191
{
192
    TriaRawIterator ();
193
 
194
    TriaRawIterator (const TriaRawIterator &);
195
    TriaRawIterator (const MGDoFObjectAccessor &a);
196
    const MGDoFObjectAccessor & operator * () const;
197
 
198
    MGDoFObjectAccessor & operator * ();
199
    const MGDoFObjectAccessor * operator -> () const;
200
 
201
    MGDoFObjectAccessor * operator -> ();
202
 
203
    TriaRawIterator & operator = (const TriaRawIterator &);
204
 
205
    bool operator == (const TriaRawIterator &) const;
206
    bool operator != (const TriaRawIterator &) const;
207
    bool operator < (const TriaRawIterator &) const;
208
    MGDoFObjectAccessor accessor;
209
 
210
    TriaRawIterator & operator ++ ();
211
};
212
 
213
struct TriaIterator : TriaRawIterator
214
{
215
    TriaIterator ();
216
 
217
    TriaIterator (const TriaIterator &i);
218
 
219
    TriaIterator &
220
    operator = (const TriaIterator &);
221
 
222
    TriaIterator &
223
    operator = (const TriaRawIterator &);
224
};
225
 
226
 
227
inline
228
TriaRawIterator::TriaRawIterator (const TriaRawIterator &i) :
229
                accessor (i.accessor) {}
230
 
231
inline
232
TriaIterator::TriaIterator (const TriaIterator &i) :
233
                TriaRawIterator (static_cast(i)) {}
234
 
235
inline
236
TriaRawIterator & TriaRawIterator::operator ++ () {
237
  while (++accessor, (this->accessor.state() == 0))
238
    if (this->accessor.used() == true)
239
      return *this;
240
  return *this;
241
}
242
 
243
struct Comp {
244
    Comp (const Tensor &dir) : dir(dir) {}
245
 
246
    bool operator () (const TriaIterator &c1, const TriaIterator &c2) const;
247
    const Tensor dir;
248
};
249
 
250
 
251
template
252
void x1(Iter first, Iter last, int i, Comp comp)
253
{
254
  x1(Iter(), last, i, comp);
255
}
256
 
257
template
258
inline void x2(Iter first, Iter last, Comp comp)
259
{
260
  if (first.base() != last.base())
261
    x1(first, last, (last - first), comp);
262
}
263
 
264
void downstream_dg (const Tensor& direction)
265
{
266
  vector ordered_cells(13);
267
  const Comp comparator(direction);
268
 
269
  TriaIterator begin, end;
270
 
271
  copy (begin, end, ordered_cells.begin());
272
  x2 (ordered_cells.begin(), ordered_cells.begin(), comparator);
273
}

powered by: WebSVN 2.1.0

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