Index: llvm/docs/RISCVUsage.rst =================================================================== --- llvm/docs/RISCVUsage.rst +++ llvm/docs/RISCVUsage.rst @@ -73,9 +73,11 @@ ``Zicbom`` Assembly Support ``Zicbop`` Assembly Support ``Zicboz`` Assembly Support + ``Zicntr`` (`See Note <#riscv-i2p1-note>`__) ``Zicsr`` (`See Note <#riscv-i2p1-note>`__) ``Zifencei`` (`See Note <#riscv-i2p1-note>`__) ``Zihintpause`` Assembly Support + ``Zihpm`` (`See Note <#riscv-i2p1-note>`__) ``Zkn`` Supported ``Zknd`` Supported (`See note <#riscv-scalar-crypto-note2>`__) ``Zkne`` Supported (`See note <#riscv-scalar-crypto-note2>`__) @@ -129,8 +131,8 @@ .. _riscv-i2p1-note: -``zicsr``, ``zifencei`` - Between versions 2.0 and 2.1 of the base I specification, a backwards incompatible change was made to remove selected instructions and CSRs from the base ISA. These instructions were grouped into a set of new extensions, but were no longer required by the base ISA. This change is described in "Preface to Document Version 20190608-Base-Ratified" from the specification document. LLVM currently implements version 2.0 of the base specification. Thus, instructions from these extensions are accepted as part of the base ISA. LLVM also allows the explicit specification of the extensions in an march string. +``zicnt``, ``zicsr``, ``zifencei``, ``zihpm`` + Between versions 2.0 and 2.1 of the base I specification, a backwards incompatible change was made to remove selected instructions and CSRs from the base ISA. These instructions were grouped into a set of new extensions, but were no longer required by the base ISA. This change is partially described in "Preface to Document Version 20190608-Base-Ratified" from the specification document (the ``zicntr`` and ``zihpm`` bits are not mentioned). LLVM currently implements version 2.0 of the base specification. Thus, instructions from these extensions are accepted as part of the base ISA. LLVM also allows the explicit specification of the extensions in an march string. Experimental Extensions ======================= Index: llvm/lib/Support/RISCVISAInfo.cpp =================================================================== --- llvm/lib/Support/RISCVISAInfo.cpp +++ llvm/lib/Support/RISCVISAInfo.cpp @@ -103,8 +103,10 @@ {"zicbom", RISCVExtensionVersion{1, 0}}, {"zicboz", RISCVExtensionVersion{1, 0}}, {"zicbop", RISCVExtensionVersion{1, 0}}, + {"zicntr", RISCVExtensionVersion{1, 0}}, {"zicsr", RISCVExtensionVersion{2, 0}}, {"zifencei", RISCVExtensionVersion{2, 0}}, + {"zihpm", RISCVExtensionVersion{1, 0}}, {"svnapot", RISCVExtensionVersion{1, 0}}, {"svpbmt", RISCVExtensionVersion{1, 0}}, Index: llvm/lib/Target/RISCV/RISCVFeatures.td =================================================================== --- llvm/lib/Target/RISCV/RISCVFeatures.td +++ llvm/lib/Target/RISCV/RISCVFeatures.td @@ -85,6 +85,20 @@ AssemblerPredicate<(all_of FeatureStdExtZifencei), "'Zifencei' (fence.i)">; +def FeatureStdExtZicntr + : SubtargetFeature<"zicntr", "HasStdExtZicntr", "true", + "'zicntr' (Base Counters and Timers)">; +def HasStdExtZicntr : Predicate<"Subtarget->hasStdExtZicntr()">, + AssemblerPredicate<(all_of FeatureStdExtZicntr), + "'Zicntr' (Base Counters and Timers)">; + +def FeatureStdExtZihpm + : SubtargetFeature<"zihpm", "HasStdExtZihpm", "true", + "'zihpm' (Hardware Performance Counters)">; +def HasStdExtZihpm : Predicate<"Subtarget->hasStdExtZihpm()">, + AssemblerPredicate<(all_of FeatureStdExtZihpm), + "'Zihpm' (Hardware Performance Counters)">; + def FeatureStdExtZfhmin : SubtargetFeature<"zfhmin", "HasStdExtZfhmin", "true", "'Zfhmin' (Half-Precision Floating-Point Minimal)", Index: llvm/test/CodeGen/RISCV/attributes.ll =================================================================== --- llvm/test/CodeGen/RISCV/attributes.ll +++ llvm/test/CodeGen/RISCV/attributes.ll @@ -48,6 +48,8 @@ ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcf %s -o - | FileCheck --check-prefixes=CHECK,RV32ZCF %s ; RUN: llc -mtriple=riscv32 -mattr=+zicsr %s -o - | FileCheck --check-prefixes=CHECK,RV32ZICSR %s ; RUN: llc -mtriple=riscv32 -mattr=+zifencei %s -o - | FileCheck --check-prefixes=CHECK,RV32ZIFENCEI %s +; RUN: llc -mtriple=riscv32 -mattr=+zicntr %s -o - | FileCheck --check-prefixes=CHECK,RV32ZICNTR %s +; RUN: llc -mtriple=riscv32 -mattr=+zihpm %s -o - | FileCheck --check-prefixes=CHECK,RV32ZIHPM %s ; RUN: llc -mtriple=riscv64 %s -o - | FileCheck %s ; RUN: llc -mtriple=riscv64 -mattr=+m %s -o - | FileCheck --check-prefixes=CHECK,RV64M %s @@ -103,6 +105,8 @@ ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zcd %s -o - | FileCheck --check-prefixes=CHECK,RV64ZCD %s ; RUN: llc -mtriple=riscv64 -mattr=+zicsr %s -o - | FileCheck --check-prefixes=CHECK,RV64ZICSR %s ; RUN: llc -mtriple=riscv64 -mattr=+zifencei %s -o - | FileCheck --check-prefixes=CHECK,RV64ZIFENCEI %s +; RUN: llc -mtriple=riscv64 -mattr=+zicntr %s -o - | FileCheck --check-prefixes=CHECK,RV64ZICNTR %s +; RUN: llc -mtriple=riscv64 -mattr=+zihpm %s -o - | FileCheck --check-prefixes=CHECK,RV64ZIHPM %s ; CHECK: .attribute 4, 16 @@ -153,6 +157,8 @@ ; RV32ZCF: .attribute 5, "rv32i2p0_zcf1p0" ; RV32ZICSR: .attribute 5, "rv32i2p0_zicsr2p0" ; RV32ZIFENCEI: .attribute 5, "rv32i2p0_zifencei2p0" +; RV32ZICNTR: .attribute 5, "rv32i2p0_zicntr1p0" +; RV32ZIHPM: .attribute 5, "rv32i2p0_zihpm1p0" ; RV64M: .attribute 5, "rv64i2p0_m2p0" ; RV64ZMMUL: .attribute 5, "rv64i2p0_zmmul1p0" @@ -207,6 +213,8 @@ ; RV64ZCD: .attribute 5, "rv64i2p0_zcd1p0" ; RV64ZICSR: .attribute 5, "rv64i2p0_zicsr2p0" ; RV64ZIFENCEI: .attribute 5, "rv64i2p0_zifencei2p0" +; RV64ZICNTR: .attribute 5, "rv64i2p0_zicntr1p0" +; RV64ZIHPM: .attribute 5, "rv64i2p0_zihpm1p0" define i32 @addi(i32 %a) { %1 = add i32 %a, 1 Index: llvm/test/MC/RISCV/attribute-arch.s =================================================================== --- llvm/test/MC/RISCV/attribute-arch.s +++ llvm/test/MC/RISCV/attribute-arch.s @@ -199,3 +199,9 @@ .attribute arch, "rv32izifencei2p0" # CHECK: attribute 5, "rv32i2p0_zifencei2p0" + +.attribute arch, "rv32izicntr1p0" +# CHECK: attribute 5, "rv32i2p0_zicntr1p0" + +.attribute arch, "rv32izihpm1p0" +# CHECK: attribute 5, "rv32i2p0_zihpm1p0"