38 #include <sys/types.h> 50 #include "llvm/Config/config.h" 58 {
"alnum",
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ 60 {
"alpha",
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
62 {
"blank",
" \t",
""} ,
63 {
"cntrl",
"\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\ 64 \25\26\27\30\31\32\33\34\35\36\37\177",
""} ,
65 {
"digit",
"0123456789",
""} ,
66 {
"graph",
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ 67 0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
69 {
"lower",
"abcdefghijklmnopqrstuvwxyz",
71 {
"print",
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ 72 0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ",
74 {
"punct",
"!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~",
76 {
"space",
"\t\n\v\f\r ",
""} ,
77 {
"upper",
"ABCDEFGHIJKLMNOPQRSTUVWXYZ",
79 {
"xdigit",
"0123456789ABCDEFabcdef",
99 {
"backspace",
'\b' },
105 {
"vertical-tab",
'\v' },
107 {
"form-feed",
'\f' },
109 {
"carriage-return",
'\r' },
133 {
"exclamation-mark",
'!' },
134 {
"quotation-mark",
'"' },
135 {
"number-sign",
'#' },
136 {
"dollar-sign",
'$' },
137 {
"percent-sign",
'%' },
138 {
"ampersand",
'&' },
139 {
"apostrophe",
'\'' },
140 {
"left-parenthesis",
'(' },
141 {
"right-parenthesis",
')' },
143 {
"plus-sign",
'+' },
146 {
"hyphen-minus",
'-' },
148 {
"full-stop",
'.' },
162 {
"semicolon",
';' },
163 {
"less-than-sign",
'<' },
164 {
"equals-sign",
'=' },
165 {
"greater-than-sign",
'>' },
166 {
"question-mark",
'?' },
167 {
"commercial-at",
'@' },
168 {
"left-square-bracket",
'[' },
169 {
"backslash",
'\\' },
170 {
"reverse-solidus",
'\\' },
171 {
"right-square-bracket",
']' },
172 {
"circumflex",
'^' },
173 {
"circumflex-accent",
'^' },
174 {
"underscore",
'_' },
176 {
"grave-accent",
'`' },
177 {
"left-brace",
'{' },
178 {
"left-curly-bracket",
'{' },
179 {
"vertical-line",
'|' },
180 {
"right-brace",
'}' },
181 {
"right-curly-bracket",
'}' },
249 #define PEEK() (*p->next) 250 #define PEEK2() (*(p->next+1)) 251 #define MORE() (p->next < p->end) 252 #define MORE2() (p->next+1 < p->end) 253 #define SEE(c) (MORE() && PEEK() == (c)) 254 #define SEETWO(a, b) (MORE() && MORE2() && PEEK() == (a) && PEEK2() == (b)) 255 #define EAT(c) ((SEE(c)) ? (NEXT(), 1) : 0) 256 #define EATTWO(a, b) ((SEETWO(a, b)) ? (NEXT2(), 1) : 0) 257 #define NEXT() (p->next++) 258 #define NEXT2() (p->next += 2) 259 #define NEXTn(n) (p->next += (n)) 260 #define GETNEXT() (*p->next++) 261 #define SETERROR(e) seterr(p, (e)) 262 #define REQUIRE(co, e) (void)((co) || SETERROR(e)) 263 #define MUSTSEE(c, e) (REQUIRE(MORE() && PEEK() == (c), e)) 264 #define MUSTEAT(c, e) (REQUIRE(MORE() && GETNEXT() == (c), e)) 265 #define MUSTNOTSEE(c, e) (REQUIRE(!MORE() || PEEK() != (c), e)) 266 #define EMIT(op, sopnd) doemit(p, (sop)(op), (size_t)(sopnd)) 267 #define INSERT(op, pos) doinsert(p, (sop)(op), HERE()-(pos)+1, pos) 268 #define AHEAD(pos) dofwd(p, pos, HERE()-(pos)) 269 #define ASTERN(sop, pos) EMIT(sop, HERE()-pos) 270 #define HERE() (p->slen) 271 #define THERE() (p->slen - 1) 272 #define THERETHERE() (p->slen - 2) 273 #define DROP(n) (p->slen -= (n)) 275 #ifdef _POSIX2_RE_DUP_MAX 276 #define DUPMAX _POSIX2_RE_DUP_MAX 280 #define INFINITY (DUPMAX + 1) 283 static int never = 0;
296 struct parse *p = &pa;
300 # define GOODFLAGS(f) (f) 302 # define GOODFLAGS(f) ((f)&~REG_DUMP) 314 len = strlen((
const char *)pattern);
324 if (p->
strip == NULL) {
331 p->
next = (
char *)pattern;
335 for (i = 0; i <
NPAREN; i++) {
358 if (cflags®_EXTENDED)
360 else if (cflags®_NOSPEC)
403 while (
MORE() && (c =
PEEK()) !=
'|' && c != stop)
466 #ifndef POSIX_MISTAKE 509 if (c >=
'1' && c <=
'9') {
515 backrefnum = c -
'0';
516 if (p->
pend[backrefnum] == 0) {
524 assert(backrefnum <= p->g->nsub);
550 if (!( c ==
'*' || c ==
'+' || c ==
'?' ||
587 repeat(p, pos, count, count2);
600 if (!( c ==
'*' || c ==
'+' || c ==
'?' ||
668 # define BACKSL (1<<CHAR_BIT) 722 if (p->
pend[i] != 0) {
748 }
else if (
EATTWO(
'\\',
'{')) {
758 repeat(p, pos, count, count2);
781 count = count*10 + (
GETNEXT() -
'0');
802 if (p->
next + 5 < p->
end && strncmp(p->
next,
"[:<:]]", 6) == 0) {
807 if (p->
next + 5 < p->
end && strncmp(p->
next,
"[:>:]]", 6) == 0) {
839 for (i = p->
g->
csetsize - 1; i >= 0; i--)
840 if (
CHIN(cs, i) && isalpha(i)) {
851 for (i = p->
g->
csetsize - 1; i >= 0; i--)
864 if (
nch(p, cs) == 1) {
928 for (i = start; i <= finish; i++)
950 if (strncmp(cp->
name, sp, len) == 0 && cp->
name[len] ==
'\0')
952 if (cp->
name == NULL) {
959 while ((c = *u++) !=
'\0')
961 for (u = cp->
multis; *u !=
'\0'; u += strlen(u) + 1)
1016 if (strncmp(cp->
name, sp, len) == 0 && strlen(cp->
name) == len)
1033 return ((
uch)tolower(ch));
1034 else if (islower(ch))
1035 return ((
uch)toupper(ch));
1048 char *oldnext = p->
next;
1049 char *oldend = p->
end;
1090 char *oldnext = p->
next;
1091 char *oldend = p->
end;
1118 # define REP(f, t) ((f)*8 + (t)) 1119 # define MAP(n) (((n) <= 1) ? (n) : ((n) == INFINITY) ? INF : N) 1136 repeat(p, start+1, 1, to);
1154 copy =
dupl(p, start+1, finish+1);
1155 assert(copy == finish+4);
1156 repeat(p, copy, 1, to-1);
1163 copy =
dupl(p, start, finish);
1164 repeat(p, copy, from-1, to-1);
1167 copy =
dupl(p, start, finish);
1168 repeat(p, copy, from-1, to);
1207 if (nc > SIZE_MAX /
sizeof(
cset))
1209 assert(nc % CHAR_BIT == 0);
1210 nbytes = nc / CHAR_BIT * css;
1212 ptr = (
cset *)realloc((
char *)p->
g->
sets, nc *
sizeof(
cset));
1217 ptr = (
uch *)realloc((
char *)p->
g->
setbits, nbytes);
1222 for (i = 0; i < no; i++)
1231 cs = &p->
g->
sets[no];
1233 cs->
mask = 1 << ((no) % CHAR_BIT);
1260 for (i = 0; i < css; i++)
1285 for (cs2 = &p->
g->
sets[0]; cs2 < top; cs2++)
1286 if (cs2->
hash == h && cs2 != cs) {
1288 for (i = 0; i < css; i++)
1289 if (!!
CHIN(cs2, i) != !!
CHIN(cs, i))
1300 return((
int)(cs - p->
g->
sets));
1312 for (i = 0; i < css; i++)
1329 for (i = 0; i < css; i++)
1344 cs->
smultis += strlen(cp) + 1;
1392 int ncols = (g->
ncsets+(CHAR_BIT-1)) / CHAR_BIT;
1393 unsigned uc = (
uch)c;
1395 for (i = 0, col = g->
setbits; i < ncols; i++, col += g->csetsize)
1409 int ncols = (g->
ncsets+(CHAR_BIT-1)) / CHAR_BIT;
1410 unsigned uc1 = (
uch)c1;
1411 unsigned uc2 = (
uch)c2;
1413 for (i = 0, col = g->
setbits; i < ncols; i++, col += g->csetsize)
1414 if (col[uc1] != col[uc2])
1434 for (c = CHAR_MIN; c <= CHAR_MAX; c++)
1435 if (cats[c] == 0 &&
isinsets(g, c)) {
1438 for (c2 = c+1; c2 <= CHAR_MAX; c2++)
1439 if (cats[c2] == 0 &&
samesets(g, c, c2))
1453 sopno len = finish - start;
1461 (
char *)(p->
strip + start), (
size_t)len*
sizeof(
sop));
1513 for (i = 1; i <
NPAREN; i++) {
1514 if (p->
pbegin[i] >= pos) {
1517 if (p->
pend[i] >= pos) {
1549 if (p->
ssize >= size)
1552 if ((uintptr_t)size > SIZE_MAX /
sizeof(
sop)) {
1573 if ((uintptr_t)p->
slen > SIZE_MAX /
sizeof(
sop)) {
1580 if (g->
strip == NULL) {
1612 scan = g->
strip + 1;
1618 newstart = scan - 1;
1640 if (newlen > g->
mlen) {
1653 g->
must = malloc((
size_t)g->
mlen + 1);
1654 if (g->
must == NULL) {
1660 for (i = g->
mlen; i > 0; i--) {
1661 while (
OP(s = *scan++) !=
OCHAR)
1684 scan = g->
strip + 1;
1692 if (plusnest > maxnest)
static void nonnewline(struct parse *)
static void p_ere_exp(struct parse *)
static int p_simp_re(struct parse *, int)
static int firstch(struct parse *, cset *)
static int samesets(struct re_guts *, int, int)
static int freezeset(struct parse *, cset *)
static struct cname cnames[]
static void mccase(struct parse *, cset *)
static void p_b_term(struct parse *, cset *)
static void categorize(struct parse *, struct re_guts *)
static void findmust(struct parse *, struct re_guts *)
int llvm_regcomp(llvm_regex_t *preg, const char *pattern, int cflags)
static int seterr(struct parse *, int)
void llvm_regfree(llvm_regex_t *)
static cset * allocset(struct parse *)
static void stripsnug(struct parse *, struct re_guts *)
static void dofwd(struct parse *, sopno, sop)
static void doemit(struct parse *, sop, size_t)
static void bothcases(struct parse *, int)
static int nch(struct parse *, cset *)
size_t llvm_strlcpy(char *dst, const char *src, size_t siz)
static void enlarge(struct parse *, sopno)
static void p_ere(struct parse *, int)
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
* if(!EatIfPresent(lltok::kw_thread_local)) return false
ParseOptionalThreadLocal := /*empty.
static void mcadd(struct parse *, cset *, const char *)
static void doinsert(struct parse *, sop, size_t, sopno)
static void p_b_cclass(struct parse *, cset *)
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
static void p_bracket(struct parse *)
static void freeset(struct parse *, cset *)
static char p_b_symbol(struct parse *)
static void ordinary(struct parse *, int)
static void p_bre(struct parse *, int, int)
static int p_count(struct parse *)
static char p_b_coll_elem(struct parse *, int)
static void p_b_eclass(struct parse *, cset *)
static char othercase(int)
static sopno dupl(struct parse *, sopno, sopno)
static struct cclass cclasses[]
static void repeat(struct parse *, sopno, int, int)
static sopno pluscount(struct parse *, struct re_guts *)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void p_str(struct parse *)
static int isinsets(struct re_guts *, int)
for(unsigned i=Desc.getNumOperands(), e=OldMI.getNumOperands();i !=e;++i)
OutputIt copy(R &&Range, OutputIt Out)
static Expected< BitVector > scan(StringRef &S, StringRef Original)
static void mcinvert(struct parse *, cset *)