Remove some code that moved to the generic asm printer a long time ago.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@22407 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nate Begeman 2005-07-12 18:34:15 +00:00
parent fce2ddcefd
commit 63b3f9acae

View File

@ -225,90 +225,6 @@ static void SwitchSection(std::ostream &OS, std::string &CurSection,
}
}
/// 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) {
return (X&7)+'0';
}
// Possible states while outputting ASCII strings
namespace {
enum StringSection {
None,
Alpha,
Numeric
};
}
/// SwitchStringSection - manage the changes required to output bytes as
/// characters in a string vs. numeric decimal values
///
static inline void SwitchStringSection(std::ostream &O, StringSection NewSect,
StringSection &Current) {
if (Current == None) {
if (NewSect == Alpha)
O << "\t.byte \"";
else if (NewSect == Numeric)
O << "\t.byte ";
} else if (Current == Alpha) {
if (NewSect == None)
O << "\"";
else if (NewSect == Numeric)
O << "\"\n"
<< "\t.byte ";
} else if (Current == Numeric) {
if (NewSect == Alpha)
O << '\n'
<< "\t.byte \"";
else if (NewSect == Numeric)
O << ", ";
}
Current = NewSect;
}
/// getAsCString - Return the specified array as a C compatible
/// 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!");
if (CVA->getNumOperands() == 0)
return;
StringSection Current = None;
for (unsigned i = 0, e = CVA->getNumOperands(); i != e; ++i) {
unsigned char C = cast<ConstantInt>(CVA->getOperand(i))->getRawValue();
if (C == '"') {
SwitchStringSection(O, Alpha, Current);
O << "\"\"";
} else if (isprint(C)) {
SwitchStringSection(O, Alpha, Current);
O << C;
} else {
SwitchStringSection(O, Numeric, Current);
O << utostr((unsigned)C);
}
}
SwitchStringSection(O, None, Current);
O << '\n';
}
/// createDarwinAsmPrinterPass - Returns a pass that prints the PPC assembly
/// code for a MachineFunction to the given output stream, in a format that the
/// Darwin assembler can deal with.