1 // Check passing Mips ABI options to the backend.
2 //
3 // REQUIRES: mips-registered-target
4 //
5 // RUN: %clang -target mips-linux-gnu -### -c %s 2>&1 \
6 // RUN:   | FileCheck -check-prefix=MIPS32R2-O32 %s
7 // RUN: %clang -target mips64-linux-gnu -mips32r2 -mabi=32 -### -c %s 2>&1 \
8 // RUN:   | FileCheck -check-prefix=MIPS32R2-O32 %s
9 // MIPS32R2-O32: "-target-cpu" "mips32r2"
10 // MIPS32R2-O32: "-target-abi" "o32"
11 //
12 // FIXME: This is a valid combination of options but we reject it at the moment
13 //        because the backend can't handle it.
14 // RUN: not %clang -target mips-linux-gnu -c %s \
15 // RUN:        -march=mips64r2 -mabi=32 2>&1 \
16 // RUN:   | FileCheck -check-prefix=MIPS64R2-O32 %s
17 // MIPS64R2-O32: error: ABI 'o32' is not supported on CPU 'mips64r2'
18 //
19 // RUN: %clang -target mips64-linux-gnu -### -c %s 2>&1 \
20 // RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
21 // RUN: %clang -target mips-img-linux-gnu -mips64r2 -### -c %s 2>&1 \
22 // RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
23 // RUN: %clang -target mips-mti-linux-gnu -mips64r2 -### -c %s 2>&1 \
24 // RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
25 // RUN: %clang -target mips-linux-gnu -mips64r2 -mabi=64 -### -c %s 2>&1 \
26 // RUN:   | FileCheck -check-prefix=MIPS64R2-N64 %s
27 // MIPS64R2-N64: "-target-cpu" "mips64r2"
28 // MIPS64R2-N64: "-target-abi" "n64"
29 //
30 // RUN: %clang -target mips64-linux-gnu -### -mips64r3 -c %s 2>&1 \
31 // RUN:   | FileCheck -check-prefix=MIPS64R3-N64 %s
32 // RUN: %clang -target mips-img-linux-gnu -mips64r3 -### -c %s 2>&1 \
33 // RUN:   | FileCheck -check-prefix=MIPS64R3-N64 %s
34 // RUN: %clang -target mips-mti-linux-gnu -mips64r3 -### -c %s 2>&1 \
35 // RUN:   | FileCheck -check-prefix=MIPS64R3-N64 %s
36 // MIPS64R3-N64: "-target-cpu" "mips64r3"
37 // MIPS64R3-N64: "-target-abi" "n64"
38 //
39 // RUN: %clang -target mips-linux-gnu -### -c %s \
40 // RUN:        -mabi=32 2>&1 \
41 // RUN:   | FileCheck -check-prefix=MIPS-ABI-32 %s
42 // MIPS-ABI-32: "-target-cpu" "mips32r2"
43 // MIPS-ABI-32: "-target-abi" "o32"
44 //
45 // RUN: %clang -target mips-linux-gnu -### -c %s \
46 // RUN:        -mabi=o32 2>&1 \
47 // RUN:   | FileCheck -check-prefix=MIPS-ABI-O32 %s
48 // MIPS-ABI-O32: "-target-cpu" "mips32r2"
49 // MIPS-ABI-O32: "-target-abi" "o32"
50 //
51 // RUN: %clang -target mips-linux-gnu -### -c %s \
52 // RUN:        -mabi=n32 2>&1 \
53 // RUN:   | FileCheck -check-prefix=MIPS-ABI-N32 %s
54 // MIPS-ABI-N32: "-target-cpu" "mips64r2"
55 // MIPS-ABI-N32: "-target-abi" "n32"
56 //
57 // RUN: %clang -target mips64-linux-gnu -### -c %s \
58 // RUN:        -mabi=64 2>&1 \
59 // RUN:   | FileCheck -check-prefix=MIPS-ABI-64 %s
60 // MIPS-ABI-64: "-target-cpu" "mips64r2"
61 // MIPS-ABI-64: "-target-abi" "n64"
62 //
63 // RUN: %clang -target mips64-linux-gnu -### -c %s \
64 // RUN:        -mabi=n64 2>&1 \
65 // RUN:   | FileCheck -check-prefix=MIPS-ABI-N64 %s
66 // MIPS-ABI-N64: "-target-cpu" "mips64r2"
67 // MIPS-ABI-N64: "-target-abi" "n64"
68 //
69 // RUN: not %clang -target mips64-linux-gnu -c %s \
70 // RUN:        -mabi=o64 2>&1 \
71 // RUN:   | FileCheck -check-prefix=MIPS-ABI-O64 %s
72 // MIPS-ABI-O64: error: unknown target ABI 'o64'
73 //
74 // RUN: not %clang -target mips-linux-gnu -c %s \
75 // RUN:        -mabi=unknown 2>&1 \
76 // RUN:   | FileCheck -check-prefix=MIPS-ABI-UNKNOWN %s
77 // MIPS-ABI-UNKNOWN: error: unknown target ABI 'unknown'
78 //
79 // RUN: %clang -target mips-linux-gnu -### -c %s \
80 // RUN:        -march=mips1 2>&1 \
81 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-1 %s
82 // MIPS-ARCH-1: "-target-cpu" "mips1"
83 // MIPS-ARCH-1: "-target-abi" "o32"
84 //
85 // RUN: %clang -target mips-linux-gnu -### -c %s \
86 // RUN:        -march=mips2 2>&1 \
87 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-2 %s
88 // MIPS-ARCH-2: "-target-cpu" "mips2"
89 // MIPS-ARCH-2: "-target-abi" "o32"
90 //
91 // RUN: %clang -target mips-linux-gnu -### -c %s \
92 // RUN:        -march=mips3 2>&1 \
93 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-3 %s
94 // MIPS-ARCH-3: "-target-cpu" "mips3"
95 // MIPS-ARCH-3: "-target-abi" "o32"
96 //
97 // RUN: %clang -target mips-linux-gnu -### -c %s \
98 // RUN:        -march=mips4 2>&1 \
99 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-4 %s
100 // MIPS-ARCH-4: "-target-cpu" "mips4"
101 // MIPS-ARCH-4: "-target-abi" "o32"
102 //
103 // RUN: %clang -target mips-linux-gnu -### -c %s \
104 // RUN:        -march=mips5 2>&1 \
105 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-5 %s
106 // MIPS-ARCH-5: "-target-cpu" "mips5"
107 // MIPS-ARCH-5: "-target-abi" "o32"
108 //
109 // RUN: %clang -target mips-linux-gnu -### -c %s \
110 // RUN:        -march=mips32 2>&1 \
111 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-32 %s
112 // MIPS-ARCH-32: "-target-cpu" "mips32"
113 // MIPS-ARCH-32: "-target-abi" "o32"
114 //
115 // RUN: %clang -target mips-linux-gnu -### -c %s \
116 // RUN:        -march=mips32r2 2>&1 \
117 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-32R2 %s
118 // MIPS-ARCH-32R2: "-target-cpu" "mips32r2"
119 // MIPS-ARCH-32R2: "-target-abi" "o32"
120 //
121 // RUN: %clang -target mips-linux-gnu -### -c %s \
122 // RUN:        -march=p5600 2>&1 \
123 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-P5600 %s
124 // MIPS-ARCH-P5600: "-target-cpu" "p5600"
125 // MIPS-ARCH-P5600: "-target-abi" "o32"
126 //
127 // RUN: not %clang -target mips-linux-gnu -c %s \
128 // RUN:        -march=p5600 -mabi=64 2>&1 \
129 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-P5600-N64 %s
130 // MIPS-ARCH-P5600-N64: error: ABI 'n64' is not supported on CPU 'p5600'
131 //
132 // RUN: %clang -target mips-linux-gnu -### -c %s \
133 // RUN:        -march=mips64 2>&1 \
134 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-3264 %s
135 // MIPS-ARCH-3264: "-target-cpu" "mips64"
136 // MIPS-ARCH-3264: "-target-abi" "o32"
137 //
138 // RUN: %clang -target mips64-linux-gnu -### -c %s \
139 // RUN:        -march=mips64 2>&1 \
140 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-64 %s
141 // MIPS-ARCH-64: "-target-cpu" "mips64"
142 // MIPS-ARCH-64: "-target-abi" "n64"
143 //
144 // RUN: %clang -target mips64-linux-gnu -### -c %s \
145 // RUN:        -march=mips64r2 2>&1 \
146 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-64R2 %s
147 // MIPS-ARCH-64R2: "-target-cpu" "mips64r2"
148 // MIPS-ARCH-64R2: "-target-abi" "n64"
149 //
150 // RUN: %clang -target mips64-linux-gnu -### -c %s \
151 // RUN:        -march=octeon 2>&1 \
152 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-OCTEON %s
153 // MIPS-ARCH-OCTEON: "-target-cpu" "octeon"
154 // MIPS-ARCH-OCTEON: "-target-abi" "n64"
155 //
156 // RUN: %clang -target mips64-linux-gnu -### -c %s \
157 // RUN:        -march=octeon+ 2>&1 \
158 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-OCTEONP %s
159 // MIPS-ARCH-OCTEONP: "-target-cpu" "octeon+"
160 // MIPS-ARCH-OCTEONP: "-target-abi" "n64"
161 //
162 // RUN: not %clang -target mips64-linux-gnu -c %s \
163 // RUN:        -march=mips32 2>&1 \
164 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-6432 %s
165 // MIPS-ARCH-6432: error: ABI 'n64' is not supported on CPU 'mips32'
166 //
167 // RUN: not %clang -target mips-linux-gnu -c %s \
168 // RUN:        -march=unknown 2>&1 \
169 // RUN:   | FileCheck -check-prefix=MIPS-ARCH-UNKNOWN %s
170 // MIPS-ARCH-UNKNOWN: error: unknown target CPU 'unknown'
171 
172 // Check adjusting of target triple accordingly to `-mabi` option.
173 // RUN: %clang -target mips64-linux-gnuabi64 -mabi=32 -### %s 2>&1 \
174 // RUN:   | FileCheck -check-prefix=TARGET-O32 %s
175 // TARGET-O32: "-triple" "mips-unknown-linux-gnu"
176 // TARGET-O32: "-target-cpu" "mips32r2"
177 // TARGET-O32: "-target-abi" "o32"
178 // TARGET-O32: ld{{(.exe)?}}"
179 // TARGET-O32: "-m" "elf32btsmip"
180 
181 // RUN: %clang -target mips-linux-gnu -mabi=n32 -### %s 2>&1 \
182 // RUN:   | FileCheck -check-prefix=TARGET-N32 %s
183 // TARGET-N32: "-triple" "mips64-unknown-linux-gnuabin32"
184 // TARGET-N32: "-target-cpu" "mips64r2"
185 // TARGET-N32: "-target-abi" "n32"
186 // TARGET-N32: ld{{(.exe)?}}"
187 // TARGET-N32: "-m" "elf32btsmipn32"
188 
189 // RUN: %clang -target mips-linux-gnu -mabi=64 -### %s 2>&1 \
190 // RUN:   | FileCheck -check-prefix=TARGET-N64 %s
191 // TARGET-N64: "-triple" "mips64-unknown-linux-gnuabi64"
192 // TARGET-N64: "-target-cpu" "mips64r2"
193 // TARGET-N64: "-target-abi" "n64"
194 // TARGET-N64: ld{{(.exe)?}}"
195 // TARGET-N64: "-m" "elf64btsmip"
196