aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/example.c
diff options
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-12-11 12:14:42 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:06:00 -0700
commit40cccfe627575f2ccb6f34c9729fa9fb37fcf426 (patch)
tree51e7e8e73960979c9af08ceda79dd142a08d7478 /example.c
parent95237be67643ec945a6e2f30132d012db00cda94 (diff)
downloadsparse-dev-40cccfe627575f2ccb6f34c9729fa9fb37fcf426.tar.gz
Mark the backing store storage dead when marking a pseudo dead.
This allows us to mark a register dead when we load it from dead backing store. NOTE! This all sounds nonsensical, but we mark things "dead" _before_ the last use, not after. So dead means not that it's gone, it means that this use is the last one.
Diffstat (limited to 'example.c')
-rw-r--r--example.c44
1 files changed, 25 insertions, 19 deletions
diff --git a/example.c b/example.c
index 6e1149e9..fe8f7a55 100644
--- a/example.c
+++ b/example.c
@@ -241,19 +241,15 @@ static struct storage_hash *find_pseudo_storage(struct bb_state *state, pseudo_t
if (!src) {
src = find_storage_hash(pseudo, state->outputs);
/* Undefined? Screw it! */
- if (!src) {
- output_insn(state, "undef %s ??", show_pseudo(pseudo));
+ if (!src)
return NULL;
- }
/*
* If we found output storage, it had better be local stack
* that we flushed to earlier..
*/
- if (src->storage->type != REG_STACK) {
- output_insn(state, "fill_reg on undef storage %s ??", show_pseudo(pseudo));
+ if (src->storage->type != REG_STACK)
return NULL;
- }
}
}
@@ -273,6 +269,21 @@ static struct storage_hash *find_pseudo_storage(struct bb_state *state, pseudo_t
return src;
}
+static void mark_reg_dead(struct bb_state *state, pseudo_t pseudo, struct hardreg *reg)
+{
+ pseudo_t p;
+
+ FOR_EACH_PTR(reg->contains, p) {
+ if (p != pseudo)
+ continue;
+ if (CURRENT_TAG(p) & TAG_DEAD)
+ continue;
+ output_comment(state, "marking pseudo %s in reg %s dead", show_pseudo(pseudo), reg->name);
+ TAG_CURRENT(p, TAG_DEAD);
+ reg->dead++;
+ } END_FOR_EACH_PTR(p);
+}
+
/* Fill a hardreg with the pseudo it has */
static struct hardreg *fill_reg(struct bb_state *state, struct hardreg *hardreg, pseudo_t pseudo)
{
@@ -296,6 +307,8 @@ static struct hardreg *fill_reg(struct bb_state *state, struct hardreg *hardreg,
src = find_pseudo_storage(state, pseudo, hardreg);
if (!src)
break;
+ if (src->flags & TAG_DEAD)
+ mark_reg_dead(state, pseudo, hardreg);
output_insn(state, "mov.%d %s,%s", 32, show_memop(src->storage), hardreg->name);
break;
default:
@@ -597,20 +610,13 @@ static void generate_binop(struct bb_state *state, struct instruction *insn)
static void mark_pseudo_dead(struct bb_state *state, pseudo_t pseudo)
{
int i;
+ struct storage_hash *src;
- for (i = 0; i < REGNO; i++) {
- pseudo_t p;
- struct hardreg *reg = hardregs + i;
- FOR_EACH_PTR(reg->contains, p) {
- if (p != pseudo)
- continue;
- if (CURRENT_TAG(p) & TAG_DEAD)
- continue;
- output_comment(state, "marking pseudo %s in reg %s dead", show_pseudo(pseudo), reg->name);
- TAG_CURRENT(p, TAG_DEAD);
- reg->dead++;
- } END_FOR_EACH_PTR(p);
- }
+ src = find_pseudo_storage(state, pseudo, NULL);
+ if (src)
+ src->flags |= TAG_DEAD;
+ for (i = 0; i < REGNO; i++)
+ mark_reg_dead(state, pseudo, hardregs + i);
}
static void kill_dead_pseudos(struct bb_state *state)