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 ##------------------------------------------------------------------------
6 ## NOTE: This is preliminary and will change in the future
8 include ${LEVEL}/Makefile.common
10 # Specify ENABLE_STATS on the command line to enable -stats output from gccas
19 # These files, which might be intermediate results, should not be deleted by
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
27 ifdef ENABLE_OPTIMIZED
28 TOOLS = $(BUILD_ROOT_TOP)/tools/Release
30 TOOLS = $(BUILD_ROOT_TOP)/tools/Debug
33 # LLVM Tool Definitions...
35 LCC = $(LLVMGCCDIR)/bin/llvm-gcc
36 LCC1 = $(LLVMGCCDIR)/lib/gcc-lib/llvm/3.1/cc1
40 LGCCAS = $(TOOLS)/gccas
41 LGCCLD = $(TOOLS)/gccld -L$(LLVMGCCDIR)/llvm/lib
45 LANALYZE = $(TOOLS)/analyze
46 LJELLO = $(TOOLS)/jello
50 FAILURE = $(LEVEL)/test/Failure.sh
51 TESTRUNR = $(LEVEL)/test/TestRunner.sh
53 # Native Tool Definitions
54 NATGCC = /usr/dcs/software/supported/bin/gcc
57 ifndef DISABLE_LLC_DIFFS
58 CC = /opt/SUNWspro/bin/cc
59 AS = /opt/SUNWspro/bin/cc
60 DIS = /usr/ccs/bin/dis
61 CFLAGS += -g -xarch=v9
66 LLCFLAGS += -trace basicblock
67 LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
70 LLCFLAGS += -trace function
71 LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
75 LLCLIBS := $(LLCLIBS) -lm
81 # Compile from X.c to Output/X.ll
82 Output/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES)
83 $(LCC) $(LCCFLAGS) -S $< -o $@
85 # LLVM Assemble from Output/X.ll to Output/X.bc. Output/X.ll must have come
86 # from GCC output, so use GCCAS.
88 Output/%.bc: Output/%.ll $(LGCCAS)
89 $(LGCCAS) $(STATS) $< -o $@
91 # LLVM Assemble from X.ll to Output/X.bc. Because we are coming directly from
92 # LLVM source, use the non-transforming assembler.
94 Output/%.bc: %.ll $(LAS) Output/.dir
97 # Compile a linked program to machine code for this processor.
99 Output/%.llc.s: Output/%.llvm.bc $(LLC)
100 $(LLC) $(LLCFLAGS) -f $< -o $@
102 # Assemble (and link) an LLVM-linked program using the system assembler...
104 Output/%.llc: Output/%.llc.s
105 $(CC) $(CFLAGS) $< $(LLCLIBS) -o $@
108 # Testing versions of provided utilities...
110 Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
111 @echo "======== Compiling $<"
112 $(LCC) $(LCCFLAGS) -S $< -o $@ || \
113 ( rm -f $@; $(FAILURE) $@ )
115 Output/%.tbc: Output/%.tll $(LAS)
116 @echo "======== Assembling $<"
117 $(LAS) -f $< -o $@ || \
118 ( rm -f $@; $(FAILURE) $@ )
121 ## Cancel built-in implicit rules that override above rules