diff options
| author | Simon Atanasyan <simon@atanasyan.com> | 2019-02-13 18:27:09 +0000 |
|---|---|---|
| committer | Simon Atanasyan <simon@atanasyan.com> | 2019-02-13 18:27:09 +0000 |
| commit | 4c22a574140c799117d340d803c2ae0468ca3b86 (patch) | |
| tree | a9533b18f4aeadb4c8188b77c815c9ad797f5ef5 /clang/lib | |
| parent | 430d294f0b845c6fee710f5b5c33008ebe06ec69 (diff) | |
| download | bcm5719-llvm-4c22a574140c799117d340d803c2ae0468ca3b86.tar.gz bcm5719-llvm-4c22a574140c799117d340d803c2ae0468ca3b86.zip | |
[Headers][mips] Add `__attribute__((__mode__(__unwind_word__)))` to the _Unwind_Word / _Unwind_SWord definitions
The rationale of this change is to fix _Unwind_Word / _Unwind_SWord
definitions for MIPS N32 ABI. This ABI uses 32-bit pointers,
but _Unwind_Word and _Unwind_SWord types are eight bytes long.
# The __attribute__((__mode__(__unwind_word__))) is added to the type
definitions. It makes them equal to the corresponding definitions used
by GCC and allows to override types using `getUnwindWordWidth` function.
# The `getUnwindWordWidth` virtual function override in the `MipsTargetInfo`
class and provides correct type size values.
Differential revision: https://reviews.llvm.org/D58165
llvm-svn: 353965
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Basic/Targets/Mips.cpp | 8 | ||||
| -rw-r--r-- | clang/lib/Basic/Targets/Mips.h | 2 | ||||
| -rw-r--r-- | clang/lib/Headers/unwind.h | 4 |
3 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp index 840ad1bc627..2cafbe87a99 100644 --- a/clang/lib/Basic/Targets/Mips.cpp +++ b/clang/lib/Basic/Targets/Mips.cpp @@ -215,6 +215,14 @@ ArrayRef<Builtin::Info> MipsTargetInfo::getTargetBuiltins() const { 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")) { diff --git a/clang/lib/Basic/Targets/Mips.h b/clang/lib/Basic/Targets/Mips.h index ca0a5bf5965..474cda84a40 100644 --- a/clang/lib/Basic/Targets/Mips.h +++ b/clang/lib/Basic/Targets/Mips.h @@ -401,6 +401,8 @@ public: return (ABI == "n32" || ABI == "n64") || getTargetOpts().ForceEnableInt128; } + unsigned getUnwindWordWidth() const override; + bool validateTarget(DiagnosticsEngine &Diags) const override; }; } // namespace targets diff --git a/clang/lib/Headers/unwind.h b/clang/lib/Headers/unwind.h index 0e8317e5b9d..438f91446ae 100644 --- a/clang/lib/Headers/unwind.h +++ b/clang/lib/Headers/unwind.h @@ -66,8 +66,8 @@ extern "C" { #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; |

