-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[RISCV] Add MC layer support for XSfmm*. #133031
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
bb123ff
[RISCV] Add MC layer support for XSfmm*.
topperc d308dba
fixup! add tests I forgot
topperc 7ebe32c
fixup! Update riscv-target-features-sifive.
topperc b36e65b
fixup! Remove getXSfmmAltFmt which duplicates isAltFmt.
topperc 3ed4141
Merge remote-tracking branch 'origin/main' into pr/xsfmm
topperc dab4832
Merge remote-tracking branch 'origin/main' into pr/xsfmm
topperc 0497985
fixup! remove Xsfmm32a4i and Xsfmm32a.
topperc 4656703
fixup! Address review comments
topperc 268e0c7
fixup! XSfmm64a64f depends on Zve64d.
topperc 89ba8c1
Merge remote-tracking branch 'origin/main' into pr/xsfmm
topperc b40f01f
Merge remote-tracking branch 'origin/main' into pr/xsfmm
topperc 87468b8
fixup! Improve invalid vtype tests
topperc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// RUN: %clang --target=riscv32 \ | ||
// RUN: -march=rv32i_zve32x_xsfmm128t -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM128T %s | ||
// RUN: %clang --target=riscv64 \ | ||
// RUN: -march=rv64i_zve32x_xsfmm128t -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM128T %s | ||
// CHECK-XSFMM128T: __riscv_xsfmm128t 6000{{$}} | ||
// | ||
// RUN: %clang --target=riscv32 \ | ||
// RUN: -march=rv32i_zve32x_xsfmm16t -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM16T %s | ||
// RUN: %clang --target=riscv64 \ | ||
// RUN: -march=rv64i_zve32x_xsfmm16t -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM16T %s | ||
// CHECK-XSFMM16T: __riscv_xsfmm16t 6000{{$}} | ||
|
||
// RUN: %clang --target=riscv32 \ | ||
// RUN: -march=rv32i_zve32x_xsfmm32a8i -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM32a8I %s | ||
// RUN: %clang --target=riscv64 \ | ||
// RUN: -march=rv64i_zve32x_xsfmm32a8i -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM32a8I %s | ||
// CHECK-XSFMM32a8I: __riscv_xsfmm32a8i 6000{{$}} | ||
|
||
// RUN: %clang --target=riscv32 \ | ||
// RUN: -march=rv32i_zve32x_xsfmm32a8f -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM32A8F %s | ||
// RUN: %clang --target=riscv64 \ | ||
// RUN: -march=rv64i_zve32x_xsfmm32a8f -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM32A8F %s | ||
// CHECK-XSFMM32A8F: __riscv_xsfmm32a8f 6000{{$}} | ||
|
||
// RUN: %clang --target=riscv32 \ | ||
// RUN: -march=rv32i_zve32x_xsfmm32a16f -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM32a16F %s | ||
// RUN: %clang --target=riscv64 \ | ||
// RUN: -march=rv64i_zve32x_xsfmm32a16f -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM32a16F %s | ||
// CHECK-XSFMM32a16F: __riscv_xsfmm32a16f 6000{{$}} | ||
|
||
// RUN: %clang --target=riscv32 \ | ||
// RUN: -march=rv32i_zve32x_xsfmm32a32f -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM32a32F %s | ||
// RUN: %clang --target=riscv64 \ | ||
// RUN: -march=rv64i_zve32x_xsfmm32a32f -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM32a32F %s | ||
// CHECK-XSFMM32a32F: __riscv_xsfmm32a32f 6000{{$}} | ||
|
||
// RUN: %clang --target=riscv32 \ | ||
// RUN: -march=rv32i_zve32x_xsfmm32t -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM32T %s | ||
// RUN: %clang --target=riscv64 \ | ||
// RUN: -march=rv64i_zve32x_xsfmm32t -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM32T %s | ||
// CHECK-XSFMM32T: __riscv_xsfmm32t 6000{{$}} | ||
|
||
// RUN: %clang --target=riscv32 \ | ||
// RUN: -march=rv32i_zve32x_xsfmm64a64f -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM64a64f %s | ||
// RUN: %clang --target=riscv64 \ | ||
// RUN: -march=rv64i_zve32x_xsfmm64a64f -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM64a64f %s | ||
// CHECK-XSFMM64a64f: __riscv_xsfmm64a64f 6000{{$}} | ||
|
||
// RUN: %clang --target=riscv32 \ | ||
// RUN: -march=rv32i_zve32x_xsfmm64t -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM64T %s | ||
// RUN: %clang --target=riscv64 \ | ||
// RUN: -march=rv64i_zve32x_xsfmm64t -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMM64T %s | ||
// CHECK-XSFMM64T: __riscv_xsfmm64t 6000{{$}} | ||
|
||
// RUN: %clang --target=riscv32 \ | ||
// RUN: -march=rv32i_zve32x_xsfmmbase -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMMBASE %s | ||
// RUN: %clang --target=riscv64 \ | ||
// RUN: -march=rv64i_zve32x_xsfmmbase -E -dM %s \ | ||
// RUN: -o - | FileCheck --check-prefix=CHECK-XSFMMBASE %s | ||
// CHECK-XSFMMBASE: __riscv_xsfmmbase 6000{{$}} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,6 +77,12 @@ class RISCVAsmParser : public MCTargetAsmParser { | |
VTypeState_Done, | ||
}; | ||
|
||
enum WWEEState { | ||
WWEEState_Widen, | ||
WWEEState_SEW, | ||
WWEEState_Done, | ||
}; | ||
|
||
SmallVector<FeatureBitset, 4> FeatureBitStack; | ||
|
||
SmallVector<ParserOptionsSet, 4> ParserOptionsStack; | ||
|
@@ -125,6 +131,9 @@ class RISCVAsmParser : public MCTargetAsmParser { | |
bool &MaskAgnostic); | ||
bool generateVTypeError(SMLoc ErrorLoc); | ||
|
||
bool parseXSfmmVTypeToken(const AsmToken &Tok, WWEEState &State, unsigned &WW, | ||
unsigned &EE, bool &AltFmt); | ||
bool generateXSfmmVTypeError(SMLoc ErrorLoc); | ||
// Helper to actually emit an instruction to the MCStreamer. Also, when | ||
// possible, compression of the instruction is performed. | ||
void emitToStreamer(MCStreamer &S, const MCInst &Inst); | ||
|
@@ -222,6 +231,7 @@ class RISCVAsmParser : public MCTargetAsmParser { | |
} | ||
|
||
ParseStatus parseRegReg(OperandVector &Operands); | ||
ParseStatus parseXSfmmVType(OperandVector &Operands); | ||
ParseStatus parseRetval(OperandVector &Operands); | ||
ParseStatus parseZcmpStackAdj(OperandVector &Operands, | ||
bool ExpectNegative = false); | ||
|
@@ -635,6 +645,10 @@ struct RISCVOperand final : public MCParsedAsmOperand { | |
return isUImm<11>(); | ||
} | ||
|
||
bool isXSfmmVType() const { | ||
return Kind == KindTy::VType && RISCVVType::isValidXSfmmVType(VType.Val); | ||
} | ||
|
||
/// Return true if the operand is a valid for the fence instruction e.g. | ||
/// ('iorw'). | ||
bool isFenceArg() const { return Kind == KindTy::Fence; } | ||
|
@@ -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; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. |
||
|
||
if (parseXSfmmVTypeToken(getTok(), State, Widen, SEW, AltFmt)) | ||
return generateXSfmmVTypeError(S); | ||
|
||
getLexer().Lex(); | ||
|
||
if (!parseOptionalToken(AsmToken::Comma)) | ||
return generateXSfmmVTypeError(S); | ||
|
||
if (parseXSfmmVTypeToken(getTok(), State, Widen, SEW, AltFmt)) | ||
return generateXSfmmVTypeError(S); | ||
|
||
getLexer().Lex(); | ||
|
||
if (getLexer().is(AsmToken::EndOfStatement) && State == WWEEState_Done) { | ||
Operands.push_back(RISCVOperand::createVType( | ||
RISCVVType::encodeXSfmmVType(SEW, Widen, AltFmt), S)); | ||
return ParseStatus::Success; | ||
} | ||
|
||
return generateXSfmmVTypeError(S); | ||
} | ||
|
||
bool RISCVAsmParser::generateXSfmmVTypeError(SMLoc ErrorLoc) { | ||
return Error(ErrorLoc, "operand must be e[8|16|16alt|32|64],w[1|2|4]"); | ||
} | ||
|
||
ParseStatus RISCVAsmParser::parseMaskReg(OperandVector &Operands) { | ||
if (getLexer().isNot(AsmToken::Identifier)) | ||
return ParseStatus::NoMatch; | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.