From b0eb3919835a7bb57cb28ae684d77fece8ff025c Mon Sep 17 00:00:00 2001 From: Ben Shi Date: Thu, 10 Jun 2021 09:14:14 +0800 Subject: [PATCH] [clang][RISCV][test] Add more tests of the -mabi and -march options 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 --- clang/test/Driver/riscv-abi.c | 25 ++++++++++++++++ clang/test/Driver/riscv-arch.c | 54 ++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) diff --git a/clang/test/Driver/riscv-abi.c b/clang/test/Driver/riscv-abi.c index ef3913ee3c4ba..1035fe4c668b0 100644 --- a/clang/test/Driver/riscv-abi.c +++ b/clang/test/Driver/riscv-abi.c @@ -2,6 +2,10 @@ // 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 \ @@ -9,6 +13,15 @@ // 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 @@ -16,6 +29,10 @@ // 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 \ @@ -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 \ @@ -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 \ diff --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c index cf148ca885d09..f79d29d87e983 100644 --- a/clang/test/Driver/riscv-arch.c +++ b/clang/test/Driver/riscv-arch.c @@ -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 \ @@ -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 \