Skip to content

Commit

Permalink
[clang][RISCV][test] Add more tests of the -mabi and -march options
Browse files Browse the repository at this point in the history
1. There is no tests for mabi=ilp32e, and my patch covers that.
2. The tests in riscv-abi.c will show default ABI changes for special archs
   in the future, especially the arch with the F but without the D extension.
3. The tests in riscv-arch.c will show default arch changes for abi=ilp32,
   which is rv32imacfd currently, but it is better to be rv32imac.
   And it is also better for abi=ilp32f defaults to arch=imacf.

Reviewed By: MaskRay, luismarques

Differential Revision: https://reviews.llvm.org/D103878
  • Loading branch information
benshi001 committed Jun 10, 2021
1 parent f8f1c9c commit b0eb391
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 0 deletions.
25 changes: 25 additions & 0 deletions clang/test/Driver/riscv-abi.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,37 @@
// RUN: | FileCheck -check-prefix=CHECK-ILP32 %s
// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -mabi=ilp32 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ILP32 %s
// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -march=rv32imc 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ILP32 %s
// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -march=rv32imf 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ILP32 %s
// RUN: %clang -target riscv32-unknown-elf -x assembler %s -### -o %t.o 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ILP32 %s
// RUN: %clang -target riscv32-unknown-elf -x assembler %s -### -o %t.o \
// RUN: -mabi=ilp32 2>&1 | FileCheck -check-prefix=CHECK-ILP32 %s

// CHECK-ILP32: "-target-abi" "ilp32"

// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -march=rv32e -mabi=ilp32e 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ILP32E %s
// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -mabi=ilp32e 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ILP32E %s
// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -march=rv32e 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ILP32E %s

// CHECK-ILP32E: "-target-abi" "ilp32e"

// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -march=rv32if -mabi=ilp32f 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ILP32F %s

// CHECK-ILP32F: "-target-abi" "ilp32f"

// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -march=rv32ifd -mabi=ilp32d 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ILP32D %s
// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -march=rv32ifd 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ILP32D %s
// RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -march=rv32g 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ILP32D %s
// RUN: %clang -target riscv32-unknown-linux-gnu %s -### -o %t.o 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-ILP32D %s
// RUN: %clang -target riscv32-unknown-linux-gnu -x assembler %s -### -o %t.o 2>&1 \
Expand All @@ -32,6 +49,10 @@
// RUN: | FileCheck -check-prefix=CHECK-LP64 %s
// RUN: %clang -target riscv64-unknown-elf %s -### -o %t.o -mabi=lp64 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-LP64 %s
// RUN: %clang -target riscv64-unknown-elf %s -### -o %t.o -march=rv64imc 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-LP64 %s
// RUN: %clang -target riscv64-unknown-elf %s -### -o %t.o -march=rv64imf 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-LP64 %s
// RUN: %clang -target riscv64-unknown-elf -x assembler %s -### -o %t.o 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-LP64 %s
// RUN: %clang -target riscv64-unknown-elf -x assembler %s -### -o %t.o \
Expand All @@ -46,6 +67,10 @@

// RUN: %clang -target riscv64-unknown-elf %s -### -o %t.o -march=rv64d -mabi=lp64d 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-LP64D %s
// RUN: %clang -target riscv64-unknown-elf %s -### -o %t.o -march=rv64d 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-LP64D %s
// RUN: %clang -target riscv64-unknown-elf %s -### -o %t.o -march=rv64g 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-LP64D %s
// RUN: %clang -target riscv64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
// RUN: | FileCheck -check-prefix=CHECK-LP64D %s
// RUN: %clang -target riscv64-unknown-linux-gnu -x assembler %s -### -o %t.o 2>&1 \
Expand Down
54 changes: 54 additions & 0 deletions clang/test/Driver/riscv-arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,33 @@
// RUN: %clang -target riscv32-unknown-elf -march=rv32gc -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck %s

// RUN: %clang -target riscv32-unknown-elf -mabi=ilp32 -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-ILP32 %s

// CHECK-ILP32: "-target-feature" "+m"
// CHECK-ILP32-SAME: {{^}} "-target-feature" "+a"
// CHECK-ILP32-SAME: {{^}} "-target-feature" "+f"
// CHECK-ILP32-SAME: {{^}} "-target-feature" "+d"
// CHECK-ILP32-SAME: {{^}} "-target-feature" "+c"

// RUN: %clang -target riscv32-unknown-elf -mabi=ilp32f -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-ILP32F %s

// CHECK-ILP32F: "-target-feature" "+m"
// CHECK-ILP32F-SAME: {{^}} "-target-feature" "+a"
// CHECK-ILP32F-SAME: {{^}} "-target-feature" "+f"
// CHECK-ILP32F-SAME: {{^}} "-target-feature" "+d"
// CHECK-ILP32F-SAME: {{^}} "-target-feature" "+c"

// RUN: %clang -target riscv32-unknown-elf -mabi=ilp32d -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-ILP32D %s

// CHECK-ILP32D: "-target-feature" "+m"
// CHECK-ILP32D-SAME: {{^}} "-target-feature" "+a"
// CHECK-ILP32D-SAME: {{^}} "-target-feature" "+f"
// CHECK-ILP32D-SAME: {{^}} "-target-feature" "+d"
// CHECK-ILP32D-SAME: {{^}} "-target-feature" "+c"

// RUN: %clang -target riscv64-unknown-elf -march=rv64i -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck %s
// RUN: %clang -target riscv64-unknown-elf -march=rv64im -### %s \
Expand Down Expand Up @@ -80,6 +107,33 @@
// RUN: %clang -target riscv64-unknown-elf -march=rv64gc -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck %s

// RUN: %clang -target riscv64-unknown-elf -mabi=lp64 -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-LP64 %s

// CHECK-LP64: "-target-feature" "+m"
// CHECK-LP64-SAME: {{^}} "-target-feature" "+a"
// CHECK-LP64-SAME: {{^}} "-target-feature" "+f"
// CHECK-LP64-SAME: {{^}} "-target-feature" "+d"
// CHECK-LP64-SAME: {{^}} "-target-feature" "+c"

// RUN: %clang -target riscv64-unknown-elf -mabi=lp64f -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-LP64F %s

// CHECK-LP64F: "-target-feature" "+m"
// CHECK-LP64F-SAME: {{^}} "-target-feature" "+a"
// CHECK-LP64F-SAME: {{^}} "-target-feature" "+f"
// CHECK-LP64F-SAME: {{^}} "-target-feature" "+d"
// CHECK-LP64F-SAME: {{^}} "-target-feature" "+c"

// RUN: %clang -target riscv64-unknown-elf -mabi=lp64d -### %s \
// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=CHECK-LP64D %s

// CHECK-LP64D: "-target-feature" "+m"
// CHECK-LP64D-SAME: {{^}} "-target-feature" "+a"
// CHECK-LP64D-SAME: {{^}} "-target-feature" "+f"
// CHECK-LP64D-SAME: {{^}} "-target-feature" "+d"
// CHECK-LP64D-SAME: {{^}} "-target-feature" "+c"

// CHECK-NOT: error: invalid arch name '

// RUN: %clang -target riscv32-unknown-elf -march=rv32 -### %s \
Expand Down

0 comments on commit b0eb391

Please sign in to comment.