Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
llvm-epi
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Roger Ferrer
llvm-epi
Commits
96fe532c
Commit
96fe532c
authored
14 years ago
by
Chris Lattner
Browse files
Options
Downloads
Patches
Plain Diff
allow specifying an indentation level for the string matcher.
llvm-svn: 113143
parent
497d13e8
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
llvm/utils/TableGen/StringMatcher.cpp
+11
-7
11 additions, 7 deletions
llvm/utils/TableGen/StringMatcher.cpp
llvm/utils/TableGen/StringMatcher.h
+1
-1
1 addition, 1 deletion
llvm/utils/TableGen/StringMatcher.h
with
12 additions
and
8 deletions
llvm/utils/TableGen/StringMatcher.cpp
+
11
−
7
View file @
96fe532c
...
@@ -112,7 +112,10 @@ EmitStringMatcherForChar(const std::vector<const StringPair*> &Matches,
...
@@ -112,7 +112,10 @@ EmitStringMatcherForChar(const std::vector<const StringPair*> &Matches,
/// Emit - Top level entry point.
/// Emit - Top level entry point.
///
///
void
StringMatcher
::
Emit
()
const
{
void
StringMatcher
::
Emit
(
unsigned
Indent
)
const
{
// If nothing to match, just fall through.
if
(
Matches
.
empty
())
return
;
// First level categorization: group strings by length.
// First level categorization: group strings by length.
std
::
map
<
unsigned
,
std
::
vector
<
const
StringPair
*>
>
MatchesByLength
;
std
::
map
<
unsigned
,
std
::
vector
<
const
StringPair
*>
>
MatchesByLength
;
...
@@ -121,16 +124,17 @@ void StringMatcher::Emit() const {
...
@@ -121,16 +124,17 @@ void StringMatcher::Emit() const {
// Output a switch statement on length and categorize the elements within each
// Output a switch statement on length and categorize the elements within each
// bin.
// bin.
OS
<<
"
switch ("
<<
StrVariableName
<<
".size()) {
\n
"
;
OS
.
indent
(
Indent
*
2
+
2
)
<<
"switch ("
<<
StrVariableName
<<
".size()) {
\n
"
;
OS
<<
"
default: break;
\n
"
;
OS
.
indent
(
Indent
*
2
+
2
)
<<
"default: break;
\n
"
;
for
(
std
::
map
<
unsigned
,
std
::
vector
<
const
StringPair
*>
>::
iterator
LI
=
for
(
std
::
map
<
unsigned
,
std
::
vector
<
const
StringPair
*>
>::
iterator
LI
=
MatchesByLength
.
begin
(),
E
=
MatchesByLength
.
end
();
LI
!=
E
;
++
LI
)
{
MatchesByLength
.
begin
(),
E
=
MatchesByLength
.
end
();
LI
!=
E
;
++
LI
)
{
OS
<<
" case "
<<
LI
->
first
<<
":
\t
// "
<<
LI
->
second
.
size
()
OS
.
indent
(
Indent
*
2
+
2
)
<<
"case "
<<
LI
->
first
<<
":
\t
// "
<<
LI
->
second
.
size
()
<<
" string"
<<
(
LI
->
second
.
size
()
==
1
?
""
:
"s"
)
<<
" to match.
\n
"
;
<<
" string"
<<
(
LI
->
second
.
size
()
==
1
?
""
:
"s"
)
<<
" to match.
\n
"
;
if
(
EmitStringMatcherForChar
(
LI
->
second
,
0
,
0
))
if
(
EmitStringMatcherForChar
(
LI
->
second
,
0
,
Indent
))
OS
<<
"
break;
\n
"
;
OS
.
indent
(
Indent
*
2
+
4
)
<<
"break;
\n
"
;
}
}
OS
<<
"
}
\n
"
;
OS
.
indent
(
Indent
*
2
+
2
)
<<
"}
\n
"
;
}
}
This diff is collapsed.
Click to expand it.
llvm/utils/TableGen/StringMatcher.h
+
1
−
1
View file @
96fe532c
...
@@ -41,7 +41,7 @@ public:
...
@@ -41,7 +41,7 @@ public:
const
std
::
vector
<
StringPair
>
&
matches
,
raw_ostream
&
os
)
const
std
::
vector
<
StringPair
>
&
matches
,
raw_ostream
&
os
)
:
StrVariableName
(
strVariableName
),
Matches
(
matches
),
OS
(
os
)
{}
:
StrVariableName
(
strVariableName
),
Matches
(
matches
),
OS
(
os
)
{}
void
Emit
()
const
;
void
Emit
(
unsigned
Indent
=
0
)
const
;
private
:
private
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment