diff options
author | Chris Lattner <sabre@nondot.org> | 2004-01-14 17:14:42 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-01-14 17:14:42 +0000 |
commit | aa06d0439ec183c2a7546c38ff50dbcfb285261b (patch) | |
tree | e0c5775713b7e8f91e0e37ad2fe1744bba59030f | |
parent | e3f84f53cac6e00c1eb819d9a1bba09037bcf7f7 (diff) | |
download | external_llvm-aa06d0439ec183c2a7546c38ff50dbcfb285261b.zip external_llvm-aa06d0439ec183c2a7546c38ff50dbcfb285261b.tar.gz external_llvm-aa06d0439ec183c2a7546c38ff50dbcfb285261b.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10853 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/X86/Printer.cpp | 21 | ||||
-rw-r--r-- | lib/Target/X86/X86AsmPrinter.cpp | 21 |
2 files changed, 6 insertions, 36 deletions
diff --git a/lib/Target/X86/Printer.cpp b/lib/Target/X86/Printer.cpp index 4d586c0..5ac5c78 100644 --- a/lib/Target/X86/Printer.cpp +++ b/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<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 @@ 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<ConstantInt>(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<ConstantArray>(CV)) { - if (isStringCompatible(CVA)) { + if (CVA->isString()) { O << "\t.ascii\t"; printAsCString(O, CVA); O << "\n"; diff --git a/lib/Target/X86/X86AsmPrinter.cpp b/lib/Target/X86/X86AsmPrinter.cpp index 4d586c0..5ac5c78 100644 --- a/lib/Target/X86/X86AsmPrinter.cpp +++ b/lib/Target/X86/X86AsmPrinter.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<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 @@ 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<ConstantInt>(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<ConstantArray>(CV)) { - if (isStringCompatible(CVA)) { + if (CVA->isString()) { O << "\t.ascii\t"; printAsCString(O, CVA); O << "\n"; |