2006-09-06 21:21:41 +02:00
|
|
|
//===-- TargetAsmInfo.cpp - Asm Info ---------------------------------------==//
|
2006-09-06 20:35:33 +02:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by James M. Laskey and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines target asm properties related what form asm statements
|
|
|
|
// should take.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/Target/TargetAsmInfo.h"
|
2007-04-23 22:00:17 +02:00
|
|
|
#include <cctype>
|
|
|
|
#include <cstring>
|
2006-09-06 20:35:33 +02:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
TargetAsmInfo::TargetAsmInfo() :
|
2007-05-03 20:46:30 +02:00
|
|
|
TextSection("\t.text"),
|
|
|
|
DataSection("\t.data"),
|
|
|
|
BSSSection("\t.bss"),
|
2007-04-20 23:38:10 +02:00
|
|
|
TLSDataSection("\t.section .tdata,\"awT\",@progbits"),
|
|
|
|
TLSBSSSection("\t.section .tbss,\"awT\",@nobits"),
|
2007-01-17 18:42:42 +01:00
|
|
|
ZeroFillDirective(0),
|
2006-09-06 20:35:33 +02:00
|
|
|
NeedsSet(false),
|
2006-10-13 19:50:07 +02:00
|
|
|
MaxInstLength(4),
|
2007-02-01 17:31:34 +01:00
|
|
|
PCSymbol("$"),
|
2006-10-13 19:50:07 +02:00
|
|
|
SeparatorChar(';'),
|
2006-09-06 20:35:33 +02:00
|
|
|
CommentString("#"),
|
|
|
|
GlobalPrefix(""),
|
|
|
|
PrivateGlobalPrefix("."),
|
2007-01-18 02:12:56 +01:00
|
|
|
JumpTableSpecialLabelPrefix(0),
|
2006-09-06 20:35:33 +02:00
|
|
|
GlobalVarAddrPrefix(""),
|
|
|
|
GlobalVarAddrSuffix(""),
|
|
|
|
FunctionAddrPrefix(""),
|
|
|
|
FunctionAddrSuffix(""),
|
2007-09-11 10:27:17 +02:00
|
|
|
PersonalityPrefix(""),
|
|
|
|
PersonalitySuffix(""),
|
2007-09-11 19:20:55 +02:00
|
|
|
NeedsIndirectEncoding(false),
|
2006-09-06 20:35:33 +02:00
|
|
|
InlineAsmStart("#APP"),
|
|
|
|
InlineAsmEnd("#NO_APP"),
|
2007-01-16 04:42:04 +01:00
|
|
|
AssemblerDialect(0),
|
2006-09-06 20:35:33 +02:00
|
|
|
ZeroDirective("\t.zero\t"),
|
|
|
|
ZeroDirectiveSuffix(0),
|
|
|
|
AsciiDirective("\t.ascii\t"),
|
|
|
|
AscizDirective("\t.asciz\t"),
|
|
|
|
Data8bitsDirective("\t.byte\t"),
|
|
|
|
Data16bitsDirective("\t.short\t"),
|
|
|
|
Data32bitsDirective("\t.long\t"),
|
|
|
|
Data64bitsDirective("\t.quad\t"),
|
|
|
|
AlignDirective("\t.align\t"),
|
|
|
|
AlignmentIsInBytes(true),
|
|
|
|
SwitchToSectionDirective("\t.section\t"),
|
|
|
|
TextSectionStartSuffix(""),
|
|
|
|
DataSectionStartSuffix(""),
|
|
|
|
SectionEndDirectiveSuffix(0),
|
2007-06-14 17:00:27 +02:00
|
|
|
ConstantPoolSection("\t.section .rodata"),
|
|
|
|
JumpTableDataSection("\t.section .rodata"),
|
2006-09-24 21:45:58 +02:00
|
|
|
JumpTableDirective(0),
|
2006-10-27 18:14:06 +02:00
|
|
|
CStringSection(0),
|
2006-09-06 20:35:33 +02:00
|
|
|
StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
|
|
|
|
StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
|
|
|
|
FourByteConstantSection(0),
|
|
|
|
EightByteConstantSection(0),
|
|
|
|
SixteenByteConstantSection(0),
|
2007-03-08 02:00:38 +01:00
|
|
|
ReadOnlySection(0),
|
2007-01-29 19:51:14 +01:00
|
|
|
GlobalDirective(0),
|
2006-09-06 20:35:33 +02:00
|
|
|
SetDirective(0),
|
|
|
|
LCOMMDirective(0),
|
|
|
|
COMMDirective("\t.comm\t"),
|
|
|
|
COMMDirectiveTakesAlignment(true),
|
|
|
|
HasDotTypeDotSizeDirective(true),
|
2006-09-26 05:38:18 +02:00
|
|
|
UsedDirective(0),
|
2006-12-01 21:47:11 +01:00
|
|
|
WeakRefDirective(0),
|
2007-11-21 00:24:42 +01:00
|
|
|
WeakDefDirective(0),
|
2007-01-14 07:27:21 +01:00
|
|
|
HiddenDirective("\t.hidden\t"),
|
2007-04-29 20:35:00 +02:00
|
|
|
ProtectedDirective("\t.protected\t"),
|
2007-05-02 00:23:12 +02:00
|
|
|
AbsoluteDebugSectionOffsets(false),
|
|
|
|
AbsoluteEHSectionOffsets(false),
|
2006-09-06 20:35:33 +02:00
|
|
|
HasLEB128(false),
|
2007-09-24 23:09:53 +02:00
|
|
|
HasDotLocAndDotFile(false),
|
2007-05-05 11:04:50 +02:00
|
|
|
SupportsDebugInformation(false),
|
2007-01-29 19:51:14 +01:00
|
|
|
SupportsExceptionHandling(false),
|
2006-10-30 23:32:30 +01:00
|
|
|
DwarfRequiresFrameSection(true),
|
2007-11-21 01:45:00 +01:00
|
|
|
GlobalEHDirective(0),
|
2007-03-07 03:47:57 +01:00
|
|
|
DwarfSectionOffsetDirective(0),
|
2006-09-06 20:35:33 +02:00
|
|
|
DwarfAbbrevSection(".debug_abbrev"),
|
|
|
|
DwarfInfoSection(".debug_info"),
|
|
|
|
DwarfLineSection(".debug_line"),
|
|
|
|
DwarfFrameSection(".debug_frame"),
|
|
|
|
DwarfPubNamesSection(".debug_pubnames"),
|
|
|
|
DwarfPubTypesSection(".debug_pubtypes"),
|
|
|
|
DwarfStrSection(".debug_str"),
|
|
|
|
DwarfLocSection(".debug_loc"),
|
|
|
|
DwarfARangesSection(".debug_aranges"),
|
|
|
|
DwarfRangesSection(".debug_ranges"),
|
2006-11-28 20:52:20 +01:00
|
|
|
DwarfMacInfoSection(".debug_macinfo"),
|
2007-02-01 17:31:34 +01:00
|
|
|
DwarfEHFrameSection(".eh_frame"),
|
2007-02-21 23:43:40 +01:00
|
|
|
DwarfExceptionSection(".gcc_except_table"),
|
2006-11-28 20:52:20 +01:00
|
|
|
AsmTransCBE(0) {
|
2006-10-13 19:50:07 +02:00
|
|
|
}
|
2006-10-05 02:35:16 +02:00
|
|
|
|
|
|
|
TargetAsmInfo::~TargetAsmInfo() {
|
|
|
|
}
|
2006-10-13 19:50:07 +02:00
|
|
|
|
|
|
|
/// Measure the specified inline asm to determine an approximation of its
|
|
|
|
/// length.
|
2007-04-23 22:00:17 +02:00
|
|
|
/// Comments (which run till the next SeparatorChar or newline) do not
|
|
|
|
/// count as an instruction.
|
|
|
|
/// Any other non-whitespace text is considered an instruction, with
|
|
|
|
/// multiple instructions separated by SeparatorChar or newlines.
|
|
|
|
/// Variable-length instructions are not handled here; this function
|
|
|
|
/// may be overloaded in the target code to do that.
|
2006-10-13 19:50:07 +02:00
|
|
|
unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
|
|
|
|
// Count the number of instructions in the asm.
|
2007-04-23 22:00:17 +02:00
|
|
|
bool atInsnStart = true;
|
|
|
|
unsigned Length = 0;
|
2006-10-13 19:50:07 +02:00
|
|
|
for (; *Str; ++Str) {
|
|
|
|
if (*Str == '\n' || *Str == SeparatorChar)
|
2007-04-23 22:00:17 +02:00
|
|
|
atInsnStart = true;
|
|
|
|
if (atInsnStart && !isspace(*Str)) {
|
|
|
|
Length += MaxInstLength;
|
|
|
|
atInsnStart = false;
|
|
|
|
}
|
|
|
|
if (atInsnStart && strncmp(Str, CommentString, strlen(CommentString))==0)
|
|
|
|
atInsnStart = false;
|
2006-10-13 19:50:07 +02:00
|
|
|
}
|
|
|
|
|
2007-04-23 22:00:17 +02:00
|
|
|
return Length;
|
2006-10-13 19:50:07 +02:00
|
|
|
}
|
2007-03-07 03:47:57 +01:00
|
|
|
|