forked from OSchip/llvm-project
MC: Add target hook to control symbol quoting
llvm-svn: 239370
This commit is contained in:
parent
003c2e937b
commit
8b643559d4
|
@ -155,6 +155,10 @@ protected:
|
||||||
/// Defaults to false.
|
/// Defaults to false.
|
||||||
bool AllowAtInName;
|
bool AllowAtInName;
|
||||||
|
|
||||||
|
/// If this is true, symbol names with invalid characters will be printed in
|
||||||
|
/// quotes.
|
||||||
|
bool SupportsQuotedNames;
|
||||||
|
|
||||||
/// This is true if data region markers should be printed as
|
/// This is true if data region markers should be printed as
|
||||||
/// ".data_region/.end_data_region" directives. If false, use "$d/$a" labels
|
/// ".data_region/.end_data_region" directives. If false, use "$d/$a" labels
|
||||||
/// instead.
|
/// instead.
|
||||||
|
@ -406,6 +410,10 @@ public:
|
||||||
unsigned Encoding,
|
unsigned Encoding,
|
||||||
MCStreamer &Streamer) const;
|
MCStreamer &Streamer) const;
|
||||||
|
|
||||||
|
/// Return true if the identifier \p Name does not need quotes to be
|
||||||
|
/// syntactically correct.
|
||||||
|
virtual bool isValidUnquotedName(StringRef Name) const;
|
||||||
|
|
||||||
bool usesSunStyleELFSectionSwitchSyntax() const {
|
bool usesSunStyleELFSectionSwitchSyntax() const {
|
||||||
return SunStyleELFSectionSwitchSyntax;
|
return SunStyleELFSectionSwitchSyntax;
|
||||||
}
|
}
|
||||||
|
@ -456,6 +464,7 @@ public:
|
||||||
const char *getCode64Directive() const { return Code64Directive; }
|
const char *getCode64Directive() const { return Code64Directive; }
|
||||||
unsigned getAssemblerDialect() const { return AssemblerDialect; }
|
unsigned getAssemblerDialect() const { return AssemblerDialect; }
|
||||||
bool doesAllowAtInName() const { return AllowAtInName; }
|
bool doesAllowAtInName() const { return AllowAtInName; }
|
||||||
|
bool supportsNameQuoting() const { return SupportsQuotedNames; }
|
||||||
bool doesSupportDataRegionDirectives() const {
|
bool doesSupportDataRegionDirectives() const {
|
||||||
return UseDataRegionDirectives;
|
return UseDataRegionDirectives;
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,7 +72,7 @@ public:
|
||||||
/// \name Utility Methods
|
/// \name Utility Methods
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
void print(raw_ostream &OS) const;
|
void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
|
||||||
void dump() const;
|
void dump() const;
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
@ -121,7 +121,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
inline raw_ostream &operator<<(raw_ostream &OS, const MCExpr &E) {
|
inline raw_ostream &operator<<(raw_ostream &OS, const MCExpr &E) {
|
||||||
E.print(OS);
|
E.print(OS, nullptr);
|
||||||
return OS;
|
return OS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,8 +551,7 @@ protected:
|
||||||
MCTargetExpr() : MCExpr(Target) {}
|
MCTargetExpr() : MCExpr(Target) {}
|
||||||
virtual ~MCTargetExpr() {}
|
virtual ~MCTargetExpr() {}
|
||||||
public:
|
public:
|
||||||
|
virtual void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const = 0;
|
||||||
virtual void printImpl(raw_ostream &OS) const = 0;
|
|
||||||
virtual bool evaluateAsRelocatableImpl(MCValue &Res,
|
virtual bool evaluateAsRelocatableImpl(MCValue &Res,
|
||||||
const MCAsmLayout *Layout,
|
const MCAsmLayout *Layout,
|
||||||
const MCFixup *Fixup) const = 0;
|
const MCFixup *Fixup) const = 0;
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
#include "llvm/Support/Compiler.h"
|
#include "llvm/Support/Compiler.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
class MCAsmInfo;
|
||||||
class MCExpr;
|
class MCExpr;
|
||||||
class MCSymbol;
|
class MCSymbol;
|
||||||
class MCFragment;
|
class MCFragment;
|
||||||
|
@ -302,7 +303,7 @@ public:
|
||||||
void setPrivateExtern(bool Value) { IsPrivateExtern = Value; }
|
void setPrivateExtern(bool Value) { IsPrivateExtern = Value; }
|
||||||
|
|
||||||
/// print - Print the value to the stream \p OS.
|
/// print - Print the value to the stream \p OS.
|
||||||
void print(raw_ostream &OS) const;
|
void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
|
||||||
|
|
||||||
/// dump - Print the value to stderr.
|
/// dump - Print the value to stderr.
|
||||||
void dump() const;
|
void dump() const;
|
||||||
|
@ -321,7 +322,7 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
inline raw_ostream &operator<<(raw_ostream &OS, const MCSymbol &Sym) {
|
inline raw_ostream &operator<<(raw_ostream &OS, const MCSymbol &Sym) {
|
||||||
Sym.print(OS);
|
Sym.print(OS, nullptr);
|
||||||
return OS;
|
return OS;
|
||||||
}
|
}
|
||||||
} // end namespace llvm
|
} // end namespace llvm
|
||||||
|
|
|
@ -402,10 +402,11 @@ static void EmitGCCInlineAsmStr(const char *AsmStr, const MachineInstr *MI,
|
||||||
unsigned OpFlags = MI->getOperand(OpNo).getImm();
|
unsigned OpFlags = MI->getOperand(OpNo).getImm();
|
||||||
++OpNo; // Skip over the ID number.
|
++OpNo; // Skip over the ID number.
|
||||||
|
|
||||||
if (Modifier[0] == 'l') // labels are target independent
|
if (Modifier[0] == 'l') { // Labels are target independent.
|
||||||
// FIXME: What if the operand isn't an MBB, report error?
|
// FIXME: What if the operand isn't an MBB, report error?
|
||||||
OS << *MI->getOperand(OpNo).getMBB()->getSymbol();
|
const MCSymbol *Sym = MI->getOperand(OpNo).getMBB()->getSymbol();
|
||||||
else {
|
Sym->print(OS, AP->MAI);
|
||||||
|
} else {
|
||||||
if (InlineAsm::isMemKind(OpFlags)) {
|
if (InlineAsm::isMemKind(OpFlags)) {
|
||||||
Error = AP->PrintAsmMemoryOperand(MI, OpNo, InlineAsmVariant,
|
Error = AP->PrintAsmMemoryOperand(MI, OpNo, InlineAsmVariant,
|
||||||
Modifier[0] ? Modifier : nullptr,
|
Modifier[0] ? Modifier : nullptr,
|
||||||
|
|
|
@ -50,6 +50,7 @@ MCAsmInfo::MCAsmInfo() {
|
||||||
Code64Directive = ".code64";
|
Code64Directive = ".code64";
|
||||||
AssemblerDialect = 0;
|
AssemblerDialect = 0;
|
||||||
AllowAtInName = false;
|
AllowAtInName = false;
|
||||||
|
SupportsQuotedNames = true;
|
||||||
UseDataRegionDirectives = false;
|
UseDataRegionDirectives = false;
|
||||||
ZeroDirective = "\t.zero\t";
|
ZeroDirective = "\t.zero\t";
|
||||||
AsciiDirective = "\t.ascii\t";
|
AsciiDirective = "\t.ascii\t";
|
||||||
|
@ -137,3 +138,22 @@ MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
|
||||||
const MCExpr *PC = MCSymbolRefExpr::create(PCSym, Context);
|
const MCExpr *PC = MCSymbolRefExpr::create(PCSym, Context);
|
||||||
return MCBinaryExpr::createSub(Res, PC, Context);
|
return MCBinaryExpr::createSub(Res, PC, Context);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool isAcceptableChar(char C) {
|
||||||
|
return (C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z') ||
|
||||||
|
(C >= '0' && C <= '9') || C == '_' || C == '$' || C == '.' || C == '@';
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MCAsmInfo::isValidUnquotedName(StringRef Name) const {
|
||||||
|
if (Name.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// If any of the characters in the string is an unacceptable character, force
|
||||||
|
// quotes.
|
||||||
|
for (char C : Name) {
|
||||||
|
if (!isAcceptableChar(C))
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -308,7 +308,9 @@ void MCAsmStreamer::EmitLabel(MCSymbol *Symbol) {
|
||||||
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
|
assert(Symbol->isUndefined() && "Cannot define a symbol twice!");
|
||||||
MCStreamer::EmitLabel(Symbol);
|
MCStreamer::EmitLabel(Symbol);
|
||||||
|
|
||||||
OS << *Symbol << MAI->getLabelSuffix();
|
Symbol->print(OS, MAI);
|
||||||
|
OS << MAI->getLabelSuffix();
|
||||||
|
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -328,7 +330,7 @@ void MCAsmStreamer::EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) {
|
||||||
if (!IsFirst)
|
if (!IsFirst)
|
||||||
OS << ", ";
|
OS << ", ";
|
||||||
IsFirst = false;
|
IsFirst = false;
|
||||||
OS << **It;
|
(*It)->print(OS, MAI);
|
||||||
}
|
}
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
@ -384,20 +386,28 @@ void MCAsmStreamer::EmitThumbFunc(MCSymbol *Func) {
|
||||||
// MCSymbols when they have spaces in them.
|
// MCSymbols when they have spaces in them.
|
||||||
OS << "\t.thumb_func";
|
OS << "\t.thumb_func";
|
||||||
// Only Mach-O hasSubsectionsViaSymbols()
|
// Only Mach-O hasSubsectionsViaSymbols()
|
||||||
if (MAI->hasSubsectionsViaSymbols())
|
if (MAI->hasSubsectionsViaSymbols()) {
|
||||||
OS << '\t' << *Func;
|
OS << '\t';
|
||||||
|
Func->print(OS, MAI);
|
||||||
|
}
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
|
void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
|
||||||
OS << *Symbol << " = " << *Value;
|
Symbol->print(OS, MAI);
|
||||||
|
OS << " = ";
|
||||||
|
Value->print(OS, MAI);
|
||||||
|
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
|
|
||||||
MCStreamer::EmitAssignment(Symbol, Value);
|
MCStreamer::EmitAssignment(Symbol, Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {
|
void MCAsmStreamer::EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {
|
||||||
OS << ".weakref " << *Alias << ", " << *Symbol;
|
OS << ".weakref ";
|
||||||
|
Alias->print(OS, MAI);
|
||||||
|
OS << ", ";
|
||||||
|
Symbol->print(OS, MAI);
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,8 +424,9 @@ bool MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
|
||||||
case MCSA_ELF_TypeGnuUniqueObject: /// .type _foo, @gnu_unique_object
|
case MCSA_ELF_TypeGnuUniqueObject: /// .type _foo, @gnu_unique_object
|
||||||
if (!MAI->hasDotTypeDotSizeDirective())
|
if (!MAI->hasDotTypeDotSizeDirective())
|
||||||
return false; // Symbol attribute not supported
|
return false; // Symbol attribute not supported
|
||||||
OS << "\t.type\t" << *Symbol << ','
|
OS << "\t.type\t";
|
||||||
<< ((MAI->getCommentString()[0] != '@') ? '@' : '%');
|
Symbol->print(OS, MAI);
|
||||||
|
OS << ',' << ((MAI->getCommentString()[0] != '@') ? '@' : '%');
|
||||||
switch (Attribute) {
|
switch (Attribute) {
|
||||||
default: return false;
|
default: return false;
|
||||||
case MCSA_ELF_TypeFunction: OS << "function"; break;
|
case MCSA_ELF_TypeFunction: OS << "function"; break;
|
||||||
|
@ -456,19 +467,23 @@ bool MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
|
||||||
case MCSA_WeakDefAutoPrivate: OS << "\t.weak_def_can_be_hidden\t"; break;
|
case MCSA_WeakDefAutoPrivate: OS << "\t.weak_def_can_be_hidden\t"; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
OS << *Symbol;
|
Symbol->print(OS, MAI);
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
|
void MCAsmStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
|
||||||
OS << ".desc" << ' ' << *Symbol << ',' << DescValue;
|
OS << ".desc" << ' ';
|
||||||
|
Symbol->print(OS, MAI);
|
||||||
|
OS << ',' << DescValue;
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::BeginCOFFSymbolDef(const MCSymbol *Symbol) {
|
void MCAsmStreamer::BeginCOFFSymbolDef(const MCSymbol *Symbol) {
|
||||||
OS << "\t.def\t " << *Symbol << ';';
|
OS << "\t.def\t ";
|
||||||
|
Symbol->print(OS, MAI);
|
||||||
|
OS << ';';
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -493,18 +508,24 @@ void MCAsmStreamer::EmitCOFFSafeSEH(MCSymbol const *Symbol) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) {
|
void MCAsmStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) {
|
||||||
OS << "\t.secidx\t" << *Symbol;
|
OS << "\t.secidx\t";
|
||||||
|
Symbol->print(OS, MAI);
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol) {
|
void MCAsmStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol) {
|
||||||
OS << "\t.secrel32\t" << *Symbol;
|
OS << "\t.secrel32\t";
|
||||||
|
Symbol->print(OS, MAI);
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value) {
|
void MCAsmStreamer::emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value) {
|
||||||
assert(MAI->hasDotTypeDotSizeDirective());
|
assert(MAI->hasDotTypeDotSizeDirective());
|
||||||
OS << "\t.size\t" << *Symbol << ", " << *Value << '\n';
|
OS << "\t.size\t";
|
||||||
|
Symbol->print(OS, MAI);
|
||||||
|
OS << ", ";
|
||||||
|
Value->print(OS, MAI);
|
||||||
|
OS << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||||
|
@ -512,7 +533,10 @@ void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||||
// Common symbols do not belong to any actual section.
|
// Common symbols do not belong to any actual section.
|
||||||
AssignSection(Symbol, nullptr);
|
AssignSection(Symbol, nullptr);
|
||||||
|
|
||||||
OS << "\t.comm\t" << *Symbol << ',' << Size;
|
OS << "\t.comm\t";
|
||||||
|
Symbol->print(OS, MAI);
|
||||||
|
OS << ',' << Size;
|
||||||
|
|
||||||
if (ByteAlignment != 0) {
|
if (ByteAlignment != 0) {
|
||||||
if (MAI->getCOMMDirectiveAlignmentIsInBytes())
|
if (MAI->getCOMMDirectiveAlignmentIsInBytes())
|
||||||
OS << ',' << ByteAlignment;
|
OS << ',' << ByteAlignment;
|
||||||
|
@ -531,7 +555,10 @@ void MCAsmStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
||||||
// Common symbols do not belong to any actual section.
|
// Common symbols do not belong to any actual section.
|
||||||
AssignSection(Symbol, nullptr);
|
AssignSection(Symbol, nullptr);
|
||||||
|
|
||||||
OS << "\t.lcomm\t" << *Symbol << ',' << Size;
|
OS << "\t.lcomm\t";
|
||||||
|
Symbol->print(OS, MAI);
|
||||||
|
OS << ',' << Size;
|
||||||
|
|
||||||
if (ByteAlign > 1) {
|
if (ByteAlign > 1) {
|
||||||
switch (MAI->getLCOMMDirectiveAlignmentType()) {
|
switch (MAI->getLCOMMDirectiveAlignmentType()) {
|
||||||
case LCOMM::NoAlignment:
|
case LCOMM::NoAlignment:
|
||||||
|
@ -561,7 +588,9 @@ void MCAsmStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
|
||||||
OS << MOSection->getSegmentName() << "," << MOSection->getSectionName();
|
OS << MOSection->getSegmentName() << "," << MOSection->getSectionName();
|
||||||
|
|
||||||
if (Symbol) {
|
if (Symbol) {
|
||||||
OS << ',' << *Symbol << ',' << Size;
|
OS << ',';
|
||||||
|
Symbol->print(OS, MAI);
|
||||||
|
OS << ',' << Size;
|
||||||
if (ByteAlignment != 0)
|
if (ByteAlignment != 0)
|
||||||
OS << ',' << Log2_32(ByteAlignment);
|
OS << ',' << Log2_32(ByteAlignment);
|
||||||
}
|
}
|
||||||
|
@ -578,7 +607,9 @@ void MCAsmStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
|
||||||
assert(Symbol && "Symbol shouldn't be NULL!");
|
assert(Symbol && "Symbol shouldn't be NULL!");
|
||||||
// Instead of using the Section we'll just use the shortcut.
|
// Instead of using the Section we'll just use the shortcut.
|
||||||
// This is a mach-o specific directive and section.
|
// This is a mach-o specific directive and section.
|
||||||
OS << ".tbss " << *Symbol << ", " << Size;
|
OS << ".tbss ";
|
||||||
|
Symbol->print(OS, MAI);
|
||||||
|
OS << ", " << Size;
|
||||||
|
|
||||||
// Output align if we have it. We default to 1 so don't bother printing
|
// Output align if we have it. We default to 1 so don't bother printing
|
||||||
// that.
|
// that.
|
||||||
|
@ -703,7 +734,8 @@ void MCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(Directive && "Invalid size for machine code value!");
|
assert(Directive && "Invalid size for machine code value!");
|
||||||
OS << Directive << *Value;
|
OS << Directive;
|
||||||
|
Value->print(OS, MAI);
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -713,7 +745,8 @@ void MCAsmStreamer::EmitULEB128Value(const MCExpr *Value) {
|
||||||
EmitULEB128IntValue(IntValue);
|
EmitULEB128IntValue(IntValue);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
OS << ".uleb128 " << *Value;
|
OS << ".uleb128 ";
|
||||||
|
Value->print(OS, MAI);
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -723,19 +756,22 @@ void MCAsmStreamer::EmitSLEB128Value(const MCExpr *Value) {
|
||||||
EmitSLEB128IntValue(IntValue);
|
EmitSLEB128IntValue(IntValue);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
OS << ".sleb128 " << *Value;
|
OS << ".sleb128 ";
|
||||||
|
Value->print(OS, MAI);
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::EmitGPRel64Value(const MCExpr *Value) {
|
void MCAsmStreamer::EmitGPRel64Value(const MCExpr *Value) {
|
||||||
assert(MAI->getGPRel64Directive() != nullptr);
|
assert(MAI->getGPRel64Directive() != nullptr);
|
||||||
OS << MAI->getGPRel64Directive() << *Value;
|
OS << MAI->getGPRel64Directive();
|
||||||
|
Value->print(OS, MAI);
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::EmitGPRel32Value(const MCExpr *Value) {
|
void MCAsmStreamer::EmitGPRel32Value(const MCExpr *Value) {
|
||||||
assert(MAI->getGPRel32Directive() != nullptr);
|
assert(MAI->getGPRel32Directive() != nullptr);
|
||||||
OS << MAI->getGPRel32Directive() << *Value;
|
OS << MAI->getGPRel32Directive();
|
||||||
|
Value->print(OS, MAI);
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -822,7 +858,9 @@ void MCAsmStreamer::EmitCodeAlignment(unsigned ByteAlignment,
|
||||||
bool MCAsmStreamer::EmitValueToOffset(const MCExpr *Offset,
|
bool MCAsmStreamer::EmitValueToOffset(const MCExpr *Offset,
|
||||||
unsigned char Value) {
|
unsigned char Value) {
|
||||||
// FIXME: Verify that Offset is associated with the current section.
|
// FIXME: Verify that Offset is associated with the current section.
|
||||||
OS << ".org " << *Offset << ", " << (unsigned) Value;
|
OS << ".org ";
|
||||||
|
Offset->print(OS, MAI);
|
||||||
|
OS << ", " << (unsigned)Value;
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -993,13 +1031,15 @@ void MCAsmStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) {
|
||||||
void MCAsmStreamer::EmitCFIPersonality(const MCSymbol *Sym,
|
void MCAsmStreamer::EmitCFIPersonality(const MCSymbol *Sym,
|
||||||
unsigned Encoding) {
|
unsigned Encoding) {
|
||||||
MCStreamer::EmitCFIPersonality(Sym, Encoding);
|
MCStreamer::EmitCFIPersonality(Sym, Encoding);
|
||||||
OS << "\t.cfi_personality " << Encoding << ", " << *Sym;
|
OS << "\t.cfi_personality " << Encoding << ", ";
|
||||||
|
Sym->print(OS, MAI);
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCAsmStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
|
void MCAsmStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
|
||||||
MCStreamer::EmitCFILsda(Sym, Encoding);
|
MCStreamer::EmitCFILsda(Sym, Encoding);
|
||||||
OS << "\t.cfi_lsda " << Encoding << ", " << *Sym;
|
OS << "\t.cfi_lsda " << Encoding << ", ";
|
||||||
|
Sym->print(OS, MAI);
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1063,7 +1103,8 @@ void MCAsmStreamer::EmitCFIWindowSave() {
|
||||||
void MCAsmStreamer::EmitWinCFIStartProc(const MCSymbol *Symbol) {
|
void MCAsmStreamer::EmitWinCFIStartProc(const MCSymbol *Symbol) {
|
||||||
MCStreamer::EmitWinCFIStartProc(Symbol);
|
MCStreamer::EmitWinCFIStartProc(Symbol);
|
||||||
|
|
||||||
OS << ".seh_proc " << *Symbol;
|
OS << ".seh_proc ";
|
||||||
|
Symbol->print(OS, MAI);
|
||||||
EmitEOL();
|
EmitEOL();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1092,7 +1133,8 @@ void MCAsmStreamer::EmitWinEHHandler(const MCSymbol *Sym, bool Unwind,
|
||||||
bool Except) {
|
bool Except) {
|
||||||
MCStreamer::EmitWinEHHandler(Sym, Unwind, Except);
|
MCStreamer::EmitWinEHHandler(Sym, Unwind, Except);
|
||||||
|
|
||||||
OS << "\t.seh_handler " << *Sym;
|
OS << "\t.seh_handler ";
|
||||||
|
Sym->print(OS, MAI);
|
||||||
if (Unwind)
|
if (Unwind)
|
||||||
OS << ", @unwind";
|
OS << ", @unwind";
|
||||||
if (Except)
|
if (Except)
|
||||||
|
|
|
@ -1199,8 +1199,7 @@ void MCFragment::dump() {
|
||||||
case MCFragment::FT_SafeSEH: {
|
case MCFragment::FT_SafeSEH: {
|
||||||
const MCSafeSEHFragment *F = cast<MCSafeSEHFragment>(this);
|
const MCSafeSEHFragment *F = cast<MCSafeSEHFragment>(this);
|
||||||
OS << "\n ";
|
OS << "\n ";
|
||||||
OS << " Sym:";
|
OS << " Sym:" << F->getSymbol();
|
||||||
F->getSymbol()->print(OS);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,10 @@ STATISTIC(MCExprEvaluate, "Number of MCExpr evaluations");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCExpr::print(raw_ostream &OS) const {
|
void MCExpr::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
|
||||||
switch (getKind()) {
|
switch (getKind()) {
|
||||||
case MCExpr::Target:
|
case MCExpr::Target:
|
||||||
return cast<MCTargetExpr>(this)->printImpl(OS);
|
return cast<MCTargetExpr>(this)->printImpl(OS, MAI);
|
||||||
case MCExpr::Constant:
|
case MCExpr::Constant:
|
||||||
OS << cast<MCConstantExpr>(*this).getValue();
|
OS << cast<MCConstantExpr>(*this).getValue();
|
||||||
return;
|
return;
|
||||||
|
@ -43,11 +43,13 @@ void MCExpr::print(raw_ostream &OS) const {
|
||||||
const MCSymbol &Sym = SRE.getSymbol();
|
const MCSymbol &Sym = SRE.getSymbol();
|
||||||
// Parenthesize names that start with $ so that they don't look like
|
// Parenthesize names that start with $ so that they don't look like
|
||||||
// absolute names.
|
// absolute names.
|
||||||
bool UseParens = !Sym.getName().empty() && Sym.getName()[0] == '$';
|
bool UseParens = Sym.getName()[0] == '$';
|
||||||
if (UseParens)
|
if (UseParens) {
|
||||||
OS << '(' << Sym << ')';
|
OS << '(';
|
||||||
else
|
Sym.print(OS, MAI);
|
||||||
OS << Sym;
|
OS << ')';
|
||||||
|
} else
|
||||||
|
Sym.print(OS, MAI);
|
||||||
|
|
||||||
if (SRE.getKind() != MCSymbolRefExpr::VK_None)
|
if (SRE.getKind() != MCSymbolRefExpr::VK_None)
|
||||||
SRE.printVariantKind(OS);
|
SRE.printVariantKind(OS);
|
||||||
|
@ -63,7 +65,7 @@ void MCExpr::print(raw_ostream &OS) const {
|
||||||
case MCUnaryExpr::Not: OS << '~'; break;
|
case MCUnaryExpr::Not: OS << '~'; break;
|
||||||
case MCUnaryExpr::Plus: OS << '+'; break;
|
case MCUnaryExpr::Plus: OS << '+'; break;
|
||||||
}
|
}
|
||||||
OS << *UE.getSubExpr();
|
UE.getSubExpr()->print(OS, MAI);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,9 +74,11 @@ void MCExpr::print(raw_ostream &OS) const {
|
||||||
|
|
||||||
// Only print parens around the LHS if it is non-trivial.
|
// Only print parens around the LHS if it is non-trivial.
|
||||||
if (isa<MCConstantExpr>(BE.getLHS()) || isa<MCSymbolRefExpr>(BE.getLHS())) {
|
if (isa<MCConstantExpr>(BE.getLHS()) || isa<MCSymbolRefExpr>(BE.getLHS())) {
|
||||||
OS << *BE.getLHS();
|
BE.getLHS()->print(OS, MAI);
|
||||||
} else {
|
} else {
|
||||||
OS << '(' << *BE.getLHS() << ')';
|
OS << '(';
|
||||||
|
BE.getLHS()->print(OS, MAI);
|
||||||
|
OS << ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (BE.getOpcode()) {
|
switch (BE.getOpcode()) {
|
||||||
|
@ -111,9 +115,11 @@ void MCExpr::print(raw_ostream &OS) const {
|
||||||
|
|
||||||
// Only print parens around the LHS if it is non-trivial.
|
// Only print parens around the LHS if it is non-trivial.
|
||||||
if (isa<MCConstantExpr>(BE.getRHS()) || isa<MCSymbolRefExpr>(BE.getRHS())) {
|
if (isa<MCConstantExpr>(BE.getRHS()) || isa<MCSymbolRefExpr>(BE.getRHS())) {
|
||||||
OS << *BE.getRHS();
|
BE.getRHS()->print(OS, MAI);
|
||||||
} else {
|
} else {
|
||||||
OS << '(' << *BE.getRHS() << ')';
|
OS << '(';
|
||||||
|
BE.getRHS()->print(OS, MAI);
|
||||||
|
OS << ')';
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
assert(COMDATSymbol);
|
assert(COMDATSymbol);
|
||||||
OS << *COMDATSymbol;
|
COMDATSymbol->print(OS, &MAI);
|
||||||
}
|
}
|
||||||
OS << '\n';
|
OS << '\n';
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,8 +64,10 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI,
|
||||||
|
|
||||||
if (ShouldOmitSectionDirective(SectionName, MAI)) {
|
if (ShouldOmitSectionDirective(SectionName, MAI)) {
|
||||||
OS << '\t' << getSectionName();
|
OS << '\t' << getSectionName();
|
||||||
if (Subsection)
|
if (Subsection) {
|
||||||
OS << '\t' << *Subsection;
|
OS << '\t';
|
||||||
|
Subsection->print(OS, &MAI);
|
||||||
|
}
|
||||||
OS << '\n';
|
OS << '\n';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -153,8 +155,11 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI,
|
||||||
|
|
||||||
OS << '\n';
|
OS << '\n';
|
||||||
|
|
||||||
if (Subsection)
|
if (Subsection) {
|
||||||
OS << "\t.subsection\t" << *Subsection << '\n';
|
OS << "\t.subsection\t";
|
||||||
|
Subsection->print(OS, &MAI);
|
||||||
|
OS << '\n';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MCSectionELF::UseCodeAlign() const {
|
bool MCSectionELF::UseCodeAlign() const {
|
||||||
|
|
|
@ -8,36 +8,16 @@
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbol.h"
|
||||||
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
#include "llvm/MC/MCExpr.h"
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/Support/Debug.h"
|
#include "llvm/Support/Debug.h"
|
||||||
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
#include "llvm/Support/raw_ostream.h"
|
#include "llvm/Support/raw_ostream.h"
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
// Sentinel value for the absolute pseudo section.
|
// Sentinel value for the absolute pseudo section.
|
||||||
MCSection *MCSymbol::AbsolutePseudoSection = reinterpret_cast<MCSection *>(1);
|
MCSection *MCSymbol::AbsolutePseudoSection = reinterpret_cast<MCSection *>(1);
|
||||||
|
|
||||||
static bool isAcceptableChar(char C) {
|
|
||||||
if ((C < 'a' || C > 'z') &&
|
|
||||||
(C < 'A' || C > 'Z') &&
|
|
||||||
(C < '0' || C > '9') &&
|
|
||||||
C != '_' && C != '$' && C != '.' && C != '@')
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// NameNeedsQuoting - Return true if the identifier \p Str needs quotes to be
|
|
||||||
/// syntactically correct.
|
|
||||||
static bool NameNeedsQuoting(StringRef Str) {
|
|
||||||
assert(!Str.empty() && "Cannot create an empty MCSymbol");
|
|
||||||
|
|
||||||
// If any of the characters in the string is an unacceptable character, force
|
|
||||||
// quotes.
|
|
||||||
for (unsigned i = 0, e = Str.size(); i != e; ++i)
|
|
||||||
if (!isAcceptableChar(Str[i]))
|
|
||||||
return true;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void MCSymbol::setVariableValue(const MCExpr *Value) {
|
void MCSymbol::setVariableValue(const MCExpr *Value) {
|
||||||
assert(!IsUsed && "Cannot set a variable that has already been used.");
|
assert(!IsUsed && "Cannot set a variable that has already been used.");
|
||||||
assert(Value && "Invalid variable value!");
|
assert(Value && "Invalid variable value!");
|
||||||
|
@ -45,23 +25,21 @@ void MCSymbol::setVariableValue(const MCExpr *Value) {
|
||||||
SectionOrFragment = nullptr;
|
SectionOrFragment = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCSymbol::print(raw_ostream &OS) const {
|
void MCSymbol::print(raw_ostream &OS, const MCAsmInfo *MAI) const {
|
||||||
// The name for this MCSymbol is required to be a valid target name. However,
|
// The name for this MCSymbol is required to be a valid target name. However,
|
||||||
// some targets support quoting names with funny characters. If the name
|
// some targets support quoting names with funny characters. If the name
|
||||||
// contains a funny character, then print it quoted.
|
// contains a funny character, then print it quoted.
|
||||||
StringRef Name = getName();
|
StringRef Name = getName();
|
||||||
if (Name.empty()) {
|
if (!MAI || MAI->isValidUnquotedName(Name)) {
|
||||||
OS << "\"\"";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!NameNeedsQuoting(Name)) {
|
|
||||||
OS << Name;
|
OS << Name;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (MAI && !MAI->supportsNameQuoting())
|
||||||
|
report_fatal_error("Symbol name with unsupported characters");
|
||||||
|
|
||||||
OS << '"';
|
OS << '"';
|
||||||
for (unsigned I = 0, E = Name.size(); I != E; ++I) {
|
for (char C : Name) {
|
||||||
char C = Name[I];
|
|
||||||
if (C == '\n')
|
if (C == '\n')
|
||||||
OS << "\\n";
|
OS << "\\n";
|
||||||
else if (C == '"')
|
else if (C == '"')
|
||||||
|
|
|
@ -206,7 +206,7 @@ void AArch64AsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNum,
|
||||||
// FIXME: Can we get anything other than a plain symbol here?
|
// FIXME: Can we get anything other than a plain symbol here?
|
||||||
assert(!MO.getTargetFlags() && "Unknown operand target flag!");
|
assert(!MO.getTargetFlags() && "Unknown operand target flag!");
|
||||||
|
|
||||||
O << *Sym;
|
Sym->print(O, MAI);
|
||||||
printOffset(MO.getOffset(), O);
|
printOffset(MO.getOffset(), O);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -206,15 +206,15 @@ void AArch64InstPrinter::printInst(const MCInst *MI, raw_ostream &O,
|
||||||
else
|
else
|
||||||
O << "\tmovn\t";
|
O << "\tmovn\t";
|
||||||
|
|
||||||
O << getRegisterName(MI->getOperand(0).getReg()) << ", #"
|
O << getRegisterName(MI->getOperand(0).getReg()) << ", #";
|
||||||
<< *MI->getOperand(1).getExpr();
|
MI->getOperand(1).getExpr()->print(O, &MAI);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((Opcode == AArch64::MOVKXi || Opcode == AArch64::MOVKWi) &&
|
if ((Opcode == AArch64::MOVKXi || Opcode == AArch64::MOVKWi) &&
|
||||||
MI->getOperand(2).isExpr()) {
|
MI->getOperand(2).isExpr()) {
|
||||||
O << "\tmovk\t" << getRegisterName(MI->getOperand(0).getReg()) << ", #"
|
O << "\tmovk\t" << getRegisterName(MI->getOperand(0).getReg()) << ", #";
|
||||||
<< *MI->getOperand(2).getExpr();
|
MI->getOperand(2).getExpr()->print(O, &MAI);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -908,7 +908,7 @@ void AArch64InstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||||
O << '#' << Op.getImm();
|
O << '#' << Op.getImm();
|
||||||
} else {
|
} else {
|
||||||
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
||||||
O << *Op.getExpr();
|
Op.getExpr()->print(O, &MAI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -966,7 +966,7 @@ void AArch64InstPrinter::printAddSubImm(const MCInst *MI, unsigned OpNum,
|
||||||
*CommentStream << '=' << (Val << Shift) << '\n';
|
*CommentStream << '=' << (Val << Shift) << '\n';
|
||||||
} else {
|
} else {
|
||||||
assert(MO.isExpr() && "Unexpected operand type!");
|
assert(MO.isExpr() && "Unexpected operand type!");
|
||||||
O << *MO.getExpr();
|
MO.getExpr()->print(O, &MAI);
|
||||||
printShifter(MI, OpNum + 1, STI, O);
|
printShifter(MI, OpNum + 1, STI, O);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1091,7 +1091,7 @@ void AArch64InstPrinter::printUImm12Offset(const MCInst *MI, unsigned OpNum,
|
||||||
O << "#" << (MO.getImm() * Scale);
|
O << "#" << (MO.getImm() * Scale);
|
||||||
} else {
|
} else {
|
||||||
assert(MO.isExpr() && "Unexpected operand type!");
|
assert(MO.isExpr() && "Unexpected operand type!");
|
||||||
O << *MO.getExpr();
|
MO.getExpr()->print(O, &MAI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1103,7 +1103,8 @@ void AArch64InstPrinter::printAMIndexedWB(const MCInst *MI, unsigned OpNum,
|
||||||
O << ", #" << (MO1.getImm() * Scale);
|
O << ", #" << (MO1.getImm() * Scale);
|
||||||
} else {
|
} else {
|
||||||
assert(MO1.isExpr() && "Unexpected operand type!");
|
assert(MO1.isExpr() && "Unexpected operand type!");
|
||||||
O << ", " << *MO1.getExpr();
|
O << ", ";
|
||||||
|
MO1.getExpr()->print(O, &MAI);
|
||||||
}
|
}
|
||||||
O << ']';
|
O << ']';
|
||||||
}
|
}
|
||||||
|
@ -1286,7 +1287,7 @@ void AArch64InstPrinter::printAlignedLabel(const MCInst *MI, unsigned OpNum,
|
||||||
O.write_hex(Address);
|
O.write_hex(Address);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, just print the expression.
|
// Otherwise, just print the expression.
|
||||||
O << *MI->getOperand(OpNum).getExpr();
|
MI->getOperand(OpNum).getExpr()->print(O, &MAI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1303,7 +1304,7 @@ void AArch64InstPrinter::printAdrpLabel(const MCInst *MI, unsigned OpNum,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise, just print the expression.
|
// Otherwise, just print the expression.
|
||||||
O << *MI->getOperand(OpNum).getExpr();
|
MI->getOperand(OpNum).getExpr()->print(O, &MAI);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AArch64InstPrinter::printBarrierOption(const MCInst *MI, unsigned OpNo,
|
void AArch64InstPrinter::printBarrierOption(const MCInst *MI, unsigned OpNo,
|
||||||
|
|
|
@ -75,10 +75,10 @@ StringRef AArch64MCExpr::getVariantKindName() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AArch64MCExpr::printImpl(raw_ostream &OS) const {
|
void AArch64MCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
|
||||||
if (getKind() != VK_NONE)
|
if (getKind() != VK_NONE)
|
||||||
OS << getVariantKindName();
|
OS << getVariantKindName();
|
||||||
OS << *Expr;
|
Expr->print(OS, MAI);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AArch64MCExpr::visitUsedExpr(MCStreamer &Streamer) const {
|
void AArch64MCExpr::visitUsedExpr(MCStreamer &Streamer) const {
|
||||||
|
|
|
@ -145,7 +145,7 @@ public:
|
||||||
/// (e.g. ":got:", ":lo12:").
|
/// (e.g. ":got:", ":lo12:").
|
||||||
StringRef getVariantKindName() const;
|
StringRef getVariantKindName() const;
|
||||||
|
|
||||||
void printImpl(raw_ostream &OS) const override;
|
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
|
||||||
|
|
||||||
void visitUsedExpr(MCStreamer &Streamer) const override;
|
void visitUsedExpr(MCStreamer &Streamer) const override;
|
||||||
|
|
||||||
|
|
|
@ -173,7 +173,7 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MachineOperand::MO_MachineBasicBlock:
|
case MachineOperand::MO_MachineBasicBlock:
|
||||||
O << *MO.getMBB()->getSymbol();
|
MO.getMBB()->getSymbol()->print(O, MAI);
|
||||||
return;
|
return;
|
||||||
case MachineOperand::MO_GlobalAddress: {
|
case MachineOperand::MO_GlobalAddress: {
|
||||||
const GlobalValue *GV = MO.getGlobal();
|
const GlobalValue *GV = MO.getGlobal();
|
||||||
|
@ -181,7 +181,7 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
||||||
O << ":lower16:";
|
O << ":lower16:";
|
||||||
else if (TF & ARMII::MO_HI16)
|
else if (TF & ARMII::MO_HI16)
|
||||||
O << ":upper16:";
|
O << ":upper16:";
|
||||||
O << *GetARMGVSymbol(GV, TF);
|
GetARMGVSymbol(GV, TF)->print(O, MAI);
|
||||||
|
|
||||||
printOffset(MO.getOffset(), O);
|
printOffset(MO.getOffset(), O);
|
||||||
if (TF == ARMII::MO_PLT)
|
if (TF == ARMII::MO_PLT)
|
||||||
|
@ -189,7 +189,7 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MachineOperand::MO_ConstantPoolIndex:
|
case MachineOperand::MO_ConstantPoolIndex:
|
||||||
O << *GetCPISymbol(MO.getIndex());
|
GetCPISymbol(MO.getIndex())->print(O, MAI);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -329,7 +329,8 @@ void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||||
const MCExpr *Expr = Op.getExpr();
|
const MCExpr *Expr = Op.getExpr();
|
||||||
switch (Expr->getKind()) {
|
switch (Expr->getKind()) {
|
||||||
case MCExpr::Binary:
|
case MCExpr::Binary:
|
||||||
O << '#' << *Expr;
|
O << '#';
|
||||||
|
Expr->print(O, &MAI);
|
||||||
break;
|
break;
|
||||||
case MCExpr::Constant: {
|
case MCExpr::Constant: {
|
||||||
// If a symbolic branch target was added as a constant expression then
|
// If a symbolic branch target was added as a constant expression then
|
||||||
|
@ -338,7 +339,8 @@ void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||||
const MCConstantExpr *Constant = cast<MCConstantExpr>(Expr);
|
const MCConstantExpr *Constant = cast<MCConstantExpr>(Expr);
|
||||||
int64_t TargetAddress;
|
int64_t TargetAddress;
|
||||||
if (!Constant->evaluateAsAbsolute(TargetAddress)) {
|
if (!Constant->evaluateAsAbsolute(TargetAddress)) {
|
||||||
O << '#' << *Expr;
|
O << '#';
|
||||||
|
Expr->print(O, &MAI);
|
||||||
} else {
|
} else {
|
||||||
O << "0x";
|
O << "0x";
|
||||||
O.write_hex(static_cast<uint32_t>(TargetAddress));
|
O.write_hex(static_cast<uint32_t>(TargetAddress));
|
||||||
|
@ -348,7 +350,7 @@ void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||||
default:
|
default:
|
||||||
// FIXME: Should we always treat this as if it is a constant literal and
|
// FIXME: Should we always treat this as if it is a constant literal and
|
||||||
// prefix it with '#'?
|
// prefix it with '#'?
|
||||||
O << *Expr;
|
Expr->print(O, &MAI);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -359,7 +361,7 @@ void ARMInstPrinter::printThumbLdrLabelOperand(const MCInst *MI, unsigned OpNum,
|
||||||
raw_ostream &O) {
|
raw_ostream &O) {
|
||||||
const MCOperand &MO1 = MI->getOperand(OpNum);
|
const MCOperand &MO1 = MI->getOperand(OpNum);
|
||||||
if (MO1.isExpr()) {
|
if (MO1.isExpr()) {
|
||||||
O << *MO1.getExpr();
|
MO1.getExpr()->print(O, &MAI);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1055,7 +1057,7 @@ void ARMInstPrinter::printAdrLabelOperand(const MCInst *MI, unsigned OpNum,
|
||||||
const MCOperand &MO = MI->getOperand(OpNum);
|
const MCOperand &MO = MI->getOperand(OpNum);
|
||||||
|
|
||||||
if (MO.isExpr()) {
|
if (MO.isExpr()) {
|
||||||
O << *MO.getExpr();
|
MO.getExpr()->print(O, &MAI);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,13 @@ ARMTargetAsmStreamer::AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *S) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARMTargetAsmStreamer::emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) {
|
void ARMTargetAsmStreamer::emitThumbSet(MCSymbol *Symbol, const MCExpr *Value) {
|
||||||
OS << "\t.thumb_set\t" << *Symbol << ", " << *Value << '\n';
|
const MCAsmInfo *MAI = Streamer.getContext().getAsmInfo();
|
||||||
|
|
||||||
|
OS << "\t.thumb_set\t";
|
||||||
|
Symbol->print(OS, MAI);
|
||||||
|
OS << ", ";
|
||||||
|
Value->print(OS, MAI);
|
||||||
|
OS << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARMTargetAsmStreamer::emitInst(uint32_t Inst, char Suffix) {
|
void ARMTargetAsmStreamer::emitInst(uint32_t Inst, char Suffix) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ ARMMCExpr::create(VariantKind Kind, const MCExpr *Expr,
|
||||||
return new (Ctx) ARMMCExpr(Kind, Expr);
|
return new (Ctx) ARMMCExpr(Kind, Expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARMMCExpr::printImpl(raw_ostream &OS) const {
|
void ARMMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
|
||||||
switch (Kind) {
|
switch (Kind) {
|
||||||
default: llvm_unreachable("Invalid kind!");
|
default: llvm_unreachable("Invalid kind!");
|
||||||
case VK_ARM_HI16: OS << ":upper16:"; break;
|
case VK_ARM_HI16: OS << ":upper16:"; break;
|
||||||
|
@ -31,7 +31,7 @@ void ARMMCExpr::printImpl(raw_ostream &OS) const {
|
||||||
const MCExpr *Expr = getSubExpr();
|
const MCExpr *Expr = getSubExpr();
|
||||||
if (Expr->getKind() != MCExpr::SymbolRef)
|
if (Expr->getKind() != MCExpr::SymbolRef)
|
||||||
OS << '(';
|
OS << '(';
|
||||||
Expr->print(OS);
|
Expr->print(OS, MAI);
|
||||||
if (Expr->getKind() != MCExpr::SymbolRef)
|
if (Expr->getKind() != MCExpr::SymbolRef)
|
||||||
OS << ')';
|
OS << ')';
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ public:
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
void printImpl(raw_ostream &OS) const override;
|
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
|
||||||
bool evaluateAsRelocatableImpl(MCValue &Res,
|
bool evaluateAsRelocatableImpl(MCValue &Res,
|
||||||
const MCAsmLayout *Layout,
|
const MCAsmLayout *Layout,
|
||||||
const MCFixup *Fixup) const override {
|
const MCFixup *Fixup) const override {
|
||||||
|
|
|
@ -79,14 +79,14 @@ void HexagonAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
||||||
O << MO.getImm();
|
O << MO.getImm();
|
||||||
return;
|
return;
|
||||||
case MachineOperand::MO_MachineBasicBlock:
|
case MachineOperand::MO_MachineBasicBlock:
|
||||||
O << *MO.getMBB()->getSymbol();
|
MO.getMBB()->getSymbol()->print(O, MAI);
|
||||||
return;
|
return;
|
||||||
case MachineOperand::MO_ConstantPoolIndex:
|
case MachineOperand::MO_ConstantPoolIndex:
|
||||||
O << *GetCPISymbol(MO.getIndex());
|
GetCPISymbol(MO.getIndex())->print(O, MAI);
|
||||||
return;
|
return;
|
||||||
case MachineOperand::MO_GlobalAddress:
|
case MachineOperand::MO_GlobalAddress:
|
||||||
// Computing the address of a global symbol, not calling it.
|
// Computing the address of a global symbol, not calling it.
|
||||||
O << *getSymbol(MO.getGlobal());
|
getSymbol(MO.getGlobal())->print(O, MAI);
|
||||||
printOffset(MO.getOffset(), O);
|
printOffset(MO.getOffset(), O);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -164,7 +164,7 @@ void HexagonInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||||
if (MO.isReg()) {
|
if (MO.isReg()) {
|
||||||
printRegName(O, MO.getReg());
|
printRegName(O, MO.getReg());
|
||||||
} else if(MO.isExpr()) {
|
} else if(MO.isExpr()) {
|
||||||
O << *MO.getExpr();
|
MO.getExpr()->print(O, &MAI);
|
||||||
} else if(MO.isImm()) {
|
} else if(MO.isImm()) {
|
||||||
printImmOperand(MI, OpNo, O);
|
printImmOperand(MI, OpNo, O);
|
||||||
} else {
|
} else {
|
||||||
|
@ -177,7 +177,7 @@ void HexagonInstPrinter::printImmOperand(const MCInst *MI, unsigned OpNo,
|
||||||
const MCOperand& MO = MI->getOperand(OpNo);
|
const MCOperand& MO = MI->getOperand(OpNo);
|
||||||
|
|
||||||
if(MO.isExpr()) {
|
if(MO.isExpr()) {
|
||||||
O << *MO.getExpr();
|
MO.getExpr()->print(O, &MAI);
|
||||||
} else if(MO.isImm()) {
|
} else if(MO.isImm()) {
|
||||||
O << MI->getOperand(OpNo).getImm();
|
O << MI->getOperand(OpNo).getImm();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -39,7 +39,7 @@ void MSP430InstPrinter::printPCRelImmOperand(const MCInst *MI, unsigned OpNo,
|
||||||
O << Op.getImm();
|
O << Op.getImm();
|
||||||
else {
|
else {
|
||||||
assert(Op.isExpr() && "unknown pcrel immediate operand");
|
assert(Op.isExpr() && "unknown pcrel immediate operand");
|
||||||
O << *Op.getExpr();
|
Op.getExpr()->print(O, &MAI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,7 +53,8 @@ void MSP430InstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||||
O << '#' << Op.getImm();
|
O << '#' << Op.getImm();
|
||||||
} else {
|
} else {
|
||||||
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
||||||
O << '#' << *Op.getExpr();
|
O << '#';
|
||||||
|
Op.getExpr()->print(O, &MAI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +76,7 @@ void MSP430InstPrinter::printSrcMemOperand(const MCInst *MI, unsigned OpNo,
|
||||||
O << '&';
|
O << '&';
|
||||||
|
|
||||||
if (Disp.isExpr())
|
if (Disp.isExpr())
|
||||||
O << *Disp.getExpr();
|
Disp.getExpr()->print(O, &MAI);
|
||||||
else {
|
else {
|
||||||
assert(Disp.isImm() && "Expected immediate in displacement field");
|
assert(Disp.isImm() && "Expected immediate in displacement field");
|
||||||
O << Disp.getImm();
|
O << Disp.getImm();
|
||||||
|
|
|
@ -75,7 +75,7 @@ void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
||||||
O << MO.getImm();
|
O << MO.getImm();
|
||||||
return;
|
return;
|
||||||
case MachineOperand::MO_MachineBasicBlock:
|
case MachineOperand::MO_MachineBasicBlock:
|
||||||
O << *MO.getMBB()->getSymbol();
|
MO.getMBB()->getSymbol()->print(O, MAI);
|
||||||
return;
|
return;
|
||||||
case MachineOperand::MO_GlobalAddress: {
|
case MachineOperand::MO_GlobalAddress: {
|
||||||
bool isMemOp = Modifier && !strcmp(Modifier, "mem");
|
bool isMemOp = Modifier && !strcmp(Modifier, "mem");
|
||||||
|
@ -92,7 +92,7 @@ void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
||||||
if (Offset)
|
if (Offset)
|
||||||
O << '(' << Offset << '+';
|
O << '(' << Offset << '+';
|
||||||
|
|
||||||
O << *getSymbol(MO.getGlobal());
|
getSymbol(MO.getGlobal())->print(O, MAI);
|
||||||
|
|
||||||
if (Offset)
|
if (Offset)
|
||||||
O << ')';
|
O << ')';
|
||||||
|
|
|
@ -122,7 +122,8 @@ void MipsInstPrinter::printInst(const MCInst *MI, raw_ostream &O,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printExpr(const MCExpr *Expr, raw_ostream &OS) {
|
static void printExpr(const MCExpr *Expr, const MCAsmInfo *MAI,
|
||||||
|
raw_ostream &OS) {
|
||||||
int Offset = 0;
|
int Offset = 0;
|
||||||
const MCSymbolRefExpr *SRE;
|
const MCSymbolRefExpr *SRE;
|
||||||
|
|
||||||
|
@ -132,7 +133,7 @@ static void printExpr(const MCExpr *Expr, raw_ostream &OS) {
|
||||||
assert(SRE && CE && "Binary expression must be sym+const.");
|
assert(SRE && CE && "Binary expression must be sym+const.");
|
||||||
Offset = CE->getValue();
|
Offset = CE->getValue();
|
||||||
} else if (const MipsMCExpr *ME = dyn_cast<MipsMCExpr>(Expr)) {
|
} else if (const MipsMCExpr *ME = dyn_cast<MipsMCExpr>(Expr)) {
|
||||||
ME->print(OS);
|
ME->print(OS, MAI);
|
||||||
return;
|
return;
|
||||||
} else
|
} else
|
||||||
SRE = cast<MCSymbolRefExpr>(Expr);
|
SRE = cast<MCSymbolRefExpr>(Expr);
|
||||||
|
@ -170,7 +171,7 @@ static void printExpr(const MCExpr *Expr, raw_ostream &OS) {
|
||||||
case MCSymbolRefExpr::VK_Mips_PCREL_LO16: OS << "%pcrel_lo("; break;
|
case MCSymbolRefExpr::VK_Mips_PCREL_LO16: OS << "%pcrel_lo("; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
OS << SRE->getSymbol();
|
SRE->getSymbol().print(OS, MAI);
|
||||||
|
|
||||||
if (Offset) {
|
if (Offset) {
|
||||||
if (Offset > 0)
|
if (Offset > 0)
|
||||||
|
@ -199,7 +200,7 @@ void MipsInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
||||||
printExpr(Op.getExpr(), O);
|
printExpr(Op.getExpr(), &MAI, O);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MipsInstPrinter::printUnsignedImm(const MCInst *MI, int opNum,
|
void MipsInstPrinter::printUnsignedImm(const MCInst *MI, int opNum,
|
||||||
|
|
|
@ -64,7 +64,7 @@ MipsMCExpr::create(MCSymbolRefExpr::VariantKind VK, const MCExpr *Expr,
|
||||||
return new (Ctx) MipsMCExpr(Kind, Expr);
|
return new (Ctx) MipsMCExpr(Kind, Expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MipsMCExpr::printImpl(raw_ostream &OS) const {
|
void MipsMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
|
||||||
switch (Kind) {
|
switch (Kind) {
|
||||||
default: llvm_unreachable("Invalid kind!");
|
default: llvm_unreachable("Invalid kind!");
|
||||||
case VK_Mips_LO: OS << "%lo"; break;
|
case VK_Mips_LO: OS << "%lo"; break;
|
||||||
|
@ -74,7 +74,7 @@ void MipsMCExpr::printImpl(raw_ostream &OS) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
OS << '(';
|
OS << '(';
|
||||||
Expr->print(OS);
|
Expr->print(OS, MAI);
|
||||||
OS << ')';
|
OS << ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public:
|
||||||
/// getSubExpr - Get the child of this expression.
|
/// getSubExpr - Get the child of this expression.
|
||||||
const MCExpr *getSubExpr() const { return Expr; }
|
const MCExpr *getSubExpr() const { return Expr; }
|
||||||
|
|
||||||
void printImpl(raw_ostream &OS) const override;
|
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
|
||||||
bool evaluateAsRelocatableImpl(MCValue &Res,
|
bool evaluateAsRelocatableImpl(MCValue &Res,
|
||||||
const MCAsmLayout *Layout,
|
const MCAsmLayout *Layout,
|
||||||
const MCFixup *Fixup) const override;
|
const MCFixup *Fixup) const override;
|
||||||
|
|
|
@ -594,11 +594,11 @@ void MipsAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MachineOperand::MO_MachineBasicBlock:
|
case MachineOperand::MO_MachineBasicBlock:
|
||||||
O << *MO.getMBB()->getSymbol();
|
MO.getMBB()->getSymbol()->print(O, MAI);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case MachineOperand::MO_GlobalAddress:
|
case MachineOperand::MO_GlobalAddress:
|
||||||
O << *getSymbol(MO.getGlobal());
|
getSymbol(MO.getGlobal())->print(O, MAI);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MachineOperand::MO_BlockAddress: {
|
case MachineOperand::MO_BlockAddress: {
|
||||||
|
|
|
@ -85,7 +85,7 @@ void NVPTXInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||||
O << markup("<imm:") << formatImm(Op.getImm()) << markup(">");
|
O << markup("<imm:") << formatImm(Op.getImm()) << markup(">");
|
||||||
} else {
|
} else {
|
||||||
assert(Op.isExpr() && "Unknown operand kind in printOperand");
|
assert(Op.isExpr() && "Unknown operand kind in printOperand");
|
||||||
O << *Op.getExpr();
|
Op.getExpr()->print(O, &MAI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -467,7 +467,7 @@ void NVPTXAsmPrinter::EmitFunctionEntryLabel() {
|
||||||
printReturnValStr(*MF, O);
|
printReturnValStr(*MF, O);
|
||||||
}
|
}
|
||||||
|
|
||||||
O << *CurrentFnSym;
|
CurrentFnSym->print(O, MAI);
|
||||||
|
|
||||||
emitFunctionParamList(*MF, O);
|
emitFunctionParamList(*MF, O);
|
||||||
|
|
||||||
|
@ -624,7 +624,8 @@ void NVPTXAsmPrinter::emitDeclaration(const Function *F, raw_ostream &O) {
|
||||||
else
|
else
|
||||||
O << ".func ";
|
O << ".func ";
|
||||||
printReturnValStr(F, O);
|
printReturnValStr(F, O);
|
||||||
O << *getSymbol(F) << "\n";
|
getSymbol(F)->print(O, MAI);
|
||||||
|
O << "\n";
|
||||||
emitFunctionParamList(F, O);
|
emitFunctionParamList(F, O);
|
||||||
O << ";\n";
|
O << ";\n";
|
||||||
}
|
}
|
||||||
|
@ -1171,7 +1172,7 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
|
||||||
else
|
else
|
||||||
O << getPTXFundamentalTypeStr(ETy, false);
|
O << getPTXFundamentalTypeStr(ETy, false);
|
||||||
O << " ";
|
O << " ";
|
||||||
O << *getSymbol(GVar);
|
getSymbol(GVar)->print(O, MAI);
|
||||||
|
|
||||||
// Ptx allows variable initilization only for constant and global state
|
// Ptx allows variable initilization only for constant and global state
|
||||||
// spaces.
|
// spaces.
|
||||||
|
@ -1217,15 +1218,21 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
|
||||||
bufferAggregateConstant(Initializer, &aggBuffer);
|
bufferAggregateConstant(Initializer, &aggBuffer);
|
||||||
if (aggBuffer.numSymbols) {
|
if (aggBuffer.numSymbols) {
|
||||||
if (static_cast<const NVPTXTargetMachine &>(TM).is64Bit()) {
|
if (static_cast<const NVPTXTargetMachine &>(TM).is64Bit()) {
|
||||||
O << " .u64 " << *getSymbol(GVar) << "[";
|
O << " .u64 ";
|
||||||
|
getSymbol(GVar)->print(O, MAI);
|
||||||
|
O << "[";
|
||||||
O << ElementSize / 8;
|
O << ElementSize / 8;
|
||||||
} else {
|
} else {
|
||||||
O << " .u32 " << *getSymbol(GVar) << "[";
|
O << " .u32 ";
|
||||||
|
getSymbol(GVar)->print(O, MAI);
|
||||||
|
O << "[";
|
||||||
O << ElementSize / 4;
|
O << ElementSize / 4;
|
||||||
}
|
}
|
||||||
O << "]";
|
O << "]";
|
||||||
} else {
|
} else {
|
||||||
O << " .b8 " << *getSymbol(GVar) << "[";
|
O << " .b8 ";
|
||||||
|
getSymbol(GVar)->print(O, MAI);
|
||||||
|
O << "[";
|
||||||
O << ElementSize;
|
O << ElementSize;
|
||||||
O << "]";
|
O << "]";
|
||||||
}
|
}
|
||||||
|
@ -1233,7 +1240,8 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
|
||||||
aggBuffer.print();
|
aggBuffer.print();
|
||||||
O << "}";
|
O << "}";
|
||||||
} else {
|
} else {
|
||||||
O << " .b8 " << *getSymbol(GVar);
|
O << " .b8 ";
|
||||||
|
getSymbol(GVar)->print(O, MAI);
|
||||||
if (ElementSize) {
|
if (ElementSize) {
|
||||||
O << "[";
|
O << "[";
|
||||||
O << ElementSize;
|
O << ElementSize;
|
||||||
|
@ -1241,7 +1249,8 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
O << " .b8 " << *getSymbol(GVar);
|
O << " .b8 ";
|
||||||
|
getSymbol(GVar)->print(O, MAI);
|
||||||
if (ElementSize) {
|
if (ElementSize) {
|
||||||
O << "[";
|
O << "[";
|
||||||
O << ElementSize;
|
O << ElementSize;
|
||||||
|
@ -1348,7 +1357,7 @@ void NVPTXAsmPrinter::emitPTXGlobalVariable(const GlobalVariable *GVar,
|
||||||
O << " .";
|
O << " .";
|
||||||
O << getPTXFundamentalTypeStr(ETy);
|
O << getPTXFundamentalTypeStr(ETy);
|
||||||
O << " ";
|
O << " ";
|
||||||
O << *getSymbol(GVar);
|
getSymbol(GVar)->print(O, MAI);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1363,7 +1372,9 @@ void NVPTXAsmPrinter::emitPTXGlobalVariable(const GlobalVariable *GVar,
|
||||||
case Type::ArrayTyID:
|
case Type::ArrayTyID:
|
||||||
case Type::VectorTyID:
|
case Type::VectorTyID:
|
||||||
ElementSize = TD->getTypeStoreSize(ETy);
|
ElementSize = TD->getTypeStoreSize(ETy);
|
||||||
O << " .b8 " << *getSymbol(GVar) << "[";
|
O << " .b8 ";
|
||||||
|
getSymbol(GVar)->print(O, MAI);
|
||||||
|
O << "[";
|
||||||
if (ElementSize) {
|
if (ElementSize) {
|
||||||
O << ElementSize;
|
O << ElementSize;
|
||||||
}
|
}
|
||||||
|
@ -1405,11 +1416,13 @@ static unsigned int getOpenCLAlignment(const DataLayout *TD, Type *Ty) {
|
||||||
|
|
||||||
void NVPTXAsmPrinter::printParamName(Function::const_arg_iterator I,
|
void NVPTXAsmPrinter::printParamName(Function::const_arg_iterator I,
|
||||||
int paramIndex, raw_ostream &O) {
|
int paramIndex, raw_ostream &O) {
|
||||||
O << *getSymbol(I->getParent()) << "_param_" << paramIndex;
|
getSymbol(I->getParent())->print(O, MAI);
|
||||||
|
O << "_param_" << paramIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NVPTXAsmPrinter::printParamName(int paramIndex, raw_ostream &O) {
|
void NVPTXAsmPrinter::printParamName(int paramIndex, raw_ostream &O) {
|
||||||
O << *CurrentFnSym << "_param_" << paramIndex;
|
CurrentFnSym->print(O, MAI);
|
||||||
|
O << "_param_" << paramIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
|
void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
|
||||||
|
@ -1443,21 +1456,24 @@ void NVPTXAsmPrinter::emitFunctionParamList(const Function *F, raw_ostream &O) {
|
||||||
O << "\t.param .u64 .ptr .surfref ";
|
O << "\t.param .u64 .ptr .surfref ";
|
||||||
else
|
else
|
||||||
O << "\t.param .surfref ";
|
O << "\t.param .surfref ";
|
||||||
O << *CurrentFnSym << "_param_" << paramIndex;
|
CurrentFnSym->print(O, MAI);
|
||||||
|
O << "_param_" << paramIndex;
|
||||||
}
|
}
|
||||||
else { // Default image is read_only
|
else { // Default image is read_only
|
||||||
if (nvptxSubtarget->hasImageHandles())
|
if (nvptxSubtarget->hasImageHandles())
|
||||||
O << "\t.param .u64 .ptr .texref ";
|
O << "\t.param .u64 .ptr .texref ";
|
||||||
else
|
else
|
||||||
O << "\t.param .texref ";
|
O << "\t.param .texref ";
|
||||||
O << *CurrentFnSym << "_param_" << paramIndex;
|
CurrentFnSym->print(O, MAI);
|
||||||
|
O << "_param_" << paramIndex;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (nvptxSubtarget->hasImageHandles())
|
if (nvptxSubtarget->hasImageHandles())
|
||||||
O << "\t.param .u64 .ptr .samplerref ";
|
O << "\t.param .u64 .ptr .samplerref ";
|
||||||
else
|
else
|
||||||
O << "\t.param .samplerref ";
|
O << "\t.param .samplerref ";
|
||||||
O << *CurrentFnSym << "_param_" << paramIndex;
|
CurrentFnSym->print(O, MAI);
|
||||||
|
O << "_param_" << paramIndex;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1713,10 +1729,10 @@ void NVPTXAsmPrinter::printScalarConstant(const Constant *CPV, raw_ostream &O) {
|
||||||
}
|
}
|
||||||
if (EmitGeneric && !isa<Function>(CPV) && !IsNonGenericPointer) {
|
if (EmitGeneric && !isa<Function>(CPV) && !IsNonGenericPointer) {
|
||||||
O << "generic(";
|
O << "generic(";
|
||||||
O << *getSymbol(GVar);
|
getSymbol(GVar)->print(O, MAI);
|
||||||
O << ")";
|
O << ")";
|
||||||
} else {
|
} else {
|
||||||
O << *getSymbol(GVar);
|
getSymbol(GVar)->print(O, MAI);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1730,14 +1746,14 @@ void NVPTXAsmPrinter::printScalarConstant(const Constant *CPV, raw_ostream &O) {
|
||||||
if (const GlobalValue *GVar = dyn_cast<GlobalValue>(v)) {
|
if (const GlobalValue *GVar = dyn_cast<GlobalValue>(v)) {
|
||||||
if (EmitGeneric && !isa<Function>(v) && !IsNonGenericPointer) {
|
if (EmitGeneric && !isa<Function>(v) && !IsNonGenericPointer) {
|
||||||
O << "generic(";
|
O << "generic(";
|
||||||
O << *getSymbol(GVar);
|
getSymbol(GVar)->print(O, MAI);
|
||||||
O << ")";
|
O << ")";
|
||||||
} else {
|
} else {
|
||||||
O << *getSymbol(GVar);
|
getSymbol(GVar)->print(O, MAI);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
O << *lowerConstant(CPV);
|
lowerConstant(CPV)->print(O, MAI);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2120,7 +2136,7 @@ NVPTXAsmPrinter::lowerConstantForGV(const Constant *CV, bool ProcessingGeneric)
|
||||||
void NVPTXAsmPrinter::printMCExpr(const MCExpr &Expr, raw_ostream &OS) {
|
void NVPTXAsmPrinter::printMCExpr(const MCExpr &Expr, raw_ostream &OS) {
|
||||||
switch (Expr.getKind()) {
|
switch (Expr.getKind()) {
|
||||||
case MCExpr::Target:
|
case MCExpr::Target:
|
||||||
return cast<MCTargetExpr>(&Expr)->printImpl(OS);
|
return cast<MCTargetExpr>(&Expr)->printImpl(OS, MAI);
|
||||||
case MCExpr::Constant:
|
case MCExpr::Constant:
|
||||||
OS << cast<MCConstantExpr>(Expr).getValue();
|
OS << cast<MCConstantExpr>(Expr).getValue();
|
||||||
return;
|
return;
|
||||||
|
@ -2128,7 +2144,7 @@ void NVPTXAsmPrinter::printMCExpr(const MCExpr &Expr, raw_ostream &OS) {
|
||||||
case MCExpr::SymbolRef: {
|
case MCExpr::SymbolRef: {
|
||||||
const MCSymbolRefExpr &SRE = cast<MCSymbolRefExpr>(Expr);
|
const MCSymbolRefExpr &SRE = cast<MCSymbolRefExpr>(Expr);
|
||||||
const MCSymbol &Sym = SRE.getSymbol();
|
const MCSymbol &Sym = SRE.getSymbol();
|
||||||
OS << Sym;
|
Sym.print(OS, MAI);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2253,11 +2269,11 @@ void NVPTXAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MachineOperand::MO_GlobalAddress:
|
case MachineOperand::MO_GlobalAddress:
|
||||||
O << *getSymbol(MO.getGlobal());
|
getSymbol(MO.getGlobal())->print(O, MAI);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MachineOperand::MO_MachineBasicBlock:
|
case MachineOperand::MO_MachineBasicBlock:
|
||||||
O << *MO.getMBB()->getSymbol();
|
MO.getMBB()->getSymbol()->print(O, MAI);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -165,10 +165,10 @@ class LLVM_LIBRARY_VISIBILITY NVPTXAsmPrinter : public AsmPrinter {
|
||||||
}
|
}
|
||||||
if (EmitGeneric && !isa<Function>(v) && !IsNonGenericPointer) {
|
if (EmitGeneric && !isa<Function>(v) && !IsNonGenericPointer) {
|
||||||
O << "generic(";
|
O << "generic(";
|
||||||
O << *Name;
|
Name->print(O, AP.MAI);
|
||||||
O << ")";
|
O << ")";
|
||||||
} else {
|
} else {
|
||||||
O << *Name;
|
Name->print(O, AP.MAI);
|
||||||
}
|
}
|
||||||
} else if (const ConstantExpr *CExpr = dyn_cast<ConstantExpr>(v0)) {
|
} else if (const ConstantExpr *CExpr = dyn_cast<ConstantExpr>(v0)) {
|
||||||
const MCExpr *Expr =
|
const MCExpr *Expr =
|
||||||
|
|
|
@ -20,7 +20,7 @@ NVPTXFloatMCExpr::create(VariantKind Kind, APFloat Flt, MCContext &Ctx) {
|
||||||
return new (Ctx) NVPTXFloatMCExpr(Kind, Flt);
|
return new (Ctx) NVPTXFloatMCExpr(Kind, Flt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NVPTXFloatMCExpr::printImpl(raw_ostream &OS) const {
|
void NVPTXFloatMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
|
||||||
bool Ignored;
|
bool Ignored;
|
||||||
unsigned NumHex;
|
unsigned NumHex;
|
||||||
APFloat APF = getAPFloat();
|
APFloat APF = getAPFloat();
|
||||||
|
@ -52,6 +52,9 @@ NVPTXGenericMCSymbolRefExpr::create(const MCSymbolRefExpr *SymExpr,
|
||||||
return new (Ctx) NVPTXGenericMCSymbolRefExpr(SymExpr);
|
return new (Ctx) NVPTXGenericMCSymbolRefExpr(SymExpr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NVPTXGenericMCSymbolRefExpr::printImpl(raw_ostream &OS) const {
|
void NVPTXGenericMCSymbolRefExpr::printImpl(raw_ostream &OS,
|
||||||
OS << "generic(" << *SymExpr << ")";
|
const MCAsmInfo *MAI) const {
|
||||||
|
OS << "generic(";
|
||||||
|
SymExpr->print(OS, MAI);
|
||||||
|
OS << ")";
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,7 @@ public:
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
void printImpl(raw_ostream &OS) const override;
|
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
|
||||||
bool evaluateAsRelocatableImpl(MCValue &Res,
|
bool evaluateAsRelocatableImpl(MCValue &Res,
|
||||||
const MCAsmLayout *Layout,
|
const MCAsmLayout *Layout,
|
||||||
const MCFixup *Fixup) const override {
|
const MCFixup *Fixup) const override {
|
||||||
|
@ -103,7 +103,7 @@ public:
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
void printImpl(raw_ostream &OS) const override;
|
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
|
||||||
bool evaluateAsRelocatableImpl(MCValue &Res,
|
bool evaluateAsRelocatableImpl(MCValue &Res,
|
||||||
const MCAsmLayout *Layout,
|
const MCAsmLayout *Layout,
|
||||||
const MCFixup *Fixup) const override {
|
const MCFixup *Fixup) const override {
|
||||||
|
|
|
@ -445,6 +445,6 @@ void PPCInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
||||||
O << *Op.getExpr();
|
Op.getExpr()->print(O, &MAI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ PPCMCExpr::create(VariantKind Kind, const MCExpr *Expr,
|
||||||
return new (Ctx) PPCMCExpr(Kind, Expr, isDarwin);
|
return new (Ctx) PPCMCExpr(Kind, Expr, isDarwin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPCMCExpr::printImpl(raw_ostream &OS) const {
|
void PPCMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
|
||||||
if (isDarwinSyntax()) {
|
if (isDarwinSyntax()) {
|
||||||
switch (Kind) {
|
switch (Kind) {
|
||||||
default: llvm_unreachable("Invalid kind!");
|
default: llvm_unreachable("Invalid kind!");
|
||||||
|
@ -34,10 +34,10 @@ void PPCMCExpr::printImpl(raw_ostream &OS) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
OS << '(';
|
OS << '(';
|
||||||
getSubExpr()->print(OS);
|
getSubExpr()->print(OS, MAI);
|
||||||
OS << ')';
|
OS << ')';
|
||||||
} else {
|
} else {
|
||||||
getSubExpr()->print(OS);
|
getSubExpr()->print(OS, MAI);
|
||||||
|
|
||||||
switch (Kind) {
|
switch (Kind) {
|
||||||
default: llvm_unreachable("Invalid kind!");
|
default: llvm_unreachable("Invalid kind!");
|
||||||
|
|
|
@ -77,7 +77,7 @@ public:
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
|
|
||||||
void printImpl(raw_ostream &OS) const override;
|
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
|
||||||
bool evaluateAsRelocatableImpl(MCValue &Res,
|
bool evaluateAsRelocatableImpl(MCValue &Res,
|
||||||
const MCAsmLayout *Layout,
|
const MCAsmLayout *Layout,
|
||||||
const MCFixup *Fixup) const override;
|
const MCFixup *Fixup) const override;
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "PPCMCAsmInfo.h"
|
#include "PPCMCAsmInfo.h"
|
||||||
#include "PPCTargetStreamer.h"
|
#include "PPCTargetStreamer.h"
|
||||||
#include "llvm/MC/MCCodeGenInfo.h"
|
#include "llvm/MC/MCCodeGenInfo.h"
|
||||||
|
#include "llvm/MC/MCContext.h"
|
||||||
#include "llvm/MC/MCELFStreamer.h"
|
#include "llvm/MC/MCELFStreamer.h"
|
||||||
#include "llvm/MC/MCExpr.h"
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/MC/MCInstrInfo.h"
|
#include "llvm/MC/MCInstrInfo.h"
|
||||||
|
@ -132,7 +133,13 @@ public:
|
||||||
OS << "\t.abiversion " << AbiVersion << '\n';
|
OS << "\t.abiversion " << AbiVersion << '\n';
|
||||||
}
|
}
|
||||||
void emitLocalEntry(MCSymbolELF *S, const MCExpr *LocalOffset) override {
|
void emitLocalEntry(MCSymbolELF *S, const MCExpr *LocalOffset) override {
|
||||||
OS << "\t.localentry\t" << *S << ", " << *LocalOffset << '\n';
|
const MCAsmInfo *MAI = Streamer.getContext().getAsmInfo();
|
||||||
|
|
||||||
|
OS << "\t.localentry\t";
|
||||||
|
S->print(OS, MAI);
|
||||||
|
OS << ", ";
|
||||||
|
LocalOffset->print(OS, MAI);
|
||||||
|
OS << '\n';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -181,14 +181,14 @@ void PPCAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case MachineOperand::MO_MachineBasicBlock:
|
case MachineOperand::MO_MachineBasicBlock:
|
||||||
O << *MO.getMBB()->getSymbol();
|
MO.getMBB()->getSymbol()->print(O, MAI);
|
||||||
return;
|
return;
|
||||||
case MachineOperand::MO_ConstantPoolIndex:
|
case MachineOperand::MO_ConstantPoolIndex:
|
||||||
O << DL->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
|
O << DL->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
|
||||||
<< '_' << MO.getIndex();
|
<< '_' << MO.getIndex();
|
||||||
return;
|
return;
|
||||||
case MachineOperand::MO_BlockAddress:
|
case MachineOperand::MO_BlockAddress:
|
||||||
O << *GetBlockAddressSymbol(MO.getBlockAddress());
|
GetBlockAddressSymbol(MO.getBlockAddress())->print(O, MAI);
|
||||||
return;
|
return;
|
||||||
case MachineOperand::MO_GlobalAddress: {
|
case MachineOperand::MO_GlobalAddress: {
|
||||||
// Computing the address of a global symbol, not calling it.
|
// Computing the address of a global symbol, not calling it.
|
||||||
|
@ -223,7 +223,7 @@ void PPCAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
||||||
SymToPrint = getSymbol(GV);
|
SymToPrint = getSymbol(GV);
|
||||||
}
|
}
|
||||||
|
|
||||||
O << *SymToPrint;
|
SymToPrint->print(O, MAI);
|
||||||
|
|
||||||
printOffset(MO.getOffset(), O);
|
printOffset(MO.getOffset(), O);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -337,7 +337,7 @@ void AMDGPUInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||||
}
|
}
|
||||||
} else if (Op.isExpr()) {
|
} else if (Op.isExpr()) {
|
||||||
const MCExpr *Exp = Op.getExpr();
|
const MCExpr *Exp = Op.getExpr();
|
||||||
Exp->print(O);
|
Exp->print(O, &MAI);
|
||||||
} else {
|
} else {
|
||||||
llvm_unreachable("unknown operand type in printOperand");
|
llvm_unreachable("unknown operand type in printOperand");
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ void SparcInstPrinter::printOperand(const MCInst *MI, int opNum,
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(MO.isExpr() && "Unknown operand kind in printOperand");
|
assert(MO.isExpr() && "Unknown operand kind in printOperand");
|
||||||
MO.getExpr()->print(O);
|
MO.getExpr()->print(O, &MAI);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SparcInstPrinter::printMemOperand(const MCInst *MI, int opNum,
|
void SparcInstPrinter::printMemOperand(const MCInst *MI, int opNum,
|
||||||
|
|
|
@ -30,15 +30,12 @@ SparcMCExpr::create(VariantKind Kind, const MCExpr *Expr,
|
||||||
return new (Ctx) SparcMCExpr(Kind, Expr);
|
return new (Ctx) SparcMCExpr(Kind, Expr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SparcMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
|
||||||
|
|
||||||
void SparcMCExpr::printImpl(raw_ostream &OS) const
|
|
||||||
{
|
|
||||||
|
|
||||||
bool closeParen = printVariantKind(OS, Kind);
|
bool closeParen = printVariantKind(OS, Kind);
|
||||||
|
|
||||||
const MCExpr *Expr = getSubExpr();
|
const MCExpr *Expr = getSubExpr();
|
||||||
Expr->print(OS);
|
Expr->print(OS, MAI);
|
||||||
|
|
||||||
if (closeParen)
|
if (closeParen)
|
||||||
OS << ')';
|
OS << ')';
|
||||||
|
|
|
@ -85,7 +85,7 @@ public:
|
||||||
Sparc::Fixups getFixupKind() const { return getFixupKind(Kind); }
|
Sparc::Fixups getFixupKind() const { return getFixupKind(Kind); }
|
||||||
|
|
||||||
/// @}
|
/// @}
|
||||||
void printImpl(raw_ostream &OS) const override;
|
void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const override;
|
||||||
bool evaluateAsRelocatableImpl(MCValue &Res,
|
bool evaluateAsRelocatableImpl(MCValue &Res,
|
||||||
const MCAsmLayout *Layout,
|
const MCAsmLayout *Layout,
|
||||||
const MCFixup *Fixup) const override;
|
const MCFixup *Fixup) const override;
|
||||||
|
|
|
@ -361,10 +361,10 @@ void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
|
||||||
O << (int)MO.getImm();
|
O << (int)MO.getImm();
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_MachineBasicBlock:
|
case MachineOperand::MO_MachineBasicBlock:
|
||||||
O << *MO.getMBB()->getSymbol();
|
MO.getMBB()->getSymbol()->print(O, MAI);
|
||||||
return;
|
return;
|
||||||
case MachineOperand::MO_GlobalAddress:
|
case MachineOperand::MO_GlobalAddress:
|
||||||
O << *getSymbol(MO.getGlobal());
|
getSymbol(MO.getGlobal())->print(O, MAI);
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_BlockAddress:
|
case MachineOperand::MO_BlockAddress:
|
||||||
O << GetBlockAddressSymbol(MO.getBlockAddress())->getName();
|
O << GetBlockAddressSymbol(MO.getBlockAddress())->getName();
|
||||||
|
|
|
@ -37,13 +37,14 @@ void SystemZInstPrinter::printAddress(unsigned Base, int64_t Disp,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemZInstPrinter::printOperand(const MCOperand &MO, raw_ostream &O) {
|
void SystemZInstPrinter::printOperand(const MCOperand &MO, const MCAsmInfo *MAI,
|
||||||
|
raw_ostream &O) {
|
||||||
if (MO.isReg())
|
if (MO.isReg())
|
||||||
O << '%' << getRegisterName(MO.getReg());
|
O << '%' << getRegisterName(MO.getReg());
|
||||||
else if (MO.isImm())
|
else if (MO.isImm())
|
||||||
O << MO.getImm();
|
O << MO.getImm();
|
||||||
else if (MO.isExpr())
|
else if (MO.isExpr())
|
||||||
O << *MO.getExpr();
|
MO.getExpr()->print(O, MAI);
|
||||||
else
|
else
|
||||||
llvm_unreachable("Invalid operand");
|
llvm_unreachable("Invalid operand");
|
||||||
}
|
}
|
||||||
|
@ -147,7 +148,7 @@ void SystemZInstPrinter::printPCRelOperand(const MCInst *MI, int OpNum,
|
||||||
O << "0x";
|
O << "0x";
|
||||||
O.write_hex(MO.getImm());
|
O.write_hex(MO.getImm());
|
||||||
} else
|
} else
|
||||||
O << *MO.getExpr();
|
MO.getExpr()->print(O, &MAI);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemZInstPrinter::printPCRelTLSOperand(const MCInst *MI, int OpNum,
|
void SystemZInstPrinter::printPCRelTLSOperand(const MCInst *MI, int OpNum,
|
||||||
|
@ -175,7 +176,7 @@ void SystemZInstPrinter::printPCRelTLSOperand(const MCInst *MI, int OpNum,
|
||||||
|
|
||||||
void SystemZInstPrinter::printOperand(const MCInst *MI, int OpNum,
|
void SystemZInstPrinter::printOperand(const MCInst *MI, int OpNum,
|
||||||
raw_ostream &O) {
|
raw_ostream &O) {
|
||||||
printOperand(MI->getOperand(OpNum), O);
|
printOperand(MI->getOperand(OpNum), &MAI, O);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SystemZInstPrinter::printBDAddrOperand(const MCInst *MI, int OpNum,
|
void SystemZInstPrinter::printBDAddrOperand(const MCInst *MI, int OpNum,
|
||||||
|
|
|
@ -35,7 +35,8 @@ public:
|
||||||
raw_ostream &O);
|
raw_ostream &O);
|
||||||
|
|
||||||
// Print the given operand.
|
// Print the given operand.
|
||||||
static void printOperand(const MCOperand &MO, raw_ostream &O);
|
static void printOperand(const MCOperand &MO, const MCAsmInfo *MAI,
|
||||||
|
raw_ostream &O);
|
||||||
|
|
||||||
// Override MCInstPrinter.
|
// Override MCInstPrinter.
|
||||||
void printRegName(raw_ostream &O, unsigned RegNo) const override;
|
void printRegName(raw_ostream &O, unsigned RegNo) const override;
|
||||||
|
|
|
@ -305,7 +305,7 @@ bool SystemZAsmPrinter::PrintAsmOperand(const MachineInstr *MI,
|
||||||
} else {
|
} else {
|
||||||
SystemZMCInstLower Lower(MF->getContext(), *this);
|
SystemZMCInstLower Lower(MF->getContext(), *this);
|
||||||
MCOperand MO(Lower.lowerOperand(MI->getOperand(OpNo)));
|
MCOperand MO(Lower.lowerOperand(MI->getOperand(OpNo)));
|
||||||
SystemZInstPrinter::printOperand(MO, OS);
|
SystemZInstPrinter::printOperand(MO, MAI, OS);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ void X86ATTInstPrinter::printPCRelImm(const MCInst *MI, unsigned OpNo,
|
||||||
O << formatHex((uint64_t)Address);
|
O << formatHex((uint64_t)Address);
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, just print the expression.
|
// Otherwise, just print the expression.
|
||||||
O << *Op.getExpr();
|
Op.getExpr()->print(O, &MAI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,9 @@ void X86ATTInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
||||||
O << markup("<imm:") << '$' << *Op.getExpr() << markup(">");
|
O << markup("<imm:") << '$';
|
||||||
|
Op.getExpr()->print(O, &MAI);
|
||||||
|
O << markup(">");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,7 +205,7 @@ void X86ATTInstPrinter::printMemReference(const MCInst *MI, unsigned Op,
|
||||||
O << formatImm(DispVal);
|
O << formatImm(DispVal);
|
||||||
} else {
|
} else {
|
||||||
assert(DispSpec.isExpr() && "non-immediate displacement for LEA?");
|
assert(DispSpec.isExpr() && "non-immediate displacement for LEA?");
|
||||||
O << *DispSpec.getExpr();
|
DispSpec.getExpr()->print(O, &MAI);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IndexReg.getReg() || BaseReg.getReg()) {
|
if (IndexReg.getReg() || BaseReg.getReg()) {
|
||||||
|
@ -273,7 +275,7 @@ void X86ATTInstPrinter::printMemOffset(const MCInst *MI, unsigned Op,
|
||||||
O << formatImm(DispSpec.getImm());
|
O << formatImm(DispSpec.getImm());
|
||||||
} else {
|
} else {
|
||||||
assert(DispSpec.isExpr() && "non-immediate displacement?");
|
assert(DispSpec.isExpr() && "non-immediate displacement?");
|
||||||
O << *DispSpec.getExpr();
|
DispSpec.getExpr()->print(O, &MAI);
|
||||||
}
|
}
|
||||||
|
|
||||||
O << markup(">");
|
O << markup(">");
|
||||||
|
|
|
@ -136,7 +136,7 @@ void X86IntelInstPrinter::printPCRelImm(const MCInst *MI, unsigned OpNo,
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Otherwise, just print the expression.
|
// Otherwise, just print the expression.
|
||||||
O << *Op.getExpr();
|
Op.getExpr()->print(O, &MAI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ void X86IntelInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||||
O << formatImm((int64_t)Op.getImm());
|
O << formatImm((int64_t)Op.getImm());
|
||||||
} else {
|
} else {
|
||||||
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
||||||
O << *Op.getExpr();
|
Op.getExpr()->print(O, &MAI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@ void X86IntelInstPrinter::printMemReference(const MCInst *MI, unsigned Op,
|
||||||
if (!DispSpec.isImm()) {
|
if (!DispSpec.isImm()) {
|
||||||
if (NeedPlus) O << " + ";
|
if (NeedPlus) O << " + ";
|
||||||
assert(DispSpec.isExpr() && "non-immediate displacement for LEA?");
|
assert(DispSpec.isExpr() && "non-immediate displacement for LEA?");
|
||||||
O << *DispSpec.getExpr();
|
DispSpec.getExpr()->print(O, &MAI);
|
||||||
} else {
|
} else {
|
||||||
int64_t DispVal = DispSpec.getImm();
|
int64_t DispVal = DispSpec.getImm();
|
||||||
if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg())) {
|
if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg())) {
|
||||||
|
@ -245,7 +245,7 @@ void X86IntelInstPrinter::printMemOffset(const MCInst *MI, unsigned Op,
|
||||||
O << formatImm(DispSpec.getImm());
|
O << formatImm(DispSpec.getImm());
|
||||||
} else {
|
} else {
|
||||||
assert(DispSpec.isExpr() && "non-immediate displacement?");
|
assert(DispSpec.isExpr() && "non-immediate displacement?");
|
||||||
O << *DispSpec.getExpr();
|
DispSpec.getExpr()->print(O, &MAI);
|
||||||
}
|
}
|
||||||
|
|
||||||
O << ']';
|
O << ']';
|
||||||
|
|
|
@ -78,7 +78,7 @@ static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO,
|
||||||
switch (MO.getType()) {
|
switch (MO.getType()) {
|
||||||
default: llvm_unreachable("unknown symbol type!");
|
default: llvm_unreachable("unknown symbol type!");
|
||||||
case MachineOperand::MO_ConstantPoolIndex:
|
case MachineOperand::MO_ConstantPoolIndex:
|
||||||
O << *P.GetCPISymbol(MO.getIndex());
|
P.GetCPISymbol(MO.getIndex())->print(O, P.MAI);
|
||||||
P.printOffset(MO.getOffset(), O);
|
P.printOffset(MO.getOffset(), O);
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_GlobalAddress: {
|
case MachineOperand::MO_GlobalAddress: {
|
||||||
|
@ -127,9 +127,12 @@ static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO,
|
||||||
// If the name begins with a dollar-sign, enclose it in parens. We do this
|
// If the name begins with a dollar-sign, enclose it in parens. We do this
|
||||||
// to avoid having it look like an integer immediate to the assembler.
|
// to avoid having it look like an integer immediate to the assembler.
|
||||||
if (GVSym->getName()[0] != '$')
|
if (GVSym->getName()[0] != '$')
|
||||||
O << *GVSym;
|
GVSym->print(O, P.MAI);
|
||||||
else
|
else {
|
||||||
O << '(' << *GVSym << ')';
|
O << '(';
|
||||||
|
GVSym->print(O, P.MAI);
|
||||||
|
O << ')';
|
||||||
|
}
|
||||||
P.printOffset(MO.getOffset(), O);
|
P.printOffset(MO.getOffset(), O);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -146,12 +149,15 @@ static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO,
|
||||||
// These affect the name of the symbol, not any suffix.
|
// These affect the name of the symbol, not any suffix.
|
||||||
break;
|
break;
|
||||||
case X86II::MO_GOT_ABSOLUTE_ADDRESS:
|
case X86II::MO_GOT_ABSOLUTE_ADDRESS:
|
||||||
O << " + [.-" << *P.MF->getPICBaseSymbol() << ']';
|
O << " + [.-";
|
||||||
|
P.MF->getPICBaseSymbol()->print(O, P.MAI);
|
||||||
|
O << ']';
|
||||||
break;
|
break;
|
||||||
case X86II::MO_PIC_BASE_OFFSET:
|
case X86II::MO_PIC_BASE_OFFSET:
|
||||||
case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
|
case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
|
||||||
case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE:
|
case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE:
|
||||||
O << '-' << *P.MF->getPICBaseSymbol();
|
O << '-';
|
||||||
|
P.MF->getPICBaseSymbol()->print(O, P.MAI);
|
||||||
break;
|
break;
|
||||||
case X86II::MO_TLSGD: O << "@TLSGD"; break;
|
case X86II::MO_TLSGD: O << "@TLSGD"; break;
|
||||||
case X86II::MO_TLSLD: O << "@TLSLD"; break;
|
case X86II::MO_TLSLD: O << "@TLSLD"; break;
|
||||||
|
@ -168,7 +174,8 @@ static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO,
|
||||||
case X86II::MO_PLT: O << "@PLT"; break;
|
case X86II::MO_PLT: O << "@PLT"; break;
|
||||||
case X86II::MO_TLVP: O << "@TLVP"; break;
|
case X86II::MO_TLVP: O << "@TLVP"; break;
|
||||||
case X86II::MO_TLVP_PIC_BASE:
|
case X86II::MO_TLVP_PIC_BASE:
|
||||||
O << "@TLVP" << '-' << *P.MF->getPICBaseSymbol();
|
O << "@TLVP" << '-';
|
||||||
|
P.MF->getPICBaseSymbol()->print(O, P.MAI);
|
||||||
break;
|
break;
|
||||||
case X86II::MO_SECREL: O << "@SECREL32"; break;
|
case X86II::MO_SECREL: O << "@SECREL32"; break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,8 @@ printInlineJT32(const MCInst *MI, int opNum, raw_ostream &O) {
|
||||||
report_fatal_error("can't handle InlineJT32");
|
report_fatal_error("can't handle InlineJT32");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void printExpr(const MCExpr *Expr, raw_ostream &OS) {
|
static void printExpr(const MCExpr *Expr, const MCAsmInfo *MAI,
|
||||||
|
raw_ostream &OS) {
|
||||||
int Offset = 0;
|
int Offset = 0;
|
||||||
const MCSymbolRefExpr *SRE;
|
const MCSymbolRefExpr *SRE;
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ static void printExpr(const MCExpr *Expr, raw_ostream &OS) {
|
||||||
}
|
}
|
||||||
assert(SRE->getKind() == MCSymbolRefExpr::VK_None);
|
assert(SRE->getKind() == MCSymbolRefExpr::VK_None);
|
||||||
|
|
||||||
OS << SRE->getSymbol();
|
SRE->getSymbol().print(OS, MAI);
|
||||||
|
|
||||||
if (Offset) {
|
if (Offset) {
|
||||||
if (Offset > 0)
|
if (Offset > 0)
|
||||||
|
@ -83,5 +84,5 @@ printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
||||||
printExpr(Op.getExpr(), O);
|
printExpr(Op.getExpr(), &MAI, O);
|
||||||
}
|
}
|
||||||
|
|
|
@ -202,7 +202,7 @@ printInlineJT(const MachineInstr *MI, int opNum, raw_ostream &O,
|
||||||
MachineBasicBlock *MBB = JTBBs[i];
|
MachineBasicBlock *MBB = JTBBs[i];
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
O << ",";
|
O << ",";
|
||||||
O << *MBB->getSymbol();
|
MBB->getSymbol()->print(O, MAI);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,17 +218,17 @@ void XCoreAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
|
||||||
O << MO.getImm();
|
O << MO.getImm();
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_MachineBasicBlock:
|
case MachineOperand::MO_MachineBasicBlock:
|
||||||
O << *MO.getMBB()->getSymbol();
|
MO.getMBB()->getSymbol()->print(O, MAI);
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_GlobalAddress:
|
case MachineOperand::MO_GlobalAddress:
|
||||||
O << *getSymbol(MO.getGlobal());
|
getSymbol(MO.getGlobal())->print(O, MAI);
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_ConstantPoolIndex:
|
case MachineOperand::MO_ConstantPoolIndex:
|
||||||
O << DL->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
|
O << DL->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
|
||||||
<< '_' << MO.getIndex();
|
<< '_' << MO.getIndex();
|
||||||
break;
|
break;
|
||||||
case MachineOperand::MO_BlockAddress:
|
case MachineOperand::MO_BlockAddress:
|
||||||
O << *GetBlockAddressSymbol(MO.getBlockAddress());
|
GetBlockAddressSymbol(MO.getBlockAddress())->print(O, MAI);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
llvm_unreachable("not implemented");
|
llvm_unreachable("not implemented");
|
||||||
|
|
Loading…
Reference in New Issue