New function for tablegenning: clang_tablegen.

llvm-svn: 126093
This commit is contained in:
Oscar Fuentes 2011-02-20 22:06:32 +00:00
parent 3145e923c1
commit 6f72540e46
8 changed files with 85 additions and 78 deletions

View File

@ -121,6 +121,36 @@ configure_file(
${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake
${CLANG_BINARY_DIR}/include/clang/Config/config.h) ${CLANG_BINARY_DIR}/include/clang/Config/config.h)
include(LLVMParseArguments)
function(clang_tablegen)
# Syntax:
# clang_tablegen output-file [tablegen-arg ...] SOURCE source-file
# [[TARGET cmake-target-name] [DEPENDS extra-dependency ...]]
#
# Generates a custom command for invoking tblgen as
#
# tblgen source-file -o=output-file tablegen-arg ...
#
# and, if cmake-target-name is provided, creates a custom target for
# executing the custom command depending on output-file. It is
# possible to list more files to depend after DEPENDS.
parse_arguments( CTG "SOURCE;TARGET;DEPENDS" "" ${ARGN} )
if( NOT CTG_SOURCE )
message(FATAL_ERROR "SOURCE source-file required by clang_tablegen")
endif()
set( LLVM_TARGET_DEFINITIONS ${CTG_SOURCE} )
tablegen( ${CTG_DEFAULT_ARGS} )
list( GET CTG_DEFAULT_ARGS 0 output_file )
if( CTG_TARGET )
add_custom_target( ${CTG_TARGET} DEPENDS ${output_file} ${CTG_DEPENDS} )
endif()
endfunction(clang_tablegen)
macro(add_clang_library name) macro(add_clang_library name)
llvm_process_sources(srcs ${ARGN}) llvm_process_sources(srcs ${ARGN})
if(MSVC_IDE OR XCODE) if(MSVC_IDE OR XCODE)

View File

@ -1,24 +1,17 @@
set(LLVM_TARGET_DEFINITIONS ../Basic/Attr.td) clang_tablegen(Attrs.inc -gen-clang-attr-classes
tablegen(Attrs.inc -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
-gen-clang-attr-classes SOURCE ../Basic/Attr.td
-I ${CMAKE_CURRENT_SOURCE_DIR}/../../) TARGET ClangAttrClasses)
add_custom_target(ClangAttrClasses
DEPENDS Attrs.inc)
tablegen(AttrImpl.inc clang_tablegen(AttrImpl.inc -gen-clang-attr-impl
-gen-clang-attr-impl -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
-I ${CMAKE_CURRENT_SOURCE_DIR}/../../) SOURCE ../Basic/Attr.td
add_custom_target(ClangAttrImpl TARGET ClangAttrImpl)
DEPENDS AttrImpl.inc)
set(LLVM_TARGET_DEFINITIONS ../Basic/StmtNodes.td) clang_tablegen(StmtNodes.inc -gen-clang-stmt-nodes
tablegen(StmtNodes.inc SOURCE ../Basic/StmtNodes.td
-gen-clang-stmt-nodes) TARGET ClangStmtNodes)
add_custom_target(ClangStmtNodes
DEPENDS StmtNodes.inc)
set(LLVM_TARGET_DEFINITIONS ../Basic/DeclNodes.td) clang_tablegen(DeclNodes.inc -gen-clang-decl-nodes
tablegen(DeclNodes.inc SOURCE ../Basic/DeclNodes.td
-gen-clang-decl-nodes) TARGET ClangDeclNodes)
add_custom_target(ClangDeclNodes
DEPENDS DeclNodes.inc)

View File

@ -1,11 +1,10 @@
macro(clang_diag_gen component) macro(clang_diag_gen component)
tablegen(Diagnostic${component}Kinds.inc clang_tablegen(Diagnostic${component}Kinds.inc
-gen-clang-diags-defs -clang-component=${component}) -gen-clang-diags-defs -clang-component=${component}
add_custom_target(ClangDiagnostic${component} SOURCE Diagnostic.td
DEPENDS Diagnostic${component}Kinds.inc) TARGET ClangDiagnostic${component})
endmacro(clang_diag_gen) endmacro(clang_diag_gen)
set(LLVM_TARGET_DEFINITIONS Diagnostic.td)
clang_diag_gen(Analysis) clang_diag_gen(Analysis)
clang_diag_gen(AST) clang_diag_gen(AST)
clang_diag_gen(Common) clang_diag_gen(Common)
@ -14,19 +13,16 @@ clang_diag_gen(Frontend)
clang_diag_gen(Lex) clang_diag_gen(Lex)
clang_diag_gen(Parse) clang_diag_gen(Parse)
clang_diag_gen(Sema) clang_diag_gen(Sema)
tablegen(DiagnosticGroups.inc clang_tablegen(DiagnosticGroups.inc -gen-clang-diag-groups
-gen-clang-diag-groups) SOURCE Diagnostic.td
add_custom_target(ClangDiagnosticGroups TARGET ClangDiagnosticGroups)
DEPENDS DiagnosticGroups.inc)
set(LLVM_TARGET_DEFINITIONS Attr.td) clang_tablegen(AttrList.inc -gen-clang-attr-list
tablegen(AttrList.inc -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
-gen-clang-attr-list SOURCE Attr.td
-I ${CMAKE_CURRENT_SOURCE_DIR}/../../) TARGET ClangAttrList)
add_custom_target(ClangAttrList
DEPENDS AttrList.inc)
# ARM NEON # ARM NEON
set(LLVM_TARGET_DEFINITIONS arm_neon.td) clang_tablegen(arm_neon.inc -gen-arm-neon-sema
tablegen(arm_neon.inc -gen-arm-neon-sema) SOURCE arm_neon.td
add_custom_target(ClangARMNeon DEPENDS arm_neon.inc) TARGET ClangARMNeon)

View File

@ -1,17 +1,11 @@
set(LLVM_TARGET_DEFINITIONS Options.td) clang_tablegen(Options.inc -gen-opt-parser-defs
tablegen(Options.inc SOURCE Options.td
-gen-opt-parser-defs) TARGET ClangDriverOptions)
add_custom_target(ClangDriverOptions
DEPENDS Options.inc)
set(LLVM_TARGET_DEFINITIONS CC1Options.td) clang_tablegen(CC1Options.inc -gen-opt-parser-defs
tablegen(CC1Options.inc SOURCE CC1Options.td
-gen-opt-parser-defs) TARGET ClangCC1Options)
add_custom_target(ClangCC1Options
DEPENDS CC1Options.inc)
set(LLVM_TARGET_DEFINITIONS CC1AsOptions.td) clang_tablegen(CC1AsOptions.inc -gen-opt-parser-defs
tablegen(CC1AsOptions.inc SOURCE CC1AsOptions.td
-gen-opt-parser-defs) TARGET ClangCC1AsOptions)
add_custom_target(ClangCC1AsOptions
DEPENDS CC1AsOptions.inc)

View File

@ -1,6 +1,5 @@
set(LLVM_TARGET_DEFINITIONS ../Basic/Attr.td) clang_tablegen(AttrSpellings.inc -gen-clang-attr-spelling-list
tablegen(AttrSpellings.inc -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
-gen-clang-attr-spelling-list SOURCE ../Basic/Attr.td
-I ${CMAKE_CURRENT_SOURCE_DIR}/../../) TARGET ClangAttrSpellings
add_custom_target(ClangAttrSpellings
DEPENDS AttrSpellings.inc) DEPENDS AttrSpellings.inc)

View File

@ -1,12 +1,9 @@
set(LLVM_TARGET_DEFINITIONS ../Basic/Attr.td) clang_tablegen(AttrPCHRead.inc -gen-clang-attr-pch-read
tablegen(AttrPCHRead.inc -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
-gen-clang-attr-pch-read SOURCE ../Basic/Attr.td
-I ${CMAKE_CURRENT_SOURCE_DIR}/../../) TARGET ClangAttrPCHRead)
add_custom_target(ClangAttrPCHRead
DEPENDS AttrPCHRead.inc)
tablegen(AttrPCHWrite.inc clang_tablegen(AttrPCHWrite.inc -gen-clang-attr-pch-write
-gen-clang-attr-pch-write -I ${CMAKE_CURRENT_SOURCE_DIR}/../../
-I ${CMAKE_CURRENT_SOURCE_DIR}/../../) SOURCE ../Basic/Attr.td
add_custom_target(ClangAttrPCHWrite TARGET ClangAttrPCHWrite)
DEPENDS AttrPCHWrite.inc)

View File

@ -28,8 +28,8 @@ if(MSVC_IDE OR XCODE)
endif() endif()
# Generate arm_neon.h # Generate arm_neon.h
set(LLVM_TARGET_DEFINITIONS ${CLANG_SOURCE_DIR}/include/clang/Basic/arm_neon.td) clang_tablegen(arm_neon.h.inc -gen-arm-neon
tablegen(arm_neon.h.inc -gen-arm-neon) SOURCE ${CLANG_SOURCE_DIR}/include/clang/Basic/arm_neon.td)
set(out_files) set(out_files)
foreach( f ${files} ) foreach( f ${files} )

View File

@ -1,9 +1,7 @@
set(LLVM_TARGET_DEFINITIONS Checkers.td) clang_tablegen(Checkers.inc -gen-clang-sa-checkers
tablegen(Checkers.inc -I ${CMAKE_CURRENT_SOURCE_DIR}/../../../include
-gen-clang-sa-checkers SOURCE Checkers.td
-I ${CMAKE_CURRENT_SOURCE_DIR}/../../../include) TARGET ClangSACheckers)
add_custom_target(ClangSACheckers
DEPENDS Checkers.inc)
set(LLVM_USED_LIBS clangBasic clangAST) set(LLVM_USED_LIBS clangBasic clangAST)