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
This commit is contained in:
Daniel Dunbar 2008-11-08 03:25:47 +00:00
parent edeb4f9726
commit 77e0c85dcc
4 changed files with 66 additions and 2 deletions

View File

@ -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"]>,

12
test/LLVMC/hello.m Normal file
View File

@ -0,0 +1,12 @@
/*
* Check that we can compile helloworld
* RUN: llvmc2 %s -o %t
* RUN: ./%t | grep hello
*/
#include <stdio.h>
int main() {
printf("hello\n");
return 0;
}

8
test/LLVMC/hello.mm Normal file
View File

@ -0,0 +1,8 @@
// Test that we can compile Objective-C++ code.
// RUN: llvmc2 %s -o %t
// RUN: ./%t | grep hello
#include <iostream>
int main() {
std::cout << "hello" << '\n';
}

View File

@ -20,14 +20,20 @@ def CompilationGraph : CompilationGraph<[
Edge<root, llvm_gcc_c>,
Edge<root, llvm_gcc_assembler>,
Edge<root, llvm_gcc_cpp>,
Edge<root, llvm_gcc_m>,
Edge<root, llvm_gcc_mxx>,
Edge<root, llvm_as>,
Edge<llvm_gcc_c, llc>,
Edge<llvm_gcc_cpp, llc>,
Edge<llvm_gcc_m, llc>,
Edge<llvm_gcc_mxx, llc>,
Edge<llvm_as, llc>,
OptionalEdge<llvm_gcc_c, opt, (case (switch_on "opt"), (inc_weight))>,
OptionalEdge<llvm_gcc_cpp, opt, (case (switch_on "opt"), (inc_weight))>,
OptionalEdge<llvm_gcc_m, opt, (case (switch_on "opt"), (inc_weight))>,
OptionalEdge<llvm_gcc_mxx, opt, (case (switch_on "opt"), (inc_weight))>,
OptionalEdge<llvm_as, opt, (case (switch_on "opt"), (inc_weight))>,
Edge<opt, llc>,
@ -35,7 +41,9 @@ def CompilationGraph : CompilationGraph<[
Edge<llvm_gcc_assembler, llvm_gcc_linker>,
OptionalEdge<llvm_gcc_assembler, llvm_gcc_cpp_linker,
(case
(input_languages_contain "c++"), (inc_weight),
(or (input_languages_contain "c++"),
(input_languages_contain "objective-c++")),
(inc_weight),
(or (parameter_equals "linker", "g++"),
(parameter_equals "linker", "c++")), (inc_weight))>,
@ -43,7 +51,9 @@ def CompilationGraph : CompilationGraph<[
Edge<root, llvm_gcc_linker>,
OptionalEdge<root, llvm_gcc_cpp_linker,
(case
(input_languages_contain "c++"), (inc_weight),
(or (input_languages_contain "c++"),
(input_languages_contain "objective-c++")),
(inc_weight),
(or (parameter_equals "linker", "g++"),
(parameter_equals "linker", "c++")), (inc_weight))>
]>;