blob: fd2e6fbbc11ad57339b0c3444c365cbf677d6678 [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- TargetAsmInfo.cpp - Asm Info ---------------------------------------==//
2//
3// The LLVM Compiler Infrastructure
4//
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.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file defines target asm properties related what form asm statements
11// should take.
12//
13//===----------------------------------------------------------------------===//
14
15#include "llvm/Target/TargetAsmInfo.h"
16#include <cctype>
17#include <cstring>
18
19using namespace llvm;
20
21TargetAsmInfo::TargetAsmInfo() :
22 TextSection("\t.text"),
23 DataSection("\t.data"),
24 BSSSection("\t.bss"),
25 TLSDataSection("\t.section .tdata,\"awT\",@progbits"),
26 TLSBSSSection("\t.section .tbss,\"awT\",@nobits"),
27 ZeroFillDirective(0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000028 NeedsSet(false),
29 MaxInstLength(4),
30 PCSymbol("$"),
31 SeparatorChar(';'),
32 CommentString("#"),
33 GlobalPrefix(""),
34 PrivateGlobalPrefix("."),
35 JumpTableSpecialLabelPrefix(0),
36 GlobalVarAddrPrefix(""),
37 GlobalVarAddrSuffix(""),
38 FunctionAddrPrefix(""),
39 FunctionAddrSuffix(""),
Bill Wendlingd1bda4f2007-09-11 08:27:17 +000040 PersonalityPrefix(""),
41 PersonalitySuffix(""),
Bill Wendling2d369922007-09-11 17:20:55 +000042 NeedsIndirectEncoding(false),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000043 InlineAsmStart("#APP"),
44 InlineAsmEnd("#NO_APP"),
45 AssemblerDialect(0),
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),
63 CStringSection(0),
64 StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
65 StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
66 FourByteConstantSection(0),
67 EightByteConstantSection(0),
68 SixteenByteConstantSection(0),
69 ReadOnlySection(0),
70 GlobalDirective(0),
71 SetDirective(0),
72 LCOMMDirective(0),
73 COMMDirective("\t.comm\t"),
74 COMMDirectiveTakesAlignment(true),
75 HasDotTypeDotSizeDirective(true),
76 UsedDirective(0),
77 WeakRefDirective(0),
78 HiddenDirective("\t.hidden\t"),
79 ProtectedDirective("\t.protected\t"),
80 AbsoluteDebugSectionOffsets(false),
81 AbsoluteEHSectionOffsets(false),
82 HasLEB128(false),
Dan Gohman307ad202007-09-24 21:09:53 +000083 HasDotLocAndDotFile(false),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000084 SupportsDebugInformation(false),
85 SupportsExceptionHandling(false),
86 DwarfRequiresFrameSection(true),
87 DwarfSectionOffsetDirective(0),
88 DwarfAbbrevSection(".debug_abbrev"),
89 DwarfInfoSection(".debug_info"),
90 DwarfLineSection(".debug_line"),
91 DwarfFrameSection(".debug_frame"),
92 DwarfPubNamesSection(".debug_pubnames"),
93 DwarfPubTypesSection(".debug_pubtypes"),
94 DwarfStrSection(".debug_str"),
95 DwarfLocSection(".debug_loc"),
96 DwarfARangesSection(".debug_aranges"),
97 DwarfRangesSection(".debug_ranges"),
98 DwarfMacInfoSection(".debug_macinfo"),
99 DwarfEHFrameSection(".eh_frame"),
100 DwarfExceptionSection(".gcc_except_table"),
101 AsmTransCBE(0) {
102}
103
104TargetAsmInfo::~TargetAsmInfo() {
105}
106
107/// Measure the specified inline asm to determine an approximation of its
108/// length.
109/// Comments (which run till the next SeparatorChar or newline) do not
110/// count as an instruction.
111/// Any other non-whitespace text is considered an instruction, with
112/// multiple instructions separated by SeparatorChar or newlines.
113/// Variable-length instructions are not handled here; this function
114/// may be overloaded in the target code to do that.
115unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
116 // Count the number of instructions in the asm.
117 bool atInsnStart = true;
118 unsigned Length = 0;
119 for (; *Str; ++Str) {
120 if (*Str == '\n' || *Str == SeparatorChar)
121 atInsnStart = true;
122 if (atInsnStart && !isspace(*Str)) {
123 Length += MaxInstLength;
124 atInsnStart = false;
125 }
126 if (atInsnStart && strncmp(Str, CommentString, strlen(CommentString))==0)
127 atInsnStart = false;
128 }
129
130 return Length;
131}
132