aboutsummaryrefslogtreecommitdiff
path: root/lib/Driver/Tools.cpp
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-06-07 23:28:45 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-06-07 23:28:45 +0000
commit6c6424bc0d3b5f080a97b5f6ef4a8d70c38e38f5 (patch)
tree2ff4a2b19b5a48f6aef33881d979b51ce2817924 /lib/Driver/Tools.cpp
parent4cbbd94d0abeec2d7e7438d098527aa340d82389 (diff)
Driver: Support invoking Clang on .ll or .bc inputs.
- We actually pretend that we have two separate types for LLVM assembly/bitcode because we need to use the standard suffixes with LTO ('clang -O4 -c t.c' should generate 't.o'). It is now possible to do something like: $ clang -emit-llvm -S t.c -o t.ll ... assorted other compile flags ... $ clang -c t.ll -o t.o ... assorted other compile flags ... and expect that the output will be almost* identical to: $ clang -c t.c -o t.o ... assorted other compile flags ... because all the target settings (default CPU, target features, etc.) will all be initialized properly by the driver/frontend. *: This isn't perfect yet, because in practice we will end up running the optimization passes twice. It's possible to get something equivalent out with a well placed -mllvm -disable-llvm-optzns, but I'm still thinking about the cleanest way to solve this problem more generally. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@105584 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/Tools.cpp')
-rw-r--r--lib/Driver/Tools.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp
index 4ab32ed3ef..05569074a4 100644
--- a/lib/Driver/Tools.cpp
+++ b/lib/Driver/Tools.cpp
@@ -792,9 +792,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (JA.getType() == types::TY_Nothing) {
CmdArgs.push_back("-fsyntax-only");
- } else if (JA.getType() == types::TY_LLVMAsm) {
+ } else if (JA.getType() == types::TY_LLVM_IR ||
+ JA.getType() == types::TY_LTO_IR) {
CmdArgs.push_back("-emit-llvm");
- } else if (JA.getType() == types::TY_LLVMBC) {
+ } else if (JA.getType() == types::TY_LLVM_BC ||
+ JA.getType() == types::TY_LTO_BC) {
CmdArgs.push_back("-emit-llvm-bc");
} else if (JA.getType() == types::TY_PP_Asm) {
CmdArgs.push_back("-S");
@@ -1634,7 +1636,8 @@ void gcc::Common::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &II = *it;
// Don't try to pass LLVM or AST inputs to a generic gcc.
- if (II.getType() == types::TY_LLVMBC)
+ if (II.getType() == types::TY_LLVM_IR || II.getType() == types::TY_LTO_IR ||
+ II.getType() == types::TY_LLVM_BC || II.getType() == types::TY_LTO_BC)
D.Diag(clang::diag::err_drv_no_linker_llvm_support)
<< getToolChain().getTripleString();
else if (II.getType() == types::TY_AST)
@@ -1676,7 +1679,8 @@ void gcc::Compile::RenderExtraToolArgs(const JobAction &JA,
const Driver &D = getToolChain().getDriver();
// If -flto, etc. are present then make sure not to force assembly output.
- if (JA.getType() == types::TY_LLVMBC)
+ if (JA.getType() == types::TY_LLVM_IR || JA.getType() == types::TY_LTO_IR ||
+ JA.getType() == types::TY_LLVM_BC || JA.getType() == types::TY_LTO_BC)
CmdArgs.push_back("-c");
else {
if (JA.getType() != types::TY_PP_Asm)
@@ -2083,9 +2087,11 @@ void darwin::Compile::ConstructJob(Compilation &C, const JobAction &JA,
D.Diag(clang::diag::err_drv_argument_only_allowed_with)
<< A->getAsString(Args) << "-E";
- if (Output.getType() == types::TY_LLVMAsm)
+ if (JA.getType() == types::TY_LLVM_IR ||
+ JA.getType() == types::TY_LTO_IR)
CmdArgs.push_back("-emit-llvm");
- else if (Output.getType() == types::TY_LLVMBC)
+ else if (JA.getType() == types::TY_LLVM_BC ||
+ JA.getType() == types::TY_LTO_BC)
CmdArgs.push_back("-emit-llvm-bc");
else if (Output.getType() == types::TY_AST)
D.Diag(clang::diag::err_drv_no_ast_support)
@@ -2679,7 +2685,8 @@ void auroraux::Link::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &II = *it;
// Don't try to pass LLVM inputs to a generic gcc.
- if (II.getType() == types::TY_LLVMBC)
+ if (II.getType() == types::TY_LLVM_IR || II.getType() == types::TY_LTO_IR ||
+ II.getType() == types::TY_LLVM_BC || II.getType() == types::TY_LTO_BC)
D.Diag(clang::diag::err_drv_no_linker_llvm_support)
<< getToolChain().getTripleString();
@@ -2809,7 +2816,8 @@ void openbsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &II = *it;
// Don't try to pass LLVM inputs to a generic gcc.
- if (II.getType() == types::TY_LLVMBC)
+ if (II.getType() == types::TY_LLVM_IR || II.getType() == types::TY_LTO_IR ||
+ II.getType() == types::TY_LLVM_BC || II.getType() == types::TY_LTO_BC)
D.Diag(clang::diag::err_drv_no_linker_llvm_support)
<< getToolChain().getTripleString();
@@ -2947,7 +2955,8 @@ void freebsd::Link::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &II = *it;
// Don't try to pass LLVM inputs to a generic gcc.
- if (II.getType() == types::TY_LLVMBC)
+ if (II.getType() == types::TY_LLVM_IR || II.getType() == types::TY_LTO_IR ||
+ II.getType() == types::TY_LLVM_BC || II.getType() == types::TY_LTO_BC)
D.Diag(clang::diag::err_drv_no_linker_llvm_support)
<< getToolChain().getTripleString();
@@ -3100,7 +3109,8 @@ void dragonfly::Link::ConstructJob(Compilation &C, const JobAction &JA,
const InputInfo &II = *it;
// Don't try to pass LLVM inputs to a generic gcc.
- if (II.getType() == types::TY_LLVMBC)
+ if (II.getType() == types::TY_LLVM_IR || II.getType() == types::TY_LTO_IR ||
+ II.getType() == types::TY_LLVM_BC || II.getType() == types::TY_LTO_BC)
D.Diag(clang::diag::err_drv_no_linker_llvm_support)
<< getToolChain().getTripleString();