[llvm-commits] CVS: llvm/lib/Target/X86/Printer.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Jan 14 11:15:01 PST 2004


Changes in directory llvm/lib/Target/X86:

Printer.cpp updated: 1.75 -> 1.76

---
Log message:

Eliminate the isStringCompatible function, using ConstantArray::isString.
It's not clear why the code was looking for signed chars < 0, but it can't
matter to the assembler anyway, so the check goes away.


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

Index: llvm/lib/Target/X86/Printer.cpp
diff -u llvm/lib/Target/X86/Printer.cpp:1.75 llvm/lib/Target/X86/Printer.cpp:1.76
--- llvm/lib/Target/X86/Printer.cpp:1.75	Sun Dec 14 07:24:14 2003
+++ llvm/lib/Target/X86/Printer.cpp	Wed Jan 14 11:14:42 2004
@@ -95,21 +95,6 @@
   return new Printer(o, tm);
 }
 
-/// isStringCompatible - Can we treat the specified array as a string?
-/// Only if it is an array of ubytes or non-negative sbytes.
-///
-static bool isStringCompatible(const ConstantArray *CVA) {
-  const Type *ETy = cast<ArrayType>(CVA->getType())->getElementType();
-  if (ETy == Type::UByteTy) return true;
-  if (ETy != Type::SByteTy) return false;
-
-  for (unsigned i = 0; i < CVA->getNumOperands(); ++i)
-    if (cast<ConstantSInt>(CVA->getOperand(i))->getValue() < 0)
-      return false;
-
-  return true;
-}
-
 /// toOctal - Convert the low order bits of X into an octal digit.
 ///
 static inline char toOctal(int X) {
@@ -120,10 +105,10 @@
 /// string, only if the predicate isStringCompatible is true.
 ///
 static void printAsCString(std::ostream &O, const ConstantArray *CVA) {
-  assert(isStringCompatible(CVA) && "Array is not string compatible!");
+  assert(CVA->isString() && "Array is not string compatible!");
 
   O << "\"";
-  for (unsigned i = 0; i < CVA->getNumOperands(); ++i) {
+  for (unsigned i = 0; i != CVA->getNumOperands(); ++i) {
     unsigned char C = cast<ConstantInt>(CVA->getOperand(i))->getRawValue();
 
     if (C == '"') {
@@ -230,7 +215,7 @@
     O << "\t.zero\t " << TD.getTypeSize(CV->getType()) << "\n";      
     return;
   } else if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV)) {
-    if (isStringCompatible(CVA)) {
+    if (CVA->isString()) {
       O << "\t.ascii\t";
       printAsCString(O, CVA);
       O << "\n";





More information about the llvm-commits mailing list