[llvm-commits] [compiler-rt] r93717 - in /compiler-rt/trunk: .gitignore Makefile make/lib_info.mk make/lib_util.mk

Daniel Dunbar daniel at zuster.org
Sun Jan 17 22:48:57 PST 2010


Author: ddunbar
Date: Mon Jan 18 00:48:56 2010
New Revision: 93717

URL: http://llvm.org/viewvc/llvm-project?rev=93717&view=rev
Log:
Add 'SelectFunctionDir' function, to select appropriate function implementation based on a configuration and architecture.

Added:
    compiler-rt/trunk/make/lib_info.mk
    compiler-rt/trunk/make/lib_util.mk
Modified:
    compiler-rt/trunk/.gitignore
    compiler-rt/trunk/Makefile

Modified: compiler-rt/trunk/.gitignore
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/.gitignore?rev=93717&r1=93716&r2=93717&view=diff

==============================================================================
--- compiler-rt/trunk/.gitignore (original)
+++ compiler-rt/trunk/.gitignore Mon Jan 18 00:48:56 2010
@@ -1,3 +1,4 @@
+*~
 Debug
 Release
 Profile

Modified: compiler-rt/trunk/Makefile
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/Makefile?rev=93717&r1=93716&r2=93717&view=diff

==============================================================================
--- compiler-rt/trunk/Makefile (original)
+++ compiler-rt/trunk/Makefile Mon Jan 18 00:48:56 2010
@@ -239,22 +239,12 @@
   $(foreach arch,$(Archs), \
     $(eval $(call Final_CNA_template,$(config),$(arch)))))
 
+###
+
+include make/lib_info.mk
+include make/lib_util.mk
+
 ifneq ($(DEBUGMAKE),)
   $(info MAKE: Done processing Makefile)
   $(info  )
 endif
-
-###
-# Function Information
-#
-# FIXME: Factor out.
-
-AvailableObjects := $(sort $(foreach key,$(SubDirKeys),\
-	$($(key).ObjNames)))
-AvailableFunctions := $(AvailableObjects:%.o=%)
-
-# Compute lists of where each function is available.
-$(foreach key,$(SubDirKeys),\
-  $(foreach fn,$(subst .o,,$($(key).ObjNames)),\
-    $(call Append,AvailableIn.$(fn),$(key))))
-

Added: compiler-rt/trunk/make/lib_info.mk
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/lib_info.mk?rev=93717&view=auto

==============================================================================
--- compiler-rt/trunk/make/lib_info.mk (added)
+++ compiler-rt/trunk/make/lib_info.mk Mon Jan 18 00:48:56 2010
@@ -0,0 +1,45 @@
+# compiler-rt Library Info
+#
+# This should be included once the subdirectory information has been loaded, and
+# uses the utilities in 'util.mk'.
+#
+# This defines the following variables describing compiler-rt:
+#   AvailableFunctions   - The entire list of function names (unmangled) the
+#                          library can provide.
+#   CommonFunctions      - The list of generic functions available.
+#   ArchFunctions.<arch> - The list of functions commonly available for
+#                          'arch'. This does not include any config specific
+#                          functions.
+#
+#   AvailableIn.<function> - The list of subdir keys where 'function' is
+#                            defined.
+
+AvailableArchs := $(sort $(foreach key,$(SubDirKeys),\
+	$($(key).OnlyArchs)))
+
+AvailableFunctions := $(sort $(foreach key,$(SubDirKeys),\
+	$(basename $($(key).ObjNames))))
+
+CommonFunctions := $(sort\
+  $(foreach key,$(SubDirKeys),\
+    $(if $(call strneq,,$(strip $($(key).OnlyArchs) $($(key).OnlyConfigs))),,\
+         $(basename $($(key).ObjNames)))))
+
+# Compute common arch functions.
+$(foreach key,$(SubDirKeys),\
+  $(if $(call strneq,,$($(key).OnlyConfigs)),,\
+    $(foreach arch,$($(key).OnlyArchs),\
+      $(call Append,ArchFunctions.$(arch),$(sort \
+        $(basename $($(key).ObjNames)))))))
+
+# Compute arch only functions.
+$(foreach arch,$(AvailableArchs),\
+  $(call Set,ArchFunctions.$(arch),$(sort $(ArchFunctions.$(arch))))\
+  $(call Set,ArchOnlyFunctions.$(arch),\
+    $(call set_difference,$(ArchFunctions.$(arch)),$(CommonFunctions))))
+
+# Compute lists of where each function is available.
+$(foreach key,$(SubDirKeys),\
+  $(foreach fn,$(basename $($(key).ObjNames)),\
+    $(call Append,AvailableIn.$(fn),$(key))))
+

Added: compiler-rt/trunk/make/lib_util.mk
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/make/lib_util.mk?rev=93717&view=auto

==============================================================================
--- compiler-rt/trunk/make/lib_util.mk (added)
+++ compiler-rt/trunk/make/lib_util.mk Mon Jan 18 00:48:56 2010
@@ -0,0 +1,56 @@
+# Library Utility Functions
+#
+# This should be included following 'lib_info.mk'.
+
+# Function: SelectFunctionDir config arch function-name optimized
+#
+# Choose the appropriate implementation directory to use for 'function-name' in
+# the configuration 'config' and on given arch.
+SelectFunctionDir = $(strip \
+  $(call Set,Tmp.SelectFunctionDir,$(call SelectFunctionDirs,$(1),$(2),$(3),$(4)))\
+  $(if $(call streq,1,$(words $(Tmp.SelectFunctionDir))),\
+       $(Tmp.SelectFunctionDir),\
+       $(error SelectFunctionDir: invalid function name "$(3)" ($(strip\
+               $(if $(call streq,0,$(words $(Tmp.SelectFunctionDir))),\
+                    no such function,\
+                    function implemented in multiple directories!!!))))))
+
+# Helper functions that select the entire list of subdirs where a function is
+# defined with a certain specificity.
+SelectFunctionDirs_Opt_ConfigAndArch = $(strip \
+  $(foreach key,$(AvailableIn.$(3)),\
+    $(if $(and $(call streq,Optimized,$($(key).Target)),\
+               $(call contains,$($(key).OnlyConfigs),$(1)),\
+               $(call contains,$($(key).OnlyArchs),$(2))),$(key),)))
+SelectFunctionDirs_Opt_Config = $(strip \
+  $(foreach key,$(AvailableIn.$(3)),\
+    $(if $(and $(call streq,Optimized,$($(key).Target)),\
+               $(call contains,$($(key).OnlyConfigs),$(1))),$(key),)))
+SelectFunctionDirs_Opt_Arch = $(strip \
+  $(foreach key,$(AvailableIn.$(3)),\
+    $(if $(and $(call streq,Optimized,$($(key).Target)),\
+               $(call contains,$($(key).OnlyArchs),$(2))),$(key),)))
+SelectFunctionDirs_Gen = $(strip \
+  $(foreach key,$(AvailableIn.$(3)),\
+    $(if $(call streq,Generic,$($(key).Target)),$(key))))
+
+# Helper function to select the right set of dirs in generic priority order.
+SelectFunctions_Gen = \
+  $(or $(call SelectFunctionDirs_Gen,$(1),$(2),$(3)),\
+       $(call SelectFunctionDirs_Opt_ConfigAndArch,$(1),$(2),$(3)), \
+       $(call SelectFunctionDirs_Opt_Config,$(1),$(2),$(3)), \
+       $(call SelectFunctionDirs_Opt_Arch,$(1),$(2),$(3)))
+
+# Helper function to select the right set of dirs in optimized priority order.
+SelectFunctions_Opt = \
+  $(or $(call SelectFunctionDirs_Opt_ConfigAndArch,$(1),$(2),$(3)), \
+       $(call SelectFunctionDirs_Opt_Config,$(1),$(2),$(3)), \
+       $(call SelectFunctionDirs_Opt_Arch,$(1),$(2),$(3)), \
+       $(call SelectFunctionDirs_Gen,$(1),$(2),$(3)))
+
+# Helper function to select the right set of dirs (which should be exactly one)
+# for a function.
+SelectFunctionDirs = \
+  $(if $(call streq,1,$(4)),\
+       $(call SelectFunctions_Opt,$(1),$(2),$(3)),\
+       $(call SelectFunctions_Gen,$(1),$(2),$(3)))





More information about the llvm-commits mailing list