mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-18 12:29:21 +00:00
* getAsString requires that the input array is string compatible, so
assert it. * Use WriteAsOperand instead of getStringValue for constants git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@2296 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ccc259635a
commit
4b1de8eb99
@ -22,6 +22,7 @@
|
|||||||
#include "llvm/Function.h"
|
#include "llvm/Function.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/SlotCalculator.h"
|
#include "llvm/SlotCalculator.h"
|
||||||
|
#include "llvm/Assembly/Writer.h"
|
||||||
#include "Support/StringExtras.h"
|
#include "Support/StringExtras.h"
|
||||||
#include "Support/HashExtras.h"
|
#include "Support/HashExtras.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
@ -472,41 +473,39 @@ static inline char toOctal(int X) {
|
|||||||
// the predicate isStringCompatible is true.
|
// the predicate isStringCompatible is true.
|
||||||
//
|
//
|
||||||
static string getAsCString(ConstantArray *CPA) {
|
static string getAsCString(ConstantArray *CPA) {
|
||||||
if (isStringCompatible(CPA)) {
|
assert(isStringCompatible(CPA) && "Array is not string compatible!");
|
||||||
string Result;
|
|
||||||
const Type *ETy = cast<ArrayType>(CPA->getType())->getElementType();
|
|
||||||
Result = "\"";
|
|
||||||
for (unsigned i = 0; i < CPA->getNumOperands(); ++i) {
|
|
||||||
unsigned char C = (ETy == Type::SByteTy) ?
|
|
||||||
(unsigned char)cast<ConstantSInt>(CPA->getOperand(i))->getValue() :
|
|
||||||
(unsigned char)cast<ConstantUInt>(CPA->getOperand(i))->getValue();
|
|
||||||
|
|
||||||
if (isprint(C)) {
|
string Result;
|
||||||
Result += C;
|
const Type *ETy = cast<ArrayType>(CPA->getType())->getElementType();
|
||||||
} else {
|
Result = "\"";
|
||||||
switch(C) {
|
for (unsigned i = 0; i < CPA->getNumOperands(); ++i) {
|
||||||
case '\a': Result += "\\a"; break;
|
unsigned char C = (ETy == Type::SByteTy) ?
|
||||||
case '\b': Result += "\\b"; break;
|
(unsigned char)cast<ConstantSInt>(CPA->getOperand(i))->getValue() :
|
||||||
case '\f': Result += "\\f"; break;
|
(unsigned char)cast<ConstantUInt>(CPA->getOperand(i))->getValue();
|
||||||
case '\n': Result += "\\n"; break;
|
|
||||||
case '\r': Result += "\\r"; break;
|
if (isprint(C)) {
|
||||||
case '\t': Result += "\\t"; break;
|
Result += C;
|
||||||
case '\v': Result += "\\v"; break;
|
} else {
|
||||||
default:
|
switch(C) {
|
||||||
Result += '\\';
|
case '\a': Result += "\\a"; break;
|
||||||
Result += toOctal(C >> 6);
|
case '\b': Result += "\\b"; break;
|
||||||
Result += toOctal(C >> 3);
|
case '\f': Result += "\\f"; break;
|
||||||
Result += toOctal(C >> 0);
|
case '\n': Result += "\\n"; break;
|
||||||
break;
|
case '\r': Result += "\\r"; break;
|
||||||
}
|
case '\t': Result += "\\t"; break;
|
||||||
|
case '\v': Result += "\\v"; break;
|
||||||
|
default:
|
||||||
|
Result += '\\';
|
||||||
|
Result += toOctal(C >> 6);
|
||||||
|
Result += toOctal(C >> 3);
|
||||||
|
Result += toOctal(C >> 0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Result += "\"";
|
|
||||||
|
|
||||||
return Result;
|
|
||||||
} else {
|
|
||||||
return CPA->getStrValue();
|
|
||||||
}
|
}
|
||||||
|
Result += "\"";
|
||||||
|
|
||||||
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
@ -631,7 +630,7 @@ SparcModuleAsmPrinter::printSingleConstant(const Constant* CV)
|
|||||||
toAsm << "\t! " << CV->getType()->getDescription()
|
toAsm << "\t! " << CV->getType()->getDescription()
|
||||||
<< " value: " << Val << "\n";
|
<< " value: " << Val << "\n";
|
||||||
} else {
|
} else {
|
||||||
toAsm << CV->getStrValue() << "\n";
|
WriteAsOperand(toAsm, CV, false, false) << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ConstantPointer* CPP = dyn_cast<ConstantPointer>(CV))
|
else if (ConstantPointer* CPP = dyn_cast<ConstantPointer>(CV))
|
||||||
|
Loading…
Reference in New Issue
Block a user