LLVM API Documentation

PPCTargetAsmInfo.cpp

Go to the documentation of this file.
00001 //===-- PPCTargetAsmInfo.cpp - PPC asm properties ---------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This file contains the declarations of the DarwinTargetAsmInfo properties.
00011 //
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "PPCTargetAsmInfo.h"
00015 #include "PPCTargetMachine.h"
00016 #include "llvm/Function.h"
00017 #include "llvm/Support/Dwarf.h"
00018 
00019 using namespace llvm;
00020 using namespace llvm::dwarf;
00021 
00022 PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM):
00023   PPCTargetAsmInfo<DarwinTargetAsmInfo>(TM) {
00024   PCSymbol = ".";
00025   CommentString = ";";
00026   GlobalPrefix = "_";
00027   PrivateGlobalPrefix = "L";
00028   LessPrivateGlobalPrefix = "l";
00029   StringConstantPrefix = "\1LC";
00030   ConstantPoolSection = "\t.const\t";
00031   JumpTableDataSection = ".const";
00032   CStringSection = "\t.cstring";
00033   if (TM.getRelocationModel() == Reloc::Static) {
00034     StaticCtorsSection = ".constructor";
00035     StaticDtorsSection = ".destructor";
00036   } else {
00037     StaticCtorsSection = ".mod_init_func";
00038     StaticDtorsSection = ".mod_term_func";
00039   }
00040   HasSingleParameterDotFile = false;
00041   SwitchToSectionDirective = "\t.section ";
00042   UsedDirective = "\t.no_dead_strip\t";
00043   WeakDefDirective = "\t.weak_definition ";
00044   WeakRefDirective = "\t.weak_reference ";
00045   HiddenDirective = "\t.private_extern ";
00046   SupportsExceptionHandling = true;
00047   NeedsIndirectEncoding = true;
00048   NeedsSet = true;
00049   BSSSection = 0;
00050   
00051   DwarfEHFrameSection =
00052   ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
00053   DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
00054   GlobalEHDirective = "\t.globl\t";
00055   SupportsWeakOmittedEHFrame = false;
00056 
00057   DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug";
00058   DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug";
00059   DwarfLineSection = ".section __DWARF,__debug_line,regular,debug";
00060   DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug";
00061   DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug";
00062   DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug";
00063   DwarfStrSection = ".section __DWARF,__debug_str,regular,debug";
00064   DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug";
00065   DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug";
00066   DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug";
00067   DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug";
00068   
00069   // In non-PIC modes, emit a special label before jump tables so that the
00070   // linker can perform more accurate dead code stripping.
00071   if (TM.getRelocationModel() != Reloc::PIC_) {
00072     // Emit a local label that is preserved until the linker runs.
00073     JumpTableSpecialLabelPrefix = "l";
00074   }
00075 }
00076 
00077 /// PreferredEHDataFormat - This hook allows the target to select data
00078 /// format used for encoding pointers in exception handling data. Reason is
00079 /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
00080 /// if the symbol can be relocated.
00081 unsigned
00082 PPCDarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
00083                                               bool Global) const {
00084   if (Reason == DwarfEncoding::Functions && Global)
00085     return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
00086   else if (Reason == DwarfEncoding::CodeLabels || !Global)
00087     return DW_EH_PE_pcrel;
00088   else
00089     return DW_EH_PE_absptr;
00090 }
00091 
00092 const char *
00093 PPCDarwinTargetAsmInfo::getEHGlobalPrefix() const
00094 {
00095   const PPCSubtarget* Subtarget = &TM.getSubtarget<PPCSubtarget>();
00096   if (Subtarget->getDarwinVers() > 9)
00097     return PrivateGlobalPrefix;
00098   else
00099     return "";
00100 }
00101 
00102 PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) :
00103   PPCTargetAsmInfo<ELFTargetAsmInfo>(TM) {
00104   CommentString = "#";
00105   GlobalPrefix = "";
00106   PrivateGlobalPrefix = ".L";
00107   ConstantPoolSection = "\t.section .rodata.cst4\t";
00108   JumpTableDataSection = ".section .rodata.cst4";
00109   CStringSection = ".rodata.str";
00110   StaticCtorsSection = ".section\t.ctors,\"aw\",@progbits";
00111   StaticDtorsSection = ".section\t.dtors,\"aw\",@progbits";
00112   UsedDirective = "\t# .no_dead_strip\t";
00113   WeakRefDirective = "\t.weak\t";
00114   BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
00115 
00116   // PPC/Linux normally uses named section for BSS.
00117   BSSSection_  = getNamedSection("\t.bss",
00118                                  SectionFlags::Writeable | SectionFlags::BSS,
00119                                  /* Override */ true);
00120 
00121   // Debug Information
00122   AbsoluteDebugSectionOffsets = true;
00123   SupportsDebugInformation = true;
00124   DwarfAbbrevSection =  "\t.section\t.debug_abbrev,\"\",@progbits";
00125   DwarfInfoSection =    "\t.section\t.debug_info,\"\",@progbits";
00126   DwarfLineSection =    "\t.section\t.debug_line,\"\",@progbits";
00127   DwarfFrameSection =   "\t.section\t.debug_frame,\"\",@progbits";
00128   DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
00129   DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
00130   DwarfStrSection =     "\t.section\t.debug_str,\"\",@progbits";
00131   DwarfLocSection =     "\t.section\t.debug_loc,\"\",@progbits";
00132   DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
00133   DwarfRangesSection =  "\t.section\t.debug_ranges,\"\",@progbits";
00134   DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
00135 
00136   PCSymbol = ".";
00137 
00138   // Set up DWARF directives
00139   HasLEB128 = true;  // Target asm supports leb128 directives (little-endian)
00140 
00141   // Exceptions handling
00142   if (!TM.getSubtargetImpl()->isPPC64())
00143     SupportsExceptionHandling = true;
00144   AbsoluteEHSectionOffsets = false;
00145   DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
00146   DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
00147 }
00148 
00149 /// PreferredEHDataFormat - This hook allows the target to select data
00150 /// format used for encoding pointers in exception handling data. Reason is
00151 /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
00152 /// if the symbol can be relocated.
00153 unsigned
00154 PPCLinuxTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
00155                                              bool Global) const {
00156   // We really need to write something here.
00157   return TargetAsmInfo::PreferredEHDataFormat(Reason, Global);
00158 }
00159 
00160 // Instantiate default implementation.
00161 TEMPLATE_INSTANTIATION(class PPCTargetAsmInfo<TargetAsmInfo>);