-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.common
74 lines (56 loc) · 1.91 KB
/
Makefile.common
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
PADIR = $(LEVEL)
LLVMDIR = $(HOME)/llvm
LLVMLIBDIR = $(LLVMDIR)/lib
OPT = $(LLVMDIR)/bin/opt -O3
LEXER = reference/lexer
PARSER = reference/parser
SEMANT = reference/semant
ifdef PA5
COOLRT = $(PADIR)/src/coolrt.o
else
COOLRT =
endif
debug = true
ifeq ($(debug),true)
EXTRAFLAGS = -DDEBUG
CGENOPTS = -c
else
EXTRAFLAGS =
CGENOPTS =
endif
CPPFLAGS = -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS $(EXTRAFLAGS) \
-I. -I$(PADIR)/cool-support/include
LDFLAGS = -L$(LLVMDIR)/lib
LDLIBS =
CXXFLAGS = -g -Wall -Wno-deprecated -Wno-unused -fpermissive -Wno-write-strings
CXX = $(LLVMDIR)/bin/clang++
CC =$(LLVMDIR)/bin/clang
%.ast: %.cl
$(LEXER) $< | $(PARSER) | $(SEMANT) > $@
%.ll: %.ast
$(CGEN) $(CGENOPTS) < $< > $@
%.bc: %.ll
$(LLVMDIR)/bin/llvm-as < $< > $@
%.s: %.bc
$(LLVMDIR)/bin/llc < $< > $@
%.exe: %.s $(COOLRT)
$(CC) -g $+ -o $@
%.verify: %.bc
$(OPT) -verify $< | $(LLVMDIR)/bin/llvm-dis > $@
%-opt.bc: %.bc
$(OPT) -basicaa -instcombine -simplifycfg -scalarrepl-ssa -early-cse -jump-threading \
-reassociate -loop-simplify -loop-rotate -licm -loop-unswitch -instcombine -loop-simplify -loop-deletion \
-loop-unroll -gvn -sccp -instcombine -jump-threading -dse -adce -simplifycfg -instcombine \
< $< > $*-opt.bc
%-optmax.bc: %.bc
$(OPT) -tbaa -basicaa -globalopt -ipsccp -deadargelim -instcombine -simplifycfg -basiccg -inline \
-argpromotion -scalarrepl-ssa -early-cse -simplify-libcalls -jump-threading -correlated-propagation \
-simplifycfg -instcombine -tailcallelim -simplifycfg -reassociate -loop-simplify -loop-rotate -licm \
-loop-unswitch -instcombine -loop-simplify -loop-idiom -loop-deletion -loop-unroll -gvn -memcpyopt -sccp \
-instcombine -jump-threading -dse -adce -simplifycfg -instcombine -strip-dead-prototypes -globaldce -constmerge \
< $< > $*-optmax.bc
%.out: %.exe
./$< > $@ || true
clean:
-rm -f core *.exe *.bc *.ll *.out *.ast *.o *.verify
$(CLEAN_LOCAL)