ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
aliasingentryhelper.h
Go to the documentation of this file.
1 /* This file is part of the Vc library.
2 
3  Copyright (C) 2010-2011 Matthias Kretz <kretz@kde.org>
4 
5  Vc is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as
7  published by the Free Software Foundation, either version 3 of
8  the License, or (at your option) any later version.
9 
10  Vc is distributed in the hope that it will be useful, but
11  WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with Vc. If not, see <http://www.gnu.org/licenses/>.
17 
18 */
19 
20 #ifndef VC_COMMON_ALIASINGENTRYHELPER_H
21 #define VC_COMMON_ALIASINGENTRYHELPER_H
22 
23 #include "macros.h"
24 
25 namespace ROOT {
26 namespace Vc
27 {
28 namespace Common
29 {
30 
31 template<class StorageType> class AliasingEntryHelper
32 {
33  private:
34  typedef typename StorageType::EntryType T;
35 #ifdef VC_ICC
36  StorageType *const m_storage;
37  const int m_index;
38  public:
39  Vc_ALWAYS_INLINE AliasingEntryHelper(StorageType *d, int index) : m_storage(d), m_index(index) {}
40  Vc_ALWAYS_INLINE AliasingEntryHelper(const AliasingEntryHelper &rhs) : m_storage(rhs.m_storage), m_index(rhs.m_index) {}
42  m_storage->assign(m_index, rhs);
43  return *this;
44  }
45 
46  Vc_ALWAYS_INLINE AliasingEntryHelper &operator =(T x) { m_storage->assign(m_index, x); return *this; }
47  Vc_ALWAYS_INLINE AliasingEntryHelper &operator +=(T x) { m_storage->assign(m_index, m_storage->m(m_index) + x); return *this; }
48  Vc_ALWAYS_INLINE AliasingEntryHelper &operator -=(T x) { m_storage->assign(m_index, m_storage->m(m_index) - x); return *this; }
49  Vc_ALWAYS_INLINE AliasingEntryHelper &operator /=(T x) { m_storage->assign(m_index, m_storage->m(m_index) / x); return *this; }
50  Vc_ALWAYS_INLINE AliasingEntryHelper &operator *=(T x) { m_storage->assign(m_index, m_storage->m(m_index) * x); return *this; }
51  Vc_ALWAYS_INLINE AliasingEntryHelper &operator |=(T x) { m_storage->assign(m_index, m_storage->m(m_index) | x); return *this; }
52  Vc_ALWAYS_INLINE AliasingEntryHelper &operator &=(T x) { m_storage->assign(m_index, m_storage->m(m_index) & x); return *this; }
53  Vc_ALWAYS_INLINE AliasingEntryHelper &operator ^=(T x) { m_storage->assign(m_index, m_storage->m(m_index) ^ x); return *this; }
54  Vc_ALWAYS_INLINE AliasingEntryHelper &operator %=(T x) { m_storage->assign(m_index, m_storage->m(m_index) % x); return *this; }
55  Vc_ALWAYS_INLINE AliasingEntryHelper &operator<<=(T x) { m_storage->assign(m_index, m_storage->m(m_index)<< x); return *this; }
56  Vc_ALWAYS_INLINE AliasingEntryHelper &operator>>=(T x) { m_storage->assign(m_index, m_storage->m(m_index)>> x); return *this; }
57 
58  Vc_ALWAYS_INLINE AliasingEntryHelper &operator++() { m_storage->assign(m_index, m_storage->m(m_index) + T(1)); return *this; }
59  Vc_ALWAYS_INLINE T operator++(int) { T r = m_storage->m(m_index); m_storage->assign(m_index, m_storage->m(m_index) + T(1)); return r; }
60  Vc_ALWAYS_INLINE AliasingEntryHelper &operator--() { m_storage->assign(m_index, m_storage->m(m_index) - T(1)); return *this; }
61  Vc_ALWAYS_INLINE T operator--(int) { T r = m_storage->m(m_index); m_storage->assign(m_index, m_storage->m(m_index) - T(1)); return r; }
62 #define m_data m_storage->read(m_index)
63 #else
64  typedef T A Vc_MAY_ALIAS;
66  public:
67  template<typename T2>
68  Vc_ALWAYS_INLINE AliasingEntryHelper(T2 &d) : m_data(reinterpret_cast<A &>(d)) {}
69 
72  m_data = rhs.m_data;
73  return *this;
74  }
75 
87 
89  Vc_ALWAYS_INLINE T operator++(int) { T r = m_data; ++m_data; return r; }
91  Vc_ALWAYS_INLINE T operator--(int) { T r = m_data; --m_data; return r; }
92 #endif
93 
94  Vc_ALWAYS_INLINE Vc_PURE operator const T() const { return m_data; }
95 
96  Vc_ALWAYS_INLINE Vc_PURE bool operator==(T x) const { return static_cast<T>(m_data) == x; }
97  Vc_ALWAYS_INLINE Vc_PURE bool operator!=(T x) const { return static_cast<T>(m_data) != x; }
98  Vc_ALWAYS_INLINE Vc_PURE bool operator<=(T x) const { return static_cast<T>(m_data) <= x; }
99  Vc_ALWAYS_INLINE Vc_PURE bool operator>=(T x) const { return static_cast<T>(m_data) >= x; }
100  Vc_ALWAYS_INLINE Vc_PURE bool operator< (T x) const { return static_cast<T>(m_data) < x; }
101  Vc_ALWAYS_INLINE Vc_PURE bool operator> (T x) const { return static_cast<T>(m_data) > x; }
102 
103  Vc_ALWAYS_INLINE Vc_PURE T operator-() const { return -static_cast<T>(m_data); }
104  Vc_ALWAYS_INLINE Vc_PURE T operator~() const { return ~static_cast<T>(m_data); }
105  Vc_ALWAYS_INLINE Vc_PURE T operator+(T x) const { return static_cast<T>(m_data) + x; }
106  Vc_ALWAYS_INLINE Vc_PURE T operator-(T x) const { return static_cast<T>(m_data) - x; }
107  Vc_ALWAYS_INLINE Vc_PURE T operator/(T x) const { return static_cast<T>(m_data) / x; }
108  Vc_ALWAYS_INLINE Vc_PURE T operator*(T x) const { return static_cast<T>(m_data) * x; }
109  Vc_ALWAYS_INLINE Vc_PURE T operator|(T x) const { return static_cast<T>(m_data) | x; }
110  Vc_ALWAYS_INLINE Vc_PURE T operator&(T x) const { return static_cast<T>(m_data) & x; }
111  Vc_ALWAYS_INLINE Vc_PURE T operator^(T x) const { return static_cast<T>(m_data) ^ x; }
112  Vc_ALWAYS_INLINE Vc_PURE T operator%(T x) const { return static_cast<T>(m_data) % x; }
113  //T operator<<(T x) const { return static_cast<T>(m_data) << x; }
114  //T operator>>(T x) const { return static_cast<T>(m_data) >> x; }
115 #ifdef m_data
116 #undef m_data
117 #endif
118 };
119 
120 } // namespace Common
121 } // namespace Vc
122 } // namespace ROOT
123 
124 #include "undomacros.h"
125 
126 #endif // VC_COMMON_ALIASINGENTRYHELPER_H
Vc_ALWAYS_INLINE AliasingEntryHelper & operator<<=(T x)
Vc_ALWAYS_INLINE AliasingEntryHelper & operator+=(T x)
Vc_ALWAYS_INLINE Vc_PURE T operator^(T x) const
Vc_ALWAYS_INLINE AliasingEntryHelper & operator=(const AliasingEntryHelper &rhs)
Vc_ALWAYS_INLINE Vc_PURE T operator+(T x) const
Vc_ALWAYS_INLINE Vc_PURE T operator-(T x) const
Vc_ALWAYS_INLINE AliasingEntryHelper & operator*=(T x)
Vc_ALWAYS_INLINE AliasingEntryHelper & operator>>=(T x)
Vc_ALWAYS_INLINE AliasingEntryHelper & operator%=(T x)
Vc_ALWAYS_INLINE AliasingEntryHelper & operator|=(T x)
static double A[]
Vc_ALWAYS_INLINE AliasingEntryHelper & operator-=(T x)
Double_t x[n]
Definition: legend1.C:17
int d
Definition: tornado.py:11
Vc_ALWAYS_INLINE Vc_PURE T operator~() const
Vc_ALWAYS_INLINE AliasingEntryHelper & operator--()
#define Vc_PURE
Definition: macros.h:136
Vc_ALWAYS_INLINE Vc_PURE bool operator!=(T x) const
Vc_ALWAYS_INLINE Vc_PURE T operator-() const
Vc_ALWAYS_INLINE AliasingEntryHelper & operator^=(T x)
ROOT::R::TRInterface & r
Definition: Object.C:4
Vc_ALWAYS_INLINE Vc_PURE bool operator>(T x) const
Vc_ALWAYS_INLINE AliasingEntryHelper & operator/=(T x)
Vc_ALWAYS_INLINE Vc_PURE bool operator<(T x) const
Vc_ALWAYS_INLINE AliasingEntryHelper & operator&=(T x)
Vc_ALWAYS_INLINE Vc_PURE bool operator>=(T x) const
Vc_ALWAYS_INLINE Vc_PURE bool operator<=(T x) const
#define Vc_ALWAYS_INLINE
Definition: macros.h:130
#define T2
Definition: md5.inl:146
Vc_ALWAYS_INLINE Vc_PURE T operator*(T x) const
Vc_ALWAYS_INLINE Vc_PURE T operator/(T x) const
Vc_ALWAYS_INLINE Vc_PURE T operator|(T x) const
Vc_ALWAYS_INLINE Vc_PURE bool operator==(T x) const
Vc_ALWAYS_INLINE AliasingEntryHelper(T2 &d)
Vc_ALWAYS_INLINE AliasingEntryHelper & operator++()
Vc_ALWAYS_INLINE Vc_PURE T operator&(T x) const
Vc_ALWAYS_INLINE Vc_PURE T operator%(T x) const