1 //===-- PPCTargetAsmInfo.cpp - PPC asm properties ---------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains the declarations of the DarwinTargetAsmInfo properties.
12 //===----------------------------------------------------------------------===//
14 #include "PPCTargetAsmInfo.h"
15 #include "PPCTargetMachine.h"
16 #include "llvm/Function.h"
17 #include "llvm/Support/Dwarf.h"
20 using namespace llvm::dwarf;
22 PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM) :
23 PPCTargetAsmInfo<DarwinTargetAsmInfo>(TM) {
26 ConstantPoolSection = "\t.const\t";
27 UsedDirective = "\t.no_dead_strip\t";
28 SupportsExceptionHandling = true;
31 ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
32 DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
33 GlobalEHDirective = "\t.globl\t";
34 SupportsWeakOmittedEHFrame = false;
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.
42 PPCDarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
44 if (Reason == DwarfEncoding::Functions && Global)
45 return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
46 else if (Reason == DwarfEncoding::CodeLabels || !Global)
47 return DW_EH_PE_pcrel;
49 return DW_EH_PE_absptr;
53 PPCDarwinTargetAsmInfo::getEHGlobalPrefix() const
55 const PPCSubtarget* Subtarget = &TM.getSubtarget<PPCSubtarget>();
56 if (Subtarget->getDarwinVers() > 9)
57 return PrivateGlobalPrefix;
62 PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) :
63 PPCTargetAsmInfo<ELFTargetAsmInfo>(TM) {
66 PrivateGlobalPrefix = ".L";
67 ConstantPoolSection = "\t.section .rodata.cst4\t";
68 JumpTableDataSection = ".section .rodata.cst4";
69 CStringSection = ".rodata.str";
70 StaticCtorsSection = ".section\t.ctors,\"aw\",@progbits";
71 StaticDtorsSection = ".section\t.dtors,\"aw\",@progbits";
72 UsedDirective = "\t# .no_dead_strip\t";
73 WeakRefDirective = "\t.weak\t";
74 BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
76 // PPC/Linux normally uses named section for BSS.
77 BSSSection_ = getNamedSection("\t.bss",
78 SectionFlags::Writeable | SectionFlags::BSS,
82 AbsoluteDebugSectionOffsets = true;
83 SupportsDebugInformation = true;
84 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
85 DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
86 DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits";
87 DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits";
88 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
89 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
90 DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits";
91 DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits";
92 DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
93 DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
94 DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
98 // Set up DWARF directives
99 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
101 // Exceptions handling
102 if (!TM.getSubtargetImpl()->isPPC64())
103 SupportsExceptionHandling = true;
104 AbsoluteEHSectionOffsets = false;
105 DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
106 DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
109 /// PreferredEHDataFormat - This hook allows the target to select data
110 /// format used for encoding pointers in exception handling data. Reason is
111 /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
112 /// if the symbol can be relocated.
114 PPCLinuxTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
116 // We really need to write something here.
117 return TargetAsmInfo::PreferredEHDataFormat(Reason, Global);
120 // Instantiate default implementation.
121 TEMPLATE_INSTANTIATION(class PPCTargetAsmInfo<TargetAsmInfo>);