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