Remove duplication in Makefile.rules.

Merge common bits from the LLVMC and TABLEGEN sections.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@65834 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Mikhail Glushenkov 2009-03-02 09:42:59 +00:00
parent 09c9ed4409
commit 1386ae4b0f

View File

@ -208,7 +208,7 @@ endif
# TableGen stuff...
ifneq ($(BUILT_SOURCES),)
BUILD_AUTOGENERATED_INC=1
LLVMC_BUILD_AUTOGENERATED_INC=1
endif
endif # LLVMC_PLUGIN
@ -1303,50 +1303,20 @@ $(ObjDir)/%.bc: %.ll $(ObjDir)/.dir $(LLVMAS)
$(Echo) "Compiling $*.ll for $(BuildMode) build"
$(Verb) $(LLVMAS) $< -f -o $@
###############################################################################
# LLVMC: Provide rules for compiling llvmc plugins, pt. 2
###############################################################################
ifdef BUILD_AUTOGENERATED_INC
# This needs to be in a separate section, otherwise we get an infinite loop:)
# This stuff is mostly copied from the TABLEGEN section below
# TODO: merge
LLVMCPluginSrc := $(strip $(wildcard $(PROJ_SRC_DIR)/*.td))
TDFiles := $(LLVMCPluginSrc) \
$(strip $(wildcard $(LLVM_SRC_ROOT)/include/llvm/CompilerDriver/*.td))
INCFiles := $(filter %.inc,$(BUILT_SOURCES))
INCTMPFiles := $(INCFiles:%=$(ObjDir)/%.tmp)
.PRECIOUS: $(INCTMPFiles) $(INCFiles)
# All of these files depend on tblgen and the .td files.
$(INCTMPFiles) : $(TBLGEN) $(TDFiles)
$(INCFiles) : %.inc : $(ObjDir)/%.inc.tmp
$(Verb) $(CMP) -s $@ $< || $(CP) $< $@
$(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 # BUILD_AUTOGENERATED_INC
###############################################################################
# TABLEGEN: Provide rules for running tblgen to produce *.inc files
###############################################################################
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)
@ -1363,6 +1333,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"
@ -1431,7 +1413,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