aboutsummaryrefslogtreecommitdiff
path: root/lib/Target/TargetAsmInfo.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-10-13 17:50:07 +0000
committerChris Lattner <sabre@nondot.org>2006-10-13 17:50:07 +0000
commit4c7b07a66f3d5c14339a6181fa12d060aeb9b18c (patch)
tree96b7a30dbf78a771a6fb5f333a391d3f0bce08c8 /lib/Target/TargetAsmInfo.cpp
parent7445ea6b177abcf7da1daa4abe5cbbb014fbb932 (diff)
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
Diffstat (limited to 'lib/Target/TargetAsmInfo.cpp')
-rw-r--r--lib/Target/TargetAsmInfo.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/lib/Target/TargetAsmInfo.cpp b/lib/Target/TargetAsmInfo.cpp
index 79c064c371..7d463ce572 100644
--- a/lib/Target/TargetAsmInfo.cpp
+++ b/lib/Target/TargetAsmInfo.cpp
@@ -21,6 +21,8 @@ TargetAsmInfo::TargetAsmInfo() :
DataSection(".data"),
AddressSize(4),
NeedsSet(false),
+ MaxInstLength(4),
+ SeparatorChar(';'),
CommentString("#"),
GlobalPrefix(""),
PrivateGlobalPrefix("."),
@@ -71,8 +73,22 @@ TargetAsmInfo::TargetAsmInfo() :
DwarfLocSection(".debug_loc"),
DwarfARangesSection(".debug_aranges"),
DwarfRangesSection(".debug_ranges"),
- DwarfMacInfoSection(".debug_macinfo")
-{}
+ DwarfMacInfoSection(".debug_macinfo") {
+}
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;
+}