summaryrefslogtreecommitdiff
path: root/6/peep.c
diff options
context:
space:
mode:
authorOri Bernstein <ori@eigenstate.org>2015-11-17 20:53:32 -0800
committerOri Bernstein <ori@eigenstate.org>2015-11-17 20:53:32 -0800
commit8531896f8d21ba1e727262aaf5cd96043590b480 (patch)
tree7c01441755f56ab66d33c37d3ac41642ddc46c0b /6/peep.c
parentc20862cda53c711fe476f6c7d0f6631af47a4933 (diff)
downloadmc-8531896f8d21ba1e727262aaf5cd96043590b480.tar.gz
MEGAPATCH: Tabification.
Tabs > spaces. By 4 spaces, to be precise. Let's use them.
Diffstat (limited to '6/peep.c')
-rw-r--r--6/peep.c96
1 files changed, 48 insertions, 48 deletions
diff --git a/6/peep.c b/6/peep.c
index f36cdff..cb31911 100644
--- a/6/peep.c
+++ b/6/peep.c
@@ -21,17 +21,17 @@
* at that point */
static void deadcode(Isel *s, Asmbb *bb)
{
- size_t i;
+ size_t i;
- if (!bb)
- return;
- for (i = 0; i < bb->ni; i++) {
- if (bb->il[i]->op == Ijmp) {
- i++;
- break;
- }
- }
- bb->ni = i;
+ if (!bb)
+ return;
+ for (i = 0; i < bb->ni; i++) {
+ if (bb->il[i]->op == Ijmp) {
+ i++;
+ break;
+ }
+ }
+ bb->ni = i;
}
/* checks for of dumb jump code.
@@ -42,48 +42,48 @@ static void deadcode(Isel *s, Asmbb *bb)
*/
static void nopjmp(Isel *s, Asmbb *bb, size_t idx)
{
- Insn *jmp;
- Loc *targ;
- Asmbb *nextbb;
- size_t i;
+ Insn *jmp;
+ Loc *targ;
+ Asmbb *nextbb;
+ size_t i;
- /* skip empty bbs */
- if (!bb || !bb->ni)
- return;
- /* find the target of the last unconditional
- * jump in the bb */
- targ = NULL;
- if (bb->il[bb->ni - 1]->op == Ijmp) {
- jmp = bb->il[bb->ni - 1];
- if (jmp->args[0]->type == Loclbl)
- targ = jmp->args[0];
- }
- if (!targ)
- return;
-
- /* figure out if it's somewhere in the head of the next bb */
- nextbb = NULL;
- for (i = idx + 1; i < s->nbb; i++) {
- nextbb = s->bb[i];
- if (nextbb)
- break;
- }
- if (!nextbb)
- return;
- for (i = 0; i < nextbb->nlbls; i++) {
- if (!strcmp(nextbb->lbls[i], targ->lbl)) {
- bb->ni--;
- break;
- }
- }
+ /* skip empty bbs */
+ if (!bb || !bb->ni)
+ return;
+ /* find the target of the last unconditional
+ * jump in the bb */
+ targ = NULL;
+ if (bb->il[bb->ni - 1]->op == Ijmp) {
+ jmp = bb->il[bb->ni - 1];
+ if (jmp->args[0]->type == Loclbl)
+ targ = jmp->args[0];
+ }
+ if (!targ)
+ return;
+
+ /* figure out if it's somewhere in the head of the next bb */
+ nextbb = NULL;
+ for (i = idx + 1; i < s->nbb; i++) {
+ nextbb = s->bb[i];
+ if (nextbb)
+ break;
+ }
+ if (!nextbb)
+ return;
+ for (i = 0; i < nextbb->nlbls; i++) {
+ if (!strcmp(nextbb->lbls[i], targ->lbl)) {
+ bb->ni--;
+ break;
+ }
+ }
}
void peep(Isel *s)
{
- size_t i;
+ size_t i;
- for (i = 0; i < s->nbb; i++) {
- deadcode(s, s->bb[i]);
- nopjmp(s, s->bb[i], i);
- }
+ for (i = 0; i < s->nbb; i++) {
+ deadcode(s, s->bb[i]);
+ nopjmp(s, s->bb[i], i);
+ }
}