1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

Remove address spaces from MC.

This is dead code since PIC16 was removed in 2010. The result was an odd mix,
where some parts would carefully pass it along and others would assert it was
zero (most of the object streamer for example).

llvm-svn: 185436
This commit is contained in:
Rafael Espindola 2013-07-02 15:49:13 +00:00
parent 750b064fa2
commit 304ef43e7d
24 changed files with 153 additions and 209 deletions

View File

@ -233,8 +233,8 @@ namespace llvm {
/// it if appropriate.
void EmitBasicBlockStart(const MachineBasicBlock *MBB) const;
/// EmitGlobalConstant - Print a general LLVM constant to the .s file.
void EmitGlobalConstant(const Constant *CV, unsigned AddrSpace = 0);
/// \brief Print a general LLVM constant to the .s file.
void EmitGlobalConstant(const Constant *CV);
//===------------------------------------------------------------------===//

View File

@ -200,13 +200,6 @@ namespace llvm {
/// on Mips or .gprel32 on Alpha.
const char *GPRel32Directive; // Defaults to NULL.
/// getDataASDirective - Return the directive that should be used to emit
/// data of the specified size to the specified numeric address space.
virtual const char *getDataASDirective(unsigned Size, unsigned AS) const {
assert(AS != 0 && "Don't know the directives for default addr space");
return 0;
}
/// SunStyleELFSectionSwitchSyntax - This is true if this target uses "Sun
/// Style" syntax for section switching ("#alloc,#write" etc) instead of the
/// normal ELF syntax (,"a,w") in .section directives.
@ -372,17 +365,17 @@ namespace llvm {
// Data directive accessors.
//
const char *getData8bitsDirective(unsigned AS = 0) const {
return AS == 0 ? Data8bitsDirective : getDataASDirective(8, AS);
const char *getData8bitsDirective() const {
return Data8bitsDirective;
}
const char *getData16bitsDirective(unsigned AS = 0) const {
return AS == 0 ? Data16bitsDirective : getDataASDirective(16, AS);
const char *getData16bitsDirective() const {
return Data16bitsDirective;
}
const char *getData32bitsDirective(unsigned AS = 0) const {
return AS == 0 ? Data32bitsDirective : getDataASDirective(32, AS);
const char *getData32bitsDirective() const {
return Data32bitsDirective;
}
const char *getData64bitsDirective(unsigned AS = 0) const {
return AS == 0 ? Data64bitsDirective : getDataASDirective(64, AS);
const char *getData64bitsDirective() const {
return Data64bitsDirective;
}
const char *getGPRel64Directive() const { return GPRel64Directive; }
const char *getGPRel32Directive() const { return GPRel32Directive; }

View File

@ -77,8 +77,7 @@ public:
uint64_t Size = 0, unsigned ByteAlignment = 0);
virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
uint64_t Size, unsigned ByteAlignment = 0);
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
unsigned AddrSpace);
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size);
virtual void EmitFileDirective(StringRef Filename);

View File

@ -78,8 +78,7 @@ public:
virtual void EmitLabel(MCSymbol *Symbol);
virtual void EmitDebugLabel(MCSymbol *Symbol);
virtual void EmitAssignment(MCSymbol *Symbol, const MCExpr *Value);
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
unsigned AddrSpace);
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size);
virtual void EmitULEB128Value(const MCExpr *Value);
virtual void EmitSLEB128Value(const MCExpr *Value);
virtual void EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol);
@ -94,7 +93,7 @@ public:
virtual void EmitBundleAlignMode(unsigned AlignPow2);
virtual void EmitBundleLock(bool AlignToEnd);
virtual void EmitBundleUnlock();
virtual void EmitBytes(StringRef Data, unsigned AddrSpace = 0);
virtual void EmitBytes(StringRef Data);
virtual void EmitValueToAlignment(unsigned ByteAlignment,
int64_t Value = 0,
unsigned ValueSize = 1,
@ -114,9 +113,8 @@ public:
const MCSymbol *Label);
virtual void EmitGPRel32Value(const MCExpr *Value);
virtual void EmitGPRel64Value(const MCExpr *Value);
virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue,
unsigned AddrSpace = 0);
virtual void EmitZeros(uint64_t NumBytes, unsigned AddrSpace = 0);
virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue);
virtual void EmitZeros(uint64_t NumBytes);
virtual void FinishImpl();
/// @}

View File

@ -407,7 +407,7 @@ namespace llvm {
///
/// This is used to implement assembler directives such as .byte, .ascii,
/// etc.
virtual void EmitBytes(StringRef Data, unsigned AddrSpace = 0) = 0;
virtual void EmitBytes(StringRef Data) = 0;
/// EmitValue - Emit the expression @p Value into the output as a native
/// integer of the given @p Size bytes.
@ -418,22 +418,19 @@ namespace llvm {
/// @param Value - The value to emit.
/// @param Size - The size of the integer (in bytes) to emit. This must
/// match a native machine width.
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
unsigned AddrSpace) = 0;
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size) = 0;
void EmitValue(const MCExpr *Value, unsigned Size, unsigned AddrSpace = 0);
void EmitValue(const MCExpr *Value, unsigned Size);
/// EmitIntValue - Special case of EmitValue that avoids the client having
/// to pass in a MCExpr for constant integers.
virtual void EmitIntValue(uint64_t Value, unsigned Size,
unsigned AddrSpace = 0);
virtual void EmitIntValue(uint64_t Value, unsigned Size);
/// EmitAbsValue - Emit the Value, but try to avoid relocations. On MachO
/// this is done by producing
/// foo = value
/// .long foo
void EmitAbsValue(const MCExpr *Value, unsigned Size,
unsigned AddrSpace = 0);
void EmitAbsValue(const MCExpr *Value, unsigned Size);
virtual void EmitULEB128Value(const MCExpr *Value) = 0;
@ -441,17 +438,15 @@ namespace llvm {
/// EmitULEB128Value - Special case of EmitULEB128Value that avoids the
/// client having to pass in a MCExpr for constant integers.
void EmitULEB128IntValue(uint64_t Value, unsigned Padding = 0,
unsigned AddrSpace = 0);
void EmitULEB128IntValue(uint64_t Value, unsigned Padding = 0);
/// EmitSLEB128Value - Special case of EmitSLEB128Value that avoids the
/// client having to pass in a MCExpr for constant integers.
void EmitSLEB128IntValue(int64_t Value, unsigned AddrSpace = 0);
void EmitSLEB128IntValue(int64_t Value);
/// EmitSymbolValue - Special case of EmitValue that avoids the client
/// having to pass in a MCExpr for MCSymbols.
void EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
unsigned AddrSpace = 0);
void EmitSymbolValue(const MCSymbol *Sym, unsigned Size);
/// EmitGPRel64Value - Emit the expression @p Value into the output as a
/// gprel64 (64-bit GP relative) value.
@ -469,12 +464,11 @@ namespace llvm {
/// EmitFill - Emit NumBytes bytes worth of the value specified by
/// FillValue. This implements directives such as '.space'.
virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue,
unsigned AddrSpace = 0);
virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue);
/// \brief EmitZeros - Emit NumBytes worth of zeros.
/// \brief Emit NumBytes worth of zeros.
/// This function properly handles data in virtual sections.
virtual void EmitZeros(uint64_t NumBytes, unsigned AddrSpace = 0);
virtual void EmitZeros(uint64_t NumBytes);
/// EmitValueToAlignment - Emit some number of copies of @p Value until
/// the byte alignment @p ByteAlignment is reached.

View File

@ -1578,8 +1578,7 @@ static const MCExpr *lowerConstant(const Constant *CV, AsmPrinter &AP) {
}
}
static void emitGlobalConstantImpl(const Constant *C, unsigned AddrSpace,
AsmPrinter &AP);
static void emitGlobalConstantImpl(const Constant *C, AsmPrinter &AP);
/// isRepeatedByteSequence - Determine whether the given value is
/// composed of a repeated sequence of identical bytes and return the
@ -1641,7 +1640,7 @@ static int isRepeatedByteSequence(const Value *V, TargetMachine &TM) {
}
static void emitGlobalConstantDataSequential(const ConstantDataSequential *CDS,
unsigned AddrSpace,AsmPrinter &AP){
AsmPrinter &AP){
// See if we can aggregate this into a .fill, if so, emit it as such.
int Value = isRepeatedByteSequence(CDS, AP.TM);
@ -1649,12 +1648,12 @@ static void emitGlobalConstantDataSequential(const ConstantDataSequential *CDS,
uint64_t Bytes = AP.TM.getDataLayout()->getTypeAllocSize(CDS->getType());
// Don't emit a 1-byte object as a .fill.
if (Bytes > 1)
return AP.OutStreamer.EmitFill(Bytes, Value, AddrSpace);
return AP.OutStreamer.EmitFill(Bytes, Value);
}
// If this can be emitted with .ascii/.asciz, emit it as such.
if (CDS->isString())
return AP.OutStreamer.EmitBytes(CDS->getAsString(), AddrSpace);
return AP.OutStreamer.EmitBytes(CDS->getAsString());
// Otherwise, emit the values in successive locations.
unsigned ElementByteSize = CDS->getElementByteSize();
@ -1664,7 +1663,7 @@ static void emitGlobalConstantDataSequential(const ConstantDataSequential *CDS,
AP.OutStreamer.GetCommentOS() << format("0x%" PRIx64 "\n",
CDS->getElementAsInteger(i));
AP.OutStreamer.EmitIntValue(CDS->getElementAsInteger(i),
ElementByteSize, AddrSpace);
ElementByteSize);
}
} else if (ElementByteSize == 4) {
// FP Constants are printed as integer constants to avoid losing
@ -1679,7 +1678,7 @@ static void emitGlobalConstantDataSequential(const ConstantDataSequential *CDS,
F = CDS->getElementAsFloat(i);
if (AP.isVerbose())
AP.OutStreamer.GetCommentOS() << "float " << F << '\n';
AP.OutStreamer.EmitIntValue(I, 4, AddrSpace);
AP.OutStreamer.EmitIntValue(I, 4);
}
} else {
assert(CDS->getElementType()->isDoubleTy());
@ -1692,7 +1691,7 @@ static void emitGlobalConstantDataSequential(const ConstantDataSequential *CDS,
F = CDS->getElementAsDouble(i);
if (AP.isVerbose())
AP.OutStreamer.GetCommentOS() << "double " << F << '\n';
AP.OutStreamer.EmitIntValue(I, 8, AddrSpace);
AP.OutStreamer.EmitIntValue(I, 8);
}
}
@ -1701,41 +1700,38 @@ static void emitGlobalConstantDataSequential(const ConstantDataSequential *CDS,
unsigned EmittedSize = TD.getTypeAllocSize(CDS->getType()->getElementType()) *
CDS->getNumElements();
if (unsigned Padding = Size - EmittedSize)
AP.OutStreamer.EmitZeros(Padding, AddrSpace);
AP.OutStreamer.EmitZeros(Padding);
}
static void emitGlobalConstantArray(const ConstantArray *CA, unsigned AddrSpace,
AsmPrinter &AP) {
static void emitGlobalConstantArray(const ConstantArray *CA, AsmPrinter &AP) {
// See if we can aggregate some values. Make sure it can be
// represented as a series of bytes of the constant value.
int Value = isRepeatedByteSequence(CA, AP.TM);
if (Value != -1) {
uint64_t Bytes = AP.TM.getDataLayout()->getTypeAllocSize(CA->getType());
AP.OutStreamer.EmitFill(Bytes, Value, AddrSpace);
AP.OutStreamer.EmitFill(Bytes, Value);
}
else {
for (unsigned i = 0, e = CA->getNumOperands(); i != e; ++i)
emitGlobalConstantImpl(CA->getOperand(i), AddrSpace, AP);
emitGlobalConstantImpl(CA->getOperand(i), AP);
}
}
static void emitGlobalConstantVector(const ConstantVector *CV,
unsigned AddrSpace, AsmPrinter &AP) {
static void emitGlobalConstantVector(const ConstantVector *CV, AsmPrinter &AP) {
for (unsigned i = 0, e = CV->getType()->getNumElements(); i != e; ++i)
emitGlobalConstantImpl(CV->getOperand(i), AddrSpace, AP);
emitGlobalConstantImpl(CV->getOperand(i), AP);
const DataLayout &TD = *AP.TM.getDataLayout();
unsigned Size = TD.getTypeAllocSize(CV->getType());
unsigned EmittedSize = TD.getTypeAllocSize(CV->getType()->getElementType()) *
CV->getType()->getNumElements();
if (unsigned Padding = Size - EmittedSize)
AP.OutStreamer.EmitZeros(Padding, AddrSpace);
AP.OutStreamer.EmitZeros(Padding);
}
static void emitGlobalConstantStruct(const ConstantStruct *CS,
unsigned AddrSpace, AsmPrinter &AP) {
static void emitGlobalConstantStruct(const ConstantStruct *CS, AsmPrinter &AP) {
// Print the fields in successive locations. Pad to align if needed!
const DataLayout *TD = AP.TM.getDataLayout();
unsigned Size = TD->getTypeAllocSize(CS->getType());
@ -1751,19 +1747,18 @@ static void emitGlobalConstantStruct(const ConstantStruct *CS,
SizeSoFar += FieldSize + PadSize;
// Now print the actual field value.
emitGlobalConstantImpl(Field, AddrSpace, AP);
emitGlobalConstantImpl(Field, AP);
// Insert padding - this may include padding to increase the size of the
// current field up to the ABI size (if the struct is not packed) as well
// as padding to ensure that the next field starts at the right offset.
AP.OutStreamer.EmitZeros(PadSize, AddrSpace);
AP.OutStreamer.EmitZeros(PadSize);
}
assert(SizeSoFar == Layout->getSizeInBytes() &&
"Layout of constant struct may be incorrect!");
}
static void emitGlobalConstantFP(const ConstantFP *CFP, unsigned AddrSpace,
AsmPrinter &AP) {
static void emitGlobalConstantFP(const ConstantFP *CFP, AsmPrinter &AP) {
APInt API = CFP->getValueAPF().bitcastToAPInt();
// First print a comment with what we think the original floating-point value
@ -1789,27 +1784,26 @@ static void emitGlobalConstantFP(const ConstantFP *CFP, unsigned AddrSpace,
int Chunk = API.getNumWords() - 1;
if (TrailingBytes)
AP.OutStreamer.EmitIntValue(p[Chunk--], TrailingBytes, AddrSpace);
AP.OutStreamer.EmitIntValue(p[Chunk--], TrailingBytes);
for (; Chunk >= 0; --Chunk)
AP.OutStreamer.EmitIntValue(p[Chunk], sizeof(uint64_t), AddrSpace);
AP.OutStreamer.EmitIntValue(p[Chunk], sizeof(uint64_t));
} else {
unsigned Chunk;
for (Chunk = 0; Chunk < NumBytes / sizeof(uint64_t); ++Chunk)
AP.OutStreamer.EmitIntValue(p[Chunk], sizeof(uint64_t), AddrSpace);
AP.OutStreamer.EmitIntValue(p[Chunk], sizeof(uint64_t));
if (TrailingBytes)
AP.OutStreamer.EmitIntValue(p[Chunk], TrailingBytes, AddrSpace);
AP.OutStreamer.EmitIntValue(p[Chunk], TrailingBytes);
}
// Emit the tail padding for the long double.
const DataLayout &TD = *AP.TM.getDataLayout();
AP.OutStreamer.EmitZeros(TD.getTypeAllocSize(CFP->getType()) -
TD.getTypeStoreSize(CFP->getType()), AddrSpace);
TD.getTypeStoreSize(CFP->getType()));
}
static void emitGlobalConstantLargeInt(const ConstantInt *CI,
unsigned AddrSpace, AsmPrinter &AP) {
static void emitGlobalConstantLargeInt(const ConstantInt *CI, AsmPrinter &AP) {
const DataLayout *TD = AP.TM.getDataLayout();
unsigned BitWidth = CI->getBitWidth();
@ -1849,7 +1843,7 @@ static void emitGlobalConstantLargeInt(const ConstantInt *CI,
const uint64_t *RawData = Realigned.getRawData();
for (unsigned i = 0, e = BitWidth / 64; i != e; ++i) {
uint64_t Val = TD->isBigEndian() ? RawData[e - i - 1] : RawData[i];
AP.OutStreamer.EmitIntValue(Val, 8, AddrSpace);
AP.OutStreamer.EmitIntValue(Val, 8);
}
if (ExtraBitsSize) {
@ -1861,16 +1855,15 @@ static void emitGlobalConstantLargeInt(const ConstantInt *CI,
assert(Size && Size * 8 >= ExtraBitsSize &&
(ExtraBits & (((uint64_t)-1) >> (64 - ExtraBitsSize)))
== ExtraBits && "Directive too small for extra bits.");
AP.OutStreamer.EmitIntValue(ExtraBits, Size, AddrSpace);
AP.OutStreamer.EmitIntValue(ExtraBits, Size);
}
}
static void emitGlobalConstantImpl(const Constant *CV, unsigned AddrSpace,
AsmPrinter &AP) {
static void emitGlobalConstantImpl(const Constant *CV, AsmPrinter &AP) {
const DataLayout *TD = AP.TM.getDataLayout();
uint64_t Size = TD->getTypeAllocSize(CV->getType());
if (isa<ConstantAggregateZero>(CV) || isa<UndefValue>(CV))
return AP.OutStreamer.EmitZeros(Size, AddrSpace);
return AP.OutStreamer.EmitZeros(Size);
if (const ConstantInt *CI = dyn_cast<ConstantInt>(CV)) {
switch (Size) {
@ -1881,36 +1874,36 @@ static void emitGlobalConstantImpl(const Constant *CV, unsigned AddrSpace,
if (AP.isVerbose())
AP.OutStreamer.GetCommentOS() << format("0x%" PRIx64 "\n",
CI->getZExtValue());
AP.OutStreamer.EmitIntValue(CI->getZExtValue(), Size, AddrSpace);
AP.OutStreamer.EmitIntValue(CI->getZExtValue(), Size);
return;
default:
emitGlobalConstantLargeInt(CI, AddrSpace, AP);
emitGlobalConstantLargeInt(CI, AP);
return;
}
}
if (const ConstantFP *CFP = dyn_cast<ConstantFP>(CV))
return emitGlobalConstantFP(CFP, AddrSpace, AP);
return emitGlobalConstantFP(CFP, AP);
if (isa<ConstantPointerNull>(CV)) {
AP.OutStreamer.EmitIntValue(0, Size, AddrSpace);
AP.OutStreamer.EmitIntValue(0, Size);
return;
}
if (const ConstantDataSequential *CDS = dyn_cast<ConstantDataSequential>(CV))
return emitGlobalConstantDataSequential(CDS, AddrSpace, AP);
return emitGlobalConstantDataSequential(CDS, AP);
if (const ConstantArray *CVA = dyn_cast<ConstantArray>(CV))
return emitGlobalConstantArray(CVA, AddrSpace, AP);
return emitGlobalConstantArray(CVA, AP);
if (const ConstantStruct *CVS = dyn_cast<ConstantStruct>(CV))
return emitGlobalConstantStruct(CVS, AddrSpace, AP);
return emitGlobalConstantStruct(CVS, AP);
if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CV)) {
// Look through bitcasts, which might not be able to be MCExpr'ized (e.g. of
// vectors).
if (CE->getOpcode() == Instruction::BitCast)
return emitGlobalConstantImpl(CE->getOperand(0), AddrSpace, AP);
return emitGlobalConstantImpl(CE->getOperand(0), AP);
if (Size > 8) {
// If the constant expression's size is greater than 64-bits, then we have
@ -1918,27 +1911,27 @@ static void emitGlobalConstantImpl(const Constant *CV, unsigned AddrSpace,
// that way.
Constant *New = ConstantFoldConstantExpression(CE, TD);
if (New && New != CE)
return emitGlobalConstantImpl(New, AddrSpace, AP);
return emitGlobalConstantImpl(New, AP);
}
}
if (const ConstantVector *V = dyn_cast<ConstantVector>(CV))
return emitGlobalConstantVector(V, AddrSpace, AP);
return emitGlobalConstantVector(V, AP);
// Otherwise, it must be a ConstantExpr. Lower it to an MCExpr, then emit it
// thread the streamer with EmitValue.
AP.OutStreamer.EmitValue(lowerConstant(CV, AP), Size, AddrSpace);
AP.OutStreamer.EmitValue(lowerConstant(CV, AP), Size);
}
/// EmitGlobalConstant - Print a general LLVM constant to the .s file.
void AsmPrinter::EmitGlobalConstant(const Constant *CV, unsigned AddrSpace) {
void AsmPrinter::EmitGlobalConstant(const Constant *CV) {
uint64_t Size = TM.getDataLayout()->getTypeAllocSize(CV->getType());
if (Size)
emitGlobalConstantImpl(CV, AddrSpace, *this);
emitGlobalConstantImpl(CV, *this);
else if (MAI->hasSubsectionsViaSymbols()) {
// If the global has zero size, emit a single byte so that two labels don't
// look like they are at the same location.
OutStreamer.EmitIntValue(0, 1, AddrSpace);
OutStreamer.EmitIntValue(0, 1);
}
}

View File

@ -2247,7 +2247,7 @@ void DwarfDebug::emitDebugPubnames() {
if (Asm->isVerbose())
Asm->OutStreamer.AddComment("External Name");
Asm->OutStreamer.EmitBytes(StringRef(Name, GI->getKeyLength()+1), 0);
Asm->OutStreamer.EmitBytes(StringRef(Name, GI->getKeyLength()+1));
}
Asm->OutStreamer.AddComment("End Mark");

View File

@ -180,12 +180,10 @@ public:
virtual void EmitTBSSSymbol (const MCSection *Section, MCSymbol *Symbol,
uint64_t Size, unsigned ByteAlignment = 0);
virtual void EmitBytes(StringRef Data, unsigned AddrSpace);
virtual void EmitBytes(StringRef Data);
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
unsigned AddrSpace);
virtual void EmitIntValue(uint64_t Value, unsigned Size,
unsigned AddrSpace = 0);
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size);
virtual void EmitIntValue(uint64_t Value, unsigned Size);
virtual void EmitULEB128Value(const MCExpr *Value);
@ -196,8 +194,7 @@ public:
virtual void EmitGPRel32Value(const MCExpr *Value);
virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue,
unsigned AddrSpace);
virtual void EmitFill(uint64_t NumBytes, uint8_t FillValue);
virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
unsigned ValueSize = 1,
@ -636,13 +633,13 @@ static void PrintQuotedString(StringRef Data, raw_ostream &OS) {
}
void MCAsmStreamer::EmitBytes(StringRef Data, unsigned AddrSpace) {
void MCAsmStreamer::EmitBytes(StringRef Data) {
assert(getCurrentSection().first &&
"Cannot emit contents before setting section!");
if (Data.empty()) return;
if (Data.size() == 1) {
OS << MAI->getData8bitsDirective(AddrSpace);
OS << MAI->getData8bitsDirective();
OS << (unsigned)(unsigned char)Data[0];
EmitEOL();
return;
@ -662,34 +659,32 @@ void MCAsmStreamer::EmitBytes(StringRef Data, unsigned AddrSpace) {
EmitEOL();
}
void MCAsmStreamer::EmitIntValue(uint64_t Value, unsigned Size,
unsigned AddrSpace) {
EmitValue(MCConstantExpr::Create(Value, getContext()), Size, AddrSpace);
void MCAsmStreamer::EmitIntValue(uint64_t Value, unsigned Size) {
EmitValue(MCConstantExpr::Create(Value, getContext()), Size);
}
void MCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
unsigned AddrSpace) {
void MCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size) {
assert(getCurrentSection().first &&
"Cannot emit contents before setting section!");
const char *Directive = 0;
switch (Size) {
default: break;
case 1: Directive = MAI->getData8bitsDirective(AddrSpace); break;
case 2: Directive = MAI->getData16bitsDirective(AddrSpace); break;
case 4: Directive = MAI->getData32bitsDirective(AddrSpace); break;
case 1: Directive = MAI->getData8bitsDirective(); break;
case 2: Directive = MAI->getData16bitsDirective(); break;
case 4: Directive = MAI->getData32bitsDirective(); break;
case 8:
Directive = MAI->getData64bitsDirective(AddrSpace);
Directive = MAI->getData64bitsDirective();
// If the target doesn't support 64-bit data, emit as two 32-bit halves.
if (Directive) break;
int64_t IntValue;
if (!Value->EvaluateAsAbsolute(IntValue))
report_fatal_error("Don't know how to emit this value.");
if (MAI->isLittleEndian()) {
EmitIntValue((uint32_t)(IntValue >> 0 ), 4, AddrSpace);
EmitIntValue((uint32_t)(IntValue >> 32), 4, AddrSpace);
EmitIntValue((uint32_t)(IntValue >> 0 ), 4);
EmitIntValue((uint32_t)(IntValue >> 32), 4);
} else {
EmitIntValue((uint32_t)(IntValue >> 32), 4, AddrSpace);
EmitIntValue((uint32_t)(IntValue >> 0 ), 4, AddrSpace);
EmitIntValue((uint32_t)(IntValue >> 32), 4);
EmitIntValue((uint32_t)(IntValue >> 0 ), 4);
}
return;
}
@ -736,21 +731,19 @@ void MCAsmStreamer::EmitGPRel32Value(const MCExpr *Value) {
/// EmitFill - Emit NumBytes bytes worth of the value specified by
/// FillValue. This implements directives such as '.space'.
void MCAsmStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue,
unsigned AddrSpace) {
void MCAsmStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue) {
if (NumBytes == 0) return;
if (AddrSpace == 0)
if (const char *ZeroDirective = MAI->getZeroDirective()) {
OS << ZeroDirective << NumBytes;
if (FillValue != 0)
OS << ',' << (int)FillValue;
EmitEOL();
return;
}
if (const char *ZeroDirective = MAI->getZeroDirective()) {
OS << ZeroDirective << NumBytes;
if (FillValue != 0)
OS << ',' << (int)FillValue;
EmitEOL();
return;
}
// Emit a byte at a time.
MCStreamer::EmitFill(NumBytes, FillValue, AddrSpace);
MCStreamer::EmitFill(NumBytes, FillValue);
}
void MCAsmStreamer::EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,

View File

@ -268,7 +268,7 @@ const MCSymbol *MCDwarfFileTable::EmitCU(MCStreamer *MCOS, unsigned CUID) {
// total length, the 2 bytes for the version, and these 4 bytes for the
// length of the prologue.
MCOS->EmitAbsValue(MakeStartMinusEndExpr(*MCOS, *LineStartSym, *ProEndSym,
(4 + 2 + 4)), 4, 0);
(4 + 2 + 4)), 4);
// Parameters of the state machine, are next.
MCOS->EmitIntValue(context.getAsmInfo()->getMinInstAlignment(), 1);

View File

@ -296,12 +296,11 @@ void MCELFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
EmitCommonSymbol(Symbol, Size, ByteAlignment);
}
void MCELFStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
unsigned AddrSpace) {
void MCELFStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size) {
if (getCurrentSectionData()->isBundleLocked())
report_fatal_error("Emitting values inside a locked bundle is forbidden");
fixSymbolsInTLSFixups(Value);
MCObjectStreamer::EmitValueImpl(Value, Size, AddrSpace);
MCObjectStreamer::EmitValueImpl(Value, Size);
}
void MCELFStreamer::EmitValueToAlignment(unsigned ByteAlignment,

View File

@ -71,10 +71,9 @@ namespace {
uint64_t Size = 0, unsigned ByteAlignment = 0) {}
virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
uint64_t Size, unsigned ByteAlignment) {}
virtual void EmitBytes(StringRef Data, unsigned AddrSpace) {}
virtual void EmitBytes(StringRef Data) {}
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
unsigned AddrSpace) {}
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size) {}
virtual void EmitULEB128Value(const MCExpr *Value) {}
virtual void EmitSLEB128Value(const MCExpr *Value) {}
virtual void EmitGPRel32Value(const MCExpr *Value) {}

View File

@ -99,9 +99,7 @@ const MCExpr *MCObjectStreamer::AddValueSymbols(const MCExpr *Value) {
return Value;
}
void MCObjectStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
unsigned AddrSpace) {
assert(AddrSpace == 0 && "Address space must be 0!");
void MCObjectStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size) {
MCDataFragment *DF = getOrCreateDataFragment();
MCLineEntry::Make(this, getCurrentSection().first);
@ -109,7 +107,7 @@ void MCObjectStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
// Avoid fixups when possible.
int64_t AbsValue;
if (AddValueSymbols(Value)->EvaluateAsAbsolute(AbsValue, getAssembler())) {
EmitIntValue(AbsValue, Size, AddrSpace);
EmitIntValue(AbsValue, Size);
return;
}
DF->getFixups().push_back(
@ -303,8 +301,7 @@ void MCObjectStreamer::EmitDwarfAdvanceFrameAddr(const MCSymbol *LastLabel,
insert(new MCDwarfCallFrameFragment(*AddrDelta));
}
void MCObjectStreamer::EmitBytes(StringRef Data, unsigned AddrSpace) {
assert(AddrSpace == 0 && "Address space must be 0!");
void MCObjectStreamer::EmitBytes(StringRef Data) {
getOrCreateDataFragment()->getContents().append(Data.begin(), Data.end());
}
@ -367,16 +364,13 @@ void MCObjectStreamer::EmitGPRel64Value(const MCExpr *Value) {
DF->getContents().resize(DF->getContents().size() + 8, 0);
}
void MCObjectStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue,
unsigned AddrSpace) {
assert(AddrSpace == 0 && "Address space must be 0!");
void MCObjectStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue) {
// FIXME: A MCFillFragment would be more memory efficient but MCExpr has
// problems evaluating expressions across multiple fragments.
getOrCreateDataFragment()->getContents().append(NumBytes, FillValue);
}
void MCObjectStreamer::EmitZeros(uint64_t NumBytes, unsigned AddrSpace) {
assert(AddrSpace == 0 && "Address space must be 0!");
void MCObjectStreamer::EmitZeros(uint64_t NumBytes) {
unsigned ItemSize = getCurrentSection().first->isVirtualSection() ? 0 : 1;
insert(new MCFillFragment(0, ItemSize, NumBytes));
}

View File

@ -562,8 +562,7 @@ bool AsmParser::ProcessIncbinFile(const std::string &Filename) {
return true;
// Pick up the bytes from the file and emit them.
getStreamer().EmitBytes(SrcMgr.getMemoryBuffer(NewBuf)->getBuffer(),
DEFAULT_ADDRSPACE);
getStreamer().EmitBytes(SrcMgr.getMemoryBuffer(NewBuf)->getBuffer());
return false;
}
@ -2220,9 +2219,9 @@ bool AsmParser::ParseDirectiveAscii(StringRef IDVal, bool ZeroTerminated) {
if (parseEscapedString(Data))
return true;
getStreamer().EmitBytes(Data, DEFAULT_ADDRSPACE);
getStreamer().EmitBytes(Data);
if (ZeroTerminated)
getStreamer().EmitBytes(StringRef("\0", 1), DEFAULT_ADDRSPACE);
getStreamer().EmitBytes(StringRef("\0", 1));
Lex();
@ -2257,9 +2256,9 @@ bool AsmParser::ParseDirectiveValue(unsigned Size) {
uint64_t IntValue = MCE->getValue();
if (!isUIntN(8 * Size, IntValue) && !isIntN(8 * Size, IntValue))
return Error(ExprLoc, "literal value out of range for directive");
getStreamer().EmitIntValue(IntValue, Size, DEFAULT_ADDRSPACE);
getStreamer().EmitIntValue(IntValue, Size);
} else
getStreamer().EmitValue(Value, Size, DEFAULT_ADDRSPACE);
getStreamer().EmitValue(Value, Size);
if (getLexer().is(AsmToken::EndOfStatement))
break;
@ -2318,7 +2317,7 @@ bool AsmParser::ParseDirectiveRealValue(const fltSemantics &Semantics) {
// Emit the value as an integer.
APInt AsInt = Value.bitcastToAPInt();
getStreamer().EmitIntValue(AsInt.getLimitedValue(),
AsInt.getBitWidth() / 8, DEFAULT_ADDRSPACE);
AsInt.getBitWidth() / 8);
if (getLexer().is(AsmToken::EndOfStatement))
break;
@ -2354,7 +2353,7 @@ bool AsmParser::ParseDirectiveZero() {
Lex();
getStreamer().EmitFill(NumBytes, Val, DEFAULT_ADDRSPACE);
getStreamer().EmitFill(NumBytes, Val);
return false;
}
@ -2393,7 +2392,7 @@ bool AsmParser::ParseDirectiveFill() {
return TokError("invalid '.fill' size, expected 1, 2, 4, or 8");
for (uint64_t i = 0, e = NumValues; i != e; ++i)
getStreamer().EmitIntValue(FillExpr, FillSize, DEFAULT_ADDRSPACE);
getStreamer().EmitIntValue(FillExpr, FillSize);
return false;
}
@ -3331,7 +3330,7 @@ bool AsmParser::ParseDirectiveSpace(StringRef IDVal) {
Twine(IDVal) + "' directive");
// FIXME: Sometimes the fill expr is 'nop' if it isn't supplied, instead of 0.
getStreamer().EmitFill(NumBytes, FillExpr, DEFAULT_ADDRSPACE);
getStreamer().EmitFill(NumBytes, FillExpr);
return false;
}

View File

@ -40,7 +40,7 @@ public:
virtual void EmitDebugLabel(MCSymbol *Symbol);
virtual void EmitZerofill(const MCSection *Section, MCSymbol *Symbol = 0,
uint64_t Size = 0, unsigned ByteAlignment = 0);
virtual void EmitBytes(StringRef Data, unsigned AddrSpace);
virtual void EmitBytes(StringRef Data);
virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value = 0,
unsigned ValueSize = 1,
unsigned MaxBytesToEmit = 0);
@ -149,7 +149,7 @@ void MCPureStreamer::EmitZerofill(const MCSection *Section, MCSymbol *Symbol,
report_fatal_error("not yet implemented in pure streamer");
}
void MCPureStreamer::EmitBytes(StringRef Data, unsigned AddrSpace) {
void MCPureStreamer::EmitBytes(StringRef Data) {
// TODO: This is exactly the same as WinCOFFStreamer. Consider merging into
// MCObjectStreamer.
getOrCreateDataFragment()->getContents().append(Data.begin(), Data.end());

View File

@ -86,8 +86,7 @@ void MCStreamer::EmitDwarfSetLineAddr(int64_t LineDelta,
/// EmitIntValue - Special case of EmitValue that avoids the client having to
/// pass in a MCExpr for constant integers.
void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size,
unsigned AddrSpace) {
void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size) {
assert(Size <= 8 && "Invalid size");
assert((isUIntN(8 * Size, Value) || isIntN(8 * Size, Value)) &&
"Invalid size");
@ -97,44 +96,39 @@ void MCStreamer::EmitIntValue(uint64_t Value, unsigned Size,
unsigned index = isLittleEndian ? i : (Size - i - 1);
buf[i] = uint8_t(Value >> (index * 8));
}
EmitBytes(StringRef(buf, Size), AddrSpace);
EmitBytes(StringRef(buf, Size));
}
/// EmitULEB128Value - Special case of EmitULEB128Value that avoids the
/// client having to pass in a MCExpr for constant integers.
void MCStreamer::EmitULEB128IntValue(uint64_t Value, unsigned Padding,
unsigned AddrSpace) {
void MCStreamer::EmitULEB128IntValue(uint64_t Value, unsigned Padding) {
SmallString<128> Tmp;
raw_svector_ostream OSE(Tmp);
encodeULEB128(Value, OSE, Padding);
EmitBytes(OSE.str(), AddrSpace);
EmitBytes(OSE.str());
}
/// EmitSLEB128Value - Special case of EmitSLEB128Value that avoids the
/// client having to pass in a MCExpr for constant integers.
void MCStreamer::EmitSLEB128IntValue(int64_t Value, unsigned AddrSpace) {
void MCStreamer::EmitSLEB128IntValue(int64_t Value) {
SmallString<128> Tmp;
raw_svector_ostream OSE(Tmp);
encodeSLEB128(Value, OSE);
EmitBytes(OSE.str(), AddrSpace);
EmitBytes(OSE.str());
}
void MCStreamer::EmitAbsValue(const MCExpr *Value, unsigned Size,
unsigned AddrSpace) {
void MCStreamer::EmitAbsValue(const MCExpr *Value, unsigned Size) {
const MCExpr *ABS = ForceExpAbs(Value);
EmitValue(ABS, Size, AddrSpace);
EmitValue(ABS, Size);
}
void MCStreamer::EmitValue(const MCExpr *Value, unsigned Size,
unsigned AddrSpace) {
EmitValueImpl(Value, Size, AddrSpace);
void MCStreamer::EmitValue(const MCExpr *Value, unsigned Size) {
EmitValueImpl(Value, Size);
}
void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size,
unsigned AddrSpace) {
EmitValueImpl(MCSymbolRefExpr::Create(Sym, getContext()), Size,
AddrSpace);
void MCStreamer::EmitSymbolValue(const MCSymbol *Sym, unsigned Size) {
EmitValueImpl(MCSymbolRefExpr::Create(Sym, getContext()), Size);
}
void MCStreamer::EmitGPRel64Value(const MCExpr *Value) {
@ -147,17 +141,15 @@ void MCStreamer::EmitGPRel32Value(const MCExpr *Value) {
/// EmitFill - Emit NumBytes bytes worth of the value specified by
/// FillValue. This implements directives such as '.space'.
void MCStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue,
unsigned AddrSpace) {
void MCStreamer::EmitFill(uint64_t NumBytes, uint8_t FillValue) {
const MCExpr *E = MCConstantExpr::Create(FillValue, getContext());
for (uint64_t i = 0, e = NumBytes; i != e; ++i)
EmitValue(E, 1, AddrSpace);
EmitValue(E, 1);
}
/// EmitZeros - Emit NumBytes worth of zeros. Implementation in this class
/// just redirects to EmitFill.
void MCStreamer::EmitZeros(uint64_t NumBytes, unsigned AddrSpace) {
EmitFill(NumBytes, 0, AddrSpace);
/// The implementation in this class just redirects to EmitFill.
void MCStreamer::EmitZeros(uint64_t NumBytes) {
EmitFill(NumBytes, 0);
}
bool MCStreamer::EmitDwarfFileDirective(unsigned FileNo,

View File

@ -289,7 +289,7 @@ void AArch64AsmPrinter::EmitEndOfAsmFile(Module &M) {
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
OutStreamer.EmitLabel(Stubs[i].first);
OutStreamer.EmitSymbolValue(Stubs[i].second.getPointer(),
TD->getPointerSize(0), 0);
TD->getPointerSize(0));
}
Stubs.clear();
}

View File

@ -1918,7 +1918,7 @@ bool AArch64AsmParser::ParseDirectiveWord(unsigned Size, SMLoc L) {
if (getParser().parseExpression(Value))
return true;
getParser().getStreamer().EmitValue(Value, Size, 0/*addrspace*/);
getParser().getStreamer().EmitValue(Value, Size);
if (getLexer().is(AsmToken::EndOfStatement))
break;

View File

@ -85,18 +85,17 @@ public:
/// This is one of the functions used to emit data into an ELF section, so the
/// AArch64 streamer overrides it to add the appropriate mapping symbol ($d)
/// if necessary.
virtual void EmitBytes(StringRef Data, unsigned AddrSpace) {
virtual void EmitBytes(StringRef Data) {
EmitDataMappingSymbol();
MCELFStreamer::EmitBytes(Data, AddrSpace);
MCELFStreamer::EmitBytes(Data);
}
/// This is one of the functions used to emit data into an ELF section, so the
/// AArch64 streamer overrides it to add the appropriate mapping symbol ($d)
/// if necessary.
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
unsigned AddrSpace) {
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size) {
EmitDataMappingSymbol();
MCELFStreamer::EmitValueImpl(Value, Size, AddrSpace);
MCELFStreamer::EmitValueImpl(Value, Size);
}
private:

View File

@ -109,18 +109,17 @@ public:
/// This is one of the functions used to emit data into an ELF section, so the
/// ARM streamer overrides it to add the appropriate mapping symbol ($d) if
/// necessary.
virtual void EmitBytes(StringRef Data, unsigned AddrSpace) {
virtual void EmitBytes(StringRef Data) {
EmitDataMappingSymbol();
MCELFStreamer::EmitBytes(Data, AddrSpace);
MCELFStreamer::EmitBytes(Data);
}
/// This is one of the functions used to emit data into an ELF section, so the
/// ARM streamer overrides it to add the appropriate mapping symbol ($d) if
/// necessary.
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
unsigned AddrSpace) {
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size) {
EmitDataMappingSymbol();
MCELFStreamer::EmitValueImpl(Value, Size, AddrSpace);
MCELFStreamer::EmitValueImpl(Value, Size);
}
virtual void EmitAssemblerFlag(MCAssemblerFlag Flag) {
@ -336,17 +335,17 @@ void ARMELFStreamer::EmitFnEnd() {
MCSymbolRefExpr::VK_ARM_PREL31,
getContext());
EmitValue(FnStartRef, 4, 0);
EmitValue(FnStartRef, 4);
if (CantUnwind) {
EmitIntValue(EXIDX_CANTUNWIND, 4, 0);
EmitIntValue(EXIDX_CANTUNWIND, 4);
} else if (ExTab) {
// Emit a reference to the unwind opcodes in the ".ARM.extab" section.
const MCSymbolRefExpr *ExTabEntryRef =
MCSymbolRefExpr::Create(ExTab,
MCSymbolRefExpr::VK_ARM_PREL31,
getContext());
EmitValue(ExTabEntryRef, 4, 0);
EmitValue(ExTabEntryRef, 4);
} else {
// For the __aeabi_unwind_cpp_pr0, we have to emit the unwind opcodes in
// the second word of exception index table entry. The size of the unwind
@ -356,7 +355,7 @@ void ARMELFStreamer::EmitFnEnd() {
assert(Opcodes.size() == 4u &&
"Unwind opcode size for __aeabi_cpp_unwind_pr0 must be equal to 4");
EmitBytes(StringRef(reinterpret_cast<const char*>(Opcodes.data()),
Opcodes.size()), 0);
Opcodes.size()));
}
// Switch to the section containing FnStart
@ -412,12 +411,12 @@ void ARMELFStreamer::FlushUnwindOpcodes(bool NoHandlerData) {
MCSymbolRefExpr::VK_ARM_PREL31,
getContext());
EmitValue(PersonalityRef, 4, 0);
EmitValue(PersonalityRef, 4);
}
// Emit unwind opcodes
EmitBytes(StringRef(reinterpret_cast<const char *>(Opcodes.data()),
Opcodes.size()), 0);
Opcodes.size()));
// According to ARM EHABI section 9.2, if the __aeabi_unwind_cpp_pr1() or
// __aeabi_unwind_cpp_pr2() is used, then the handler data must be emitted

View File

@ -769,7 +769,7 @@ bool PPCLinuxAsmPrinter::doFinalization(Module &M) {
// .long _foo
OutStreamer.EmitValue(MCSymbolRefExpr::Create(Stubs[i].second.getPointer(),
OutContext),
isPPC64 ? 8 : 4/*size*/, 0/*addrspace*/);
isPPC64 ? 8 : 4/*size*/);
}
Stubs.clear();

View File

@ -70,11 +70,6 @@ AMDGPUMCAsmInfo::AMDGPUMCAsmInfo(StringRef &TT) : MCAsmInfo() {
SupportsDebugInformation = true;
}
const char*
AMDGPUMCAsmInfo::getDataASDirective(unsigned int Size, unsigned int AS) const {
return 0;
}
const MCSection*
AMDGPUMCAsmInfo::getNonexecutableStackSection(MCContext &CTX) const {
return 0;

View File

@ -22,7 +22,6 @@ class StringRef;
class AMDGPUMCAsmInfo : public MCAsmInfo {
public:
explicit AMDGPUMCAsmInfo(StringRef &TT);
const char* getDataASDirective(unsigned int Size, unsigned int AS) const;
const MCSection* getNonexecutableStackSection(MCContext &CTX) const;
};
} // namespace llvm

View File

@ -100,7 +100,7 @@ void SystemZAsmPrinter::EmitEndOfAsmFile(Module &M) {
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
OutStreamer.EmitLabel(Stubs[i].first);
OutStreamer.EmitSymbolValue(Stubs[i].second.getPointer(),
TD->getPointerSize(0), 0);
TD->getPointerSize(0));
}
Stubs.clear();
}

View File

@ -792,9 +792,8 @@ namespace {
unsigned ByteAlignment) {}
virtual void EmitTBSSSymbol(const MCSection *Section, MCSymbol *Symbol,
uint64_t Size, unsigned ByteAlignment) {}
virtual void EmitBytes(StringRef Data, unsigned AddrSpace) {}
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size,
unsigned AddrSpace) {}
virtual void EmitBytes(StringRef Data) {}
virtual void EmitValueImpl(const MCExpr *Value, unsigned Size) {}
virtual void EmitULEB128Value(const MCExpr *Value) {}
virtual void EmitSLEB128Value(const MCExpr *Value) {}
virtual void EmitValueToAlignment(unsigned ByteAlignment, int64_t Value,