mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-30 07:00:57 +00:00
emit .ascii and .asciz through MCStreamer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94282 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
33b1758e16
commit
05f845314a
@ -340,10 +340,6 @@ namespace llvm {
|
|||||||
/// EmitGlobalConstant - Print a general LLVM constant to the .s file.
|
/// EmitGlobalConstant - Print a general LLVM constant to the .s file.
|
||||||
void EmitGlobalConstant(const Constant* CV, unsigned AddrSpace = 0);
|
void EmitGlobalConstant(const Constant* CV, unsigned AddrSpace = 0);
|
||||||
|
|
||||||
/// EmitString - Emit a zero-byte-terminated string constant.
|
|
||||||
///
|
|
||||||
virtual void EmitString(const ConstantArray *CVA) const;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/// EmitConstantValueOnly - Print out the specified constant, without a
|
/// EmitConstantValueOnly - Print out the specified constant, without a
|
||||||
/// storage class. Only constants of first-class type are allowed here.
|
/// storage class. Only constants of first-class type are allowed here.
|
||||||
|
@ -683,6 +683,7 @@ void AsmPrinter::EmitInt64(uint64_t Value) const {
|
|||||||
OutStreamer.EmitIntValue(Value, 8, 0/*addrspace*/);
|
OutStreamer.EmitIntValue(Value, 8, 0/*addrspace*/);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// toOctal - Convert the low order bits of X into an octal digit.
|
/// toOctal - Convert the low order bits of X into an octal digit.
|
||||||
///
|
///
|
||||||
static inline char toOctal(int X) {
|
static inline char toOctal(int X) {
|
||||||
@ -900,45 +901,22 @@ void AsmPrinter::EmitConstantValueOnly(const Constant *CV) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// printAsCString - Print the specified array as a C compatible string, only if
|
|
||||||
/// the predicate isString is true.
|
|
||||||
///
|
|
||||||
static void printAsCString(formatted_raw_ostream &O, const ConstantArray *CVA,
|
|
||||||
unsigned LastElt) {
|
|
||||||
assert(CVA->isString() && "Array is not string compatible!");
|
|
||||||
|
|
||||||
O << '\"';
|
|
||||||
for (unsigned i = 0; i != LastElt; ++i) {
|
|
||||||
unsigned char C =
|
|
||||||
(unsigned char)cast<ConstantInt>(CVA->getOperand(i))->getZExtValue();
|
|
||||||
printStringChar(O, C);
|
|
||||||
}
|
|
||||||
O << '\"';
|
|
||||||
}
|
|
||||||
|
|
||||||
/// EmitString - Emit a zero-byte-terminated string constant.
|
|
||||||
///
|
|
||||||
void AsmPrinter::EmitString(const ConstantArray *CVA) const {
|
|
||||||
unsigned NumElts = CVA->getNumOperands();
|
|
||||||
if (MAI->getAscizDirective() && NumElts &&
|
|
||||||
cast<ConstantInt>(CVA->getOperand(NumElts-1))->getZExtValue() == 0) {
|
|
||||||
O << MAI->getAscizDirective();
|
|
||||||
printAsCString(O, CVA, NumElts-1);
|
|
||||||
} else {
|
|
||||||
O << MAI->getAsciiDirective();
|
|
||||||
printAsCString(O, CVA, NumElts);
|
|
||||||
}
|
|
||||||
O << '\n';
|
|
||||||
}
|
|
||||||
|
|
||||||
static void EmitGlobalConstantArray(const ConstantArray *CA, unsigned AddrSpace,
|
static void EmitGlobalConstantArray(const ConstantArray *CA, unsigned AddrSpace,
|
||||||
AsmPrinter &AP) {
|
AsmPrinter &AP) {
|
||||||
if (AddrSpace == 0 && CA->isString()) {
|
if (AddrSpace != 0 || !CA->isString()) {
|
||||||
AP.EmitString(CA);
|
// Not a string. Print the values in successive locations
|
||||||
} else { // Not a string. Print the values in successive locations
|
|
||||||
for (unsigned i = 0, e = CA->getNumOperands(); i != e; ++i)
|
for (unsigned i = 0, e = CA->getNumOperands(); i != e; ++i)
|
||||||
AP.EmitGlobalConstant(CA->getOperand(i), AddrSpace);
|
AP.EmitGlobalConstant(CA->getOperand(i), AddrSpace);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Otherwise, it can be emitted as .ascii.
|
||||||
|
SmallVector<char, 128> TmpVec;
|
||||||
|
TmpVec.reserve(CA->getNumOperands());
|
||||||
|
for (unsigned i = 0, e = CA->getNumOperands(); i != e; ++i)
|
||||||
|
TmpVec.push_back(cast<ConstantInt>(CA->getOperand(i))->getZExtValue());
|
||||||
|
|
||||||
|
AP.OutStreamer.EmitBytes(StringRef(TmpVec.data(), TmpVec.size()), AddrSpace);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void EmitGlobalConstantVector(const ConstantVector *CV,
|
static void EmitGlobalConstantVector(const ConstantVector *CV,
|
||||||
|
@ -75,14 +75,14 @@
|
|||||||
; LINUX: .section .gnu.linkonce.r.G6,"a",@progbits
|
; LINUX: .section .gnu.linkonce.r.G6,"a",@progbits
|
||||||
; LINUX: .weak G6
|
; LINUX: .weak G6
|
||||||
; LINUX: G6:
|
; LINUX: G6:
|
||||||
; LINUX: .ascii "\001"
|
; LINUX: .byte 1
|
||||||
; LINUX: .size G6, 1
|
; LINUX: .size G6, 1
|
||||||
|
|
||||||
; DARWIN: .section __TEXT,__const_coal,coalesced
|
; DARWIN: .section __TEXT,__const_coal,coalesced
|
||||||
; DARWIN: .globl _G6
|
; DARWIN: .globl _G6
|
||||||
; DARWIN: .weak_definition _G6
|
; DARWIN: .weak_definition _G6
|
||||||
; DARWIN:_G6:
|
; DARWIN:_G6:
|
||||||
; DARWIN: .ascii "\001"
|
; DARWIN: .byte 1
|
||||||
|
|
||||||
|
|
||||||
@G7 = constant [10 x i8] c"abcdefghi\00"
|
@G7 = constant [10 x i8] c"abcdefghi\00"
|
||||||
|
Loading…
Reference in New Issue
Block a user