-ENABLE_STATS also enables timing
[oota-llvm.git] / test / Makefile.tests
1 ##-----------------------------------------------------------*-Makefile-*-
2 ## Common rules for generating, linking, and compiling via LLVM.  This is
3 ## used to implement a robust testing framework for LLVM
4 ##------------------------------------------------------------------------
5
6 ## NOTE: This is preliminary and will change in the future
7
8 # If the user specified a TEST= option on the command line, we do not want to do
9 # the default testing type.  Instead, we change the default target to be the
10 # test:: target.
11 #
12 ifdef TEST
13 test::
14 endif
15
16 include ${LEVEL}/Makefile.common
17
18 # Specify ENABLE_STATS on the command line to enable -stats and -time-passes
19 # output from gccas and gccld.
20 ifdef ENABLE_STATS
21 STATS = -stats -time-passes
22 endif
23
24
25 .PHONY: clean default
26
27 # These files, which might be intermediate results, should not be deleted by
28 # make
29 .PRECIOUS: Output/%.bc  Output/%.ll
30 .PRECIOUS: Output/%.tbc Output/%.tll
31 .PRECIOUS: Output/.dir
32 .PRECIOUS: Output/%.llvm.bc
33 .PRECIOUS: Output/%.llvm
34
35 ifdef ENABLE_OPTIMIZED
36 TOOLS    = $(BUILD_ROOT_TOP)/tools/Release
37 else
38 TOOLS    = $(BUILD_ROOT_TOP)/tools/Debug
39 endif
40
41 # LLVM Tool Definitions...
42 #
43 LCC      = $(LLVMGCCDIR)/bin/llvm-gcc
44 LCC1     = $(LLVMGCCDIR)/lib/gcc-lib/llvm/3.1/cc1
45 LLI      = $(TOOLS)/lli
46 LLC      = $(TOOLS)/llc
47 LAS      = $(TOOLS)/as
48 LGCCAS   = $(TOOLS)/gccas
49 LGCCLD   = $(TOOLS)/gccld -L$(LLVMGCCDIR)/llvm/lib
50 LDIS     = $(TOOLS)/dis 
51 LOPT     = $(TOOLS)/opt
52 LLINK    = $(TOOLS)/link
53 LANALYZE = $(TOOLS)/analyze
54 LBUGPOINT= $(TOOLS)/bugpoint
55
56 LCCFLAGS  += -O2 -Wall
57 LLCFLAGS =
58 FAILURE  = $(LEVEL)/test/Failure.sh
59 TESTRUNR = $(LEVEL)/test/TestRunner.sh
60
61 # Native Tool Definitions
62 NATGCC  = /usr/dcs/software/supported/bin/gcc
63 CP      = /bin/cp -f
64
65 ifndef DISABLE_LLC_DIFFS
66 CC      = /opt/SUNWspro/bin/cc
67 AS      = /opt/SUNWspro/bin/cc
68 DIS     = /usr/ccs/bin/dis
69 CFLAGS  += -g -xarch=v9
70 endif
71
72
73 ifeq ($(TRACE), yes)
74     LLCFLAGS += -trace basicblock
75     LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
76 else
77     ifeq ($(TRACEM), yes)
78         LLCFLAGS += -trace function
79         LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
80     endif
81 endif
82
83 LLCLIBS := $(LLCLIBS) -lm
84
85 clean::
86         $(RM) a.out core
87         $(RM) -rf Output/
88
89 # Compile from X.c to Output/X.ll
90 Output/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES)
91         $(LCC) $(LCCFLAGS) -S $< -o $@
92
93 # LLVM Assemble from Output/X.ll to Output/X.bc.  Output/X.ll must have come
94 # from GCC output, so use GCCAS.
95 #
96 Output/%.bc: Output/%.ll $(LGCCAS)
97         $(LGCCAS) $(STATS) $< -o $@
98
99 # LLVM Assemble from X.ll to Output/X.bc.  Because we are coming directly from
100 # LLVM source, use the non-transforming assembler.
101 #
102 Output/%.bc: %.ll $(LAS) Output/.dir
103         $(LAS) -f $< -o $@
104
105 # Compile a linked program to machine code for this processor.
106 #
107 Output/%.llc.s: Output/%.llvm.bc $(LLC)
108         $(LLC) $(LLCFLAGS) -f $< -o $@
109
110 # Assemble (and link) an LLVM-linked program using the system assembler...
111 #
112 Output/%.llc: Output/%.llc.s
113         $(CC) $(CFLAGS) $< $(LLCLIBS) -o $@
114
115 #
116 # Testing versions of provided utilities...
117 #
118 Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
119         @echo "======== Compiling $<"
120         $(LCC) $(LCCFLAGS) -S $< -o $@ || \
121             ( rm -f $@; $(FAILURE) $@ )
122
123 Output/%.tbc: Output/%.tll $(LAS)
124         @echo "======== Assembling $<"
125         $(LAS) -f $< -o $@ || \
126             ( rm -f $@; $(FAILURE) $@ )
127
128
129 ## Cancel built-in implicit rules that override above rules
130 %: %.s
131
132 %: %.c
133
134 %.o: %.c
135