50#include "llvm/Config/config.h"
59 {
"alnum",
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
61 {
"alpha",
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
63 {
"blank",
" \t",
""} ,
64 {
"cntrl",
"\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\
65\25\26\27\30\31\32\33\34\35\36\37\177",
""} ,
66 {
"digit",
"0123456789",
""} ,
67 {
"graph",
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
680123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
70 {
"lower",
"abcdefghijklmnopqrstuvwxyz",
72 {
"print",
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\
730123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ",
75 {
"punct",
"!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
77 {
"space",
"\t\n\v\f\r ",
""} ,
78 {
"upper",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
80 {
"xdigit",
"0123456789ABCDEFabcdef",
100 {
"backspace",
'\b' },
106 {
"vertical-tab",
'\v' },
108 {
"form-feed",
'\f' },
110 {
"carriage-return",
'\r' },
134 {
"exclamation-mark",
'!' },
135 {
"quotation-mark",
'"' },
136 {
"number-sign",
'#' },
137 {
"dollar-sign",
'$' },
138 {
"percent-sign",
'%' },
139 {
"ampersand",
'&' },
140 {
"apostrophe",
'\'' },
141 {
"left-parenthesis",
'(' },
142 {
"right-parenthesis",
')' },
144 {
"plus-sign",
'+' },
147 {
"hyphen-minus",
'-' },
149 {
"full-stop",
'.' },
163 {
"semicolon",
';' },
164 {
"less-than-sign",
'<' },
165 {
"equals-sign",
'=' },
166 {
"greater-than-sign",
'>' },
167 {
"question-mark",
'?' },
168 {
"commercial-at",
'@' },
169 {
"left-square-bracket",
'[' },
170 {
"backslash",
'\\' },
171 {
"reverse-solidus",
'\\' },
172 {
"right-square-bracket",
']' },
173 {
"circumflex",
'^' },
174 {
"circumflex-accent",
'^' },
175 {
"underscore",
'_' },
177 {
"grave-accent",
'`' },
178 {
"left-brace",
'{' },
179 {
"left-curly-bracket",
'{' },
180 {
"vertical-line",
'|' },
181 {
"right-brace",
'}' },
182 {
"right-curly-bracket",
'}' },
250#define PEEK() (*p->next)
251#define PEEK2() (*(p->next+1))
252#define MORE() (p->end - p->next > 0)
253#define MORE2() (p->end - p->next > 1)
254#define SEE(c) (MORE() && PEEK() == (c))
255#define SEETWO(a, b) (MORE2() && PEEK() == (a) && PEEK2() == (b))
256#define EAT(c) ((SEE(c)) ? (NEXT(), 1) : 0)
257#define EATTWO(a, b) ((SEETWO(a, b)) ? (NEXT2(), 1) : 0)
258#define NEXT() (p->next++)
259#define NEXT2() (p->next += 2)
260#define NEXTn(n) (p->next += (n))
261#define GETNEXT() (*p->next++)
262#define SETERROR(e) seterr(p, (e))
263#define REQUIRE(co, e) (void)((co) || SETERROR(e))
264#define MUSTSEE(c, e) (REQUIRE(MORE() && PEEK() == (c), e))
265#define MUSTEAT(c, e) (REQUIRE(MORE() && GETNEXT() == (c), e))
266#define MUSTNOTSEE(c, e) (REQUIRE(!MORE() || PEEK() != (c), e))
267#define EMIT(op, sopnd) doemit(p, (sop)(op), (size_t)(sopnd))
268#define INSERT(op, pos) doinsert(p, (sop)(op), HERE()-(pos)+1, pos)
269#define AHEAD(pos) dofwd(p, pos, HERE()-(pos))
270#define ASTERN(sop, pos) EMIT(sop, HERE()-pos)
271#define HERE() (p->slen)
272#define THERE() (p->slen - 1)
273#define THERETHERE() (p->slen - 2)
274#define DROP(n) (p->slen -= (n))
276#ifdef _POSIX2_RE_DUP_MAX
277#define DUPMAX _POSIX2_RE_DUP_MAX
281#define REGINFINITY (DUPMAX + 1)
297 struct parse *p = &pa;
301# define GOODFLAGS(f) (f)
303# define GOODFLAGS(f) ((f)&~REG_DUMP)
315 len = strlen((
const char *)pattern);
322 p->ssize = len/(size_t)2*(
size_t)3 + (size_t)1;
323 p->strip = (
sop *)calloc(p->ssize,
sizeof(
sop));
325 if (p->strip == NULL) {
333 p->end = p->next + len;
336 for (i = 0; i <
NPAREN; i++) {
352 g->categories = &
g->catspace[-(CHAR_MIN)];
353 (void) memset((
char *)
g->catspace, 0,
NC*
sizeof(
cat_t));
404 while (
MORE() && (c =
PEEK()) !=
'|' && c != stop)
456 p->pbegin[subno] =
HERE();
461 p->pend[subno] =
HERE();
462 assert(p->pend[subno] != 0);
510 if (c >=
'1' && c <=
'9') {
516 backrefnum = c -
'0';
517 if (p->pend[backrefnum] == 0) {
525 assert(backrefnum <= p->
g->nsub);
527 assert(p->pbegin[backrefnum] != 0);
530 (void)
dupl(p, p->pbegin[backrefnum]+1, p->pend[backrefnum]);
551 if (!( c ==
'*' || c ==
'+' || c ==
'?' ||
588 repeat(p, pos, count, count2);
601 if (!( c ==
'*' || c ==
'+' || c ==
'?' ||
669# define BACKSL (1<<CHAR_BIT)
696 p->pbegin[subno] =
HERE();
702 p->pend[subno] =
HERE();
703 assert(p->pend[subno] != 0);
721 i = (c&~BACKSL) -
'0';
723 if (p->pend[i] != 0) {
726 assert(p->pbegin[i] != 0);
729 (void)
dupl(p, p->pbegin[i]+1, p->pend[i]);
749 }
else if (
EATTWO(
'\\',
'{')) {
759 repeat(p, pos, count, count2);
782 count = count*10 + (
GETNEXT() -
'0');
803 if (p->end - p->next > 5) {
804 if (strncmp(p->next,
"[:<:]]", 6) == 0) {
809 if (strncmp(p->next,
"[:>:]]", 6) == 0) {
842 for (i = p->g->csetsize - 1; i >= 0; i--)
843 if (
CHIN(cs, i) && isalpha(i)) {
854 for (i = p->g->csetsize - 1; i >= 0; i--)
867 if (
nch(p, cs) == 1) {
931 for (i = start; i <= finish; i++)
943 const char *sp = p->next;
953 if (strncmp(cp->
name, sp, len) == 0 && cp->
name[len] ==
'\0')
955 if (cp->
name == NULL) {
962 while ((c = *u++) !=
'\0')
964 for (u = cp->
multis; *u !=
'\0'; u += strlen(u) + 1)
1007 const char *sp = p->next;
1019 if (strncmp(cp->
name, sp, len) == 0 && strlen(cp->
name) == len)
1036 return ((
uch)tolower(ch));
1037 else if (islower(ch))
1038 return ((
uch)toupper(ch));
1051 const char *oldnext = p->next;
1052 const char *oldend = p->end;
1063 assert(p->next == bracket+2);
1074 cat_t *cap = p->g->categories;
1081 cap[ch] = p->g->ncategories++;
1093 const char *oldnext = p->next;
1094 const char *oldend = p->end;
1095 static const char bracket[4] = {
'^',
'\n',
']',
'\0'};
1100 assert(p->next == bracket+3);
1117# define REP(f, t) ((f)*8 + (t))
1118# define MAP(n) (((n) <= 1) ? (n) : ((n) == REGINFINITY) ? INF : N)
1135 repeat(p, start+1, 1, to);
1153 copy =
dupl(p, start+1, finish+1);
1154 assert(copy == finish+4);
1155 repeat(p, copy, 1, to-1);
1162 copy =
dupl(p, start, finish);
1163 repeat(p, copy, from-1, to-1);
1166 copy =
dupl(p, start, finish);
1167 repeat(p, copy, from-1, to);
1194 int no = p->g->ncsets++;
1198 size_t css = (size_t)p->g->csetsize;
1201 if (no >= p->ncsalloc) {
1204 p->ncsalloc += CHAR_BIT;
1206 if (nc > SIZE_MAX /
sizeof(
cset))
1208 assert(nc % CHAR_BIT == 0);
1209 nbytes = nc / CHAR_BIT * css;
1211 ptr = (
cset *)realloc((
char *)p->g->sets, nc *
sizeof(
cset));
1216 ptr = (
uch *)realloc((
char *)p->g->setbits, nbytes);
1219 p->g->setbits = ptr;
1221 for (i = 0; i < no; i++)
1222 p->g->sets[i].ptr = p->g->setbits + css*(i/CHAR_BIT);
1224 (void) memset((
char *)p->g->setbits + (nbytes - css), 0, css);
1227 if (p->g->sets == NULL || p->g->setbits == NULL)
1230 cs = &p->g->sets[no];
1231 cs->
ptr = p->g->setbits + css*((no)/CHAR_BIT);
1232 cs->
mask = 1 << ((no) % CHAR_BIT);
1241 free(p->g->setbits);
1242 p->g->setbits = NULL;
1256 cset *top = &p->g->sets[p->g->ncsets];
1257 size_t css = (size_t)p->g->csetsize;
1259 for (i = 0; i < css; i++)
1279 cset *top = &p->g->sets[p->g->ncsets];
1281 size_t css = (size_t)p->g->csetsize;
1284 for (cs2 = &p->g->sets[0]; cs2 < top; cs2++)
1285 if (cs2->
hash == h && cs2 != cs) {
1287 for (i = 0; i < css; i++)
1288 if (!!
CHIN(cs2, i) != !!
CHIN(cs, i))
1299 return((
int)(cs - p->g->sets));
1309 size_t css = (size_t)p->g->csetsize;
1311 for (i = 0; i < css; i++)
1325 size_t css = (size_t)p->g->csetsize;
1328 for (i = 0; i < css; i++)
1343 cs->
smultis += strlen(cp) + 1;
1391 int ncols = (
g->ncsets+(CHAR_BIT-1)) / CHAR_BIT;
1392 unsigned uc = (
uch)c;
1394 for (i = 0, col =
g->setbits; i < ncols; i++, col += g->csetsize)
1408 int ncols = (
g->ncsets+(CHAR_BIT-1)) / CHAR_BIT;
1409 unsigned uc1 = (
uch)c1;
1410 unsigned uc2 = (
uch)c2;
1412 for (i = 0, col =
g->setbits; i < ncols; i++, col += g->csetsize)
1413 if (col[uc1] != col[uc2])
1424 cat_t *cats =
g->categories;
1433 for (c = CHAR_MIN; c <= CHAR_MAX; c++)
1435 cat =
g->ncategories++;
1437 for (c2 = c+1; c2 <= CHAR_MAX; c2++)
1438 if (cats[c2] == 0 &&
samesets(
g, c, c2))
1452 sopno len = finish - start;
1458 assert(p->ssize >= p->slen + len);
1459 (void) memmove((
char *)(p->strip + p->slen),
1460 (
char *)(p->strip + start), (
size_t)len*
sizeof(
sop));
1483 if (p->slen >= p->ssize)
1484 enlarge(p, (p->ssize+1) / 2 * 3);
1485 assert(p->slen < p->ssize);
1488 p->strip[p->slen++] =
SOP(
op, opnd);
1512 for (i = 1; i <
NPAREN; i++) {
1513 if (p->pbegin[i] >= pos) {
1516 if (p->pend[i] >= pos) {
1521 memmove((
char *)&p->strip[pos+1], (
char *)&p->strip[pos],
1537 p->strip[pos] =
OP(p->strip[pos]) |
value;
1548 if (p->ssize >= size)
1551 if ((uintptr_t)size > SIZE_MAX /
sizeof(
sop)) {
1556 sp = (
sop *)realloc(p->strip, size*
sizeof(
sop));
1571 g->nstates = p->slen;
1572 if ((uintptr_t)p->slen > SIZE_MAX /
sizeof(
sop)) {
1573 g->strip = p->strip;
1578 g->strip = (
sop *)realloc((
char *)p->strip, p->slen *
sizeof(
sop));
1579 if (
g->strip == NULL) {
1581 g->strip = p->strip;
1611 scan =
g->strip + 1;
1617 newstart = scan - 1;
1639 if (newlen >
g->mlen) {
1652 g->must = malloc((
size_t)
g->mlen + 1);
1653 if (
g->must == NULL) {
1659 for (i =
g->mlen; i > 0; i--) {
1660 while (
OP(s = *scan++) !=
OCHAR)
1662 assert(cp < g->must +
g->mlen);
1683 scan =
g->strip + 1;
1691 if (plusnest > maxnest)
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
Given that RA is a live value
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)
static void mccase(struct parse *, cset *)
static int samesets(struct re_guts *, int, int)
static void stripsnug(struct parse *, struct re_guts *)
static void mcadd(struct parse *, cset *, const char *)
static char p_b_coll_elem(struct parse *, int)
static void p_ere_exp(struct parse *)
static sopno dupl(struct parse *, sopno, sopno)
static char othercase(int)
static void p_b_cclass(struct parse *, cset *)
static void doemit(struct parse *, sop, size_t)
static void nonnewline(struct parse *)
static void p_b_eclass(struct parse *, cset *)
static int freezeset(struct parse *, cset *)
static struct cclass cclasses[]
static struct cname cnames[]
static void ordinary(struct parse *, int)
static void categorize(struct parse *, struct re_guts *)
static void p_str(struct parse *)
static void bothcases(struct parse *, int)
static void repeat(struct parse *, sopno, int, int)
int llvm_regcomp(llvm_regex_t *preg, const char *pattern, int cflags)
static void p_b_term(struct parse *, cset *)
static int isinsets(struct re_guts *, int)
static void p_bre(struct parse *, int, int)
static int nch(struct parse *, cset *)
static void doinsert(struct parse *, sop, size_t, sopno)
static sopno pluscount(struct parse *, struct re_guts *)
static void p_ere(struct parse *, int)
static char p_b_symbol(struct parse *)
static void findmust(struct parse *, struct re_guts *)
static cset * allocset(struct parse *)
static void p_bracket(struct parse *)
static void dofwd(struct parse *, sopno, sop)
static int p_count(struct parse *)
static void enlarge(struct parse *, sopno)
static int p_simp_re(struct parse *, int)
static void freeset(struct parse *, cset *)
static void mcinvert(struct parse *, cset *)
static int seterr(struct parse *, int)
static int firstch(struct parse *, cset *)
size_t llvm_strlcpy(char *dst, const char *src, size_t siz)
void llvm_regfree(llvm_regex_t *)