blob: f66d0ffbed027712a1313eac3e396fa5e57066ba [file] [log] [blame]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00001//===-- TargetAsmInfo.cpp - Asm Info ---------------------------------------==//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner081ce942007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007//
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"
Anton Korobeynikov65c0d872008-02-27 23:33:50 +000016#include "llvm/Support/Dwarf.h"
Dan Gohmanf17a25c2007-07-18 16:29:46 +000017#include <cctype>
18#include <cstring>
19
20using namespace llvm;
21
22TargetAsmInfo::TargetAsmInfo() :
23 TextSection("\t.text"),
24 DataSection("\t.data"),
25 BSSSection("\t.bss"),
26 TLSDataSection("\t.section .tdata,\"awT\",@progbits"),
27 TLSBSSSection("\t.section .tbss,\"awT\",@nobits"),
28 ZeroFillDirective(0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000029 NeedsSet(false),
30 MaxInstLength(4),
31 PCSymbol("$"),
32 SeparatorChar(';'),
33 CommentString("#"),
34 GlobalPrefix(""),
35 PrivateGlobalPrefix("."),
36 JumpTableSpecialLabelPrefix(0),
37 GlobalVarAddrPrefix(""),
38 GlobalVarAddrSuffix(""),
39 FunctionAddrPrefix(""),
40 FunctionAddrSuffix(""),
Bill Wendlingd1bda4f2007-09-11 08:27:17 +000041 PersonalityPrefix(""),
42 PersonalitySuffix(""),
Bill Wendling2d369922007-09-11 17:20:55 +000043 NeedsIndirectEncoding(false),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000044 InlineAsmStart("#APP"),
45 InlineAsmEnd("#NO_APP"),
46 AssemblerDialect(0),
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),
64 CStringSection(0),
65 StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
66 StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
67 FourByteConstantSection(0),
68 EightByteConstantSection(0),
69 SixteenByteConstantSection(0),
70 ReadOnlySection(0),
Gordon Henriksene383f2a2007-12-23 20:58:16 +000071 GlobalDirective("\t.globl\t"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000072 SetDirective(0),
73 LCOMMDirective(0),
74 COMMDirective("\t.comm\t"),
75 COMMDirectiveTakesAlignment(true),
76 HasDotTypeDotSizeDirective(true),
77 UsedDirective(0),
78 WeakRefDirective(0),
Dale Johannesenfb3ac732007-11-20 23:24:42 +000079 WeakDefDirective(0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000080 HiddenDirective("\t.hidden\t"),
81 ProtectedDirective("\t.protected\t"),
82 AbsoluteDebugSectionOffsets(false),
83 AbsoluteEHSectionOffsets(false),
84 HasLEB128(false),
Dan Gohman307ad202007-09-24 21:09:53 +000085 HasDotLocAndDotFile(false),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000086 SupportsDebugInformation(false),
87 SupportsExceptionHandling(false),
88 DwarfRequiresFrameSection(true),
Dale Johannesen23b89a62007-11-21 00:45:00 +000089 GlobalEHDirective(0),
Dale Johannesenf09b5992008-01-10 02:03:30 +000090 SupportsWeakOmittedEHFrame(true),
Dale Johannesenbc56bc32008-01-15 23:25:27 +000091 ShortenEHDataOn64Bit(false),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000092 DwarfSectionOffsetDirective(0),
93 DwarfAbbrevSection(".debug_abbrev"),
94 DwarfInfoSection(".debug_info"),
95 DwarfLineSection(".debug_line"),
96 DwarfFrameSection(".debug_frame"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000097 DwarfPubNamesSection(".debug_pubnames"),
98 DwarfPubTypesSection(".debug_pubtypes"),
99 DwarfStrSection(".debug_str"),
100 DwarfLocSection(".debug_loc"),
101 DwarfARangesSection(".debug_aranges"),
102 DwarfRangesSection(".debug_ranges"),
103 DwarfMacInfoSection(".debug_macinfo"),
104 DwarfEHFrameSection(".eh_frame"),
105 DwarfExceptionSection(".gcc_except_table"),
106 AsmTransCBE(0) {
107}
108
109TargetAsmInfo::~TargetAsmInfo() {
110}
111
112/// Measure the specified inline asm to determine an approximation of its
113/// length.
114/// Comments (which run till the next SeparatorChar or newline) do not
115/// count as an instruction.
116/// Any other non-whitespace text is considered an instruction, with
117/// multiple instructions separated by SeparatorChar or newlines.
118/// Variable-length instructions are not handled here; this function
119/// may be overloaded in the target code to do that.
120unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
121 // Count the number of instructions in the asm.
122 bool atInsnStart = true;
123 unsigned Length = 0;
124 for (; *Str; ++Str) {
125 if (*Str == '\n' || *Str == SeparatorChar)
126 atInsnStart = true;
127 if (atInsnStart && !isspace(*Str)) {
128 Length += MaxInstLength;
129 atInsnStart = false;
130 }
131 if (atInsnStart && strncmp(Str, CommentString, strlen(CommentString))==0)
132 atInsnStart = false;
133 }
134
135 return Length;
136}
137
Anton Korobeynikov65c0d872008-02-27 23:33:50 +0000138unsigned TargetAsmInfo::PreferredEHDataFormat(unsigned Reason,
139 bool Global) const {
140 return dwarf::DW_EH_PE_absptr;
141}
142