Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 1 | //===-- PPCTargetAsmInfo.cpp - PPC asm properties ---------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 081ce94 | 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. |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +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" |
| 16 | #include "llvm/Function.h" |
Anton Korobeynikov | 0aeac60 | 2008-02-27 23:49:15 +0000 | [diff] [blame] | 17 | #include "llvm/Support/Dwarf.h" |
| 18 | |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 19 | using namespace llvm; |
Anton Korobeynikov | 0aeac60 | 2008-02-27 23:49:15 +0000 | [diff] [blame] | 20 | using namespace llvm::dwarf; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 21 | |
Chris Lattner | ca07217 | 2009-06-19 00:08:39 +0000 | [diff] [blame] | 22 | PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM) : |
Anton Korobeynikov | 3829e8a | 2008-09-25 21:00:33 +0000 | [diff] [blame] | 23 | PPCTargetAsmInfo<DarwinTargetAsmInfo>(TM) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 24 | PCSymbol = "."; |
| 25 | CommentString = ";"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 26 | ConstantPoolSection = "\t.const\t"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 27 | UsedDirective = "\t.no_dead_strip\t"; |
Dale Johannesen | 15e8f53 | 2007-12-19 21:54:36 +0000 | [diff] [blame] | 28 | SupportsExceptionHandling = true; |
Nicolas Geoffray | 6186476 | 2007-12-21 12:19:44 +0000 | [diff] [blame] | 29 | |
| 30 | DwarfEHFrameSection = |
Chris Lattner | ca07217 | 2009-06-19 00:08:39 +0000 | [diff] [blame] | 31 | ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support"; |
Nicolas Geoffray | 6186476 | 2007-12-21 12:19:44 +0000 | [diff] [blame] | 32 | DwarfExceptionSection = ".section __DATA,__gcc_except_tab"; |
Dale Johannesen | f09b599 | 2008-01-10 02:03:30 +0000 | [diff] [blame] | 33 | GlobalEHDirective = "\t.globl\t"; |
| 34 | SupportsWeakOmittedEHFrame = false; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 35 | } |
| 36 | |
Anton Korobeynikov | 0aeac60 | 2008-02-27 23:49:15 +0000 | [diff] [blame] | 37 | /// PreferredEHDataFormat - This hook allows the target to select data |
| 38 | /// format used for encoding pointers in exception handling data. Reason is |
| 39 | /// 0 for data, 1 for code labels, 2 for function pointers. Global is true |
| 40 | /// if the symbol can be relocated. |
Anton Korobeynikov | d15bc31 | 2008-07-19 21:44:57 +0000 | [diff] [blame] | 41 | unsigned |
| 42 | PPCDarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason, |
| 43 | bool Global) const { |
Anton Korobeynikov | 8750d7c | 2008-02-29 22:09:08 +0000 | [diff] [blame] | 44 | if (Reason == DwarfEncoding::Functions && Global) |
Anton Korobeynikov | 0aeac60 | 2008-02-27 23:49:15 +0000 | [diff] [blame] | 45 | return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4); |
Anton Korobeynikov | 8750d7c | 2008-02-29 22:09:08 +0000 | [diff] [blame] | 46 | else if (Reason == DwarfEncoding::CodeLabels || !Global) |
Anton Korobeynikov | 0aeac60 | 2008-02-27 23:49:15 +0000 | [diff] [blame] | 47 | return DW_EH_PE_pcrel; |
| 48 | else |
| 49 | return DW_EH_PE_absptr; |
| 50 | } |
| 51 | |
Chris Lattner | d831052 | 2009-07-27 05:32:16 +0000 | [diff] [blame] | 52 | const char *PPCDarwinTargetAsmInfo::getEHGlobalPrefix() const { |
Rafael Espindola | 1a93184 | 2008-12-19 10:55:56 +0000 | [diff] [blame] | 53 | const PPCSubtarget* Subtarget = &TM.getSubtarget<PPCSubtarget>(); |
| 54 | if (Subtarget->getDarwinVers() > 9) |
| 55 | return PrivateGlobalPrefix; |
Chris Lattner | c51585b | 2009-07-26 19:23:28 +0000 | [diff] [blame] | 56 | return ""; |
Rafael Espindola | 1a93184 | 2008-12-19 10:55:56 +0000 | [diff] [blame] | 57 | } |
Anton Korobeynikov | 0aeac60 | 2008-02-27 23:49:15 +0000 | [diff] [blame] | 58 | |
Anton Korobeynikov | 894be4b | 2008-08-08 18:23:49 +0000 | [diff] [blame] | 59 | PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) : |
Anton Korobeynikov | 3829e8a | 2008-09-25 21:00:33 +0000 | [diff] [blame] | 60 | PPCTargetAsmInfo<ELFTargetAsmInfo>(TM) { |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 61 | CommentString = "#"; |
| 62 | GlobalPrefix = ""; |
Rafael Espindola | 1a93184 | 2008-12-19 10:55:56 +0000 | [diff] [blame] | 63 | PrivateGlobalPrefix = ".L"; |
Evan Cheng | bde1bfc | 2008-02-12 19:25:12 +0000 | [diff] [blame] | 64 | ConstantPoolSection = "\t.section .rodata.cst4\t"; |
| 65 | JumpTableDataSection = ".section .rodata.cst4"; |
asl | 7e07ea5 | 2008-08-16 12:58:46 +0000 | [diff] [blame] | 66 | CStringSection = ".rodata.str"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 67 | StaticCtorsSection = ".section\t.ctors,\"aw\",@progbits"; |
| 68 | StaticDtorsSection = ".section\t.dtors,\"aw\",@progbits"; |
| 69 | UsedDirective = "\t# .no_dead_strip\t"; |
| 70 | WeakRefDirective = "\t.weak\t"; |
Nick Lewycky | c658375 | 2007-11-04 17:32:10 +0000 | [diff] [blame] | 71 | BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits"; |
Nick Lewycky | 3246a9c | 2007-07-25 03:48:45 +0000 | [diff] [blame] | 72 | |
Nicolas Geoffray | 6186476 | 2007-12-21 12:19:44 +0000 | [diff] [blame] | 73 | // Debug Information |
| 74 | AbsoluteDebugSectionOffsets = true; |
| 75 | SupportsDebugInformation = true; |
Nick Lewycky | 3246a9c | 2007-07-25 03:48:45 +0000 | [diff] [blame] | 76 | DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits"; |
| 77 | DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits"; |
| 78 | DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits"; |
| 79 | DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits"; |
| 80 | DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits"; |
| 81 | DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits"; |
| 82 | DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits"; |
| 83 | DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits"; |
| 84 | DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits"; |
| 85 | DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits"; |
Chris Lattner | ecbf73b | 2009-06-18 23:31:37 +0000 | [diff] [blame] | 86 | DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits"; |
Nicolas Geoffray | 6186476 | 2007-12-21 12:19:44 +0000 | [diff] [blame] | 87 | |
Nicolas Geoffray | 6186476 | 2007-12-21 12:19:44 +0000 | [diff] [blame] | 88 | PCSymbol = "."; |
| 89 | |
| 90 | // Set up DWARF directives |
| 91 | HasLEB128 = true; // Target asm supports leb128 directives (little-endian) |
| 92 | |
| 93 | // Exceptions handling |
| 94 | if (!TM.getSubtargetImpl()->isPPC64()) |
| 95 | SupportsExceptionHandling = true; |
| 96 | AbsoluteEHSectionOffsets = false; |
| 97 | DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits"; |
| 98 | DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits"; |
Dan Gohman | f17a25c | 2007-07-18 16:29:46 +0000 | [diff] [blame] | 99 | } |
Anton Korobeynikov | 0aeac60 | 2008-02-27 23:49:15 +0000 | [diff] [blame] | 100 | |
| 101 | /// PreferredEHDataFormat - This hook allows the target to select data |
| 102 | /// format used for encoding pointers in exception handling data. Reason is |
| 103 | /// 0 for data, 1 for code labels, 2 for function pointers. Global is true |
| 104 | /// if the symbol can be relocated. |
Anton Korobeynikov | d15bc31 | 2008-07-19 21:44:57 +0000 | [diff] [blame] | 105 | unsigned |
| 106 | PPCLinuxTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason, |
| 107 | bool Global) const { |
Anton Korobeynikov | 0aeac60 | 2008-02-27 23:49:15 +0000 | [diff] [blame] | 108 | // We really need to write something here. |
| 109 | return TargetAsmInfo::PreferredEHDataFormat(Reason, Global); |
| 110 | } |
Anton Korobeynikov | 45d1b62 | 2008-10-05 08:53:29 +0000 | [diff] [blame] | 111 | |
| 112 | // Instantiate default implementation. |
| 113 | TEMPLATE_INSTANTIATION(class PPCTargetAsmInfo<TargetAsmInfo>); |