blob: 5ddd120d931b36236574eb9bf6a4b5e23ea77c6d [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
Chris Lattnerd8310522009-07-27 05:32:16 +000052const char *PPCDarwinTargetAsmInfo::getEHGlobalPrefix() const {
Rafael Espindola1a931842008-12-19 10:55:56 +000053 const PPCSubtarget* Subtarget = &TM.getSubtarget<PPCSubtarget>();
54 if (Subtarget->getDarwinVers() > 9)
55 return PrivateGlobalPrefix;
Chris Lattnerc51585b2009-07-26 19:23:28 +000056 return "";
Rafael Espindola1a931842008-12-19 10:55:56 +000057}
Anton Korobeynikov0aeac602008-02-27 23:49:15 +000058
Anton Korobeynikov894be4b2008-08-08 18:23:49 +000059PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) :
Anton Korobeynikov3829e8a2008-09-25 21:00:33 +000060 PPCTargetAsmInfo<ELFTargetAsmInfo>(TM) {
Dan Gohmanf17a25c2007-07-18 16:29:46 +000061 CommentString = "#";
62 GlobalPrefix = "";
Rafael Espindola1a931842008-12-19 10:55:56 +000063 PrivateGlobalPrefix = ".L";
Evan Chengbde1bfc2008-02-12 19:25:12 +000064 ConstantPoolSection = "\t.section .rodata.cst4\t";
65 JumpTableDataSection = ".section .rodata.cst4";
asl7e07ea52008-08-16 12:58:46 +000066 CStringSection = ".rodata.str";
Dan Gohmanf17a25c2007-07-18 16:29:46 +000067 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 Lewyckyc6583752007-11-04 17:32:10 +000071 BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
Nick Lewycky3246a9c2007-07-25 03:48:45 +000072
Nicolas Geoffray61864762007-12-21 12:19:44 +000073 // Debug Information
74 AbsoluteDebugSectionOffsets = true;
75 SupportsDebugInformation = true;
Nick Lewycky3246a9c2007-07-25 03:48:45 +000076 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 Lattnerecbf73b2009-06-18 23:31:37 +000086 DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
Nicolas Geoffray61864762007-12-21 12:19:44 +000087
Nicolas Geoffray61864762007-12-21 12:19:44 +000088 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 Gohmanf17a25c2007-07-18 16:29:46 +000099}
Anton Korobeynikov0aeac602008-02-27 23:49:15 +0000100
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 Korobeynikovd15bc312008-07-19 21:44:57 +0000105unsigned
106PPCLinuxTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
107 bool Global) const {
Anton Korobeynikov0aeac602008-02-27 23:49:15 +0000108 // We really need to write something here.
109 return TargetAsmInfo::PreferredEHDataFormat(Reason, Global);
110}
Anton Korobeynikov45d1b622008-10-05 08:53:29 +0000111
112// Instantiate default implementation.
113TEMPLATE_INSTANTIATION(class PPCTargetAsmInfo<TargetAsmInfo>);