ro updated this revision to Diff 289658. ro added a comment. Add FIXME for SparcV8 `MaxAtomicInlineWidth`.
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D86621/new/ https://reviews.llvm.org/D86621 Files: clang/lib/Basic/Targets/Sparc.cpp clang/lib/Basic/Targets/Sparc.h clang/lib/Driver/ToolChains/CommonArgs.cpp clang/test/Preprocessor/predefined-arch-macros.c compiler-rt/test/profile/Posix/instrprof-gcov-parallel.test compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp
Index: compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp =================================================================== --- compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp +++ compiler-rt/test/ubsan/TestCases/Float/cast-overflow.cpp @@ -11,9 +11,6 @@ // FIXME: not %run %t 8 2>&1 | FileCheck %s --check-prefix=CHECK-8 // RUN: not %run %t 9 2>&1 | FileCheck %s --check-prefix=CHECK-9 -// Bug 42535 -// XFAIL: sparc-target-arch - // This test assumes float and double are IEEE-754 single- and double-precision. #if defined(__APPLE__) Index: compiler-rt/test/profile/Posix/instrprof-gcov-parallel.test =================================================================== --- compiler-rt/test/profile/Posix/instrprof-gcov-parallel.test +++ compiler-rt/test/profile/Posix/instrprof-gcov-parallel.test @@ -10,9 +10,6 @@ RUN: llvm-cov gcov instrprof-gcov-parallel.target.gcda RUN: FileCheck --input-file instrprof-gcov-parallel.target.c.gcov %s -# Bug 42535 -# XFAIL: sparc-target-arch - # Test if the .gcda file is correctly created from one of child processes # and counters of all processes are recorded correctly. # 707 = CHILDREN * COUNT Index: clang/test/Preprocessor/predefined-arch-macros.c =================================================================== --- clang/test/Preprocessor/predefined-arch-macros.c +++ clang/test/Preprocessor/predefined-arch-macros.c @@ -3233,9 +3233,26 @@ // RUN: -target sparc-unknown-linux \ // RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SPARC-V9 // CHECK_SPARC-V9-NOT: #define __sparcv8 1 +// CHECK_SPARC-V9-NOT: #define __sparcv8__ 1 // CHECK_SPARC-V9: #define __sparc_v9__ 1 // CHECK_SPARC-V9: #define __sparcv9 1 -// CHECK_SPARC-V9-NOT: #define __sparcv8 1 +// CHECK_SPARC-V9: #define __sparcv9__ 1 + +// RUN: %clang -E -dM %s -o - 2>&1 \ +// RUN: -target sparc-sun-solaris \ +// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SPARC_SOLARIS_GCC_ATOMICS +// CHECK_SPARC_SOLARIS_GCC_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 +// CHECK_SPARC_SOLARIS_GCC_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 +// CHECK_SPARC_SOLARIS_GCC_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 +// CHECK_SPARC_SOLARIS_GCC_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1 + +// RUN: %clang -mcpu=v8 -E -dM %s -o - 2>&1 \ +// RUN: -target sparc-sun-solaris \ +// RUN: | FileCheck -match-full-lines %s -check-prefix=CHECK_SPARC_SOLARIS_GCC_ATOMICS-V8 +// CHECK_SPARC_SOLARIS_GCC_ATOMICS-V8-NOT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1 +// CHECK_SPARC_SOLARIS_GCC_ATOMICS-V8-NOT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1 +// CHECK_SPARC_SOLARIS_GCC_ATOMICS-V8-NOT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1 +// CHECK_SPARC_SOLARIS_GCC_ATOMICS-V8-NOT: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1 // RUN: %clang -E -dM %s -o - 2>&1 \ // RUN: -target sparcel-unknown-linux \ Index: clang/lib/Driver/ToolChains/CommonArgs.cpp =================================================================== --- clang/lib/Driver/ToolChains/CommonArgs.cpp +++ clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -347,6 +347,8 @@ case llvm::Triple::sparcv9: if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ)) return A->getValue(); + if (T.getArch() == llvm::Triple::sparc && T.isOSSolaris()) + return "v9"; return ""; case llvm::Triple::x86: Index: clang/lib/Basic/Targets/Sparc.h =================================================================== --- clang/lib/Basic/Targets/Sparc.h +++ clang/lib/Basic/Targets/Sparc.h @@ -166,10 +166,15 @@ PtrDiffType = SignedLong; break; } - // Up to 32 bits are lock-free atomic, but we're willing to do atomic ops - // on up to 64 bits. + // Up to 32 bits (V8) or 64 bits (V9) are lock-free atomic, but we're + // willing to do atomic ops on up to 64 bits. MaxAtomicPromoteWidth = 64; - MaxAtomicInlineWidth = 32; + if (getCPUGeneration(CPU) == CG_V9) + MaxAtomicInlineWidth = 64; + else + // FIXME: This isn't correct for plain V8 which lacks CAS, + // only for LEON 3+ and Myriad. + MaxAtomicInlineWidth = 32; } void getTargetDefines(const LangOptions &Opts, Index: clang/lib/Basic/Targets/Sparc.cpp =================================================================== --- clang/lib/Basic/Targets/Sparc.cpp +++ clang/lib/Basic/Targets/Sparc.cpp @@ -147,19 +147,20 @@ void SparcV8TargetInfo::getTargetDefines(const LangOptions &Opts, MacroBuilder &Builder) const { SparcTargetInfo::getTargetDefines(Opts, Builder); - switch (getCPUGeneration(CPU)) { - case CG_V8: + if (getTriple().getOS() == llvm::Triple::Solaris) Builder.defineMacro("__sparcv8"); - if (getTriple().getOS() != llvm::Triple::Solaris) + else { + switch (getCPUGeneration(CPU)) { + case CG_V8: + Builder.defineMacro("__sparcv8"); Builder.defineMacro("__sparcv8__"); - break; - case CG_V9: - Builder.defineMacro("__sparcv9"); - if (getTriple().getOS() != llvm::Triple::Solaris) { + break; + case CG_V9: + Builder.defineMacro("__sparcv9"); Builder.defineMacro("__sparcv9__"); Builder.defineMacro("__sparc_v9__"); + break; } - break; } if (getTriple().getVendor() == llvm::Triple::Myriad) { std::string MyriadArchValue, Myriad2Value; @@ -227,6 +228,12 @@ Builder.defineMacro("__myriad2__", Myriad2Value); Builder.defineMacro("__myriad2", Myriad2Value); } + if (getCPUGeneration(CPU) == CG_V9) { + Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1"); + Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2"); + Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4"); + Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8"); + } } void SparcV9TargetInfo::getTargetDefines(const LangOptions &Opts,
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits