[clang] [llvm] [RISCV] Add MC layer support for XSfmm*. (PR #133031)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 17 11:09:41 PDT 2025
================
@@ -2302,6 +2316,81 @@ bool RISCVAsmParser::generateVTypeError(SMLoc ErrorLoc) {
"e[8|16|32|64],m[1|2|4|8|f2|f4|f8],[ta|tu],[ma|mu]");
}
+bool RISCVAsmParser::parseXSfmmVTypeToken(const AsmToken &Tok, WWEEState &State,
+ unsigned &WW, unsigned &EE,
+ bool &AltFmt) {
+ if (getLexer().isNot(AsmToken::Identifier))
+ return true;
+
+ StringRef Identifier = getTok().getIdentifier();
+
+ switch (State) {
+ case WWEEState_SEW:
+ if (!Identifier.consume_front("e"))
+ break;
+ if (Identifier.getAsInteger(10, EE)) {
+ if (Identifier != "16alt")
+ break;
+
+ AltFmt = true;
+ EE = 16;
+ }
+ if (!RISCVVType::isValidSEW(EE))
+ break;
+ State = WWEEState_Widen;
+ return false;
+ case WWEEState_Widen:
+ if (!Identifier.consume_front("w"))
+ break;
+ if (Identifier.getAsInteger(10, WW))
+ break;
+ if (WW != 1 && WW != 2 && WW != 4)
+ break;
+ State = WWEEState_Done;
+ return false;
+ case WWEEState_Done:
+ // Extra token?
+ break;
+ }
+
+ return true;
+}
+
+ParseStatus RISCVAsmParser::parseXSfmmVType(OperandVector &Operands) {
+ SMLoc S = getLoc();
+
+ unsigned Widen = 0;
+ unsigned SEW = 0;
+ bool AltFmt = false;
+
+ WWEEState State = WWEEState_SEW;
----------------
preames wrote:
It's not really clear to me that the state mechanism is worthwhile over just inlining the two calls and specializing the switch. The state machine is exceedingly simple, and the extra helper may actually just confuse things.
https://github.com/llvm/llvm-project/pull/133031
More information about the llvm-commits
mailing list