mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-05 12:31:33 +00:00
Expose method and ivars for measuring inline asm length properly.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30934 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7445ea6b17
commit
4c7b07a66f
@ -27,7 +27,6 @@ namespace llvm {
|
|||||||
/// TargetAsmInfo - This class is intended to be used as a base class for asm
|
/// TargetAsmInfo - This class is intended to be used as a base class for asm
|
||||||
/// properties and features specific to the target.
|
/// properties and features specific to the target.
|
||||||
class TargetAsmInfo {
|
class TargetAsmInfo {
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//===------------------------------------------------------------------===//
|
//===------------------------------------------------------------------===//
|
||||||
// Properties to be set by the target writer, used to configure asm printer.
|
// Properties to be set by the target writer, used to configure asm printer.
|
||||||
@ -48,6 +47,15 @@ namespace llvm {
|
|||||||
/// NeedsSet - True if target asm can't compute addresses on data
|
/// NeedsSet - True if target asm can't compute addresses on data
|
||||||
/// directives.
|
/// directives.
|
||||||
bool NeedsSet; // Defaults to false.
|
bool NeedsSet; // Defaults to false.
|
||||||
|
|
||||||
|
/// MaxInstLength - This is the maximum possible length of an instruction,
|
||||||
|
/// which is needed to compute the size of an inline asm.
|
||||||
|
unsigned MaxInstLength; // Defaults to 4.
|
||||||
|
|
||||||
|
/// SeparatorChar - This character, if specified, is used to separate
|
||||||
|
/// instructions from each other when on the same line. This is used to
|
||||||
|
/// measure inline asm instructions.
|
||||||
|
char SeparatorChar; // Defaults to ';'
|
||||||
|
|
||||||
/// CommentString - This indicates the comment character used by the
|
/// CommentString - This indicates the comment character used by the
|
||||||
/// assembler.
|
/// assembler.
|
||||||
@ -261,6 +269,10 @@ namespace llvm {
|
|||||||
TargetAsmInfo();
|
TargetAsmInfo();
|
||||||
virtual ~TargetAsmInfo();
|
virtual ~TargetAsmInfo();
|
||||||
|
|
||||||
|
/// Measure the specified inline asm to determine an approximation of its
|
||||||
|
/// length.
|
||||||
|
unsigned getInlineAsmLength(const char *Str) const;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Accessors.
|
// Accessors.
|
||||||
//
|
//
|
||||||
@ -430,7 +442,6 @@ namespace llvm {
|
|||||||
return DwarfMacInfoSection;
|
return DwarfMacInfoSection;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -21,6 +21,8 @@ TargetAsmInfo::TargetAsmInfo() :
|
|||||||
DataSection(".data"),
|
DataSection(".data"),
|
||||||
AddressSize(4),
|
AddressSize(4),
|
||||||
NeedsSet(false),
|
NeedsSet(false),
|
||||||
|
MaxInstLength(4),
|
||||||
|
SeparatorChar(';'),
|
||||||
CommentString("#"),
|
CommentString("#"),
|
||||||
GlobalPrefix(""),
|
GlobalPrefix(""),
|
||||||
PrivateGlobalPrefix("."),
|
PrivateGlobalPrefix("."),
|
||||||
@ -71,8 +73,22 @@ TargetAsmInfo::TargetAsmInfo() :
|
|||||||
DwarfLocSection(".debug_loc"),
|
DwarfLocSection(".debug_loc"),
|
||||||
DwarfARangesSection(".debug_aranges"),
|
DwarfARangesSection(".debug_aranges"),
|
||||||
DwarfRangesSection(".debug_ranges"),
|
DwarfRangesSection(".debug_ranges"),
|
||||||
DwarfMacInfoSection(".debug_macinfo")
|
DwarfMacInfoSection(".debug_macinfo") {
|
||||||
{}
|
}
|
||||||
|
|
||||||
TargetAsmInfo::~TargetAsmInfo() {
|
TargetAsmInfo::~TargetAsmInfo() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Measure the specified inline asm to determine an approximation of its
|
||||||
|
/// length.
|
||||||
|
unsigned TargetAsmInfo::getInlineAsmLength(const char *Str) const {
|
||||||
|
// Count the number of instructions in the asm.
|
||||||
|
unsigned NumInsts = 0;
|
||||||
|
for (; *Str; ++Str) {
|
||||||
|
if (*Str == '\n' || *Str == SeparatorChar)
|
||||||
|
++NumInsts;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Multiply by the worst-case length for each instruction.
|
||||||
|
return NumInsts * MaxInstLength;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user