diff options
author | Puyan Lotfi <puyan@puyan.org> | 2019-08-22 23:44:34 +0000 |
---|---|---|
committer | Puyan Lotfi <puyan@puyan.org> | 2019-08-22 23:44:34 +0000 |
commit | 272b5247eb1b7e7c3784b24a0dc9dc996527b0fc (patch) | |
tree | 2b58bb5e251c7220216e479d86bd230b45a880e5 /lib | |
parent | f9ea87c3e3ab0d6772b1c16a0f5734dc29791724 (diff) | |
download | clang-272b5247eb1b7e7c3784b24a0dc9dc996527b0fc.tar.gz |
[clang][ifs] Dropping older experimental interface stub formats.
I've been working on a new tool, llvm-ifs, for merging interface stub files
generated by clang and I've iterated on my derivative format of TBE to a newer
format. llvm-ifs will only support the new format, so I am going to drop the
older experimental interface stubs formats in this commit to make things
simpler.
Differential Revision: https://reviews.llvm.org/D66573
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@369719 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Driver/ToolChains/Clang.cpp | 27 | ||||
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 37 | ||||
-rw-r--r-- | lib/Frontend/InterfaceStubFunctionsConsumer.cpp | 133 | ||||
-rw-r--r-- | lib/FrontendTool/ExecuteCompilerInvocation.cpp | 4 |
4 files changed, 37 insertions, 164 deletions
diff --git a/lib/Driver/ToolChains/Clang.cpp b/lib/Driver/ToolChains/Clang.cpp index 7e420da94f..76d3f623b2 100644 --- a/lib/Driver/ToolChains/Clang.cpp +++ b/lib/Driver/ToolChains/Clang.cpp @@ -3631,22 +3631,27 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, JA.getType() == types::TY_LTO_BC) { CmdArgs.push_back("-emit-llvm-bc"); } else if (JA.getType() == types::TY_IFS) { + StringRef ArgStr = + Args.hasArg(options::OPT_iterface_stub_version_EQ) + ? Args.getLastArgValue(options::OPT_iterface_stub_version_EQ) + : ""; StringRef StubFormat = - llvm::StringSwitch<StringRef>( - Args.hasArg(options::OPT_iterface_stub_version_EQ) - ? Args.getLastArgValue(options::OPT_iterface_stub_version_EQ) - : "") - .Case("experimental-yaml-elf-v1", "experimental-yaml-elf-v1") - .Case("experimental-tapi-elf-v1", "experimental-tapi-elf-v1") + llvm::StringSwitch<StringRef>(ArgStr) .Case("experimental-ifs-v1", "experimental-ifs-v1") .Default(""); - if (StubFormat.empty()) + if (StubFormat.empty()) { + std::string ErrorMessage = + "Invalid interface stub format: " + ArgStr.str() + + ((ArgStr == "experimental-yaml-elf-v1" || + ArgStr == "experimental-tapi-elf-v1") + ? " is deprecated." + : "."); D.Diag(diag::err_drv_invalid_value) - << "Must specify a valid interface stub format type using " - << "-interface-stub-version=<experimental-tapi-elf-v1 | " - "experimental-ifs-v1 | " - "experimental-yaml-elf-v1>"; + << "Must specify a valid interface stub format type, ie: " + "-interface-stub-version=experimental-ifs-v1" + << ErrorMessage; + } CmdArgs.push_back("-emit-interface-stubs"); CmdArgs.push_back( diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index c0539cda11..c45b751713 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -1728,25 +1728,28 @@ static InputKind ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args, case OPT_emit_pch: Opts.ProgramAction = frontend::GeneratePCH; break; case OPT_emit_iterface_stubs: { + StringRef ArgStr = + Args.hasArg(OPT_iterface_stub_version_EQ) + ? Args.getLastArgValue(OPT_iterface_stub_version_EQ) + : ""; llvm::Optional<frontend::ActionKind> ProgramAction = - llvm::StringSwitch<llvm::Optional<frontend::ActionKind>>( - Args.hasArg(OPT_iterface_stub_version_EQ) - ? Args.getLastArgValue(OPT_iterface_stub_version_EQ) - : "") - .Case("experimental-yaml-elf-v1", - frontend::GenerateInterfaceYAMLExpV1) - .Case("experimental-tapi-elf-v1", - frontend::GenerateInterfaceTBEExpV1) - .Case("experimental-ifs-v1", - frontend::GenerateInterfaceIfsExpV1) + llvm::StringSwitch<llvm::Optional<frontend::ActionKind>>(ArgStr) + .Case("experimental-ifs-v1", frontend::GenerateInterfaceIfsExpV1) .Default(llvm::None); - if (!ProgramAction) + if (!ProgramAction) { + std::string ErrorMessage = + "Invalid interface stub format: " + ArgStr.str() + + ((ArgStr == "experimental-yaml-elf-v1" || + ArgStr == "experimental-tapi-elf-v1") + ? " is deprecated." + : "."); Diags.Report(diag::err_drv_invalid_value) - << "Must specify a valid interface stub format type using " - << "-interface-stub-version=<experimental-tapi-elf-v1 | " - "experimental-ifs-v1 | " - "experimental-yaml-elf-v1>"; - Opts.ProgramAction = *ProgramAction; + << "Must specify a valid interface stub format type, ie: " + "-interface-stub-version=experimental-ifs-v1" + << ErrorMessage; + } else { + Opts.ProgramAction = *ProgramAction; + } break; } case OPT_init_only: @@ -3186,8 +3189,6 @@ static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) { case frontend::GenerateModuleInterface: case frontend::GenerateHeaderModule: case frontend::GeneratePCH: - case frontend::GenerateInterfaceYAMLExpV1: - case frontend::GenerateInterfaceTBEExpV1: case frontend::GenerateInterfaceIfsExpV1: case frontend::ParseSyntaxOnly: case frontend::ModuleFileInfo: diff --git a/lib/Frontend/InterfaceStubFunctionsConsumer.cpp b/lib/Frontend/InterfaceStubFunctionsConsumer.cpp index cb597c4709..cdf4e6b33b 100644 --- a/lib/Frontend/InterfaceStubFunctionsConsumer.cpp +++ b/lib/Frontend/InterfaceStubFunctionsConsumer.cpp @@ -246,114 +246,6 @@ public: for (const NamedDecl *ND : v.NamedDecls) HandleNamedDecl(ND, Symbols, FromTU); - auto writeIfoYaml = [this](const llvm::Triple &T, - const MangledSymbols &Symbols, - const ASTContext &context, StringRef Format, - raw_ostream &OS) -> void { - OS << "--- !" << Format << "\n"; - OS << "FileHeader:\n"; - OS << " Class: ELFCLASS"; - OS << (T.isArch64Bit() ? "64" : "32"); - OS << "\n"; - OS << " Data: ELFDATA2"; - OS << (T.isLittleEndian() ? "LSB" : "MSB"); - OS << "\n"; - OS << " Type: ET_REL\n"; - OS << " Machine: " - << llvm::StringSwitch<llvm::StringRef>(T.getArchName()) - .Case("x86_64", "EM_X86_64") - .Case("i386", "EM_386") - .Case("i686", "EM_386") - .Case("aarch64", "EM_AARCH64") - .Case("amdgcn", "EM_AMDGPU") - .Case("r600", "EM_AMDGPU") - .Case("arm", "EM_ARM") - .Case("thumb", "EM_ARM") - .Case("avr", "EM_AVR") - .Case("mips", "EM_MIPS") - .Case("mipsel", "EM_MIPS") - .Case("mips64", "EM_MIPS") - .Case("mips64el", "EM_MIPS") - .Case("msp430", "EM_MSP430") - .Case("ppc", "EM_PPC") - .Case("ppc64", "EM_PPC64") - .Case("ppc64le", "EM_PPC64") - .Case("x86", T.isOSIAMCU() ? "EM_IAMCU" : "EM_386") - .Case("x86_64", "EM_X86_64") - .Default("EM_NONE") - << "\nSymbols:\n"; - for (const auto &E : Symbols) { - const MangledSymbol &Symbol = E.second; - for (auto Name : Symbol.Names) { - OS << " - Name: " - << (Symbol.ParentName.empty() || Instance.getLangOpts().CPlusPlus - ? "" - : (Symbol.ParentName + ".")) - << Name << "\n" - << " Type: STT_"; - switch (Symbol.Type) { - default: - case llvm::ELF::STT_NOTYPE: - OS << "NOTYPE"; - break; - case llvm::ELF::STT_OBJECT: - OS << "OBJECT"; - break; - case llvm::ELF::STT_FUNC: - OS << "FUNC"; - break; - } - OS << "\n Binding: STB_" - << ((Symbol.Binding == llvm::ELF::STB_WEAK) ? "WEAK" : "GLOBAL") - << "\n"; - } - } - OS << "...\n"; - OS.flush(); - }; - - auto writeIfoElfAbiYaml = - [this](const llvm::Triple &T, const MangledSymbols &Symbols, - const ASTContext &context, StringRef Format, - raw_ostream &OS) -> void { - OS << "--- !" << Format << "\n"; - OS << "TbeVersion: 1.0\n"; - OS << "Arch: " << T.getArchName() << "\n"; - OS << "Symbols:\n"; - for (const auto &E : Symbols) { - const MangledSymbol &Symbol = E.second; - for (auto Name : Symbol.Names) { - OS << " " - << (Symbol.ParentName.empty() || Instance.getLangOpts().CPlusPlus - ? "" - : (Symbol.ParentName + ".")) - << Name << ": { Type: "; - switch (Symbol.Type) { - default: - llvm_unreachable( - "clang -emit-iterface-stubs: Unexpected symbol type."); - case llvm::ELF::STT_NOTYPE: - OS << "NoType"; - break; - case llvm::ELF::STT_OBJECT: { - auto VD = cast<ValueDecl>(E.first)->getType(); - OS << "Object, Size: " - << context.getTypeSizeInChars(VD).getQuantity(); - break; - } - case llvm::ELF::STT_FUNC: - OS << "Func"; - break; - } - if (Symbol.Binding == llvm::ELF::STB_WEAK) - OS << ", Weak: true"; - OS << " }\n"; - } - } - OS << "...\n"; - OS.flush(); - }; - auto writeIfsV1 = [this](const llvm::Triple &T, const MangledSymbols &Symbols, const ASTContext &context, StringRef Format, @@ -397,33 +289,12 @@ public: OS.flush(); }; - if (Format == "experimental-yaml-elf-v1") - writeIfoYaml(Instance.getTarget().getTriple(), Symbols, context, Format, - *OS); - else if (Format == "experimental-ifs-v1") - writeIfsV1(Instance.getTarget().getTriple(), Symbols, context, Format, - *OS); - else - writeIfoElfAbiYaml(Instance.getTarget().getTriple(), Symbols, context, - Format, *OS); + assert(Format == "experimental-ifs-v1" && "Unexpected IFS Format."); + writeIfsV1(Instance.getTarget().getTriple(), Symbols, context, Format, *OS); } }; std::unique_ptr<ASTConsumer> -GenerateInterfaceYAMLExpV1Action::CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) { - return std::make_unique<InterfaceStubFunctionsConsumer>( - CI, InFile, "experimental-yaml-elf-v1"); -} - -std::unique_ptr<ASTConsumer> -GenerateInterfaceTBEExpV1Action::CreateASTConsumer(CompilerInstance &CI, - StringRef InFile) { - return std::make_unique<InterfaceStubFunctionsConsumer>( - CI, InFile, "experimental-tapi-elf-v1"); -} - -std::unique_ptr<ASTConsumer> GenerateInterfaceIfsExpV1Action::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) { return std::make_unique<InterfaceStubFunctionsConsumer>( diff --git a/lib/FrontendTool/ExecuteCompilerInvocation.cpp b/lib/FrontendTool/ExecuteCompilerInvocation.cpp index f966750161..e11d50663d 100644 --- a/lib/FrontendTool/ExecuteCompilerInvocation.cpp +++ b/lib/FrontendTool/ExecuteCompilerInvocation.cpp @@ -64,10 +64,6 @@ CreateFrontendBaseAction(CompilerInstance &CI) { case GenerateHeaderModule: return std::make_unique<GenerateHeaderModuleAction>(); case GeneratePCH: return std::make_unique<GeneratePCHAction>(); - case GenerateInterfaceYAMLExpV1: - return std::make_unique<GenerateInterfaceYAMLExpV1Action>(); - case GenerateInterfaceTBEExpV1: - return std::make_unique<GenerateInterfaceTBEExpV1Action>(); case GenerateInterfaceIfsExpV1: return std::make_unique<GenerateInterfaceIfsExpV1Action>(); case InitOnly: return std::make_unique<InitOnlyAction>(); |