blob: 5d080b425f7dd3c9fa99e6312573223a3d950095 [file] [log] [blame]
Chris Lattner40412e72009-07-27 16:45:59 +00001//===-- COFFTargetAsmInfo.cpp - COFF asm properties -------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines target asm properties related what form asm statements
11// should take in general on COFF-based targets
12//
13//===----------------------------------------------------------------------===//
14
15#include "llvm/Target/COFFTargetAsmInfo.h"
16#include "llvm/ADT/SmallVector.h"
17using namespace llvm;
18
19COFFTargetAsmInfo::COFFTargetAsmInfo(const TargetMachine &TM)
20 : TargetAsmInfo(TM) {
21
22 TextSection = getOrCreateSection("_text", true, SectionKind::Text);
23 DataSection = getOrCreateSection("_data", true, SectionKind::DataRel);
24
25 GlobalPrefix = "_";
26 LCOMMDirective = "\t.lcomm\t";
27 COMMDirectiveTakesAlignment = false;
28 HasDotTypeDotSizeDirective = false;
29 HasSingleParameterDotFile = false;
30 StaticCtorsSection = "\t.section .ctors,\"aw\"";
31 StaticDtorsSection = "\t.section .dtors,\"aw\"";
32 HiddenDirective = NULL;
33 PrivateGlobalPrefix = "L"; // Prefix for private global symbols
34 WeakRefDirective = "\t.weak\t";
35 SetDirective = "\t.set\t";
36
37 // Set up DWARF directives
38 HasLEB128 = true; // Target asm supports leb128 directives (little-endian)
39 AbsoluteDebugSectionOffsets = true;
40 AbsoluteEHSectionOffsets = false;
41 SupportsDebugInformation = true;
42 DwarfSectionOffsetDirective = "\t.secrel32\t";
43 DwarfAbbrevSection = "\t.section\t.debug_abbrev,\"dr\"";
44 DwarfInfoSection = "\t.section\t.debug_info,\"dr\"";
45 DwarfLineSection = "\t.section\t.debug_line,\"dr\"";
46 DwarfFrameSection = "\t.section\t.debug_frame,\"dr\"";
47 DwarfPubNamesSection ="\t.section\t.debug_pubnames,\"dr\"";
48 DwarfPubTypesSection ="\t.section\t.debug_pubtypes,\"dr\"";
49 DwarfStrSection = "\t.section\t.debug_str,\"dr\"";
50 DwarfLocSection = "\t.section\t.debug_loc,\"dr\"";
51 DwarfARangesSection = "\t.section\t.debug_aranges,\"dr\"";
52 DwarfRangesSection = "\t.section\t.debug_ranges,\"dr\"";
53 DwarfMacroInfoSection = "\t.section\t.debug_macinfo,\"dr\"";
54}
55
56const char *COFFTargetAsmInfo::
57getSectionPrefixForUniqueGlobal(SectionKind Kind) const {
58 if (Kind.isText())
59 return ".text$linkonce";
60 if (Kind.isWriteable())
61 return ".data$linkonce";
62 return ".rdata$linkonce";
63}
64
65void COFFTargetAsmInfo::getSectionFlagsAsString(SectionKind Kind,
66 SmallVectorImpl<char> &Str) const {
67 // FIXME: Inefficient.
68 std::string Res = ",\"";
69 if (Kind.isText())
70 Res += 'x';
71 if (Kind.isWriteable())
72 Res += 'w';
73 Res += "\"";
74
75 Str.append(Res.begin(), Res.end());
76}