From 8ebf66236e1a0a3f6796abcbf6be83eb6a55e3fa Mon Sep 17 00:00:00 2001 From: Kevin Enderby Date: Thu, 30 Sep 2010 16:38:07 +0000 Subject: [PATCH] Adds getPointerSize() to the AsmBackend which will be needed by the final patch for the dwarf .loc support to emit dwarf line number tables. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@115153 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Target/TargetAsmBackend.h | 3 +++ lib/Target/ARM/ARMAsmBackend.cpp | 8 ++++++++ lib/Target/X86/X86AsmBackend.cpp | 23 +++++++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/include/llvm/Target/TargetAsmBackend.h b/include/llvm/Target/TargetAsmBackend.h index 979595ad4f4..b0a7af6371e 100644 --- a/include/llvm/Target/TargetAsmBackend.h +++ b/include/llvm/Target/TargetAsmBackend.h @@ -101,6 +101,9 @@ public: /// has no actual object file contents. virtual bool isVirtualSection(const MCSection &Section) const = 0; + /// getPointerSize - Get the pointer size in bytes. + virtual unsigned getPointerSize() const = 0; + /// ApplyFixup - Apply the \arg Value for given \arg Fixup into the provided /// data fragment, at the offset specified by the fixup and following the /// fixup kind as appropriate. diff --git a/lib/Target/ARM/ARMAsmBackend.cpp b/lib/Target/ARM/ARMAsmBackend.cpp index f13c2bbf482..9de6eba09fa 100644 --- a/lib/Target/ARM/ARMAsmBackend.cpp +++ b/lib/Target/ARM/ARMAsmBackend.cpp @@ -84,6 +84,10 @@ public: /*IsLittleEndian=*/true, /*HasRelocationAddend=*/false); } + + unsigned getPointerSize() const { + return 4; + }; }; // Fixme: can we raise this to share code between Darwin and ELF? @@ -116,6 +120,10 @@ public: return new MachObjectWriter(OS, /*Is64Bit=*/false); } + unsigned getPointerSize() const { + return 4; + }; + virtual bool doesSectionRequireSymbols(const MCSection &Section) const { return false; } diff --git a/lib/Target/X86/X86AsmBackend.cpp b/lib/Target/X86/X86AsmBackend.cpp index d9c6daa2cc2..cabc6015aa6 100644 --- a/lib/Target/X86/X86AsmBackend.cpp +++ b/lib/Target/X86/X86AsmBackend.cpp @@ -211,6 +211,10 @@ public: ELFX86_32AsmBackend(const Target &T, Triple::OSType OSType) : ELFX86AsmBackend(T, OSType) {} + unsigned getPointerSize() const { + return 4; + } + MCObjectWriter *createObjectWriter(raw_ostream &OS) const { return new ELFObjectWriter(OS, /*Is64Bit=*/false, OSType, @@ -224,6 +228,10 @@ public: ELFX86_64AsmBackend(const Target &T, Triple::OSType OSType) : ELFX86AsmBackend(T, OSType) {} + unsigned getPointerSize() const { + return 8; + } + MCObjectWriter *createObjectWriter(raw_ostream &OS) const { return new ELFObjectWriter(OS, /*Is64Bit=*/true, OSType, @@ -241,6 +249,13 @@ public: HasScatteredSymbols = true; } + unsigned getPointerSize() const { + if (Is64Bit) + return 8; + else + return 4; + } + MCObjectWriter *createObjectWriter(raw_ostream &OS) const { return createWinCOFFObjectWriter(OS, Is64Bit); } @@ -272,6 +287,10 @@ public: DarwinX86_32AsmBackend(const Target &T) : DarwinX86AsmBackend(T) {} + unsigned getPointerSize() const { + return 4; + } + MCObjectWriter *createObjectWriter(raw_ostream &OS) const { return new MachObjectWriter(OS, /*Is64Bit=*/false); } @@ -284,6 +303,10 @@ public: HasReliableSymbolDifference = true; } + unsigned getPointerSize() const { + return 8; + } + MCObjectWriter *createObjectWriter(raw_ostream &OS) const { return new MachObjectWriter(OS, /*Is64Bit=*/true); }