blob: d56a92147cecf2be0ed512c1be3e9f5021b15aa5 [file] [log] [blame]
Jim Laskey8e8de8f2006-09-07 22:05:02 +00001//===-- PPCTargetAsmInfo.cpp - PPC asm properties ---------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Jim Laskey8e8de8f2006-09-07 22:05:02 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file contains the declarations of the DarwinTargetAsmInfo properties.
11//
12//===----------------------------------------------------------------------===//
13
14#include "PPCTargetAsmInfo.h"
15#include "PPCTargetMachine.h"
Chris Lattnerb56dcc42006-10-05 00:35:50 +000016#include "llvm/Function.h"
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +000017#include "llvm/Support/Dwarf.h"
18
Jim Laskey8e8de8f2006-09-07 22:05:02 +000019using namespace llvm;
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +000020using namespace llvm::dwarf;
Jim Laskey8e8de8f2006-09-07 22:05:02 +000021
Chris Lattner4e0f25b2009-06-19 00:08:39 +000022PPCDarwinTargetAsmInfo::PPCDarwinTargetAsmInfo(const PPCTargetMachine &TM) :
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000023 PPCTargetAsmInfo<DarwinTargetAsmInfo>(TM) {
Jim Laskeyb82313f2007-02-01 16:31:34 +000024 PCSymbol = ".";
Jim Laskeybf111822006-12-21 20:26:09 +000025 CommentString = ";";
Jim Laskeybf111822006-12-21 20:26:09 +000026 ConstantPoolSection = "\t.const\t";
Jim Laskeybf111822006-12-21 20:26:09 +000027 UsedDirective = "\t.no_dead_strip\t";
Dale Johannesen696f7682007-12-19 21:54:36 +000028 SupportsExceptionHandling = true;
Nicolas Geoffray616585b2007-12-21 12:19:44 +000029
30 DwarfEHFrameSection =
Chris Lattner4e0f25b2009-06-19 00:08:39 +000031 ".section __TEXT,__eh_frame,coalesced,no_toc+strip_static_syms+live_support";
Nicolas Geoffray616585b2007-12-21 12:19:44 +000032 DwarfExceptionSection = ".section __DATA,__gcc_except_tab";
Dale Johannesen038129d2008-01-10 02:03:30 +000033 GlobalEHDirective = "\t.globl\t";
34 SupportsWeakOmittedEHFrame = false;
Jim Laskeybf111822006-12-21 20:26:09 +000035}
36
Anton Korobeynikov7b1b7f52008-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 Korobeynikovbadd8df2008-07-19 21:44:57 +000041unsigned
42PPCDarwinTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
43 bool Global) const {
Anton Korobeynikov8213f9c2008-02-29 22:09:08 +000044 if (Reason == DwarfEncoding::Functions && Global)
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +000045 return (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4);
Anton Korobeynikov8213f9c2008-02-29 22:09:08 +000046 else if (Reason == DwarfEncoding::CodeLabels || !Global)
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +000047 return DW_EH_PE_pcrel;
48 else
49 return DW_EH_PE_absptr;
50}
51
Chris Lattner5fe575f2009-07-27 05:32:16 +000052const char *PPCDarwinTargetAsmInfo::getEHGlobalPrefix() const {
Rafael Espindola2f6fea92008-12-19 10:55:56 +000053 const PPCSubtarget* Subtarget = &TM.getSubtarget<PPCSubtarget>();
54 if (Subtarget->getDarwinVers() > 9)
55 return PrivateGlobalPrefix;
Chris Lattner0fcf4dc2009-07-26 19:23:28 +000056 return "";
Rafael Espindola2f6fea92008-12-19 10:55:56 +000057}
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +000058
Anton Korobeynikov7396e592008-08-08 18:23:49 +000059PPCLinuxTargetAsmInfo::PPCLinuxTargetAsmInfo(const PPCTargetMachine &TM) :
Anton Korobeynikov32b952a2008-09-25 21:00:33 +000060 PPCTargetAsmInfo<ELFTargetAsmInfo>(TM) {
Jim Laskeybf111822006-12-21 20:26:09 +000061 CommentString = "#";
62 GlobalPrefix = "";
Rafael Espindola2f6fea92008-12-19 10:55:56 +000063 PrivateGlobalPrefix = ".L";
Evan Cheng394d2802008-02-12 19:25:12 +000064 ConstantPoolSection = "\t.section .rodata.cst4\t";
65 JumpTableDataSection = ".section .rodata.cst4";
Anton Korobeynikov888839e2008-08-16 12:58:46 +000066 CStringSection = ".rodata.str";
Jim Laskeybf111822006-12-21 20:26:09 +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 Lewyckyf4c164c2007-11-04 17:32:10 +000071 BSSSection = "\t.section\t\".sbss\",\"aw\",@nobits";
Nick Lewyckye2b90522007-07-25 03:48:45 +000072
Anton Korobeynikovafc20ae2008-08-16 12:59:02 +000073 // PPC/Linux normally uses named section for BSS.
Chris Lattner5fe575f2009-07-27 05:32:16 +000074 BSSSection_ = getNamedSection("\t.bss", SectionKind::BSS);
Anton Korobeynikovafc20ae2008-08-16 12:59:02 +000075
Nicolas Geoffray616585b2007-12-21 12:19:44 +000076 // Debug Information
77 AbsoluteDebugSectionOffsets = true;
78 SupportsDebugInformation = true;
Nick Lewyckye2b90522007-07-25 03:48:45 +000079 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";
Chris Lattnerb839c3f2009-06-18 23:31:37 +000089 DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"\",@progbits";
Nicolas Geoffray616585b2007-12-21 12:19:44 +000090
Nicolas Geoffray616585b2007-12-21 12:19:44 +000091 PCSymbol = ".";
92
93 // Set up DWARF directives
94 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
95
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";
Jim Laskeybf111822006-12-21 20:26:09 +0000102}
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +0000103
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.
Anton Korobeynikovbadd8df2008-07-19 21:44:57 +0000108unsigned
109PPCLinuxTargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
110 bool Global) const {
Anton Korobeynikov7b1b7f52008-02-27 23:49:15 +0000111 // We really need to write something here.
112 return TargetAsmInfo::PreferredEHDataFormat(Reason, Global);
113}
Anton Korobeynikov6381a132008-10-05 08:53:29 +0000114
115// Instantiate default implementation.
116TEMPLATE_INSTANTIATION(class PPCTargetAsmInfo<TargetAsmInfo>);