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.
|
||||
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
|
||||
/// ".data_region/.end_data_region" directives. If false, use "$d/$a" labels
|
||||
/// instead.
|
||||
|
@ -406,6 +410,10 @@ public:
|
|||
unsigned Encoding,
|
||||
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 {
|
||||
return SunStyleELFSectionSwitchSyntax;
|
||||
}
|
||||
|
@ -456,6 +464,7 @@ public:
|
|||
const char *getCode64Directive() const { return Code64Directive; }
|
||||
unsigned getAssemblerDialect() const { return AssemblerDialect; }
|
||||
bool doesAllowAtInName() const { return AllowAtInName; }
|
||||
bool supportsNameQuoting() const { return SupportsQuotedNames; }
|
||||
bool doesSupportDataRegionDirectives() const {
|
||||
return UseDataRegionDirectives;
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public:
|
|||
/// \name Utility Methods
|
||||
/// @{
|
||||
|
||||
void print(raw_ostream &OS) const;
|
||||
void print(raw_ostream &OS, const MCAsmInfo *MAI) const;
|
||||
void dump() const;
|
||||
|
||||
/// @}
|
||||
|
@ -121,7 +121,7 @@ public:
|
|||
};
|
||||
|
||||
inline raw_ostream &operator<<(raw_ostream &OS, const MCExpr &E) {
|
||||
E.print(OS);
|
||||
E.print(OS, nullptr);
|
||||
return OS;
|
||||
}
|
||||
|
||||
|
@ -551,8 +551,7 @@ protected:
|
|||
MCTargetExpr() : MCExpr(Target) {}
|
||||
virtual ~MCTargetExpr() {}
|
||||
public:
|
||||
|
||||
virtual void printImpl(raw_ostream &OS) const = 0;
|
||||
virtual void printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const = 0;
|
||||
virtual bool evaluateAsRelocatableImpl(MCValue &Res,
|
||||
const MCAsmLayout *Layout,
|
||||
const MCFixup *Fixup) const = 0;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "llvm/Support/Compiler.h"
|
||||
|
||||
namespace llvm {
|
||||
class MCAsmInfo;
|
||||
class MCExpr;
|
||||
class MCSymbol;
|
||||
class MCFragment;
|
||||
|
@ -302,7 +303,7 @@ public:
|
|||
void setPrivateExtern(bool Value) { IsPrivateExtern = Value; }
|
||||
|
||||
/// 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.
|
||||
void dump() const;
|
||||
|
@ -321,7 +322,7 @@ protected:
|
|||
};
|
||||
|
||||
inline raw_ostream &operator<<(raw_ostream &OS, const MCSymbol &Sym) {
|
||||
Sym.print(OS);
|
||||
Sym.print(OS, nullptr);
|
||||
return OS;
|
||||
}
|
||||
} // end namespace llvm
|
||||
|
|
|
@ -402,10 +402,11 @@ static void EmitGCCInlineAsmStr(const char *AsmStr, const MachineInstr *MI,
|
|||
unsigned OpFlags = MI->getOperand(OpNo).getImm();
|
||||
++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?
|
||||
OS << *MI->getOperand(OpNo).getMBB()->getSymbol();
|
||||
else {
|
||||
const MCSymbol *Sym = MI->getOperand(OpNo).getMBB()->getSymbol();
|
||||
Sym->print(OS, AP->MAI);
|
||||
} else {
|
||||
if (InlineAsm::isMemKind(OpFlags)) {
|
||||
Error = AP->PrintAsmMemoryOperand(MI, OpNo, InlineAsmVariant,
|
||||
Modifier[0] ? Modifier : nullptr,
|
||||
|
|
|
@ -50,6 +50,7 @@ MCAsmInfo::MCAsmInfo() {
|
|||
Code64Directive = ".code64";
|
||||
AssemblerDialect = 0;
|
||||
AllowAtInName = false;
|
||||
SupportsQuotedNames = true;
|
||||
UseDataRegionDirectives = false;
|
||||
ZeroDirective = "\t.zero\t";
|
||||
AsciiDirective = "\t.ascii\t";
|
||||
|
@ -137,3 +138,22 @@ MCAsmInfo::getExprForFDESymbol(const MCSymbol *Sym,
|
|||
const MCExpr *PC = MCSymbolRefExpr::create(PCSym, 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!");
|
||||
MCStreamer::EmitLabel(Symbol);
|
||||
|
||||
OS << *Symbol << MAI->getLabelSuffix();
|
||||
Symbol->print(OS, MAI);
|
||||
OS << MAI->getLabelSuffix();
|
||||
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
|
@ -328,7 +330,7 @@ void MCAsmStreamer::EmitLOHDirective(MCLOHType Kind, const MCLOHArgs &Args) {
|
|||
if (!IsFirst)
|
||||
OS << ", ";
|
||||
IsFirst = false;
|
||||
OS << **It;
|
||||
(*It)->print(OS, MAI);
|
||||
}
|
||||
EmitEOL();
|
||||
}
|
||||
|
@ -384,20 +386,28 @@ void MCAsmStreamer::EmitThumbFunc(MCSymbol *Func) {
|
|||
// MCSymbols when they have spaces in them.
|
||||
OS << "\t.thumb_func";
|
||||
// Only Mach-O hasSubsectionsViaSymbols()
|
||||
if (MAI->hasSubsectionsViaSymbols())
|
||||
OS << '\t' << *Func;
|
||||
if (MAI->hasSubsectionsViaSymbols()) {
|
||||
OS << '\t';
|
||||
Func->print(OS, MAI);
|
||||
}
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
void MCAsmStreamer::EmitAssignment(MCSymbol *Symbol, const MCExpr *Value) {
|
||||
OS << *Symbol << " = " << *Value;
|
||||
Symbol->print(OS, MAI);
|
||||
OS << " = ";
|
||||
Value->print(OS, MAI);
|
||||
|
||||
EmitEOL();
|
||||
|
||||
MCStreamer::EmitAssignment(Symbol, Value);
|
||||
}
|
||||
|
||||
void MCAsmStreamer::EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {
|
||||
OS << ".weakref " << *Alias << ", " << *Symbol;
|
||||
OS << ".weakref ";
|
||||
Alias->print(OS, MAI);
|
||||
OS << ", ";
|
||||
Symbol->print(OS, MAI);
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
|
@ -414,8 +424,9 @@ bool MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
|
|||
case MCSA_ELF_TypeGnuUniqueObject: /// .type _foo, @gnu_unique_object
|
||||
if (!MAI->hasDotTypeDotSizeDirective())
|
||||
return false; // Symbol attribute not supported
|
||||
OS << "\t.type\t" << *Symbol << ','
|
||||
<< ((MAI->getCommentString()[0] != '@') ? '@' : '%');
|
||||
OS << "\t.type\t";
|
||||
Symbol->print(OS, MAI);
|
||||
OS << ',' << ((MAI->getCommentString()[0] != '@') ? '@' : '%');
|
||||
switch (Attribute) {
|
||||
default: return false;
|
||||
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;
|
||||
}
|
||||
|
||||
OS << *Symbol;
|
||||
Symbol->print(OS, MAI);
|
||||
EmitEOL();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void MCAsmStreamer::EmitSymbolDesc(MCSymbol *Symbol, unsigned DescValue) {
|
||||
OS << ".desc" << ' ' << *Symbol << ',' << DescValue;
|
||||
OS << ".desc" << ' ';
|
||||
Symbol->print(OS, MAI);
|
||||
OS << ',' << DescValue;
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
void MCAsmStreamer::BeginCOFFSymbolDef(const MCSymbol *Symbol) {
|
||||
OS << "\t.def\t " << *Symbol << ';';
|
||||
OS << "\t.def\t ";
|
||||
Symbol->print(OS, MAI);
|
||||
OS << ';';
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
|
@ -493,18 +508,24 @@ void MCAsmStreamer::EmitCOFFSafeSEH(MCSymbol const *Symbol) {
|
|||
}
|
||||
|
||||
void MCAsmStreamer::EmitCOFFSectionIndex(MCSymbol const *Symbol) {
|
||||
OS << "\t.secidx\t" << *Symbol;
|
||||
OS << "\t.secidx\t";
|
||||
Symbol->print(OS, MAI);
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
void MCAsmStreamer::EmitCOFFSecRel32(MCSymbol const *Symbol) {
|
||||
OS << "\t.secrel32\t" << *Symbol;
|
||||
OS << "\t.secrel32\t";
|
||||
Symbol->print(OS, MAI);
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
void MCAsmStreamer::emitELFSize(MCSymbolELF *Symbol, const MCExpr *Value) {
|
||||
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,
|
||||
|
@ -512,7 +533,10 @@ void MCAsmStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
|||
// Common symbols do not belong to any actual section.
|
||||
AssignSection(Symbol, nullptr);
|
||||
|
||||
OS << "\t.comm\t" << *Symbol << ',' << Size;
|
||||
OS << "\t.comm\t";
|
||||
Symbol->print(OS, MAI);
|
||||
OS << ',' << Size;
|
||||
|
||||
if (ByteAlignment != 0) {
|
||||
if (MAI->getCOMMDirectiveAlignmentIsInBytes())
|
||||
OS << ',' << ByteAlignment;
|
||||
|
@ -531,7 +555,10 @@ void MCAsmStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
|
|||
// Common symbols do not belong to any actual section.
|
||||
AssignSection(Symbol, nullptr);
|
||||
|
||||
OS << "\t.lcomm\t" << *Symbol << ',' << Size;
|
||||
OS << "\t.lcomm\t";
|
||||
Symbol->print(OS, MAI);
|
||||
OS << ',' << Size;
|
||||
|
||||
if (ByteAlign > 1) {
|
||||
switch (MAI->getLCOMMDirectiveAlignmentType()) {
|
||||
case LCOMM::NoAlignment:
|
||||
|
@ -561,7 +588,9 @@ void MCAsmStreamer::EmitZerofill(MCSection *Section, MCSymbol *Symbol,
|
|||
OS << MOSection->getSegmentName() << "," << MOSection->getSectionName();
|
||||
|
||||
if (Symbol) {
|
||||
OS << ',' << *Symbol << ',' << Size;
|
||||
OS << ',';
|
||||
Symbol->print(OS, MAI);
|
||||
OS << ',' << Size;
|
||||
if (ByteAlignment != 0)
|
||||
OS << ',' << Log2_32(ByteAlignment);
|
||||
}
|
||||
|
@ -578,7 +607,9 @@ void MCAsmStreamer::EmitTBSSSymbol(MCSection *Section, MCSymbol *Symbol,
|
|||
assert(Symbol && "Symbol shouldn't be NULL!");
|
||||
// Instead of using the Section we'll just use the shortcut.
|
||||
// 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
|
||||
// that.
|
||||
|
@ -703,7 +734,8 @@ void MCAsmStreamer::EmitValueImpl(const MCExpr *Value, unsigned Size,
|
|||
}
|
||||
|
||||
assert(Directive && "Invalid size for machine code value!");
|
||||
OS << Directive << *Value;
|
||||
OS << Directive;
|
||||
Value->print(OS, MAI);
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
|
@ -713,7 +745,8 @@ void MCAsmStreamer::EmitULEB128Value(const MCExpr *Value) {
|
|||
EmitULEB128IntValue(IntValue);
|
||||
return;
|
||||
}
|
||||
OS << ".uleb128 " << *Value;
|
||||
OS << ".uleb128 ";
|
||||
Value->print(OS, MAI);
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
|
@ -723,19 +756,22 @@ void MCAsmStreamer::EmitSLEB128Value(const MCExpr *Value) {
|
|||
EmitSLEB128IntValue(IntValue);
|
||||
return;
|
||||
}
|
||||
OS << ".sleb128 " << *Value;
|
||||
OS << ".sleb128 ";
|
||||
Value->print(OS, MAI);
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
void MCAsmStreamer::EmitGPRel64Value(const MCExpr *Value) {
|
||||
assert(MAI->getGPRel64Directive() != nullptr);
|
||||
OS << MAI->getGPRel64Directive() << *Value;
|
||||
OS << MAI->getGPRel64Directive();
|
||||
Value->print(OS, MAI);
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
void MCAsmStreamer::EmitGPRel32Value(const MCExpr *Value) {
|
||||
assert(MAI->getGPRel32Directive() != nullptr);
|
||||
OS << MAI->getGPRel32Directive() << *Value;
|
||||
OS << MAI->getGPRel32Directive();
|
||||
Value->print(OS, MAI);
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
|
@ -822,7 +858,9 @@ void MCAsmStreamer::EmitCodeAlignment(unsigned ByteAlignment,
|
|||
bool MCAsmStreamer::EmitValueToOffset(const MCExpr *Offset,
|
||||
unsigned char Value) {
|
||||
// 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();
|
||||
return false;
|
||||
}
|
||||
|
@ -993,13 +1031,15 @@ void MCAsmStreamer::EmitCFIOffset(int64_t Register, int64_t Offset) {
|
|||
void MCAsmStreamer::EmitCFIPersonality(const MCSymbol *Sym,
|
||||
unsigned Encoding) {
|
||||
MCStreamer::EmitCFIPersonality(Sym, Encoding);
|
||||
OS << "\t.cfi_personality " << Encoding << ", " << *Sym;
|
||||
OS << "\t.cfi_personality " << Encoding << ", ";
|
||||
Sym->print(OS, MAI);
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
void MCAsmStreamer::EmitCFILsda(const MCSymbol *Sym, unsigned Encoding) {
|
||||
MCStreamer::EmitCFILsda(Sym, Encoding);
|
||||
OS << "\t.cfi_lsda " << Encoding << ", " << *Sym;
|
||||
OS << "\t.cfi_lsda " << Encoding << ", ";
|
||||
Sym->print(OS, MAI);
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
|
@ -1063,7 +1103,8 @@ void MCAsmStreamer::EmitCFIWindowSave() {
|
|||
void MCAsmStreamer::EmitWinCFIStartProc(const MCSymbol *Symbol) {
|
||||
MCStreamer::EmitWinCFIStartProc(Symbol);
|
||||
|
||||
OS << ".seh_proc " << *Symbol;
|
||||
OS << ".seh_proc ";
|
||||
Symbol->print(OS, MAI);
|
||||
EmitEOL();
|
||||
}
|
||||
|
||||
|
@ -1092,7 +1133,8 @@ void MCAsmStreamer::EmitWinEHHandler(const MCSymbol *Sym, bool Unwind,
|
|||
bool Except) {
|
||||
MCStreamer::EmitWinEHHandler(Sym, Unwind, Except);
|
||||
|
||||
OS << "\t.seh_handler " << *Sym;
|
||||
OS << "\t.seh_handler ";
|
||||
Sym->print(OS, MAI);
|
||||
if (Unwind)
|
||||
OS << ", @unwind";
|
||||
if (Except)
|
||||
|
|
|
@ -1199,8 +1199,7 @@ void MCFragment::dump() {
|
|||
case MCFragment::FT_SafeSEH: {
|
||||
const MCSafeSEHFragment *F = cast<MCSafeSEHFragment>(this);
|
||||
OS << "\n ";
|
||||
OS << " Sym:";
|
||||
F->getSymbol()->print(OS);
|
||||
OS << " Sym:" << F->getSymbol();
|
||||
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()) {
|
||||
case MCExpr::Target:
|
||||
return cast<MCTargetExpr>(this)->printImpl(OS);
|
||||
return cast<MCTargetExpr>(this)->printImpl(OS, MAI);
|
||||
case MCExpr::Constant:
|
||||
OS << cast<MCConstantExpr>(*this).getValue();
|
||||
return;
|
||||
|
@ -43,11 +43,13 @@ void MCExpr::print(raw_ostream &OS) const {
|
|||
const MCSymbol &Sym = SRE.getSymbol();
|
||||
// Parenthesize names that start with $ so that they don't look like
|
||||
// absolute names.
|
||||
bool UseParens = !Sym.getName().empty() && Sym.getName()[0] == '$';
|
||||
if (UseParens)
|
||||
OS << '(' << Sym << ')';
|
||||
else
|
||||
OS << Sym;
|
||||
bool UseParens = Sym.getName()[0] == '$';
|
||||
if (UseParens) {
|
||||
OS << '(';
|
||||
Sym.print(OS, MAI);
|
||||
OS << ')';
|
||||
} else
|
||||
Sym.print(OS, MAI);
|
||||
|
||||
if (SRE.getKind() != MCSymbolRefExpr::VK_None)
|
||||
SRE.printVariantKind(OS);
|
||||
|
@ -63,7 +65,7 @@ void MCExpr::print(raw_ostream &OS) const {
|
|||
case MCUnaryExpr::Not: OS << '~'; break;
|
||||
case MCUnaryExpr::Plus: OS << '+'; break;
|
||||
}
|
||||
OS << *UE.getSubExpr();
|
||||
UE.getSubExpr()->print(OS, MAI);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -72,9 +74,11 @@ void MCExpr::print(raw_ostream &OS) const {
|
|||
|
||||
// Only print parens around the LHS if it is non-trivial.
|
||||
if (isa<MCConstantExpr>(BE.getLHS()) || isa<MCSymbolRefExpr>(BE.getLHS())) {
|
||||
OS << *BE.getLHS();
|
||||
BE.getLHS()->print(OS, MAI);
|
||||
} else {
|
||||
OS << '(' << *BE.getLHS() << ')';
|
||||
OS << '(';
|
||||
BE.getLHS()->print(OS, MAI);
|
||||
OS << ')';
|
||||
}
|
||||
|
||||
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.
|
||||
if (isa<MCConstantExpr>(BE.getRHS()) || isa<MCSymbolRefExpr>(BE.getRHS())) {
|
||||
OS << *BE.getRHS();
|
||||
BE.getRHS()->print(OS, MAI);
|
||||
} else {
|
||||
OS << '(' << *BE.getRHS() << ')';
|
||||
OS << '(';
|
||||
BE.getRHS()->print(OS, MAI);
|
||||
OS << ')';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -94,7 +94,7 @@ void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI,
|
|||
break;
|
||||
}
|
||||
assert(COMDATSymbol);
|
||||
OS << *COMDATSymbol;
|
||||
COMDATSymbol->print(OS, &MAI);
|
||||
}
|
||||
OS << '\n';
|
||||
}
|
||||
|
|
|
@ -64,8 +64,10 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI,
|
|||
|
||||
if (ShouldOmitSectionDirective(SectionName, MAI)) {
|
||||
OS << '\t' << getSectionName();
|
||||
if (Subsection)
|
||||
OS << '\t' << *Subsection;
|
||||
if (Subsection) {
|
||||
OS << '\t';
|
||||
Subsection->print(OS, &MAI);
|
||||
}
|
||||
OS << '\n';
|
||||
return;
|
||||
}
|
||||
|
@ -153,8 +155,11 @@ void MCSectionELF::PrintSwitchToSection(const MCAsmInfo &MAI,
|
|||
|
||||
OS << '\n';
|
||||
|
||||
if (Subsection)
|
||||
OS << "\t.subsection\t" << *Subsection << '\n';
|
||||
if (Subsection) {
|
||||
OS << "\t.subsection\t";
|
||||
Subsection->print(OS, &MAI);
|
||||
OS << '\n';
|
||||
}
|
||||
}
|
||||
|
||||
bool MCSectionELF::UseCodeAlign() const {
|
||||
|
|
|
@ -8,36 +8,16 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/MC/MCSymbol.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
using namespace llvm;
|
||||
|
||||
// Sentinel value for the absolute pseudo section.
|
||||
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) {
|
||||
assert(!IsUsed && "Cannot set a variable that has already been used.");
|
||||
assert(Value && "Invalid variable value!");
|
||||
|
@ -45,23 +25,21 @@ void MCSymbol::setVariableValue(const MCExpr *Value) {
|
|||
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,
|
||||
// some targets support quoting names with funny characters. If the name
|
||||
// contains a funny character, then print it quoted.
|
||||
StringRef Name = getName();
|
||||
if (Name.empty()) {
|
||||
OS << "\"\"";
|
||||
return;
|
||||
}
|
||||
if (!NameNeedsQuoting(Name)) {
|
||||
if (!MAI || MAI->isValidUnquotedName(Name)) {
|
||||
OS << Name;
|
||||
return;
|
||||
}
|
||||
|
||||
if (MAI && !MAI->supportsNameQuoting())
|
||||
report_fatal_error("Symbol name with unsupported characters");
|
||||
|
||||
OS << '"';
|
||||
for (unsigned I = 0, E = Name.size(); I != E; ++I) {
|
||||
char C = Name[I];
|
||||
for (char C : Name) {
|
||||
if (C == '\n')
|
||||
OS << "\\n";
|
||||
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?
|
||||
assert(!MO.getTargetFlags() && "Unknown operand target flag!");
|
||||
|
||||
O << *Sym;
|
||||
Sym->print(O, MAI);
|
||||
printOffset(MO.getOffset(), O);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -206,15 +206,15 @@ void AArch64InstPrinter::printInst(const MCInst *MI, raw_ostream &O,
|
|||
else
|
||||
O << "\tmovn\t";
|
||||
|
||||
O << getRegisterName(MI->getOperand(0).getReg()) << ", #"
|
||||
<< *MI->getOperand(1).getExpr();
|
||||
O << getRegisterName(MI->getOperand(0).getReg()) << ", #";
|
||||
MI->getOperand(1).getExpr()->print(O, &MAI);
|
||||
return;
|
||||
}
|
||||
|
||||
if ((Opcode == AArch64::MOVKXi || Opcode == AArch64::MOVKWi) &&
|
||||
MI->getOperand(2).isExpr()) {
|
||||
O << "\tmovk\t" << getRegisterName(MI->getOperand(0).getReg()) << ", #"
|
||||
<< *MI->getOperand(2).getExpr();
|
||||
O << "\tmovk\t" << getRegisterName(MI->getOperand(0).getReg()) << ", #";
|
||||
MI->getOperand(2).getExpr()->print(O, &MAI);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -908,7 +908,7 @@ void AArch64InstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
|||
O << '#' << Op.getImm();
|
||||
} else {
|
||||
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';
|
||||
} else {
|
||||
assert(MO.isExpr() && "Unexpected operand type!");
|
||||
O << *MO.getExpr();
|
||||
MO.getExpr()->print(O, &MAI);
|
||||
printShifter(MI, OpNum + 1, STI, O);
|
||||
}
|
||||
}
|
||||
|
@ -1091,7 +1091,7 @@ void AArch64InstPrinter::printUImm12Offset(const MCInst *MI, unsigned OpNum,
|
|||
O << "#" << (MO.getImm() * Scale);
|
||||
} else {
|
||||
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);
|
||||
} else {
|
||||
assert(MO1.isExpr() && "Unexpected operand type!");
|
||||
O << ", " << *MO1.getExpr();
|
||||
O << ", ";
|
||||
MO1.getExpr()->print(O, &MAI);
|
||||
}
|
||||
O << ']';
|
||||
}
|
||||
|
@ -1286,7 +1287,7 @@ void AArch64InstPrinter::printAlignedLabel(const MCInst *MI, unsigned OpNum,
|
|||
O.write_hex(Address);
|
||||
} else {
|
||||
// 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.
|
||||
O << *MI->getOperand(OpNum).getExpr();
|
||||
MI->getOperand(OpNum).getExpr()->print(O, &MAI);
|
||||
}
|
||||
|
||||
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)
|
||||
OS << getVariantKindName();
|
||||
OS << *Expr;
|
||||
Expr->print(OS, MAI);
|
||||
}
|
||||
|
||||
void AArch64MCExpr::visitUsedExpr(MCStreamer &Streamer) const {
|
||||
|
|
|
@ -145,7 +145,7 @@ public:
|
|||
/// (e.g. ":got:", ":lo12:").
|
||||
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;
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
|||
break;
|
||||
}
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *MO.getMBB()->getSymbol();
|
||||
MO.getMBB()->getSymbol()->print(O, MAI);
|
||||
return;
|
||||
case MachineOperand::MO_GlobalAddress: {
|
||||
const GlobalValue *GV = MO.getGlobal();
|
||||
|
@ -181,7 +181,7 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
|||
O << ":lower16:";
|
||||
else if (TF & ARMII::MO_HI16)
|
||||
O << ":upper16:";
|
||||
O << *GetARMGVSymbol(GV, TF);
|
||||
GetARMGVSymbol(GV, TF)->print(O, MAI);
|
||||
|
||||
printOffset(MO.getOffset(), O);
|
||||
if (TF == ARMII::MO_PLT)
|
||||
|
@ -189,7 +189,7 @@ void ARMAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
|||
break;
|
||||
}
|
||||
case MachineOperand::MO_ConstantPoolIndex:
|
||||
O << *GetCPISymbol(MO.getIndex());
|
||||
GetCPISymbol(MO.getIndex())->print(O, MAI);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -329,7 +329,8 @@ void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
|||
const MCExpr *Expr = Op.getExpr();
|
||||
switch (Expr->getKind()) {
|
||||
case MCExpr::Binary:
|
||||
O << '#' << *Expr;
|
||||
O << '#';
|
||||
Expr->print(O, &MAI);
|
||||
break;
|
||||
case MCExpr::Constant: {
|
||||
// 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);
|
||||
int64_t TargetAddress;
|
||||
if (!Constant->evaluateAsAbsolute(TargetAddress)) {
|
||||
O << '#' << *Expr;
|
||||
O << '#';
|
||||
Expr->print(O, &MAI);
|
||||
} else {
|
||||
O << "0x";
|
||||
O.write_hex(static_cast<uint32_t>(TargetAddress));
|
||||
|
@ -348,7 +350,7 @@ void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
|||
default:
|
||||
// FIXME: Should we always treat this as if it is a constant literal and
|
||||
// prefix it with '#'?
|
||||
O << *Expr;
|
||||
Expr->print(O, &MAI);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -359,7 +361,7 @@ void ARMInstPrinter::printThumbLdrLabelOperand(const MCInst *MI, unsigned OpNum,
|
|||
raw_ostream &O) {
|
||||
const MCOperand &MO1 = MI->getOperand(OpNum);
|
||||
if (MO1.isExpr()) {
|
||||
O << *MO1.getExpr();
|
||||
MO1.getExpr()->print(O, &MAI);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1055,7 +1057,7 @@ void ARMInstPrinter::printAdrLabelOperand(const MCInst *MI, unsigned OpNum,
|
|||
const MCOperand &MO = MI->getOperand(OpNum);
|
||||
|
||||
if (MO.isExpr()) {
|
||||
O << *MO.getExpr();
|
||||
MO.getExpr()->print(O, &MAI);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -214,7 +214,13 @@ ARMTargetAsmStreamer::AnnotateTLSDescriptorSequence(const MCSymbolRefExpr *S) {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -21,7 +21,7 @@ ARMMCExpr::create(VariantKind Kind, const MCExpr *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) {
|
||||
default: llvm_unreachable("Invalid kind!");
|
||||
case VK_ARM_HI16: OS << ":upper16:"; break;
|
||||
|
@ -31,7 +31,7 @@ void ARMMCExpr::printImpl(raw_ostream &OS) const {
|
|||
const MCExpr *Expr = getSubExpr();
|
||||
if (Expr->getKind() != MCExpr::SymbolRef)
|
||||
OS << '(';
|
||||
Expr->print(OS);
|
||||
Expr->print(OS, MAI);
|
||||
if (Expr->getKind() != MCExpr::SymbolRef)
|
||||
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,
|
||||
const MCAsmLayout *Layout,
|
||||
const MCFixup *Fixup) const override {
|
||||
|
|
|
@ -79,14 +79,14 @@ void HexagonAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo,
|
|||
O << MO.getImm();
|
||||
return;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *MO.getMBB()->getSymbol();
|
||||
MO.getMBB()->getSymbol()->print(O, MAI);
|
||||
return;
|
||||
case MachineOperand::MO_ConstantPoolIndex:
|
||||
O << *GetCPISymbol(MO.getIndex());
|
||||
GetCPISymbol(MO.getIndex())->print(O, MAI);
|
||||
return;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
// Computing the address of a global symbol, not calling it.
|
||||
O << *getSymbol(MO.getGlobal());
|
||||
getSymbol(MO.getGlobal())->print(O, MAI);
|
||||
printOffset(MO.getOffset(), O);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -164,7 +164,7 @@ void HexagonInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
|||
if (MO.isReg()) {
|
||||
printRegName(O, MO.getReg());
|
||||
} else if(MO.isExpr()) {
|
||||
O << *MO.getExpr();
|
||||
MO.getExpr()->print(O, &MAI);
|
||||
} else if(MO.isImm()) {
|
||||
printImmOperand(MI, OpNo, O);
|
||||
} else {
|
||||
|
@ -177,7 +177,7 @@ void HexagonInstPrinter::printImmOperand(const MCInst *MI, unsigned OpNo,
|
|||
const MCOperand& MO = MI->getOperand(OpNo);
|
||||
|
||||
if(MO.isExpr()) {
|
||||
O << *MO.getExpr();
|
||||
MO.getExpr()->print(O, &MAI);
|
||||
} else if(MO.isImm()) {
|
||||
O << MI->getOperand(OpNo).getImm();
|
||||
} else {
|
||||
|
|
|
@ -39,7 +39,7 @@ void MSP430InstPrinter::printPCRelImmOperand(const MCInst *MI, unsigned OpNo,
|
|||
O << Op.getImm();
|
||||
else {
|
||||
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();
|
||||
} else {
|
||||
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 << '&';
|
||||
|
||||
if (Disp.isExpr())
|
||||
O << *Disp.getExpr();
|
||||
Disp.getExpr()->print(O, &MAI);
|
||||
else {
|
||||
assert(Disp.isImm() && "Expected immediate in displacement field");
|
||||
O << Disp.getImm();
|
||||
|
|
|
@ -75,7 +75,7 @@ void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
|||
O << MO.getImm();
|
||||
return;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *MO.getMBB()->getSymbol();
|
||||
MO.getMBB()->getSymbol()->print(O, MAI);
|
||||
return;
|
||||
case MachineOperand::MO_GlobalAddress: {
|
||||
bool isMemOp = Modifier && !strcmp(Modifier, "mem");
|
||||
|
@ -92,7 +92,7 @@ void MSP430AsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
|
|||
if (Offset)
|
||||
O << '(' << Offset << '+';
|
||||
|
||||
O << *getSymbol(MO.getGlobal());
|
||||
getSymbol(MO.getGlobal())->print(O, MAI);
|
||||
|
||||
if (Offset)
|
||||
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;
|
||||
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.");
|
||||
Offset = CE->getValue();
|
||||
} else if (const MipsMCExpr *ME = dyn_cast<MipsMCExpr>(Expr)) {
|
||||
ME->print(OS);
|
||||
ME->print(OS, MAI);
|
||||
return;
|
||||
} else
|
||||
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;
|
||||
}
|
||||
|
||||
OS << SRE->getSymbol();
|
||||
SRE->getSymbol().print(OS, MAI);
|
||||
|
||||
if (Offset) {
|
||||
if (Offset > 0)
|
||||
|
@ -199,7 +200,7 @@ void MipsInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
|||
}
|
||||
|
||||
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,
|
||||
|
|
|
@ -64,7 +64,7 @@ MipsMCExpr::create(MCSymbolRefExpr::VariantKind VK, const MCExpr *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) {
|
||||
default: llvm_unreachable("Invalid kind!");
|
||||
case VK_Mips_LO: OS << "%lo"; break;
|
||||
|
@ -74,7 +74,7 @@ void MipsMCExpr::printImpl(raw_ostream &OS) const {
|
|||
}
|
||||
|
||||
OS << '(';
|
||||
Expr->print(OS);
|
||||
Expr->print(OS, MAI);
|
||||
OS << ')';
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
/// getSubExpr - Get the child of this expression.
|
||||
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,
|
||||
const MCAsmLayout *Layout,
|
||||
const MCFixup *Fixup) const override;
|
||||
|
|
|
@ -594,11 +594,11 @@ void MipsAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
|
|||
break;
|
||||
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *MO.getMBB()->getSymbol();
|
||||
MO.getMBB()->getSymbol()->print(O, MAI);
|
||||
return;
|
||||
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
O << *getSymbol(MO.getGlobal());
|
||||
getSymbol(MO.getGlobal())->print(O, MAI);
|
||||
break;
|
||||
|
||||
case MachineOperand::MO_BlockAddress: {
|
||||
|
|
|
@ -85,7 +85,7 @@ void NVPTXInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
|||
O << markup("<imm:") << formatImm(Op.getImm()) << markup(">");
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
|
||||
O << *CurrentFnSym;
|
||||
CurrentFnSym->print(O, MAI);
|
||||
|
||||
emitFunctionParamList(*MF, O);
|
||||
|
||||
|
@ -624,7 +624,8 @@ void NVPTXAsmPrinter::emitDeclaration(const Function *F, raw_ostream &O) {
|
|||
else
|
||||
O << ".func ";
|
||||
printReturnValStr(F, O);
|
||||
O << *getSymbol(F) << "\n";
|
||||
getSymbol(F)->print(O, MAI);
|
||||
O << "\n";
|
||||
emitFunctionParamList(F, O);
|
||||
O << ";\n";
|
||||
}
|
||||
|
@ -1171,7 +1172,7 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
|
|||
else
|
||||
O << getPTXFundamentalTypeStr(ETy, false);
|
||||
O << " ";
|
||||
O << *getSymbol(GVar);
|
||||
getSymbol(GVar)->print(O, MAI);
|
||||
|
||||
// Ptx allows variable initilization only for constant and global state
|
||||
// spaces.
|
||||
|
@ -1217,15 +1218,21 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
|
|||
bufferAggregateConstant(Initializer, &aggBuffer);
|
||||
if (aggBuffer.numSymbols) {
|
||||
if (static_cast<const NVPTXTargetMachine &>(TM).is64Bit()) {
|
||||
O << " .u64 " << *getSymbol(GVar) << "[";
|
||||
O << " .u64 ";
|
||||
getSymbol(GVar)->print(O, MAI);
|
||||
O << "[";
|
||||
O << ElementSize / 8;
|
||||
} else {
|
||||
O << " .u32 " << *getSymbol(GVar) << "[";
|
||||
O << " .u32 ";
|
||||
getSymbol(GVar)->print(O, MAI);
|
||||
O << "[";
|
||||
O << ElementSize / 4;
|
||||
}
|
||||
O << "]";
|
||||
} else {
|
||||
O << " .b8 " << *getSymbol(GVar) << "[";
|
||||
O << " .b8 ";
|
||||
getSymbol(GVar)->print(O, MAI);
|
||||
O << "[";
|
||||
O << ElementSize;
|
||||
O << "]";
|
||||
}
|
||||
|
@ -1233,7 +1240,8 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
|
|||
aggBuffer.print();
|
||||
O << "}";
|
||||
} else {
|
||||
O << " .b8 " << *getSymbol(GVar);
|
||||
O << " .b8 ";
|
||||
getSymbol(GVar)->print(O, MAI);
|
||||
if (ElementSize) {
|
||||
O << "[";
|
||||
O << ElementSize;
|
||||
|
@ -1241,7 +1249,8 @@ void NVPTXAsmPrinter::printModuleLevelGV(const GlobalVariable *GVar,
|
|||
}
|
||||
}
|
||||
} else {
|
||||
O << " .b8 " << *getSymbol(GVar);
|
||||
O << " .b8 ";
|
||||
getSymbol(GVar)->print(O, MAI);
|
||||
if (ElementSize) {
|
||||
O << "[";
|
||||
O << ElementSize;
|
||||
|
@ -1348,7 +1357,7 @@ void NVPTXAsmPrinter::emitPTXGlobalVariable(const GlobalVariable *GVar,
|
|||
O << " .";
|
||||
O << getPTXFundamentalTypeStr(ETy);
|
||||
O << " ";
|
||||
O << *getSymbol(GVar);
|
||||
getSymbol(GVar)->print(O, MAI);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1363,7 +1372,9 @@ void NVPTXAsmPrinter::emitPTXGlobalVariable(const GlobalVariable *GVar,
|
|||
case Type::ArrayTyID:
|
||||
case Type::VectorTyID:
|
||||
ElementSize = TD->getTypeStoreSize(ETy);
|
||||
O << " .b8 " << *getSymbol(GVar) << "[";
|
||||
O << " .b8 ";
|
||||
getSymbol(GVar)->print(O, MAI);
|
||||
O << "[";
|
||||
if (ElementSize) {
|
||||
O << ElementSize;
|
||||
}
|
||||
|
@ -1405,11 +1416,13 @@ static unsigned int getOpenCLAlignment(const DataLayout *TD, Type *Ty) {
|
|||
|
||||
void NVPTXAsmPrinter::printParamName(Function::const_arg_iterator I,
|
||||
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) {
|
||||
O << *CurrentFnSym << "_param_" << paramIndex;
|
||||
CurrentFnSym->print(O, MAI);
|
||||
O << "_param_" << paramIndex;
|
||||
}
|
||||
|
||||
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 ";
|
||||
else
|
||||
O << "\t.param .surfref ";
|
||||
O << *CurrentFnSym << "_param_" << paramIndex;
|
||||
CurrentFnSym->print(O, MAI);
|
||||
O << "_param_" << paramIndex;
|
||||
}
|
||||
else { // Default image is read_only
|
||||
if (nvptxSubtarget->hasImageHandles())
|
||||
O << "\t.param .u64 .ptr .texref ";
|
||||
else
|
||||
O << "\t.param .texref ";
|
||||
O << *CurrentFnSym << "_param_" << paramIndex;
|
||||
CurrentFnSym->print(O, MAI);
|
||||
O << "_param_" << paramIndex;
|
||||
}
|
||||
} else {
|
||||
if (nvptxSubtarget->hasImageHandles())
|
||||
O << "\t.param .u64 .ptr .samplerref ";
|
||||
else
|
||||
O << "\t.param .samplerref ";
|
||||
O << *CurrentFnSym << "_param_" << paramIndex;
|
||||
CurrentFnSym->print(O, MAI);
|
||||
O << "_param_" << paramIndex;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -1713,10 +1729,10 @@ void NVPTXAsmPrinter::printScalarConstant(const Constant *CPV, raw_ostream &O) {
|
|||
}
|
||||
if (EmitGeneric && !isa<Function>(CPV) && !IsNonGenericPointer) {
|
||||
O << "generic(";
|
||||
O << *getSymbol(GVar);
|
||||
getSymbol(GVar)->print(O, MAI);
|
||||
O << ")";
|
||||
} else {
|
||||
O << *getSymbol(GVar);
|
||||
getSymbol(GVar)->print(O, MAI);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -1730,14 +1746,14 @@ void NVPTXAsmPrinter::printScalarConstant(const Constant *CPV, raw_ostream &O) {
|
|||
if (const GlobalValue *GVar = dyn_cast<GlobalValue>(v)) {
|
||||
if (EmitGeneric && !isa<Function>(v) && !IsNonGenericPointer) {
|
||||
O << "generic(";
|
||||
O << *getSymbol(GVar);
|
||||
getSymbol(GVar)->print(O, MAI);
|
||||
O << ")";
|
||||
} else {
|
||||
O << *getSymbol(GVar);
|
||||
getSymbol(GVar)->print(O, MAI);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
O << *lowerConstant(CPV);
|
||||
lowerConstant(CPV)->print(O, MAI);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -2120,7 +2136,7 @@ NVPTXAsmPrinter::lowerConstantForGV(const Constant *CV, bool ProcessingGeneric)
|
|||
void NVPTXAsmPrinter::printMCExpr(const MCExpr &Expr, raw_ostream &OS) {
|
||||
switch (Expr.getKind()) {
|
||||
case MCExpr::Target:
|
||||
return cast<MCTargetExpr>(&Expr)->printImpl(OS);
|
||||
return cast<MCTargetExpr>(&Expr)->printImpl(OS, MAI);
|
||||
case MCExpr::Constant:
|
||||
OS << cast<MCConstantExpr>(Expr).getValue();
|
||||
return;
|
||||
|
@ -2128,7 +2144,7 @@ void NVPTXAsmPrinter::printMCExpr(const MCExpr &Expr, raw_ostream &OS) {
|
|||
case MCExpr::SymbolRef: {
|
||||
const MCSymbolRefExpr &SRE = cast<MCSymbolRefExpr>(Expr);
|
||||
const MCSymbol &Sym = SRE.getSymbol();
|
||||
OS << Sym;
|
||||
Sym.print(OS, MAI);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2253,11 +2269,11 @@ void NVPTXAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
|
|||
break;
|
||||
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
O << *getSymbol(MO.getGlobal());
|
||||
getSymbol(MO.getGlobal())->print(O, MAI);
|
||||
break;
|
||||
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *MO.getMBB()->getSymbol();
|
||||
MO.getMBB()->getSymbol()->print(O, MAI);
|
||||
return;
|
||||
|
||||
default:
|
||||
|
|
|
@ -165,10 +165,10 @@ class LLVM_LIBRARY_VISIBILITY NVPTXAsmPrinter : public AsmPrinter {
|
|||
}
|
||||
if (EmitGeneric && !isa<Function>(v) && !IsNonGenericPointer) {
|
||||
O << "generic(";
|
||||
O << *Name;
|
||||
Name->print(O, AP.MAI);
|
||||
O << ")";
|
||||
} else {
|
||||
O << *Name;
|
||||
Name->print(O, AP.MAI);
|
||||
}
|
||||
} else if (const ConstantExpr *CExpr = dyn_cast<ConstantExpr>(v0)) {
|
||||
const MCExpr *Expr =
|
||||
|
|
|
@ -20,7 +20,7 @@ NVPTXFloatMCExpr::create(VariantKind Kind, APFloat Flt, MCContext &Ctx) {
|
|||
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;
|
||||
unsigned NumHex;
|
||||
APFloat APF = getAPFloat();
|
||||
|
@ -52,6 +52,9 @@ NVPTXGenericMCSymbolRefExpr::create(const MCSymbolRefExpr *SymExpr,
|
|||
return new (Ctx) NVPTXGenericMCSymbolRefExpr(SymExpr);
|
||||
}
|
||||
|
||||
void NVPTXGenericMCSymbolRefExpr::printImpl(raw_ostream &OS) const {
|
||||
OS << "generic(" << *SymExpr << ")";
|
||||
void NVPTXGenericMCSymbolRefExpr::printImpl(raw_ostream &OS,
|
||||
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,
|
||||
const MCAsmLayout *Layout,
|
||||
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,
|
||||
const MCAsmLayout *Layout,
|
||||
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");
|
||||
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);
|
||||
}
|
||||
|
||||
void PPCMCExpr::printImpl(raw_ostream &OS) const {
|
||||
void PPCMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
|
||||
if (isDarwinSyntax()) {
|
||||
switch (Kind) {
|
||||
default: llvm_unreachable("Invalid kind!");
|
||||
|
@ -34,10 +34,10 @@ void PPCMCExpr::printImpl(raw_ostream &OS) const {
|
|||
}
|
||||
|
||||
OS << '(';
|
||||
getSubExpr()->print(OS);
|
||||
getSubExpr()->print(OS, MAI);
|
||||
OS << ')';
|
||||
} else {
|
||||
getSubExpr()->print(OS);
|
||||
getSubExpr()->print(OS, MAI);
|
||||
|
||||
switch (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,
|
||||
const MCAsmLayout *Layout,
|
||||
const MCFixup *Fixup) const override;
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include "PPCMCAsmInfo.h"
|
||||
#include "PPCTargetStreamer.h"
|
||||
#include "llvm/MC/MCCodeGenInfo.h"
|
||||
#include "llvm/MC/MCContext.h"
|
||||
#include "llvm/MC/MCELFStreamer.h"
|
||||
#include "llvm/MC/MCExpr.h"
|
||||
#include "llvm/MC/MCInstrInfo.h"
|
||||
|
@ -132,7 +133,13 @@ public:
|
|||
OS << "\t.abiversion " << AbiVersion << '\n';
|
||||
}
|
||||
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;
|
||||
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *MO.getMBB()->getSymbol();
|
||||
MO.getMBB()->getSymbol()->print(O, MAI);
|
||||
return;
|
||||
case MachineOperand::MO_ConstantPoolIndex:
|
||||
O << DL->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
|
||||
<< '_' << MO.getIndex();
|
||||
return;
|
||||
case MachineOperand::MO_BlockAddress:
|
||||
O << *GetBlockAddressSymbol(MO.getBlockAddress());
|
||||
GetBlockAddressSymbol(MO.getBlockAddress())->print(O, MAI);
|
||||
return;
|
||||
case MachineOperand::MO_GlobalAddress: {
|
||||
// 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);
|
||||
}
|
||||
|
||||
O << *SymToPrint;
|
||||
SymToPrint->print(O, MAI);
|
||||
|
||||
printOffset(MO.getOffset(), O);
|
||||
return;
|
||||
|
|
|
@ -337,7 +337,7 @@ void AMDGPUInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
|||
}
|
||||
} else if (Op.isExpr()) {
|
||||
const MCExpr *Exp = Op.getExpr();
|
||||
Exp->print(O);
|
||||
Exp->print(O, &MAI);
|
||||
} else {
|
||||
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");
|
||||
MO.getExpr()->print(O);
|
||||
MO.getExpr()->print(O, &MAI);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SparcMCExpr::printImpl(raw_ostream &OS) const
|
||||
{
|
||||
void SparcMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
|
||||
|
||||
bool closeParen = printVariantKind(OS, Kind);
|
||||
|
||||
const MCExpr *Expr = getSubExpr();
|
||||
Expr->print(OS);
|
||||
Expr->print(OS, MAI);
|
||||
|
||||
if (closeParen)
|
||||
OS << ')';
|
||||
|
|
|
@ -85,7 +85,7 @@ public:
|
|||
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,
|
||||
const MCAsmLayout *Layout,
|
||||
const MCFixup *Fixup) const override;
|
||||
|
|
|
@ -361,10 +361,10 @@ void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
|
|||
O << (int)MO.getImm();
|
||||
break;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *MO.getMBB()->getSymbol();
|
||||
MO.getMBB()->getSymbol()->print(O, MAI);
|
||||
return;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
O << *getSymbol(MO.getGlobal());
|
||||
getSymbol(MO.getGlobal())->print(O, MAI);
|
||||
break;
|
||||
case MachineOperand::MO_BlockAddress:
|
||||
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())
|
||||
O << '%' << getRegisterName(MO.getReg());
|
||||
else if (MO.isImm())
|
||||
O << MO.getImm();
|
||||
else if (MO.isExpr())
|
||||
O << *MO.getExpr();
|
||||
MO.getExpr()->print(O, MAI);
|
||||
else
|
||||
llvm_unreachable("Invalid operand");
|
||||
}
|
||||
|
@ -147,7 +148,7 @@ void SystemZInstPrinter::printPCRelOperand(const MCInst *MI, int OpNum,
|
|||
O << "0x";
|
||||
O.write_hex(MO.getImm());
|
||||
} else
|
||||
O << *MO.getExpr();
|
||||
MO.getExpr()->print(O, &MAI);
|
||||
}
|
||||
|
||||
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,
|
||||
raw_ostream &O) {
|
||||
printOperand(MI->getOperand(OpNum), O);
|
||||
printOperand(MI->getOperand(OpNum), &MAI, O);
|
||||
}
|
||||
|
||||
void SystemZInstPrinter::printBDAddrOperand(const MCInst *MI, int OpNum,
|
||||
|
|
|
@ -35,7 +35,8 @@ public:
|
|||
raw_ostream &O);
|
||||
|
||||
// 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.
|
||||
void printRegName(raw_ostream &O, unsigned RegNo) const override;
|
||||
|
|
|
@ -305,7 +305,7 @@ bool SystemZAsmPrinter::PrintAsmOperand(const MachineInstr *MI,
|
|||
} else {
|
||||
SystemZMCInstLower Lower(MF->getContext(), *this);
|
||||
MCOperand MO(Lower.lowerOperand(MI->getOperand(OpNo)));
|
||||
SystemZInstPrinter::printOperand(MO, OS);
|
||||
SystemZInstPrinter::printOperand(MO, MAI, OS);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ void X86ATTInstPrinter::printPCRelImm(const MCInst *MI, unsigned OpNo,
|
|||
O << formatHex((uint64_t)Address);
|
||||
} else {
|
||||
// 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 {
|
||||
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);
|
||||
} else {
|
||||
assert(DispSpec.isExpr() && "non-immediate displacement for LEA?");
|
||||
O << *DispSpec.getExpr();
|
||||
DispSpec.getExpr()->print(O, &MAI);
|
||||
}
|
||||
|
||||
if (IndexReg.getReg() || BaseReg.getReg()) {
|
||||
|
@ -273,7 +275,7 @@ void X86ATTInstPrinter::printMemOffset(const MCInst *MI, unsigned Op,
|
|||
O << formatImm(DispSpec.getImm());
|
||||
} else {
|
||||
assert(DispSpec.isExpr() && "non-immediate displacement?");
|
||||
O << *DispSpec.getExpr();
|
||||
DispSpec.getExpr()->print(O, &MAI);
|
||||
}
|
||||
|
||||
O << markup(">");
|
||||
|
|
|
@ -136,7 +136,7 @@ void X86IntelInstPrinter::printPCRelImm(const MCInst *MI, unsigned OpNo,
|
|||
}
|
||||
else {
|
||||
// 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());
|
||||
} else {
|
||||
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 (NeedPlus) O << " + ";
|
||||
assert(DispSpec.isExpr() && "non-immediate displacement for LEA?");
|
||||
O << *DispSpec.getExpr();
|
||||
DispSpec.getExpr()->print(O, &MAI);
|
||||
} else {
|
||||
int64_t DispVal = DispSpec.getImm();
|
||||
if (DispVal || (!IndexReg.getReg() && !BaseReg.getReg())) {
|
||||
|
@ -245,7 +245,7 @@ void X86IntelInstPrinter::printMemOffset(const MCInst *MI, unsigned Op,
|
|||
O << formatImm(DispSpec.getImm());
|
||||
} else {
|
||||
assert(DispSpec.isExpr() && "non-immediate displacement?");
|
||||
O << *DispSpec.getExpr();
|
||||
DispSpec.getExpr()->print(O, &MAI);
|
||||
}
|
||||
|
||||
O << ']';
|
||||
|
|
|
@ -78,7 +78,7 @@ static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO,
|
|||
switch (MO.getType()) {
|
||||
default: llvm_unreachable("unknown symbol type!");
|
||||
case MachineOperand::MO_ConstantPoolIndex:
|
||||
O << *P.GetCPISymbol(MO.getIndex());
|
||||
P.GetCPISymbol(MO.getIndex())->print(O, P.MAI);
|
||||
P.printOffset(MO.getOffset(), O);
|
||||
break;
|
||||
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
|
||||
// to avoid having it look like an integer immediate to the assembler.
|
||||
if (GVSym->getName()[0] != '$')
|
||||
O << *GVSym;
|
||||
else
|
||||
O << '(' << *GVSym << ')';
|
||||
GVSym->print(O, P.MAI);
|
||||
else {
|
||||
O << '(';
|
||||
GVSym->print(O, P.MAI);
|
||||
O << ')';
|
||||
}
|
||||
P.printOffset(MO.getOffset(), O);
|
||||
break;
|
||||
}
|
||||
|
@ -146,12 +149,15 @@ static void printSymbolOperand(X86AsmPrinter &P, const MachineOperand &MO,
|
|||
// These affect the name of the symbol, not any suffix.
|
||||
break;
|
||||
case X86II::MO_GOT_ABSOLUTE_ADDRESS:
|
||||
O << " + [.-" << *P.MF->getPICBaseSymbol() << ']';
|
||||
O << " + [.-";
|
||||
P.MF->getPICBaseSymbol()->print(O, P.MAI);
|
||||
O << ']';
|
||||
break;
|
||||
case X86II::MO_PIC_BASE_OFFSET:
|
||||
case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
|
||||
case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE:
|
||||
O << '-' << *P.MF->getPICBaseSymbol();
|
||||
O << '-';
|
||||
P.MF->getPICBaseSymbol()->print(O, P.MAI);
|
||||
break;
|
||||
case X86II::MO_TLSGD: O << "@TLSGD"; 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_TLVP: O << "@TLVP"; break;
|
||||
case X86II::MO_TLVP_PIC_BASE:
|
||||
O << "@TLVP" << '-' << *P.MF->getPICBaseSymbol();
|
||||
O << "@TLVP" << '-';
|
||||
P.MF->getPICBaseSymbol()->print(O, P.MAI);
|
||||
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");
|
||||
}
|
||||
|
||||
static void printExpr(const MCExpr *Expr, raw_ostream &OS) {
|
||||
static void printExpr(const MCExpr *Expr, const MCAsmInfo *MAI,
|
||||
raw_ostream &OS) {
|
||||
int Offset = 0;
|
||||
const MCSymbolRefExpr *SRE;
|
||||
|
||||
|
@ -60,7 +61,7 @@ static void printExpr(const MCExpr *Expr, raw_ostream &OS) {
|
|||
}
|
||||
assert(SRE->getKind() == MCSymbolRefExpr::VK_None);
|
||||
|
||||
OS << SRE->getSymbol();
|
||||
SRE->getSymbol().print(OS, MAI);
|
||||
|
||||
if (Offset) {
|
||||
if (Offset > 0)
|
||||
|
@ -83,5 +84,5 @@ printOperand(const MCInst *MI, unsigned OpNo, raw_ostream &O) {
|
|||
}
|
||||
|
||||
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];
|
||||
if (i > 0)
|
||||
O << ",";
|
||||
O << *MBB->getSymbol();
|
||||
MBB->getSymbol()->print(O, MAI);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,17 +218,17 @@ void XCoreAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
|
|||
O << MO.getImm();
|
||||
break;
|
||||
case MachineOperand::MO_MachineBasicBlock:
|
||||
O << *MO.getMBB()->getSymbol();
|
||||
MO.getMBB()->getSymbol()->print(O, MAI);
|
||||
break;
|
||||
case MachineOperand::MO_GlobalAddress:
|
||||
O << *getSymbol(MO.getGlobal());
|
||||
getSymbol(MO.getGlobal())->print(O, MAI);
|
||||
break;
|
||||
case MachineOperand::MO_ConstantPoolIndex:
|
||||
O << DL->getPrivateGlobalPrefix() << "CPI" << getFunctionNumber()
|
||||
<< '_' << MO.getIndex();
|
||||
break;
|
||||
case MachineOperand::MO_BlockAddress:
|
||||
O << *GetBlockAddressSymbol(MO.getBlockAddress());
|
||||
GetBlockAddressSymbol(MO.getBlockAddress())->print(O, MAI);
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("not implemented");
|
||||
|
|
Loading…
Reference in New Issue