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;
52 const char *PPCDarwinTargetAsmInfo::getEHGlobalPrefix() const {
53 const PPCSubtarget* Subtarget = &TM.getSubtarget<PPCSubtarget>();
54 if (Subtarget->getDarwinVers() > 9)
55 return PrivateGlobalPrefix;
59 PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) :
60 PPCTargetAsmInfo<ELFTargetAsmInfo>(TM) {
63 PrivateGlobalPrefix = ".L";
64 ConstantPoolSection = "\t.section .rodata.cst4\t";
65 JumpTableDataSection = ".section .rodata.cst4";
66 CStringSection = ".rodata.str";
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";
71 BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
73 // PPC/Linux normally uses named section for BSS.
74 BSSSection_ = getOrCreateSection("\t.bss", true, SectionKind::BSS);
77 AbsoluteDebugSectionOffsets = true;
78 SupportsDebugInformation = true;
79 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
80 DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
81 DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits";
82 DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits";
83 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
84 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
85 DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits";
86 DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits";
87 DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
88 DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
89 DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
93 // Set up DWARF directives
94 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
96 // Exceptions handling
97 if (!TM.getSubtargetImpl()->isPPC64())
98 SupportsExceptionHandling = true;
99 AbsoluteEHSectionOffsets = false;
100 DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
101 DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
104 /// PreferredEHDataFormat - This hook allows the target to select data
105 /// format used for encoding pointers in exception handling data. Reason is
106 /// 0 for data, 1 for code labels, 2 for function pointers. Global is true
107 /// if the symbol can be relocated.
109 PPCLinuxTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
111 // We really need to write something here.
112 return TargetAsmInfo::PreferredEHDataFormat(Reason, Global);
115 // Instantiate default implementation.
116 TEMPLATE_INSTANTIATION(class PPCTargetAsmInfo<TargetAsmInfo>);