blob: 79186789ba0f0dbd29182e0ec28a35bd3aa4fbee [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//
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"
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 AddressSize(4),
29 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(""),
41 InlineAsmStart("#APP"),
42 InlineAsmEnd("#NO_APP"),
Bill Wendlingeb9a42c2007-01-16 03:42:04 +000043 AssemblerDialect(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000044 ZeroDirective("\t.zero\t"),
45 ZeroDirectiveSuffix(0),
46 AsciiDirective("\t.ascii\t"),
47 AscizDirective("\t.asciz\t"),
48 Data8bitsDirective("\t.byte\t"),
49 Data16bitsDirective("\t.short\t"),
50 Data32bitsDirective("\t.long\t"),
51 Data64bitsDirective("\t.quad\t"),
52 AlignDirective("\t.align\t"),
53 AlignmentIsInBytes(true),
54 SwitchToSectionDirective("\t.section\t"),
55 TextSectionStartSuffix(""),
56 DataSectionStartSuffix(""),
57 SectionEndDirectiveSuffix(0),
58 ConstantPoolSection("\t.section .rodata\n"),
59 JumpTableDataSection("\t.section .rodata\n"),
Andrew Lenharthbeec30e2006-09-24 19:45:58 +000060 JumpTableDirective(0),
Reid Spencerc50209b2006-10-27 16:14:06 +000061 CStringSection(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000062 StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
63 StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
64 FourByteConstantSection(0),
65 EightByteConstantSection(0),
66 SixteenByteConstantSection(0),
Evan Chengbe346c92007-03-08 01:00:38 +000067 ReadOnlySection(0),
Jim Laskey072200c2007-01-29 18:51:14 +000068 GlobalDirective(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000069 SetDirective(0),
70 LCOMMDirective(0),
71 COMMDirective("\t.comm\t"),
72 COMMDirectiveTakesAlignment(true),
73 HasDotTypeDotSizeDirective(true),
Chris Lattnercb05af82006-09-26 03:38:18 +000074 UsedDirective(0),
Evan Cheng8752ce62006-12-01 20:47:11 +000075 WeakRefDirective(0),
Chris Lattner9784bc72007-01-14 06:27:21 +000076 HiddenDirective("\t.hidden\t"),
Anton Korobeynikov6f9896f2007-04-29 18:35:00 +000077 ProtectedDirective("\t.protected\t"),
Anton Korobeynikov79dda2b2007-05-01 22:23:12 +000078 AbsoluteDebugSectionOffsets(false),
79 AbsoluteEHSectionOffsets(false),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000080 HasLEB128(false),
81 HasDotLoc(false),
82 HasDotFile(false),
Anton Korobeynikov2a07e2f2007-05-05 09:04:50 +000083 SupportsDebugInformation(false),
Jim Laskey072200c2007-01-29 18:51:14 +000084 SupportsExceptionHandling(false),
Reid Spencer02b85112006-10-30 22:32:30 +000085 DwarfRequiresFrameSection(true),
Anton Korobeynikova6199c82007-03-07 02:47:57 +000086 DwarfSectionOffsetDirective(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000087 DwarfAbbrevSection(".debug_abbrev"),
88 DwarfInfoSection(".debug_info"),
89 DwarfLineSection(".debug_line"),
90 DwarfFrameSection(".debug_frame"),
91 DwarfPubNamesSection(".debug_pubnames"),
92 DwarfPubTypesSection(".debug_pubtypes"),
93 DwarfStrSection(".debug_str"),
94 DwarfLocSection(".debug_loc"),
95 DwarfARangesSection(".debug_aranges"),
96 DwarfRangesSection(".debug_ranges"),
Andrew Lenharth3655de62006-11-28 19:52:20 +000097 DwarfMacInfoSection(".debug_macinfo"),
Jim Laskeyb82313f2007-02-01 16:31:34 +000098 DwarfEHFrameSection(".eh_frame"),
Jim Laskeya15be8c2007-02-21 22:43:40 +000099 DwarfExceptionSection(".gcc_except_table"),
Andrew Lenharth3655de62006-11-28 19:52:20 +0000100 AsmTransCBE(0) {
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000101}
Chris Lattnerf5b10ec2006-10-05 00:35:16 +0000102
103TargetAsmInfo::~TargetAsmInfo() {
104}
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000105
106/// Measure the specified inline asm to determine an approximation of its
107/// length.
Dale Johannesen3bb62832007-04-23 20:00:17 +0000108/// Comments (which run till the next SeparatorChar or newline) do not
109/// count as an instruction.
110/// Any other non-whitespace text is considered an instruction, with
111/// multiple instructions separated by SeparatorChar or newlines.
112/// Variable-length instructions are not handled here; this function
113/// may be overloaded in the target code to do that.
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000114unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
115 // Count the number of instructions in the asm.
Dale Johannesen3bb62832007-04-23 20:00:17 +0000116 bool atInsnStart = true;
117 unsigned Length = 0;
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000118 for (; *Str; ++Str) {
119 if (*Str == '\n' || *Str == SeparatorChar)
Dale Johannesen3bb62832007-04-23 20:00:17 +0000120 atInsnStart = true;
121 if (atInsnStart && !isspace(*Str)) {
122 Length += MaxInstLength;
123 atInsnStart = false;
124 }
125 if (atInsnStart && strncmp(Str, CommentString, strlen(CommentString))==0)
126 atInsnStart = false;
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000127 }
128
Dale Johannesen3bb62832007-04-23 20:00:17 +0000129 return Length;
Chris Lattner4c7b07a2006-10-13 17:50:07 +0000130}
Anton Korobeynikova6199c82007-03-07 02:47:57 +0000131