LLVM: lib/Support/regexec.c Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45#include <sys/types.h>
46#include <stdio.h>
47#include <stdlib.h>
48#include <string.h>
49#include <limits.h>
50#include <ctype.h>
52
55
56
57
58#define states1 long
59#define states states1
60#define CLEAR(v) ((v) = 0)
61#define SET0(v, n) ((v) &= ~((unsigned long)1 << (n)))
62#define SET1(v, n) ((v) |= (unsigned long)1 << (n))
63#define ISSET(v, n) (((v) & ((unsigned long)1 << (n))) != 0)
64#define ASSIGN(d, s) ((d) = (s))
65#define EQ(a, b) ((a) == (b))
66#define STATEVARS long dummy
67#define STATESETUP(m, n)
68#define STATETEARDOWN(m)
69#define SETUP(v) ((v) = 0)
70#define onestate long
71#define INIT(o, n) ((o) = (unsigned long)1 << (n))
72#define INC(o) ((o) = (unsigned long)(o) << 1)
73#define ISSTATEIN(v, o) (((v) & (o)) != 0)
74
75
76#define FWD(dst, src, n) ((dst) |= ((unsigned long)(src)&(here)) << (n))
77#define BACK(dst, src, n) ((dst) |= ((unsigned long)(src)&(here)) >> (n))
78#define ISSETBACK(v, n) (((v) & ((unsigned long)here >> (n))) != 0)
79
80#define SNAMES
81
83
84
85#undef states
86#undef CLEAR
87#undef SET0
88#undef SET1
89#undef ISSET
90#undef ASSIGN
91#undef EQ
92#undef STATEVARS
93#undef STATESETUP
94#undef STATETEARDOWN
95#undef SETUP
96#undef onestate
97#undef INIT
98#undef INC
99#undef ISSTATEIN
100#undef FWD
101#undef BACK
102#undef ISSETBACK
103#undef SNAMES
104
105
106#define states char *
107#define CLEAR(v) memset(v, 0, m->g->nstates)
108#define SET0(v, n) ((v)[n] = 0)
109#define SET1(v, n) ((v)[n] = 1)
110#define ISSET(v, n) ((v)[n])
111#define ASSIGN(d, s) memmove(d, s, m->g->nstates)
112#define EQ(a, b) (memcmp(a, b, m->g->nstates) == 0)
113#define STATEVARS long vn; char *space
114#define STATESETUP(m, nv) { (m)->space = malloc((nv)*(m)->g->nstates); \
115 if ((m)->space == NULL) return(REG_ESPACE); \
116 (m)->vn = 0; }
117#define STATETEARDOWN(m) { free((m)->space); }
118#define SETUP(v) ((v) = &m->space[m->vn++ * m->g->nstates])
119#define onestate long
120#define INIT(o, n) ((o) = (n))
121#define INC(o) ((o)++)
122#define ISSTATEIN(v, o) ((v)[o])
123
124
125#define FWD(dst, src, n) ((dst)[here+(n)] |= (src)[here])
126#define BACK(dst, src, n) ((dst)[here-(n)] |= (src)[here])
127#define ISSETBACK(v, n) ((v)[here - (n)])
128
129#define LNAMES
130
132
133
134
135
136
137
138
139
140int
143{
145#ifdef REDEBUG
146# define GOODFLAGS(f) (f)
147#else
148# define GOODFLAGS(f) ((f)&(REG_NOTBOL|REG_NOTEOL|REG_STARTEND))
149#endif
150
157
158 if (g->nstates <= (long)(CHAR_BIT*sizeof(states1)) && !(eflags®_LARGE))
159 return(smatcher(g, string, nmatch, pmatch, eflags));
160 else
161 return(lmatcher(g, string, nmatch, pmatch, eflags));
162}
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
INLINE void g(uint32_t *state, size_t a, size_t b, size_t c, size_t d, uint32_t x, uint32_t y)
int llvm_regexec(const llvm_regex_t *preg, const char *string, size_t nmatch, llvm_regmatch_t pmatch[], int eflags)