Don't record the increment instruction; just recompute it from the Phi
[oota-llvm.git] / Makefile.rules
index a048f941ad170922726cf79e5400754a5074c4be..3c115d2a52e0b4533d1b4091778603c49353e556 100644 (file)
@@ -191,6 +191,28 @@ uninstall:: uninstall-local
 install-local:: all-local
 install-bytecode:: install-bytecode-local
 
+###############################################################################
+# LLVMC: Provide rules for compiling llvmc plugins
+###############################################################################
+
+ifdef LLVMC_PLUGIN
+
+LIBRARYNAME := $(patsubst %,plugin_llvmc_%,$(LLVMC_PLUGIN))
+REQUIRES_EH := 1
+
+# Build a dynamic library if the user runs `make` directly from the plugin
+# directory.
+ifndef LLVMC_BUILTIN_PLUGIN
+LOADABLE_MODULE = 1
+endif
+
+# TableGen stuff...
+ifneq ($(BUILT_SOURCES),)
+LLVMC_BUILD_AUTOGENERATED_INC=1
+endif
+
+endif # LLVMC_PLUGIN
+
 ###############################################################################
 # VARIABLES: Set up various variables based on configuration data
 ###############################################################################
@@ -291,7 +313,7 @@ ifdef SHARED_LIBRARY
 endif
 
 ifeq ($(ENABLE_PIC),1)
-  ifeq ($(LLVM_ON_WIN32),1)
+  ifeq ($(OS), $(filter $(OS), Cygwin MingW))
     # Nothing. Win32 defaults to PIC and warns when given -fPIC
   else
     ifeq ($(OS),Darwin)
@@ -406,7 +428,7 @@ ifdef LOADABLE_MODULE
 endif
 
 ifdef SHARED_LIBRARY
-  LD.Flags += -Wl,-rpath -Wl,$(LibDir)
+  LD.Flags += $(RPATH) -Wl,$(LibDir)
 endif
 
 ifdef TOOL_VERBOSE
@@ -436,24 +458,36 @@ endif
 ifneq ($(OS),Darwin)
 ifdef TOOLNAME
 ifdef EXAMPLE_TOOL
-  LD.Flags += -Wl,-rpath -Wl,$(ExmplDir) -export-dynamic
+  LD.Flags += $(RPATH) -Wl,$(ExmplDir) $(RDYNAMIC)
 else
-  LD.Flags += -Wl,-rpath -Wl,$(ToolDir) -export-dynamic
+  LD.Flags += $(RPATH) -Wl,$(ToolDir) $(RDYNAMIC)
 endif
 endif
 endif
 
 ifeq ($(OS),Darwin)
-  SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress -bundle
+  DARWIN_VERSION := `sw_vers -productVersion`
+  # Strip a number like 10.4.7 to 10.4
+  DARWIN_VERSION := $(shell echo $(DARWIN_VERSION)| sed -E 's/(10.[0-9]).*/\1/')
+     
+  SharedLinkOptions=-Wl,-flat_namespace -Wl,-undefined -Wl,suppress -bundle \
+                    -mmacosx-version-min=$(DARWIN_VERSION)
+  CompileCommonOpts += -mmacosx-version-min=$(DARWIN_VERSION)
 else
-  SharedLinkOptions=-shared
+  ifeq ($(OS),Cygwin)
+    SharedLinkOptions=-shared -nostdlib -Wl,--export-all-symbols \
+                      -Wl,--enable-auto-import -Wl,--enable-auto-image-base \
+                      -Wl,--enable-runtime-pseudo-relocs
+  else
+    SharedLinkOptions=-shared
+  endif
 endif
 
 #----------------------------------------------------------
 # Options To Invoke Tools
 #----------------------------------------------------------
 
-CompileCommonOpts := -pedantic -Wall -W -Wwrite-strings -Wno-long-long \
+CompileCommonOpts += -pedantic -Wall -W -Wwrite-strings -Wno-long-long \
                      -Wunused -Wno-unused-parameter $(EXTRA_OPTIONS)
 
 ifeq ($(OS),HP-UX)
@@ -477,14 +511,24 @@ ifdef UNIVERSAL
   endif
   UNIVERSAL_ARCH_OPTIONS := $(UNIVERSAL_ARCH:%=-arch %)
   CompileCommonOpts += $(UNIVERSAL_ARCH_OPTIONS)
-  Relink.Flags := $(UNIVERSAL_ARCH_OPTIONS:%=-XCClinker %)
+  Relink.Flags := $(UNIVERSAL_ARCH_OPTIONS)
   ifdef UNIVERSAL_SDK_PATH
     CompileCommonOpts += -isysroot $(UNIVERSAL_SDK_PATH)
-    Relink.Flags      += -XCClinker -isysroot -XCClinker $(UNIVERSAL_SDK_PATH)
+    Relink.Flags      += -isysroot $(UNIVERSAL_SDK_PATH)
   endif
 
   # Building universal cannot compute dependencies automatically.
   DISABLE_AUTO_DEPENDENCIES=1
+else
+  ifeq ($(OS),Darwin)
+    ifeq ($(ARCH),x86_64)
+      CompileCommonOpts += -m64
+    else
+      ifeq ($(ARCH),x86)
+        CompileCommonOpts += -m32
+      endif
+    endif
+  endif
 endif
 
 ifeq ($(OS),SunOS)
@@ -753,8 +797,8 @@ $(LLVM_CONFIG):
 
 $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT): $(LLVM_CONFIG)
 
-ProjLibsOptions += $(shell $(LLVM_CONFIG) --libs     $(LINK_COMPONENTS))
-ProjLibsPaths   += $(LLVM_CONFIG) \
+LLVMLibsOptions += $(shell $(LLVM_CONFIG) --libs     $(LINK_COMPONENTS))
+LLVMLibsPaths   += $(LLVM_CONFIG) \
                   $(shell $(LLVM_CONFIG) --libfiles $(LINK_COMPONENTS))
 endif
 endif
@@ -977,7 +1021,7 @@ all-local:: $(LibName.O)
 
 $(LibName.O): $(ObjectsO) $(LibDir)/.dir
        $(Echo) Linking $(BuildMode) Object Library $(notdir $@)
-       $(Verb) $(Relink) -Wl,-r -nodefaultlibs -nostdlibs -nostartfiles -o $@ $(ObjectsO)
+       $(Verb) $(Relink) -Wl,-r -nodefaultlibs -nostdlib -nostartfiles -o $@ $(ObjectsO)
 
 clean-local::
 ifneq ($(strip $(LibName.O)),)
@@ -1063,6 +1107,24 @@ else
 ToolBuildPath   := $(ToolDir)/$(strip $(TOOLNAME))$(EXEEXT)
 endif
 
+#---------------------------------------------------------
+# Prune Exports
+#---------------------------------------------------------
+
+# If the tool opts in with TOOL_NO_EXPORTS, optimize startup time of the app by
+# not exporting all of the weak symbols from the binary.  This reduces dyld
+# startup time by 4x on darwin in some cases.
+ifdef TOOL_NO_EXPORTS
+ifeq ($(OS),Darwin)
+LD.Flags += -Wl,-exported_symbol -Wl,_main
+endif
+
+ifeq ($(OS), $(filter $(OS), Linux NetBSD FreeBSD))
+LD.Flags += -Wl,--version-script=$(LLVM_SRC_ROOT)/autoconf/ExportMap.map
+endif
+endif
+
+
 #---------------------------------------------------------
 # Provide targets for building the tools
 #---------------------------------------------------------
@@ -1265,14 +1327,15 @@ $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
 ###############################################################################
 
 ifdef TARGET
+TABLEGEN_INC_FILES_COMMON = 1
+endif
+
+ifdef LLVMC_BUILD_AUTOGENERATED_INC
+TABLEGEN_INC_FILES_COMMON = 1
+endif
+
+ifdef TABLEGEN_INC_FILES_COMMON
 
-TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
-           $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
-           $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
-           $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
-           $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
-           $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
-           $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
 INCFiles := $(filter %.inc,$(BUILT_SOURCES))
 INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
 .PRECIOUS: $(INCTMPFiles) $(INCFiles)
@@ -1289,6 +1352,18 @@ $(INCTMPFiles) : $(TBLGEN) $(TDFiles)
 $(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
        $(Verb) $(CMP) -s $@ $< || $(CP) $< $@
 
+endif # TABLEGEN_INC_FILES_COMMON
+
+ifdef TARGET
+
+TDFiles := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td) \
+           $(LLVM_SRC_ROOT)/include/llvm/Target/Target.td \
+           $(LLVM_SRC_ROOT)/include/llvm/Target/TargetCallingConv.td \
+           $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSchedule.td \
+           $(LLVM_SRC_ROOT)/include/llvm/Target/TargetSelectionDAG.td \
+           $(LLVM_SRC_ROOT)/include/llvm/CodeGen/ValueTypes.td) \
+           $(wildcard $(LLVM_SRC_ROOT)/include/llvm/Intrinsics*.td)
+
 $(TARGET:%=$(ObjDir)/%GenRegisterNames.inc.tmp): \
 $(ObjDir)/%GenRegisterNames.inc.tmp : %.td $(ObjDir)/.dir
        $(Echo) "Building $(<F) register names with tblgen"
@@ -1357,7 +1432,22 @@ $(ObjDir)/%GenIntrinsics.inc.tmp : Intrinsics%.td $(ObjDir)/.dir
 clean-local::
        -$(Verb) $(RM) -f $(INCFiles)
 
-endif
+endif # TARGET
+
+ifdef LLVMC_BUILD_AUTOGENERATED_INC
+
+LLVMCPluginSrc := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td))
+
+TDFiles := $(LLVMCPluginSrc) \
+       $(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
+
+$(ObjDir)/AutoGenerated.inc.tmp: $(LLVMCPluginSrc) $(ObjDir)/.dir \
+                               $(TBLGEN) $(TD_COMMON)
+       $(Echo) "Building LLVMC configuration library with tblgen"
+       $(Verb) $(TableGen) -gen-llvmc -o $(call SYSPATH, $@) $<
+
+endif # LLVMC_BUILD_AUTOGENERATED_INC
+
 
 ###############################################################################
 # OTHER RULES: Other rules needed
@@ -1761,7 +1851,7 @@ printvars::
 ###
 # Debugging
 
-# General debugging rule, use 'make print-XXX' to print the
+# General debugging rule, use 'make dbg-print-XXX' to print the
 # definition, value and origin of XXX.
-print-%: 
+make-print-%:
        $(error PRINT: $(value $*) = "$($*)" (from $(origin $*)))