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
5cb1f2fa
Commit
5cb1f2fa
authored
Jan 04, 1997
by
Richard Kenner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(integer_pow2): Mask value to width of type.
(tree_log2): New function. From-SVN: r13374
parent
86b5812c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
1 deletions
+57
-1
gcc/tree.c
+57
-1
No files found.
gcc/tree.c
View file @
5cb1f2fa
/* Language-independent node constructors for parse phase of GNU compiler.
/* Language-independent node constructors for parse phase of GNU compiler.
Copyright (C) 1987, 88, 92
, 93, 94, 95, 1996
Free Software Foundation, Inc.
Copyright (C) 1987, 88, 92
-96, 1997
Free Software Foundation, Inc.
This file is part of GNU CC.
This file is part of GNU CC.
...
@@ -1625,6 +1625,7 @@ int
...
@@ -1625,6 +1625,7 @@ int
integer_pow2p
(
expr
)
integer_pow2p
(
expr
)
tree
expr
;
tree
expr
;
{
{
int
prec
;
HOST_WIDE_INT
high
,
low
;
HOST_WIDE_INT
high
,
low
;
STRIP_NOPS
(
expr
);
STRIP_NOPS
(
expr
);
...
@@ -1637,9 +1638,25 @@ integer_pow2p (expr)
...
@@ -1637,9 +1638,25 @@ integer_pow2p (expr)
if
(
TREE_CODE
(
expr
)
!=
INTEGER_CST
||
TREE_CONSTANT_OVERFLOW
(
expr
))
if
(
TREE_CODE
(
expr
)
!=
INTEGER_CST
||
TREE_CONSTANT_OVERFLOW
(
expr
))
return
0
;
return
0
;
prec
=
(
TREE_CODE
(
TREE_TYPE
(
expr
))
==
POINTER_TYPE
?
POINTER_SIZE
:
TYPE_PRECISION
(
TREE_TYPE
(
expr
)));
high
=
TREE_INT_CST_HIGH
(
expr
);
high
=
TREE_INT_CST_HIGH
(
expr
);
low
=
TREE_INT_CST_LOW
(
expr
);
low
=
TREE_INT_CST_LOW
(
expr
);
/* First clear all bits that are beyond the type's precision in case
we've been sign extended. */
if
(
prec
==
2
*
HOST_BITS_PER_WIDE_INT
)
;
else
if
(
prec
>
HOST_BITS_PER_WIDE_INT
)
high
&=
~
((
HOST_WIDE_INT
)
(
-
1
)
<<
(
prec
-
HOST_BITS_PER_WIDE_INT
));
else
{
high
=
0
;
if
(
prec
<
HOST_BITS_PER_WIDE_INT
)
low
&=
~
((
HOST_WIDE_INT
)
(
-
1
)
<<
prec
);
}
if
(
high
==
0
&&
low
==
0
)
if
(
high
==
0
&&
low
==
0
)
return
0
;
return
0
;
...
@@ -1647,6 +1664,45 @@ integer_pow2p (expr)
...
@@ -1647,6 +1664,45 @@ integer_pow2p (expr)
||
(
low
==
0
&&
(
high
&
(
high
-
1
))
==
0
));
||
(
low
==
0
&&
(
high
&
(
high
-
1
))
==
0
));
}
}
/* Return the power of two represented by a tree node known to be a
power of two. */
int
tree_log2
(
expr
)
tree
expr
;
{
int
prec
;
HOST_WIDE_INT
high
,
low
;
STRIP_NOPS
(
expr
);
if
(
TREE_CODE
(
expr
)
==
COMPLEX_CST
)
return
tree_log2
(
TREE_REALPART
(
expr
));
prec
=
(
TREE_CODE
(
TREE_TYPE
(
expr
))
==
POINTER_TYPE
?
POINTER_SIZE
:
TYPE_PRECISION
(
TREE_TYPE
(
expr
)));
high
=
TREE_INT_CST_HIGH
(
expr
);
low
=
TREE_INT_CST_LOW
(
expr
);
/* First clear all bits that are beyond the type's precision in case
we've been sign extended. */
if
(
prec
==
2
*
HOST_BITS_PER_WIDE_INT
)
;
else
if
(
prec
>
HOST_BITS_PER_WIDE_INT
)
high
&=
~
((
HOST_WIDE_INT
)
(
-
1
)
<<
(
prec
-
HOST_BITS_PER_WIDE_INT
));
else
{
high
=
0
;
if
(
prec
<
HOST_BITS_PER_WIDE_INT
)
low
&=
~
((
HOST_WIDE_INT
)
(
-
1
)
<<
prec
);
}
return
(
high
!=
0
?
HOST_BITS_PER_WIDE_INT
+
exact_log2
(
high
)
:
exact_log2
(
low
));
}
/* Return 1 if EXPR is the real constant zero. */
/* Return 1 if EXPR is the real constant zero. */
int
int
...
...
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