blob: f66d0ffbed027712a1313eac3e396fa5e57066ba [file] [log] [blame]
Jim Laskey7c95ad42006-09-06 19:21:41 +00001//===-- TargetAsmInfo.cpp - Asm Info ---------------------------------------==//
Jim Laskeyec0d9fe2006-09-06 18:35:33 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Jim Laskeyec0d9fe2006-09-06 18:35:33 +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 Korobeynikovcee750f2008-02-27 23:33:50 +000016#include "llvm/Support/Dwarf.h"
Dale Johannesen3bb62832007-04-23 20:00:17 +000017#include <cctype>
18#include <cstring>
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000019
20using namespace llvm;
21
22TargetAsmInfo::TargetAsmInfo() :
Dan Gohman95701652007-05-03 18:46:30 +000023 TextSection("\t.text"),
24 DataSection("\t.data"),
25 BSSSection("\t.bss"),
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000026 TLSDataSection("\t.section .tdata,\"awT\",@progbits"),
27 TLSBSSSection("\t.section .tbss,\"awT\",@nobits"),
Chris Lattner6f198df2007-01-17 17:42:42 +000028 ZeroFillDirective(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000029 NeedsSet(false),
Chris Lattner4c7b07a2006-10-13 17:50:07 +000030 MaxInstLength(4),
Jim Laskeyb82313f2007-02-01 16:31:34 +000031 PCSymbol("$"),
Chris Lattner4c7b07a2006-10-13 17:50:07 +000032 SeparatorChar(';'),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000033 CommentString("#"),
34 GlobalPrefix(""),
35 PrivateGlobalPrefix("."),
Chris Lattner393a8ee2007-01-18 01:12:56 +000036 JumpTableSpecialLabelPrefix(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000037 GlobalVarAddrPrefix(""),
38 GlobalVarAddrSuffix(""),
39 FunctionAddrPrefix(""),
40 FunctionAddrSuffix(""),
Bill Wendlingd60da492007-09-11 08:27:17 +000041 PersonalityPrefix(""),
42 PersonalitySuffix(""),
Bill Wendlingef4a6612007-09-11 17:20:55 +000043 NeedsIndirectEncoding(false),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000044 InlineAsmStart("#APP"),
45 InlineAsmEnd("#NO_APP"),
Bill Wendlingeb9a42c2007-01-16 03:42:04 +000046 AssemblerDialect(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000047 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),
Dan Gohmanaf67ea72007-06-14 15:00:27 +000061 ConstantPoolSection("\t.section .rodata"),
62 JumpTableDataSection("\t.section .rodata"),
Andrew Lenharthbeec30e2006-09-24 19:45:58 +000063 JumpTableDirective(0),
Reid Spencerc50209b2006-10-27 16:14:06 +000064 CStringSection(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000065 StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
66 StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
67 FourByteConstantSection(0),
68 EightByteConstantSection(0),
69 SixteenByteConstantSection(0),
Evan Chengbe346c92007-03-08 01:00:38 +000070 ReadOnlySection(0),
Gordon Henriksen81361d62007-12-23 20:58:16 +000071 GlobalDirective("\t.globl\t"),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000072 SetDirective(0),
73 LCOMMDirective(0),
74 COMMDirective("\t.comm\t"),
75 COMMDirectiveTakesAlignment(true),
76 HasDotTypeDotSizeDirective(true),
Chris Lattnercb05af82006-09-26 03:38:18 +000077 UsedDirective(0),
Evan Cheng8752ce62006-12-01 20:47:11 +000078 WeakRefDirective(0),
Dale Johannesen1d4ce2a2007-11-20 23:24:42 +000079 WeakDefDirective(0),
Chris Lattner9784bc72007-01-14 06:27:21 +000080 HiddenDirective("\t.hidden\t"),
Anton Korobeynikov6f9896f2007-04-29 18:35:00 +000081 ProtectedDirective("\t.protected\t"),
Anton Korobeynikov79dda2b2007-05-01 22:23:12 +000082 AbsoluteDebugSectionOffsets(false),
83 AbsoluteEHSectionOffsets(false),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000084 HasLEB128(false),
Dan Gohman72252732007-09-24 21:09:53 +000085 HasDotLocAndDotFile(false),
Anton Korobeynikov2a07e2f2007-05-05 09:04:50 +000086 SupportsDebugInformation(false),
Jim Laskey072200c2007-01-29 18:51:14 +000087 SupportsExceptionHandling(false),
Reid Spencer02b85112006-10-30 22:32:30 +000088 DwarfRequiresFrameSection(true),
Dale Johannesen9305dcb2007-11-21 00:45:00 +000089 GlobalEHDirective(0),
Dale Johannesen038129d2008-01-10 02:03:30 +000090 SupportsWeakOmittedEHFrame(true),
Dale Johannesen0991d0b2008-01-15 23:25:27 +000091 ShortenEHDataOn64Bit(false),
Anton Korobeynikova6199c82007-03-07 02:47:57 +000092 DwarfSectionOffsetDirective(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000093 DwarfAbbrevSection(".debug_abbrev"),
94 DwarfInfoSection(".debug_info"),
95 DwarfLineSection(".debug_line"),
96 DwarfFrameSection(".debug_frame"),
97 DwarfPubNamesSection(".debug_pubnames"),
98 DwarfPubTypesSection(".debug_pubtypes"),
99 DwarfStrSection(".debug_str"),
100 DwarfLocSection(".debug_loc"),
101 DwarfARangesSection(".debug_aranges"),
102 DwarfRangesSection(".debug_ranges"),
Andrew Lenharth3655de62006-11-28 19:52:20 +0000103 DwarfMacInfoSection(".debug_macinfo"),
Jim Laskeyb82313f2007-02-01 16:31:34 +0000104 DwarfEHFrameSection(".eh_frame"),
Jim Laskeya15be8c2007-02-21 22:43:40 +0000105 DwarfExceptionSection(".gcc_except_table"),
Andrew Lenharth3655de62006-11-28 19:52:20 +0000106 AsmTransCBE(0) {
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000107}
Chris Lattnerf5b10ec2006-10-05 00:35:16 +0000108
109TargetAsmInfo::~TargetAsmInfo() {
110}
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000111
112/// Measure the specified inline asm to determine an approximation of its
113/// length.
Dale Johannesen3bb62832007-04-23 20:00:17 +0000114/// 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.
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000120unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
121 // Count the number of instructions in the asm.
Dale Johannesen3bb62832007-04-23 20:00:17 +0000122 bool atInsnStart = true;
123 unsigned Length = 0;
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000124 for (; *Str; ++Str) {
125 if (*Str == '\n' || *Str == SeparatorChar)
Dale Johannesen3bb62832007-04-23 20:00:17 +0000126 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;
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000133 }
134
Dale Johannesen3bb62832007-04-23 20:00:17 +0000135 return Length;
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000136}
Anton Korobeynikova6199c82007-03-07 02:47:57 +0000137
Anton Korobeynikovcee750f2008-02-27 23:33:50 +0000138unsigned TargetAsmInfo::PreferredEHDataFormat(unsigned Reason,
139 bool Global) const {
140 return dwarf::DW_EH_PE_absptr;
141}
142