blob: cf3f6eec39a55748b0d445c7b621c15c053c893b [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),
Jim Laskeyc3de9b42007-02-01 16:31:34 +000027 PCSymbol("$"),
Chris Lattner95129a72006-10-13 17:50:07 +000028 SeparatorChar(';'),
Jim Laskey681ecbb2006-09-06 18:35:33 +000029 CommentString("#"),
30 GlobalPrefix(""),
31 PrivateGlobalPrefix("."),
Chris Lattner0ee2d462007-01-18 01:12:56 +000032 JumpTableSpecialLabelPrefix(0),
Jim Laskey681ecbb2006-09-06 18:35:33 +000033 GlobalVarAddrPrefix(""),
34 GlobalVarAddrSuffix(""),
35 FunctionAddrPrefix(""),
36 FunctionAddrSuffix(""),
37 InlineAsmStart("#APP"),
38 InlineAsmEnd("#NO_APP"),
Bill Wendlinge21237e2007-01-16 03:42:04 +000039 AssemblerDialect(0),
Jim Laskey681ecbb2006-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 Lenharth783a4a92006-09-24 19:45:58 +000056 JumpTableDirective(0),
Reid Spencere54243f2006-10-27 16:14:06 +000057 CStringSection(0),
Jim Laskey681ecbb2006-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),
Evan Cheng58aeb9c2007-03-08 01:00:38 +000063 ReadOnlySection(0),
Jim Laskeyb4a2f052007-01-29 18:51:14 +000064 GlobalDirective(0),
Jim Laskey681ecbb2006-09-06 18:35:33 +000065 SetDirective(0),
66 LCOMMDirective(0),
67 COMMDirective("\t.comm\t"),
68 COMMDirectiveTakesAlignment(true),
69 HasDotTypeDotSizeDirective(true),
Chris Lattner66af3902006-09-26 03:38:18 +000070 UsedDirective(0),
Evan Cheng022030a2006-12-01 20:47:11 +000071 WeakRefDirective(0),
Chris Lattner9f6badb2007-01-14 06:27:21 +000072 HiddenDirective("\t.hidden\t"),
Anton Korobeynikov942fda02007-03-07 02:47:57 +000073 AbsoluteSectionOffsets(false),
Jim Laskey681ecbb2006-09-06 18:35:33 +000074 HasLEB128(false),
75 HasDotLoc(false),
76 HasDotFile(false),
Jim Laskeyb4a2f052007-01-29 18:51:14 +000077 SupportsExceptionHandling(false),
Reid Spencerb51b5c02006-10-30 22:32:30 +000078 DwarfRequiresFrameSection(true),
Anton Korobeynikov942fda02007-03-07 02:47:57 +000079 DwarfSectionOffsetDirective(0),
Jim Laskey681ecbb2006-09-06 18:35:33 +000080 DwarfAbbrevSection(".debug_abbrev"),
81 DwarfInfoSection(".debug_info"),
82 DwarfLineSection(".debug_line"),
83 DwarfFrameSection(".debug_frame"),
84 DwarfPubNamesSection(".debug_pubnames"),
85 DwarfPubTypesSection(".debug_pubtypes"),
86 DwarfStrSection(".debug_str"),
87 DwarfLocSection(".debug_loc"),
88 DwarfARangesSection(".debug_aranges"),
89 DwarfRangesSection(".debug_ranges"),
Andrew Lenharthff35b442006-11-28 19:52:20 +000090 DwarfMacInfoSection(".debug_macinfo"),
Jim Laskeyc3de9b42007-02-01 16:31:34 +000091 DwarfEHFrameSection(".eh_frame"),
Jim Laskeyaf76e0e2007-02-21 22:43:40 +000092 DwarfExceptionSection(".gcc_except_table"),
Andrew Lenharthff35b442006-11-28 19:52:20 +000093 AsmTransCBE(0) {
Chris Lattner95129a72006-10-13 17:50:07 +000094}
Chris Lattnerafe6d7a2006-10-05 00:35:16 +000095
96TargetAsmInfo::~TargetAsmInfo() {
97}
Chris Lattner95129a72006-10-13 17:50:07 +000098
99/// Measure the specified inline asm to determine an approximation of its
100/// length.
101unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
102 // Count the number of instructions in the asm.
103 unsigned NumInsts = 0;
104 for (; *Str; ++Str) {
105 if (*Str == '\n' || *Str == SeparatorChar)
106 ++NumInsts;
107 }
108
109 // Multiply by the worst-case length for each instruction.
110 return NumInsts * MaxInstLength;
111}
Anton Korobeynikov942fda02007-03-07 02:47:57 +0000112