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
916b1701
Commit
916b1701
authored
Jun 05, 1997
by
Michael Meissner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
abstract regset stuff into macros
From-SVN: r14147
parent
2217c9f0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
255 additions
and
75 deletions
+255
-75
gcc/basic-block.h
+219
-2
gcc/caller-save.c
+10
-21
gcc/flow.c
+0
-0
gcc/global.c
+15
-33
gcc/reorg.c
+11
-19
gcc/sched.c
+0
-0
No files found.
gcc/basic-block.h
View file @
916b1701
...
...
@@ -19,9 +19,11 @@ the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* Number of bits in each actual element of a regset. */
/* Number of bits in each actual element of a regset. We get slightly
better code for reg%bits and reg/bits if bits is unsigned, assuming
it is a power of 2. */
#define REGSET_ELT_BITS
HOST_BITS_PER_WIDE_INT
#define REGSET_ELT_BITS
((unsigned) HOST_BITS_PER_WIDE_INT)
/* Type to use for a regset element. Note that lots of code assumes
that the initial part of a regset that contains information on the
...
...
@@ -40,6 +42,221 @@ typedef REGSET_ELT_TYPE *regset;
extern
int
regset_bytes
;
extern
int
regset_size
;
/* clear a register set */
#define CLEAR_REG_SET(TO) \
do { register REGSET_ELT_TYPE *scan_tp_ = (TO); \
register int i_; \
for (i_ = 0; i_ < regset_size; i_++) \
*scan_tp_++ = 0; } while (0)
/* copy a register to another register */
#define COPY_REG_SET(TO, FROM) \
do { register REGSET_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
register int i_; \
for (i_ = 0; i_ < regset_size; i_++) \
*scan_tp_++ = *scan_fp_++; } while (0)
/* complent a register set, storing it in a second register set. */
#define COMPL_REG_SET(TO, FROM) \
do { register REGSET_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
register int i_; \
for (i_ = 0; i_ < regset_size; i_++) \
*scan_tp_++ = ~ *scan_fp_++; } while (0)
/* and a register set with a second register set. */
#define AND_REG_SET(TO, FROM) \
do { register REGSET_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
register int i_; \
for (i_ = 0; i_ < regset_size; i_++) \
*scan_tp_++ &= *scan_fp_++; } while (0)
/* and the complement of a register set to a register set. */
#define AND_COMPL_REG_SET(TO, FROM) \
do { register REGSET_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
register int i_; \
for (i_ = 0; i_ < regset_size; i_++) \
*scan_tp_++ &= ~ *scan_fp_++; } while (0)
/* inclusive or a register set with a second register set. */
#define IOR_REG_SET(TO, FROM) \
do { register REGSET_ELT_TYPE *scan_tp_ = (TO), *scan_fp_ = (FROM); \
register int i_; \
for (i_ = 0; i_ < regset_size; i_++) \
*scan_tp_++ |= *scan_fp_++; } while (0)
/* complement two register sets and or in the result into a third. */
#define IOR_AND_COMPL_REG_SET(TO, FROM1, FROM2) \
do { register REGSET_ELT_TYPE *scan_tp_ = (TO); \
register REGSET_ELT_TYPE *scan_fp1_ = (FROM1); \
register REGSET_ELT_TYPE *scan_fp2_ = (FROM2); \
register int i_; \
for (i_ = 0; i_ < regset_size; i_++) \
*scan_tp_++ |= *scan_fp1_++ & ~ *scan_fp2_++; } while (0)
/* Clear a single register in a register set. */
#define CLEAR_REGNO_REG_SET(TO, REG) \
do { \
register REGSET_ELT_TYPE *tp_ = (TO); \
tp_[ (REG) / REGSET_ELT_BITS ] \
&= ~ ((REGSET_ELT_TYPE) 1 << ((REG) % REGSET_ELT_BITS)); } while (0);
/* Set a single register in a register set. */
#define SET_REGNO_REG_SET(TO, REG) \
do { \
register REGSET_ELT_TYPE *tp_ = (TO); \
tp_[ (REG) / REGSET_ELT_BITS ] \
|= ((REGSET_ELT_TYPE) 1 << ((REG) % REGSET_ELT_BITS)); } while (0);
/* Return true if a register is set in a register set. */
#define REGNO_REG_SET_P(TO, REG) \
(((TO)[ (REG) / REGSET_ELT_BITS ] \
& (((REGSET_ELT_TYPE)1) << (REG) % REGSET_ELT_BITS)) != 0)
/* Copy the hard registers in a register set to the hard register set. */
#define REG_SET_TO_HARD_REG_SET(TO, FROM) \
do { \
int i_; \
CLEAR_HARD_REG_SET (TO); \
for (i_ = 0; i < FIRST_PSEUDO_REGISTER; i++) \
if (REGNO_REG_SET_P (FROM, i_)) \
SET_HARD_REG_BIT (TO, i_); \
} while (0)
/* Loop over all registers in REGSET, starting with MIN, setting REGNUM to the
register number and executing CODE for all registers that are set. */
#define EXECUTE_IF_SET_IN_REG_SET(REGSET, MIN, REGNUM, CODE) \
do { \
register REGSET_ELT_TYPE *scan_rs_ = (REGSET); \
register int i_; \
register int shift_ = (MIN) % REGSET_ELT_BITS; \
for (i_ = (MIN) / REGSET_ELT_BITS; i_ < regset_size; i_++) \
{ \
REGSET_ELT_TYPE word_ = *scan_rs_++; \
if (word_) \
{ \
REGSET_ELT_TYPE j_; \
REGNUM = (i_ * REGSET_ELT_BITS) + shift_; \
for (j_ = ((REGSET_ELT_TYPE)1) << shift_; \
j_ != 0; \
(j_ <<= 1), REGNUM++) \
{ \
if (word_ & j_) \
{ \
CODE; \
word_ &= ~ j_; \
if (!word_) \
break; \
} \
} \
} \
shift_ = 0; \
} \
} while (0)
/* Like EXECUTE_IF_SET_IN_REG_SET, but also clear the register set. */
#define EXECUTE_IF_SET_AND_RESET_IN_REG_SET(REGSET, MIN, REGNUM, CODE) \
do { \
register REGSET_ELT_TYPE *scan_rs_ = (REGSET); \
register int i_; \
register int shift_ = (MIN) % REGSET_ELT_BITS; \
for (i_ = (MIN) / REGSET_ELT_BITS; i_ < regset_size; i_++) \
{ \
REGSET_ELT_TYPE word_ = *scan_rs_++; \
if (word_) \
{ \
REGSET_ELT_TYPE j_; \
REGNUM = (i_ * REGSET_ELT_BITS) + shift_; \
scan_rs_[-1] = 0; \
for (j_ = ((REGSET_ELT_TYPE)1) << shift_; \
j_ != 0; \
(j_ <<= 1), REGNUM++) \
{ \
if (word_ & j_) \
{ \
CODE; \
word_ &= ~ j_; \
if (!word_) \
break; \
} \
} \
} \
shift_ = 0; \
} \
} while (0)
/* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting
REGNUM to the register number and executing CODE for all registers that are
set in both regsets. */
#define EXECUTE_IF_AND_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, CODE) \
do { \
register REGSET_ELT_TYPE *scan_rs1_ = (REGSET1); \
register REGSET_ELT_TYPE *scan_rs2_ = (REGSET2); \
register int i_; \
register int shift_ = (MIN) % REGSET_ELT_BITS; \
for (i_ = (MIN) / REGSET_ELT_BITS; i_ < regset_size; i_++) \
{ \
REGSET_ELT_TYPE word_ = *scan_rs1_++ & *scan_rs2_++; \
if (word_) \
{ \
REGSET_ELT_TYPE j_; \
REGNUM = (i_ * REGSET_ELT_BITS) + shift_; \
for (j_ = ((REGSET_ELT_TYPE)1) << shift_; \
j_ != 0; \
(j_ <<= 1), REGNUM++) \
{ \
if (word_ & j_) \
{ \
CODE; \
word_ &= ~ j_; \
if (!word_) \
break; \
} \
} \
} \
shift_ = 0; \
} \
} while (0)
/* Loop over all registers in REGSET1 and REGSET2, starting with MIN, setting
REGNUM to the register number and executing CODE for all registers that are
set in the first regset and not set in the second. */
#define EXECUTE_IF_AND_COMPL_IN_REG_SET(REGSET1, REGSET2, MIN, REGNUM, CODE) \
do { \
register REGSET_ELT_TYPE *scan_rs1_ = (REGSET1); \
register REGSET_ELT_TYPE *scan_rs2_ = (REGSET2); \
register int i_; \
register int shift_ = (MIN) % REGSET_ELT_BITS; \
for (i_ = (MIN) / REGSET_ELT_BITS; i_ < regset_size; i_++) \
{ \
REGSET_ELT_TYPE word_ = *scan_rs1_++ & ~ *scan_rs2_++; \
if (word_) \
{ \
REGSET_ELT_TYPE j_; \
REGNUM = (i_ * REGSET_ELT_BITS) + shift_; \
for (j_ = ((REGSET_ELT_TYPE)1) << shift_; \
j_ != 0; \
(j_ <<= 1), REGNUM++) \
{ \
if (word_ & j_) \
{ \
CODE; \
word_ &= ~ j_; \
if (!word_) \
break; \
} \
} \
} \
shift_ = 0; \
} \
} while (0)
/* Allocate a register set with oballoc. */
#define OBALLOC_REG_SET() \
((regset) obstack_alloc (&flow_obstack, regset_bytes))
/* Allocate a register set with alloca. */
#define ALLOCA_REG_SET() ((regset) alloca (regset_bytes))
/* Number of basic blocks in the current function. */
extern
int
n_basic_blocks
;
...
...
gcc/caller-save.c
View file @
916b1701
...
...
@@ -367,31 +367,20 @@ save_call_clobbered_regs (insn_mode)
saved because we restore all of them before the end of the basic
block. */
#ifdef HARD_REG_SET
hard_regs_live
=
*
regs_live
;
#else
COPY_HARD_REG_SET
(
hard_regs_live
,
regs_live
);
#endif
REG_SET_TO_HARD_REG_SET
(
hard_regs_live
,
regs_live
);
CLEAR_HARD_REG_SET
(
hard_regs_saved
);
CLEAR_HARD_REG_SET
(
hard_regs_need_restore
);
n_regs_saved
=
0
;
for
(
offset
=
0
,
i
=
0
;
offset
<
regset_size
;
offset
++
)
{
if
(
regs_live
[
offset
]
==
0
)
i
+=
REGSET_ELT_BITS
;
else
for
(
bit
=
1
;
bit
&&
i
<
max_regno
;
bit
<<=
1
,
i
++
)
if
((
regs_live
[
offset
]
&
bit
)
&&
(
regno
=
reg_renumber
[
i
])
>=
0
)
for
(
j
=
regno
;
j
<
regno
+
HARD_REGNO_NREGS
(
regno
,
PSEUDO_REGNO_MODE
(
i
));
j
++
)
SET_HARD_REG_BIT
(
hard_regs_live
,
j
);
}
EXECUTE_IF_SET_IN_REG_SET
(
regs_live
,
0
,
i
,
{
if
((
regno
=
reg_renumber
[
i
])
>=
0
)
for
(
j
=
regno
;
j
<
regno
+
HARD_REGNO_NREGS
(
regno
,
PSEUDO_REGNO_MODE
(
i
));
j
++
)
SET_HARD_REG_BIT
(
hard_regs_live
,
j
);
});
/* Now scan the insns in the block, keeping track of what hard
regs are live as we go. When we see a call, save the live
...
...
gcc/flow.c
View file @
916b1701
This diff is collapsed.
Click to expand it.
gcc/global.c
View file @
916b1701
...
...
@@ -642,36 +642,21 @@ global_conflicts ()
are explicitly marked in basic_block_live_at_start. */
{
register
int
offset
;
REGSET_ELT_TYPE
bit
;
register
regset
old
=
basic_block_live_at_start
[
b
];
int
ax
=
0
;
#ifdef HARD_REG_SET
hard_regs_live
=
old
[
0
];
#else
COPY_HARD_REG_SET
(
hard_regs_live
,
old
);
#endif
for
(
offset
=
0
,
i
=
0
;
offset
<
regset_size
;
offset
++
)
if
(
old
[
offset
]
==
0
)
i
+=
REGSET_ELT_BITS
;
else
for
(
bit
=
1
;
bit
;
bit
<<=
1
,
i
++
)
{
if
(
i
>=
max_regno
)
break
;
if
(
old
[
offset
]
&
bit
)
{
register
int
a
=
reg_allocno
[
i
];
if
(
a
>=
0
)
{
SET_ALLOCNO_LIVE
(
a
);
block_start_allocnos
[
ax
++
]
=
a
;
}
else
if
((
a
=
reg_renumber
[
i
])
>=
0
)
mark_reg_live_nc
(
a
,
PSEUDO_REGNO_MODE
(
i
));
}
}
REG_SET_TO_HARD_REG_SET
(
hard_regs_live
,
old
);
EXECUTE_IF_SET_IN_REG_SET
(
old
,
0
,
i
,
{
register
int
a
=
reg_allocno
[
i
];
if
(
a
>=
0
)
{
SET_ALLOCNO_LIVE
(
a
);
block_start_allocnos
[
ax
++
]
=
a
;
}
else
if
((
a
=
reg_renumber
[
i
])
>=
0
)
mark_reg_live_nc
(
a
,
PSEUDO_REGNO_MODE
(
i
));
});
/* Record that each allocno now live conflicts with each other
allocno now live, and with each hard reg now live. */
...
...
@@ -1640,13 +1625,10 @@ mark_elimination (from, to)
int
i
;
for
(
i
=
0
;
i
<
n_basic_blocks
;
i
++
)
if
((
basic_block_live_at_start
[
i
][
from
/
REGSET_ELT_BITS
]
&
((
REGSET_ELT_TYPE
)
1
<<
(
from
%
REGSET_ELT_BITS
)))
!=
0
)
if
(
REGNO_REG_SET_P
(
basic_block_live_at_start
[
i
],
from
))
{
basic_block_live_at_start
[
i
][
from
/
REGSET_ELT_BITS
]
&=
~
((
REGSET_ELT_TYPE
)
1
<<
(
from
%
REGSET_ELT_BITS
));
basic_block_live_at_start
[
i
][
to
/
REGSET_ELT_BITS
]
|=
((
REGSET_ELT_TYPE
)
1
<<
(
to
%
REGSET_ELT_BITS
));
CLEAR_REGNO_REG_SET
(
basic_block_live_at_start
[
i
],
from
);
SET_REGNO_REG_SET
(
basic_block_live_at_start
[
i
],
to
);
}
}
...
...
gcc/reorg.c
View file @
916b1701
...
...
@@ -2762,25 +2762,17 @@ mark_target_live_regs (target, res)
marked live, plus live pseudo regs that have been renumbered to
hard regs. */
#ifdef HARD_REG_SET
current_live_regs
=
*
regs_live
;
#else
COPY_HARD_REG_SET
(
current_live_regs
,
regs_live
);
#endif
for
(
offset
=
0
,
i
=
0
;
offset
<
regset_size
;
offset
++
)
{
if
(
regs_live
[
offset
]
==
0
)
i
+=
REGSET_ELT_BITS
;
else
for
(
bit
=
1
;
bit
&&
i
<
max_regno
;
bit
<<=
1
,
i
++
)
if
((
regs_live
[
offset
]
&
bit
)
&&
(
regno
=
reg_renumber
[
i
])
>=
0
)
for
(
j
=
regno
;
j
<
regno
+
HARD_REGNO_NREGS
(
regno
,
PSEUDO_REGNO_MODE
(
i
));
j
++
)
SET_HARD_REG_BIT
(
current_live_regs
,
j
);
REG_SET_TO_HARD_REG_SET
(
current_live_regs
,
regs_live
);
EXECUTE_IF_SET_IN_REG_SET
(
regs_live
,
0
,
i
,
{
if
((
regno
=
reg_renumber
[
i
])
>=
0
)
for
(
j
=
regno
;
j
<
regno
+
HARD_REGNO_NREGS
(
regno
,
PSEUDO_REGNO_MODE
(
i
));
j
++
)
SET_HARD_REG_BIT
(
current_live_regs
,
j
);
});
}
/* Get starting and ending insn, handling the case where each might
...
...
gcc/sched.c
View file @
916b1701
This diff is collapsed.
Click to expand it.
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