Add 'SelectFunctionDir' function, to select appropriate function implementation based on a configuration and architecture.

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@93717 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/make/lib_info.mk b/make/lib_info.mk
new file mode 100644
index 0000000..d7fc607
--- /dev/null
+++ b/make/lib_info.mk
@@ -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))))
+