1 // Check target CPUs are correctly passed. 2 3 // RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=rocket-rv32 | FileCheck -check-prefix=MCPU-ROCKET32 %s 4 // MCPU-ROCKET32: "-nostdsysteminc" "-target-cpu" "rocket-rv32" 5 6 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=rocket-rv64 | FileCheck -check-prefix=MCPU-ROCKET64 %s 7 // MCPU-ROCKET64: "-nostdsysteminc" "-target-cpu" "rocket-rv64" 8 // MCPU-ROCKET64: "-target-feature" "+64bit" 9 10 // RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=sifive-7-rv32 | FileCheck -check-prefix=MCPU-SIFIVE7-32 %s 11 // MCPU-SIFIVE7-32: "-nostdsysteminc" "-target-cpu" "sifive-7-rv32" 12 13 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-7-rv64 | FileCheck -check-prefix=MCPU-SIFIVE7-64 %s 14 // MCPU-SIFIVE7-64: "-nostdsysteminc" "-target-cpu" "sifive-7-rv64" 15 // MCPU-SIFIVE7-64: "-target-feature" "+64bit" 16 17 // RUN: %clang -target riscv32 -### -c %s 2>&1 -mtune=rocket-rv32 | FileCheck -check-prefix=MTUNE-ROCKET32 %s 18 // MTUNE-ROCKET32: "-tune-cpu" "rocket-rv32" 19 20 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mtune=rocket-rv64 | FileCheck -check-prefix=MTUNE-ROCKET64 %s 21 // MTUNE-ROCKET64: "-tune-cpu" "rocket-rv64" 22 23 // RUN: %clang -target riscv32 -### -c %s 2>&1 -mtune=sifive-7-rv32 | FileCheck -check-prefix=MTUNE-SIFIVE7-32 %s 24 // MTUNE-SIFIVE7-32: "-tune-cpu" "sifive-7-rv32" 25 26 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mtune=sifive-7-rv64 | FileCheck -check-prefix=MTUNE-SIFIVE7-64 %s 27 // MTUNE-SIFIVE7-64: "-tune-cpu" "sifive-7-rv64" 28 29 // Check mtune alias CPU has resolved to the right CPU according XLEN. 30 // RUN: %clang -target riscv32 -### -c %s 2>&1 -mtune=generic | FileCheck -check-prefix=MTUNE-GENERIC-32 %s 31 // MTUNE-GENERIC-32: "-tune-cpu" "generic-rv32" 32 33 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mtune=generic | FileCheck -check-prefix=MTUNE-GENERIC-64 %s 34 // MTUNE-GENERIC-64: "-tune-cpu" "generic-rv64" 35 36 // RUN: %clang -target riscv32 -### -c %s 2>&1 -mtune=rocket | FileCheck -check-prefix=MTUNE-ROCKET-32 %s 37 // MTUNE-ROCKET-32: "-tune-cpu" "rocket-rv32" 38 39 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mtune=rocket | FileCheck -check-prefix=MTUNE-ROCKET-64 %s 40 // MTUNE-ROCKET-64: "-tune-cpu" "rocket-rv64" 41 42 // RUN: %clang -target riscv32 -### -c %s 2>&1 -mtune=sifive-7-series | FileCheck -check-prefix=MTUNE-SIFIVE7-SERIES-32 %s 43 // MTUNE-SIFIVE7-SERIES-32: "-tune-cpu" "sifive-7-rv32" 44 45 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mtune=sifive-7-series | FileCheck -check-prefix=MTUNE-SIFIVE7-SERIES-64 %s 46 // MTUNE-SIFIVE7-SERIES-64: "-tune-cpu" "sifive-7-rv64" 47 48 // mcpu with default march 49 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-u54 | FileCheck -check-prefix=MCPU-SIFIVE-U54 %s 50 // MCPU-SIFIVE-U54: "-nostdsysteminc" "-target-cpu" "sifive-u54" 51 // MCPU-SIFIVE-U54: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d" 52 // MCPU-SIFIVE-U54: "-target-feature" "+c" "-target-feature" "+64bit" 53 // MCPU-SIFIVE-U54: "-target-abi" "lp64d" 54 55 // mcpu with mabi option 56 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-u54 -mabi=lp64 | FileCheck -check-prefix=MCPU-ABI-SIFIVE-U54 %s 57 // MCPU-ABI-SIFIVE-U54: "-nostdsysteminc" "-target-cpu" "sifive-u54" 58 // MCPU-ABI-SIFIVE-U54: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d" 59 // MCPU-ABI-SIFIVE-U54: "-target-feature" "+c" "-target-feature" "+64bit" 60 // MCPU-ABI-SIFIVE-U54: "-target-abi" "lp64" 61 62 // mcpu with default march 63 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-e76 | FileCheck -check-prefix=MCPU-SIFIVE-E76 %s 64 // MCPU-SIFIVE-E76: "-nostdsysteminc" "-target-cpu" "sifive-e76" 65 // MCPU-SIFIVE-E76: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" 66 // MCPU-SIFIVE-E76: "-target-feature" "+c" 67 // MCPU-SIFIVE-E76: "-target-abi" "ilp32" 68 69 // mcpu with mabi option 70 // RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=sifive-u74 -mabi=lp64 | FileCheck -check-prefix=MCPU-ABI-SIFIVE-U74 %s 71 // MCPU-ABI-SIFIVE-U74: "-nostdsysteminc" "-target-cpu" "sifive-u74" 72 // MCPU-ABI-SIFIVE-U74: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d" 73 // MCPU-ABI-SIFIVE-U74: "-target-feature" "+c" "-target-feature" "+64bit" 74 // MCPU-ABI-SIFIVE-U74: "-target-abi" "lp64" 75 76 // march overwrite mcpu's default march 77 // RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=sifive-e31 -march=rv32imc | FileCheck -check-prefix=MCPU-MARCH %s 78 // MCPU-MARCH: "-nostdsysteminc" "-target-cpu" "sifive-e31" "-target-feature" "+m" "-target-feature" "+c" 79 // MCPU-MARCH: "-target-abi" "ilp32" 80 81 // Check interaction between mcpu and mtune, mtune won't affect arch related 82 // target feature, but mcpu will. 83 // 84 // In this case, sifive-e31 is rv32imac, sifive-e76 is rv32imafc, so M-extension 85 // should not enabled. 86 // 87 // RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=sifive-e31 -mtune=sifive-e76 | FileCheck -check-prefix=MTUNE-E31-MCPU-E76 %s 88 // MTUNE-E31-MCPU-E76: "-target-cpu" "sifive-e31" 89 // MTUNE-E31-MCPU-E76-NOT: "-target-feature" "+f" 90 // MTUNE-E31-MCPU-E76-SAME: "-target-feature" "+m" 91 // MTUNE-E31-MCPU-E76-SAME: "-target-feature" "+a" 92 // MTUNE-E31-MCPU-E76-SAME: "-target-feature" "+c" 93 // MTUNE-E31-MCPU-E76-SAME: "-tune-cpu" "sifive-e76" 94 95 // Check failed cases 96 97 // RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=generic-rv321 | FileCheck -check-prefix=FAIL-MCPU-NAME %s 98 // FAIL-MCPU-NAME: error: the clang compiler does not support '-mcpu=generic-rv321' 99 100 // RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=generic-rv32 -march=rv64i | FileCheck -check-prefix=MISMATCH-ARCH %s 101 // MISMATCH-ARCH: error: the clang compiler does not support '-mcpu=generic-rv32' 102 103 // RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=generic-rv64 | FileCheck -check-prefix=MISMATCH-MCPU %s 104 // MISMATCH-MCPU: error: the clang compiler does not support '-mcpu=generic-rv64' 105