aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@penguin.transmeta.com>2003-04-09 15:30:07 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:00:25 -0700
commitbbd57e9990529223b129893b7b764d3a6ec856ba (patch)
tree81b7e14fb826cd9c2c0de93b36e8b0be2b779c42
parentShow switch- and case-statements in some half-way sane (diff)
downloadsparse-bbd57e9990529223b129893b7b764d3a6ec856ba.tar.gz
sparse-bbd57e9990529223b129893b7b764d3a6ec856ba.tar.bz2
sparse-bbd57e9990529223b129893b7b764d3a6ec856ba.zip
Make symbol addressing do something half-way sane.
-rw-r--r--show-parse.c11
-rw-r--r--symbol.c1
-rw-r--r--symbol.h1
3 files changed, 12 insertions, 1 deletions
diff --git a/show-parse.c b/show-parse.c
index 9c41902..3b44204 100644
--- a/show-parse.c
+++ b/show-parse.c
@@ -682,7 +682,16 @@ static int show_postop(struct expression *expr)
static int show_symbol_expr(struct symbol *sym)
{
int new = new_pseudo();
- printf("\tmovi.%d\t\tv%d,$%s\n", BITS_IN_POINTER, new, show_ident(sym->ident));
+
+ if (sym->ctype.modifiers & (MOD_TOPLEVEL | MOD_EXTERN | MOD_STATIC)) {
+ printf("\tmovi.%d\t\tv%d,$%s\n", BITS_IN_POINTER, new, show_ident(sym->ident));
+ return new;
+ }
+ if (sym->ctype.modifiers & MOD_ADDRESSABLE) {
+ printf("\taddi.%d\t\tv%d,vFP,$%lld\n", BITS_IN_POINTER, new, sym->value);
+ return new;
+ }
+ printf("\taddi.%d\t\tv%d,vFP,$xxx\n", BITS_IN_POINTER, new);
return new;
}
diff --git a/symbol.c b/symbol.c
index 2dc99f3..ed9bf9d 100644
--- a/symbol.c
+++ b/symbol.c
@@ -264,6 +264,7 @@ void bind_symbol(struct symbol *sym, struct ident *ident, enum namespace ns)
scope = block_scope;
if (toplevel(scope)) {
+ sym->ctype.modifiers |= MOD_TOPLEVEL;
if (sym->ctype.modifiers & MOD_STATIC)
scope = file_scope;
}
diff --git a/symbol.h b/symbol.h
index 86e65e4..24f31d5 100644
--- a/symbol.h
+++ b/symbol.h
@@ -119,6 +119,7 @@ struct symbol {
#define MOD_NOCAST 0x100000
#define MOD_NODEREF 0x200000
#define MOD_ACCESSED 0x400000
+#define MOD_TOPLEVEL 0x800000 // scoping..
/* Basic types */
extern struct symbol void_type,