IPSDK  4_1_0_2
IPSDK : Image Processing Software Development Kit
FrexpReg.h
Go to the documentation of this file.
1 // FrexpReg.h:
3 // -------------------
4 //
13 
14 #ifndef __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_COMMON_FREXPREG_H__
15 #define __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_COMMON_FREXPREG_H__
16 
27 
28 namespace ipsdk {
29 namespace simd {
30 namespace detail {
31 
34 
36 template <eInstructionSet::domain IS>
37 struct FrexpReg<IS, ipReal32>
38 {
39  static IPSDK_FORCEINLINE
41  act(const typename RegType<IS, ipReal32>::Type& in,
42  typename RegType<IS, ipInt32>::Type& e)
43  {
44  typename RegType<IS, ipReal32>::Type m;
45  act(in, m, e);
46  return m;
47  }
48 
49  static IPSDK_FORCEINLINE
50  void
51  act(const typename RegType<IS, ipReal32>::Type& in,
52  typename RegType<IS, ipReal32>::Type& m,
53  typename RegType<IS, ipInt32>::Type& e)
54  {
55  typedef typename RegType<IS, ipReal32>::Type RegReal32;
56  typedef typename RegType<IS, ipInt32>::Type RegInt32;
57 
58  const ipInt32 scalarMask1 = 0x7F800000;
59  const ipInt32 scalarMask2 = 0x3F000000;
60  const ipInt32 scalar126 = 0x7E;
61 
62  RegInt32 r126;
63  RegReal32 tmp, mask1, mask2, eReal32;
64 
65  AssignReg<IS, ipReal32>::act(mask1, *reinterpret_cast<const ipReal32*>(&scalarMask1));
66  AssignReg<IS, ipReal32>::act(mask2, *reinterpret_cast<const ipReal32*>(&scalarMask2));
67  AssignReg<IS, ipInt32>::act(r126, 0x7E);
68 
69  BitwiseAndReg<IS, ipReal32>::act(in, mask1, eReal32);
71 
74  SubReg<IS, ipInt32>::act(e, r126, e);
75 
76  BitwiseOrReg<IS, ipReal32>::act(tmp, mask2, m);
77  }
78 
79  static IPSDK_FORCEINLINE
80  void
81  act(const typename RegType<IS, ipReal32>::Type& in,
82  typename RegType<IS, ipReal32>::Type& m,
83  typename RegType<IS, ipReal32>::Type& e)
84  {
85  typedef typename RegType<IS, ipReal32>::Type RegReal32;
86  typedef typename RegType<IS, ipInt32>::Type RegInt32;
87 
88  const ipInt32 scalarMask1 = 0x7F800000;
89  const ipInt32 scalarMask2 = 0x3F000000;
90  const ipInt32 scalar126 = 0x7E;
91  RegReal32 mask1, mask2, r126, tmp;
92 
93  AssignReg<IS, ipReal32>::act(mask1, *reinterpret_cast<const ipReal32*>(&scalarMask1));
94  AssignReg<IS, ipReal32>::act(mask2, *reinterpret_cast<const ipReal32*>(&scalarMask2));
95  AssignReg<IS, ipReal32>::act(r126, *reinterpret_cast<const ipReal32*>(&scalar126));
96 
98 
101  SubReg<IS, ipReal32>::act(e, r126, e);
102 
103  BitwiseOrReg<IS, ipReal32>::act(tmp, mask2, m);
104  }
105 };
106 
108 template <eInstructionSet::domain IS>
109 struct FrexpReg<IS, ipReal64>
110 {
111  static const ipInt64 s_scalarMask1 = 0x7FF0000000000000;
112  static const ipInt64 s_scalarMask2 = 0x3FE0000000000000;
113  static const ipInt64 s_scalar1022 = 1022;
114  static const ipInt32 s_nbBitsInMantissa = 52;
115 
116  static IPSDK_FORCEINLINE
118  act(const typename RegType<IS, ipReal64>::Type& in,
119  typename RegType<IS, ipInt64>::Type& e)
120  {
121  typename RegType<IS, ipReal64>::Type m;
122  act(in, m, e);
123  return m;
124  }
125 
126  static IPSDK_FORCEINLINE
127  void
128  act(const typename RegType<IS, ipReal64>::Type& in,
129  typename RegType<IS, ipReal64>::Type& m,
130  typename RegType<IS, ipInt64>::Type& e)
131  {
132  typedef typename RegType<IS, ipReal64>::Type RegReal64;
133  typedef typename RegType<IS, ipInt64>::Type RegInt64;
134 
135  RegInt64 r1022;
136  RegReal64 tmp, mask1, mask2, eReal64;
137 
138  AssignReg<IS, ipReal64>::act(mask1, *reinterpret_cast<const ipReal64*>(&s_scalarMask1));
139  AssignReg<IS, ipReal64>::act(mask2, *reinterpret_cast<const ipReal64*>(&s_scalarMask2));
140  AssignReg<IS, ipInt64>::act(r1022, s_scalar1022);
141 
142  BitwiseAndReg<IS, ipReal64>::act(in, mask1, eReal64);
144 
145  BitwiseAndNotReg<IS, ipReal64>::act(in, mask1, tmp);
146  ShiftRightReg<IS, ipInt64>::act(e, s_nbBitsInMantissa, e);
147  SubReg<IS, ipInt64>::act(e, r1022, e);
148 
149  BitwiseOrReg<IS, ipReal64>::act(tmp, mask2, m);
150  }
151 
152  static IPSDK_FORCEINLINE
153  void
154  act(const typename RegType<IS, ipReal64>::Type& in,
155  typename RegType<IS, ipReal64>::Type& m,
156  typename RegType<IS, ipReal64>::Type& e)
157  {
158  typedef typename RegType<IS, ipReal64>::Type RegReal64;
159  typedef typename RegType<IS, ipInt64>::Type RegInt64;
160 
161  RegReal64 mask1, mask2, r126, tmp;
162 
163  AssignReg<IS, ipReal64>::act(mask1, *reinterpret_cast<const ipReal64*>(&s_scalarMask1));
164  AssignReg<IS, ipReal64>::act(mask2, *reinterpret_cast<const ipReal64*>(&s_scalarMask2));
165  AssignReg<IS, ipReal64>::act(r126, *reinterpret_cast<const ipReal64*>(&s_scalar1022));
166 
167  BitwiseAndReg<IS, ipReal64>::act(in, mask1, e);
168 
169  BitwiseAndNotReg<IS, ipReal64>::act(in, mask1, tmp);
171  SubReg<IS, ipReal64>::act(e, r126, e);
172 
173  BitwiseOrReg<IS, ipReal64>::act(tmp, mask2, m);
174  }
175 };
176 
179 
180 } // end of namespace detail
181 } // end of namespace simd
182 } // end of namespace ipsdk
183 
184 #endif // __IPSDKUTIL_INSTRUCTIONSET_ARITHMETIC_DETAIL_COMMON_FREXPREG_H__
Defines the IPSDK_FORCEINLINE.
Main namespace for IPSDK library.
Definition: AlgorithmFunctionEfficiency.h:22
Definition: BitwiseAndNotReg.h:30
Definition: SubReg.h:39
template structure which is specialized to implement the decomposition of input floating value f into...
Definition: FrexpReg.h:37
double ipReal64
Base types definition.
Definition: BaseTypes.h:57
int32_t ipInt32
Base types definition.
Definition: BaseTypes.h:52
RegType class.
Definition: BitwiseOrReg.h:30
Definition of import/export macro for library.
Definition: BitwiseCastReg.h:29
Definition: ShiftRightReg.h:30
int64_t ipInt64
Base types definition.
Definition: BaseTypes.h:54
Definition: RegType.h:29
Definition: BitwiseAndReg.h:30
Definition: AssignRegDecl.h:31
float ipReal32
Base types definition.
Definition: BaseTypes.h:56