[hackers] [scc] [cc2] Rename addressability() to apply() || Roberto E. Vargas Caballero
commit 3bab86e457e6c4035faa26e237bc5ed7e85da472
Author: Roberto E. Vargas Caballero <roberto.vargas_AT_igrid-td.com>
AuthorDate: Tue Apr 12 17:01:49 2016 +0200
Commit: Roberto E. Vargas Caballero <roberto.vargas_AT_igrid-td.com>
CommitDate: Tue Apr 12 17:01:49 2016 +0200
[cc2] Rename addressability() to apply()
Addressability() was basically running over the nodes of the current
function and calling a function for every statement. This is a general
function and it is better to pass it the function we can call for
every statement.
Since the function is now a generic function, the best place for it
is in node.c
diff --git a/cc2/arch/amd64-sysv/cgen.c b/cc2/arch/amd64-sysv/cgen.c
index 1101f84..54e3ed2 100644
--- a/cc2/arch/amd64-sysv/cgen.c
+++ b/cc2/arch/amd64-sysv/cgen.c
_AT_@ -7,7 +7,7 @@ generate(void)
{
}
-void
-addressability(void)
+Node *
+sethi(Node *np)
{
}
diff --git a/cc2/arch/i386-sysv/cgen.c b/cc2/arch/i386-sysv/cgen.c
index 1101f84..54e3ed2 100644
--- a/cc2/arch/i386-sysv/cgen.c
+++ b/cc2/arch/i386-sysv/cgen.c
_AT_@ -7,7 +7,7 @@ generate(void)
{
}
-void
-addressability(void)
+Node *
+sethi(Node *np)
{
}
diff --git a/cc2/arch/qbe/cgen.c b/cc2/arch/qbe/cgen.c
index 1101f84..54e3ed2 100644
--- a/cc2/arch/qbe/cgen.c
+++ b/cc2/arch/qbe/cgen.c
_AT_@ -7,7 +7,7 @@ generate(void)
{
}
-void
-addressability(void)
+Node *
+sethi(Node *np)
{
}
diff --git a/cc2/arch/z80/cgen.c b/cc2/arch/z80/cgen.c
index 1a70d6a..567d209 100644
--- a/cc2/arch/z80/cgen.c
+++ b/cc2/arch/z80/cgen.c
_AT_@ -16,8 +16,8 @@ generate(void)
* STATIC => 12 (value)
* CONST => 20 $value
*/
-static Node *
-address(Node *np)
+Node *
+sethi(Node *np)
{
Node *lp, *rp;
_AT_@ -43,9 +43,9 @@ address(Node *np)
break;
default:
if (lp)
- address(lp);
+ sethi(lp);
if (rp)
- address(rp);
+ sethi(rp);
break;
}
_AT_@ -65,15 +65,3 @@ address(Node *np)
++np->complex;
return np;
}
-
-void
-addressability(void)
-{
- Node *np;
-
- if (!curfun)
- return;
-
- for (np = curfun->u.label; np; np = np->stmt)
- address(np);
-}
diff --git a/cc2/cc2.h b/cc2/cc2.h
index d176514..4f9a205 100644
--- a/cc2/cc2.h
+++ b/cc2/cc2.h
_AT_@ -182,7 +182,7 @@ extern void parse(void);
extern void optimize(void);
/* cgen.c */
-extern void addressability(void);
+extern Node *sethi(Node *np);
extern void generate(void);
/* peep.c */
_AT_@ -194,6 +194,7 @@ extern void writeout(void), endinit(void), newfun(void);
extern void defvar(Symbol *), defpar(Symbol *), defglobal(Symbol *);
/* node.c */
+extern void apply(Node *(*fun)(Node *));
extern void cleannodes(void);
extern void delnode(Node *np);
extern void deltree(Node *np);
diff --git a/cc2/main.c b/cc2/main.c
index fc4500d..561e2b5 100644
--- a/cc2/main.c
+++ b/cc2/main.c
_AT_@ -39,7 +39,7 @@ main(void)
while (moreinput()) {
parse();
optimize();
- addressability();
+ apply(sethi);
generate();
peephole();
writeout();
diff --git a/cc2/node.c b/cc2/node.c
index ef91dce..21594f3 100644
--- a/cc2/node.c
+++ b/cc2/node.c
_AT_@ -74,3 +74,15 @@ cleannodes(void)
free(ap);
}
}
+
+void
+apply(Node *(*fun)(Node *))
+{
+ Node *np;
+
+ if (!curfun)
+ return;
+
+ for (np = curfun->u.label; np; np = np->stmt)
+ (*fun)(np);
+}
Received on Wed Apr 13 2016 - 08:11:38 CEST
This archive was generated by hypermail 2.3.0
: Wed Apr 13 2016 - 08:12:23 CEST