[llvm] [LLVM][IR] Add textual shorthand for specifying constant vector splats. (PR #74620)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 7 06:19:18 PST 2023
================
@@ -3981,6 +3981,33 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
return false;
}
+ case lltok::kw_splat: {
+ Lex.Lex();
+ if (parseToken(lltok::lparen, "expected '(' after vector splat"))
+ return true;
+ Constant *C;
+ if (parseGlobalTypeAndValue(C))
+ return true;
+ if (parseToken(lltok::rparen, "expected ')' at end of vector splat"))
+ return true;
+
+ if (auto *CI = dyn_cast<ConstantInt>(C)) {
+ ID.APSIntVal = CI->getValue();
+ ID.Kind = ValID::t_APSInt;
+ return false;
+ }
+
+ if (auto *CFP = dyn_cast<ConstantFP>(C)) {
+ ID.APFloatVal = CFP->getValue();
+ ID.Kind = ValID::t_APFloat;
+ return false;
+ }
+
+ ID.ConstantVal = C;
+ ID.Kind = ValID::t_Constant;
----------------
nikic wrote:
I would expect the `ConstantVector::getSplat()` call to occur here, rather than in the t_Constant branch. If it's done there, I think it might hide vector vs scalar mismatches?
https://github.com/llvm/llvm-project/pull/74620
More information about the llvm-commits
mailing list