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