[llvm] [LLVM][IR] Add textual shorthand for specifying constant vector splats. (PR #74620)
Paul Walker via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 8 02:51:51 PST 2023
================
@@ -3981,6 +3981,21 @@ 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;
+
+ ID.ConstantVal = C;
+ ID.Kind = ValID::t_ConstantSplat;
----------------
paulwalker-arm wrote:
We don’t have the target type at this point in the parsing (NOTE `ExpectedTy` defaults to `nullptr` and is only used in one part of `parseValID`). ConstantExprs can be constructed based on their input operands, with only their final result type needing to be validated within `convertValIDToValue`.
The reason for not reusing `t_Constant` is to maintain the accuracy of the diagnostics.
https://github.com/llvm/llvm-project/pull/74620
More information about the llvm-commits
mailing list