[llvm-commits] [llvm] r47701 - in /llvm/trunk/lib/Target/PowerPC: PPCTargetAsmInfo.cpp PPCTargetAsmInfo.h

Anton Korobeynikov asl at math.spbu.ru
Wed Feb 27 15:49:15 PST 2008


Author: asl
Date: Wed Feb 27 17:49:15 2008
New Revision: 47701

URL: http://llvm.org/viewvc/llvm-project?rev=47701&view=rev
Log:
EHPreferredDataFormat hook for PPC targets. Looks like Darwin
uses the same encoding everywhere. Linux FIXME'ed.

Modified:
    llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp
    llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.h

Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp?rev=47701&r1=47700&r2=47701&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.cpp Wed Feb 27 17:49:15 2008
@@ -14,7 +14,10 @@
 #include "PPCTargetAsmInfo.h"
 #include "PPCTargetMachine.h"
 #include "llvm/Function.h"
+#include "llvm/Support/Dwarf.h"
+
 using namespace llvm;
+using namespace llvm::dwarf;
 
 PPCTargetAsmInfo::PPCTargetAsmInfo(const PPCTargetMachine &TM) {
   bool isPPC64 = TM.getSubtargetImpl()->isPPC64();
@@ -27,7 +30,6 @@
   InlineAsmStart = "# InlineAsm Start";
   InlineAsmEnd = "# InlineAsm End";
   AssemblerDialect = TM.getSubtargetImpl()->getAsmFlavor();
-  
 }
 
 DarwinTargetAsmInfo::DarwinTargetAsmInfo(const PPCTargetMachine &TM)
@@ -86,6 +88,21 @@
   }
 }
 
+/// PreferredEHDataFormat - This hook allows the target to select data
+/// format used for encoding pointers in exception handling data. Reason is
+/// 0 for data, 1 for code labels, 2 for function pointers. Global is true
+/// if the symbol can be relocated.
+unsigned DarwinTargetAsmInfo::PreferredEHDataFormat(unsigned Reason,
+                                                    bool Global) const {
+  if (Reason == 2 && Global)
+    return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
+  else if (Reason == 1 || !Global)
+    return DW_EH_PE_pcrel;
+  else
+    return DW_EH_PE_absptr;
+}
+
+
 LinuxTargetAsmInfo::LinuxTargetAsmInfo(const PPCTargetMachine &TM)
 : PPCTargetAsmInfo(TM)
 {
@@ -132,3 +149,13 @@
   DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\", at progbits";
   DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\", at progbits";
 }
+
+/// PreferredEHDataFormat - This hook allows the target to select data
+/// format used for encoding pointers in exception handling data. Reason is
+/// 0 for data, 1 for code labels, 2 for function pointers. Global is true
+/// if the symbol can be relocated.
+unsigned LinuxTargetAsmInfo::PreferredEHDataFormat(unsigned Reason,
+                                                   bool Global) const {
+  // We really need to write something here.
+  return TargetAsmInfo::PreferredEHDataFormat(Reason, Global);
+}

Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.h?rev=47701&r1=47700&r2=47701&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.h (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCTargetAsmInfo.h Wed Feb 27 17:49:15 2008
@@ -27,10 +27,12 @@
 
   struct DarwinTargetAsmInfo : public PPCTargetAsmInfo {
     explicit DarwinTargetAsmInfo(const PPCTargetMachine &TM);
+    virtual unsigned PreferredEHDataFormat(unsigned Reason, bool Global) const;
   };
 
   struct LinuxTargetAsmInfo : public PPCTargetAsmInfo {
     explicit LinuxTargetAsmInfo(const PPCTargetMachine &TM);
+    virtual unsigned PreferredEHDataFormat(unsigned Reason, bool Global) const;
   };
 
 } // namespace llvm





More information about the llvm-commits mailing list