Modify tracing rules to use opt -trace[m] instead of llc -trace[m].
[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 # If the user specified a TEST= option on the command line, we do not want to do
7 # the default testing type.  Instead, we change the default target to be the
8 # test:: target.
9 #
10 ifdef TEST
11 test::
12 endif
13
14 include ${LEVEL}/Makefile.common
15
16 # Specify ENABLE_STATS on the command line to enable -stats and -time-passes
17 # output from gccas and gccld.
18 ifdef ENABLE_STATS
19 STATS = -stats -time-passes
20 endif
21
22
23 .PHONY: clean default
24
25 # These files, which might be intermediate results, should not be deleted by
26 # make
27 .PRECIOUS: Output/%.bc  Output/%.ll
28 .PRECIOUS: Output/%.tbc Output/%.tll
29 .PRECIOUS: Output/.dir
30 .PRECIOUS: Output/%.llvm.bc
31 .PRECIOUS: Output/%.llvm
32
33 ifdef ENABLE_OPTIMIZED
34 TOOLS    = $(BUILD_ROOT_TOP)/tools/Release
35 else
36 TOOLS    = $(BUILD_ROOT_TOP)/tools/Debug
37 endif
38
39 # LLVM Tool Definitions...
40 #
41 LCC      = $(LLVMGCCDIR)/bin/gcc
42 LCC1     = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1
43 LCXX     = $(LLVMGCCDIR)/bin/g++
44 LCC1XX   = $(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH)/cc1plus
45 LLI      = $(TOOLS)/lli
46 LLC      = $(TOOLS)/llc
47 LAS      = $(TOOLS)/as
48 LGCCAS   = $(TOOLS)/gccas
49 LGCCLD   = $(TOOLS)/gccld -L$(LLVMGCCDIR)/lib/gcc-lib/$(LLVMGCCARCH) -L$(LLVMGCCDIR)/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 LCXXFLAGS += -O2 -Wall
58 LLCFLAGS =
59 FAILURE  = $(LEVEL)/test/Failure.sh
60 TESTRUNR = $(LEVEL)/test/TestRunner.sh
61
62 # Native Tool Definitions
63 NATGCC  = /usr/dcs/software/supported/bin/gcc
64 CP      = /bin/cp -f
65
66 ## If TRACE or TRACEM is "yes", set the appropriate llc flag (-trace or -tracem)
67 ## mark that tracing on, and set the TRACELIBS variable.
68 TRACEFLAGS = 
69 ifeq ($(TRACE), yes)
70     TRACEFLAGS += -trace
71     DOTRACING = yes
72 else
73     ifeq ($(TRACEM), yes)
74         TRACEFLAGS += -tracem
75         DOTRACING = yes
76     endif
77 endif
78 ifeq ($(DOTRACING), yes)
79     TRACELIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
80 endif
81
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: $(SourceDir)%.c $(LCC1) Output/.dir $(INCLUDES)
91         $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@
92
93 # Compile from X.cpp to Output/X.ll
94 Output/%.ll: $(SourceDir)%.cpp $(LCC1XX) Output/.dir $(INCLUDES)
95         $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
96
97 # Compile from X.cc to Output/X.ll
98 Output/%.ll: $(SourceDir)%.cc $(LCC1XX) Output/.dir $(INCLUDES)
99         $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@
100
101 # LLVM Assemble from Output/X.ll to Output/X.bc.  Output/X.ll must have come
102 # from GCC output, so use GCCAS.
103 #
104 Output/%.bc: Output/%.ll $(LGCCAS)
105         $(LGCCAS) $(STATS) $< -o $@
106
107 # LLVM Assemble from X.ll to Output/X.bc.  Because we are coming directly from
108 # LLVM source, use the non-transforming assembler.
109 #
110 Output/%.bc: %.ll $(LAS) Output/.dir
111         $(LAS) -f $< -o $@
112
113 #
114 # Testing versions of provided utilities...
115 #
116 Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
117         @echo "======== Compiling $<"
118         $(LCC) $(CPPFLAGS) $(LCCFLAGS) -S $< -o $@ || \
119             ( rm -f $@; $(FAILURE) $@ )
120
121 Output/%.tll: %.cpp $(LCC1XX) Output/.dir $(INCLUDES)
122         @echo "======== Compiling $<"
123         $(LCXX) $(CPPFLAGS) $(LCXXFLAGS) -S $< -o $@ || \
124             ( rm -f $@; $(FAILURE) $@ )
125
126 Output/%.tbc: Output/%.tll $(LAS)
127         @echo "======== Assembling $<"
128         $(LAS) -f $< -o $@ || \
129             ( rm -f $@; $(FAILURE) $@ )
130
131
132 ## Cancel built-in implicit rules that override above rules
133 %: %.s
134
135 %: %.c
136
137 %.o: %.c
138