Changes in directory llvm/lib/Target:

TargetAsmInfo.cpp updated: 1.6 -> 1.7
---
Log message:

Expose method and ivars for measuring inline asm length properly.


---
Diffs of the changes:  (+18 -2)

 TargetAsmInfo.cpp |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)


Index: llvm/lib/Target/TargetAsmInfo.cpp
diff -u llvm/lib/Target/TargetAsmInfo.cpp:1.6 
llvm/lib/Target/TargetAsmInfo.cpp:1.7
--- llvm/lib/Target/TargetAsmInfo.cpp:1.6       Wed Oct  4 22:13:59 2006
+++ llvm/lib/Target/TargetAsmInfo.cpp   Fri Oct 13 12:50:07 2006
@@ -21,6 +21,8 @@
   DataSection(".data"),
   AddressSize(4),
   NeedsSet(false),
+  MaxInstLength(4),
+  SeparatorChar(';'),
   CommentString("#"),
   GlobalPrefix(""),
   PrivateGlobalPrefix("."),
@@ -71,8 +73,22 @@
   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;
+}



_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to