r338045 - [RISCV] Add support for interrupt attribute
Author: apazos Date: Thu Jul 26 10:37:45 2018 New Revision: 338045 URL: http://llvm.org/viewvc/llvm-project?rev=338045&view=rev Log: [RISCV] Add support for interrupt attribute Summary: Clang supports the GNU style ``__attribute__((interrupt))`` attribute on RISCV targets. Permissible values for this parameter are user, supervisor, and machine. If there is no parameter, then it defaults to machine. Reference: https://gcc.gnu.org/onlinedocs/gcc/RISC-V-Function-Attributes.html Based on initial patch by Zhaoshi Zheng. Reviewers: asb, aaron.ballman Reviewed By: asb, aaron.ballman Subscribers: rkruppe, the_o, aaron.ballman, MartinMosbeck, brucehoult, rbar, johnrusso, simoncook, sabuasal, niosHD, kito-cheng, shiva0217, zzheng, edward-jones, mgrang, rogfer01, cfe-commits Differential Revision: https://reviews.llvm.org/D48412 Added: cfe/trunk/test/Sema/riscv-interrupt-attr.c cfe/trunk/test/Sema/riscv-interrupt-attr.cpp Modified: cfe/trunk/include/clang/Basic/Attr.td cfe/trunk/include/clang/Basic/AttrDocs.td cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/CodeGen/TargetInfo.cpp cfe/trunk/lib/Sema/SemaDeclAttr.cpp Modified: cfe/trunk/include/clang/Basic/Attr.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=338045&r1=338044&r2=338045&view=diff == --- cfe/trunk/include/clang/Basic/Attr.td (original) +++ cfe/trunk/include/clang/Basic/Attr.td Thu Jul 26 10:37:45 2018 @@ -308,6 +308,7 @@ def TargetAVR : TargetArch<["avr"]>; def TargetMips32 : TargetArch<["mips", "mipsel"]>; def TargetAnyMips : TargetArch<["mips", "mipsel", "mips64", "mips64el"]>; def TargetMSP430 : TargetArch<["msp430"]>; +def TargetRISCV : TargetArch<["riscv32", "riscv64"]>; def TargetX86 : TargetArch<["x86"]>; def TargetAnyX86 : TargetArch<["x86", "x86_64"]>; def TargetWindows : TargetArch<["x86", "x86_64", "arm", "thumb", "aarch64"]> { @@ -1374,6 +1375,17 @@ def NoMicroMips : InheritableAttr, Targe let Documentation = [MicroMipsDocs]; } +def RISCVInterrupt : InheritableAttr, TargetSpecificAttr { + let Spellings = [GCC<"interrupt">]; + let Subjects = SubjectList<[Function]>; + let Args = [EnumArgument<"Interrupt", "InterruptType", + ["user", "supervisor", "machine"], + ["user", "supervisor", "machine"], + 1>]; + let ParseKind = "Interrupt"; + let Documentation = [RISCVInterruptDocs]; +} + // This is not a TargetSpecificAttr so that is silently accepted and // ignored on other targets as encouraged by the OpenCL spec. // Modified: cfe/trunk/include/clang/Basic/AttrDocs.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=338045&r1=338044&r2=338045&view=diff == --- cfe/trunk/include/clang/Basic/AttrDocs.td (original) +++ cfe/trunk/include/clang/Basic/AttrDocs.td Thu Jul 26 10:37:45 2018 @@ -1501,6 +1501,29 @@ as ``-mlong-calls`` and ``-mno-long-call }]; } +def RISCVInterruptDocs : Documentation { + let Category = DocCatFunction; + let Heading = "interrupt (RISCV)"; + let Content = [{ +Clang supports the GNU style ``__attribute__((interrupt))`` attribute on RISCV +targets. This attribute may be attached to a function definition and instructs +the backend to generate appropriate function entry/exit code so that it can be +used directly as an interrupt service routine. + +Permissible values for this parameter are ``user``, ``supervisor``, +and ``machine``. If there is no parameter, then it defaults to machine. + +Repeated interrupt attribute on the same declaration will cause a warning +to be emitted. In case of repeated declarations, the last one prevails. + +Refer to: +https://gcc.gnu.org/onlinedocs/gcc/RISC-V-Function-Attributes.html +https://riscv.org/specifications/privileged-isa/ +The RISC-V Instruction Set Manual Volume II: Privileged Architecture +Version 1.10. + }]; +} + def AVRInterruptDocs : Documentation { let Category = DocCatFunction; let Heading = "interrupt (AVR)"; Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=338045&r1=338044&r2=338045&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu Jul 26 10:37:45 2018 @@ -274,6 +274,14 @@ def warn_mips_interrupt_attribute : Warn "MIPS 'interrupt' attribute only applies to functions that have " "%select{no parameters|a 'void' return type}0">, InGroup; +def warn_riscv_repeated_interrupt_attribute : Warning< + "repeated RISC-V 'interrupt' attribute">, InGroup; +def note_riscv_repeated_interrupt_attribute : Note< + "
r354089 - Fixed failure on Darwin due to r354064
Author: apazos Date: Thu Feb 14 16:19:45 2019 New Revision: 354089 URL: http://llvm.org/viewvc/llvm-project?rev=354089&view=rev Log: Fixed failure on Darwin due to r354064 Summary: instrprof-darwin-exports.c test fails on Darwin due to r354064. Updated clang list of exported symbols to fix the issue. Reviewers: vsk Reviewed By: vsk Subscribers: davidxl, efriedma Differential Revision: https://reviews.llvm.org/D58259 Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=354089&r1=354088&r2=354089&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Thu Feb 14 16:19:45 2019 @@ -1048,7 +1048,6 @@ void Darwin::addProfileRTLibs(const ArgL addExportedSymbol(CmdArgs, "___llvm_profile_filename"); addExportedSymbol(CmdArgs, "___llvm_profile_raw_version"); addExportedSymbol(CmdArgs, "_lprofCurFilename"); - addExportedSymbol(CmdArgs, "_lprofMergeValueProfData"); } addExportedSymbol(CmdArgs, "_lprofDirMode"); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330880 - [RISCV] More validations on the input value of -march=
Author: apazos Date: Wed Apr 25 15:42:38 2018 New Revision: 330880 URL: http://llvm.org/viewvc/llvm-project?rev=330880&view=rev Log: [RISCV] More validations on the input value of -march= Supporting additional rules for parsing ISA string. - RISC-V ISA strings must be lowercase. E.g.: rv32IMC is not supported, rv32imc is correct. - Multi-letter extensions are to be separated by a single underscore '_'. The extension prefix counts as a letter. This means extensions that start with 's', 'sx' and 'sx' are all multi-letter. E.g.: xasb is a single non-standard extension named 'xasb' xa_sb are two extensions, the non-standard user level extension 'xa', and the supervisor level extension 'sb'. - Standard user-level extensions are specified following a canonical order, according to Table 22.1 in RISC-V User-Level ISA V2.2. - Non-standard user-level 'x' extensions, standard supervisor-level 's' extensions and non-standard supervisor-level 'sx' extensions are also specified following a canonical order according to Table 22.1 in RISC-V User-Level ISA V2.2: 'x' extensions, follwed by 's' extensions and then 'sx' extensions. - Extensions might have a version number. Underscores may be used to separate ISA subset components to improve readability and to provide disambiguation. E.g.: rv32i2_m3_a1_f2_d2 - Version numbers are divided into major and minor numbers, separated by a 'p'. If the minor version is 0, then 'p0' can be omitted. - Additional checks for dependent extensions and invalid extensions combinations. E.g.: 'e' requires rv32 'e' can't be combined with 'f' nor 'd' 'q' requires rv64 - TODO items have also been marked with comments in the code. Reviewers: asb, kito-cheng Reviewed By: asb Subscribers: edward-jones, mgrang, zzheng, rbar, johnrusso, simoncook, jordy.potman.lists, sabuasal, niosHD, shiva0217, cfe-commits Differential Revision: https://reviews.llvm.org/D45284 Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp cfe/trunk/test/Driver/riscv-arch.c Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=330880&r1=330879&r2=330880&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Wed Apr 25 15:42:38 2018 @@ -24,6 +24,10 @@ def err_drv_unknown_stdin_type_clang_cl def err_drv_unknown_language : Error<"language not recognized: '%0'">; def err_drv_invalid_arch_name : Error< "invalid arch name '%0'">; +def err_drv_invalid_riscv_arch_name : Error< + "invalid arch name '%0', %1">; +def err_drv_invalid_riscv_ext_arch_name : Error< + "invalid arch name '%0', %1 '%2'">; def err_drv_cuda_bad_gpu_arch : Error<"Unsupported CUDA gpu architecture: %0">; def err_drv_no_cuda_installation : Error< "cannot find CUDA installation. Provide its path via --cuda-path, or pass " Modified: cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp?rev=330880&r1=330879&r2=330880&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Arch/RISCV.cpp Wed Apr 25 15:42:38 2018 @@ -20,32 +20,232 @@ using namespace clang::driver::tools; using namespace clang; using namespace llvm::opt; +static StringRef getExtensionTypeDesc(StringRef Ext) { + if (Ext.startswith("sx")) +return "non-standard supervisor-level extension"; + if (Ext.startswith("s")) +return "standard supervisor-level extension"; + if (Ext.startswith("x")) +return "non-standard user-level extension"; + return StringRef(); +} + +static StringRef getExtensionType(StringRef Ext) { + if (Ext.startswith("sx")) +return "sx"; + if (Ext.startswith("s")) +return "s"; + if (Ext.startswith("x")) +return "x"; + return StringRef(); +} + +static bool isSupportedExtension(StringRef Ext) { + // LLVM does not support "sx", "s" nor "x" extensions. + return false; +} + +// Extensions may have a version number, and may be separated by +// an underscore '_' e.g.: rv32i2_m2. +// Version number is divided into major and minor version numbers, +// separated by a 'p'. If the minor version is 0 then 'p0' can be +// omitted from the version string. E.g., rv32i2p0, rv32i2, rv32i2p1. +static bool getExtensionVersion(const Driver &D, StringRef MArch, +StringRef Ext, StringRef In, +std::string &Major, std::string &Minor) { + auto I = In.begin(); + auto E = In.end(); + + while (I != E && isdigit(*I)) +Major.append(1, *I++); + + if (Major.empty()) +return true; + + if (I != E && *I == 'p') { +++I; + +while (I
[clang] [llvm] [RISCV] Add back SiFive's cdiscard.d.l1 and cflush.d.l1 instructions. (PR #83896)
apazos wrote: @topperc , how about the CEASE instruction? Can you add it in this patch? https://github.com/llvm/llvm-project/pull/83896 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Add back SiFive's cdiscard.d.l1 and cflush.d.l1 instructions. (PR #83896)
apazos wrote: Also, @topperc, we should add the new extensions to the list of vendor extensions in the specs: ttps://github.com/riscv-non-isa/riscv-toolchain-conventions/tree/master?tab=readme-ov-file#list-of-vendor-extensions https://github.com/llvm/llvm-project/pull/83896 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r322769 - [RISCV] Propagate -mabi and -march values to GNU assembler.
Author: apazos Date: Wed Jan 17 14:09:58 2018 New Revision: 322769 URL: http://llvm.org/viewvc/llvm-project?rev=322769&view=rev Log: [RISCV] Propagate -mabi and -march values to GNU assembler. When using -fno-integrated-as flag, the gnu assembler produces code with some default march/mabi which later causes linker failure due to incompatible mabi/march. In this patch we explicitly propagate -mabi and -march flags to the GNU assembler. In this patch we explicitly propagate -mabi and -march flags to the GNU assembler. Differential Revision: https://reviews.llvm.org/D41271 Added: cfe/trunk/test/Driver/Inputs/multilib_riscv_linux_sdk/riscv64-unknown-linux-gnu/bin/as cfe/trunk/test/Driver/riscv-gnutools.c Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=322769&r1=322768&r2=322769&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Wed Jan 17 14:09:58 2018 @@ -629,6 +629,18 @@ void tools::gnutools::Assembler::Constru ppc::getPPCAsmModeForCPU(getCPUName(Args, getToolChain().getTriple(; break; } + case llvm::Triple::riscv32: + case llvm::Triple::riscv64: { +StringRef ABIName = riscv::getRISCVABI(Args, getToolChain().getTriple()); +CmdArgs.push_back("-mabi"); +CmdArgs.push_back(ABIName.data()); +if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) { + StringRef MArch = A->getValue(); + CmdArgs.push_back("-march"); + CmdArgs.push_back(MArch.data()); +} +break; + } case llvm::Triple::sparc: case llvm::Triple::sparcel: { CmdArgs.push_back("-32"); Added: cfe/trunk/test/Driver/Inputs/multilib_riscv_linux_sdk/riscv64-unknown-linux-gnu/bin/as URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/multilib_riscv_linux_sdk/riscv64-unknown-linux-gnu/bin/as?rev=322769&view=auto == --- cfe/trunk/test/Driver/Inputs/multilib_riscv_linux_sdk/riscv64-unknown-linux-gnu/bin/as (added) +++ cfe/trunk/test/Driver/Inputs/multilib_riscv_linux_sdk/riscv64-unknown-linux-gnu/bin/as Wed Jan 17 14:09:58 2018 @@ -0,0 +1 @@ +#!/bin/true Added: cfe/trunk/test/Driver/riscv-gnutools.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv-gnutools.c?rev=322769&view=auto == --- cfe/trunk/test/Driver/riscv-gnutools.c (added) +++ cfe/trunk/test/Driver/riscv-gnutools.c Wed Jan 17 14:09:58 2018 @@ -0,0 +1,14 @@ +// Check gnutools are invoked with propagated values for -mabi and -march. + +// RUN: %clang -target riscv32-linux-unknown-elf -fno-integrated-as \ +// RUN: --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \ +// RUN: --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot %s -### \ +// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP32 %s +// RUN: %clang -target riscv32-linux-unknown-elf -fno-integrated-as \ +// RUN: -march=rv32g --gcc-toolchain=%S/Inputs/multilib_riscv_linux_sdk \ +// RUN: --sysroot=%S/Inputs/multilib_riscv_linux_sdk/sysroot %s -### \ +// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP32-MARCH-G %s + +// MABI-ILP32: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/../../../../riscv64-unknown-linux-gnu/bin{{/|}}as" "-mabi" "ilp32" +// MABI-ILP32-MARCH-G: "{{.*}}/Inputs/multilib_riscv_linux_sdk/lib/gcc/riscv64-unknown-linux-gnu/7.2.0/../../../../riscv64-unknown-linux-gnu/bin{{/|}}as" "-mabi" "ilp32" "-march" "rv32g" + ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r323894 - Revert "Revert rC322769: [RISCV] Propagate -mabi and -march values to GNU assembler."
Author: apazos Date: Wed Jan 31 10:11:09 2018 New Revision: 323894 URL: http://llvm.org/viewvc/llvm-project?rev=323894&view=rev Log: Revert "Revert rC322769: [RISCV] Propagate -mabi and -march values to GNU assembler." Summary: Bringing back the code change and simplified test cases to test 32/64 bit targets. Reviewers: asb, yroux, inouehrs, mgrang Reviewed By: yroux, inouehrs Subscribers: cfe-commits, rbar, johnrusso, simoncook, jordy.potman.lists, sabuasal, niosHD Differential Revision: https://reviews.llvm.org/D42666 Added: cfe/trunk/test/Driver/riscv-gnutools.c Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=323894&r1=323893&r2=323894&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Wed Jan 31 10:11:09 2018 @@ -629,6 +629,18 @@ void tools::gnutools::Assembler::Constru ppc::getPPCAsmModeForCPU(getCPUName(Args, getToolChain().getTriple(; break; } + case llvm::Triple::riscv32: + case llvm::Triple::riscv64: { +StringRef ABIName = riscv::getRISCVABI(Args, getToolChain().getTriple()); +CmdArgs.push_back("-mabi"); +CmdArgs.push_back(ABIName.data()); +if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) { + StringRef MArch = A->getValue(); + CmdArgs.push_back("-march"); + CmdArgs.push_back(MArch.data()); +} +break; + } case llvm::Triple::sparc: case llvm::Triple::sparcel: { CmdArgs.push_back("-32"); Added: cfe/trunk/test/Driver/riscv-gnutools.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/riscv-gnutools.c?rev=323894&view=auto == --- cfe/trunk/test/Driver/riscv-gnutools.c (added) +++ cfe/trunk/test/Driver/riscv-gnutools.c Wed Jan 31 10:11:09 2018 @@ -0,0 +1,19 @@ +// Check gnutools are invoked with propagated values for -mabi and -march. + +// RUN: %clang -target riscv32 -fno-integrated-as %s -### -c \ +// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP32 %s + +// RUN: %clang -target riscv32 -fno-integrated-as -march=rv32g %s -### -c \ +// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP32-MARCH-G %s + +// RUN: %clang -target riscv64 -fno-integrated-as %s -### -c \ +// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP64 %s + +// RUN: %clang -target riscv64 -fno-integrated-as -march=rv64g %s -### -c \ +// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP64-MARCH-G %s + +// MABI-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" +// MABI-ILP32-MARCH-G: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32g" + +// MABI-ILP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" +// MABI-ILP64-MARCH-G: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64g" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [RISCV] Allow `Zicsr`/`Zifencei` to duplicate with `g` (PR #136842)
apazos wrote: This matter was addressed at the RVI Toolchain SIG meeting on 05/08/25. It was concluded that the duplication of implied extensions, such as in the cases of G and Zifencei, and F and Zicsr, can be silently disregarded. Both GCC and LLVM toolchains are consistent with this approach through the application of this LLVM patch. However, the duplication of unrelated extensions should result in an error message indicating an invalid duplicated extension, which is already implemented in both toolchains. https://github.com/llvm/llvm-project/pull/136842 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits