blob: 7ac395002ed9916be3f7b8942525ce7bebceacb4 [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("."),
Chris Lattner0ee2d462007-01-18 01:12:56 +000031 JumpTableSpecialLabelPrefix(0),
Jim Laskey681ecbb2006-09-06 18:35:33 +000032 GlobalVarAddrPrefix(""),
33 GlobalVarAddrSuffix(""),
34 FunctionAddrPrefix(""),
35 FunctionAddrSuffix(""),
36 InlineAsmStart("#APP"),
37 InlineAsmEnd("#NO_APP"),
Bill Wendlinge21237e2007-01-16 03:42:04 +000038 AssemblerDialect(0),
Jim Laskey681ecbb2006-09-06 18:35:33 +000039 ZeroDirective("\t.zero\t"),
40 ZeroDirectiveSuffix(0),
41 AsciiDirective("\t.ascii\t"),
42 AscizDirective("\t.asciz\t"),
43 Data8bitsDirective("\t.byte\t"),
44 Data16bitsDirective("\t.short\t"),
45 Data32bitsDirective("\t.long\t"),
46 Data64bitsDirective("\t.quad\t"),
47 AlignDirective("\t.align\t"),
48 AlignmentIsInBytes(true),
49 SwitchToSectionDirective("\t.section\t"),
50 TextSectionStartSuffix(""),
51 DataSectionStartSuffix(""),
52 SectionEndDirectiveSuffix(0),
53 ConstantPoolSection("\t.section .rodata\n"),
54 JumpTableDataSection("\t.section .rodata\n"),
Andrew Lenharth783a4a92006-09-24 19:45:58 +000055 JumpTableDirective(0),
Reid Spencere54243f2006-10-27 16:14:06 +000056 CStringSection(0),
Jim Laskey681ecbb2006-09-06 18:35:33 +000057 StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
58 StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
59 FourByteConstantSection(0),
60 EightByteConstantSection(0),
61 SixteenByteConstantSection(0),
Jim Laskeyb4a2f052007-01-29 18:51:14 +000062 GlobalDirective(0),
Jim Laskey681ecbb2006-09-06 18:35:33 +000063 SetDirective(0),
64 LCOMMDirective(0),
65 COMMDirective("\t.comm\t"),
66 COMMDirectiveTakesAlignment(true),
67 HasDotTypeDotSizeDirective(true),
Chris Lattner66af3902006-09-26 03:38:18 +000068 UsedDirective(0),
Evan Cheng022030a2006-12-01 20:47:11 +000069 WeakRefDirective(0),
Chris Lattner9f6badb2007-01-14 06:27:21 +000070 HiddenDirective("\t.hidden\t"),
Jim Laskey681ecbb2006-09-06 18:35:33 +000071 HasLEB128(false),
72 HasDotLoc(false),
73 HasDotFile(false),
Jim Laskeyb4a2f052007-01-29 18:51:14 +000074 SupportsExceptionHandling(false),
Reid Spencerb51b5c02006-10-30 22:32:30 +000075 DwarfRequiresFrameSection(true),
Jim Laskey681ecbb2006-09-06 18:35:33 +000076 DwarfAbbrevSection(".debug_abbrev"),
77 DwarfInfoSection(".debug_info"),
78 DwarfLineSection(".debug_line"),
79 DwarfFrameSection(".debug_frame"),
80 DwarfPubNamesSection(".debug_pubnames"),
81 DwarfPubTypesSection(".debug_pubtypes"),
82 DwarfStrSection(".debug_str"),
83 DwarfLocSection(".debug_loc"),
84 DwarfARangesSection(".debug_aranges"),
85 DwarfRangesSection(".debug_ranges"),
Andrew Lenharthff35b442006-11-28 19:52:20 +000086 DwarfMacInfoSection(".debug_macinfo"),
87 AsmTransCBE(0) {
Chris Lattner95129a72006-10-13 17:50:07 +000088}
Chris Lattnerafe6d7a2006-10-05 00:35:16 +000089
90TargetAsmInfo::~TargetAsmInfo() {
91}
Chris Lattner95129a72006-10-13 17:50:07 +000092
93/// Measure the specified inline asm to determine an approximation of its
94/// length.
95unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
96 // Count the number of instructions in the asm.
97 unsigned NumInsts = 0;
98 for (; *Str; ++Str) {
99 if (*Str == '\n' || *Str == SeparatorChar)
100 ++NumInsts;
101 }
102
103 // Multiply by the worst-case length for each instruction.
104 return NumInsts * MaxInstLength;
105}