blob: da477493440ef058adc67929e7857e2a1ddc6f34 [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"
16
17using namespace llvm;
18
19TargetAsmInfo::TargetAsmInfo() :
20 TextSection(".text"),
21 DataSection(".data"),
Anton Korobeynikov5032e5a2007-01-17 10:33:08 +000022 BSSSection(".bss"),
Chris Lattner6f198df2007-01-17 17:42:42 +000023 ZeroFillDirective(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000024 AddressSize(4),
25 NeedsSet(false),
Chris Lattner4c7b07a2006-10-13 17:50:07 +000026 MaxInstLength(4),
Jim Laskeyb82313f2007-02-01 16:31:34 +000027 PCSymbol("$"),
Chris Lattner4c7b07a2006-10-13 17:50:07 +000028 SeparatorChar(';'),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000029 CommentString("#"),
30 GlobalPrefix(""),
31 PrivateGlobalPrefix("."),
Chris Lattner393a8ee2007-01-18 01:12:56 +000032 JumpTableSpecialLabelPrefix(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000033 GlobalVarAddrPrefix(""),
34 GlobalVarAddrSuffix(""),
35 FunctionAddrPrefix(""),
36 FunctionAddrSuffix(""),
37 InlineAsmStart("#APP"),
38 InlineAsmEnd("#NO_APP"),
Bill Wendlingeb9a42c2007-01-16 03:42:04 +000039 AssemblerDialect(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000040 ZeroDirective("\t.zero\t"),
41 ZeroDirectiveSuffix(0),
42 AsciiDirective("\t.ascii\t"),
43 AscizDirective("\t.asciz\t"),
44 Data8bitsDirective("\t.byte\t"),
45 Data16bitsDirective("\t.short\t"),
46 Data32bitsDirective("\t.long\t"),
47 Data64bitsDirective("\t.quad\t"),
48 AlignDirective("\t.align\t"),
49 AlignmentIsInBytes(true),
50 SwitchToSectionDirective("\t.section\t"),
51 TextSectionStartSuffix(""),
52 DataSectionStartSuffix(""),
53 SectionEndDirectiveSuffix(0),
54 ConstantPoolSection("\t.section .rodata\n"),
55 JumpTableDataSection("\t.section .rodata\n"),
Andrew Lenharthbeec30e2006-09-24 19:45:58 +000056 JumpTableDirective(0),
Reid Spencerc50209b2006-10-27 16:14:06 +000057 CStringSection(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000058 StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
59 StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
60 FourByteConstantSection(0),
61 EightByteConstantSection(0),
62 SixteenByteConstantSection(0),
Jim Laskey072200c2007-01-29 18:51:14 +000063 GlobalDirective(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000064 SetDirective(0),
65 LCOMMDirective(0),
66 COMMDirective("\t.comm\t"),
67 COMMDirectiveTakesAlignment(true),
68 HasDotTypeDotSizeDirective(true),
Chris Lattnercb05af82006-09-26 03:38:18 +000069 UsedDirective(0),
Evan Cheng8752ce62006-12-01 20:47:11 +000070 WeakRefDirective(0),
Chris Lattner9784bc72007-01-14 06:27:21 +000071 HiddenDirective("\t.hidden\t"),
Anton Korobeynikova6199c82007-03-07 02:47:57 +000072 AbsoluteSectionOffsets(false),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000073 HasLEB128(false),
74 HasDotLoc(false),
75 HasDotFile(false),
Jim Laskey072200c2007-01-29 18:51:14 +000076 SupportsExceptionHandling(false),
Reid Spencer02b85112006-10-30 22:32:30 +000077 DwarfRequiresFrameSection(true),
Anton Korobeynikova6199c82007-03-07 02:47:57 +000078 DwarfSectionOffsetDirective(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000079 DwarfAbbrevSection(".debug_abbrev"),
80 DwarfInfoSection(".debug_info"),
81 DwarfLineSection(".debug_line"),
82 DwarfFrameSection(".debug_frame"),
83 DwarfPubNamesSection(".debug_pubnames"),
84 DwarfPubTypesSection(".debug_pubtypes"),
85 DwarfStrSection(".debug_str"),
86 DwarfLocSection(".debug_loc"),
87 DwarfARangesSection(".debug_aranges"),
88 DwarfRangesSection(".debug_ranges"),
Andrew Lenharth3655de62006-11-28 19:52:20 +000089 DwarfMacInfoSection(".debug_macinfo"),
Jim Laskeyb82313f2007-02-01 16:31:34 +000090 DwarfEHFrameSection(".eh_frame"),
Jim Laskeya15be8c2007-02-21 22:43:40 +000091 DwarfExceptionSection(".gcc_except_table"),
Andrew Lenharth3655de62006-11-28 19:52:20 +000092 AsmTransCBE(0) {
Chris Lattner4c7b07a2006-10-13 17:50:07 +000093}
Chris Lattnerf5b10ec2006-10-05 00:35:16 +000094
95TargetAsmInfo::~TargetAsmInfo() {
96}
Chris Lattner4c7b07a2006-10-13 17:50:07 +000097
98/// Measure the specified inline asm to determine an approximation of its
99/// length.
100unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
101 // Count the number of instructions in the asm.
102 unsigned NumInsts = 0;
103 for (; *Str; ++Str) {
104 if (*Str == '\n' || *Str == SeparatorChar)
105 ++NumInsts;
106 }
107
108 // Multiply by the worst-case length for each instruction.
109 return NumInsts * MaxInstLength;
110}
Anton Korobeynikova6199c82007-03-07 02:47:57 +0000111