blob: b90eaa16689190e0baed57ae4fe25309e1e8d997 [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"),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000023 AddressSize(4),
24 NeedsSet(false),
Chris Lattner4c7b07a2006-10-13 17:50:07 +000025 MaxInstLength(4),
26 SeparatorChar(';'),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000027 CommentString("#"),
28 GlobalPrefix(""),
29 PrivateGlobalPrefix("."),
30 GlobalVarAddrPrefix(""),
31 GlobalVarAddrSuffix(""),
32 FunctionAddrPrefix(""),
33 FunctionAddrSuffix(""),
34 InlineAsmStart("#APP"),
35 InlineAsmEnd("#NO_APP"),
Bill Wendlingeb9a42c2007-01-16 03:42:04 +000036 AssemblerDialect(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000037 ZeroDirective("\t.zero\t"),
38 ZeroDirectiveSuffix(0),
39 AsciiDirective("\t.ascii\t"),
40 AscizDirective("\t.asciz\t"),
41 Data8bitsDirective("\t.byte\t"),
42 Data16bitsDirective("\t.short\t"),
43 Data32bitsDirective("\t.long\t"),
44 Data64bitsDirective("\t.quad\t"),
45 AlignDirective("\t.align\t"),
46 AlignmentIsInBytes(true),
47 SwitchToSectionDirective("\t.section\t"),
48 TextSectionStartSuffix(""),
49 DataSectionStartSuffix(""),
50 SectionEndDirectiveSuffix(0),
51 ConstantPoolSection("\t.section .rodata\n"),
52 JumpTableDataSection("\t.section .rodata\n"),
Andrew Lenharthbeec30e2006-09-24 19:45:58 +000053 JumpTableDirective(0),
Reid Spencerc50209b2006-10-27 16:14:06 +000054 CStringSection(0),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000055 StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
56 StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
57 FourByteConstantSection(0),
58 EightByteConstantSection(0),
59 SixteenByteConstantSection(0),
60 SetDirective(0),
61 LCOMMDirective(0),
62 COMMDirective("\t.comm\t"),
63 COMMDirectiveTakesAlignment(true),
64 HasDotTypeDotSizeDirective(true),
Chris Lattnercb05af82006-09-26 03:38:18 +000065 UsedDirective(0),
Evan Cheng8752ce62006-12-01 20:47:11 +000066 WeakRefDirective(0),
Chris Lattner9784bc72007-01-14 06:27:21 +000067 HiddenDirective("\t.hidden\t"),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000068 HasLEB128(false),
69 HasDotLoc(false),
70 HasDotFile(false),
Reid Spencer02b85112006-10-30 22:32:30 +000071 DwarfRequiresFrameSection(true),
Jim Laskeyec0d9fe2006-09-06 18:35:33 +000072 DwarfAbbrevSection(".debug_abbrev"),
73 DwarfInfoSection(".debug_info"),
74 DwarfLineSection(".debug_line"),
75 DwarfFrameSection(".debug_frame"),
76 DwarfPubNamesSection(".debug_pubnames"),
77 DwarfPubTypesSection(".debug_pubtypes"),
78 DwarfStrSection(".debug_str"),
79 DwarfLocSection(".debug_loc"),
80 DwarfARangesSection(".debug_aranges"),
81 DwarfRangesSection(".debug_ranges"),
Andrew Lenharth3655de62006-11-28 19:52:20 +000082 DwarfMacInfoSection(".debug_macinfo"),
83 AsmTransCBE(0) {
Chris Lattner4c7b07a2006-10-13 17:50:07 +000084}
Chris Lattnerf5b10ec2006-10-05 00:35:16 +000085
86TargetAsmInfo::~TargetAsmInfo() {
87}
Chris Lattner4c7b07a2006-10-13 17:50:07 +000088
89/// Measure the specified inline asm to determine an approximation of its
90/// length.
91unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
92 // Count the number of instructions in the asm.
93 unsigned NumInsts = 0;
94 for (; *Str; ++Str) {
95 if (*Str == '\n' || *Str == SeparatorChar)
96 ++NumInsts;
97 }
98
99 // Multiply by the worst-case length for each instruction.
100 return NumInsts * MaxInstLength;
101}