@@ -1 +1,4 @@
-papers
+obj
+config.h
+.comfile
+*.out
@@ -1,6 +1,4 @@
-MIT/X Consortium License
-
-© 2015-2016 Quentin Carbonneaux
+© 2015-2016 Quentin Carbonneaux <[email protected]>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
@@ -1,8 +1,41 @@
-all clean check:
- @make -C src $@
- @make -C minic $@
+BIN = qbe
-sync-papers:
- unison -auto papers ssh://qcar@h/data/d/ssa-doc
+V = @
+OBJDIR = obj
-.PHONY: all clean check sync-papers
+SRC = main.c util.c parse.c mem.c ssa.c copy.c live.c isel.c spill.c rega.c emit.c
+OBJ = $(SRC:%.c=$(OBJDIR)/%.o)
+
+CFLAGS += -Wall -Wextra -std=c99 -g -pedantic
+$(OBJDIR)/$(BIN): $(OBJ) $(OBJDIR)/timestamp
+ @echo "ld $@"
+ $(V)$(CC) $(LDFLAGS) $(OBJ) -o $@
+$(OBJDIR)/%.o: %.c $(OBJDIR)/timestamp
+ @echo "cc $<"
+ $(V)$(CC) $(CFLAGS) -c $< -o $@
+$(OBJDIR)/timestamp:
+ @mkdir -p $(OBJDIR)
+ @touch $@
+$(OBJ): all.h
+obj/main.o: config.h
+config.h:
+ @case `uname` in \
+ *Darwin*) echo "#define Defaultasm Gasmacho" ;; \
+ *Linux*) echo "#define Defaultasm Gaself" ;; \
+ esac > $@
+clean:
+ rm -fr $(OBJDIR)
+clean-gen: clean
+ rm -f config.h
+check: $(OBJDIR)/$(BIN)
+ tools/unit.sh all
+.PHONY: clean clean-gen check syndoc
@@ -0,0 +1,8 @@
+QBE - Backend Compiler http://c9x.me/compile/
+doc/ Documentation.
+minic/ An example C frontend for QBE.
+tools/ Miscelaneous tools (testing).
+test/ Unit tests.
+The LICENSE file applies to all files distributed.
@@ -6,9 +6,7 @@ $(BIN): yacc minic.y
./yacc minic.y
$(CC) $(CFLAGS) -o $@ y.tab.c
-all: $(BIN)
-check:
clean:
rm -f yacc minic y.*
-.PHONY: all check clean
+.PHONY: clean
@@ -29,7 +29,7 @@ fi
../minic/minic < $file > /tmp/minic.ssa &&
-../src/qbe < /tmp/minic.ssa > /tmp/minic.s &&
+../obj/qbe < /tmp/minic.ssa > /tmp/minic.s &&
cc $flags /tmp/minic.s
if test $? -ne 0
@@ -1,5 +0,0 @@
-qbe
-config.h
-.comfile
-*.o
-*.out
@@ -1,24 +0,0 @@
-BIN = qbe
-OBJ = main.o util.o parse.o mem.o ssa.o copy.o live.o isel.o spill.o rega.o emit.o
-CFLAGS += -Wall -Wextra -std=c99 -g -pedantic
-$(BIN): $(OBJ)
- $(CC) $(LDFLAGS) $(OBJ) -o $@
-$(OBJ): all.h config.h
-config.h:
- @case `uname` in \
- *Darwin*) echo "#define Defaultasm Gasmacho" ;; \
- *Linux*) echo "#define Defaultasm Gaself" ;; \
- esac > $@
-clean:
- rm -f $(BIN) $(OBJ)
-check: $(BIN)
- ../test/go.sh all
-.PHONY: all clean check syndoc
@@ -2,7 +2,7 @@
OCAMLC=${OCAMLC:-/usr/bin/ocamlc}
DIR=`cd $(dirname "$0"); pwd`
-QBE=$DIR/../src/qbe
+QBE=$DIR/../obj/qbe
failure() {
echo "Failure at stage:" $1 >&2
@@ -1,18 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-int
-main(int ac, char *av[])
-{
- double d;
- float f;
- if (ac < 2) {
- usage:
- fputs("usage: fptox NUMBER\n", stderr);
- return 1;
- }
- f = d = strtod(av[1], 0);
- printf("0x%08x 0x%016llx\n", *(unsigned *)&f, *(unsigned long long*)&d);
- return 0;
-}
@@ -13,7 +13,7 @@
static void assert_test(char *, int), fail(void), iexec(int *);
-#include "../src/rega.c"
+#include "../../rega.c"
static void bsinit_(BSet *, uint);
@@ -1,17 +0,0 @@
-#!/bin/sh
-for t in ../test/*
-do
- printf "Test $t ... "
- ./qbe $t >/tmp/out.0 2>&1
- ./qbe.1 $t >/tmp/out.1 2>&1
- if diff /tmp/out.0 /tmp/out.1 > /dev/null
- then
- echo "OK"
- else
- echo "KO"
- break
- fi
-done
@@ -1,7 +1,7 @@
#!/bin/sh
TMP=/tmp/qbe.zzzz
@@ -98,7 +98,7 @@ fi
case $1 in
"all")
F=0
- for T in $DIR/[!_]*.ssa
+ for T in $DIR/../test/[!_]*.ssa
do
once $T
F=`expr $F + $?`