xref: /llvm-project/clang/test/Driver/loongarch-relax-features.c (revision ba70368f1380f8d22494fc8c100d2ab894a3cf94)
1 /// Test -m[no-]relax options.
2 
3 // RUN: %clang --target=loongarch32 -S -emit-llvm %s -o - | FileCheck %s --check-prefix=LA32
4 // RUN: %clang --target=loongarch64 -S -emit-llvm %s -o - | FileCheck %s --check-prefix=LA64
5 // RUN: %clang --target=loongarch32 -mno-relax -S -emit-llvm %s -o - | FileCheck %s --check-prefix=LA32-NORELAX
6 // RUN: %clang --target=loongarch64 -mno-relax -S -emit-llvm %s -o - | FileCheck %s --check-prefix=LA64-NORELAX
7 // RUN: %clang --target=loongarch32 -mrelax -S -emit-llvm %s -o - | FileCheck %s --check-prefix=LA32-RELAX
8 // RUN: %clang --target=loongarch64 -mrelax -S -emit-llvm %s -o - | FileCheck %s --check-prefix=LA64-RELAX
9 
10 /// Error when using -gsplit-dwarf with linker relaxation (-mrelax).
11 
12 // RUN: %clang -### -c --target=loongarch32 -mno-relax -g -gsplit-dwarf %s 2>&1 | FileCheck %s --check-prefix=SPLIT-DWARF
13 // RUN: not %clang -c --target=loongarch32-linux-gnu -mrelax -gsplit-dwarf %s 2>&1 | FileCheck %s --check-prefix=ERR-SPLIT-DWARF
14 // RUN: not %clang -c --target=loongarch32 -mrelax -gsplit-dwarf=single %s 2>&1 | FileCheck %s --check-prefix=ERR-SPLIT-DWARF
15 // RUN: %clang -### -c --target=loongarch64 -mno-relax -g -gsplit-dwarf %s 2>&1 | FileCheck %s --check-prefix=SPLIT-DWARF
16 // RUN: not %clang -c --target=loongarch64-linux-gnu -mrelax -gsplit-dwarf %s 2>&1 | FileCheck %s --check-prefix=ERR-SPLIT-DWARF
17 // RUN: not %clang -c --target=loongarch64 -mrelax -gsplit-dwarf=single %s 2>&1 | FileCheck %s --check-prefix=ERR-SPLIT-DWARF
18 
19 // LA32: "target-features"="+32bit"
20 // LA64: "target-features"="+64bit,+d,+f,+lsx,+ual"
21 
22 // LA32-NORELAX: "target-features"="+32bit,-relax"
23 // LA64-NORELAX: "target-features"="+64bit,+d,+f,+lsx,+ual,-relax"
24 
25 // LA32-RELAX: "target-features"="+32bit,+relax"
26 // LA64-RELAX: "target-features"="+64bit,+d,+f,+lsx,+relax,+ual"
27 
28 // SPLIT-DWARF:     "-split-dwarf-file"
29 // ERR-SPLIT-DWARF: error: -gsplit-dwarf{{.*}} is unsupported with LoongArch linker relaxation (-mrelax)
30 
31 int foo(void) {
32   return 3;
33 }
34