blob: d7769bf11c526d633dff4f56e096c496d18ecdd3 [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"
Dale Johannesen3bb62832007-04-23 20:00:17 +000016#include <cctype>
17#include <cstring>
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000018
19using namespace llvm;
20
21TargetAsmInfo::TargetAsmInfo() :
Dan Gohman95701652007-05-03 18:46:30 +000022 TextSection("\t.text"),
23 DataSection("\t.data"),
24 BSSSection("\t.bss"),
Lauro Ramos Venanciob3a04172007-04-20 21:38:10 +000025 TLSDataSection("\t.section .tdata,\"awT\",@progbits"),
26 TLSBSSSection("\t.section .tbss,\"awT\",@nobits"),
Chris Lattner6f198df2007-01-17 17:42:42 +000027 ZeroFillDirective(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000028 NeedsSet(false),
Chris Lattner4c7b07a2006-10-13 17:50:07 +000029 MaxInstLength(4),
Jim Laskeyb82313f2007-02-01 16:31:34 +000030 PCSymbol("$"),
Chris Lattner4c7b07a2006-10-13 17:50:07 +000031 SeparatorChar(';'),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000032 CommentString("#"),
33 GlobalPrefix(""),
34 PrivateGlobalPrefix("."),
Chris Lattner393a8ee2007-01-18 01:12:56 +000035 JumpTableSpecialLabelPrefix(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000036 GlobalVarAddrPrefix(""),
37 GlobalVarAddrSuffix(""),
38 FunctionAddrPrefix(""),
39 FunctionAddrSuffix(""),
Bill Wendlingd60da492007-09-11 08:27:17 +000040 PersonalityPrefix(""),
41 PersonalitySuffix(""),
Bill Wendlingef4a6612007-09-11 17:20:55 +000042 NeedsIndirectEncoding(false),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000043 InlineAsmStart("#APP"),
44 InlineAsmEnd("#NO_APP"),
Bill Wendlingeb9a42c2007-01-16 03:42:04 +000045 AssemblerDialect(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000046 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),
Dan Gohmanaf67ea72007-06-14 15:00:27 +000060 ConstantPoolSection("\t.section .rodata"),
61 JumpTableDataSection("\t.section .rodata"),
Andrew Lenharthbeec30e2006-09-24 19:45:58 +000062 JumpTableDirective(0),
Reid Spencerc50209b2006-10-27 16:14:06 +000063 CStringSection(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000064 StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
65 StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
66 FourByteConstantSection(0),
67 EightByteConstantSection(0),
68 SixteenByteConstantSection(0),
Evan Chengbe346c92007-03-08 01:00:38 +000069 ReadOnlySection(0),
Gordon Henriksen81361d62007-12-23 20:58:16 +000070 GlobalDirective("\t.globl\t"),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000071 SetDirective(0),
72 LCOMMDirective(0),
73 COMMDirective("\t.comm\t"),
74 COMMDirectiveTakesAlignment(true),
75 HasDotTypeDotSizeDirective(true),
Chris Lattnercb05af82006-09-26 03:38:18 +000076 UsedDirective(0),
Evan Cheng8752ce62006-12-01 20:47:11 +000077 WeakRefDirective(0),
Dale Johannesen1d4ce2a2007-11-20 23:24:42 +000078 WeakDefDirective(0),
Chris Lattner9784bc72007-01-14 06:27:21 +000079 HiddenDirective("\t.hidden\t"),
Anton Korobeynikov6f9896f2007-04-29 18:35:00 +000080 ProtectedDirective("\t.protected\t"),
Anton Korobeynikov79dda2b2007-05-01 22:23:12 +000081 AbsoluteDebugSectionOffsets(false),
82 AbsoluteEHSectionOffsets(false),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000083 HasLEB128(false),
Dan Gohman72252732007-09-24 21:09:53 +000084 HasDotLocAndDotFile(false),
Anton Korobeynikov2a07e2f2007-05-05 09:04:50 +000085 SupportsDebugInformation(false),
Jim Laskey072200c2007-01-29 18:51:14 +000086 SupportsExceptionHandling(false),
Reid Spencer02b85112006-10-30 22:32:30 +000087 DwarfRequiresFrameSection(true),
Dale Johannesen9305dcb2007-11-21 00:45:00 +000088 GlobalEHDirective(0),
Anton Korobeynikova6199c82007-03-07 02:47:57 +000089 DwarfSectionOffsetDirective(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000090 DwarfAbbrevSection(".debug_abbrev"),
91 DwarfInfoSection(".debug_info"),
92 DwarfLineSection(".debug_line"),
93 DwarfFrameSection(".debug_frame"),
94 DwarfPubNamesSection(".debug_pubnames"),
95 DwarfPubTypesSection(".debug_pubtypes"),
96 DwarfStrSection(".debug_str"),
97 DwarfLocSection(".debug_loc"),
98 DwarfARangesSection(".debug_aranges"),
99 DwarfRangesSection(".debug_ranges"),
Andrew Lenharth3655de62006-11-28 19:52:20 +0000100 DwarfMacInfoSection(".debug_macinfo"),
Jim Laskeyb82313f2007-02-01 16:31:34 +0000101 DwarfEHFrameSection(".eh_frame"),
Jim Laskeya15be8c2007-02-21 22:43:40 +0000102 DwarfExceptionSection(".gcc_except_table"),
Andrew Lenharth3655de62006-11-28 19:52:20 +0000103 AsmTransCBE(0) {
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000104}
Chris Lattnerf5b10ec2006-10-05 00:35:16 +0000105
106TargetAsmInfo::~TargetAsmInfo() {
107}
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000108
109/// Measure the specified inline asm to determine an approximation of its
110/// length.
Dale Johannesen3bb62832007-04-23 20:00:17 +0000111/// Comments (which run till the next SeparatorChar or newline) do not
112/// count as an instruction.
113/// Any other non-whitespace text is considered an instruction, with
114/// multiple instructions separated by SeparatorChar or newlines.
115/// Variable-length instructions are not handled here; this function
116/// may be overloaded in the target code to do that.
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000117unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
118 // Count the number of instructions in the asm.
Dale Johannesen3bb62832007-04-23 20:00:17 +0000119 bool atInsnStart = true;
120 unsigned Length = 0;
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000121 for (; *Str; ++Str) {
122 if (*Str == '\n' || *Str == SeparatorChar)
Dale Johannesen3bb62832007-04-23 20:00:17 +0000123 atInsnStart = true;
124 if (atInsnStart && !isspace(*Str)) {
125 Length += MaxInstLength;
126 atInsnStart = false;
127 }
128 if (atInsnStart && strncmp(Str, CommentString, strlen(CommentString))==0)
129 atInsnStart = false;
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000130 }
131
Dale Johannesen3bb62832007-04-23 20:00:17 +0000132 return Length;
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000133}
Anton Korobeynikova6199c82007-03-07 02:47:57 +0000134