[PATCH] D58165: [Headers][mips] Add `__attribute__((__mode__(__unwind_word__)))` to the _Unwind_Word / _Unwind_SWord definitions

Simon Atanasyan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 13 10:27:37 PST 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rC353965: [Headers][mips] Add `__attribute__((__mode__(__unwind_word__)))` to theā€¦ (authored by atanasyan, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D58165?vs=186585&id=186694#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58165/new/

https://reviews.llvm.org/D58165

Files:
  lib/Basic/Targets/Mips.cpp
  lib/Basic/Targets/Mips.h
  lib/Headers/unwind.h
  test/Sema/attr-mode.c


Index: lib/Basic/Targets/Mips.cpp
===================================================================
--- lib/Basic/Targets/Mips.cpp
+++ lib/Basic/Targets/Mips.cpp
@@ -215,6 +215,14 @@
                                              Builtin::FirstTSBuiltin);
 }
 
+unsigned MipsTargetInfo::getUnwindWordWidth() const {
+  return llvm::StringSwitch<unsigned>(ABI)
+      .Case("o32", 32)
+      .Case("n32", 64)
+      .Case("n64", 64)
+      .Default(getPointerWidth(0));
+}
+
 bool MipsTargetInfo::validateTarget(DiagnosticsEngine &Diags) const {
   // microMIPS64R6 backend was removed.
   if (getTriple().isMIPS64() && IsMicromips && (ABI == "n32" || ABI == "n64")) {
Index: lib/Basic/Targets/Mips.h
===================================================================
--- lib/Basic/Targets/Mips.h
+++ lib/Basic/Targets/Mips.h
@@ -401,6 +401,8 @@
     return (ABI == "n32" || ABI == "n64") || getTargetOpts().ForceEnableInt128;
   }
 
+  unsigned getUnwindWordWidth() const override;
+
   bool validateTarget(DiagnosticsEngine &Diags) const override;
 };
 } // namespace targets
Index: lib/Headers/unwind.h
===================================================================
--- lib/Headers/unwind.h
+++ lib/Headers/unwind.h
@@ -66,8 +66,8 @@
 #pragma GCC visibility push(default)
 #endif
 
-typedef uintptr_t _Unwind_Word;
-typedef intptr_t _Unwind_Sword;
+typedef uintptr_t _Unwind_Word __attribute__((__mode__(__unwind_word__)));
+typedef intptr_t _Unwind_Sword __attribute__((__mode__(__unwind_word__)));
 typedef uintptr_t _Unwind_Ptr;
 typedef uintptr_t _Unwind_Internal_Ptr;
 typedef uint64_t _Unwind_Exception_Class;
Index: test/Sema/attr-mode.c
===================================================================
--- test/Sema/attr-mode.c
+++ test/Sema/attr-mode.c
@@ -6,6 +6,12 @@
 // RUN:   -verify %s
 // RUN: %clang_cc1 -triple x86_64-pc-linux-gnux32 -DTEST_64BIT_X86 -fsyntax-only \
 // RUN:   -verify %s
+// RUN: %clang_cc1 -triple mips-linux-gnu -DTEST_MIPS_32 -fsyntax-only \
+// RUN:   -verify %s
+// RUN: %clang_cc1 -triple mips64-linux-gnuabin32 -DTEST_MIPS_N32 -fsyntax-only \
+// RUN:   -verify %s
+// RUN: %clang_cc1 -triple mips64-linux-gnu -DTEST_MIPS_64 -fsyntax-only \
+// RUN:   -verify %s
 
 typedef int i16_1 __attribute((mode(HI)));
 int i16_1_test[sizeof(i16_1) == 2 ? 1 : -1];
@@ -33,7 +39,7 @@
 int c32_test[sizeof(c32) == 8 ? 1 : -1];
 typedef _Complex float c64 __attribute((mode(DC)));
 
-#ifndef TEST_64BIT_PPC64 // Note, 'XC' mode is illegal for PPC64 machines.
+#if !defined(__ppc__) && !defined(__mips__) // Note, 'XC' mode is illegal for PPC64 and MIPS machines.
 typedef _Complex float c80 __attribute((mode(XC)));
 #endif
 
@@ -84,6 +90,15 @@
 void f_ft128_complex_arg(_Complex long double *x);
 void test_TFtype(f128ibm *a) { f_ft128_arg (a); }
 void test_TCtype(c128ibm *a) { f_ft128_complex_arg (a); }
+#elif TEST_MIPS_32
+typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
+int foo[sizeof(gcc_unwind_word) == 4 ? 1 : -1];
+#elif TEST_MIPS_N32
+typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
+int foo[sizeof(gcc_unwind_word) == 8 ? 1 : -1];
+#elif TEST_MIPS_64
+typedef unsigned int gcc_unwind_word __attribute__((mode(unwind_word)));
+int foo[sizeof(gcc_unwind_word) == 8 ? 1 : -1];
 #else
 #error Unknown test architecture.
 #endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58165.186694.patch
Type: text/x-patch
Size: 3329 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190213/d0444653/attachment.bin>


More information about the cfe-commits mailing list