Skip to content

Commit 0727e7a

Browse files
4vtomattopperc
andauthored
[RISCV] Support Zvfbfa codegen (#161158)
- [RISCV][llvm] Support Zvfbfa codegen and vsetvli insertion - [RISCV][clang] Support Zvfbfa C intrinsics The original PR is split into 2 PRs, this is codegen PR and other is here: #164094 Co-authored-by: Craig Topper <craig.topper@sifive.com>
1 parent 035f811 commit 0727e7a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+21835
-2
lines changed

llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -699,7 +699,8 @@ class VSETVLIInfo {
699699
"Can't encode VTYPE for uninitialized or unknown");
700700
if (TWiden != 0)
701701
return RISCVVType::encodeXSfmmVType(SEW, TWiden, AltFmt);
702-
return RISCVVType::encodeVTYPE(VLMul, SEW, TailAgnostic, MaskAgnostic);
702+
return RISCVVType::encodeVTYPE(VLMul, SEW, TailAgnostic, MaskAgnostic,
703+
AltFmt);
703704
}
704705

705706
bool hasSEWLMULRatioOnly() const { return SEWLMULRatioOnly; }

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3775,11 +3775,13 @@ std::string RISCVInstrInfo::createMIROperandComment(
37753775

37763776
#define CASE_VFMA_OPCODE_VV(OP) \
37773777
CASE_VFMA_OPCODE_LMULS_MF4(OP, VV, E16): \
3778+
case CASE_VFMA_OPCODE_LMULS_MF4(OP##_ALT, VV, E16): \
37783779
case CASE_VFMA_OPCODE_LMULS_MF2(OP, VV, E32): \
37793780
case CASE_VFMA_OPCODE_LMULS_M1(OP, VV, E64)
37803781

37813782
#define CASE_VFMA_SPLATS(OP) \
37823783
CASE_VFMA_OPCODE_LMULS_MF4(OP, VFPR16, E16): \
3784+
case CASE_VFMA_OPCODE_LMULS_MF4(OP##_ALT, VFPR16, E16): \
37833785
case CASE_VFMA_OPCODE_LMULS_MF2(OP, VFPR32, E32): \
37843786
case CASE_VFMA_OPCODE_LMULS_M1(OP, VFPR64, E64)
37853787
// clang-format on
@@ -4003,11 +4005,13 @@ bool RISCVInstrInfo::findCommutedOpIndices(const MachineInstr &MI,
40034005

40044006
#define CASE_VFMA_CHANGE_OPCODE_VV(OLDOP, NEWOP) \
40054007
CASE_VFMA_CHANGE_OPCODE_LMULS_MF4(OLDOP, NEWOP, VV, E16) \
4008+
CASE_VFMA_CHANGE_OPCODE_LMULS_MF4(OLDOP##_ALT, NEWOP##_ALT, VV, E16) \
40064009
CASE_VFMA_CHANGE_OPCODE_LMULS_MF2(OLDOP, NEWOP, VV, E32) \
40074010
CASE_VFMA_CHANGE_OPCODE_LMULS_M1(OLDOP, NEWOP, VV, E64)
40084011

40094012
#define CASE_VFMA_CHANGE_OPCODE_SPLATS(OLDOP, NEWOP) \
40104013
CASE_VFMA_CHANGE_OPCODE_LMULS_MF4(OLDOP, NEWOP, VFPR16, E16) \
4014+
CASE_VFMA_CHANGE_OPCODE_LMULS_MF4(OLDOP##_ALT, NEWOP##_ALT, VFPR16, E16) \
40114015
CASE_VFMA_CHANGE_OPCODE_LMULS_MF2(OLDOP, NEWOP, VFPR32, E32) \
40124016
CASE_VFMA_CHANGE_OPCODE_LMULS_M1(OLDOP, NEWOP, VFPR64, E64)
40134017
// clang-format on
@@ -4469,6 +4473,20 @@ bool RISCVInstrInfo::simplifyInstruction(MachineInstr &MI) const {
44694473
CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, M2, E32) \
44704474
CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, M4, E16) \
44714475
CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, M4, E32) \
4476+
4477+
#define CASE_FP_WIDEOP_OPCODE_LMULS_ALT(OP) \
4478+
CASE_FP_WIDEOP_OPCODE_COMMON(OP, MF4, E16): \
4479+
case CASE_FP_WIDEOP_OPCODE_COMMON(OP, MF2, E16): \
4480+
case CASE_FP_WIDEOP_OPCODE_COMMON(OP, M1, E16): \
4481+
case CASE_FP_WIDEOP_OPCODE_COMMON(OP, M2, E16): \
4482+
case CASE_FP_WIDEOP_OPCODE_COMMON(OP, M4, E16)
4483+
4484+
#define CASE_FP_WIDEOP_CHANGE_OPCODE_LMULS_ALT(OP) \
4485+
CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, MF4, E16) \
4486+
CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, MF2, E16) \
4487+
CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, M1, E16) \
4488+
CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, M2, E16) \
4489+
CASE_FP_WIDEOP_CHANGE_OPCODE_COMMON(OP, M4, E16)
44724490
// clang-format on
44734491

44744492
MachineInstr *RISCVInstrInfo::convertToThreeAddress(MachineInstr &MI,
@@ -4478,6 +4496,8 @@ MachineInstr *RISCVInstrInfo::convertToThreeAddress(MachineInstr &MI,
44784496
switch (MI.getOpcode()) {
44794497
default:
44804498
return nullptr;
4499+
case CASE_FP_WIDEOP_OPCODE_LMULS_ALT(FWADD_ALT_WV):
4500+
case CASE_FP_WIDEOP_OPCODE_LMULS_ALT(FWSUB_ALT_WV):
44814501
case CASE_FP_WIDEOP_OPCODE_LMULS(FWADD_WV):
44824502
case CASE_FP_WIDEOP_OPCODE_LMULS(FWSUB_WV): {
44834503
assert(RISCVII::hasVecPolicyOp(MI.getDesc().TSFlags) &&
@@ -4494,6 +4514,8 @@ MachineInstr *RISCVInstrInfo::convertToThreeAddress(MachineInstr &MI,
44944514
llvm_unreachable("Unexpected opcode");
44954515
CASE_FP_WIDEOP_CHANGE_OPCODE_LMULS(FWADD_WV)
44964516
CASE_FP_WIDEOP_CHANGE_OPCODE_LMULS(FWSUB_WV)
4517+
CASE_FP_WIDEOP_CHANGE_OPCODE_LMULS_ALT(FWADD_ALT_WV)
4518+
CASE_FP_WIDEOP_CHANGE_OPCODE_LMULS_ALT(FWSUB_ALT_WV)
44974519
}
44984520
// clang-format on
44994521

0 commit comments

Comments
 (0)