blob: 5fa5abec8e9f48fdf22bd886a2a55a8c4d0ea6a2 [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 Gohmana65530a2008-05-05 00:28:39 +000029 NonexecutableStackDirective(0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000030 NeedsSet(false),
31 MaxInstLength(4),
32 PCSymbol("$"),
33 SeparatorChar(';'),
34 CommentString("#"),
35 GlobalPrefix(""),
36 PrivateGlobalPrefix("."),
37 JumpTableSpecialLabelPrefix(0),
38 GlobalVarAddrPrefix(""),
39 GlobalVarAddrSuffix(""),
40 FunctionAddrPrefix(""),
41 FunctionAddrSuffix(""),
Bill Wendlingd1bda4f2007-09-11 08:27:17 +000042 PersonalityPrefix(""),
43 PersonalitySuffix(""),
Bill Wendling2d369922007-09-11 17:20:55 +000044 NeedsIndirectEncoding(false),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000045 InlineAsmStart("#APP"),
46 InlineAsmEnd("#NO_APP"),
47 AssemblerDialect(0),
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),
Lauro Ramos Venancio9190bc42008-02-28 22:14:09 +000058 TextAlignFillValue(0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000059 SwitchToSectionDirective("\t.section\t"),
60 TextSectionStartSuffix(""),
61 DataSectionStartSuffix(""),
62 SectionEndDirectiveSuffix(0),
63 ConstantPoolSection("\t.section .rodata"),
64 JumpTableDataSection("\t.section .rodata"),
65 JumpTableDirective(0),
66 CStringSection(0),
67 StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
68 StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
69 FourByteConstantSection(0),
70 EightByteConstantSection(0),
71 SixteenByteConstantSection(0),
72 ReadOnlySection(0),
Gordon Henriksene383f2a2007-12-23 20:58:16 +000073 GlobalDirective("\t.globl\t"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000074 SetDirective(0),
75 LCOMMDirective(0),
76 COMMDirective("\t.comm\t"),
77 COMMDirectiveTakesAlignment(true),
78 HasDotTypeDotSizeDirective(true),
79 UsedDirective(0),
80 WeakRefDirective(0),
Dale Johannesenfb3ac732007-11-20 23:24:42 +000081 WeakDefDirective(0),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000082 HiddenDirective("\t.hidden\t"),
83 ProtectedDirective("\t.protected\t"),
84 AbsoluteDebugSectionOffsets(false),
85 AbsoluteEHSectionOffsets(false),
86 HasLEB128(false),
Dan Gohman307ad202007-09-24 21:09:53 +000087 HasDotLocAndDotFile(false),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000088 SupportsDebugInformation(false),
89 SupportsExceptionHandling(false),
90 DwarfRequiresFrameSection(true),
Dale Johannesen23b89a62007-11-21 00:45:00 +000091 GlobalEHDirective(0),
Dale Johannesenf09b5992008-01-10 02:03:30 +000092 SupportsWeakOmittedEHFrame(true),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000093 DwarfSectionOffsetDirective(0),
94 DwarfAbbrevSection(".debug_abbrev"),
95 DwarfInfoSection(".debug_info"),
96 DwarfLineSection(".debug_line"),
97 DwarfFrameSection(".debug_frame"),
Dan Gohmanf17a25c2007-07-18 16:29:46 +000098 DwarfPubNamesSection(".debug_pubnames"),
99 DwarfPubTypesSection(".debug_pubtypes"),
100 DwarfStrSection(".debug_str"),
101 DwarfLocSection(".debug_loc"),
102 DwarfARangesSection(".debug_aranges"),
103 DwarfRangesSection(".debug_ranges"),
104 DwarfMacInfoSection(".debug_macinfo"),
105 DwarfEHFrameSection(".eh_frame"),
106 DwarfExceptionSection(".gcc_except_table"),
107 AsmTransCBE(0) {
108}
109
110TargetAsmInfo::~TargetAsmInfo() {
111}
112
113/// Measure the specified inline asm to determine an approximation of its
114/// length.
115/// Comments (which run till the next SeparatorChar or newline) do not
116/// count as an instruction.
117/// Any other non-whitespace text is considered an instruction, with
118/// multiple instructions separated by SeparatorChar or newlines.
119/// Variable-length instructions are not handled here; this function
120/// may be overloaded in the target code to do that.
121unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
122 // Count the number of instructions in the asm.
123 bool atInsnStart = true;
124 unsigned Length = 0;
125 for (; *Str; ++Str) {
126 if (*Str == '\n' || *Str == SeparatorChar)
127 atInsnStart = true;
128 if (atInsnStart && !isspace(*Str)) {
129 Length += MaxInstLength;
130 atInsnStart = false;
131 }
132 if (atInsnStart && strncmp(Str, CommentString, strlen(CommentString))==0)
133 atInsnStart = false;
134 }
135
136 return Length;
137}
138
Anton Korobeynikov8750d7c2008-02-29 22:09:08 +0000139unsigned TargetAsmInfo::PreferredEHDataFormat(DwarfEncoding::Target Reason,
Anton Korobeynikov65c0d872008-02-27 23:33:50 +0000140 bool Global) const {
141 return dwarf::DW_EH_PE_absptr;
142}
143