From: Daniel Dunbar Date: Sat, 8 Nov 2008 03:25:47 +0000 (+0000) Subject: Add LLVMC2 tool definitions for Objective-C and Objective-C++. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=77e0c85dcccc692d4ef458912e4fe2310c892f8a;p=oota-llvm.git Add LLVMC2 tool definitions for Objective-C and Objective-C++. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@58885 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm/CompilerDriver/Tools.td b/include/llvm/CompilerDriver/Tools.td index 1a466a2735d..7bd6dd4d940 100644 --- a/include/llvm/CompilerDriver/Tools.td +++ b/include/llvm/CompilerDriver/Tools.td @@ -44,6 +44,38 @@ def llvm_gcc_cpp : Tool< (sink) ]>; +def llvm_gcc_m : Tool< +[(in_language "objective-c"), + (out_language "llvm-bitcode"), + (output_suffix "bc"), + (cmd_line (case + (switch_on "E"), + (case (not_empty "o"), + "llvm-gcc -E -x objective-c $INFILE -o $OUTFILE", + (default), + "llvm-gcc -E -x objective-c $INFILE"), + (default), + "llvm-gcc -c -x objective-c $INFILE -o $OUTFILE -emit-llvm")), + (switch_option "E", (stop_compilation)), + (sink) +]>; + +def llvm_gcc_mxx : Tool< +[(in_language "objective-c++"), + (out_language "llvm-bitcode"), + (output_suffix "bc"), + (cmd_line (case + (switch_on "E"), + (case (not_empty "o"), + "llvm-gcc -E -x objective-c++ $INFILE -o $OUTFILE", + (default), + "llvm-gcc -E -x objective-c++ $INFILE"), + (default), + "llvm-gcc -c -x objective-c++ $INFILE -o $OUTFILE -emit-llvm")), + (switch_option "E", (stop_compilation)), + (sink) +]>; + def opt : Tool< [(in_language "llvm-bitcode"), (out_language "llvm-bitcode"), @@ -109,6 +141,8 @@ def llvm_gcc_cpp_linker : Tool< def LanguageMap : LanguageMap< [LangToSuffixes<"c++", ["cc", "cp", "cxx", "cpp", "CPP", "c++", "C"]>, LangToSuffixes<"c", ["c"]>, + LangToSuffixes<"objective-c++", ["mm"]>, + LangToSuffixes<"objective-c", ["m"]>, LangToSuffixes<"assembler", ["s"]>, LangToSuffixes<"llvm-assembler", ["ll"]>, LangToSuffixes<"llvm-bitcode", ["bc"]>, diff --git a/test/LLVMC/hello.m b/test/LLVMC/hello.m new file mode 100644 index 00000000000..bf917bcdea7 --- /dev/null +++ b/test/LLVMC/hello.m @@ -0,0 +1,12 @@ +/* + * Check that we can compile helloworld + * RUN: llvmc2 %s -o %t + * RUN: ./%t | grep hello + */ + +#include + +int main() { + printf("hello\n"); + return 0; +} diff --git a/test/LLVMC/hello.mm b/test/LLVMC/hello.mm new file mode 100644 index 00000000000..5f14a94ccca --- /dev/null +++ b/test/LLVMC/hello.mm @@ -0,0 +1,8 @@ +// Test that we can compile Objective-C++ code. +// RUN: llvmc2 %s -o %t +// RUN: ./%t | grep hello +#include + +int main() { + std::cout << "hello" << '\n'; +} diff --git a/tools/llvmc2/plugins/Base/Base.td b/tools/llvmc2/plugins/Base/Base.td index 0a43d0fd533..158520c278e 100644 --- a/tools/llvmc2/plugins/Base/Base.td +++ b/tools/llvmc2/plugins/Base/Base.td @@ -20,14 +20,20 @@ def CompilationGraph : CompilationGraph<[ Edge, Edge, Edge, + Edge, + Edge, Edge, Edge, Edge, + Edge, + Edge, Edge, OptionalEdge, OptionalEdge, + OptionalEdge, + OptionalEdge, OptionalEdge, Edge, @@ -35,7 +41,9 @@ def CompilationGraph : CompilationGraph<[ Edge, OptionalEdge, @@ -43,7 +51,9 @@ def CompilationGraph : CompilationGraph<[ Edge, OptionalEdge ]>;