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

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

Initial working JSON compilable and executable.

File size: 36.6 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 BLOCK_SIZE              /* OVERLAP_BUFSIZE      - SIMD register width in bytes overlap */
19
20#define DEBUG 1
21
22#ifdef BUFFER_PROFILING
23        BOM_Table * perf_timer;
24#elif CODE_CLOCKER
25        #define NUM_EVENTS 1
26        int Events[NUM_EVENTS] = {PAPI_TOT_CYC};
27        //int Events[NUM_EVENTS] = {PAPI_L2_DCM};
28        //int Events[NUM_EVENTS] = {PAPI_TOT_CYC, PAPI_BR_MSP};
29        int cal_size = 20;
30        CC * perf_timer = new CC(Events,NUM_EVENTS,cal_size);
31#else
32        void * perf_timer;
33#endif
34
35void do_process(FILE *infile, FILE *outfile) {
36 
37        /* Compiler generated stream variable declarations. */
38        BitBlock temp40;
39BitBlock temp41;
40BitBlock strct_Lex__RSquareBracket_;
41BitBlock temp43;
42BitBlock temp44;
43BitBlock temp45;
44BitBlock temp46;
45BitBlock temp47;
46BitBlock temp48;
47BitBlock temp49;
48BitBlock temp42;
49BitBlock FalseErrors_1;
50BitBlock M4b;
51BitBlock M4a;
52BitBlock TrueSpans;
53BitBlock strct_Lex__DecimalPoint_;
54BitBlock strct_Lex__Null_;
55BitBlock array_bit__2_;
56BitBlock strct_u8__suffix_;
57BitBlock Scope3;
58BitBlock strct_Lex__n_;
59BitBlock EvenEscape;
60BitBlock StringEscapeChars;
61BitBlock OddFinal;
62BitBlock Temp40;
63BitBlock Temp41;
64BitBlock Temp42;
65BitBlock strct_u8__unibyte_;
66BitBlock temp81;
67BitBlock NullSpans;
68BitBlock strct_u8__xED_;
69BitBlock temp28;
70BitBlock temp29;
71BitBlock temp22;
72BitBlock temp23;
73BitBlock temp20;
74BitBlock temp21;
75BitBlock temp26;
76BitBlock temp27;
77BitBlock temp24;
78BitBlock temp25;
79BitBlock M4;
80BitBlock M7;
81BitBlock M6;
82BitBlock M1;
83BitBlock M0;
84BitBlock strct_Lex__a_;
85BitBlock M2b;
86BitBlock strct_u8__x80_x8F_;
87BitBlock TrueErrors_5;
88BitBlock AtomSpans;
89BitBlock array_bit__0_;
90BitBlock strct_Lex__Minus_;
91BitBlock strct_u8__prefix4_;
92BitBlock strct_Lex__LCurlyBrace_;
93BitBlock ParityMask;
94BitBlock temp36;
95BitBlock AllZero = simd_const_1(0);
96BitBlock Temp28;
97BitBlock Temp29;
98BitBlock EvenFinal;
99BitBlock Temp22;
100BitBlock Temp23;
101BitBlock Temp20;
102BitBlock Temp21;
103BitBlock Temp26;
104BitBlock Temp27;
105BitBlock Temp24;
106BitBlock Temp25;
107BitBlock Escape;
108BitBlock StringMask;
109BitBlock strct_u8__x90_xBF_;
110BitBlock M3b;
111BitBlock M9b;
112BitBlock Scope3_6;
113BitBlock Scope3_7;
114BitBlock strct_Lex__Comma_;
115BitBlock array_bit__7_;
116BitBlock strct_Lex__Colon_;
117BitBlock OddStart;
118BitBlock Scope2;
119BitBlock StringNotEscapedChars;
120BitBlock Scope1;
121BitBlock Scope4;
122BitBlock strct_Lex__e_;
123BitBlock TrueErrors_4;
124BitBlock strct_u8__xA0_xBF_;
125BitBlock strct_u8__prefix3_;
126BitBlock FalseSpans;
127BitBlock strct_Lex__PlusMinus_;
128BitBlock M9b_10;
129BitBlock M5b_0;
130BitBlock strct_u8__x80_x9F_;
131BitBlock StringErrors_20;
132BitBlock StringErrors_21;
133BitBlock StringErrors_22;
134BitBlock StringEnds;
135BitBlock temp75;
136BitBlock temp74;
137BitBlock temp77;
138BitBlock E9b;
139BitBlock temp71;
140BitBlock temp70;
141BitBlock temp73;
142BitBlock temp72;
143BitBlock strct_Lex__LSquareBracket_;
144BitBlock temp79;
145BitBlock temp78;
146BitBlock M7b;
147BitBlock M7a;
148BitBlock strct_u8__prefix_;
149BitBlock strct_Lex__s_;
150BitBlock strct_Lex__WS_;
151BitBlock AllOne = simd_const_1(1);
152BitBlock strct_Lex__t_;
153BitBlock strct_Ctrl__LF_;
154BitBlock StringSpans;
155BitBlock Follows_8;
156BitBlock Follows_9;
157BitBlock strct_Ctrl__CR_;
158BitBlock strct_u8__badprefix_;
159BitBlock strct_Lex__Zero_;
160BitBlock strct_Lex__RCurlyBrace_;
161BitBlock strct_Lex__Ee_;
162BitBlock strct_u8__xF4_;
163BitBlock strct_Lex__Digit1_9_;
164BitBlock strct_Lex__True_;
165BitBlock temp10;
166BitBlock EvenStart;
167BitBlock NullErrors_12;
168BitBlock NullErrors_11;
169BitBlock strct_u8__xE0_;
170BitBlock temp59;
171BitBlock temp58;
172BitBlock temp57;
173BitBlock temp56;
174BitBlock temp55;
175BitBlock temp54;
176BitBlock temp53;
177BitBlock temp52;
178BitBlock temp51;
179BitBlock temp50;
180BitBlock Temp43;
181BitBlock strct_Lex__f_;
182BitBlock M5b;
183BitBlock UnescapedDQuotes;
184BitBlock AtomsSpans;
185BitBlock TrueStarts;
186BitBlock FalseErrors;
187BitBlock array_bit__3_;
188BitBlock strct_Ctrl__HT_;
189BitBlock uScope2;
190BitBlock strct_Ctrl__x00_x1F_;
191BitBlock temp30;
192BitBlock uScope1;
193BitBlock uScope4;
194BitBlock temp3;
195BitBlock temp2;
196BitBlock temp1;
197BitBlock temp76;
198BitBlock temp7;
199BitBlock temp6;
200BitBlock temp5;
201BitBlock temp4;
202BitBlock temp9;
203BitBlock temp8;
204BitBlock StringStarts;
205BitBlock TrueErrors;
206BitBlock StringCursor;
207BitBlock NullStarts;
208BitBlock M10b;
209BitBlock strct_u8__prefix2_;
210BitBlock Scope1_15;
211BitBlock E1;
212BitBlock temp39;
213BitBlock temp38;
214BitBlock temp31;
215BitBlock array_bit__5_;
216BitBlock temp33;
217BitBlock temp32;
218BitBlock temp35;
219BitBlock temp34;
220BitBlock temp37;
221BitBlock E5b;
222BitBlock NumberSpans;
223BitBlock strct_Lex__DQuote_;
224BitBlock strct_Lex__RSolidus_;
225BitBlock array_bit__1_;
226BitBlock Even;
227BitBlock Follows;
228BitBlock array_bit__6_;
229BitBlock error_mask;
230BitBlock strct_Lex__r_;
231BitBlock Start;
232BitBlock Scope2_13;
233BitBlock M1_23;
234BitBlock Scope1_16;
235BitBlock strct_u8__xF0_;
236BitBlock Scope2_14;
237BitBlock M1a;
238BitBlock Temp38;
239BitBlock M1b;
240BitBlock Temp31;
241BitBlock Temp30;
242BitBlock Temp33;
243BitBlock Temp32;
244BitBlock Temp35;
245BitBlock Temp34;
246BitBlock Temp37;
247BitBlock Temp36;
248BitBlock strct_Ctrl__SP_;
249BitBlock strct_Lex__False_;
250BitBlock strct_Lex__Digit0_9_;
251BitBlock NullErrors;
252BitBlock FalseStarts;
253BitBlock FalseErrors_2;
254BitBlock FalseErrors_3;
255BitBlock NumberStarts;
256BitBlock temp88;
257BitBlock temp89;
258BitBlock temp84;
259BitBlock temp85;
260BitBlock temp86;
261BitBlock temp87;
262BitBlock temp80;
263BitBlock AtomStarts;
264BitBlock temp82;
265BitBlock temp83;
266BitBlock M11;
267BitBlock StringErrors;
268BitBlock OddEscape;
269BitBlock NumberErrors;
270BitBlock Odd;
271BitBlock temp66;
272BitBlock temp67;
273BitBlock temp64;
274BitBlock temp65;
275BitBlock temp62;
276BitBlock temp63;
277BitBlock temp60;
278BitBlock temp61;
279BitBlock temp68;
280BitBlock temp69;
281BitBlock Temp13;
282BitBlock Temp12;
283BitBlock Temp11;
284BitBlock Temp10;
285BitBlock Temp17;
286BitBlock Temp16;
287BitBlock Temp15;
288BitBlock Temp14;
289BitBlock Temp19;
290BitBlock Temp18;
291BitBlock strct_Lex__u_;
292BitBlock uScope3;
293BitBlock M2a;
294BitBlock temp13;
295BitBlock temp12;
296BitBlock temp11;
297BitBlock array_bit__4_;
298BitBlock temp17;
299BitBlock temp16;
300BitBlock temp15;
301BitBlock temp14;
302BitBlock Temp7;
303BitBlock temp19;
304BitBlock temp18;
305BitBlock strct_Lex__Number_;
306BitBlock strct_Lex__l_;
307BitBlock StringErrors_17;
308BitBlock strct_Lex__Escape_;
309BitBlock StringErrors_19;
310BitBlock StringErrors_18;
311BitBlock Temp3;
312BitBlock Temp2;
313BitBlock Temp1;
314BitBlock u;
315BitBlock Temp6;
316BitBlock Temp5;
317BitBlock Temp4;
318BitBlock strct_Lex__HexDigit_;
319BitBlock Temp9;
320BitBlock Temp8;
321BitBlock M8b;
322BitBlock Temp39;
323CarryType carry28 = Carry0;
324CarryType carry29 = Carry0;
325CarryType carry20 = Carry0;
326CarryType carry21 = Carry0;
327CarryType carry22 = Carry0;
328CarryType carry23 = Carry0;
329CarryType carry24 = Carry0;
330CarryType carry25 = Carry0;
331CarryType carry26 = Carry0;
332CarryType carry27 = Carry0;
333CarryType carry1 = Carry0;
334CarryType carry0 = Carry0;
335CarryType carry3 = Carry0;
336CarryType carry2 = Carry0;
337CarryType carry5 = Carry0;
338CarryType carry4 = Carry0;
339CarryType carry7 = Carry0;
340CarryType carry6 = Carry0;
341CarryType carry9 = Carry0;
342CarryType carry8 = Carry0;
343CarryType carry15 = Carry0;
344CarryType carry14 = Carry0;
345CarryType carry17 = Carry0;
346CarryType carry16 = Carry0;
347CarryType carry11 = Carry0;
348CarryType carry10 = Carry0;
349CarryType carry13 = Carry0;
350CarryType carry12 = Carry0;
351CarryType carry19 = Carry0;
352CarryType carry18 = Carry0;
353CarryType carry_brw2 = Carry0;
354CarryType carry_brw1 = Carry0;
355CarryType carry_brw0 = Carry0;
356CarryType carry32 = Carry0;
357CarryType carry31 = Carry0;
358CarryType carry30 = Carry0;
359
360       
361        // BitBlock error_mask;  // PyBit compiler auto declares this variable
362        BitBlock EOF_mask = simd_const_1(1);
363       
364        /*extra*/
365        /* parse_escape, do not declare, since the PyBit compiler does so by default*/
366        Odd = simd_const_2(1);
367        Even = simd_const_2(2);
368       
369        BitBlock high_bit_mask = sisd_high_bit_mask;   
370        BitBlock high_bit_is_set;
371        // BitBlock ParityMask = simd_const_1(0); // PyBit compiler auto declares this variable
372        BitBlock bitblock_parity_mask; 
373       
374        /* 8 * sizeof(SIMD_type) bytes. */
375        BytePack U8[8];
376       
377        /* Source file data is broken into buffers, buffers are broken into blocks, blocks are SIMD register width. */
378        int src_pos = 0;
379        int buf_pos = 0;
380        int err_pos = 0;
381       
382        BytePack buf[(OVERLAP_BUFSIZE+BUFFER_SIZE+OVERLAP_BUFSIZE)/sizeof(SIMD_type)]; 
383        char * srcbuf = ((char *) buf) + OVERLAP_BUFSIZE;
384        memset((unsigned char *)srcbuf,0,16);
385        memset(((unsigned char *)srcbuf)+BUFFER_SIZE,0,16); /* Zero out first and last sizeof(SIMD_type) bytes. */
386       
387        /* File IO */
388        int chars_avail = 0;
389        int chars_read = 0;
390
391        chars_read = fread((void *)srcbuf, 1, BUFFER_SIZE, infile);
392        chars_avail = chars_read;
393        if(ferror(infile)) { fprintf(stderr, "Error: Failed to read input file.\n"); return; }
394        if(chars_avail==0 && feof(infile)) { return; }
395
396       
397       
398        while(1) {
399
400                PERF_SEC_START(perf_timer);
401               
402                while (chars_avail >= BLOCK_SIZE) { /* process full blocks */
403
404                        BytePack * U8 = (BytePack *) &srcbuf[buf_pos];
405
406                        s2p(U8[0], U8[1], U8[2], U8[3], U8[4], U8[5], U8[6], U8[7],
407                        array_bit__0_,array_bit__1_,array_bit__2_,array_bit__3_,array_bit__4_,array_bit__5_,array_bit__6_,array_bit__7_);
408
409                        strct_u8__unibyte_ = simd_andc(AllOne,array_bit__0_);
410strct_u8__prefix_ = simd_and(array_bit__0_,array_bit__1_);
411strct_u8__prefix2_ = simd_andc(strct_u8__prefix_,array_bit__2_);
412temp1 = simd_andc(array_bit__2_,array_bit__3_);
413strct_u8__prefix3_ = simd_and(strct_u8__prefix_,temp1);
414temp2 = simd_and(array_bit__2_,array_bit__3_);
415strct_u8__prefix4_ = simd_and(strct_u8__prefix_,temp2);
416strct_u8__suffix_ = simd_andc(array_bit__0_,array_bit__1_);
417temp3 = simd_or(array_bit__2_,array_bit__3_);
418temp4 = simd_andc(strct_u8__prefix_,temp3);
419temp5 = simd_or(array_bit__4_,array_bit__5_);
420temp6 = simd_or(temp5,array_bit__6_);
421temp7 = simd_andc(temp4,temp6);
422temp8 = simd_or(array_bit__6_,array_bit__7_);
423temp9 = simd_and(array_bit__5_,temp8);
424temp10 = simd_or(array_bit__4_,temp9);
425temp11 = simd_and(strct_u8__prefix4_,temp10);
426strct_u8__badprefix_ = simd_or(temp7,temp11);
427temp12 = simd_or(temp5,temp8);
428strct_u8__xE0_ = simd_andc(strct_u8__prefix3_,temp12);
429temp13 = simd_and(array_bit__4_,array_bit__5_);
430temp14 = simd_andc(array_bit__7_,array_bit__6_);
431temp15 = simd_and(temp13,temp14);
432strct_u8__xED_ = simd_and(strct_u8__prefix3_,temp15);
433strct_u8__xF0_ = simd_andc(strct_u8__prefix4_,temp12);
434temp16 = simd_andc(array_bit__5_,array_bit__4_);
435temp17 = simd_andc(temp16,temp8);
436strct_u8__xF4_ = simd_and(strct_u8__prefix4_,temp17);
437strct_u8__xA0_xBF_ = simd_and(strct_u8__suffix_,array_bit__2_);
438strct_u8__x80_x9F_ = simd_andc(strct_u8__suffix_,array_bit__2_);
439strct_u8__x90_xBF_ = simd_and(strct_u8__suffix_,temp3);
440strct_u8__x80_x8F_ = simd_andc(strct_u8__suffix_,temp3);
441temp18 = simd_or(array_bit__0_,array_bit__1_);
442temp19 = simd_or(temp18,array_bit__2_);
443strct_Ctrl__x00_x1F_ = simd_andc(AllOne,temp19);
444temp20 = simd_or(temp18,temp3);
445strct_Ctrl__CR_ = simd_andc(temp15,temp20);
446temp21 = simd_andc(array_bit__4_,array_bit__5_);
447temp22 = simd_andc(array_bit__6_,array_bit__7_);
448temp23 = simd_and(temp21,temp22);
449strct_Ctrl__LF_ = simd_andc(temp23,temp20);
450temp24 = simd_and(temp21,temp14);
451strct_Ctrl__HT_ = simd_andc(temp24,temp20);
452temp25 = simd_andc(temp1,temp18);
453strct_Ctrl__SP_ = simd_andc(temp25,temp12);
454temp26 = simd_andc(array_bit__1_,array_bit__0_);
455temp27 = simd_and(temp26,temp2);
456temp28 = simd_and(array_bit__6_,array_bit__7_);
457temp29 = simd_and(temp21,temp28);
458strct_Lex__LCurlyBrace_ = simd_and(temp27,temp29);
459temp30 = simd_andc(temp2,temp18);
460strct_Lex__Colon_ = simd_and(temp30,temp23);
461temp31 = simd_andc(temp13,temp8);
462strct_Lex__Comma_ = simd_and(temp25,temp31);
463strct_Lex__RCurlyBrace_ = simd_and(temp27,temp15);
464temp32 = simd_andc(array_bit__3_,array_bit__2_);
465temp33 = simd_and(temp26,temp32);
466strct_Lex__LSquareBracket_ = simd_and(temp33,temp29);
467strct_Lex__RSquareBracket_ = simd_and(temp33,temp15);
468strct_Lex__Minus_ = simd_and(temp25,temp15);
469strct_Lex__Zero_ = simd_andc(temp30,temp12);
470temp34 = simd_or(array_bit__5_,array_bit__6_);
471temp35 = simd_andc(AllOne,temp34);
472temp36 = simd_or(array_bit__5_,temp8);
473Temp1 = simd_and(array_bit__4_,temp35);
474Temp2 = simd_andc(temp36,array_bit__4_);
475temp37 = simd_or(Temp1,Temp2);
476strct_Lex__Digit1_9_ = simd_and(temp30,temp37);
477temp38 = simd_and(array_bit__4_,temp34);
478strct_Lex__Digit0_9_ = simd_andc(temp30,temp38);
479temp39 = simd_and(temp13,temp22);
480strct_Lex__DecimalPoint_ = simd_and(temp25,temp39);
481temp40 = simd_and(temp16,temp14);
482temp41 = simd_andc(temp3,temp1);
483temp42 = simd_andc(temp26,temp41);
484strct_Lex__Ee_ = simd_and(temp40,temp42);
485temp43 = simd_or(temp29,temp15);
486strct_Lex__PlusMinus_ = simd_and(temp25,temp43);
487temp44 = simd_or(strct_Lex__Minus_,strct_Lex__Digit0_9_);
488temp45 = simd_or(temp44,strct_Lex__DecimalPoint_);
489temp46 = simd_andc(temp26,temp3);
490temp47 = simd_and(temp46,temp40);
491temp48 = simd_or(temp45,temp47);
492temp49 = simd_and(temp26,temp1);
493temp50 = simd_and(temp49,temp40);
494temp51 = simd_or(temp48,temp50);
495temp52 = simd_and(temp25,temp29);
496temp53 = simd_or(temp51,temp52);
497strct_Lex__Number_ = simd_or(temp53,strct_Lex__Minus_);
498temp54 = simd_andc(temp22,temp5);
499strct_Lex__DQuote_ = simd_and(temp25,temp54);
500strct_Lex__RSolidus_ = simd_and(temp33,temp31);
501strct_Lex__u_ = simd_and(temp27,temp40);
502temp55 = simd_or(strct_Lex__DQuote_,strct_Lex__RSolidus_);
503temp56 = simd_and(temp13,temp28);
504temp57 = simd_and(temp25,temp56);
505temp58 = simd_or(temp55,temp57);
506temp59 = simd_and(temp49,temp54);
507temp60 = simd_or(temp58,temp59);
508temp61 = simd_and(temp16,temp22);
509temp62 = simd_and(temp49,temp61);
510temp63 = simd_or(temp60,temp62);
511temp64 = simd_and(temp49,temp39);
512temp65 = simd_or(temp63,temp64);
513temp66 = simd_and(temp27,temp54);
514temp67 = simd_or(temp65,temp66);
515temp68 = simd_and(temp27,temp17);
516temp69 = simd_or(temp67,temp68);
517strct_Lex__Escape_ = simd_or(temp69,strct_Lex__u_);
518temp70 = simd_andc(temp49,array_bit__4_);
519temp71 = simd_andc(AllOne,temp28);
520Temp3 = simd_and(array_bit__5_,temp71);
521Temp4 = simd_andc(temp8,array_bit__5_);
522temp72 = simd_or(Temp3,Temp4);
523temp73 = simd_and(temp70,temp72);
524temp74 = simd_or(strct_Lex__Digit0_9_,temp73);
525temp75 = simd_andc(temp46,array_bit__4_);
526temp76 = simd_and(temp75,temp72);
527strct_Lex__HexDigit_ = simd_or(temp74,temp76);
528temp77 = simd_or(temp15,temp23);
529temp78 = simd_or(temp77,temp24);
530temp79 = simd_andc(temp78,temp20);
531strct_Lex__WS_ = simd_or(temp79,strct_Ctrl__SP_);
532strct_Lex__t_ = temp68;
533strct_Lex__r_ = temp66;
534strct_Lex__e_ = temp50;
535temp80 = simd_or(temp17,temp54);
536temp81 = simd_or(temp80,temp40);
537temp82 = simd_and(temp27,temp81);
538strct_Lex__True_ = simd_or(temp82,temp50);
539strct_Lex__f_ = temp62;
540temp83 = simd_andc(temp14,temp5);
541strct_Lex__a_ = simd_and(temp49,temp83);
542strct_Lex__l_ = simd_and(temp49,temp31);
543temp84 = simd_andc(temp28,temp5);
544strct_Lex__s_ = simd_and(temp27,temp84);
545temp85 = simd_or(temp61,temp83);
546temp86 = simd_or(temp85,temp31);
547temp87 = simd_and(temp49,temp86);
548temp88 = simd_or(temp87,strct_Lex__s_);
549strct_Lex__False_ = simd_or(temp88,temp50);
550strct_Lex__n_ = temp64;
551temp89 = simd_or(temp64,strct_Lex__u_);
552strct_Lex__Null_ = simd_or(temp89,strct_Lex__l_);
553advance_with_carry(strct_Lex__RSolidus_, carry0, Temp5);
554Start = simd_andc(strct_Lex__RSolidus_,Temp5);
555EvenStart = simd_and(Start,Even);
556adc128(EvenStart, strct_Lex__RSolidus_, carry1, Temp6);
557EvenFinal = simd_andc(Temp6,strct_Lex__RSolidus_);
558EvenEscape = simd_and(EvenFinal,Odd);
559OddStart = simd_and(Start,Odd);
560adc128(OddStart, strct_Lex__RSolidus_, carry2, Temp7);
561OddFinal = simd_andc(Temp7,strct_Lex__RSolidus_);
562OddEscape = simd_and(OddFinal,Even);
563Escape = simd_or(EvenEscape,OddEscape);
564UnescapedDQuotes = simd_andc(strct_Lex__DQuote_,Escape);
565
566                        /* Generate Parity Mask */
567                        high_bit_mask = sisd_high_bit_mask;
568                        high_bit_is_set = simd_and(high_bit_mask, bitblock_parity_mask);                       
569                        bitblock_parity_mask = sisd_add( simd_not(sisd_srl(high_bit_is_set, sisd_from_int(BLOCK_SIZE-1))) , sisd_low_bit_mask);                                         
570                        ParityMask = bitblock_parallel_prefix_parity(UnescapedDQuotes, bitblock_parity_mask);
571
572advance_with_carry(ParityMask, carry3, Temp8);
573StringMask = simd_and(ParityMask,Temp8);
574StringSpans = simd_or(StringMask,UnescapedDQuotes);
575Temp9 = simd_or(strct_Lex__True_,strct_Lex__False_);
576Temp10 = simd_or(Temp9,strct_Lex__Null_);
577Temp11 = simd_or(Temp10,strct_Lex__Number_);
578AtomSpans = simd_or(Temp11,StringSpans);
579advance_with_carry(AtomSpans, carry4, Temp12);
580AtomStarts = simd_andc(AtomSpans,Temp12);
581StringStarts = simd_and(AtomStarts,strct_Lex__DQuote_);
582NumberStarts = simd_and(AtomStarts,temp44);
583TrueStarts = simd_and(AtomStarts,temp68);
584FalseStarts = simd_and(AtomStarts,temp62);
585NullStarts = simd_and(AtomStarts,temp64);
586StringEscapeChars = simd_and(Escape,StringMask);
587StringErrors_17 = simd_andc(StringEscapeChars,strct_Lex__Escape_);
588u = simd_and(StringEscapeChars,strct_Lex__u_);
589advance_with_carry(u, carry5, uScope1);
590advance_with_carry(uScope1, carry6, uScope2);
591advance_with_carry(uScope2, carry7, uScope3);
592advance_with_carry(uScope3, carry8, uScope4);
593Temp13 = simd_andc(uScope1,strct_Lex__HexDigit_);
594StringErrors_18 = simd_or(StringErrors_17,Temp13);
595Temp14 = simd_andc(uScope2,strct_Lex__HexDigit_);
596StringErrors_19 = simd_or(StringErrors_18,Temp14);
597Temp15 = simd_andc(uScope3,strct_Lex__HexDigit_);
598StringErrors_20 = simd_or(StringErrors_19,Temp15);
599Temp16 = simd_andc(uScope4,strct_Lex__HexDigit_);
600StringErrors_21 = simd_or(StringErrors_20,Temp16);
601Temp17 = simd_or(Escape,strct_Lex__RSolidus_);
602StringNotEscapedChars = simd_andc(StringMask,Temp17);
603Temp18 = simd_and(StringNotEscapedChars,strct_Ctrl__x00_x1F_);
604StringErrors_22 = simd_or(StringErrors_21,Temp18);
605advance_with_carry(StringStarts, carry9, StringCursor);
606adc128(StringCursor, StringMask, carry10, Temp19);
607StringEnds = simd_andc(Temp19,StringMask);
608Temp20 = simd_andc(StringEnds,UnescapedDQuotes);
609StringErrors = simd_or(StringErrors_22,Temp20);
610M0 = NumberStarts;
611Temp21 = simd_and(strct_Lex__Minus_,NumberStarts);
612adc128(NumberStarts, Temp21, carry11, Temp22);
613M1_23 = simd_andc(Temp22,Temp21);
614Temp23 = simd_or(strct_Lex__Zero_,strct_Lex__Digit1_9_);
615E1 = simd_andc(M1_23,Temp23);
616M1 = simd_andc(M1_23,E1);
617M1a = simd_and(M1,strct_Lex__Zero_);
618M1b = simd_and(M1,strct_Lex__Digit1_9_);
619advance_with_carry(M1a, carry12, M2a);
620advance_with_carry(M1b, carry13, M2b);
621adc128(M2b, strct_Lex__Digit0_9_, carry14, Temp24);
622M3b = simd_andc(Temp24,strct_Lex__Digit0_9_);
623M4 = simd_or(M2a,M3b);
624M4a = simd_andc(M4,strct_Lex__DecimalPoint_);
625M4b = simd_and(M4,strct_Lex__DecimalPoint_);
626advance_with_carry(M4b, carry15, M5b_0);
627E5b = simd_andc(M5b_0,strct_Lex__Digit0_9_);
628M5b = simd_andc(M5b_0,E5b);
629adc128(M5b, strct_Lex__Digit0_9_, carry16, Temp25);
630M6 = simd_andc(Temp25,strct_Lex__Digit0_9_);
631M7 = simd_or(M4a,M6);
632M7a = simd_andc(M7,strct_Lex__Ee_);
633M7b = simd_and(M7,strct_Lex__Ee_);
634advance_with_carry(M7b, carry17, M8b);
635Temp26 = simd_and(strct_Lex__PlusMinus_,M8b);
636adc128(M8b, Temp26, carry18, Temp27);
637M9b_10 = simd_andc(Temp27,Temp26);
638E9b = simd_andc(M9b_10,strct_Lex__Digit0_9_);
639M9b = simd_andc(M9b_10,E9b);
640adc128(M9b, strct_Lex__Digit0_9_, carry19, Temp28);
641M10b = simd_andc(Temp28,strct_Lex__Digit0_9_);
642M11 = simd_or(M7a,M10b);
643Temp29 = simd_or(E1,E5b);
644NumberErrors = simd_or(Temp29,E9b);
645advance_with_carry(TrueStarts, carry20, Scope1_15);
646advance_with_carry(Scope1_15, carry21, Scope2_13);
647advance_with_carry(Scope2_13, carry22, Scope3_6);
648TrueErrors_4 = simd_andc(Scope1_15,temp66);
649Temp30 = simd_andc(Scope2_13,strct_Lex__u_);
650TrueErrors_5 = simd_or(TrueErrors_4,Temp30);
651Temp31 = simd_andc(Scope3_6,temp50);
652TrueErrors = simd_or(TrueErrors_5,Temp31);
653advance_with_carry(Scope3_6, carry23, Follows_8);
654sbb128(Follows_8, TrueStarts, carry_brw0, TrueSpans);
655advance_with_carry(FalseStarts, carry24, Scope1_16);
656advance_with_carry(Scope1_16, carry25, Scope2_14);
657advance_with_carry(Scope2_14, carry26, Scope3_7);
658advance_with_carry(Scope3_7, carry27, Scope4);
659FalseErrors_1 = simd_andc(Scope1_16,strct_Lex__a_);
660Temp32 = simd_andc(Scope2_14,strct_Lex__l_);
661FalseErrors_2 = simd_or(FalseErrors_1,Temp32);
662Temp33 = simd_andc(Scope3_7,strct_Lex__s_);
663FalseErrors_3 = simd_or(FalseErrors_2,Temp33);
664Temp34 = simd_andc(Scope4,temp50);
665FalseErrors = simd_or(FalseErrors_3,Temp34);
666advance_with_carry(Scope4, carry28, Follows_9);
667sbb128(Follows_9, FalseStarts, carry_brw1, FalseSpans);
668advance_with_carry(NullStarts, carry29, Scope1);
669advance_with_carry(Scope1, carry30, Scope2);
670advance_with_carry(Scope2, carry31, Scope3);
671Temp35 = simd_andc(Scope1,strct_Lex__u_);
672NullErrors_11 = simd_or(NullErrors,Temp35);
673Temp36 = simd_andc(Scope2,strct_Lex__l_);
674NullErrors_12 = simd_or(NullErrors_11,Temp36);
675Temp37 = simd_andc(Scope3,strct_Lex__l_);
676NullErrors = simd_or(NullErrors_12,Temp37);
677advance_with_carry(Scope3, carry32, Follows);
678sbb128(Follows, NullStarts, carry_brw2, NullSpans);
679Temp38 = simd_or(StringSpans,NumberSpans);
680Temp39 = simd_or(Temp38,TrueSpans);
681Temp40 = simd_or(Temp39,FalseSpans);
682AtomsSpans = simd_or(Temp40,NullSpans);
683Temp41 = simd_or(StringErrors,NumberErrors);
684Temp42 = simd_or(Temp41,TrueErrors);
685Temp43 = simd_or(Temp42,FalseErrors);
686error_mask = simd_or(Temp43,NullErrors);
687
688                       
689                        #ifdef DEBUG
690                       
691                        print_array_le("Data", &srcbuf[buf_pos],BLOCK_SIZE);
692                        print_simd_register("Escape", Escape);
693                        print_simd_register("Unescaped DQuote",UnescapedDQuotes);
694                        /*
695                        print_simd_register("high_bit_is_set", high_bit_is_set);
696                        print_simd_register("high_bit_mask", high_bit_mask);
697                        */
698                        print_simd_register("ParityMask", ParityMask);
699                        print_simd_register("StringMask", StringMask);
700                        print_simd_register("StringSpans", StringSpans);                                               
701               
702                        print_simd_register("AtomStarts", AtomStarts);
703                        print_simd_register("StringStarts", StringStarts);
704                        print_simd_register("NumberStarts", NumberStarts);
705                        print_simd_register("TrueStarts", TrueStarts);
706                        print_simd_register("FalseStarts", FalseStarts);
707                        print_simd_register("NullStarts", NullStarts);
708                        print_simd_register("AtomSpans", AtomSpans);
709                                               
710                        #endif
711                       
712                        if (bitblock_has_bit(error_mask)){
713                                err_pos = src_pos + buf_pos + count_forward_zeroes(error_mask) + 1;
714                                fprintf(stderr, "Error at position %i.\n", err_pos);
715                                exit(-1);
716                        }
717
718                        chars_avail -= BLOCK_SIZE;
719                        buf_pos += BLOCK_SIZE;
720                }               
721               
722                if(chars_avail > 0 /* || any_carry */) { /* process final partial block */
723                        /* extra */
724                        EOF_mask = sisd_srl(simd_const_1(1),sisd_from_int(BLOCK_SIZE-chars_avail));
725                                               
726                        BytePack * U8 = (BytePack *) &srcbuf[buf_pos];
727                       
728                        s2p(U8[0], U8[1], U8[2], U8[3], U8[4], U8[5], U8[6], U8[7],
729                        array_bit__0_,array_bit__1_,array_bit__2_,array_bit__3_,array_bit__4_,array_bit__5_,array_bit__6_,array_bit__7_);
730
731                        array_bit__0_ = simd_and(array_bit__0_, EOF_mask);
732                        array_bit__1_ = simd_and(array_bit__1_, EOF_mask);
733                        array_bit__2_ = simd_and(array_bit__2_, EOF_mask);
734                        array_bit__3_ = simd_and(array_bit__3_, EOF_mask);
735                        array_bit__4_ = simd_and(array_bit__4_, EOF_mask);
736                        array_bit__5_ = simd_and(array_bit__5_, EOF_mask);
737                        array_bit__6_ = simd_and(array_bit__6_, EOF_mask);
738                        array_bit__7_ = simd_and(array_bit__7_, EOF_mask);
739                       
740                        strct_u8__unibyte_ = simd_andc(AllOne,array_bit__0_);
741strct_u8__prefix_ = simd_and(array_bit__0_,array_bit__1_);
742strct_u8__prefix2_ = simd_andc(strct_u8__prefix_,array_bit__2_);
743temp1 = simd_andc(array_bit__2_,array_bit__3_);
744strct_u8__prefix3_ = simd_and(strct_u8__prefix_,temp1);
745temp2 = simd_and(array_bit__2_,array_bit__3_);
746strct_u8__prefix4_ = simd_and(strct_u8__prefix_,temp2);
747strct_u8__suffix_ = simd_andc(array_bit__0_,array_bit__1_);
748temp3 = simd_or(array_bit__2_,array_bit__3_);
749temp4 = simd_andc(strct_u8__prefix_,temp3);
750temp5 = simd_or(array_bit__4_,array_bit__5_);
751temp6 = simd_or(temp5,array_bit__6_);
752temp7 = simd_andc(temp4,temp6);
753temp8 = simd_or(array_bit__6_,array_bit__7_);
754temp9 = simd_and(array_bit__5_,temp8);
755temp10 = simd_or(array_bit__4_,temp9);
756temp11 = simd_and(strct_u8__prefix4_,temp10);
757strct_u8__badprefix_ = simd_or(temp7,temp11);
758temp12 = simd_or(temp5,temp8);
759strct_u8__xE0_ = simd_andc(strct_u8__prefix3_,temp12);
760temp13 = simd_and(array_bit__4_,array_bit__5_);
761temp14 = simd_andc(array_bit__7_,array_bit__6_);
762temp15 = simd_and(temp13,temp14);
763strct_u8__xED_ = simd_and(strct_u8__prefix3_,temp15);
764strct_u8__xF0_ = simd_andc(strct_u8__prefix4_,temp12);
765temp16 = simd_andc(array_bit__5_,array_bit__4_);
766temp17 = simd_andc(temp16,temp8);
767strct_u8__xF4_ = simd_and(strct_u8__prefix4_,temp17);
768strct_u8__xA0_xBF_ = simd_and(strct_u8__suffix_,array_bit__2_);
769strct_u8__x80_x9F_ = simd_andc(strct_u8__suffix_,array_bit__2_);
770strct_u8__x90_xBF_ = simd_and(strct_u8__suffix_,temp3);
771strct_u8__x80_x8F_ = simd_andc(strct_u8__suffix_,temp3);
772temp18 = simd_or(array_bit__0_,array_bit__1_);
773temp19 = simd_or(temp18,array_bit__2_);
774strct_Ctrl__x00_x1F_ = simd_andc(AllOne,temp19);
775temp20 = simd_or(temp18,temp3);
776strct_Ctrl__CR_ = simd_andc(temp15,temp20);
777temp21 = simd_andc(array_bit__4_,array_bit__5_);
778temp22 = simd_andc(array_bit__6_,array_bit__7_);
779temp23 = simd_and(temp21,temp22);
780strct_Ctrl__LF_ = simd_andc(temp23,temp20);
781temp24 = simd_and(temp21,temp14);
782strct_Ctrl__HT_ = simd_andc(temp24,temp20);
783temp25 = simd_andc(temp1,temp18);
784strct_Ctrl__SP_ = simd_andc(temp25,temp12);
785temp26 = simd_andc(array_bit__1_,array_bit__0_);
786temp27 = simd_and(temp26,temp2);
787temp28 = simd_and(array_bit__6_,array_bit__7_);
788temp29 = simd_and(temp21,temp28);
789strct_Lex__LCurlyBrace_ = simd_and(temp27,temp29);
790temp30 = simd_andc(temp2,temp18);
791strct_Lex__Colon_ = simd_and(temp30,temp23);
792temp31 = simd_andc(temp13,temp8);
793strct_Lex__Comma_ = simd_and(temp25,temp31);
794strct_Lex__RCurlyBrace_ = simd_and(temp27,temp15);
795temp32 = simd_andc(array_bit__3_,array_bit__2_);
796temp33 = simd_and(temp26,temp32);
797strct_Lex__LSquareBracket_ = simd_and(temp33,temp29);
798strct_Lex__RSquareBracket_ = simd_and(temp33,temp15);
799strct_Lex__Minus_ = simd_and(temp25,temp15);
800strct_Lex__Zero_ = simd_andc(temp30,temp12);
801temp34 = simd_or(array_bit__5_,array_bit__6_);
802temp35 = simd_andc(AllOne,temp34);
803temp36 = simd_or(array_bit__5_,temp8);
804Temp1 = simd_and(array_bit__4_,temp35);
805Temp2 = simd_andc(temp36,array_bit__4_);
806temp37 = simd_or(Temp1,Temp2);
807strct_Lex__Digit1_9_ = simd_and(temp30,temp37);
808temp38 = simd_and(array_bit__4_,temp34);
809strct_Lex__Digit0_9_ = simd_andc(temp30,temp38);
810temp39 = simd_and(temp13,temp22);
811strct_Lex__DecimalPoint_ = simd_and(temp25,temp39);
812temp40 = simd_and(temp16,temp14);
813temp41 = simd_andc(temp3,temp1);
814temp42 = simd_andc(temp26,temp41);
815strct_Lex__Ee_ = simd_and(temp40,temp42);
816temp43 = simd_or(temp29,temp15);
817strct_Lex__PlusMinus_ = simd_and(temp25,temp43);
818temp44 = simd_or(strct_Lex__Minus_,strct_Lex__Digit0_9_);
819temp45 = simd_or(temp44,strct_Lex__DecimalPoint_);
820temp46 = simd_andc(temp26,temp3);
821temp47 = simd_and(temp46,temp40);
822temp48 = simd_or(temp45,temp47);
823temp49 = simd_and(temp26,temp1);
824temp50 = simd_and(temp49,temp40);
825temp51 = simd_or(temp48,temp50);
826temp52 = simd_and(temp25,temp29);
827temp53 = simd_or(temp51,temp52);
828strct_Lex__Number_ = simd_or(temp53,strct_Lex__Minus_);
829temp54 = simd_andc(temp22,temp5);
830strct_Lex__DQuote_ = simd_and(temp25,temp54);
831strct_Lex__RSolidus_ = simd_and(temp33,temp31);
832strct_Lex__u_ = simd_and(temp27,temp40);
833temp55 = simd_or(strct_Lex__DQuote_,strct_Lex__RSolidus_);
834temp56 = simd_and(temp13,temp28);
835temp57 = simd_and(temp25,temp56);
836temp58 = simd_or(temp55,temp57);
837temp59 = simd_and(temp49,temp54);
838temp60 = simd_or(temp58,temp59);
839temp61 = simd_and(temp16,temp22);
840temp62 = simd_and(temp49,temp61);
841temp63 = simd_or(temp60,temp62);
842temp64 = simd_and(temp49,temp39);
843temp65 = simd_or(temp63,temp64);
844temp66 = simd_and(temp27,temp54);
845temp67 = simd_or(temp65,temp66);
846temp68 = simd_and(temp27,temp17);
847temp69 = simd_or(temp67,temp68);
848strct_Lex__Escape_ = simd_or(temp69,strct_Lex__u_);
849temp70 = simd_andc(temp49,array_bit__4_);
850temp71 = simd_andc(AllOne,temp28);
851Temp3 = simd_and(array_bit__5_,temp71);
852Temp4 = simd_andc(temp8,array_bit__5_);
853temp72 = simd_or(Temp3,Temp4);
854temp73 = simd_and(temp70,temp72);
855temp74 = simd_or(strct_Lex__Digit0_9_,temp73);
856temp75 = simd_andc(temp46,array_bit__4_);
857temp76 = simd_and(temp75,temp72);
858strct_Lex__HexDigit_ = simd_or(temp74,temp76);
859temp77 = simd_or(temp15,temp23);
860temp78 = simd_or(temp77,temp24);
861temp79 = simd_andc(temp78,temp20);
862strct_Lex__WS_ = simd_or(temp79,strct_Ctrl__SP_);
863strct_Lex__t_ = temp68;
864strct_Lex__r_ = temp66;
865strct_Lex__e_ = temp50;
866temp80 = simd_or(temp17,temp54);
867temp81 = simd_or(temp80,temp40);
868temp82 = simd_and(temp27,temp81);
869strct_Lex__True_ = simd_or(temp82,temp50);
870strct_Lex__f_ = temp62;
871temp83 = simd_andc(temp14,temp5);
872strct_Lex__a_ = simd_and(temp49,temp83);
873strct_Lex__l_ = simd_and(temp49,temp31);
874temp84 = simd_andc(temp28,temp5);
875strct_Lex__s_ = simd_and(temp27,temp84);
876temp85 = simd_or(temp61,temp83);
877temp86 = simd_or(temp85,temp31);
878temp87 = simd_and(temp49,temp86);
879temp88 = simd_or(temp87,strct_Lex__s_);
880strct_Lex__False_ = simd_or(temp88,temp50);
881strct_Lex__n_ = temp64;
882temp89 = simd_or(temp64,strct_Lex__u_);
883strct_Lex__Null_ = simd_or(temp89,strct_Lex__l_);
884advance_with_carry(strct_Lex__RSolidus_, carry0, Temp5);
885Start = simd_andc(strct_Lex__RSolidus_,Temp5);
886EvenStart = simd_and(Start,Even);
887adc128(EvenStart, strct_Lex__RSolidus_, carry1, Temp6);
888EvenFinal = simd_andc(Temp6,strct_Lex__RSolidus_);
889EvenEscape = simd_and(EvenFinal,Odd);
890OddStart = simd_and(Start,Odd);
891adc128(OddStart, strct_Lex__RSolidus_, carry2, Temp7);
892OddFinal = simd_andc(Temp7,strct_Lex__RSolidus_);
893OddEscape = simd_and(OddFinal,Even);
894Escape = simd_or(EvenEscape,OddEscape);
895UnescapedDQuotes = simd_andc(strct_Lex__DQuote_,Escape);
896
897                        /* Generate Parity Mask */
898                        high_bit_mask = sisd_srl(sisd_high_bit_mask, sisd_from_int(BLOCK_SIZE-chars_avail));
899                        high_bit_is_set = simd_and(high_bit_mask, bitblock_parity_mask);
900                        bitblock_parity_mask = sisd_add(simd_not(sisd_srl(high_bit_is_set, sisd_from_int(chars_avail-1))) , sisd_low_bit_mask);                 
901                        ParityMask = bitblock_parallel_prefix_parity(UnescapedDQuotes, bitblock_parity_mask);
902                        ParityMask = simd_and(ParityMask, EOF_mask);
903
904advance_with_carry(ParityMask, carry3, Temp8);
905StringMask = simd_and(ParityMask,Temp8);
906StringSpans = simd_or(StringMask,UnescapedDQuotes);
907Temp9 = simd_or(strct_Lex__True_,strct_Lex__False_);
908Temp10 = simd_or(Temp9,strct_Lex__Null_);
909Temp11 = simd_or(Temp10,strct_Lex__Number_);
910AtomSpans = simd_or(Temp11,StringSpans);
911advance_with_carry(AtomSpans, carry4, Temp12);
912AtomStarts = simd_andc(AtomSpans,Temp12);
913StringStarts = simd_and(AtomStarts,strct_Lex__DQuote_);
914NumberStarts = simd_and(AtomStarts,temp44);
915TrueStarts = simd_and(AtomStarts,temp68);
916FalseStarts = simd_and(AtomStarts,temp62);
917NullStarts = simd_and(AtomStarts,temp64);
918StringEscapeChars = simd_and(Escape,StringMask);
919StringErrors_17 = simd_andc(StringEscapeChars,strct_Lex__Escape_);
920u = simd_and(StringEscapeChars,strct_Lex__u_);
921advance_with_carry(u, carry5, uScope1);
922advance_with_carry(uScope1, carry6, uScope2);
923advance_with_carry(uScope2, carry7, uScope3);
924advance_with_carry(uScope3, carry8, uScope4);
925Temp13 = simd_andc(uScope1,strct_Lex__HexDigit_);
926StringErrors_18 = simd_or(StringErrors_17,Temp13);
927Temp14 = simd_andc(uScope2,strct_Lex__HexDigit_);
928StringErrors_19 = simd_or(StringErrors_18,Temp14);
929Temp15 = simd_andc(uScope3,strct_Lex__HexDigit_);
930StringErrors_20 = simd_or(StringErrors_19,Temp15);
931Temp16 = simd_andc(uScope4,strct_Lex__HexDigit_);
932StringErrors_21 = simd_or(StringErrors_20,Temp16);
933Temp17 = simd_or(Escape,strct_Lex__RSolidus_);
934StringNotEscapedChars = simd_andc(StringMask,Temp17);
935Temp18 = simd_and(StringNotEscapedChars,strct_Ctrl__x00_x1F_);
936StringErrors_22 = simd_or(StringErrors_21,Temp18);
937advance_with_carry(StringStarts, carry9, StringCursor);
938adc128(StringCursor, StringMask, carry10, Temp19);
939StringEnds = simd_andc(Temp19,StringMask);
940Temp20 = simd_andc(StringEnds,UnescapedDQuotes);
941StringErrors = simd_or(StringErrors_22,Temp20);
942M0 = NumberStarts;
943Temp21 = simd_and(strct_Lex__Minus_,NumberStarts);
944adc128(NumberStarts, Temp21, carry11, Temp22);
945M1_23 = simd_andc(Temp22,Temp21);
946Temp23 = simd_or(strct_Lex__Zero_,strct_Lex__Digit1_9_);
947E1 = simd_andc(M1_23,Temp23);
948M1 = simd_andc(M1_23,E1);
949M1a = simd_and(M1,strct_Lex__Zero_);
950M1b = simd_and(M1,strct_Lex__Digit1_9_);
951advance_with_carry(M1a, carry12, M2a);
952advance_with_carry(M1b, carry13, M2b);
953adc128(M2b, strct_Lex__Digit0_9_, carry14, Temp24);
954M3b = simd_andc(Temp24,strct_Lex__Digit0_9_);
955M4 = simd_or(M2a,M3b);
956M4a = simd_andc(M4,strct_Lex__DecimalPoint_);
957M4b = simd_and(M4,strct_Lex__DecimalPoint_);
958advance_with_carry(M4b, carry15, M5b_0);
959E5b = simd_andc(M5b_0,strct_Lex__Digit0_9_);
960M5b = simd_andc(M5b_0,E5b);
961adc128(M5b, strct_Lex__Digit0_9_, carry16, Temp25);
962M6 = simd_andc(Temp25,strct_Lex__Digit0_9_);
963M7 = simd_or(M4a,M6);
964M7a = simd_andc(M7,strct_Lex__Ee_);
965M7b = simd_and(M7,strct_Lex__Ee_);
966advance_with_carry(M7b, carry17, M8b);
967Temp26 = simd_and(strct_Lex__PlusMinus_,M8b);
968adc128(M8b, Temp26, carry18, Temp27);
969M9b_10 = simd_andc(Temp27,Temp26);
970E9b = simd_andc(M9b_10,strct_Lex__Digit0_9_);
971M9b = simd_andc(M9b_10,E9b);
972adc128(M9b, strct_Lex__Digit0_9_, carry19, Temp28);
973M10b = simd_andc(Temp28,strct_Lex__Digit0_9_);
974M11 = simd_or(M7a,M10b);
975Temp29 = simd_or(E1,E5b);
976NumberErrors = simd_or(Temp29,E9b);
977advance_with_carry(TrueStarts, carry20, Scope1_15);
978advance_with_carry(Scope1_15, carry21, Scope2_13);
979advance_with_carry(Scope2_13, carry22, Scope3_6);
980TrueErrors_4 = simd_andc(Scope1_15,temp66);
981Temp30 = simd_andc(Scope2_13,strct_Lex__u_);
982TrueErrors_5 = simd_or(TrueErrors_4,Temp30);
983Temp31 = simd_andc(Scope3_6,temp50);
984TrueErrors = simd_or(TrueErrors_5,Temp31);
985advance_with_carry(Scope3_6, carry23, Follows_8);
986sbb128(Follows_8, TrueStarts, carry_brw0, TrueSpans);
987advance_with_carry(FalseStarts, carry24, Scope1_16);
988advance_with_carry(Scope1_16, carry25, Scope2_14);
989advance_with_carry(Scope2_14, carry26, Scope3_7);
990advance_with_carry(Scope3_7, carry27, Scope4);
991FalseErrors_1 = simd_andc(Scope1_16,strct_Lex__a_);
992Temp32 = simd_andc(Scope2_14,strct_Lex__l_);
993FalseErrors_2 = simd_or(FalseErrors_1,Temp32);
994Temp33 = simd_andc(Scope3_7,strct_Lex__s_);
995FalseErrors_3 = simd_or(FalseErrors_2,Temp33);
996Temp34 = simd_andc(Scope4,temp50);
997FalseErrors = simd_or(FalseErrors_3,Temp34);
998advance_with_carry(Scope4, carry28, Follows_9);
999sbb128(Follows_9, FalseStarts, carry_brw1, FalseSpans);
1000advance_with_carry(NullStarts, carry29, Scope1);
1001advance_with_carry(Scope1, carry30, Scope2);
1002advance_with_carry(Scope2, carry31, Scope3);
1003Temp35 = simd_andc(Scope1,strct_Lex__u_);
1004NullErrors_11 = simd_or(NullErrors,Temp35);
1005Temp36 = simd_andc(Scope2,strct_Lex__l_);
1006NullErrors_12 = simd_or(NullErrors_11,Temp36);
1007Temp37 = simd_andc(Scope3,strct_Lex__l_);
1008NullErrors = simd_or(NullErrors_12,Temp37);
1009advance_with_carry(Scope3, carry32, Follows);
1010sbb128(Follows, NullStarts, carry_brw2, NullSpans);
1011Temp38 = simd_or(StringSpans,NumberSpans);
1012Temp39 = simd_or(Temp38,TrueSpans);
1013Temp40 = simd_or(Temp39,FalseSpans);
1014AtomsSpans = simd_or(Temp40,NullSpans);
1015Temp41 = simd_or(StringErrors,NumberErrors);
1016Temp42 = simd_or(Temp41,TrueErrors);
1017Temp43 = simd_or(Temp42,FalseErrors);
1018error_mask = simd_or(Temp43,NullErrors);
1019
1020                        #ifdef DEBUG
1021                       
1022                        print_array_le("Data", &srcbuf[buf_pos],BLOCK_SIZE);
1023                        print_simd_register("Escape", Escape);
1024                        print_simd_register("Unescaped DQuote",UnescapedDQuotes);
1025                        /*
1026                        print_simd_register("high_bit_is_set", high_bit_is_set);
1027                        print_simd_register("high_bit_mask", high_bit_mask);
1028                        */
1029                        print_simd_register("ParityMask", ParityMask);
1030                        print_simd_register("StringMask", StringMask);
1031                        print_simd_register("StringSpans", StringSpans);                                               
1032               
1033                        print_simd_register("AtomStarts", AtomStarts);
1034                        print_simd_register("StringStarts", StringStarts);
1035                        print_simd_register("NumberStarts", NumberStarts);
1036                        print_simd_register("TrueStarts", TrueStarts);
1037                        print_simd_register("FalseStarts", FalseStarts);
1038                        print_simd_register("NullStarts", NullStarts);
1039                        print_simd_register("AtomSpans", AtomSpans);
1040                                               
1041                        #endif
1042                       
1043                        if(bitblock_has_bit(error_mask)) {
1044                                err_pos = src_pos + buf_pos + count_forward_zeroes(error_mask) + 1;
1045                                fprintf(stderr, "Error at position %i.\n", err_pos);
1046                                exit(-1);
1047                        }
1048                }
1049               
1050                PERF_SEC_END(perf_timer, chars_avail);
1051
1052                src_pos += chars_read;
1053                buf_pos = 0;
1054
1055                chars_read = fread((void *)srcbuf, 1, BUFFER_SIZE, infile);
1056                chars_avail = chars_read;
1057                if(ferror(infile)) { fprintf(stderr, "Failed to read input file.\n"); return; }
1058                if(chars_avail==0 && feof(infile)) { return; } 
1059        }
1060}
1061
1062int main(int argc, char * argv[]) {
1063        char * infilename, * outfilename;       
1064        FILE *infile, *outfile;
1065        struct stat fileinfo;
1066
1067        if (argc < 2) {
1068                printf("Usage: %s <filename> [<outputfile>]\n", argv[0]);
1069                exit(-1);
1070        }
1071
1072        infilename = argv[1];
1073        stat(infilename, &fileinfo);
1074        infile = fopen(infilename, "rb");
1075        if (!infile) {
1076                fprintf(stderr, "Error: Cannot open %s for reading.\n", infilename);
1077                exit(-1);
1078        }
1079       
1080        if (argc < 3) {
1081                outfile = stdout;
1082        }       else {
1083                outfilename = argv[2];
1084                outfile = fopen(outfilename, "wb");
1085                if (!outfile) {
1086                        fprintf(stderr, "Error: Cannot open %s for writing.\n", outfilename);
1087                        exit(-1);
1088                }
1089        }
1090
1091        // PERF_SEC_BIND(1);
1092
1093        PERF_SEC_INIT(perf_timer);
1094
1095        do_process(infile, outfile);
1096       
1097        PERF_SEC_DUMP(perf_timer);
1098       
1099        PERF_SEC_DESTROY(perf_timer);
1100
1101        fclose(infile);
1102        fclose(outfile);
1103       
1104        return(0);
1105}
Note: See TracBrowser for help on using the repository browser.