forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RFC][RISCV] Support RISC-V Profiles in -march option
This PR implements the draft riscv-non-isa/riscv-toolchain-conventions#36. Currently, we replace specified profile in `-march` with standard arch string. We may need to pass it to backend so that we can emit an ELF attr proposed by riscv-non-isa/riscv-elf-psabi-doc#409.
- Loading branch information
Showing
7 changed files
with
271 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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,112 @@ | ||
// RUN: %clang -### -c %s 2>&1 -march=rvi20u32 | FileCheck -check-prefix=RVI20U32 %s | ||
// RVI20U32: "-target-cpu" "generic-rv32" | ||
// RVI20U32: "-target-feature" "-a" | ||
// RVI20U32: "-target-feature" "-c" | ||
// RVI20U32: "-target-feature" "-d" | ||
// RVI20U32: "-target-feature" "-f" | ||
// RVI20U32: "-target-feature" "-m" | ||
// RVI20U32: "-target-feature" "+rvi20u32" | ||
// RVI20U32: "-target-abi" "ilp32" | ||
|
||
// RUN: %clang -### -c %s 2>&1 -march=rvi20u64 | FileCheck -check-prefix=RVI20U64 %s | ||
// RVI20U64: "-target-cpu" "generic-rv64" | ||
// RVI20U64: "-target-feature" "-a" | ||
// RVI20U64: "-target-feature" "-c" | ||
// RVI20U64: "-target-feature" "-d" | ||
// RVI20U64: "-target-feature" "-f" | ||
// RVI20U64: "-target-feature" "-m" | ||
// RVI20U64: "-target-feature" "+rvi20u64" | ||
// RVI20U64: "-target-abi" "lp64" | ||
|
||
// RUN: %clang -### -c %s 2>&1 -march=rva20u64 | FileCheck -check-prefix=RVA20U64 %s | ||
// RVA20U64: "-target-cpu" "generic-rv64" | ||
// RVA20U64: "-target-feature" "+m" | ||
// RVA20U64: "-target-feature" "+a" | ||
// RVA20U64: "-target-feature" "+f" | ||
// RVA20U64: "-target-feature" "+d" | ||
// RVA20U64: "-target-feature" "+c" | ||
// RVA20U64: "-target-feature" "+zicsr" | ||
// RVA20U64: "-target-feature" "+rva20u64" | ||
// RVA20U64: "-target-abi" "lp64d" | ||
|
||
// RUN: %clang -### -c %s 2>&1 -march=rva20s64 | FileCheck -check-prefix=RVA20S64 %s | ||
// RVA20S64: "-target-cpu" "generic-rv64" | ||
// RVA20S64: "-target-feature" "+m" | ||
// RVA20S64: "-target-feature" "+a" | ||
// RVA20S64: "-target-feature" "+f" | ||
// RVA20S64: "-target-feature" "+d" | ||
// RVA20S64: "-target-feature" "+c" | ||
// RVA20S64: "-target-feature" "+zicsr" | ||
// RVA20S64: "-target-feature" "+zifencei" | ||
// RVA20S64: "-target-feature" "+rva20s64" | ||
// RVA20S64: "-target-abi" "lp64d" | ||
|
||
// RUN: %clang -### -c %s 2>&1 -march=rva22u64 | FileCheck -check-prefix=RVA22U64 %s | ||
// RVA22U64: "-target-cpu" "generic-rv64" | ||
// RVA22U64: "-target-feature" "+m" | ||
// RVA22U64: "-target-feature" "+a" | ||
// RVA22U64: "-target-feature" "+f" | ||
// RVA22U64: "-target-feature" "+d" | ||
// RVA22U64: "-target-feature" "+c" | ||
// RVA22U64: "-target-feature" "+zicbom" | ||
// RVA22U64: "-target-feature" "+zicbop" | ||
// RVA22U64: "-target-feature" "+zicboz" | ||
// RVA22U64: "-target-feature" "+zicsr" | ||
// RVA22U64: "-target-feature" "+zihintpause" | ||
// RVA22U64: "-target-feature" "+zfhmin" | ||
// RVA22U64: "-target-feature" "+zba" | ||
// RVA22U64: "-target-feature" "+zbb" | ||
// RVA22U64: "-target-feature" "+zbs" | ||
// RVA22U64: "-target-feature" "+zkt" | ||
// RVA22U64: "-target-feature" "+rva22u64" | ||
// RVA22U64: "-target-abi" "lp64d" | ||
|
||
// RUN: %clang -### -c %s 2>&1 -march=rva22s64 | FileCheck -check-prefix=RVA22S64 %s | ||
// RVA22S64: "-target-cpu" "generic-rv64" | ||
// RVA22S64: "-target-feature" "+m" | ||
// RVA22S64: "-target-feature" "+a" | ||
// RVA22S64: "-target-feature" "+f" | ||
// RVA22S64: "-target-feature" "+d" | ||
// RVA22S64: "-target-feature" "+c" | ||
// RVA22S64: "-target-feature" "+zicbom" | ||
// RVA22S64: "-target-feature" "+zicbop" | ||
// RVA22S64: "-target-feature" "+zicboz" | ||
// RVA22S64: "-target-feature" "+zicsr" | ||
// RVA22S64: "-target-feature" "+zifencei" | ||
// RVA22S64: "-target-feature" "+zihintpause" | ||
// RVA22S64: "-target-feature" "+zfhmin" | ||
// RVA22S64: "-target-feature" "+zba" | ||
// RVA22S64: "-target-feature" "+zbb" | ||
// RVA22S64: "-target-feature" "+zbs" | ||
// RVA22S64: "-target-feature" "+zkt" | ||
// RVA22S64: "-target-feature" "+svinval" | ||
// RVA22S64: "-target-feature" "+svpbmt" | ||
// RVA22S64: "-target-feature" "+rva22s64" | ||
// RVA22S64: "-target-abi" "lp64d" | ||
|
||
// RUN: %clang -### -c %s 2>&1 -march=rva22u64_zfa | FileCheck -check-prefix=PROFILE-WITH-ADDITIONAL %s | ||
// PROFILE-WITH-ADDITIONAL: "-target-cpu" "generic-rv64" | ||
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+m" | ||
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+a" | ||
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+f" | ||
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+d" | ||
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+c" | ||
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zicbom" | ||
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zicbop" | ||
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zicboz" | ||
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zicsr" | ||
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zihintpause" | ||
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zfa" | ||
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zfhmin" | ||
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zba" | ||
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zbb" | ||
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zbs" | ||
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zkt" | ||
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+rva22u64" | ||
// PROFILE-WITH-ADDITIONAL: "-target-abi" "lp64d" | ||
|
||
// RUN: not %clang -### -c %s 2>&1 -march=rva19u64_zfa | FileCheck -check-prefix=INVALID-PROFILE %s | ||
// INVALID-PROFILE: error: invalid arch name 'rva19u64_zfa', unsupported profile | ||
|
||
// RUN: not %clang -### -c %s 2>&1 -march=rva22u64zfa | FileCheck -check-prefix=INVALID-ADDITIONAL %s | ||
// INVALID-ADDITIONAL: error: invalid arch name 'rva22u64zfa', additional extensions must be after separator '_' |
This file contains 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 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 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 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,70 @@ | ||
//===------ RISCVProfiles.td - RISC-V Profiles -------------*- tablegen -*-===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
class RISCVProfile<string name, list<SubtargetFeature> features> | ||
: SubtargetFeature<name, "RISCVProfile", NAME, | ||
"RISC-V " # name # " profile", | ||
features>; | ||
|
||
def RVI20U32 : RISCVProfile<"rvi20u32", [Feature32Bit]>; | ||
|
||
def RVI20U64 : RISCVProfile<"rvi20u64", [Feature64Bit]>; | ||
|
||
def RVA20U64 : RISCVProfile<"rva20u64", [Feature64Bit, | ||
FeatureStdExtM, | ||
FeatureStdExtA, | ||
FeatureStdExtF, | ||
FeatureStdExtD, | ||
FeatureStdExtC, | ||
FeatureStdExtZicsr]>; | ||
|
||
def RVA20S64 : RISCVProfile<"rva20s64", [Feature64Bit, | ||
FeatureStdExtM, | ||
FeatureStdExtA, | ||
FeatureStdExtF, | ||
FeatureStdExtD, | ||
FeatureStdExtC, | ||
FeatureStdExtZicsr, | ||
FeatureStdExtZifencei]>; | ||
|
||
def RVA22U64 : RISCVProfile<"rva22u64", [Feature64Bit, | ||
FeatureStdExtM, | ||
FeatureStdExtA, | ||
FeatureStdExtF, | ||
FeatureStdExtD, | ||
FeatureStdExtC, | ||
FeatureStdExtZba, | ||
FeatureStdExtZbb, | ||
FeatureStdExtZbs, | ||
FeatureStdExtZfhmin, | ||
FeatureStdExtZicbom, | ||
FeatureStdExtZicbop, | ||
FeatureStdExtZicboz, | ||
FeatureStdExtZkt, | ||
FeatureStdExtZicsr, | ||
FeatureStdExtZihintpause]>; | ||
|
||
def RVA22S64 : RISCVProfile<"rva22s64", [Feature64Bit, | ||
FeatureStdExtM, | ||
FeatureStdExtA, | ||
FeatureStdExtF, | ||
FeatureStdExtD, | ||
FeatureStdExtC, | ||
FeatureStdExtZba, | ||
FeatureStdExtZbb, | ||
FeatureStdExtZbs, | ||
FeatureStdExtZfhmin, | ||
FeatureStdExtZicbom, | ||
FeatureStdExtZicbop, | ||
FeatureStdExtZicboz, | ||
FeatureStdExtZkt, | ||
FeatureStdExtZicsr, | ||
FeatureStdExtZifencei, | ||
FeatureStdExtZihintpause, | ||
FeatureStdExtSvpbmt, | ||
FeatureStdExtSvinval]>; |
This file contains 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 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