From ac2b198ec519e9b47f851e51c9bedddfd861ab11 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 14 Jan 2004 17:14:42 +0000 Subject: [PATCH] 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. llvm-svn: 10853 --- llvm/lib/Target/X86/Printer.cpp | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/llvm/lib/Target/X86/Printer.cpp b/llvm/lib/Target/X86/Printer.cpp index 4d586c01f5cb..5ac5c78f5c57 100644 --- a/llvm/lib/Target/X86/Printer.cpp +++ b/llvm/lib/Target/X86/Printer.cpp @@ -95,21 +95,6 @@ FunctionPass *createX86CodePrinterPass(std::ostream &o,TargetMachine &tm){ 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(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(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 @@ static inline char toOctal(int X) { /// 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(CVA->getOperand(i))->getRawValue(); if (C == '"') { @@ -230,7 +215,7 @@ void Printer::emitGlobalConstant(const Constant *CV) { O << "\t.zero\t " << TD.getTypeSize(CV->getType()) << "\n"; return; } else if (const ConstantArray *CVA = dyn_cast(CV)) { - if (isStringCompatible(CVA)) { + if (CVA->isString()) { O << "\t.ascii\t"; printAsCString(O, CVA); O << "\n";