1 //===-- TargetAsmInfo.cpp - Asm Info ---------------------------------------==//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by James M. Laskey and is distributed under
6 // the University of Illinois Open Source 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"),
35 PrivateGlobalPrefix("."),
36 JumpTableSpecialLabelPrefix(0),
37 GlobalVarAddrPrefix(""),
38 GlobalVarAddrSuffix(""),
39 FunctionAddrPrefix(""),
40 FunctionAddrSuffix(""),
41 PersonalityPrefix(""),
42 PersonalitySuffix(""),
43 NeedsIndirectEncoding(false),
44 InlineAsmStart("#APP"),
45 InlineAsmEnd("#NO_APP"),
47 ZeroDirective("\t.zero\t"),
48 ZeroDirectiveSuffix(0),
49 AsciiDirective("\t.ascii\t"),
50 AscizDirective("\t.asciz\t"),
51 Data8bitsDirective("\t.byte\t"),
52 Data16bitsDirective("\t.short\t"),
53 Data32bitsDirective("\t.long\t"),
54 Data64bitsDirective("\t.quad\t"),
55 AlignDirective("\t.align\t"),
56 AlignmentIsInBytes(true),
57 SwitchToSectionDirective("\t.section\t"),
58 TextSectionStartSuffix(""),
59 DataSectionStartSuffix(""),
60 SectionEndDirectiveSuffix(0),
61 ConstantPoolSection("\t.section .rodata"),
62 JumpTableDataSection("\t.section .rodata"),
63 JumpTableDirective(0),
65 StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
66 StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
67 FourByteConstantSection(0),
68 EightByteConstantSection(0),
69 SixteenByteConstantSection(0),
74 COMMDirective("\t.comm\t"),
75 COMMDirectiveTakesAlignment(true),
76 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),
88 DwarfSectionOffsetDirective(0),
89 DwarfAbbrevSection(".debug_abbrev"),
90 DwarfInfoSection(".debug_info"),
91 DwarfLineSection(".debug_line"),
92 DwarfFrameSection(".debug_frame"),
93 DwarfPubNamesSection(".debug_pubnames"),
94 DwarfPubTypesSection(".debug_pubtypes"),
95 DwarfStrSection(".debug_str"),
96 DwarfLocSection(".debug_loc"),
97 DwarfARangesSection(".debug_aranges"),
98 DwarfRangesSection(".debug_ranges"),
99 DwarfMacInfoSection(".debug_macinfo"),
100 DwarfEHFrameSection(".eh_frame"),
101 DwarfExceptionSection(".gcc_except_table"),
105 TargetAsmInfo::~TargetAsmInfo() {
108 /// Measure the specified inline asm to determine an approximation of its
110 /// Comments (which run till the next SeparatorChar or newline) do not
111 /// count as an instruction.
112 /// Any other non-whitespace text is considered an instruction, with
113 /// multiple instructions separated by SeparatorChar or newlines.
114 /// Variable-length instructions are not handled here; this function
115 /// may be overloaded in the target code to do that.
116 unsigned TargetAsmInfo::getInlineAsmLength(const char *Str
) const {
117 // Count the number of instructions in the asm.
118 bool atInsnStart
= true;
120 for (; *Str
; ++Str
) {
121 if (*Str
== '\n' || *Str
== SeparatorChar
)
123 if (atInsnStart
&& !isspace(*Str
)) {
124 Length
+= MaxInstLength
;
127 if (atInsnStart
&& strncmp(Str
, CommentString
, strlen(CommentString
))==0)