1 // -----------------------------------------------------------------------------
2 // Tests for the hvx features and warnings.
3 // -----------------------------------------------------------------------------
4 
5 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv66 -mhvx \
6 // RUN:  2>&1 | FileCheck -check-prefix=CHECKHVX166 %s
7 // CHECKHVX166: "-target-feature" "+hvxv66"
8 
9 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv65 -mhvx \
10 // RUN:  2>&1 | FileCheck -check-prefix=CHECKHVX165 %s
11 // CHECKHVX165: "-target-feature" "+hvxv65"
12 
13 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx \
14 // RUN:  2>&1 | FileCheck -check-prefix=CHECKHVX162 %s
15 // CHECKHVX162: "-target-feature" "+hvxv62"
16 
17 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv65 -mhvx \
18 // RUN:  -mhvx-length=128B 2>&1 | FileCheck -check-prefix=CHECKHVX2 %s
19 
20 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx \
21 // RUN:  -mhvx-length=128B 2>&1 | FileCheck -check-prefix=CHECKHVX2 %s
22 
23 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx \
24 // RUN:  -mhvx-length=128b 2>&1 | FileCheck -check-prefix=CHECKHVX2 %s
25 // CHECKHVX2-NOT: "-target-feature" "+hvx-length64b"
26 // CHECKHVX2: "-target-feature" "+hvx-length128b"
27 
28 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv65 2>&1 \
29 // RUN:  | FileCheck -check-prefix=CHECKHVX3 %s
30 
31 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 2>&1 \
32 // RUN:  | FileCheck -check-prefix=CHECKHVX3 %s
33 // CHECKHVX3-NOT: "-target-feature" "+hvx
34 
35 // No hvx target feature must be added if -mno-hvx occurs last
36 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mno-hvx \
37 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-NOHVX %s
38 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx -mno-hvx \
39 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-NOHVX %s
40 // CHECK-NOHVX-NOT: "-target-feature" "+hvx
41 
42 // Hvx target feature should be added if -mno-hvx doesn't occur last
43 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mno-hvx -mhvx\
44 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXFEAT %s
45 // CHECK-HVXFEAT: "-target-feature" "+hvxv62"
46 
47 // With -mhvx, the version of hvx defaults to Cpu
48 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx \
49 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVX-DEFAULT %s
50 // CHECK-HVX-DEFAULT: "-target-feature" "+hvxv60"
51 
52 // Test -mhvx= flag
53 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx=v62 \
54 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXEQ %s
55 // CHECK-HVXEQ: "-target-feature" "+hvxv62"
56 
57 // Honor the last occurred -mhvx=, -mhvx flag.
58 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx=v62 -mhvx\
59 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXEQ-PRE %s
60 // CHECK-HVXEQ-PRE-NOT: "-target-feature" "+hvxv62"
61 // CHECK-HVXEQ-PRE: "-target-feature" "+hvxv60"
62 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx -mhvx=v62\
63 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXEQ-PRE2 %s
64 // CHECK-HVXEQ-PRE2-NOT: "-target-feature" "+hvxv60"
65 // CHECK-HVXEQ-PRE2: "-target-feature" "+hvxv62"
66 
67 // Test -mhvx-length flag
68 // The default mode on v60,v62 is 64B.
69 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx \
70 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-64B %s
71 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx \
72 // RUN:  -mhvx-length=64b 2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-64B %s
73 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv60 -mhvx \
74 // RUN:  -mhvx-length=64B 2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-64B %s
75 // CHECK-HVXLENGTH-64B: "-target-feature" "+hvx{{.*}}" "-target-feature" "+hvx-length64b"
76 // The default mode on v66 and future archs is 128B.
77 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv66 -mhvx \
78 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-128B %s
79 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mv62 -mhvx -mhvx-length=128B\
80 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-128B %s
81 // CHECK-HVXLENGTH-128B: "-target-feature" "+hvx{{.*}}" "-target-feature" "+hvx-length128b"
82 
83 // Bail out if -mhvx-length is specified without HVX enabled
84 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx-length=64B \
85 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-ERROR %s
86 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx-length=128B \
87 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-ERROR %s
88 // CHECK-HVXLENGTH-ERROR: error: -mhvx-length is not supported without a -mhvx/-mhvx= flag
89 
90 // Error out if an unsupported value is passed to -mhvx-length.
91 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx -mhvx-length=B \
92 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-VALUE-ERROR %s
93 // RUN: %clang -c %s -### -target hexagon-unknown-elf -mhvx -mhvx-length=128 \
94 // RUN:  2>&1 | FileCheck -check-prefix=CHECK-HVXLENGTH-VALUE-ERROR %s
95 // CHECK-HVXLENGTH-VALUE-ERROR: error: unsupported argument '{{.*}}' to option 'mhvx-length='
96