blob: 37ab073ffcddb2d93defe5cb819998fa7feba673 [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//
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 Johannesen0a1069d2007-04-23 20:00:17 +000016#include <cctype>
17#include <cstring>
Jim Laskey681ecbb2006-09-06 18:35:33 +000018
19using namespace llvm;
20
21TargetAsmInfo::TargetAsmInfo() :
22 TextSection(".text"),
23 DataSection(".data"),
Anton Korobeynikov3f6d5282007-01-17 10:33:08 +000024 BSSSection(".bss"),
Lauro Ramos Venancio25188892007-04-20 21:38:10 +000025 TLSDataSection("\t.section .tdata,\"awT\",@progbits"),
26 TLSBSSSection("\t.section .tbss,\"awT\",@nobits"),
Chris Lattner1ceb6432007-01-17 17:42:42 +000027 ZeroFillDirective(0),
Jim Laskey681ecbb2006-09-06 18:35:33 +000028 AddressSize(4),
29 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(""),
41 InlineAsmStart("#APP"),
42 InlineAsmEnd("#NO_APP"),
Bill Wendlinge21237e2007-01-16 03:42:04 +000043 AssemblerDialect(0),
Jim Laskey681ecbb2006-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 Lenharth783a4a92006-09-24 19:45:58 +000060 JumpTableDirective(0),
Reid Spencere54243f2006-10-27 16:14:06 +000061 CStringSection(0),
Jim Laskey681ecbb2006-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 Cheng58aeb9c2007-03-08 01:00:38 +000067 ReadOnlySection(0),
Jim Laskeyb4a2f052007-01-29 18:51:14 +000068 GlobalDirective(0),
Jim Laskey681ecbb2006-09-06 18:35:33 +000069 SetDirective(0),
70 LCOMMDirective(0),
71 COMMDirective("\t.comm\t"),
72 COMMDirectiveTakesAlignment(true),
73 HasDotTypeDotSizeDirective(true),
Chris Lattner66af3902006-09-26 03:38:18 +000074 UsedDirective(0),
Evan Cheng022030a2006-12-01 20:47:11 +000075 WeakRefDirective(0),
Chris Lattner9f6badb2007-01-14 06:27:21 +000076 HiddenDirective("\t.hidden\t"),
Anton Korobeynikov39f3cff2007-04-29 18:35:00 +000077 ProtectedDirective("\t.protected\t"),
Anton Korobeynikov942fda02007-03-07 02:47:57 +000078 AbsoluteSectionOffsets(false),
Jim Laskey681ecbb2006-09-06 18:35:33 +000079 HasLEB128(false),
80 HasDotLoc(false),
81 HasDotFile(false),
Jim Laskeyb4a2f052007-01-29 18:51:14 +000082 SupportsExceptionHandling(false),
Reid Spencerb51b5c02006-10-30 22:32:30 +000083 DwarfRequiresFrameSection(true),
Anton Korobeynikov942fda02007-03-07 02:47:57 +000084 DwarfSectionOffsetDirective(0),
Jim Laskey681ecbb2006-09-06 18:35:33 +000085 DwarfAbbrevSection(".debug_abbrev"),
86 DwarfInfoSection(".debug_info"),
87 DwarfLineSection(".debug_line"),
88 DwarfFrameSection(".debug_frame"),
89 DwarfPubNamesSection(".debug_pubnames"),
90 DwarfPubTypesSection(".debug_pubtypes"),
91 DwarfStrSection(".debug_str"),
92 DwarfLocSection(".debug_loc"),
93 DwarfARangesSection(".debug_aranges"),
94 DwarfRangesSection(".debug_ranges"),
Andrew Lenharthff35b442006-11-28 19:52:20 +000095 DwarfMacInfoSection(".debug_macinfo"),
Jim Laskeyc3de9b42007-02-01 16:31:34 +000096 DwarfEHFrameSection(".eh_frame"),
Jim Laskeyaf76e0e2007-02-21 22:43:40 +000097 DwarfExceptionSection(".gcc_except_table"),
Andrew Lenharthff35b442006-11-28 19:52:20 +000098 AsmTransCBE(0) {
Chris Lattner95129a72006-10-13 17:50:07 +000099}
Chris Lattnerafe6d7a2006-10-05 00:35:16 +0000100
101TargetAsmInfo::~TargetAsmInfo() {
102}
Chris Lattner95129a72006-10-13 17:50:07 +0000103
104/// Measure the specified inline asm to determine an approximation of its
105/// length.
Dale Johannesen0a1069d2007-04-23 20:00:17 +0000106/// Comments (which run till the next SeparatorChar or newline) do not
107/// count as an instruction.
108/// Any other non-whitespace text is considered an instruction, with
109/// multiple instructions separated by SeparatorChar or newlines.
110/// Variable-length instructions are not handled here; this function
111/// may be overloaded in the target code to do that.
Chris Lattner95129a72006-10-13 17:50:07 +0000112unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
113 // Count the number of instructions in the asm.
Dale Johannesen0a1069d2007-04-23 20:00:17 +0000114 bool atInsnStart = true;
115 unsigned Length = 0;
Chris Lattner95129a72006-10-13 17:50:07 +0000116 for (; *Str; ++Str) {
117 if (*Str == '\n' || *Str == SeparatorChar)
Dale Johannesen0a1069d2007-04-23 20:00:17 +0000118 atInsnStart = true;
119 if (atInsnStart && !isspace(*Str)) {
120 Length += MaxInstLength;
121 atInsnStart = false;
122 }
123 if (atInsnStart && strncmp(Str, CommentString, strlen(CommentString))==0)
124 atInsnStart = false;
Chris Lattner95129a72006-10-13 17:50:07 +0000125 }
126
Dale Johannesen0a1069d2007-04-23 20:00:17 +0000127 return Length;
Chris Lattner95129a72006-10-13 17:50:07 +0000128}
Anton Korobeynikov942fda02007-03-07 02:47:57 +0000129