diff options
Diffstat (limited to 'clang/utils/TableGen')
-rw-r--r-- | clang/utils/TableGen/SveEmitter.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/clang/utils/TableGen/SveEmitter.cpp b/clang/utils/TableGen/SveEmitter.cpp index 553c7a3..b1e94e0 100644 --- a/clang/utils/TableGen/SveEmitter.cpp +++ b/clang/utils/TableGen/SveEmitter.cpp @@ -994,8 +994,29 @@ Intrinsic::Intrinsic(StringRef Name, StringRef Proto, uint64_t MergeTy, auto FormatGuard = [](StringRef Guard, StringRef Base) -> std::string { if (Guard.empty() || Guard == Base) return Guard.str(); - if (Guard.contains('|')) - return Base.str() + ",(" + Guard.str() + ")"; + + unsigned Depth = 0; + for (auto &C : Guard) { + switch (C) { + default: + break; + case '|': + if (Depth == 0) + // Group top-level ORs before ANDing with the base feature. + return Base.str() + ",(" + Guard.str() + ")"; + break; + case '(': + ++Depth; + break; + case ')': + if (Depth == 0) + llvm_unreachable("Mismatched parentheses!"); + + --Depth; + break; + } + } + return Base.str() + "," + Guard.str(); }; |