| Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 1 | //===-- PPCTargetAsmInfo.cpp - PPC asm properties ---------------*- C++ -*-===// | 
 | 2 | // | 
 | 3 | //                     The LLVM Compiler Infrastructure | 
 | 4 | // | 
| Chris Lattner | 4ee451d | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source | 
 | 6 | // License. See LICENSE.TXT for details. | 
| Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 7 | // | 
 | 8 | //===----------------------------------------------------------------------===// | 
 | 9 | // | 
 | 10 | // This file contains the declarations of the DarwinTargetAsmInfo properties. | 
 | 11 | // | 
 | 12 | //===----------------------------------------------------------------------===// | 
 | 13 |  | 
 | 14 | #include "PPCTargetAsmInfo.h" | 
 | 15 | #include "PPCTargetMachine.h" | 
| Chris Lattner | b56dcc4 | 2006-10-05 00:35:50 +0000 | [diff] [blame] | 16 | #include "llvm/Function.h" | 
| Anton Korobeynikov | 7b1b7f5 | 2008-02-27 23:49:15 +0000 | [diff] [blame] | 17 | #include "llvm/Support/Dwarf.h" | 
 | 18 |  | 
| Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 19 | using namespace llvm; | 
| Anton Korobeynikov | 7b1b7f5 | 2008-02-27 23:49:15 +0000 | [diff] [blame] | 20 | using namespace llvm::dwarf; | 
| Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 21 |  | 
| Jim Laskey | bf11182 | 2006-12-21 20:26:09 +0000 | [diff] [blame] | 22 | PPCTargetAsmInfo::PPCTargetAsmInfo(const PPCTargetMachine &TM) { | 
| Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 23 |   bool isPPC64 = TM.getSubtargetImpl()->isPPC64(); | 
| Anton Korobeynikov | bc331a8 | 2008-08-08 18:23:25 +0000 | [diff] [blame] | 24 |  | 
| Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 25 |   ZeroDirective = "\t.space\t"; | 
 | 26 |   SetDirective = "\t.set"; | 
| Jim Laskey | f45c25f | 2006-09-08 13:06:56 +0000 | [diff] [blame] | 27 |   Data64bitsDirective = isPPC64 ? "\t.quad\t" : 0;   | 
| Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 28 |   AlignmentIsInBytes = false; | 
| Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 29 |   LCOMMDirective = "\t.lcomm\t"; | 
| Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 30 |   InlineAsmStart = "# InlineAsm Start"; | 
 | 31 |   InlineAsmEnd = "# InlineAsm End"; | 
| Bill Wendling | cb90099 | 2007-01-16 09:29:17 +0000 | [diff] [blame] | 32 |   AssemblerDialect = TM.getSubtargetImpl()->getAsmFlavor(); | 
| Jim Laskey | 8e8de8f | 2006-09-07 22:05:02 +0000 | [diff] [blame] | 33 | } | 
| Chris Lattner | b56dcc4 | 2006-10-05 00:35:50 +0000 | [diff] [blame] | 34 |  | 
| Anton Korobeynikov | bc331a8 | 2008-08-08 18:23:25 +0000 | [diff] [blame] | 35 | PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM): | 
 | 36 |   PPCTargetAsmInfo(TM), DarwinTargetAsmInfo(TM) { | 
| Jim Laskey | b82313f | 2007-02-01 16:31:34 +0000 | [diff] [blame] | 37 |   PCSymbol = "."; | 
| Jim Laskey | bf11182 | 2006-12-21 20:26:09 +0000 | [diff] [blame] | 38 |   CommentString = ";"; | 
 | 39 |   GlobalPrefix = "_"; | 
 | 40 |   PrivateGlobalPrefix = "L"; | 
| Dale Johannesen | 428ac54 | 2008-06-03 18:09:06 +0000 | [diff] [blame] | 41 |   StringConstantPrefix = "\1LC"; | 
| Jim Laskey | bf11182 | 2006-12-21 20:26:09 +0000 | [diff] [blame] | 42 |   ConstantPoolSection = "\t.const\t"; | 
 | 43 |   JumpTableDataSection = ".const"; | 
 | 44 |   CStringSection = "\t.cstring"; | 
| Evan Cheng | 98ded76 | 2007-03-08 01:25:25 +0000 | [diff] [blame] | 45 |   FourByteConstantSection = "\t.literal4\n"; | 
 | 46 |   EightByteConstantSection = "\t.literal8\n"; | 
 | 47 |   ReadOnlySection = "\t.const\n"; | 
| Evan Cheng | b267ca1 | 2007-01-30 08:04:53 +0000 | [diff] [blame] | 48 |   if (TM.getRelocationModel() == Reloc::Static) { | 
 | 49 |     StaticCtorsSection = ".constructor"; | 
 | 50 |     StaticDtorsSection = ".destructor"; | 
 | 51 |   } else { | 
 | 52 |     StaticCtorsSection = ".mod_init_func"; | 
 | 53 |     StaticDtorsSection = ".mod_term_func"; | 
 | 54 |   } | 
| Dale Johannesen | 4af3494 | 2008-01-15 23:24:56 +0000 | [diff] [blame] | 55 |   SwitchToSectionDirective = "\t.section "; | 
| Jim Laskey | bf11182 | 2006-12-21 20:26:09 +0000 | [diff] [blame] | 56 |   UsedDirective = "\t.no_dead_strip\t"; | 
| Dale Johannesen | 038129d | 2008-01-10 02:03:30 +0000 | [diff] [blame] | 57 |   WeakDefDirective = "\t.weak_definition "; | 
 | 58 |   WeakRefDirective = "\t.weak_reference "; | 
| Dale Johannesen | c7406ae | 2008-01-11 00:54:37 +0000 | [diff] [blame] | 59 |   HiddenDirective = "\t.private_extern "; | 
| Dale Johannesen | 696f768 | 2007-12-19 21:54:36 +0000 | [diff] [blame] | 60 |   SupportsExceptionHandling = true; | 
| Bill Wendling | fe4afb1 | 2007-09-11 23:55:40 +0000 | [diff] [blame] | 61 |   NeedsIndirectEncoding = true; | 
| Nicolas Geoffray | 616585b | 2007-12-21 12:19:44 +0000 | [diff] [blame] | 62 |   NeedsSet = true; | 
| Nick Lewycky | f4c164c | 2007-11-04 17:32:10 +0000 | [diff] [blame] | 63 |   BSSSection = 0; | 
| Nicolas Geoffray | 616585b | 2007-12-21 12:19:44 +0000 | [diff] [blame] | 64 |    | 
 | 65 |   DwarfEHFrameSection = | 
 | 66 |   ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support"; | 
 | 67 |   DwarfExceptionSection = ".section __DATA,__gcc_except_tab"; | 
| Dale Johannesen | 038129d | 2008-01-10 02:03:30 +0000 | [diff] [blame] | 68 |   GlobalEHDirective = "\t.globl\t"; | 
 | 69 |   SupportsWeakOmittedEHFrame = false; | 
| Nick Lewycky | e2b9052 | 2007-07-25 03:48:45 +0000 | [diff] [blame] | 70 |  | 
 | 71 |   DwarfAbbrevSection = ".section __DWARF,__debug_abbrev,regular,debug"; | 
 | 72 |   DwarfInfoSection = ".section __DWARF,__debug_info,regular,debug"; | 
 | 73 |   DwarfLineSection = ".section __DWARF,__debug_line,regular,debug"; | 
 | 74 |   DwarfFrameSection = ".section __DWARF,__debug_frame,regular,debug"; | 
 | 75 |   DwarfPubNamesSection = ".section __DWARF,__debug_pubnames,regular,debug"; | 
 | 76 |   DwarfPubTypesSection = ".section __DWARF,__debug_pubtypes,regular,debug"; | 
 | 77 |   DwarfStrSection = ".section __DWARF,__debug_str,regular,debug"; | 
 | 78 |   DwarfLocSection = ".section __DWARF,__debug_loc,regular,debug"; | 
 | 79 |   DwarfARangesSection = ".section __DWARF,__debug_aranges,regular,debug"; | 
 | 80 |   DwarfRangesSection = ".section __DWARF,__debug_ranges,regular,debug"; | 
 | 81 |   DwarfMacInfoSection = ".section __DWARF,__debug_macinfo,regular,debug"; | 
| Chris Lattner | b266ccd | 2007-01-18 01:15:58 +0000 | [diff] [blame] | 82 |    | 
 | 83 |   // In non-PIC modes, emit a special label before jump tables so that the | 
 | 84 |   // linker can perform more accurate dead code stripping. | 
 | 85 |   if (TM.getRelocationModel() != Reloc::PIC_) { | 
 | 86 |     // Emit a local label that is preserved until the linker runs. | 
 | 87 |     JumpTableSpecialLabelPrefix = "l"; | 
 | 88 |   } | 
| Jim Laskey | bf11182 | 2006-12-21 20:26:09 +0000 | [diff] [blame] | 89 | } | 
 | 90 |  | 
| Anton Korobeynikov | 7b1b7f5 | 2008-02-27 23:49:15 +0000 | [diff] [blame] | 91 | /// PreferredEHDataFormat - This hook allows the target to select data | 
 | 92 | /// format used for encoding pointers in exception handling data. Reason is | 
 | 93 | /// 0 for data, 1 for code labels, 2 for function pointers. Global is true | 
 | 94 | /// if the symbol can be relocated. | 
| Anton Korobeynikov | badd8df | 2008-07-19 21:44:57 +0000 | [diff] [blame] | 95 | unsigned | 
 | 96 | PPCDarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason, | 
 | 97 |                                               bool Global) const { | 
| Anton Korobeynikov | 8213f9c | 2008-02-29 22:09:08 +0000 | [diff] [blame] | 98 |   if (Reason == DwarfEncoding::Functions && Global) | 
| Anton Korobeynikov | 7b1b7f5 | 2008-02-27 23:49:15 +0000 | [diff] [blame] | 99 |     return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4); | 
| Anton Korobeynikov | 8213f9c | 2008-02-29 22:09:08 +0000 | [diff] [blame] | 100 |   else if (Reason == DwarfEncoding::CodeLabels || !Global) | 
| Anton Korobeynikov | 7b1b7f5 | 2008-02-27 23:49:15 +0000 | [diff] [blame] | 101 |     return DW_EH_PE_pcrel; | 
 | 102 |   else | 
 | 103 |     return DW_EH_PE_absptr; | 
 | 104 | } | 
 | 105 |  | 
 | 106 |  | 
| Anton Korobeynikov | 7396e59 | 2008-08-08 18:23:49 +0000 | [diff] [blame] | 107 | PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) : | 
 | 108 |   PPCTargetAsmInfo(TM), ELFTargetAsmInfo(TM) { | 
| Jim Laskey | bf11182 | 2006-12-21 20:26:09 +0000 | [diff] [blame] | 109 |   CommentString = "#"; | 
 | 110 |   GlobalPrefix = ""; | 
 | 111 |   PrivateGlobalPrefix = ""; | 
| Evan Cheng | 394d280 | 2008-02-12 19:25:12 +0000 | [diff] [blame] | 112 |   ConstantPoolSection = "\t.section .rodata.cst4\t"; | 
 | 113 |   JumpTableDataSection = ".section .rodata.cst4"; | 
| Anton Korobeynikov | 888839e | 2008-08-16 12:58:46 +0000 | [diff] [blame] | 114 |   CStringSection = ".rodata.str"; | 
| Jim Laskey | bf11182 | 2006-12-21 20:26:09 +0000 | [diff] [blame] | 115 |   StaticCtorsSection = ".section\t.ctors,\"aw\",@progbits"; | 
 | 116 |   StaticDtorsSection = ".section\t.dtors,\"aw\",@progbits"; | 
 | 117 |   UsedDirective = "\t# .no_dead_strip\t"; | 
 | 118 |   WeakRefDirective = "\t.weak\t"; | 
| Nick Lewycky | f4c164c | 2007-11-04 17:32:10 +0000 | [diff] [blame] | 119 |   BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits"; | 
| Nick Lewycky | e2b9052 | 2007-07-25 03:48:45 +0000 | [diff] [blame] | 120 |  | 
| Anton Korobeynikov | afc20ae | 2008-08-16 12:59:02 +0000 | [diff] [blame^] | 121 |   // PPC/Linux normally uses named section for BSS. | 
 | 122 |   BSSSection_  = getNamedSection("\t.bss", | 
 | 123 |                                  SectionFlags::Writeable | SectionFlags::BSS, | 
 | 124 |                                  /* Override */ true); | 
 | 125 |  | 
| Nicolas Geoffray | 616585b | 2007-12-21 12:19:44 +0000 | [diff] [blame] | 126 |   // Debug Information | 
 | 127 |   AbsoluteDebugSectionOffsets = true; | 
 | 128 |   SupportsDebugInformation = true; | 
| Nick Lewycky | e2b9052 | 2007-07-25 03:48:45 +0000 | [diff] [blame] | 129 |   DwarfAbbrevSection =  "\t.section\t.debug_abbrev,\"\",@progbits"; | 
 | 130 |   DwarfInfoSection =    "\t.section\t.debug_info,\"\",@progbits"; | 
 | 131 |   DwarfLineSection =    "\t.section\t.debug_line,\"\",@progbits"; | 
 | 132 |   DwarfFrameSection =   "\t.section\t.debug_frame,\"\",@progbits"; | 
 | 133 |   DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits"; | 
 | 134 |   DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits"; | 
 | 135 |   DwarfStrSection =     "\t.section\t.debug_str,\"\",@progbits"; | 
 | 136 |   DwarfLocSection =     "\t.section\t.debug_loc,\"\",@progbits"; | 
 | 137 |   DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits"; | 
 | 138 |   DwarfRangesSection =  "\t.section\t.debug_ranges,\"\",@progbits"; | 
 | 139 |   DwarfMacInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits"; | 
| Nicolas Geoffray | 616585b | 2007-12-21 12:19:44 +0000 | [diff] [blame] | 140 |  | 
 | 141 |   ReadOnlySection = "\t.section\t.rodata"; | 
 | 142 |   FourByteConstantSection = "\t.section\t.rodata.cst4,\"aM\",@progbits,4"; | 
 | 143 |   EightByteConstantSection = "\t.section\t.rodata.cst8,\"aM\",@progbits,8"; | 
 | 144 |   SixteenByteConstantSection = "\t.section\t.rodata.cst16,\"aM\",@progbits,16"; | 
 | 145 |   PCSymbol = "."; | 
 | 146 |  | 
 | 147 |   // Set up DWARF directives | 
 | 148 |   HasLEB128 = true;  // Target asm supports leb128 directives (little-endian) | 
 | 149 |  | 
 | 150 |   // Exceptions handling | 
 | 151 |   if (!TM.getSubtargetImpl()->isPPC64()) | 
 | 152 |     SupportsExceptionHandling = true; | 
 | 153 |   AbsoluteEHSectionOffsets = false; | 
 | 154 |   DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits"; | 
 | 155 |   DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits"; | 
| Jim Laskey | bf11182 | 2006-12-21 20:26:09 +0000 | [diff] [blame] | 156 | } | 
| Anton Korobeynikov | 7b1b7f5 | 2008-02-27 23:49:15 +0000 | [diff] [blame] | 157 |  | 
 | 158 | /// PreferredEHDataFormat - This hook allows the target to select data | 
 | 159 | /// format used for encoding pointers in exception handling data. Reason is | 
 | 160 | /// 0 for data, 1 for code labels, 2 for function pointers. Global is true | 
 | 161 | /// if the symbol can be relocated. | 
| Anton Korobeynikov | badd8df | 2008-07-19 21:44:57 +0000 | [diff] [blame] | 162 | unsigned | 
 | 163 | PPCLinuxTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason, | 
 | 164 |                                              bool Global) const { | 
| Anton Korobeynikov | 7b1b7f5 | 2008-02-27 23:49:15 +0000 | [diff] [blame] | 165 |   // We really need to write something here. | 
 | 166 |   return TargetAsmInfo::PreferredEHDataFormat(Reason, Global); | 
 | 167 | } |