2006-09-07 03:21:41 +08:00
|
|
|
//===-- TargetAsmInfo.cpp - Asm Info ---------------------------------------==//
|
2006-09-07 02:35:33 +08: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-24 04:00:17 +08:00
|
|
|
#include <cctype>
|
|
|
|
#include <cstring>
|
2006-09-07 02:35:33 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
TargetAsmInfo::TargetAsmInfo() :
|
2007-05-04 02:46:30 +08:00
|
|
|
TextSection("\t.text"),
|
|
|
|
DataSection("\t.data"),
|
|
|
|
BSSSection("\t.bss"),
|
2007-04-21 05:38:10 +08:00
|
|
|
TLSDataSection("\t.section .tdata,\"awT\",@progbits"),
|
|
|
|
TLSBSSSection("\t.section .tbss,\"awT\",@nobits"),
|
2007-01-18 01:42:42 +08:00
|
|
|
ZeroFillDirective(0),
|
2006-09-07 02:35:33 +08:00
|
|
|
AddressSize(4),
|
|
|
|
NeedsSet(false),
|
2006-10-14 01:50:07 +08:00
|
|
|
MaxInstLength(4),
|
2007-02-02 00:31:34 +08:00
|
|
|
PCSymbol("$"),
|
2006-10-14 01:50:07 +08:00
|
|
|
SeparatorChar(';'),
|
2006-09-07 02:35:33 +08:00
|
|
|
CommentString("#"),
|
|
|
|
GlobalPrefix(""),
|
|
|
|
PrivateGlobalPrefix("."),
|
2007-01-18 09:12:56 +08:00
|
|
|
JumpTableSpecialLabelPrefix(0),
|
2006-09-07 02:35:33 +08:00
|
|
|
GlobalVarAddrPrefix(""),
|
|
|
|
GlobalVarAddrSuffix(""),
|
|
|
|
FunctionAddrPrefix(""),
|
|
|
|
FunctionAddrSuffix(""),
|
|
|
|
InlineAsmStart("#APP"),
|
|
|
|
InlineAsmEnd("#NO_APP"),
|
2007-01-16 11:42:04 +08:00
|
|
|
AssemblerDialect(0),
|
2006-09-07 02:35:33 +08: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),
|
|
|
|
ConstantPoolSection("\t.section .rodata\n"),
|
|
|
|
JumpTableDataSection("\t.section .rodata\n"),
|
2006-09-25 03:45:58 +08:00
|
|
|
JumpTableDirective(0),
|
2006-10-28 00:14:06 +08:00
|
|
|
CStringSection(0),
|
2006-09-07 02:35:33 +08:00
|
|
|
StaticCtorsSection("\t.section .ctors,\"aw\",@progbits"),
|
|
|
|
StaticDtorsSection("\t.section .dtors,\"aw\",@progbits"),
|
|
|
|
FourByteConstantSection(0),
|
|
|
|
EightByteConstantSection(0),
|
|
|
|
SixteenByteConstantSection(0),
|
2007-03-08 09:00:38 +08:00
|
|
|
ReadOnlySection(0),
|
2007-01-30 02:51:14 +08:00
|
|
|
GlobalDirective(0),
|
2006-09-07 02:35:33 +08:00
|
|
|
SetDirective(0),
|
|
|
|
LCOMMDirective(0),
|
|
|
|
COMMDirective("\t.comm\t"),
|
|
|
|
COMMDirectiveTakesAlignment(true),
|
|
|
|
HasDotTypeDotSizeDirective(true),
|
2006-09-26 11:38:18 +08:00
|
|
|
UsedDirective(0),
|
2006-12-02 04:47:11 +08:00
|
|
|
WeakRefDirective(0),
|
2007-01-14 14:27:21 +08:00
|
|
|
HiddenDirective("\t.hidden\t"),
|
2007-04-30 02:35:00 +08:00
|
|
|
ProtectedDirective("\t.protected\t"),
|
2007-05-02 06:23:12 +08:00
|
|
|
AbsoluteDebugSectionOffsets(false),
|
|
|
|
AbsoluteEHSectionOffsets(false),
|
2006-09-07 02:35:33 +08:00
|
|
|
HasLEB128(false),
|
|
|
|
HasDotLoc(false),
|
|
|
|
HasDotFile(false),
|
2007-01-30 02:51:14 +08:00
|
|
|
SupportsExceptionHandling(false),
|
2006-10-31 06:32:30 +08:00
|
|
|
DwarfRequiresFrameSection(true),
|
2007-03-07 10:47:57 +08:00
|
|
|
DwarfSectionOffsetDirective(0),
|
2006-09-07 02:35:33 +08: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-29 03:52:20 +08:00
|
|
|
DwarfMacInfoSection(".debug_macinfo"),
|
2007-02-02 00:31:34 +08:00
|
|
|
DwarfEHFrameSection(".eh_frame"),
|
2007-02-22 06:43:40 +08:00
|
|
|
DwarfExceptionSection(".gcc_except_table"),
|
2006-11-29 03:52:20 +08:00
|
|
|
AsmTransCBE(0) {
|
2006-10-14 01:50:07 +08:00
|
|
|
}
|
2006-10-05 08:35:16 +08:00
|
|
|
|
|
|
|
TargetAsmInfo::~TargetAsmInfo() {
|
|
|
|
}
|
2006-10-14 01:50:07 +08:00
|
|
|
|
|
|
|
/// Measure the specified inline asm to determine an approximation of its
|
|
|
|
/// length.
|
2007-04-24 04:00:17 +08: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-14 01:50:07 +08:00
|
|
|
unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
|
|
|
|
// Count the number of instructions in the asm.
|
2007-04-24 04:00:17 +08:00
|
|
|
bool atInsnStart = true;
|
|
|
|
unsigned Length = 0;
|
2006-10-14 01:50:07 +08:00
|
|
|
for (; *Str; ++Str) {
|
|
|
|
if (*Str == '\n' || *Str == SeparatorChar)
|
2007-04-24 04:00:17 +08:00
|
|
|
atInsnStart = true;
|
|
|
|
if (atInsnStart && !isspace(*Str)) {
|
|
|
|
Length += MaxInstLength;
|
|
|
|
atInsnStart = false;
|
|
|
|
}
|
|
|
|
if (atInsnStart && strncmp(Str, CommentString, strlen(CommentString))==0)
|
|
|
|
atInsnStart = false;
|
2006-10-14 01:50:07 +08:00
|
|
|
}
|
|
|
|
|
2007-04-24 04:00:17 +08:00
|
|
|
return Length;
|
2006-10-14 01:50:07 +08:00
|
|
|
}
|
2007-03-07 10:47:57 +08:00
|
|
|
|