source: proto/JSON/src/json.c @ 741

Last change on this file since 741 was 741, checked in by ksherdy, 8 years ago

Add template.c, json.c, json.c Makefile.

File size: 20.9 KB
Line 
1#include <string.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <errno.h>
5#include <sys/types.h>
6#include <sys/stat.h>
7
8#include "../lib/lib_simd.h"
9#include "../lib/block_carry.h"
10#include "../lib/perflib/perfsec.h"
11#include "../lib/s2p.h"
12
13typedef SIMD_type BytePack;
14typedef SIMD_type BitBlock;
15
16#define BLOCK_SIZE (sizeof(SIMD_type) * 8)      /* BLOCK_SIZE           - SIMD register in bits */     
17#define BUFFER_SIZE (BLOCK_SIZE * 16)           /* BUFFER_SIZE          - multiple of BLOCK_SIZE */
18#define OVERLAP_BUFSIZE sizeof(SIMD_type)       /* OVERLAP_BUFSIZE      - SIMD register width */
19
20#ifdef BUFFER_PROFILING
21        BOM_Table * perf_timer;
22#elif CODE_CLOCKER
23        #define NUM_EVENTS 1
24        int Events[NUM_EVENTS] = {PAPI_TOT_CYC};
25        //int Events[NUM_EVENTS] = {PAPI_L2_DCM};
26        //int Events[NUM_EVENTS] = {PAPI_TOT_CYC, PAPI_BR_MSP};
27        int cal_size = 20;
28        CC * perf_timer = new CC(Events,NUM_EVENTS,cal_size);
29#else
30        void * perf_timer;
31#endif
32
33void do_process(FILE *infile, FILE *outfile) {
34 
35        /* Compiler generated stream variable declarations. */
36        BitBlock temp40;
37BitBlock temp41;
38BitBlock strct_Lex__RSquareBracket_;
39BitBlock strct_Lex__Ee_;
40BitBlock temp44;
41BitBlock temp45;
42BitBlock temp46;
43BitBlock temp47;
44BitBlock temp48;
45BitBlock temp49;
46BitBlock temp42;
47BitBlock strct_u8__xF4_;
48BitBlock temp43;
49BitBlock strct_Lex__Null_;
50BitBlock temp10;
51BitBlock array_bit__2_;
52BitBlock strct_u8__suffix_;
53BitBlock strct_u8__xE0_;
54BitBlock temp59;
55BitBlock temp58;
56BitBlock temp57;
57BitBlock temp56;
58BitBlock temp55;
59BitBlock temp54;
60BitBlock strct_Lex__LSquareBracket_;
61BitBlock temp52;
62BitBlock temp51;
63BitBlock temp50;
64BitBlock strct_Ctrl__CR_;
65BitBlock strct_Lex__f_;
66BitBlock strct_Lex__True_;
67BitBlock strct_u8__unibyte_;
68BitBlock array_bit__3_;
69BitBlock strct_u8__xED_;
70BitBlock strct_Ctrl__HT_;
71BitBlock temp28;
72BitBlock temp29;
73BitBlock temp22;
74BitBlock strct_Ctrl__SP_;
75BitBlock temp20;
76BitBlock temp21;
77BitBlock temp26;
78BitBlock temp27;
79BitBlock temp24;
80BitBlock temp25;
81BitBlock temp3;
82BitBlock temp2;
83BitBlock temp1;
84BitBlock temp7;
85BitBlock temp6;
86BitBlock temp5;
87BitBlock temp4;
88BitBlock temp9;
89BitBlock temp8;
90BitBlock strct_Lex__a_;
91BitBlock strct_u8__x80_x8F_;
92BitBlock strct_u8__prefix2_;
93BitBlock array_bit__0_;
94BitBlock temp39;
95BitBlock temp38;
96BitBlock strct_Lex__Minus_;
97BitBlock strct_u8__prefix4_;
98BitBlock temp31;
99BitBlock temp30;
100BitBlock temp33;
101BitBlock temp32;
102BitBlock strct_Lex__LCurlyBrace_;
103BitBlock temp34;
104BitBlock temp37;
105BitBlock temp36;
106BitBlock AllZero = simd_const_1(0);
107BitBlock temp35;
108BitBlock strct_Lex__DQuote_;
109BitBlock strct_Lex__RSolidus_;
110BitBlock array_bit__1_;
111BitBlock array_bit__6_;
112BitBlock strct_Lex__r_;
113BitBlock strct_u8__xF0_;
114BitBlock strct_u8__x90_xBF_;
115BitBlock strct_Ctrl__x00_x1F_;
116BitBlock strct_Lex__False_;
117BitBlock temp23;
118BitBlock strct_Lex__Digit0_9_;
119BitBlock strct_Lex__Comma_;
120BitBlock array_bit__7_;
121BitBlock strct_Lex__Colon_;
122BitBlock temp53;
123BitBlock strct_Lex__DecimalPoint_;
124BitBlock temp88;
125BitBlock temp89;
126BitBlock temp84;
127BitBlock temp85;
128BitBlock temp86;
129BitBlock temp87;
130BitBlock temp80;
131BitBlock temp81;
132BitBlock temp82;
133BitBlock temp83;
134BitBlock strct_u8__xA0_xBF_;
135BitBlock strct_u8__prefix3_;
136BitBlock temp66;
137BitBlock temp67;
138BitBlock temp64;
139BitBlock temp65;
140BitBlock temp62;
141BitBlock temp63;
142BitBlock temp60;
143BitBlock temp61;
144BitBlock temp68;
145BitBlock temp69;
146BitBlock strct_Lex__e_;
147BitBlock strct_Lex__PlusMinus_;
148BitBlock strct_Lex__u_;
149BitBlock strct_u8__x80_x9F_;
150BitBlock strct_Lex__Zero_;
151BitBlock temp13;
152BitBlock temp12;
153BitBlock temp11;
154BitBlock array_bit__4_;
155BitBlock temp17;
156BitBlock temp16;
157BitBlock temp15;
158BitBlock temp14;
159BitBlock temp19;
160BitBlock temp18;
161BitBlock temp75;
162BitBlock temp74;
163BitBlock temp77;
164BitBlock temp76;
165BitBlock temp71;
166BitBlock temp70;
167BitBlock temp73;
168BitBlock temp72;
169BitBlock strct_Lex__Number_;
170BitBlock strct_Lex__n_;
171BitBlock strct_Lex__l_;
172BitBlock temp79;
173BitBlock temp78;
174BitBlock strct_u8__prefix_;
175BitBlock strct_Lex__s_;
176BitBlock strct_Lex__WS_;
177BitBlock array_bit__5_;
178BitBlock AllOne = simd_const_1(1);
179BitBlock strct_Lex__t_;
180BitBlock strct_Ctrl__LF_;
181BitBlock strct_Lex__Escape_;
182BitBlock Temp3;
183BitBlock Temp2;
184BitBlock Temp1;
185BitBlock strct_u8__badprefix_;
186BitBlock Temp4;
187BitBlock strct_Lex__HexDigit_;
188BitBlock strct_Lex__RCurlyBrace_;
189BitBlock strct_Lex__Digit1_9_;
190
191       
192        BitBlock error_mask;
193        BitBlock EOF_mask = simd_const_1(1);
194       
195        /*extra*/
196        BitBlock high_bit_mask = sisd_high_bit_mask;   
197        BitBlock high_bit_is_set;
198        BitBlock parity_mask = simd_const_1(0);
199        BitBlock bitblock_parity_mask; 
200       
201        /* 8 * sizeof(SIMD_type) bytes. */
202        BytePack U8[8];
203       
204        /* Source file data is broken into buffers, buffers are broken into blocks, blocks are SIMD register width. */
205        int src_pos = 0;
206        int buf_pos = 0;
207        int err_pos = 0;
208       
209        BytePack buf[(OVERLAP_BUFSIZE+BUFFER_SIZE+OVERLAP_BUFSIZE)/sizeof(SIMD_type)]; 
210        char * srcbuf = ((char *) buf) + OVERLAP_BUFSIZE;
211        memset((unsigned char *)srcbuf,0,16);
212        memset(((unsigned char *)srcbuf)+BUFFER_SIZE,0,16); /* Zero out first and last sizeof(SIMD_type) bytes. */
213       
214        /* File IO */
215        int chars_avail = 0;
216        int chars_read = 0;
217
218        chars_read = fread((void *)srcbuf, 1, BUFFER_SIZE, infile);
219        chars_avail = chars_read;
220        if(ferror(infile)) { fprintf(stderr, "Error: Failed to read input file.\n"); return; }
221        if(chars_avail==0 && feof(infile)) { return; }
222
223       
224       
225        while(1) {
226
227                PERF_SEC_START(perf_timer);
228               
229                while (chars_avail >= BLOCK_SIZE) { /* process full blocks */
230
231                        BytePack * U8 = (BytePack *) &srcbuf[buf_pos];
232
233                        s2p(U8[0], U8[1], U8[2], U8[3], U8[4], U8[5], U8[6], U8[7],
234                        array_bit__0_,array_bit__1_,array_bit__2_,array_bit__3_,array_bit__4_,array_bit__5_,array_bit__6_,array_bit__7_);
235
236                        strct_u8__unibyte_ = simd_andc(AllOne,array_bit__0_);
237strct_u8__prefix_ = simd_and(array_bit__0_,array_bit__1_);
238strct_u8__prefix2_ = simd_andc(strct_u8__prefix_,array_bit__2_);
239temp1 = simd_andc(array_bit__2_,array_bit__3_);
240strct_u8__prefix3_ = simd_and(strct_u8__prefix_,temp1);
241temp2 = simd_and(array_bit__2_,array_bit__3_);
242strct_u8__prefix4_ = simd_and(strct_u8__prefix_,temp2);
243strct_u8__suffix_ = simd_andc(array_bit__0_,array_bit__1_);
244temp3 = simd_or(array_bit__2_,array_bit__3_);
245temp4 = simd_andc(strct_u8__prefix_,temp3);
246temp5 = simd_or(array_bit__4_,array_bit__5_);
247temp6 = simd_or(temp5,array_bit__6_);
248temp7 = simd_andc(temp4,temp6);
249temp8 = simd_or(array_bit__6_,array_bit__7_);
250temp9 = simd_and(array_bit__5_,temp8);
251temp10 = simd_or(array_bit__4_,temp9);
252temp11 = simd_and(strct_u8__prefix4_,temp10);
253strct_u8__badprefix_ = simd_or(temp7,temp11);
254temp12 = simd_or(temp5,temp8);
255strct_u8__xE0_ = simd_andc(strct_u8__prefix3_,temp12);
256temp13 = simd_and(array_bit__4_,array_bit__5_);
257temp14 = simd_andc(array_bit__7_,array_bit__6_);
258temp15 = simd_and(temp13,temp14);
259strct_u8__xED_ = simd_and(strct_u8__prefix3_,temp15);
260strct_u8__xF0_ = simd_andc(strct_u8__prefix4_,temp12);
261temp16 = simd_andc(array_bit__5_,array_bit__4_);
262temp17 = simd_andc(temp16,temp8);
263strct_u8__xF4_ = simd_and(strct_u8__prefix4_,temp17);
264strct_u8__xA0_xBF_ = simd_and(strct_u8__suffix_,array_bit__2_);
265strct_u8__x80_x9F_ = simd_andc(strct_u8__suffix_,array_bit__2_);
266strct_u8__x90_xBF_ = simd_and(strct_u8__suffix_,temp3);
267strct_u8__x80_x8F_ = simd_andc(strct_u8__suffix_,temp3);
268temp18 = simd_or(array_bit__0_,array_bit__1_);
269temp19 = simd_or(temp18,array_bit__2_);
270strct_Ctrl__x00_x1F_ = simd_andc(AllOne,temp19);
271temp20 = simd_or(temp18,temp3);
272strct_Ctrl__CR_ = simd_andc(temp15,temp20);
273temp21 = simd_andc(array_bit__4_,array_bit__5_);
274temp22 = simd_andc(array_bit__6_,array_bit__7_);
275temp23 = simd_and(temp21,temp22);
276strct_Ctrl__LF_ = simd_andc(temp23,temp20);
277temp24 = simd_and(temp21,temp14);
278strct_Ctrl__HT_ = simd_andc(temp24,temp20);
279temp25 = simd_andc(temp1,temp18);
280strct_Ctrl__SP_ = simd_andc(temp25,temp12);
281temp26 = simd_andc(array_bit__1_,array_bit__0_);
282temp27 = simd_and(temp26,temp2);
283temp28 = simd_and(array_bit__6_,array_bit__7_);
284temp29 = simd_and(temp21,temp28);
285strct_Lex__LCurlyBrace_ = simd_and(temp27,temp29);
286temp30 = simd_andc(temp2,temp18);
287strct_Lex__Colon_ = simd_and(temp30,temp23);
288temp31 = simd_andc(temp13,temp8);
289strct_Lex__Comma_ = simd_and(temp25,temp31);
290strct_Lex__RCurlyBrace_ = simd_and(temp27,temp15);
291temp32 = simd_andc(array_bit__3_,array_bit__2_);
292temp33 = simd_and(temp26,temp32);
293strct_Lex__LSquareBracket_ = simd_and(temp33,temp29);
294strct_Lex__RSquareBracket_ = simd_and(temp33,temp15);
295strct_Lex__Minus_ = simd_and(temp25,temp15);
296strct_Lex__Zero_ = simd_andc(temp30,temp12);
297temp34 = simd_or(array_bit__5_,array_bit__6_);
298temp35 = simd_andc(AllOne,temp34);
299temp36 = simd_or(array_bit__5_,temp8);
300Temp1 = simd_and(array_bit__4_,temp35);
301Temp2 = simd_andc(temp36,array_bit__4_);
302temp37 = simd_or(Temp1,Temp2);
303strct_Lex__Digit1_9_ = simd_and(temp30,temp37);
304temp38 = simd_and(array_bit__4_,temp34);
305strct_Lex__Digit0_9_ = simd_andc(temp30,temp38);
306temp39 = simd_and(temp13,temp22);
307strct_Lex__DecimalPoint_ = simd_and(temp25,temp39);
308temp40 = simd_and(temp16,temp14);
309temp41 = simd_andc(temp3,temp1);
310temp42 = simd_andc(temp26,temp41);
311strct_Lex__Ee_ = simd_and(temp40,temp42);
312temp43 = simd_or(temp29,temp15);
313strct_Lex__PlusMinus_ = simd_and(temp25,temp43);
314temp44 = simd_or(strct_Lex__Minus_,strct_Lex__Digit0_9_);
315temp45 = simd_or(temp44,strct_Lex__DecimalPoint_);
316temp46 = simd_andc(temp26,temp3);
317temp47 = simd_and(temp46,temp40);
318temp48 = simd_or(temp45,temp47);
319temp49 = simd_and(temp26,temp1);
320temp50 = simd_and(temp49,temp40);
321temp51 = simd_or(temp48,temp50);
322temp52 = simd_and(temp25,temp29);
323temp53 = simd_or(temp51,temp52);
324strct_Lex__Number_ = simd_or(temp53,strct_Lex__Minus_);
325temp54 = simd_andc(temp22,temp5);
326strct_Lex__DQuote_ = simd_and(temp25,temp54);
327strct_Lex__RSolidus_ = simd_and(temp33,temp31);
328strct_Lex__u_ = simd_and(temp27,temp40);
329temp55 = simd_or(strct_Lex__DQuote_,strct_Lex__RSolidus_);
330temp56 = simd_and(temp13,temp28);
331temp57 = simd_and(temp25,temp56);
332temp58 = simd_or(temp55,temp57);
333temp59 = simd_and(temp49,temp54);
334temp60 = simd_or(temp58,temp59);
335temp61 = simd_and(temp16,temp22);
336temp62 = simd_and(temp49,temp61);
337temp63 = simd_or(temp60,temp62);
338temp64 = simd_and(temp49,temp39);
339temp65 = simd_or(temp63,temp64);
340temp66 = simd_and(temp27,temp54);
341temp67 = simd_or(temp65,temp66);
342temp68 = simd_and(temp27,temp17);
343temp69 = simd_or(temp67,temp68);
344strct_Lex__Escape_ = simd_or(temp69,strct_Lex__u_);
345temp70 = simd_andc(temp49,array_bit__4_);
346temp71 = simd_andc(AllOne,temp28);
347Temp3 = simd_and(array_bit__5_,temp71);
348Temp4 = simd_andc(temp8,array_bit__5_);
349temp72 = simd_or(Temp3,Temp4);
350temp73 = simd_and(temp70,temp72);
351temp74 = simd_or(strct_Lex__Digit0_9_,temp73);
352temp75 = simd_andc(temp46,array_bit__4_);
353temp76 = simd_and(temp75,temp72);
354strct_Lex__HexDigit_ = simd_or(temp74,temp76);
355temp77 = simd_or(temp15,temp23);
356temp78 = simd_or(temp77,temp24);
357temp79 = simd_andc(temp78,temp20);
358strct_Lex__WS_ = simd_or(temp79,strct_Ctrl__SP_);
359strct_Lex__t_ = temp68;
360strct_Lex__r_ = temp66;
361strct_Lex__e_ = temp50;
362temp80 = simd_or(temp17,temp54);
363temp81 = simd_or(temp80,temp40);
364temp82 = simd_and(temp27,temp81);
365strct_Lex__True_ = simd_or(temp82,temp50);
366strct_Lex__f_ = temp62;
367temp83 = simd_andc(temp14,temp5);
368strct_Lex__a_ = simd_and(temp49,temp83);
369strct_Lex__l_ = simd_and(temp49,temp31);
370temp84 = simd_andc(temp28,temp5);
371strct_Lex__s_ = simd_and(temp27,temp84);
372temp85 = simd_or(temp61,temp83);
373temp86 = simd_or(temp85,temp31);
374temp87 = simd_and(temp49,temp86);
375temp88 = simd_or(temp87,strct_Lex__s_);
376strct_Lex__False_ = simd_or(temp88,temp50);
377strct_Lex__n_ = temp64;
378temp89 = simd_or(temp64,strct_Lex__u_);
379strct_Lex__Null_ = simd_or(temp89,strct_Lex__l_);
380
381
382                        /* strct_Lex__Null_ = simd_or(temp89,strct_Lex__l_); */
383                        high_bit_mask = sisd_high_bit_mask;
384                        high_bit_is_set = simd_and(high_bit_mask, bitblock_parity_mask);                       
385                        parity_mask = sisd_add( simd_not(sisd_srl(high_bit_is_set, sisd_from_int(BLOCK_SIZE-1))) , sisd_low_bit_mask);                                         
386                        bitblock_parity_mask = bitblock_parallel_prefix_parity(strct_Lex__DQuote_, parity_mask);
387                       
388                        print_simd_register("strct_Lex__DQuote_",strct_Lex__DQuote_);
389                        print_simd_register("high_bit_is_set", high_bit_is_set);
390                        print_simd_register("high_bit_mask", high_bit_mask);
391                        print_simd_register("bitblock_parity_mask", bitblock_parity_mask);
392
393                        if (bitblock_has_bit(error_mask)){
394                                err_pos = src_pos + buf_pos + count_forward_zeroes(error_mask);
395                                fprintf(stderr, "Error at position %i\n.", err_pos);
396                                exit(-1);
397                        }
398
399                        chars_avail -= BLOCK_SIZE;
400                        buf_pos += BLOCK_SIZE;
401                }               
402               
403                if(chars_avail > 0 /* || any_carry */) { /* process final partial block */
404                        /* extra */
405                        EOF_mask = sisd_srl(simd_const_1(1),sisd_from_int(BLOCK_SIZE-chars_avail));
406                       
407                        BytePack * U8 = (BytePack *) &srcbuf[buf_pos];
408                       
409                        s2p(U8[0], U8[1], U8[2], U8[3], U8[4], U8[5], U8[6], U8[7],
410                        array_bit__0_,array_bit__1_,array_bit__2_,array_bit__3_,array_bit__4_,array_bit__5_,array_bit__6_,array_bit__7_);
411
412                        array_bit__0_ = simd_and(array_bit__0_, EOF_mask);
413                        array_bit__1_ = simd_and(array_bit__1_, EOF_mask);
414                        array_bit__2_ = simd_and(array_bit__2_, EOF_mask);
415                        array_bit__3_ = simd_and(array_bit__3_, EOF_mask);
416                        array_bit__4_ = simd_and(array_bit__4_, EOF_mask);
417                        array_bit__5_ = simd_and(array_bit__5_, EOF_mask);
418                        array_bit__6_ = simd_and(array_bit__6_, EOF_mask);
419                        array_bit__7_ = simd_and(array_bit__7_, EOF_mask);
420                       
421                        strct_u8__unibyte_ = simd_andc(AllOne,array_bit__0_);
422strct_u8__prefix_ = simd_and(array_bit__0_,array_bit__1_);
423strct_u8__prefix2_ = simd_andc(strct_u8__prefix_,array_bit__2_);
424temp1 = simd_andc(array_bit__2_,array_bit__3_);
425strct_u8__prefix3_ = simd_and(strct_u8__prefix_,temp1);
426temp2 = simd_and(array_bit__2_,array_bit__3_);
427strct_u8__prefix4_ = simd_and(strct_u8__prefix_,temp2);
428strct_u8__suffix_ = simd_andc(array_bit__0_,array_bit__1_);
429temp3 = simd_or(array_bit__2_,array_bit__3_);
430temp4 = simd_andc(strct_u8__prefix_,temp3);
431temp5 = simd_or(array_bit__4_,array_bit__5_);
432temp6 = simd_or(temp5,array_bit__6_);
433temp7 = simd_andc(temp4,temp6);
434temp8 = simd_or(array_bit__6_,array_bit__7_);
435temp9 = simd_and(array_bit__5_,temp8);
436temp10 = simd_or(array_bit__4_,temp9);
437temp11 = simd_and(strct_u8__prefix4_,temp10);
438strct_u8__badprefix_ = simd_or(temp7,temp11);
439temp12 = simd_or(temp5,temp8);
440strct_u8__xE0_ = simd_andc(strct_u8__prefix3_,temp12);
441temp13 = simd_and(array_bit__4_,array_bit__5_);
442temp14 = simd_andc(array_bit__7_,array_bit__6_);
443temp15 = simd_and(temp13,temp14);
444strct_u8__xED_ = simd_and(strct_u8__prefix3_,temp15);
445strct_u8__xF0_ = simd_andc(strct_u8__prefix4_,temp12);
446temp16 = simd_andc(array_bit__5_,array_bit__4_);
447temp17 = simd_andc(temp16,temp8);
448strct_u8__xF4_ = simd_and(strct_u8__prefix4_,temp17);
449strct_u8__xA0_xBF_ = simd_and(strct_u8__suffix_,array_bit__2_);
450strct_u8__x80_x9F_ = simd_andc(strct_u8__suffix_,array_bit__2_);
451strct_u8__x90_xBF_ = simd_and(strct_u8__suffix_,temp3);
452strct_u8__x80_x8F_ = simd_andc(strct_u8__suffix_,temp3);
453temp18 = simd_or(array_bit__0_,array_bit__1_);
454temp19 = simd_or(temp18,array_bit__2_);
455strct_Ctrl__x00_x1F_ = simd_andc(AllOne,temp19);
456temp20 = simd_or(temp18,temp3);
457strct_Ctrl__CR_ = simd_andc(temp15,temp20);
458temp21 = simd_andc(array_bit__4_,array_bit__5_);
459temp22 = simd_andc(array_bit__6_,array_bit__7_);
460temp23 = simd_and(temp21,temp22);
461strct_Ctrl__LF_ = simd_andc(temp23,temp20);
462temp24 = simd_and(temp21,temp14);
463strct_Ctrl__HT_ = simd_andc(temp24,temp20);
464temp25 = simd_andc(temp1,temp18);
465strct_Ctrl__SP_ = simd_andc(temp25,temp12);
466temp26 = simd_andc(array_bit__1_,array_bit__0_);
467temp27 = simd_and(temp26,temp2);
468temp28 = simd_and(array_bit__6_,array_bit__7_);
469temp29 = simd_and(temp21,temp28);
470strct_Lex__LCurlyBrace_ = simd_and(temp27,temp29);
471temp30 = simd_andc(temp2,temp18);
472strct_Lex__Colon_ = simd_and(temp30,temp23);
473temp31 = simd_andc(temp13,temp8);
474strct_Lex__Comma_ = simd_and(temp25,temp31);
475strct_Lex__RCurlyBrace_ = simd_and(temp27,temp15);
476temp32 = simd_andc(array_bit__3_,array_bit__2_);
477temp33 = simd_and(temp26,temp32);
478strct_Lex__LSquareBracket_ = simd_and(temp33,temp29);
479strct_Lex__RSquareBracket_ = simd_and(temp33,temp15);
480strct_Lex__Minus_ = simd_and(temp25,temp15);
481strct_Lex__Zero_ = simd_andc(temp30,temp12);
482temp34 = simd_or(array_bit__5_,array_bit__6_);
483temp35 = simd_andc(AllOne,temp34);
484temp36 = simd_or(array_bit__5_,temp8);
485Temp1 = simd_and(array_bit__4_,temp35);
486Temp2 = simd_andc(temp36,array_bit__4_);
487temp37 = simd_or(Temp1,Temp2);
488strct_Lex__Digit1_9_ = simd_and(temp30,temp37);
489temp38 = simd_and(array_bit__4_,temp34);
490strct_Lex__Digit0_9_ = simd_andc(temp30,temp38);
491temp39 = simd_and(temp13,temp22);
492strct_Lex__DecimalPoint_ = simd_and(temp25,temp39);
493temp40 = simd_and(temp16,temp14);
494temp41 = simd_andc(temp3,temp1);
495temp42 = simd_andc(temp26,temp41);
496strct_Lex__Ee_ = simd_and(temp40,temp42);
497temp43 = simd_or(temp29,temp15);
498strct_Lex__PlusMinus_ = simd_and(temp25,temp43);
499temp44 = simd_or(strct_Lex__Minus_,strct_Lex__Digit0_9_);
500temp45 = simd_or(temp44,strct_Lex__DecimalPoint_);
501temp46 = simd_andc(temp26,temp3);
502temp47 = simd_and(temp46,temp40);
503temp48 = simd_or(temp45,temp47);
504temp49 = simd_and(temp26,temp1);
505temp50 = simd_and(temp49,temp40);
506temp51 = simd_or(temp48,temp50);
507temp52 = simd_and(temp25,temp29);
508temp53 = simd_or(temp51,temp52);
509strct_Lex__Number_ = simd_or(temp53,strct_Lex__Minus_);
510temp54 = simd_andc(temp22,temp5);
511strct_Lex__DQuote_ = simd_and(temp25,temp54);
512strct_Lex__RSolidus_ = simd_and(temp33,temp31);
513strct_Lex__u_ = simd_and(temp27,temp40);
514temp55 = simd_or(strct_Lex__DQuote_,strct_Lex__RSolidus_);
515temp56 = simd_and(temp13,temp28);
516temp57 = simd_and(temp25,temp56);
517temp58 = simd_or(temp55,temp57);
518temp59 = simd_and(temp49,temp54);
519temp60 = simd_or(temp58,temp59);
520temp61 = simd_and(temp16,temp22);
521temp62 = simd_and(temp49,temp61);
522temp63 = simd_or(temp60,temp62);
523temp64 = simd_and(temp49,temp39);
524temp65 = simd_or(temp63,temp64);
525temp66 = simd_and(temp27,temp54);
526temp67 = simd_or(temp65,temp66);
527temp68 = simd_and(temp27,temp17);
528temp69 = simd_or(temp67,temp68);
529strct_Lex__Escape_ = simd_or(temp69,strct_Lex__u_);
530temp70 = simd_andc(temp49,array_bit__4_);
531temp71 = simd_andc(AllOne,temp28);
532Temp3 = simd_and(array_bit__5_,temp71);
533Temp4 = simd_andc(temp8,array_bit__5_);
534temp72 = simd_or(Temp3,Temp4);
535temp73 = simd_and(temp70,temp72);
536temp74 = simd_or(strct_Lex__Digit0_9_,temp73);
537temp75 = simd_andc(temp46,array_bit__4_);
538temp76 = simd_and(temp75,temp72);
539strct_Lex__HexDigit_ = simd_or(temp74,temp76);
540temp77 = simd_or(temp15,temp23);
541temp78 = simd_or(temp77,temp24);
542temp79 = simd_andc(temp78,temp20);
543strct_Lex__WS_ = simd_or(temp79,strct_Ctrl__SP_);
544strct_Lex__t_ = temp68;
545strct_Lex__r_ = temp66;
546strct_Lex__e_ = temp50;
547temp80 = simd_or(temp17,temp54);
548temp81 = simd_or(temp80,temp40);
549temp82 = simd_and(temp27,temp81);
550strct_Lex__True_ = simd_or(temp82,temp50);
551strct_Lex__f_ = temp62;
552temp83 = simd_andc(temp14,temp5);
553strct_Lex__a_ = simd_and(temp49,temp83);
554strct_Lex__l_ = simd_and(temp49,temp31);
555temp84 = simd_andc(temp28,temp5);
556strct_Lex__s_ = simd_and(temp27,temp84);
557temp85 = simd_or(temp61,temp83);
558temp86 = simd_or(temp85,temp31);
559temp87 = simd_and(temp49,temp86);
560temp88 = simd_or(temp87,strct_Lex__s_);
561strct_Lex__False_ = simd_or(temp88,temp50);
562strct_Lex__n_ = temp64;
563temp89 = simd_or(temp64,strct_Lex__u_);
564strct_Lex__Null_ = simd_or(temp89,strct_Lex__l_);
565
566
567                        /* strct_Lex__Null_ = simd_or(temp89,strct_Lex__l_); */
568                        /* extra */
569                        high_bit_mask = sisd_srl(sisd_high_bit_mask, sisd_from_int(BLOCK_SIZE-chars_avail));
570                        high_bit_is_set = simd_and(high_bit_mask, bitblock_parity_mask);
571                        parity_mask = sisd_add(simd_not(sisd_srl(high_bit_is_set, sisd_from_int(chars_avail-1))) , sisd_low_bit_mask);                 
572                        bitblock_parity_mask = bitblock_parallel_prefix_parity(strct_Lex__DQuote_, parity_mask);
573                        bitblock_parity_mask = simd_and(bitblock_parity_mask, EOF_mask);
574                       
575                        print_simd_register("strct_Lex__DQuote_",strct_Lex__DQuote_);
576                        print_simd_register("high_bit_is_set", high_bit_is_set);
577                        print_simd_register("high_bit_mask", high_bit_mask);
578                        print_simd_register("bitblock_parity_mask", bitblock_parity_mask);
579                       
580                        if(bitblock_has_bit(error_mask)) {
581                                err_pos = src_pos + buf_pos + count_forward_zeroes(error_mask);
582                                fprintf(stderr, "Error at position %i\n.", err_pos);
583                                exit(-1);
584                        }
585                }
586               
587                PERF_SEC_END(perf_timer, chars_avail);
588
589                src_pos += chars_read;
590                buf_pos = 0;
591
592                chars_read = fread((void *)srcbuf, 1, BUFFER_SIZE, infile);
593                chars_avail = chars_read;
594                if(ferror(infile)) { fprintf(stderr, "Failed to read input file.\n"); return; }
595                if(chars_avail==0 && feof(infile)) { return; } 
596        }
597}
598
599int main(int argc, char * argv[]) {
600        char * infilename, * outfilename;       
601        FILE *infile, *outfile;
602        struct stat fileinfo;
603
604        if (argc < 2) {
605                printf("Usage: %s <filename> [<outputfile>]\n", argv[0]);
606                exit(-1);
607        }
608
609        infilename = argv[1];
610        stat(infilename, &fileinfo);
611        infile = fopen(infilename, "rb");
612        if (!infile) {
613                fprintf(stderr, "Error: Cannot open %s for reading.\n", infilename);
614                exit(-1);
615        }
616       
617        if (argc < 3) {
618                outfile = stdout;
619        }       else {
620                outfilename = argv[2];
621                outfile = fopen(outfilename, "wb");
622                if (!outfile) {
623                        fprintf(stderr, "Error: Cannot open %s for writing.\n", outfilename);
624                        exit(-1);
625                }
626        }
627
628        // PERF_SEC_BIND(1);
629
630        PERF_SEC_INIT(perf_timer);
631
632        do_process(infile, outfile);
633       
634        PERF_SEC_DUMP(perf_timer);
635       
636        PERF_SEC_DESTROY(perf_timer);
637
638        fclose(infile);
639        fclose(outfile);
640       
641        return(0);
642}
Note: See TracBrowser for help on using the repository browser.