Teach LLVM how to scalarize packed types. Currently, this only works on
[oota-llvm.git] / Makefile.rules
index 9bc8d5b220e7514445fdc648a319ee813ce4aff8..9f07c1ad6837f117ed359cfbff3d3878fca46d88 100644 (file)
@@ -28,13 +28,6 @@ TopLevelTargets  := check dist dist-check dist-clean tags dist-gzip dist-bzip2 \
 UserTargets      := $(RecursiveTargets) $(LocalTargets) $(TopLevelTargets)
 InternalTargets  := preconditions distdir dist-hook
 
-FilesToConfig := \
-  include/llvm/Config/config.h \
-  include/llvm/Support/DataTypes.h \
-  include/llvm/ADT/hash_map \
-  include/llvm/ADT/hash_set \
-  include/llvm/ADT/iterator
-
 ################################################################################
 # INITIALIZATION: Basic things the makefile needs
 ################################################################################
@@ -84,10 +77,7 @@ ifneq ($(MakefileConfigIn),)
 PreConditions      += $(MakefileConfig)
 endif
 
-FilesToConfigPATH  := $(addprefix $(LLVM_OBJ_ROOT)/,$(FilesToConfig))
-PreConditions      += $(FilesToConfigPATH)
-
-preconditions : $(PreConditions)
+preconditions: $(PreConditions)
 
 #------------------------------------------------------------------------
 # Make sure the BUILT_SOURCES are built first
@@ -144,16 +134,6 @@ $(ConfigStatusScript): $(ConfigureScript)
          $(ConfigStatusScript) --recheck $(ConfigureScriptFLAGS) && \
          $(ConfigStatusScript)
 
-#------------------------------------------------------------------------
-# If we're buildilng LLVM, then make sure the generated headers are Up2Dt
-#------------------------------------------------------------------------
-ifeq ($(LLVM_OBJ_ROOT),$(PROJ_OBJ_ROOT))
-.PRECIOUS: $(FilesToConfigPATH)
-$(FilesToConfigPATH) : $(LLVM_OBJ_ROOT)/% : $(LLVM_SRC_ROOT)/%.in 
-       $(Echo) Regenerating $*
-       $(Verb) cd $(LLVM_OBJ_ROOT) && $(ConfigStatusScript) $*
-endif
-
 #------------------------------------------------------------------------
 # Make sure the configuration makefile is up to date
 #------------------------------------------------------------------------
@@ -379,10 +359,13 @@ Compile.C     = $(CC) $(CPP.Flags) $(CompileCommonOpts) -c $(C.Flags)
 LTCompile.C   = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.C)
 BCCompile.C   = $(LLVMGCCWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
                 $(C.Flags) -c
+Preprocess.C  = $(CC) $(CPP.Flags) $(CompileCommonOpts) -E $(C.Flags)
+
 Compile.CXX   = $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -c
 LTCompile.CXX = $(LIBTOOL) $(LibTool.Flags) --mode=compile $(Compile.CXX)
 BCCompile.CXX = $(LLVMGXXWITHPATH) $(CPP.Flags) $(CompileCommonOpts) \
                 $(CXX.Flags) -c
+Preprocess.CXX= $(CXX) $(CPP.Flags) $(CompileCommonOpts) $(CXX.Flags) -E
 Link          = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
                $(CompileCommonOpts) $(LD.Flags) $(Strip)
 Relink        = $(LIBTOOL) $(LibTool.Flags) --mode=link $(CXX) $(CPP.Flags) \
@@ -605,9 +588,9 @@ endif
 # What the Sparc JIT requires
 ifdef ENABLE_SPARCV9_JIT
   JIT_LIBS += LLVMSparcV9 LLVMSparcV9ModuloSched LLVMSparcV9InstrSched \
-              LLVMSparcV9LiveVar LLVMInstrumentation.a LLVMProfilePaths \
+              LLVMSparcV9LiveVar LLVMInstrumentation.a \
               LLVMBCWriter LLVMTransforms.a LLVMipo.a LLVMipa.a \
-              LLVMDataStructure.a LLVMSparcV9RegAlloc
+              LLVMDataStructure LLVMSparcV9RegAlloc
 endif
 
 # You can enable the PowerPC JIT on a non-PowerPC host by setting the flag
@@ -634,7 +617,7 @@ ifdef ENABLE_ALPHA_JIT
   JIT_LIBS += LLVMAlpha LLVMSelectionDAG
 endif
 
-LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts LLVMAnalysis.a LLVMTransformUtils.a \
+LLVMLIBS := $(JIT_LIBS) LLVMScalarOpts.a LLVMTransformUtils.a LLVMAnalysis.a \
             LLVMBCReader LLVMCore LLVMSupport.a LLVMTarget.a LLVMbzip2 \
             LLVMSystem.a $(PLATFORMLIBDL)
 endif
@@ -841,10 +824,18 @@ endif
 
 #---------------------------------------------------------
 # ReLinked Library Targets:
-#   If the user didn't explicitly forbid building a 
-#   relinked then we provide targets for building them.
+#   If the user explicitly requests a relinked library with
+#   BUILD_RELINKED, provide it.  Otherwise, if they specify
+#   neither of BUILD_ARCHIVE or DONT_BUILD_RELINKED, give
+#   them one.
 #---------------------------------------------------------
+ifndef BUILD_ARCHIVE
 ifndef DONT_BUILD_RELINKED
+BUILD_RELINKED = 1
+endif
+endif
+
+ifdef BUILD_RELINKED
 
 all-local:: $(LibName.O)
 
@@ -1022,6 +1013,20 @@ $(ObjDir)/%.o: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
 
 endif
 
+## Rules for building preprocessed (.i/.ii) outputs.
+$(BuildMode)/%.ii: %.cpp $(ObjDir)/.dir $(BUILT_SOURCES)
+       $(Echo) "Compiling $*.cpp for $(BuildMode) build to .ii file"
+       $(Verb) $(Preprocess.CXX) $< -o $@
+
+$(BuildMode)/%.ii: %.cc $(ObjDir)/.dir $(BUILT_SOURCES)
+       $(Echo) "Compiling $*.cc for $(BuildMode) build to .ii file"
+       $(Verb) $(Preprocess.CXX) $< -o $@
+
+ $(BuildMode)/%.i: %.c $(ObjDir)/.dir $(BUILT_SOURCES)
+       $(Echo) "Compiling $*.c for $(BuildMode) build to .i file"
+       $(Verb) $(Preprocess.C) $< -o $@
+
+
 #---------------------------------------------------------
 # Create .bc files in the ObjDir directory from .cpp .cc and .c files...
 #---------------------------------------------------------
@@ -1103,7 +1108,7 @@ $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
 
 ifdef TARGET
 
-TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td)
+TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) $(LLVM_SRC_ROOT)/lib/Target/Target.td $(LLVM_SRC_ROOT)/lib/Target/TargetSelectionDAG.td)
 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
@@ -1160,6 +1165,16 @@ $(ObjDir)/%GenCodeEmitter.inc.tmp: %.td $(ObjDir)/.dir
        $(Echo) "Building $(<F) code emitter with tblgen"
        $(Verb) $(TableGen) -gen-emitter -o $@ $<
 
+$(TARGET:%=$(ObjDir)/%GenDAGISel.inc.tmp): \
+$(ObjDir)/%GenDAGISel.inc.tmp : %.td $(ObjDir)/.dir
+       $(Echo) "Building $(<F) instruction selector implementation with tblgen"
+       $(Verb) $(TableGen) -gen-dag-isel -o $@ $<
+
+$(TARGET:%=$(ObjDir)/%GenSubtarget.inc.tmp): \
+$(ObjDir)/%GenSubtarget.inc.tmp : %.td $(ObjDir)/.dir
+       $(Echo) "Building $(<F) subtarget information with tblgen"
+       $(Verb) $(TableGen) -gen-subtarget -o $@ $<
+
 clean-local::
        -$(Verb) $(RM) -f $(INCFiles)
 
@@ -1178,9 +1193,9 @@ LexFiles  := $(filter %.l,$(Sources))
 
 ifneq ($(LexFiles),)
 
-LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
-
-.PRECIOUS: $(LexOutput)
+# Cancel built-in rules for lex
+%.c: %.l
+%.cpp: %.l
 
 # Note the extra sed filtering here, used to cut down on the warnings emited 
 # by GCC.  The last line is a gross hack to work around flex aparently not 
@@ -1188,13 +1203,17 @@ LexOutput := $(strip $(patsubst %.l,%.cpp,$(LexFiles)))
 # uninitialized string buffers in LLVM we can generate very long tokens, so 
 # this is a hack around it.
 # FIXME.  (f.e. char Buffer[10000] )
-%.cpp: %.l
+$(PROJ_SRC_DIR)/%.cpp: $(PROJ_SRC_DIR)/%.l
        $(Echo) Flexing $*.l
-       $(Verb) $(FLEX) -t $< | \
+       $(Verb) $(FLEX) -t $(PROJ_SRC_DIR)/$*.l | \
        $(SED) 's/void yyunput/inline void yyunput/' | \
        $(SED) 's/void \*yy_flex_realloc/inline void *yy_flex_realloc/' | \
        $(SED) 's/#define YY_BUF_SIZE 16384/#define YY_BUF_SIZE (16384*64)/' \
-         > $@
+         > $(PROJ_SRC_DIR)/$*.cpp
+       $(Echo) "*** DON'T FORGET TO CHECK IN $*.cpp (generated file)"
+
+LexObjs := $(patsubst %.l,$(ObjDir)/%.o,$(LexFiles))
+$(LexObjs): $(ObjDir)/%.o : $(PROJ_SRC_DIR)/%.cpp
 
 clean-local::
        -$(Verb) $(RM) -f $(LexOutput)
@@ -1209,7 +1228,7 @@ endif
 
 YaccFiles  := $(filter %.y,$(Sources))
 ifneq ($(YaccFiles),)
-YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
+YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.output)
 
 .PRECIOUS: $(YaccOutput)
 
@@ -1219,14 +1238,14 @@ YaccOutput := $(addprefix $(patsubst %.y,%,$(YaccFiles)),.h .cpp .output)
 %.h: %.y
 
 # Rule for building the bison parsers...
-%.cpp %.h : %.y
+$(PROJ_SRC_DIR)/%.cpp $(PROJ_SRC_DIR)/%.h : $(PROJ_SRC_DIR)/%.y
        $(Echo) "Bisoning $*.y"
-       $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c  $<
-       $(Verb) $(MV) -f $*.tab.c $*.cpp
-       $(Verb) $(MV) -f $*.tab.h $*.h
+       $(Verb) $(BISON) -v -d -p $(<F:%Parser.y=%) -o $*.tab.c $<
+       $(Verb) $(MV) -f $*.tab.c $(PROJ_SRC_DIR)/$*.cpp
+       $(Verb) $(MV) -f $*.tab.h $(PROJ_SRC_DIR)/$*.h
+       $(Echo) "*** DON'T FORGET TO CHECK IN $*.cpp and $*.h (generated files)"
 
 clean-local::
-       -$(Verb) $(RM) -f $(YaccOutput)
        $(Verb) $(RM) -f $(YaccOutput)
 endif