blob: f66d0ffbed027712a1313eac3e396fa5e57066ba [file] [log] [blame]
Jim Laskeyef94ebb2006-09-06 19:21:41 +00001//===-- TargetAsmInfo.cpp - Asm Info ---------------------------------------==//
Jim Laskey681ecbb2006-09-06 18:35:33 +00002//
3// The LLVM Compiler Infrastructure
4//
Chris Lattnerf3ebc3f2007-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 Laskey681ecbb2006-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 Korobeynikovae24cca2008-02-27 23:33:50 +000016#include "llvm/Support/Dwarf.h"
Dale Johannesen0a1069d2007-04-23 20:00:17 +000017#include <cctype>
18#include <cstring>
Jim Laskey681ecbb2006-09-06 18:35:33 +000019
20using namespace llvm;
21
22TargetAsmInfo::TargetAsmInfo() :
Dan Gohman2675a652007-05-03 18:46:30 +000023 TextSection("\t.text"),
24 DataSection("\t.data"),
25 BSSSection("\t.bss"),
Lauro Ramos Venancio25188892007-04-20 21:38:10 +000026 TLSDataSection("\t.section .tdata,\"awT\",@progbits"),
27 TLSBSSSection("\t.section .tbss,\"awT\",@nobits"),
Chris Lattner1ceb6432007-01-17 17:42:42 +000028 ZeroFillDirective(0),
Jim Laskey681ecbb2006-09-06 18:35:33 +000029 NeedsSet(false),
Chris Lattner95129a72006-10-13 17:50:07 +000030 MaxInstLength(4),
Jim Laskeyc3de9b42007-02-01 16:31:34 +000031 PCSymbol("$"),
Chris Lattner95129a72006-10-13 17:50:07 +000032 SeparatorChar(';'),
Jim Laskey681ecbb2006-09-06 18:35:33 +000033 CommentString("#"),
34 GlobalPrefix(""),
35 PrivateGlobalPrefix("."),
Chris Lattner0ee2d462007-01-18 01:12:56 +000036 JumpTableSpecialLabelPrefix(0),
Jim Laskey681ecbb2006-09-06 18:35:33 +000037 GlobalVarAddrPrefix(""),
38 GlobalVarAddrSuffix(""),
39 FunctionAddrPrefix(""),
40 FunctionAddrSuffix(""),
Bill Wendling2b8fc312007-09-11 08:27:17 +000041 PersonalityPrefix(""),
42 PersonalitySuffix(""),
Bill Wendling74fb0f12007-09-11 17:20:55 +000043 NeedsIndirectEncoding(false),
Jim Laskey681ecbb2006-09-06 18:35:33 +000044 InlineAsmStart("#APP"),
45 InlineAsmEnd("#NO_APP"),
Bill Wendlinge21237e2007-01-16 03:42:04 +000046 AssemblerDialect(0),
Jim Laskey681ecbb2006-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 Gohman3a8e2a82007-06-14 15:00:27 +000061 ConstantPoolSection("\t.section .rodata"),
62 JumpTableDataSection("\t.section .rodata"),
Andrew Lenharth783a4a92006-09-24 19:45:58 +000063 JumpTableDirective(0),
Reid Spencere54243f2006-10-27 16:14:06 +000064 CStringSection(0),
Jim Laskey681ecbb2006-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 Cheng58aeb9c2007-03-08 01:00:38 +000070 ReadOnlySection(0),
Gordon Henriksen84c73252007-12-23 20:58:16 +000071 GlobalDirective("\t.globl\t"),
Jim Laskey681ecbb2006-09-06 18:35:33 +000072 SetDirective(0),
73 LCOMMDirective(0),
74 COMMDirective("\t.comm\t"),
75 COMMDirectiveTakesAlignment(true),
76 HasDotTypeDotSizeDirective(true),
Chris Lattner66af3902006-09-26 03:38:18 +000077 UsedDirective(0),
Evan Cheng022030a2006-12-01 20:47:11 +000078 WeakRefDirective(0),
Dale Johannesen763e1102007-11-20 23:24:42 +000079 WeakDefDirective(0),
Chris Lattner9f6badb2007-01-14 06:27:21 +000080 HiddenDirective("\t.hidden\t"),
Anton Korobeynikov39f3cff2007-04-29 18:35:00 +000081 ProtectedDirective("\t.protected\t"),
Anton Korobeynikovb538f672007-05-01 22:23:12 +000082 AbsoluteDebugSectionOffsets(false),
83 AbsoluteEHSectionOffsets(false),
Jim Laskey681ecbb2006-09-06 18:35:33 +000084 HasLEB128(false),
Dan Gohman0cc9d1b2007-09-24 21:09:53 +000085 HasDotLocAndDotFile(false),
Anton Korobeynikov4db00902007-05-05 09:04:50 +000086 SupportsDebugInformation(false),
Jim Laskeyb4a2f052007-01-29 18:51:14 +000087 SupportsExceptionHandling(false),
Reid Spencerb51b5c02006-10-30 22:32:30 +000088 DwarfRequiresFrameSection(true),
Dale Johannesene70850c2007-11-21 00:45:00 +000089 GlobalEHDirective(0),
Dale Johannesen7ecb3b72008-01-10 02:03:30 +000090 SupportsWeakOmittedEHFrame(true),
Dale Johannesen00dfb552008-01-15 23:25:27 +000091 ShortenEHDataOn64Bit(false),
Anton Korobeynikov942fda02007-03-07 02:47:57 +000092 DwarfSectionOffsetDirective(0),
Jim Laskey681ecbb2006-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 Lenharthff35b442006-11-28 19:52:20 +0000103 DwarfMacInfoSection(".debug_macinfo"),
Jim Laskeyc3de9b42007-02-01 16:31:34 +0000104 DwarfEHFrameSection(".eh_frame"),
Jim Laskeyaf76e0e2007-02-21 22:43:40 +0000105 DwarfExceptionSection(".gcc_except_table"),
Andrew Lenharthff35b442006-11-28 19:52:20 +0000106 AsmTransCBE(0) {
Chris Lattner95129a72006-10-13 17:50:07 +0000107}
Chris Lattnerafe6d7a2006-10-05 00:35:16 +0000108
109TargetAsmInfo::~TargetAsmInfo() {
110}
Chris Lattner95129a72006-10-13 17:50:07 +0000111
112/// Measure the specified inline asm to determine an approximation of its
113/// length.
Dale Johannesen0a1069d2007-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 Lattner95129a72006-10-13 17:50:07 +0000120unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
121 // Count the number of instructions in the asm.
Dale Johannesen0a1069d2007-04-23 20:00:17 +0000122 bool atInsnStart = true;
123 unsigned Length = 0;
Chris Lattner95129a72006-10-13 17:50:07 +0000124 for (; *Str; ++Str) {
125 if (*Str == '\n' || *Str == SeparatorChar)
Dale Johannesen0a1069d2007-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 Lattner95129a72006-10-13 17:50:07 +0000133 }
134
Dale Johannesen0a1069d2007-04-23 20:00:17 +0000135 return Length;
Chris Lattner95129a72006-10-13 17:50:07 +0000136}
Anton Korobeynikov942fda02007-03-07 02:47:57 +0000137
Anton Korobeynikovae24cca2008-02-27 23:33:50 +0000138unsigned TargetAsmInfo::PreferredEHDataFormat(unsigned Reason,
139 bool Global) const {
140 return dwarf::DW_EH_PE_absptr;
141}
142