[MCInstPrinter] Enable MCInstPrinter to change its behavior based on the

per-function subtarget.

Currently, code-gen passes the default or generic subtarget to the constructors
of MCInstPrinter subclasses (see LLVMTargetMachine::addPassesToEmitFile), which
enables some targets (AArch64, ARM, and X86) to change their instprinter's
behavior based on the subtarget feature bits. Since the backend can now use
different subtargets for each function, instprinter has to be changed to use the
per-function subtarget rather than the default subtarget.

This patch takes the first step towards enabling instprinter to change its
behavior based on the per-function subtarget. It adds a bit "PassSubtarget" to
AsmWriter which tells table-gen to pass a reference to MCSubtargetInfo to the
various print methods table-gen auto-generates. 

I will follow up with changes to instprinters of AArch64, ARM, and X86.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233411 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Akira Hatanaka
2015-03-27 20:36:02 +00:00
parent 19e2fce680
commit f09378397e
39 changed files with 228 additions and 107 deletions

View File

@ -3347,9 +3347,9 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
Annotations.flush();
StringRef AnnotationsStr = Annotations.str();
if (isThumb)
ThumbIP->printInst(&Inst, FormattedOS, AnnotationsStr);
ThumbIP->printInst(&Inst, FormattedOS, AnnotationsStr, *ThumbSTI);
else
IP->printInst(&Inst, FormattedOS, AnnotationsStr);
IP->printInst(&Inst, FormattedOS, AnnotationsStr, *ThumbSTI);
emitComments(CommentStream, CommentsToEmit, FormattedOS, *AsmInfo);
// Print debug info.
@ -3408,7 +3408,7 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF,
outs() << "\t";
DumpBytes(ArrayRef<uint8_t>(Bytes.data() + Index, InstSize));
}
IP->printInst(&Inst, outs(), "");
IP->printInst(&Inst, outs(), "", *ThumbSTI);
outs() << "\n";
} else {
unsigned int Arch = MachOOF->getArch();

View File

@ -401,7 +401,7 @@ static void DisassembleObject(const ObjectFile *Obj, bool InlineRelocs) {
outs() << "\t";
DumpBytes(ArrayRef<uint8_t>(Bytes.data() + Index, Size));
}
IP->printInst(&Inst, outs(), "");
IP->printInst(&Inst, outs(), "", *STI);
outs() << CommentStream.str();
Comments.clear();
outs() << "\n";