Initial commit to Gerrit
[profile/ivi/orc.git] / orc / orcfunctions.c
1
2 /* autogenerated from orcfunctions.orc */
3
4 #ifdef HAVE_CONFIG_H
5 #include "config.h"
6 #endif
7 #ifndef DISABLE_ORC
8 #include <orc/orc.h>
9 #endif
10
11 #ifndef _ORC_INTEGER_TYPEDEFS_
12 #define _ORC_INTEGER_TYPEDEFS_
13 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
14 #include <stdint.h>
15 typedef int8_t orc_int8;
16 typedef int16_t orc_int16;
17 typedef int32_t orc_int32;
18 typedef int64_t orc_int64;
19 typedef uint8_t orc_uint8;
20 typedef uint16_t orc_uint16;
21 typedef uint32_t orc_uint32;
22 typedef uint64_t orc_uint64;
23 #define ORC_UINT64_C(x) UINT64_C(x)
24 #elif defined(_MSC_VER)
25 typedef signed __int8 orc_int8;
26 typedef signed __int16 orc_int16;
27 typedef signed __int32 orc_int32;
28 typedef signed __int64 orc_int64;
29 typedef unsigned __int8 orc_uint8;
30 typedef unsigned __int16 orc_uint16;
31 typedef unsigned __int32 orc_uint32;
32 typedef unsigned __int64 orc_uint64;
33 #define ORC_UINT64_C(x) (x##Ui64)
34 #else
35 #include <limits.h>
36 typedef signed char orc_int8;
37 typedef short orc_int16;
38 typedef int orc_int32;
39 typedef unsigned char orc_uint8;
40 typedef unsigned short orc_uint16;
41 typedef unsigned int orc_uint32;
42 #if INT_MAX == LONG_MAX
43 typedef long long orc_int64;
44 typedef unsigned long long orc_uint64;
45 #define ORC_UINT64_C(x) (x##ULL)
46 #else
47 typedef long orc_int64;
48 typedef unsigned long orc_uint64;
49 #define ORC_UINT64_C(x) (x##UL)
50 #endif
51 #endif
52 typedef union { orc_int16 i; orc_int8 x2[2]; } orc_union16;
53 typedef union { orc_int32 i; float f; orc_int16 x2[2]; orc_int8 x4[4]; } orc_union32;
54 typedef union { orc_int64 i; double f; orc_int32 x2[2]; float x2f[2]; orc_int16 x4[4]; } orc_union64;
55 #endif
56
57 void orc_memcpy (void * d1, const void * s1, int n);
58 void orc_memset (void * d1, int p1, int n);
59
60
61 /* begin Orc C target preamble */
62 #define ORC_CLAMP(x,a,b) ((x)<(a) ? (a) : ((x)>(b) ? (b) : (x)))
63 #define ORC_ABS(a) ((a)<0 ? -(a) : (a))
64 #define ORC_MIN(a,b) ((a)<(b) ? (a) : (b))
65 #define ORC_MAX(a,b) ((a)>(b) ? (a) : (b))
66 #define ORC_SB_MAX 127
67 #define ORC_SB_MIN (-1-ORC_SB_MAX)
68 #define ORC_UB_MAX 255
69 #define ORC_UB_MIN 0
70 #define ORC_SW_MAX 32767
71 #define ORC_SW_MIN (-1-ORC_SW_MAX)
72 #define ORC_UW_MAX 65535
73 #define ORC_UW_MIN 0
74 #define ORC_SL_MAX 2147483647
75 #define ORC_SL_MIN (-1-ORC_SL_MAX)
76 #define ORC_UL_MAX 4294967295U
77 #define ORC_UL_MIN 0
78 #define ORC_CLAMP_SB(x) ORC_CLAMP(x,ORC_SB_MIN,ORC_SB_MAX)
79 #define ORC_CLAMP_UB(x) ORC_CLAMP(x,ORC_UB_MIN,ORC_UB_MAX)
80 #define ORC_CLAMP_SW(x) ORC_CLAMP(x,ORC_SW_MIN,ORC_SW_MAX)
81 #define ORC_CLAMP_UW(x) ORC_CLAMP(x,ORC_UW_MIN,ORC_UW_MAX)
82 #define ORC_CLAMP_SL(x) ORC_CLAMP(x,ORC_SL_MIN,ORC_SL_MAX)
83 #define ORC_CLAMP_UL(x) ORC_CLAMP(x,ORC_UL_MIN,ORC_UL_MAX)
84 #define ORC_SWAP_W(x) ((((x)&0xff)<<8) | (((x)&0xff00)>>8))
85 #define ORC_SWAP_L(x) ((((x)&0xff)<<24) | (((x)&0xff00)<<8) | (((x)&0xff0000)>>8) | (((x)&0xff000000)>>24))
86 #define ORC_SWAP_Q(x) ((((x)&ORC_UINT64_C(0xff))<<56) | (((x)&ORC_UINT64_C(0xff00))<<40) | (((x)&ORC_UINT64_C(0xff0000))<<24) | (((x)&ORC_UINT64_C(0xff000000))<<8) | (((x)&ORC_UINT64_C(0xff00000000))>>8) | (((x)&ORC_UINT64_C(0xff0000000000))>>24) | (((x)&ORC_UINT64_C(0xff000000000000))>>40) | (((x)&ORC_UINT64_C(0xff00000000000000))>>56))
87 #define ORC_PTR_OFFSET(ptr,offset) ((void *)(((unsigned char *)(ptr)) + (offset)))
88 #define ORC_DENORMAL(x) ((x) & ((((x)&0x7f800000) == 0) ? 0xff800000 : 0xffffffff))
89 #define ORC_ISNAN(x) ((((x)&0x7f800000) == 0x7f800000) && (((x)&0x007fffff) != 0))
90 #define ORC_DENORMAL_DOUBLE(x) ((x) & ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == 0) ? ORC_UINT64_C(0xfff0000000000000) : ORC_UINT64_C(0xffffffffffffffff)))
91 #define ORC_ISNAN_DOUBLE(x) ((((x)&ORC_UINT64_C(0x7ff0000000000000)) == ORC_UINT64_C(0x7ff0000000000000)) && (((x)&ORC_UINT64_C(0x000fffffffffffff)) != 0))
92 #if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
93 #define ORC_RESTRICT restrict
94 #elif defined(__GNUC__) && __GNUC__ >= 4
95 #define ORC_RESTRICT __restrict__
96 #else
97 #define ORC_RESTRICT
98 #endif
99 /* end Orc C target preamble */
100
101
102
103 /* orc_memcpy */
104 #ifdef DISABLE_ORC
105 void
106 orc_memcpy (void * d1, const void * s1, int n){
107   int i;
108   orc_int8 * ORC_RESTRICT ptr0;
109   const orc_int8 * ORC_RESTRICT ptr4;
110   orc_int8 var32;
111   orc_int8 var33;
112
113   ptr0 = (orc_int8 *)d1;
114   ptr4 = (orc_int8 *)s1;
115
116
117   for (i = 0; i < n; i++) {
118     /* 0: loadb */
119     var32 = ptr4[i];
120     /* 1: copyb */
121     var33 = var32;
122     /* 2: storeb */
123     ptr0[i] = var33;
124   }
125
126 }
127
128 #else
129 static void
130 _backup_orc_memcpy (OrcExecutor * ORC_RESTRICT ex)
131 {
132   int i;
133   int n = ex->n;
134   orc_int8 * ORC_RESTRICT ptr0;
135   const orc_int8 * ORC_RESTRICT ptr4;
136   orc_int8 var32;
137   orc_int8 var33;
138
139   ptr0 = (orc_int8 *)ex->arrays[0];
140   ptr4 = (orc_int8 *)ex->arrays[4];
141
142
143   for (i = 0; i < n; i++) {
144     /* 0: loadb */
145     var32 = ptr4[i];
146     /* 1: copyb */
147     var33 = var32;
148     /* 2: storeb */
149     ptr0[i] = var33;
150   }
151
152 }
153
154 void
155 orc_memcpy (void * d1, const void * s1, int n)
156 {
157   OrcExecutor _ex, *ex = &_ex;
158   static int p_inited = 0;
159   static OrcProgram *p = 0;
160   void (*func) (OrcExecutor *);
161
162   if (!p_inited) {
163     orc_once_mutex_lock ();
164     if (!p_inited) {
165       OrcCompileResult result;
166
167       p = orc_program_new ();
168       orc_program_set_name (p, "orc_memcpy");
169       orc_program_set_backup_function (p, _backup_orc_memcpy);
170       orc_program_add_destination (p, 1, "d1");
171       orc_program_add_source (p, 1, "s1");
172
173       orc_program_append_2 (p, "copyb", 0, ORC_VAR_D1, ORC_VAR_S1, ORC_VAR_D1, ORC_VAR_D1);
174
175       result = orc_program_compile (p);
176     }
177     p_inited = TRUE;
178     orc_once_mutex_unlock ();
179   }
180   ex->program = p;
181
182   ex->n = n;
183   ex->arrays[ORC_VAR_D1] = d1;
184   ex->arrays[ORC_VAR_S1] = (void *)s1;
185
186   func = p->code_exec;
187   func (ex);
188 }
189 #endif
190
191
192 /* orc_memset */
193 #ifdef DISABLE_ORC
194 void
195 orc_memset (void * d1, int p1, int n){
196   int i;
197   orc_int8 * ORC_RESTRICT ptr0;
198   orc_int8 var32;
199   orc_int8 var33;
200
201   ptr0 = (orc_int8 *)d1;
202
203     /* 0: loadpb */
204     var32 = p1;
205
206   for (i = 0; i < n; i++) {
207     /* 1: copyb */
208     var33 = var32;
209     /* 2: storeb */
210     ptr0[i] = var33;
211   }
212
213 }
214
215 #else
216 static void
217 _backup_orc_memset (OrcExecutor * ORC_RESTRICT ex)
218 {
219   int i;
220   int n = ex->n;
221   orc_int8 * ORC_RESTRICT ptr0;
222   orc_int8 var32;
223   orc_int8 var33;
224
225   ptr0 = (orc_int8 *)ex->arrays[0];
226
227     /* 0: loadpb */
228     var32 = ex->params[24];
229
230   for (i = 0; i < n; i++) {
231     /* 1: copyb */
232     var33 = var32;
233     /* 2: storeb */
234     ptr0[i] = var33;
235   }
236
237 }
238
239 void
240 orc_memset (void * d1, int p1, int n)
241 {
242   OrcExecutor _ex, *ex = &_ex;
243   static int p_inited = 0;
244   static OrcProgram *p = 0;
245   void (*func) (OrcExecutor *);
246
247   if (!p_inited) {
248     orc_once_mutex_lock ();
249     if (!p_inited) {
250       OrcCompileResult result;
251
252       p = orc_program_new ();
253       orc_program_set_name (p, "orc_memset");
254       orc_program_set_backup_function (p, _backup_orc_memset);
255       orc_program_add_destination (p, 1, "d1");
256       orc_program_add_parameter (p, 1, "p1");
257
258       orc_program_append_2 (p, "copyb", 0, ORC_VAR_D1, ORC_VAR_P1, ORC_VAR_D1, ORC_VAR_D1);
259
260       result = orc_program_compile (p);
261     }
262     p_inited = TRUE;
263     orc_once_mutex_unlock ();
264   }
265   ex->program = p;
266
267   ex->n = n;
268   ex->arrays[ORC_VAR_D1] = d1;
269   ex->params[ORC_VAR_P1] = p1;
270
271   func = p->code_exec;
272   func (ex);
273 }
274 #endif
275
276