fhahn updated this revision to Diff 458407. fhahn added a comment. Rebase and ping :)
The potential benefit of having -m flags is also mentioned in this recent bug report: https://github.com/llvm/llvm-project/issues/57588 Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D113779/new/ https://reviews.llvm.org/D113779 Files: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Arch/AArch64.cpp clang/lib/Driver/ToolChains/Arch/ARM.cpp clang/test/Preprocessor/aarch64-target-features.c clang/test/Preprocessor/arm-target-features.c
Index: clang/test/Preprocessor/arm-target-features.c =================================================================== --- clang/test/Preprocessor/arm-target-features.c +++ clang/test/Preprocessor/arm-target-features.c @@ -25,6 +25,7 @@ // CHECK-V8A-ALLOW-FP-INSTR-V8A-NOT: #define __ARM_FEATURE_DOTPROD // RUN: %clang -target arm-none-linux-gnueabi -march=armv8.2-a+nofp16fml+fp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s +// RUN: %clang -target arm-none-linux-gnueabi -march=armv8.2-a -mnofp16fml -mfp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target arm-none-linux-gnueabi -march=armv8.2-a+nofp16+fp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target arm-none-linux-gnueabi -march=armv8.2-a+fp16+nofp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target arm-none-linux-gnueabi -march=armv8-a+fp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s @@ -77,6 +78,7 @@ // CHECK-FULLFP16-SOFT-NOT: #define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC // RUN: %clang -target arm-none-linux-gnueabi -march=armv8.2a+dotprod -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-DOTPROD %s +// RUN: %clang -target arm-none-linux-gnueabi -march=armv8.2a -mdotprod -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-DOTPROD %s // CHECK-DOTPROD: #define __ARM_FEATURE_DOTPROD 1 // RUN: %clang -target armv8r-none-linux-gnu -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-V8R %s Index: clang/test/Preprocessor/aarch64-target-features.c =================================================================== --- clang/test/Preprocessor/aarch64-target-features.c +++ clang/test/Preprocessor/aarch64-target-features.c @@ -200,20 +200,29 @@ // CHECK-SVE2BITPERM: __ARM_FEATURE_SVE2_BITPERM 1 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8.2a+dotprod -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-DOTPROD %s +// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.2a -mdotprod -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-DOTPROD %s // CHECK-DOTPROD: __ARM_FEATURE_DOTPROD 1 // On ARMv8.2-A and above, +fp16fml implies +fp16. // On ARMv8.4-A and above, +fp16 implies +fp16fml. // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2-a+nofp16fml+fp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s +// RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2-a -mnofp16fml -mfp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2-a+nofp16+fp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s +// RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2-a -mnofp16 -mfp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2-a+fp16+nofp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s +// RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2-a -mfp16 -mnofp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8-a+fp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s +// RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8-a -mfp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8-a+fp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s +// RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8-a -mfp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+nofp16fml+fp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+nofp16+fp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s +// RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a -mnofp16 -mfp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+fp16+nofp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-NOFML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+fp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s +// RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a -mfp16fml -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a+fp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s +// RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.4-a -mfp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-FML --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // CHECK-FULLFP16-FML: #define __ARM_FEATURE_FP16_FML 1 // CHECK-FULLFP16-NOFML-NOT: #define __ARM_FEATURE_FP16_FML 1 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1 Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp =================================================================== --- clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -654,6 +654,29 @@ Features.push_back("-crc"); } + if (Arg *A = Args.getLastArg(options::OPT_mfp16, options::OPT_mnofp16)) { + if (A->getOption().matches(options::OPT_mfp16)) + Features.push_back("+fullfp16"); + else + Features.push_back("-fullfp16"); + } + + if (Arg *A = + Args.getLastArg(options::OPT_mfp16fml, options::OPT_mnofp16fml)) { + if (A->getOption().matches(options::OPT_mfp16fml)) + Features.push_back("+fp16fml"); + else + Features.push_back("-fp16fml"); + } + + if (Arg *A = + Args.getLastArg(options::OPT_mdotprod, options::OPT_mnodotprod)) { + if (A->getOption().matches(options::OPT_mdotprod)) + Features.push_back("+dotprod"); + else + Features.push_back("-dotprod"); + } + // For Arch >= ARMv8.0 && A or R profile: crypto = sha2 + aes // Rather than replace within the feature vector, determine whether each // algorithm is enabled and append this to the end of the vector. Index: clang/lib/Driver/ToolChains/Arch/AArch64.cpp =================================================================== --- clang/lib/Driver/ToolChains/Arch/AArch64.cpp +++ clang/lib/Driver/ToolChains/Arch/AArch64.cpp @@ -406,6 +406,29 @@ ArchFeatPos = I - Features.begin(); } + if (Arg *A = Args.getLastArg(options::OPT_mfp16, options::OPT_mnofp16)) { + if (A->getOption().matches(options::OPT_mfp16)) + Features.push_back("+fullfp16"); + else + Features.push_back("-fullfp16"); + } + + if (Arg *A = + Args.getLastArg(options::OPT_mfp16fml, options::OPT_mnofp16fml)) { + if (A->getOption().matches(options::OPT_mfp16fml)) + Features.push_back("+fp16fml"); + else + Features.push_back("-fp16fml"); + } + + if (Arg *A = + Args.getLastArg(options::OPT_mdotprod, options::OPT_mnodotprod)) { + if (A->getOption().matches(options::OPT_mdotprod)) + Features.push_back("+dotprod"); + else + Features.push_back("-dotprod"); + } + // Handle (arch-dependent) fp16fml/fullfp16 relationship. // FIXME: this fp16fml option handling will be reimplemented after the // TargetParser rewrite. Index: clang/include/clang/Driver/Options.td =================================================================== --- clang/include/clang/Driver/Options.td +++ clang/include/clang/Driver/Options.td @@ -3533,6 +3533,19 @@ def mframe_chain : Joined<["-"], "mframe-chain=">, Group<m_arm_Features_Group>, Values<"none,aapcs,aapcs+leaf">, HelpText<"Select the frame chain model used to emit frame records (Arm only).">; +def mfp16: Flag<["-"], "mfp16">, Group<m_arm_Features_Group>, + HelpText<"Allow use of FP16 instructions.">; +def mnofp16: Flag<["-"], "mnofp16">, Group<m_arm_Features_Group>, + HelpText<"Disallow use of FP16 instructions.">; +def mfp16fml: Flag<["-"], "mfp16fml">, Group<m_arm_Features_Group>, + HelpText<"Allow use of FP16 machine learning instructions.">; +def mnofp16fml: Flag<["-"], "mnofp16fml">, Group<m_arm_Features_Group>, + HelpText<"Disallow use of FP16 FML instructions.">; +def mdotprod: Flag<["-"], "mdotprod">, Group<m_arm_Features_Group>, + HelpText<"Allow use of dot product instructions.">; +def mnodotprod: Flag<["-"], "mnodotprod">, Group<m_arm_Features_Group>, + HelpText<"Disallow use of dot product instructions.">; + def mgeneral_regs_only : Flag<["-"], "mgeneral-regs-only">, Group<m_Group>, HelpText<"Generate code which only uses the general purpose registers (AArch64/x86 only)">; def mfix_cmse_cve_2021_35465 : Flag<["-"], "mfix-cmse-cve-2021-35465">,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits