Commit 9bc6505e authored by nagayama15's avatar nagayama15

Update makefiles.

parent 17870007
...@@ -68,8 +68,9 @@ ${OBJ_DIR}/stage3/%.o: 8cc/%.c ${BIN_DIR}/stage2/8cc.out ...@@ -68,8 +68,9 @@ ${OBJ_DIR}/stage3/%.o: 8cc/%.c ${BIN_DIR}/stage2/8cc.out
${OBJ_DIR}/stage1-wm/%.o: 8cc/%.c ${OBJ_DIR}/stage1-wm/%.o: 8cc/%.c
@mkdir -p ${@D} @mkdir -p ${@D}
clang ${CFLAGS} -S -emit-llvm -o ${@:%.o=%.ll} $< clang ${CFLAGS} -S -emit-llvm -o ${@:%.o=%.ll} $<
opt -load=${ROOT}/bin/src/nykk.so -block-wm -watermark=${WATERMARK} -S -o ${@:%.o=%-wm.ll} ${@:%.o=%.ll} 2> ${@:%.o=%-log.txt} opt -load=${ROOT}/bin/src/nykk.so -block-wm -watermark=${WATERMARK} -S -o ${@:%.o=%-block-wm.ll} ${@:%.o=%.ll} 2> ${@:%.o=%-block-wm.txt}
clang ${CFLAGS} -o $@ -c ${@:%.o=%-wm.ll} opt -load=${ROOT}/bin/src/nykk.so -inst-wm -watermark=${WATERMARK} -S -o ${@:%.o=%-inst-wm.ll} ${@:%.o=%-block-wm.ll} 2> ${@:%.o=%-inst-wm.txt}
clang ${CFLAGS} -o $@ -c ${@:%.o=%-inst-wm.ll}
${OBJ_DIR}/stage2-wm/%.o: 8cc/%.c ${BIN_DIR}/stage1-wm/8cc.out ${OBJ_DIR}/stage2-wm/%.o: 8cc/%.c ${BIN_DIR}/stage1-wm/8cc.out
@mkdir -p ${@D} @mkdir -p ${@D}
......
...@@ -7,11 +7,13 @@ LLS := ${SRCS:%.c=${OBJ_DIR}/%.ll} ...@@ -7,11 +7,13 @@ LLS := ${SRCS:%.c=${OBJ_DIR}/%.ll}
LLS_0 := ${LLS:%.ll=%-0.ll} LLS_0 := ${LLS:%.ll=%-0.ll}
LLS_1 := ${LLS:%.ll=%-1.ll} LLS_1 := ${LLS:%.ll=%-1.ll}
LLS_2 := ${LLS:%.ll=%-2.ll} LLS_2 := ${LLS:%.ll=%-2.ll}
LLS_3 := ${LLS:%.ll=%-3.ll}
BINS := \ BINS := \
${LLS:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} \ ${LLS:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} \
${LLS_0:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} \ ${LLS_0:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} \
${LLS_1:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} \ ${LLS_1:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} \
${LLS_2:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} ${LLS_2:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out} \
${LLS_3:${OBJ_DIR}/%.ll=${BIN_DIR}/%.out}
all: ${BINS} all: ${BINS}
...@@ -20,18 +22,20 @@ test: ${BINS} ...@@ -20,18 +22,20 @@ test: ${BINS}
do $$i > $$i.txt; \ do $$i > $$i.txt; \
done done
${BINS}: ${LLS} ${LLS_0} ${LLS_1} ${LLS_2} ${BINS}: ${LLS} ${LLS_0} ${LLS_1} ${LLS_2} ${LLS_3}
${OBJ_DIR}/%.ll: %.c ${OBJ_DIR}/%.ll: %.c
@mkdir -p ${@D} @mkdir -p ${@D}
clang -emit-llvm -S -O2 -o $@ $< clang -emit-llvm -S -O2 -o $@ $<
%-0.ll: %.ll %-0.ll: %.ll
opt -load=${ROOT}/bin/src/nykk.so -block-wm -watermark=0 -S -o $@ $< opt -load=${ROOT}/bin/src/nykk.so -block-wm -watermark=0 -S -o $@ $< 2> ${@:.ll=.txt}
%-1.ll: %.ll %-1.ll: %.ll
opt -load=${ROOT}/bin/src/nykk.so -block-wm -watermark=1 -S -o $@ $< opt -load=${ROOT}/bin/src/nykk.so -block-wm -watermark=1 -S -o $@ $< 2> ${@:.ll=.txt}
%-2.ll: %.ll %-2.ll: %.ll
opt -load=${ROOT}/bin/src/nykk.so -block-wm -watermark=2 -S -o $@ $< opt -load=${ROOT}/bin/src/nykk.so -inst-wm -watermark=2 -S -o $@ $< 2> ${@:.ll=.txt}
%-3.ll: %.ll
opt -load=${ROOT}/bin/src/nykk.so -inst-wm -watermark=3 -S -o $@ $< 2> ${@:.ll=.txt}
${BIN_DIR}/%.out: ${OBJ_DIR}/%.ll ${BIN_DIR}/%.out: ${OBJ_DIR}/%.ll
@mkdir -p ${@D} @mkdir -p ${@D}
......
...@@ -37,36 +37,37 @@ SRCS := \ ...@@ -37,36 +37,37 @@ SRCS := \
zlib/zutil.c zlib/zutil.c
OBJS := ${SRCS:zlib/%.c=${OBJ_DIR}/zlib/%.o} OBJS := ${SRCS:zlib/%.c=${OBJ_DIR}/zlib/%.o}
OBJS_WM := ${SRCS:zlib/%.c=${OBJ_DIR}/zlib-${WATERMARK}/%.o} OBJS_WM := ${SRCS:zlib/%.c=${OBJ_DIR}/zlib-wm/%.o}
.PHONY: all test .PHONY: all test
all: \ all: \
${BIN_DIR}/libz.a \ ${BIN_DIR}/libz.a \
${BIN_DIR}/libz-${WATERMARK}.a \ ${BIN_DIR}/libz-wm.a \
${BIN_DIR}/test \ ${BIN_DIR}/test \
${BIN_DIR}/test-${WATERMARK} ${BIN_DIR}/test-wm
test: \ test: \
${BIN_DIR}/libz.a \ ${BIN_DIR}/libz.a \
${BIN_DIR}/libz-${WATERMARK}.a \ ${BIN_DIR}/libz-wm.a \
${BIN_DIR}/test \ ${BIN_DIR}/test \
${BIN_DIR}/test-${WATERMARK} ${BIN_DIR}/test-wm
${BIN_DIR}/libz.a: ${OBJS} ${BIN_DIR}/libz.a: ${OBJS}
${BIN_DIR}/libz-${WATERMARK}.a: ${OBJS_WM} ${BIN_DIR}/libz-wm.a: ${OBJS_WM}
${BIN_DIR}/test: ${OBJ_DIR}/test.o ${BIN_DIR}/libz.a ${BIN_DIR}/test: ${OBJ_DIR}/test.o ${BIN_DIR}/libz.a
${BIN_DIR}/test-${WATERMARK}: ${OBJ_DIR}/test.o ${BIN_DIR}/libz-${WATERMARK}.a ${BIN_DIR}/test-wm: ${OBJ_DIR}/test.o ${BIN_DIR}/libz-wm.a
${OBJ_DIR}/zlib/%.o: zlib/%.c ${OBJ_DIR}/zlib/%.o: zlib/%.c
@mkdir -p ${@D} @mkdir -p ${@D}
${CC} ${CFLAGS} -o $@ -c $< ${CC} ${CFLAGS} -o $@ -c $<
${OBJ_DIR}/zlib-${WATERMARK}/%.o: zlib/%.c ${OBJ_DIR}/zlib-wm/%.o: zlib/%.c
@mkdir -p ${@D} @mkdir -p ${@D}
clang ${CFLAGS} -emit-llvm -S -o ${@:.o=.ll} $< clang ${CFLAGS} -emit-llvm -S -o ${@:.o=.ll} $<
opt -load=${ROOT}/bin/src/nykk.so -block-wm -watermark=${WATERMARK} -S -o ${@:%.o=%-${WATERMARK}.ll} ${@:.o=.ll} 2> ${@:%.o=%-log.txt} opt -load=${ROOT}/bin/src/nykk.so -block-wm -watermark=${WATERMARK} -S -o ${@:%.o=%-block-wm.ll} ${@:.o=.ll} 2> ${@:%.o=%-block-wm.txt}
clang ${CFLAGS} -o $@ -c ${@:%.o=%-${WATERMARK}.ll} opt -load=${ROOT}/bin/src/nykk.so -block-wm -watermark=${WATERMARK} -S -o ${@:%.o=%-inst-wm.ll} ${@:.o=-block-wm.ll} 2> ${@:%.o=%-inst-wm.txt}
clang ${CFLAGS} -o $@ -c ${@:%.o=%-inst-wm.ll}
${OBJ_DIR}/test.o: test.cpp ${OBJ_DIR}/test.o: test.cpp
${CXX} ${CXXFLAGS} -o $@ -c $< ${CXX} ${CXXFLAGS} -o $@ -c $<
...@@ -74,7 +75,7 @@ ${OBJ_DIR}/test.o: test.cpp ...@@ -74,7 +75,7 @@ ${OBJ_DIR}/test.o: test.cpp
${BIN_DIR}/test: ${BIN_DIR}/test:
${CXX} ${CXXFLAGS} -o $@ $^ ${LDFLAGS} ${CXX} ${CXXFLAGS} -o $@ $^ ${LDFLAGS}
${BIN_DIR}/test-${WATERMARK}: ${BIN_DIR}/test-wm:
${CXX} ${CXXFLAGS} -o $@ $^ ${LDFLAGS} ${CXX} ${CXXFLAGS} -o $@ $^ ${LDFLAGS}
%.a: %.a:
......
#!/bin/zsh #!/bin/zsh
g() { g() {
FILE=$(basename ${1/-log.txt/.c}) FILE=$(basename ${1/-block-wm.txt/.c})
FUNCS=$(tail -n +2 $1 | wc -l) FUNCS=$(tail -n +2 $1 | wc -l)
BLOCKS=$(tail -n +2 $1 | awk '{a+=$2} END {print a}') BLOCKS=$(tail -n +2 $1 | awk '{a+=$2} END {print a}')
BITS=$(tail -n +2 $1 | awk '{a+=$3} END {print a}') BITS=$(tail -n +2 $1 | awk '{a+=$3} END {print a}')
...@@ -22,5 +22,5 @@ h() { ...@@ -22,5 +22,5 @@ h() {
echo "$R" | awk '{f++; a+=$2; b+=$3; c+=$4} END {print "files: " f ", funcs: " a ", blocks: " b ", bits: " c}' echo "$R" | awk '{f++; a+=$2; b+=$3; c+=$4} END {print "files: " f ", funcs: " a ", blocks: " b ", bits: " c}'
} }
h obj/example/8cc/stage1-wm/*-log.txt h obj/example/8cc/stage1-wm/*-block-wm.txt
h obj/example/zlib/zlib-77/*-log.txt h obj/example/zlib/zlib-wm/*-block-wm.txt
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment