From 9c78e0b05546a9f43b68b3eaf8c44f31b3cb98c6 Mon Sep 17 00:00:00 2001 From: gwl Date: Thu, 26 Oct 2023 20:26:49 +0800 Subject: [PATCH 1/2] [driver] enable --rewrite-bsc --- .../maple_driver/include/driver_options.h | 1 + .../maple_driver/include/mpl_options.h | 5 +++++ .../maple_driver/src/clang_compiler.cpp | 13 ++++++----- src/mapleall/maple_driver/src/mpl_options.cpp | 22 ++++++++++++------- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/mapleall/maple_driver/include/driver_options.h b/src/mapleall/maple_driver/include/driver_options.h index ad5d8708de..8f0120c7eb 100644 --- a/src/mapleall/maple_driver/include/driver_options.h +++ b/src/mapleall/maple_driver/include/driver_options.h @@ -1889,6 +1889,7 @@ extern maplecl::Option ignoreUnsupOpt; extern maplecl::Option exportMpltInline; extern maplecl::Option importMpltInline; extern maplecl::Option bsc; +extern maplecl::Option rewriteBsc; /* ##################### STRING Options ############################################################### */ diff --git a/src/mapleall/maple_driver/include/mpl_options.h b/src/mapleall/maple_driver/include/mpl_options.h index cf808276af..ab13c7b863 100644 --- a/src/mapleall/maple_driver/include/mpl_options.h +++ b/src/mapleall/maple_driver/include/mpl_options.h @@ -345,6 +345,11 @@ class MplOptions { return optString; } + const bool IsEnableProcessOpt() const { + return opts::onlyPreprocess.IsEnabledByUser() || opts::oM.IsEnabledByUser() || opts::oMM.IsEnabledByUser() || + opts::oMG.IsEnabledByUser() || opts::oMQ.IsEnabledByUser(); + } + maplecl::OptionCategory *GetCategory(const std::string &tool) const; ErrorCode AppendCombOptions(MIRSrcLang srcLang); ErrorCode AppendMplcgOptions(MIRSrcLang srcLang); diff --git a/src/mapleall/maple_driver/src/clang_compiler.cpp b/src/mapleall/maple_driver/src/clang_compiler.cpp index b59a4a348a..bc3fadb0d8 100644 --- a/src/mapleall/maple_driver/src/clang_compiler.cpp +++ b/src/mapleall/maple_driver/src/clang_compiler.cpp @@ -149,11 +149,14 @@ static uint32_t FillSpecialDefaulOpt(std::unique_ptr &opt, } } /* Set last option as -o option */ - if (action.GetInputFileType() != InputFileType::kFileTypeH && action.GetInputFileType() != InputFileType::kFileTypeHbs - && !opts::onlyPreprocess.IsEnabledByUser() && !opts::onlyPreprocess.IsEnabledByUser() && - !opts::oM.IsEnabledByUser() && !opts::oMM.IsEnabledByUser() && !opts::oMG.IsEnabledByUser() && - !opts::oMQ.IsEnabledByUser()) { - if (!opts::linkerTimeOpt.IsEnabledByUser() || !opts::compileWOLink.IsEnabledByUser()) { + if ((action.GetInputFileType() == InputFileType::kFileTypeHbs || + action.GetInputFileType() == InputFileType::kFileTypeCbs) && opts::rewriteBsc.IsEnabledByUser()) { + if (opts::output.IsEnabledByUser()) { + setMplOption("-o", opts::output.GetValue(), index++); + } + } else if (action.GetInputFileType() != InputFileType::kFileTypeH && + action.GetInputFileType() != InputFileType::kFileTypeHbs && !options.IsEnableProcessOpt()) { + if (!(opts::linkerTimeOpt.IsEnabledByUser() && opts::compileWOLink.IsEnabledByUser())) { setMplOption("-o", action.GetFullOutputName() + ".ast", index++); } else { setMplOption("-o", "./" + action.GetOutputName() + ".o", index++); diff --git a/src/mapleall/maple_driver/src/mpl_options.cpp b/src/mapleall/maple_driver/src/mpl_options.cpp index 39f8324626..38286d80e0 100644 --- a/src/mapleall/maple_driver/src/mpl_options.cpp +++ b/src/mapleall/maple_driver/src/mpl_options.cpp @@ -402,10 +402,14 @@ ErrorCode MplOptions::LtoWriteOptions() { } ErrorCode MplOptions::HandleOptions() { - if (opts::output.IsEnabledByUser() && inputInfos.size() > 1 && - (opts::onlyCompile.IsEnabledByUser() || opts::compileWOLink.IsEnabledByUser())) { - LogInfo::MapleLogger(kLlErr) << "Cannot specify -o with -c, -S when generating multiple output\n"; - return kErrorInvalidParameter; + if (opts::output.IsEnabledByUser() && inputInfos.size() > 1) { + if (opts::rewriteBsc.IsEnabledByUser()) { + LogInfo::MapleLogger(kLlErr) << "Cannot specify -o when generating multiple output files.\n"; + return kErrorInvalidParameter; + } else if (opts::onlyCompile.IsEnabledByUser() || opts::compileWOLink.IsEnabledByUser()) { + LogInfo::MapleLogger(kLlErr) << "Cannot specify -o with -c, -S when generating multiple output.\n"; + return kErrorInvalidParameter; + } } if (opts::saveTempOpt.IsEnabledByUser()) { @@ -575,11 +579,13 @@ std::unique_ptr MplOptions::DecideRunningPhasesByType(const InputInfo *c UpdateRunningExe(kBinNameClang); newAction = std::make_unique(kBinNameClang, inputInfo, currentAction); currentAction = std::move(newAction); - if (inputFileType == InputFileType::kFileTypeH || opts::onlyPreprocess.IsEnabledByUser() || - inputFileType == InputFileType::kFileTypeHbs|| opts::onlyPreprocess.IsEnabledByUser() || + if (inputFileType == InputFileType::kFileTypeH || inputFileType == InputFileType::kFileTypeHbs || (opts::linkerTimeOpt.IsEnabledByUser() && opts::compileWOLink.IsEnabledByUser()) || - opts::oM.IsEnabledByUser() || opts::oMM.IsEnabledByUser() || opts::oMG.IsEnabledByUser() || - opts::oMQ.IsEnabledByUser()) { + IsEnableProcessOpt()) { + return currentAction; + } + if ((inputFileType == InputFileType::kFileTypeHbs || inputFileType == InputFileType::kFileTypeCbs) && + opts::rewriteBsc.IsEnabledByUser()) { return currentAction; } [[clang::fallthrough]]; -- Gitee From 9c192e77ba2d6b0b56b28ce2e0985d485f399b40 Mon Sep 17 00:00:00 2001 From: gwl Date: Wed, 1 Nov 2023 20:22:20 +0800 Subject: [PATCH 2/2] [drivver]-x bsc and -std=bsc --- src/mapleall/maple_driver/include/driver_options.h | 2 ++ src/mapleall/maple_driver/src/driver_options.cpp | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mapleall/maple_driver/include/driver_options.h b/src/mapleall/maple_driver/include/driver_options.h index 8f0120c7eb..e646c9104c 100644 --- a/src/mapleall/maple_driver/include/driver_options.h +++ b/src/mapleall/maple_driver/include/driver_options.h @@ -1890,6 +1890,7 @@ extern maplecl::Option exportMpltInline; extern maplecl::Option importMpltInline; extern maplecl::Option bsc; extern maplecl::Option rewriteBsc; +extern maplecl::Option oStdBsc; /* ##################### STRING Options ############################################################### */ @@ -2095,6 +2096,7 @@ extern maplecl::Option rootPath; extern maplecl::Option aggressiveTlsWarmupFunction; extern maplecl::Option oMQ; extern maplecl::Option inlineMpltDir; +extern maplecl::Option oX; /* ##################### DIGITAL Options ############################################################### */ diff --git a/src/mapleall/maple_driver/src/driver_options.cpp b/src/mapleall/maple_driver/src/driver_options.cpp index 3aee6d8e8e..eb4ecbcff1 100644 --- a/src/mapleall/maple_driver/src/driver_options.cpp +++ b/src/mapleall/maple_driver/src/driver_options.cpp @@ -391,6 +391,10 @@ maplecl::Option oTrigraphs({"-trigraphs"}, " -trigraphs \t-trigraphs Support ISO C trigraphs.\n", {driverCategory, clangCategory}, kOptFront, maplecl::kHide); +maplecl::Option oStdBsc({"-std=bsc"}, + " -std=bsc \tConform to the bsc C++ standard.\n", + {driverCategory, clangCategory}); + maplecl::Option oStd03({"-std=c++03"}, " -std=c++03 \tConform to the ISO 1998 C++ standard revised by the 2003 technical corrigendum.\n", {driverCategory, clangCategory, unSupCategory}, maplecl::kHide); @@ -912,9 +916,13 @@ maplecl::Option oA({"-A"}, {driverCategory, clangCategory}, kOptFront, maplecl::kJoinedValue); maplecl::Option inlineMpltDir({"-finline-mplt-dir="}, - " -finline-mplt-dir= \tSpecify the inline mplt directory for exporting and importing.\n", + " -finline-mplt-dir= \tSpecify the inline mplt directory for exporting and importing.\n", {driverCategory, hir2mplCategory, mpl2mplCategory}, kOptCommon | kOptOptimization | kOptMaple, maplecl::Init("")); +maplecl::Option oX({"-x"}, + " -x \tSpecify to compile using Bi Sheng C syntax.\n", + {driverCategory, clangCategory}, kOptFront | kOptMaple); + /* ##################### DIGITAL Options ############################################################### */ maplecl::Option helpLevel({"--level"}, -- Gitee