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