[llvm] [TLI] Make VecDesc statically initializable (PR #211307)
Valery Chernov via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 4 05:34:40 PDT 2026
================
@@ -48,23 +48,28 @@ class VecDesc {
ElementCount VectorizationFactor;
bool Masked;
StringRef VABIPrefix;
- std::optional<CallingConv::ID> CC;
+ CallingConv::ID CC;
public:
VecDesc() = delete;
- VecDesc(StringRef ScalarFnName, StringRef VectorFnName,
- ElementCount VectorizationFactor, bool Masked, StringRef VABIPrefix,
- std::optional<CallingConv::ID> Conv)
+ constexpr VecDesc(StringRef ScalarFnName, StringRef VectorFnName,
+ ElementCount VectorizationFactor, bool Masked,
+ StringRef VABIPrefix,
+ std::optional<CallingConv::ID> Conv = std::nullopt)
: ScalarFnName(ScalarFnName), VectorFnName(VectorFnName),
VectorizationFactor(VectorizationFactor), Masked(Masked),
- VABIPrefix(VABIPrefix), CC(Conv) {}
+ VABIPrefix(VABIPrefix), CC(Conv.value_or(CallingConv::C)) {}
----------------
vvchernov wrote:
Thank you guys for tips! I've updated to 0 / CC+1 encoding so an explicit C calling convention remains representable, and added a unit test for it
> Can you mark the tables constinit to prevent regressions?
LLVM is still on C++17, so we can't use the constinit keyword yet
https://github.com/llvm/llvm-project/pull/211307
More information about the llvm-commits
mailing list