mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-23 02:32:11 +00:00
Convert some more random-comment-printing stuff to use
AddComment and GetCommentOS. Add a blank line between globals (even in non-verbose mode) to make the assembly more readable. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94202 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
7e02e52e9a
commit
0fd90fd8d1
@ -81,6 +81,9 @@ namespace llvm {
|
|||||||
|
|
||||||
MCContext &getContext() const { return Context; }
|
MCContext &getContext() const { return Context; }
|
||||||
|
|
||||||
|
/// @name Assembly File Formatting.
|
||||||
|
/// @{
|
||||||
|
|
||||||
/// AddComment - Add a comment that can be emitted to the generated .s
|
/// AddComment - Add a comment that can be emitted to the generated .s
|
||||||
/// file if applicable as a QoI issue to make the output of the compiler
|
/// file if applicable as a QoI issue to make the output of the compiler
|
||||||
/// more readable. This only affects the MCAsmStreamer, and only when
|
/// more readable. This only affects the MCAsmStreamer, and only when
|
||||||
@ -95,6 +98,11 @@ namespace llvm {
|
|||||||
/// use this method.
|
/// use this method.
|
||||||
virtual raw_ostream &GetCommentOS();
|
virtual raw_ostream &GetCommentOS();
|
||||||
|
|
||||||
|
/// AddBlankLine - Emit a blank line to a .s file to pretty it up.
|
||||||
|
virtual void AddBlankLine() {}
|
||||||
|
|
||||||
|
/// @}
|
||||||
|
|
||||||
/// @name Symbol & Section Management
|
/// @name Symbol & Section Management
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "llvm/MC/MCSymbol.h"
|
#include "llvm/MC/MCSymbol.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/ErrorHandling.h"
|
#include "llvm/Support/ErrorHandling.h"
|
||||||
|
#include "llvm/Support/Format.h"
|
||||||
#include "llvm/Support/FormattedStream.h"
|
#include "llvm/Support/FormattedStream.h"
|
||||||
#include "llvm/MC/MCAsmInfo.h"
|
#include "llvm/MC/MCAsmInfo.h"
|
||||||
#include "llvm/Target/Mangler.h"
|
#include "llvm/Target/Mangler.h"
|
||||||
@ -173,10 +174,9 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
|
|||||||
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
if (Size == 0) Size = 1; // .comm Foo, 0 is undefined, avoid it.
|
||||||
|
|
||||||
if (VerboseAsm) {
|
if (VerboseAsm) {
|
||||||
O.PadToColumn(MAI->getCommentColumn());
|
WriteAsOperand(OutStreamer.GetCommentOS(), GV,
|
||||||
O << MAI->getCommentString() << ' ';
|
/*PrintType=*/false, GV->getParent());
|
||||||
WriteAsOperand(O, GV, /*PrintType=*/false, GV->getParent());
|
OutStreamer.GetCommentOS() << '\n';
|
||||||
O << '\n';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle common symbols.
|
// Handle common symbols.
|
||||||
@ -266,10 +266,9 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
|
|||||||
|
|
||||||
EmitAlignment(AlignLog, GV);
|
EmitAlignment(AlignLog, GV);
|
||||||
if (VerboseAsm) {
|
if (VerboseAsm) {
|
||||||
O.PadToColumn(MAI->getCommentColumn());
|
WriteAsOperand(OutStreamer.GetCommentOS(), GV,
|
||||||
O << MAI->getCommentString() << ' ';
|
/*PrintType=*/false, GV->getParent());
|
||||||
WriteAsOperand(O, GV, /*PrintType=*/false, GV->getParent());
|
OutStreamer.GetCommentOS() << '\n';
|
||||||
O << '\n';
|
|
||||||
}
|
}
|
||||||
OutStreamer.EmitLabel(GVSym);
|
OutStreamer.EmitLabel(GVSym);
|
||||||
|
|
||||||
@ -277,6 +276,8 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
|
|||||||
|
|
||||||
if (MAI->hasDotTypeDotSizeDirective())
|
if (MAI->hasDotTypeDotSizeDirective())
|
||||||
O << "\t.size\t" << *GVSym << ", " << Size << '\n';
|
O << "\t.size\t" << *GVSym << ", " << Size << '\n';
|
||||||
|
|
||||||
|
OutStreamer.AddBlankLine();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1141,9 +1142,8 @@ static void EmitGlobalConstantFP(const ConstantFP *CFP, unsigned AddrSpace,
|
|||||||
|
|
||||||
if (CFP->getType()->isFloatTy()) {
|
if (CFP->getType()->isFloatTy()) {
|
||||||
if (AP.VerboseAsm) {
|
if (AP.VerboseAsm) {
|
||||||
float Val = CFP->getValueAPF().convertToFloat(); // for comment only
|
float Val = CFP->getValueAPF().convertToFloat();
|
||||||
AP.O.PadToColumn(AP.MAI->getCommentColumn());
|
AP.OutStreamer.GetCommentOS() << "float " << Val << '\n';
|
||||||
AP.O << AP.MAI->getCommentString() << " float " << Val << '\n';
|
|
||||||
}
|
}
|
||||||
uint64_t Val = CFP->getValueAPF().bitcastToAPInt().getZExtValue();
|
uint64_t Val = CFP->getValueAPF().bitcastToAPInt().getZExtValue();
|
||||||
AP.OutStreamer.EmitIntValue(Val, 4, AddrSpace);
|
AP.OutStreamer.EmitIntValue(Val, 4, AddrSpace);
|
||||||
@ -1161,9 +1161,8 @@ static void EmitGlobalConstantFP(const ConstantFP *CFP, unsigned AddrSpace,
|
|||||||
bool ignored;
|
bool ignored;
|
||||||
DoubleVal.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven,
|
DoubleVal.convert(APFloat::IEEEdouble, APFloat::rmNearestTiesToEven,
|
||||||
&ignored);
|
&ignored);
|
||||||
AP.O.PadToColumn(AP.MAI->getCommentColumn());
|
AP.OutStreamer.GetCommentOS() << "x86_fp80 ~= "
|
||||||
AP.O << AP.MAI->getCommentString() << " x86_fp80 ~= "
|
<< DoubleVal.convertToDouble() << '\n';
|
||||||
<< DoubleVal.convertToDouble() << '\n';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (AP.TM.getTargetData()->isBigEndian()) {
|
if (AP.TM.getTargetData()->isBigEndian()) {
|
||||||
@ -1226,12 +1225,8 @@ void AsmPrinter::EmitGlobalConstant(const Constant *CV, unsigned AddrSpace) {
|
|||||||
case 2:
|
case 2:
|
||||||
case 4:
|
case 4:
|
||||||
case 8:
|
case 8:
|
||||||
if (VerboseAsm) {
|
if (VerboseAsm)
|
||||||
O.PadToColumn(MAI->getCommentColumn());
|
OutStreamer.GetCommentOS() << format("0x%llx\n", CI->getZExtValue());
|
||||||
O << MAI->getCommentString() << " 0x";
|
|
||||||
O.write_hex(CI->getZExtValue());
|
|
||||||
O << '\n';
|
|
||||||
}
|
|
||||||
OutStreamer.EmitIntValue(CI->getZExtValue(), Size, AddrSpace);
|
OutStreamer.EmitIntValue(CI->getZExtValue(), Size, AddrSpace);
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
@ -1670,30 +1665,32 @@ void AsmPrinter::EmitBasicBlockStart(const MachineBasicBlock *MBB) const {
|
|||||||
// will be.
|
// will be.
|
||||||
if (MBB->hasAddressTaken()) {
|
if (MBB->hasAddressTaken()) {
|
||||||
const BasicBlock *BB = MBB->getBasicBlock();
|
const BasicBlock *BB = MBB->getBasicBlock();
|
||||||
|
if (VerboseAsm)
|
||||||
|
OutStreamer.AddComment("Address Taken");
|
||||||
OutStreamer.EmitLabel(GetBlockAddressSymbol(BB->getParent(), BB));
|
OutStreamer.EmitLabel(GetBlockAddressSymbol(BB->getParent(), BB));
|
||||||
if (VerboseAsm) {
|
|
||||||
O.PadToColumn(MAI->getCommentColumn());
|
|
||||||
O << MAI->getCommentString() << " Address Taken" << '\n';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the main label for the block.
|
// Print the main label for the block.
|
||||||
if (MBB->pred_empty() || MBB->isOnlyReachableByFallthrough()) {
|
if (MBB->pred_empty() || MBB->isOnlyReachableByFallthrough()) {
|
||||||
if (VerboseAsm)
|
if (VerboseAsm) {
|
||||||
O << MAI->getCommentString() << " BB#" << MBB->getNumber() << ':';
|
O << MAI->getCommentString() << " BB#" << MBB->getNumber() << ':';
|
||||||
|
if (const BasicBlock *BB = MBB->getBasicBlock())
|
||||||
|
if (BB->hasName())
|
||||||
|
OutStreamer.AddComment("%" + BB->getName());
|
||||||
|
OutStreamer.AddBlankLine();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if (VerboseAsm) {
|
||||||
|
if (const BasicBlock *BB = MBB->getBasicBlock())
|
||||||
|
if (BB->hasName())
|
||||||
|
OutStreamer.AddComment("%" + BB->getName());
|
||||||
|
}
|
||||||
OutStreamer.EmitLabel(GetMBBSymbol(MBB->getNumber()));
|
OutStreamer.EmitLabel(GetMBBSymbol(MBB->getNumber()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print some comments to accompany the label.
|
// Print some comments to accompany the label.
|
||||||
if (VerboseAsm) {
|
// FIXME: REENABLE.
|
||||||
if (const BasicBlock *BB = MBB->getBasicBlock())
|
if (0 && VerboseAsm) {
|
||||||
if (BB->hasName()) {
|
|
||||||
O.PadToColumn(MAI->getCommentColumn());
|
|
||||||
O << MAI->getCommentString() << ' ';
|
|
||||||
WriteAsOperand(O, BB, /*PrintType=*/false);
|
|
||||||
}
|
|
||||||
|
|
||||||
EmitComments(*MBB);
|
EmitComments(*MBB);
|
||||||
O << '\n';
|
O << '\n';
|
||||||
}
|
}
|
||||||
|
@ -73,6 +73,11 @@ public:
|
|||||||
return CommentStream;
|
return CommentStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// AddBlankLine - Emit a blank line to a .s file to pretty it up.
|
||||||
|
virtual void AddBlankLine() {
|
||||||
|
EmitEOL();
|
||||||
|
}
|
||||||
|
|
||||||
/// @name MCStreamer Interface
|
/// @name MCStreamer Interface
|
||||||
/// @{
|
/// @{
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user