blob: c85dddf1bff7967f9918921e98bf7c6113e8c0f3 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- PPCTargetAsmInfo.cpp - PPC asm properties ---------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
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 Korobeynikov0aeac602008-02-27 23:49:15 +000017#include "llvm/Support/Dwarf.h"
18
Dan Gohmanf17a25c2007-07-18 16:29:46 +000019using namespace llvm;
Anton Korobeynikov0aeac602008-02-27 23:49:15 +000020using namespace llvm::dwarf;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000021
Chris Lattnerca072172009-06-19 00:08:39 +000022PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM) :
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000023 PPCTargetAsmInfo<DarwinTargetAsmInfo>(TM) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000024 PCSymbol = ".";
25 CommentString = ";";
Dan Gohmanf17a25c2007-07-18 16:29:46 +000026 ConstantPoolSection = "\t.const\t";
Dan Gohmanf17a25c2007-07-18 16:29:46 +000027 UsedDirective = "\t.no_dead_strip\t";
Dale Johannesen15e8f532007-12-19 21:54:36 +000028 SupportsExceptionHandling = true;
Nicolas Geoffray61864762007-12-21 12:19:44 +000029
30 DwarfEHFrameSection =
Chris Lattnerca072172009-06-19 00:08:39 +000031 ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
Nicolas Geoffray61864762007-12-21 12:19:44 +000032 DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
Dale Johannesenf09b5992008-01-10 02:03:30 +000033 GlobalEHDirective = "\t.globl\t";
34 SupportsWeakOmittedEHFrame = false;
Dan Gohmanf17a25c2007-07-18 16:29:46 +000035}
36
Anton Korobeynikov0aeac602008-02-27 23:49:15 +000037/// 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 Korobeynikovd15bc312008-07-19 21:44:57 +000041unsigned
42PPCDarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
43 bool Global) const {
Anton Korobeynikov8750d7c2008-02-29 22:09:08 +000044 if (Reason == DwarfEncoding::Functions && Global)
Anton Korobeynikov0aeac602008-02-27 23:49:15 +000045 return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
Anton Korobeynikov8750d7c2008-02-29 22:09:08 +000046 else if (Reason == DwarfEncoding::CodeLabels || !Global)
Anton Korobeynikov0aeac602008-02-27 23:49:15 +000047 return DW_EH_PE_pcrel;
48 else
49 return DW_EH_PE_absptr;
50}
51
Rafael Espindola1a931842008-12-19 10:55:56 +000052const char *
Chris Lattnerc51585b2009-07-26 19:23:28 +000053PPCDarwinTargetAsmInfo::getEHGlobalPrefix() const {
Rafael Espindola1a931842008-12-19 10:55:56 +000054 const PPCSubtarget* Subtarget = &TM.getSubtarget<PPCSubtarget>();
55 if (Subtarget->getDarwinVers() > 9)
56 return PrivateGlobalPrefix;
Chris Lattnerc51585b2009-07-26 19:23:28 +000057 return "";
Rafael Espindola1a931842008-12-19 10:55:56 +000058}
Anton Korobeynikov0aeac602008-02-27 23:49:15 +000059
Anton Korobeynikov894be4b2008-08-08 18:23:49 +000060PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) :
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000061 PPCTargetAsmInfo<ELFTargetAsmInfo>(TM) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000062 CommentString = "#";
63 GlobalPrefix = "";
Rafael Espindola1a931842008-12-19 10:55:56 +000064 PrivateGlobalPrefix = ".L";
Evan Chengbde1bfc2008-02-12 19:25:12 +000065 ConstantPoolSection = "\t.section .rodata.cst4\t";
66 JumpTableDataSection = ".section .rodata.cst4";
asl7e07ea52008-08-16 12:58:46 +000067 CStringSection = ".rodata.str";
Dan Gohmanf17a25c2007-07-18 16:29:46 +000068 StaticCtorsSection = ".section\t.ctors,\"aw\",@progbits";
69 StaticDtorsSection = ".section\t.dtors,\"aw\",@progbits";
70 UsedDirective = "\t# .no_dead_strip\t";
71 WeakRefDirective = "\t.weak\t";
Nick Lewyckyc6583752007-11-04 17:32:10 +000072 BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
Nick Lewycky3246a9c2007-07-25 03:48:45 +000073
asl4d8bcfd2008-08-16 12:59:02 +000074 // PPC/Linux normally uses named section for BSS.
Chris Lattnerc51585b2009-07-26 19:23:28 +000075 BSSSection_ = getNamedSection("\t.bss",
76 SectionFlags::Writable | SectionFlags::BSS);
asl4d8bcfd2008-08-16 12:59:02 +000077
Nicolas Geoffray61864762007-12-21 12:19:44 +000078 // Debug Information
79 AbsoluteDebugSectionOffsets = true;
80 SupportsDebugInformation = true;
Nick Lewycky3246a9c2007-07-25 03:48:45 +000081 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"\",@progbits";
82 DwarfInfoSection = "\t.section\t.debug_info,\"\",@progbits";
83 DwarfLineSection = "\t.section\t.debug_line,\"\",@progbits";
84 DwarfFrameSection = "\t.section\t.debug_frame,\"\",@progbits";
85 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"\",@progbits";
86 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"\",@progbits";
87 DwarfStrSection = "\t.section\t.debug_str,\"\",@progbits";
88 DwarfLocSection = "\t.section\t.debug_loc,\"\",@progbits";
89 DwarfARangesSection = "\t.section\t.debug_aranges,\"\",@progbits";
90 DwarfRangesSection = "\t.section\t.debug_ranges,\"\",@progbits";
Chris Lattnerecbf73b2009-06-18 23:31:37 +000091 DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
Nicolas Geoffray61864762007-12-21 12:19:44 +000092
Nicolas Geoffray61864762007-12-21 12:19:44 +000093 PCSymbol = ".";
94
95 // Set up DWARF directives
96 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
97
98 // Exceptions handling
99 if (!TM.getSubtargetImpl()->isPPC64())
100 SupportsExceptionHandling = true;
101 AbsoluteEHSectionOffsets = false;
102 DwarfEHFrameSection = "\t.section\t.eh_frame,\"aw\",@progbits";
103 DwarfExceptionSection = "\t.section\t.gcc_except_table,\"a\",@progbits";
Dan Gohmanf17a25c2007-07-18 16:29:46 +0000104}
Anton Korobeynikov0aeac602008-02-27 23:49:15 +0000105
106/// PreferredEHDataFormat - This hook allows the target to select data
107/// format used for encoding pointers in exception handling data. Reason is
108/// 0 for data, 1 for code labels, 2 for function pointers. Global is true
109/// if the symbol can be relocated.
Anton Korobeynikovd15bc312008-07-19 21:44:57 +0000110unsigned
111PPCLinuxTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
112 bool Global) const {
Anton Korobeynikov0aeac602008-02-27 23:49:15 +0000113 // We really need to write something here.
114 return TargetAsmInfo::PreferredEHDataFormat(Reason, Global);
115}
Anton Korobeynikov45d1b622008-10-05 08:53:29 +0000116
117// Instantiate default implementation.
118TEMPLATE_INSTANTIATION(class PPCTargetAsmInfo<TargetAsmInfo>);