1 //===-- TargetAsmInfo.cpp - Asm Info ---------------------------------------==//
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 defines target asm properties related what form asm statements
13 //===----------------------------------------------------------------------===//
15 #include "llvm/Target/TargetAsmInfo.h"
16 #include "llvm/Support/Dwarf.h"
22 TargetAsmInfo::TargetAsmInfo() :
23 TextSection("\t.text"),
24 DataSection("\t.data"),
26 TLSDataSection("\t.section .tdata,\"awT\",@progbits"),
27 TLSBSSSection("\t.section .tbss,\"awT\",@nobits"),
29 NonexecutableStackDirective(0),
36 PrivateGlobalPrefix("."),
37 JumpTableSpecialLabelPrefix(0),
38 GlobalVarAddrPrefix(""),
39 GlobalVarAddrSuffix(""),
40 FunctionAddrPrefix(""),
41 FunctionAddrSuffix(""),
42 PersonalityPrefix(""),
43 PersonalitySuffix(""),
44 NeedsIndirectEncoding(false),
45 InlineAsmStart("#APP"),
46 InlineAsmEnd("#NO_APP"),
48 ZeroDirective("\t.zero\t"),
49 ZeroDirectiveSuffix(0),
50 AsciiDirective("\t.ascii\t"),
51 AscizDirective("\t.asciz\t"),
52 Data8bitsDirective("\t.byte\t"),
53 Data16bitsDirective("\t.short\t"),
54 Data32bitsDirective("\t.long\t"),
55 Data64bitsDirective("\t.quad\t"),
56 AlignDirective("\t.align\t"),
57 AlignmentIsInBytes(true),
58 TextAlignFillValue(0),
59 SwitchToSectionDirective("\t.section\t"),
60 TextSectionStartSuffix(""),
61 DataSectionStartSuffix(""),
62 SectionEndDirectiveSuffix(0),
63 ConstantPoolSection("\t.section .rodata"),
64 JumpTableDataSection("\t.section .rodata"),
65 JumpTableDirective(0),
67 StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
68 StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
69 FourByteConstantSection(0),
70 EightByteConstantSection(0),
71 SixteenByteConstantSection(0),
73 GlobalDirective("\t.globl\t"),
76 COMMDirective("\t.comm\t"),
77 COMMDirectiveTakesAlignment(true),
78 HasDotTypeDotSizeDirective(true),
82 HiddenDirective("\t.hidden\t"),
83 ProtectedDirective("\t.protected\t"),
84 AbsoluteDebugSectionOffsets(false),
85 AbsoluteEHSectionOffsets(false),
87 HasDotLocAndDotFile(false),
88 SupportsDebugInformation(false),
89 SupportsExceptionHandling(false),
90 DwarfRequiresFrameSection(true),
92 SupportsWeakOmittedEHFrame(true),
93 ShortenEHDataOn64Bit(false),
94 DwarfSectionOffsetDirective(0),
95 DwarfAbbrevSection(".debug_abbrev"),
96 DwarfInfoSection(".debug_info"),
97 DwarfLineSection(".debug_line"),
98 DwarfFrameSection(".debug_frame"),
99 DwarfPubNamesSection(".debug_pubnames"),
100 DwarfPubTypesSection(".debug_pubtypes"),
101 DwarfStrSection(".debug_str"),
102 DwarfLocSection(".debug_loc"),
103 DwarfARangesSection(".debug_aranges"),
104 DwarfRangesSection(".debug_ranges"),
105 DwarfMacInfoSection(".debug_macinfo"),
106 DwarfEHFrameSection(".eh_frame"),
107 DwarfExceptionSection(".gcc_except_table"),
111 TargetAsmInfo::~TargetAsmInfo() {
114 /// Measure the specified inline asm to determine an approximation of its
116 /// Comments (which run till the next SeparatorChar or newline) do not
117 /// count as an instruction.
118 /// Any other non-whitespace text is considered an instruction, with
119 /// multiple instructions separated by SeparatorChar or newlines.
120 /// Variable-length instructions are not handled here; this function
121 /// may be overloaded in the target code to do that.
122 unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
123 // Count the number of instructions in the asm.
124 bool atInsnStart = true;
126 for (; *Str; ++Str) {
127 if (*Str == '\n' || *Str == SeparatorChar)
129 if (atInsnStart && !isspace(*Str)) {
130 Length += MaxInstLength;
133 if (atInsnStart && strncmp(Str, CommentString, strlen(CommentString))==0)
140 unsigned TargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
142 return dwarf::DW_EH_PE_absptr;