Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
60a3da27
Commit
60a3da27
authored
Feb 16, 2012
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compiler: Lower constant string comparisons.
From-SVN: r184316
parent
539b471b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
4 deletions
+35
-4
gcc/go/gofrontend/expressions.cc
+35
-4
No files found.
gcc/go/gofrontend/expressions.cc
View file @
60a3da27
...
...
@@ -5824,15 +5824,46 @@ Binary_expression::do_lower(Gogo* gogo, Named_object*,
}
// String constant expressions.
if
(
op
==
OPERATOR_PLUS
&&
left
->
type
()
->
is_string_type
()
&&
right
->
type
()
->
is_string_type
())
if
(
left
->
type
()
->
is_string_type
()
&&
right
->
type
()
->
is_string_type
())
{
std
::
string
left_string
;
std
::
string
right_string
;
if
(
left
->
string_constant_value
(
&
left_string
)
&&
right
->
string_constant_value
(
&
right_string
))
return
Expression
::
make_string
(
left_string
+
right_string
,
location
);
{
if
(
op
==
OPERATOR_PLUS
)
return
Expression
::
make_string
(
left_string
+
right_string
,
location
);
else
if
(
is_comparison
)
{
int
cmp
=
left_string
.
compare
(
right_string
);
bool
r
;
switch
(
op
)
{
case
OPERATOR_EQEQ
:
r
=
cmp
==
0
;
break
;
case
OPERATOR_NOTEQ
:
r
=
cmp
!=
0
;
break
;
case
OPERATOR_LT
:
r
=
cmp
<
0
;
break
;
case
OPERATOR_LE
:
r
=
cmp
<=
0
;
break
;
case
OPERATOR_GT
:
r
=
cmp
>
0
;
break
;
case
OPERATOR_GE
:
r
=
cmp
>=
0
;
break
;
default:
go_unreachable
();
}
return
Expression
::
make_boolean
(
r
,
location
);
}
}
}
// Special case for shift of a floating point constant.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment