Explorar el Código

enable constant folding

Quentin Carbonneaux hace 9 años
padre
commit
abe45f1ab0
Se han modificado 3 ficheros con 7 adiciones y 1 borrados
  1. 1 1
      Makefile
  2. 3 0
      all.h
  3. 3 0
      main.c

+ 1 - 1
Makefile

@@ -4,7 +4,7 @@ ABI = sysv
 V = @
 V = @
 OBJDIR = obj
 OBJDIR = obj
 
 
-SRC = main.c util.c parse.c mem.c ssa.c copy.c live.c $(ABI).c isel.c spill.c rega.c emit.c
+SRC = main.c util.c parse.c mem.c ssa.c copy.c fold.c live.c $(ABI).c isel.c spill.c rega.c emit.c
 OBJ = $(SRC:%.c=$(OBJDIR)/%.o)
 OBJ = $(SRC:%.c=$(OBJDIR)/%.o)
 
 
 CFLAGS += -Wall -Wextra -std=c99 -g -pedantic
 CFLAGS += -Wall -Wextra -std=c99 -g -pedantic

+ 3 - 0
all.h

@@ -533,6 +533,9 @@ void ssa(Fn *);
 /* copy.c */
 /* copy.c */
 void copy(Fn *);
 void copy(Fn *);
 
 
+/* fold.c */
+void fold(Fn *);
+
 /* live.c */
 /* live.c */
 void liveon(BSet *, Blk *, Blk *);
 void liveon(BSet *, Blk *, Blk *);
 void filllive(Fn *);
 void filllive(Fn *);

+ 3 - 0
main.c

@@ -11,6 +11,7 @@ char debug['Z'+1] = {
 	['M'] = 0, /* memory optimization */
 	['M'] = 0, /* memory optimization */
 	['N'] = 0, /* ssa construction */
 	['N'] = 0, /* ssa construction */
 	['C'] = 0, /* copy elimination */
 	['C'] = 0, /* copy elimination */
+	['F'] = 0, /* constant folding */
 	['S'] = 0, /* spilling */
 	['S'] = 0, /* spilling */
 	['R'] = 0, /* reg. allocation */
 	['R'] = 0, /* reg. allocation */
 };
 };
@@ -48,6 +49,8 @@ func(Fn *fn)
 	ssa(fn);
 	ssa(fn);
 	filluse(fn);
 	filluse(fn);
 	copy(fn);
 	copy(fn);
+	filluse(fn);
+	fold(fn);
 	abi(fn);
 	abi(fn);
 	filluse(fn);
 	filluse(fn);
 	isel(fn);
 	isel(fn);