Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[RISCV] Add support for -mcpu option.
Summary: 1. gcc uses `-march` and `-mtune` flag to chose arch and pipeline model, but clang does not have `-mtune` flag, we uses `-mcpu` to chose both infos. 2. Add SiFive e31 and u54 cpu which have default march and pipeline model. 3. Specific `-mcpu` with rocket-rv[32|64] would select pipeline model only, and use the driver's arch choosing logic to get default arch. Reviewers: lenary, asb, evandro, HsiangKai Reviewed By: lenary, asb, evandro Tags: #llvm, #clang Differential Revision: https://reviews.llvm.org/D71124 (cherry picked from commit 294d1ea)
- Loading branch information
Showing
11 changed files
with
262 additions
and
34 deletions.
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
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
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,38 @@ | ||
// Check target CPUs are correctly passed. | ||
|
||
// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=rocket-rv32 | FileCheck -check-prefix=MCPU-ROCKETCHIP32 %s | ||
// MCPU-ROCKETCHIP32: "-nostdsysteminc" "-target-cpu" "rocket-rv32" | ||
|
||
// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=rocket-rv64 | FileCheck -check-prefix=MCPU-ROCKETCHIP64 %s | ||
// MCPU-ROCKETCHIP64: "-nostdsysteminc" "-target-cpu" "rocket-rv64" | ||
// MCPU-ROCKETCHIP64: "-target-feature" "+64bit" | ||
|
||
// mcpu with default march | ||
// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-u54 | FileCheck -check-prefix=MCPU-SIFIVE-U54 %s | ||
// MCPU-SIFIVE-U54: "-nostdsysteminc" "-target-cpu" "sifive-u54" | ||
// MCPU-SIFIVE-U54: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d" | ||
// MCPU-SIFIVE-U54: "-target-feature" "+c" "-target-feature" "+64bit" | ||
// MCPU-SIFIVE-U54: "-target-abi" "lp64d" | ||
|
||
// mcpu with mabi option | ||
// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-u54 -mabi=lp64 | FileCheck -check-prefix=MCPU-ABI-SIFIVE-U54 %s | ||
// MCPU-ABI-SIFIVE-U54: "-nostdsysteminc" "-target-cpu" "sifive-u54" | ||
// MCPU-ABI-SIFIVE-U54: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d" | ||
// MCPU-ABI-SIFIVE-U54: "-target-feature" "+c" "-target-feature" "+64bit" | ||
// MCPU-ABI-SIFIVE-U54: "-target-abi" "lp64" | ||
|
||
// march overwirte mcpu's default march | ||
// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=sifive-e31 -march=rv32imc | FileCheck -check-prefix=MCPU-MARCH %s | ||
// MCPU-MARCH: "-nostdsysteminc" "-target-cpu" "sifive-e31" "-target-feature" "+m" "-target-feature" "+c" | ||
// MCPU-MARCH: "-target-abi" "ilp32" | ||
|
||
// Check failed cases | ||
|
||
// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=generic-rv321 | FileCheck -check-prefix=FAIL-MCPU-NAME %s | ||
// FAIL-MCPU-NAME: error: the clang compiler does not support '-mcpu=generic-rv321' | ||
|
||
// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=generic-rv32 -march=rv64i | FileCheck -check-prefix=MISMATCH-ARCH %s | ||
// MISMATCH-ARCH: error: the clang compiler does not support '-mcpu=generic-rv32' | ||
|
||
// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=generic-rv64 | FileCheck -check-prefix=MISMATCH-MCPU %s | ||
// MISMATCH-MCPU: error: the clang compiler does not support '-mcpu=generic-rv64' |
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,13 @@ | ||
#ifndef PROC | ||
#define PROC(ENUM, NAME, FEATURES, DEFAULT_MARCH) | ||
#endif | ||
|
||
PROC(INVALID, {"invalid"}, FK_INVALID, {""}) | ||
PROC(GENERIC_RV32, {"generic-rv32"}, FK_NONE, {""}) | ||
PROC(GENERIC_RV64, {"generic-rv64"}, FK_64BIT, {""}) | ||
PROC(ROCKET_RV32, {"rocket-rv32"}, FK_NONE, {""}) | ||
PROC(ROCKET_RV64, {"rocket-rv64"}, FK_64BIT, {""}) | ||
PROC(SIFIVE_E31, {"sifive-e31"}, FK_NONE, {"rv32imac"}) | ||
PROC(SIFIVE_U54, {"sifive-u54"}, FK_64BIT, {"rv64gc"}) | ||
|
||
#undef PROC |
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
Oops, something went wrong.