• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include "llvm_logger.h"
17 
18 namespace ark::llvmbackend {
19 std::bitset<LLVMLoggerComponents::LOG_COMPONENTS_NUM> LLVMLogger::components_(0);
20 
21 // clang-format off
SetComponents(const std::vector<std::string> & args)22 void LLVMLogger::SetComponents(const std::vector<std::string>& args)
23 {
24     components_.reset();
25     for (const auto& arg : args) {
26         if (arg == "all") {
27             components_.set();
28             break;
29         }
30         if (arg == "none") {
31             components_.reset();
32             break;
33         }
34 // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
35 #define DEF(COMPONENT, NAME)                           \
36             if ((NAME) == arg) {                       \
37                 components_.set(COMPONENT);            \
38                 /* CC-OFFNXT(G.PRE.05) function gen */ \
39                 continue;                              \
40             }
41         LLVM_LOG_COMPONENTS(DEF)
42 #undef DEF
43 
44         UNREACHABLE();
45     }
46 }
47 // clang-format on
48 
49 }  // namespace ark::llvmbackend
50