1 // Check target CPUs are correctly passed.
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"
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"
10 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=rocket-rv32 | FileCheck -check-prefix=MTUNE-ROCKET32 %s
11 // MTUNE-ROCKET32: "-tune-cpu" "rocket-rv32"
13 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=rocket-rv64 | FileCheck -check-prefix=MTUNE-ROCKET64 %s
14 // MTUNE-ROCKET64: "-tune-cpu" "rocket-rv64"
16 // Check mtune alias CPU has resolved to the right CPU according XLEN.
17 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=generic | FileCheck -check-prefix=MTUNE-GENERIC-32 %s
18 // MTUNE-GENERIC-32: "-tune-cpu" "generic"
20 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=generic | FileCheck -check-prefix=MTUNE-GENERIC-64 %s
21 // MTUNE-GENERIC-64: "-tune-cpu" "generic"
23 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=rocket | FileCheck -check-prefix=MTUNE-ROCKET-32 %s
24 // MTUNE-ROCKET-32: "-tune-cpu" "rocket"
26 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=rocket | FileCheck -check-prefix=MTUNE-ROCKET-64 %s
27 // MTUNE-ROCKET-64: "-tune-cpu" "rocket"
29 // mcpu with default march
30 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=sifive-e20 | FileCheck -check-prefix=MCPU-SIFIVE-E20 %s
31 // MCPU-SIFIVE-E20: "-nostdsysteminc" "-target-cpu" "sifive-e20"
32 // MCPU-SIFIVE-E20: "-target-feature" "+m" "-target-feature" "+c"
33 // MCPU-SIFIVE-E20: "-target-abi" "ilp32"
35 // mcpu with default march
36 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=sifive-e21 | FileCheck -check-prefix=MCPU-SIFIVE-E21 %s
37 // MCPU-SIFIVE-E21: "-nostdsysteminc" "-target-cpu" "sifive-e21"
38 // MCPU-SIFIVE-E21: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+c"
39 // MCPU-SIFIVE-E21: "-target-abi" "ilp32"
41 // mcpu with default march
42 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=sifive-e24 | FileCheck -check-prefix=MCPU-SIFIVE-E24 %s
43 // MCPU-SIFIVE-E24: "-nostdsysteminc" "-target-cpu" "sifive-e24"
44 // MCPU-SIFIVE-E24: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f"
45 // MCPU-SIFIVE-E24: "-target-feature" "+c"
46 // MCPU-SIFIVE-E24: "-target-abi" "ilp32"
48 // mcpu with default march
49 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=sifive-e34 | FileCheck -check-prefix=MCPU-SIFIVE-E34 %s
50 // MCPU-SIFIVE-E34: "-nostdsysteminc" "-target-cpu" "sifive-e34"
51 // MCPU-SIFIVE-E34: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f"
52 // MCPU-SIFIVE-E34: "-target-feature" "+c"
53 // MCPU-SIFIVE-E34: "-target-abi" "ilp32"
55 // mcpu with mabi option
56 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=sifive-s21 -mabi=lp64 | FileCheck -check-prefix=MCPU-ABI-SIFIVE-S21 %s
57 // MCPU-ABI-SIFIVE-S21: "-nostdsysteminc" "-target-cpu" "sifive-s21"
58 // MCPU-ABI-SIFIVE-S21: "-target-feature" "+m" "-target-feature" "+a"
59 // MCPU-ABI-SIFIVE-S21: "-target-feature" "+c" "-target-feature" "+64bit"
60 // MCPU-ABI-SIFIVE-S21: "-target-abi" "lp64"
62 // mcpu with mabi option
63 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=sifive-s51 -mabi=lp64 | FileCheck -check-prefix=MCPU-ABI-SIFIVE-S51 %s
64 // MCPU-ABI-SIFIVE-S51: "-nostdsysteminc" "-target-cpu" "sifive-s51"
65 // MCPU-ABI-SIFIVE-S51: "-target-feature" "+m" "-target-feature" "+a"
66 // MCPU-ABI-SIFIVE-S51: "-target-feature" "+c" "-target-feature" "+64bit"
67 // MCPU-ABI-SIFIVE-S51: "-target-abi" "lp64"
69 // mcpu with default march
70 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=sifive-s54 | FileCheck -check-prefix=MCPU-SIFIVE-S54 %s
71 // MCPU-SIFIVE-S54: "-nostdsysteminc" "-target-cpu" "sifive-s54"
72 // MCPU-SIFIVE-S54: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d"
73 // MCPU-SIFIVE-S54: "-target-feature" "+c" "-target-feature" "+64bit"
74 // MCPU-SIFIVE-S54: "-target-abi" "lp64d"
76 // mcpu with mabi option
77 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=sifive-s76 | FileCheck -check-prefix=MCPU-SIFIVE-S76 %s
78 // MCPU-SIFIVE-S76: "-nostdsysteminc" "-target-cpu" "sifive-s76"
79 // MCPU-SIFIVE-S76: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d"
80 // MCPU-SIFIVE-S76: "-target-feature" "+c" "-target-feature" "+64bit"
81 // MCPU-SIFIVE-S76: "-target-abi" "lp64d"
83 // mcpu with default march
84 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=sifive-u54 | FileCheck -check-prefix=MCPU-SIFIVE-U54 %s
85 // MCPU-SIFIVE-U54: "-nostdsysteminc" "-target-cpu" "sifive-u54"
86 // MCPU-SIFIVE-U54: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d"
87 // MCPU-SIFIVE-U54: "-target-feature" "+c" "-target-feature" "+64bit"
88 // MCPU-SIFIVE-U54: "-target-abi" "lp64d"
90 // mcpu with mabi option
91 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=sifive-u54 -mabi=lp64 | FileCheck -check-prefix=MCPU-ABI-SIFIVE-U54 %s
92 // MCPU-ABI-SIFIVE-U54: "-nostdsysteminc" "-target-cpu" "sifive-u54"
93 // MCPU-ABI-SIFIVE-U54: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d"
94 // MCPU-ABI-SIFIVE-U54: "-target-feature" "+c" "-target-feature" "+64bit"
95 // MCPU-ABI-SIFIVE-U54: "-target-abi" "lp64"
97 // mcpu with default march
98 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=sifive-e76 | FileCheck -check-prefix=MCPU-SIFIVE-E76 %s
99 // MCPU-SIFIVE-E76: "-nostdsysteminc" "-target-cpu" "sifive-e76"
100 // MCPU-SIFIVE-E76: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f"
101 // MCPU-SIFIVE-E76: "-target-feature" "+c"
102 // MCPU-SIFIVE-E76: "-target-abi" "ilp32"
104 // mcpu with mabi option
105 // RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=sifive-u74 -mabi=lp64 | FileCheck -check-prefix=MCPU-ABI-SIFIVE-U74 %s
106 // MCPU-ABI-SIFIVE-U74: "-nostdsysteminc" "-target-cpu" "sifive-u74"
107 // MCPU-ABI-SIFIVE-U74: "-target-feature" "+m" "-target-feature" "+a" "-target-feature" "+f" "-target-feature" "+d"
108 // MCPU-ABI-SIFIVE-U74: "-target-feature" "+c" "-target-feature" "+64bit"
109 // MCPU-ABI-SIFIVE-U74: "-target-abi" "lp64"
111 // march overwrite mcpu's default march
112 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=sifive-e31 -march=rv32imc | FileCheck -check-prefix=MCPU-MARCH %s
113 // MCPU-MARCH: "-nostdsysteminc" "-target-cpu" "sifive-e31" "-target-feature" "+m" "-target-feature" "+c"
114 // MCPU-MARCH: "-target-abi" "ilp32"
116 // Check interaction between mcpu and mtune, mtune won't affect arch related
117 // target feature, but mcpu will.
119 // In this case, sifive-e31 is rv32imac, sifive-e76 is rv32imafc, so M-extension
120 // should not enabled.
122 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=sifive-e31 -mtune=sifive-e76 | FileCheck -check-prefix=MTUNE-E31-MCPU-E76 %s
123 // MTUNE-E31-MCPU-E76: "-target-cpu" "sifive-e31"
124 // MTUNE-E31-MCPU-E76-NOT: "-target-feature" "+f"
125 // MTUNE-E31-MCPU-E76-SAME: "-target-feature" "+m"
126 // MTUNE-E31-MCPU-E76-SAME: "-target-feature" "+a"
127 // MTUNE-E31-MCPU-E76-SAME: "-target-feature" "+c"
128 // MTUNE-E31-MCPU-E76-SAME: "-tune-cpu" "sifive-e76"
130 // Check failed cases
132 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv321 | FileCheck -check-prefix=FAIL-MCPU-NAME %s
133 // FAIL-MCPU-NAME: error: the clang compiler does not support '-mcpu=generic-rv321'
135 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv32 -march=rv64i | FileCheck -check-prefix=MISMATCH-ARCH %s
136 // MISMATCH-ARCH: error: the clang compiler does not support '-mcpu=generic-rv32'
138 // RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv64 | FileCheck -check-prefix=MISMATCH-MCPU %s
139 // MISMATCH-MCPU: error: the clang compiler does not support '-mcpu=generic-rv64'