mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Driver] Pass -emit-irgen thru to frontend.
Add a new filetype for this mode option: "Raw LLVM IR". When the mode option is emit-irgen, the new filetype will be the output kind; conversely when determining the mode option to use, if the output kind is the new filetype, the mode option will be emit-irgen.
This commit is contained in:
@@ -58,6 +58,7 @@ TYPE("assembly", Assembly, "s", "")
|
||||
TYPE("raw-sil", RawSIL, "sil", "")
|
||||
TYPE("raw-sib", RawSIB, "sib", "")
|
||||
TYPE("llvm-ir", LLVM_IR, "ll", "")
|
||||
TYPE("raw-llvm-ir", RawLLVM_IR, "ll", "")
|
||||
TYPE("llvm-bc", LLVM_BC, "bc", "")
|
||||
TYPE("diagnostics", SerializedDiagnostics, "dia", "")
|
||||
TYPE("clang-header", ClangHeader, "h", "")
|
||||
|
||||
@@ -97,6 +97,7 @@ bool file_types::isTextual(ID Id) {
|
||||
case file_types::TY_Assembly:
|
||||
case file_types::TY_ASTDump:
|
||||
case file_types::TY_RawSIL:
|
||||
case file_types::TY_RawLLVM_IR:
|
||||
case file_types::TY_LLVM_IR:
|
||||
case file_types::TY_ClangHeader:
|
||||
case file_types::TY_AutolinkFile:
|
||||
@@ -165,6 +166,7 @@ bool file_types::isAfterLLVM(ID Id) {
|
||||
case file_types::TY_ClangHeader:
|
||||
case file_types::TY_AutolinkFile:
|
||||
case file_types::TY_Image:
|
||||
case file_types::TY_RawLLVM_IR:
|
||||
case file_types::TY_dSYM:
|
||||
case file_types::TY_SIB:
|
||||
case file_types::TY_RawSIB:
|
||||
@@ -214,6 +216,7 @@ bool file_types::isPartOfSwiftCompilation(ID Id) {
|
||||
case file_types::TY_RawSIB:
|
||||
return true;
|
||||
case file_types::TY_Assembly:
|
||||
case file_types::TY_RawLLVM_IR:
|
||||
case file_types::TY_LLVM_IR:
|
||||
case file_types::TY_LLVM_BC:
|
||||
case file_types::TY_Object:
|
||||
@@ -275,6 +278,7 @@ bool file_types::isProducedFromDiagnostics(ID Id) {
|
||||
case file_types::TY_SIB:
|
||||
case file_types::TY_RawSIB:
|
||||
case file_types::TY_Assembly:
|
||||
case file_types::TY_RawLLVM_IR:
|
||||
case file_types::TY_LLVM_IR:
|
||||
case file_types::TY_LLVM_BC:
|
||||
case file_types::TY_Object:
|
||||
|
||||
@@ -1167,6 +1167,9 @@ void Driver::buildOutputInfo(const ToolChain &TC, const DerivedArgList &Args,
|
||||
break;
|
||||
|
||||
case options::OPT_emit_irgen:
|
||||
OI.CompilerOutputType = file_types::TY_RawLLVM_IR;
|
||||
break;
|
||||
|
||||
case options::OPT_emit_ir:
|
||||
OI.CompilerOutputType = file_types::TY_LLVM_IR;
|
||||
break;
|
||||
@@ -1668,6 +1671,7 @@ void Driver::buildActions(SmallVectorImpl<const Action *> &TopLevelActions,
|
||||
case file_types::TY_dSYM:
|
||||
case file_types::TY_Dependencies:
|
||||
case file_types::TY_Assembly:
|
||||
case file_types::TY_RawLLVM_IR:
|
||||
case file_types::TY_LLVM_IR:
|
||||
case file_types::TY_LLVM_BC:
|
||||
case file_types::TY_SerializedDiagnostics:
|
||||
|
||||
@@ -712,6 +712,8 @@ const char *ToolChain::JobContext::computeFrontendModeForCompile() const {
|
||||
return "-emit-sibgen";
|
||||
case file_types::TY_SIB:
|
||||
return "-emit-sib";
|
||||
case file_types::TY_RawLLVM_IR:
|
||||
return "-emit-irgen";
|
||||
case file_types::TY_LLVM_IR:
|
||||
return "-emit-ir";
|
||||
case file_types::TY_LLVM_BC:
|
||||
@@ -977,6 +979,9 @@ ToolChain::constructInvocation(const BackendJobAction &job,
|
||||
case file_types::TY_Object:
|
||||
FrontendModeOption = "-c";
|
||||
break;
|
||||
case file_types::TY_RawLLVM_IR:
|
||||
FrontendModeOption = "-emit-irgen";
|
||||
break;
|
||||
case file_types::TY_LLVM_IR:
|
||||
FrontendModeOption = "-emit-ir";
|
||||
break;
|
||||
|
||||
@@ -335,6 +335,8 @@ FrontendOptions::formatForPrincipalOutputFileForAction(ActionType action) {
|
||||
return TY_Assembly;
|
||||
|
||||
case ActionType::EmitIRGen:
|
||||
return TY_RawLLVM_IR;
|
||||
|
||||
case ActionType::EmitIR:
|
||||
return TY_LLVM_IR;
|
||||
|
||||
|
||||
3
test/Driver/emit-irgen.swift
Normal file
3
test/Driver/emit-irgen.swift
Normal file
@@ -0,0 +1,3 @@
|
||||
// RUN: %swiftc_driver -### -emit-irgen %s -o - | %FileCheck %s
|
||||
|
||||
// CHECK: -emit-irgen
|
||||
@@ -27,8 +27,9 @@ TEST(FileSystem, lookupTypeFromFilename) {
|
||||
// no extension, skip.
|
||||
if (Entry.first.empty())
|
||||
continue;
|
||||
// raw-sil and raw-sib do not have unique extension.
|
||||
if (Entry.second == TY_RawSIL || Entry.second == TY_RawSIB)
|
||||
// raw-sil, raw-sib, and raw-llvm-ir do not have unique extensions.
|
||||
if (Entry.second == TY_RawSIL || Entry.second == TY_RawSIB ||
|
||||
Entry.second == TY_RawLLVM_IR)
|
||||
continue;
|
||||
|
||||
std::string Filename = "Myfile." + Entry.first;
|
||||
|
||||
Reference in New Issue
Block a user