blob: 3afbddb89c960015ce010e1fbaaada54ae8a6595 [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"
16
17using namespace llvm;
18
19TargetAsmInfo::TargetAsmInfo() :
20 TextSection(".text"),
21 DataSection(".data"),
Anton Korobeynikov3f6d5282007-01-17 10:33:08 +000022 BSSSection(".bss"),
Chris Lattner1ceb6432007-01-17 17:42:42 +000023 ZeroFillDirective(0),
Jim Laskey681ecbb2006-09-06 18:35:33 +000024 AddressSize(4),
25 NeedsSet(false),
Chris Lattner95129a72006-10-13 17:50:07 +000026 MaxInstLength(4),
27 SeparatorChar(';'),
Jim Laskey681ecbb2006-09-06 18:35:33 +000028 CommentString("#"),
29 GlobalPrefix(""),
30 PrivateGlobalPrefix("."),
31 GlobalVarAddrPrefix(""),
32 GlobalVarAddrSuffix(""),
33 FunctionAddrPrefix(""),
34 FunctionAddrSuffix(""),
35 InlineAsmStart("#APP"),
36 InlineAsmEnd("#NO_APP"),
Bill Wendlinge21237e2007-01-16 03:42:04 +000037 AssemblerDialect(0),
Jim Laskey681ecbb2006-09-06 18:35:33 +000038 ZeroDirective("\t.zero\t"),
39 ZeroDirectiveSuffix(0),
40 AsciiDirective("\t.ascii\t"),
41 AscizDirective("\t.asciz\t"),
42 Data8bitsDirective("\t.byte\t"),
43 Data16bitsDirective("\t.short\t"),
44 Data32bitsDirective("\t.long\t"),
45 Data64bitsDirective("\t.quad\t"),
46 AlignDirective("\t.align\t"),
47 AlignmentIsInBytes(true),
48 SwitchToSectionDirective("\t.section\t"),
49 TextSectionStartSuffix(""),
50 DataSectionStartSuffix(""),
51 SectionEndDirectiveSuffix(0),
52 ConstantPoolSection("\t.section .rodata\n"),
53 JumpTableDataSection("\t.section .rodata\n"),
Andrew Lenharth783a4a92006-09-24 19:45:58 +000054 JumpTableDirective(0),
Reid Spencere54243f2006-10-27 16:14:06 +000055 CStringSection(0),
Jim Laskey681ecbb2006-09-06 18:35:33 +000056 StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
57 StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
58 FourByteConstantSection(0),
59 EightByteConstantSection(0),
60 SixteenByteConstantSection(0),
61 SetDirective(0),
62 LCOMMDirective(0),
63 COMMDirective("\t.comm\t"),
64 COMMDirectiveTakesAlignment(true),
65 HasDotTypeDotSizeDirective(true),
Chris Lattner66af3902006-09-26 03:38:18 +000066 UsedDirective(0),
Evan Cheng022030a2006-12-01 20:47:11 +000067 WeakRefDirective(0),
Chris Lattner9f6badb2007-01-14 06:27:21 +000068 HiddenDirective("\t.hidden\t"),
Jim Laskey681ecbb2006-09-06 18:35:33 +000069 HasLEB128(false),
70 HasDotLoc(false),
71 HasDotFile(false),
Reid Spencerb51b5c02006-10-30 22:32:30 +000072 DwarfRequiresFrameSection(true),
Jim Laskey681ecbb2006-09-06 18:35:33 +000073 DwarfAbbrevSection(".debug_abbrev"),
74 DwarfInfoSection(".debug_info"),
75 DwarfLineSection(".debug_line"),
76 DwarfFrameSection(".debug_frame"),
77 DwarfPubNamesSection(".debug_pubnames"),
78 DwarfPubTypesSection(".debug_pubtypes"),
79 DwarfStrSection(".debug_str"),
80 DwarfLocSection(".debug_loc"),
81 DwarfARangesSection(".debug_aranges"),
82 DwarfRangesSection(".debug_ranges"),
Andrew Lenharthff35b442006-11-28 19:52:20 +000083 DwarfMacInfoSection(".debug_macinfo"),
84 AsmTransCBE(0) {
Chris Lattner95129a72006-10-13 17:50:07 +000085}
Chris Lattnerafe6d7a2006-10-05 00:35:16 +000086
87TargetAsmInfo::~TargetAsmInfo() {
88}
Chris Lattner95129a72006-10-13 17:50:07 +000089
90/// Measure the specified inline asm to determine an approximation of its
91/// length.
92unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
93 // Count the number of instructions in the asm.
94 unsigned NumInsts = 0;
95 for (; *Str; ++Str) {
96 if (*Str == '\n' || *Str == SeparatorChar)
97 ++NumInsts;
98 }
99
100 // Multiply by the worst-case length for each instruction.
101 return NumInsts * MaxInstLength;
102}