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 # LLVM Tool Definitions...
29 LCC = $(LLVMGCCDIR)/bin/llvm-gcc
30 LCC1 = $(LLVMGCCDIR)/lib/gcc-lib/llvm/3.1/cc1
31 TOOLS = $(BUILD_ROOT_TOP)/tools/Debug
35 LGCCAS = $(TOOLS)/gccas
36 LGCCLD = $(TOOLS)/gccld -L$(LLVMGCCDIR)/llvm/lib
40 LANALYZE = $(TOOLS)/analyze
44 FAILURE = $(LEVEL)/test/Failure.sh
45 TESTRUNR = $(LEVEL)/test/TestRunner.sh
47 # Native Tool Definitions
48 NATGCC = /usr/dcs/software/supported/bin/gcc
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
60 LLCFLAGS += -trace basicblock
61 LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
64 LLCFLAGS += -trace function
65 LLCLIBS := -L$(LEVEL)/test/Libraries/Output -linstr64
69 LLCLIBS := $(LLCLIBS) -lm
75 # Compile from X.c to Output/X.ll
76 Output/%.ll: %.c $(LCC1) Output/.dir $(INCLUDES)
77 $(LCC) $(LCCFLAGS) -S $< -o $@
79 # LLVM Assemble from Output/X.ll to Output/X.bc. Output/X.ll must have come
80 # from GCC output, so use GCCAS.
82 Output/%.bc: Output/%.ll $(LGCCAS)
83 $(LGCCAS) $(STATS) $< -o $@
85 # LLVM Assemble from X.ll to Output/X.bc. Because we are coming directly from
86 # LLVM source, use the non-transforming assembler.
88 Output/%.bc: %.ll $(LAS) Output/.dir
91 # Compile a linked program to machine code for this processor.
93 Output/%.llc.s: Output/%.llvm.bc $(LLC)
94 $(LLC) $(LLCFLAGS) -f $< -o $@
96 # Assemble (and link) an LLVM-linked program using the system assembler...
98 Output/%.llc: Output/%.llc.s
99 $(CC) $(CFLAGS) $< $(LLCLIBS) -o $@
102 # Testing versions of provided utilities...
104 Output/%.tll: %.c $(LCC1) Output/.dir $(INCLUDES)
105 @echo "======== Compiling $<"
106 $(LCC) $(LCCFLAGS) -S $< -o $@ || \
107 ( rm -f $@; $(FAILURE) $@ )
109 Output/%.tbc: Output/%.tll $(LAS)
110 @echo "======== Assembling $<"
111 $(LAS) -f $< -o $@ || \
112 ( rm -f $@; $(FAILURE) $@ )
115 ## Cancel built-in implicit rules that override above rules