diff --git a/clang/test/Preprocessor/riscv-target-features.c b/clang/test/Preprocessor/riscv-target-features.c --- a/clang/test/Preprocessor/riscv-target-features.c +++ b/clang/test/Preprocessor/riscv-target-features.c @@ -45,6 +45,7 @@ // CHECK-NOT: __riscv_zk // CHECK-NOT: __riscv_zicbom // CHECK-NOT: __riscv_zicboz +// CHECK-NOT: __riscv_zcf // RUN: %clang -target riscv32-unknown-linux-gnu -march=rv32im -x c -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-M-EXT %s @@ -470,3 +471,7 @@ // RUN: -march=rv64iztso0p1 -x c -E -dM %s \ // RUN: -o - | FileCheck --check-prefix=CHECK-ZTSO-EXT %s // CHECK-ZTSO-EXT: __riscv_ztso 1000{{$}} + +// RUN: %clang -target riscv32 -march=rv32izcf0p70 -menable-experimental-extensions \ +// RUN: -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-ZCF-EXT %s +// CHECK-ZCF-EXT: __riscv_zcf 70000{{$}} diff --git a/llvm/lib/Support/RISCVISAInfo.cpp b/llvm/lib/Support/RISCVISAInfo.cpp --- a/llvm/lib/Support/RISCVISAInfo.cpp +++ b/llvm/lib/Support/RISCVISAInfo.cpp @@ -113,6 +113,7 @@ {"zbr", RISCVExtensionVersion{0, 93}}, {"zbt", RISCVExtensionVersion{0, 93}}, {"zca", RISCVExtensionVersion{0, 70}}, + {"zcf", RISCVExtensionVersion{0, 70}}, {"zvfh", RISCVExtensionVersion{0, 1}}, {"ztso", RISCVExtensionVersion{0, 1}}, }; diff --git a/llvm/lib/Target/RISCV/RISCV.td b/llvm/lib/Target/RISCV/RISCV.td --- a/llvm/lib/Target/RISCV/RISCV.td +++ b/llvm/lib/Target/RISCV/RISCV.td @@ -360,6 +360,19 @@ "'C' (Compressed Instructions) or " "'Zca' (part of the C extension, excluding compressed floating point loads/stores)">; +def FeatureExtZcf + : SubtargetFeature<"experimental-zcf", "HasStdExtZcf", "true", + "'Zcf' (Compressed Single-Precision Floating-Point Instructions)">; +def HasStdExtZcf : Predicate<"Subtarget->hasStdExtZcf()">, + AssemblerPredicate<(all_of FeatureExtZcf), + "'Zcf' (Compressed Single-Precision Floating-Point Instructions)">; + +def HasStdExtCOrZcf + : Predicate<"Subtarget->hasStdExtC() || Subtarget->hasStdExtZcf()">, + AssemblerPredicate<(any_of FeatureStdExtC, FeatureExtZcf), + "'C' (Compressed Instructions) or " + "'Zcf' (Compressed Single-Precision Floating-Point Instructions)">; + def FeatureNoRVCHints : SubtargetFeature<"no-rvc-hints", "EnableRVCHintInstrs", "false", "Disable RVC Hint Instructions.">; diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfoC.td b/llvm/lib/Target/RISCV/RISCVInstrInfoC.td --- a/llvm/lib/Target/RISCV/RISCVInstrInfoC.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfoC.td @@ -328,7 +328,7 @@ } let DecoderNamespace = "RISCV32Only_", - Predicates = [HasStdExtC, HasStdExtF, IsRV32] in + Predicates = [HasStdExtCOrZcf, HasStdExtF, IsRV32] in def C_FLW : CLoad_ri<0b011, "c.flw", FPR32C, uimm7_lsb00>, Sched<[WriteFLD32, ReadMemBase]> { bits<7> imm; @@ -362,7 +362,7 @@ } let DecoderNamespace = "RISCV32Only_", - Predicates = [HasStdExtC, HasStdExtF, IsRV32] in + Predicates = [HasStdExtCOrZcf, HasStdExtF, IsRV32] in def C_FSW : CStore_rri<0b111, "c.fsw", FPR32C, uimm7_lsb00>, Sched<[WriteFST32, ReadStoreData, ReadMemBase]> { bits<7> imm; @@ -515,7 +515,7 @@ } let DecoderNamespace = "RISCV32Only_", - Predicates = [HasStdExtC, HasStdExtF, IsRV32] in + Predicates = [HasStdExtCOrZcf, HasStdExtF, IsRV32] in def C_FLWSP : CStackLoad<0b011, "c.flwsp", FPR32, uimm8_lsb00>, Sched<[WriteFLD32, ReadMemBase]> { let Inst{6-4} = imm{4-2}; @@ -575,7 +575,7 @@ } let DecoderNamespace = "RISCV32Only_", - Predicates = [HasStdExtC, HasStdExtF, IsRV32] in + Predicates = [HasStdExtCOrZcf, HasStdExtF, IsRV32] in def C_FSWSP : CStackStore<0b111, "c.fswsp", FPR32, uimm8_lsb00>, Sched<[WriteFST32, ReadStoreData, ReadMemBase]> { let Inst{12-9} = imm{5-2}; @@ -733,7 +733,7 @@ def : InstAlias<"c.sdsp $rs2, (${rs1})", (C_SDSP GPRC:$rs2, SP:$rs1, 0)>; } -let Predicates = [HasStdExtC, HasStdExtF, IsRV32] in { +let Predicates = [HasStdExtCOrZcf, HasStdExtF, IsRV32] in { def : InstAlias<"c.flw $rd, (${rs1})", (C_FLW FPR32C:$rd, GPRC:$rs1, 0)>; def : InstAlias<"c.fsw $rs2, (${rs1})", (C_FSW FPR32C:$rs2, GPRC:$rs1, 0)>; def : InstAlias<"c.flwsp $rd, (${rs1})", (C_FLWSP FPR32C:$rd, SP:$rs1, 0)>; @@ -771,7 +771,7 @@ (C_LW GPRC:$rd, GPRC:$rs1, uimm7_lsb00:$imm)>; } // Predicates = [HasStdExtC] -let Predicates = [HasStdExtC, HasStdExtF, IsRV32] in { +let Predicates = [HasStdExtCOrZcf, HasStdExtF, IsRV32] in { def : CompressPat<(FLW FPR32C:$rd, GPRC:$rs1, uimm7_lsb00:$imm), (C_FLW FPR32C:$rd, GPRC:$rs1, uimm7_lsb00:$imm)>; } // Predicates = [HasStdExtC, HasStdExtF, IsRV32] @@ -791,10 +791,10 @@ (C_SW GPRC:$rs2, GPRC:$rs1, uimm7_lsb00:$imm)>; } // Predicates = [HasStdExtC] -let Predicates = [HasStdExtC, HasStdExtF, IsRV32] in { +let Predicates = [HasStdExtCOrZcf, HasStdExtF, IsRV32] in { def : CompressPat<(FSW FPR32C:$rs2, GPRC:$rs1, uimm7_lsb00:$imm), (C_FSW FPR32C:$rs2, GPRC:$rs1, uimm7_lsb00:$imm)>; -} // Predicates = [HasStdExtC, HasStdExtF, IsRV32] +} // Predicates = [HasStdExtCOrZcf, HasStdExtF, IsRV32] let Predicates = [HasStdExtC, IsRV64] in { def : CompressPat<(SD GPRC:$rs2, GPRC:$rs1, uimm8_lsb000:$imm), @@ -888,10 +888,10 @@ (C_LWSP GPRNoX0:$rd, SP:$rs1, uimm8_lsb00:$imm)>; } // Predicates = [HasStdExtC] -let Predicates = [HasStdExtC, HasStdExtF, IsRV32] in { +let Predicates = [HasStdExtCOrZcf, HasStdExtF, IsRV32] in { def : CompressPat<(FLW FPR32:$rd, SP:$rs1, uimm8_lsb00:$imm), (C_FLWSP FPR32:$rd, SP:$rs1, uimm8_lsb00:$imm)>; -} // Predicates = [HasStdExtC, HasStdExtF, IsRV32] +} // Predicates = [HasStdExtCOrZcf, HasStdExtF, IsRV32] let Predicates = [HasStdExtC, IsRV64] in { def : CompressPat<(LD GPRNoX0:$rd, SP:$rs1, uimm9_lsb000:$imm), @@ -930,10 +930,10 @@ (C_SWSP GPR:$rs2, SP:$rs1, uimm8_lsb00:$imm)>; } // Predicates = [HasStdExtC] -let Predicates = [HasStdExtC, HasStdExtF, IsRV32] in { +let Predicates = [HasStdExtCOrZcf, HasStdExtF, IsRV32] in { def : CompressPat<(FSW FPR32:$rs2, SP:$rs1, uimm8_lsb00:$imm), (C_FSWSP FPR32:$rs2, SP:$rs1, uimm8_lsb00:$imm)>; -} // Predicates = [HasStdExtC, HasStdExtF, IsRV32] +} // Predicates = [HasStdExtCOrZcf, HasStdExtF, IsRV32] let Predicates = [HasStdExtC, IsRV64] in { def : CompressPat<(SD GPR:$rs2, SP:$rs1, uimm9_lsb000:$imm), diff --git a/llvm/lib/Target/RISCV/RISCVSubtarget.h b/llvm/lib/Target/RISCV/RISCVSubtarget.h --- a/llvm/lib/Target/RISCV/RISCVSubtarget.h +++ b/llvm/lib/Target/RISCV/RISCVSubtarget.h @@ -62,6 +62,7 @@ bool HasStdExtZbs = false; bool HasStdExtZbt = false; bool HasStdExtZca = false; + bool HasStdExtZcf = false; bool HasStdExtV = false; bool HasStdExtZve32x = false; bool HasStdExtZve32f = false; @@ -172,6 +173,7 @@ bool hasStdExtZbs() const { return HasStdExtZbs; } bool hasStdExtZbt() const { return HasStdExtZbt; } bool hasStdExtZca() const { return HasStdExtZca; } + bool hasStdExtZcf() const { return HasStdExtZcf; } bool hasStdExtZvl() const { return ZvlLen != 0; } bool hasStdExtZvfh() const { return HasStdExtZvfh; } bool hasStdExtZfhmin() const { return HasStdExtZfhmin; } diff --git a/llvm/test/MC/RISCV/rv32fc-valid.s b/llvm/test/MC/RISCV/rv32fc-valid.s --- a/llvm/test/MC/RISCV/rv32fc-valid.s +++ b/llvm/test/MC/RISCV/rv32fc-valid.s @@ -19,25 +19,25 @@ # CHECK-ASM-AND-OBJ: c.flwsp fs0, 252(sp) # CHECK-ASM: encoding: [0x7e,0x74] # CHECK-NO-EXT-F: error: instruction requires the following: 'F' (Single-Precision Floating-Point){{$}} -# CHECK-NO-EXT-FC: error: instruction requires the following: 'C' (Compressed Instructions), 'F' (Single-Precision Floating-Point){{$}} +# CHECK-NO-EXT-FC: error: instruction requires the following: 'C' (Compressed Instructions) or 'Zcf' (Compressed Single-Precision Floating-Point Instructions), 'F' (Single-Precision Floating-Point){{$}} # CHECK-NO-RV32: error: instruction requires the following: RV32I Base Instruction Set{{$}} c.flwsp fs0, 252(sp) # CHECK-ASM-AND-OBJ: c.fswsp fa7, 252(sp) # CHECK-ASM: encoding: [0xc6,0xff] # CHECK-NO-EXT-F: error: instruction requires the following: 'F' (Single-Precision Floating-Point){{$}} -# CHECK-NO-EXT-FC: error: instruction requires the following: 'C' (Compressed Instructions), 'F' (Single-Precision Floating-Point){{$}} +# CHECK-NO-EXT-FC: error: instruction requires the following: 'C' (Compressed Instructions) or 'Zcf' (Compressed Single-Precision Floating-Point Instructions), 'F' (Single-Precision Floating-Point){{$}} # CHECK-NO-RV32: error: instruction requires the following: RV32I Base Instruction Set{{$}} c.fswsp fa7, 252(sp) # CHECK-ASM-AND-OBJ: c.flw fa3, 124(a5) # CHECK-ASM: encoding: [0xf4,0x7f] # CHECK-NO-EXT-F: error: instruction requires the following: 'F' (Single-Precision Floating-Point){{$}} -# CHECK-NO-EXT-FC: error: instruction requires the following: 'C' (Compressed Instructions), 'F' (Single-Precision Floating-Point){{$}} +# CHECK-NO-EXT-FC: error: instruction requires the following: 'C' (Compressed Instructions) or 'Zcf' (Compressed Single-Precision Floating-Point Instructions), 'F' (Single-Precision Floating-Point){{$}} # CHECK-NO-RV32: error: instruction requires the following: RV32I Base Instruction Set{{$}} c.flw fa3, 124(a5) # CHECK-ASM-AND-OBJ: c.fsw fa2, 124(a1) # CHECK-ASM: encoding: [0xf0,0xfd] # CHECK-NO-EXT-F: error: instruction requires the following: 'F' (Single-Precision Floating-Point){{$}} -# CHECK-NO-EXT-FC: error: instruction requires the following: 'C' (Compressed Instructions), 'F' (Single-Precision Floating-Point){{$}} +# CHECK-NO-EXT-FC: error: instruction requires the following: 'C' (Compressed Instructions) or 'Zcf' (Compressed Single-Precision Floating-Point Instructions), 'F' (Single-Precision Floating-Point){{$}} # CHECK-NO-RV32: error: instruction requires the following: RV32I Base Instruction Set{{$}} c.fsw fa2, 124(a1)