mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-14 11:32:34 +00:00
[X86] Clarify some stackmap shadow optimization code as based on review
feedback from Eric Christopher. No functional change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213917 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
2286ae542c
commit
76cbffa2a9
@ -44,16 +44,27 @@ class LLVM_LIBRARY_VISIBILITY X86AsmPrinter : public AsmPrinter {
|
|||||||
~StackMapShadowTracker();
|
~StackMapShadowTracker();
|
||||||
void startFunction(MachineFunction &MF);
|
void startFunction(MachineFunction &MF);
|
||||||
void count(MCInst &Inst, const MCSubtargetInfo &STI);
|
void count(MCInst &Inst, const MCSubtargetInfo &STI);
|
||||||
|
|
||||||
|
// Called to signal the start of a shadow of RequiredSize bytes.
|
||||||
void reset(unsigned RequiredSize) {
|
void reset(unsigned RequiredSize) {
|
||||||
RequiredShadowSize = RequiredSize;
|
RequiredShadowSize = RequiredSize;
|
||||||
CurrentShadowSize = 0;
|
CurrentShadowSize = 0;
|
||||||
Count = true;
|
InShadow = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Called before every stackmap/patchpoint, and at the end of basic blocks,
|
||||||
|
// to emit any necessary padding-NOPs.
|
||||||
void emitShadowPadding(MCStreamer &OutStreamer, const MCSubtargetInfo &STI);
|
void emitShadowPadding(MCStreamer &OutStreamer, const MCSubtargetInfo &STI);
|
||||||
private:
|
private:
|
||||||
TargetMachine &TM;
|
TargetMachine &TM;
|
||||||
std::unique_ptr<MCCodeEmitter> CodeEmitter;
|
std::unique_ptr<MCCodeEmitter> CodeEmitter;
|
||||||
bool Count;
|
bool InShadow;
|
||||||
|
|
||||||
|
// RequiredShadowSize holds the length of the shadow specified in the most
|
||||||
|
// recently encountered STACKMAP instruction.
|
||||||
|
// CurrentShadowSize counts the number of bytes encoded since the most
|
||||||
|
// recently encountered STACKMAP, stopping when that number is greater than
|
||||||
|
// or equal to RequiredShadowSize.
|
||||||
unsigned RequiredShadowSize, CurrentShadowSize;
|
unsigned RequiredShadowSize, CurrentShadowSize;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ static void EmitNops(MCStreamer &OS, unsigned NumBytes, bool Is64Bit,
|
|||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
X86AsmPrinter::StackMapShadowTracker::StackMapShadowTracker(TargetMachine &TM)
|
X86AsmPrinter::StackMapShadowTracker::StackMapShadowTracker(TargetMachine &TM)
|
||||||
: TM(TM), Count(false), RequiredShadowSize(0), CurrentShadowSize(0) {}
|
: TM(TM), InShadow(false), RequiredShadowSize(0), CurrentShadowSize(0) {}
|
||||||
|
|
||||||
X86AsmPrinter::StackMapShadowTracker::~StackMapShadowTracker() {}
|
X86AsmPrinter::StackMapShadowTracker::~StackMapShadowTracker() {}
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ namespace llvm {
|
|||||||
|
|
||||||
void X86AsmPrinter::StackMapShadowTracker::count(MCInst &Inst,
|
void X86AsmPrinter::StackMapShadowTracker::count(MCInst &Inst,
|
||||||
const MCSubtargetInfo &STI) {
|
const MCSubtargetInfo &STI) {
|
||||||
if (Count) {
|
if (InShadow) {
|
||||||
SmallString<256> Code;
|
SmallString<256> Code;
|
||||||
SmallVector<MCFixup, 4> Fixups;
|
SmallVector<MCFixup, 4> Fixups;
|
||||||
raw_svector_ostream VecOS(Code);
|
raw_svector_ostream VecOS(Code);
|
||||||
@ -88,16 +88,17 @@ namespace llvm {
|
|||||||
VecOS.flush();
|
VecOS.flush();
|
||||||
CurrentShadowSize += Code.size();
|
CurrentShadowSize += Code.size();
|
||||||
if (CurrentShadowSize >= RequiredShadowSize)
|
if (CurrentShadowSize >= RequiredShadowSize)
|
||||||
Count = false; // The shadow is big enough. Stop counting.
|
InShadow = false; // The shadow is big enough. Stop counting.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void X86AsmPrinter::StackMapShadowTracker::emitShadowPadding(
|
void X86AsmPrinter::StackMapShadowTracker::emitShadowPadding(
|
||||||
MCStreamer &OutStreamer, const MCSubtargetInfo &STI) {
|
MCStreamer &OutStreamer, const MCSubtargetInfo &STI) {
|
||||||
if (Count && CurrentShadowSize < RequiredShadowSize)
|
if (InShadow && CurrentShadowSize < RequiredShadowSize) {
|
||||||
|
InShadow = false;
|
||||||
EmitNops(OutStreamer, RequiredShadowSize - CurrentShadowSize,
|
EmitNops(OutStreamer, RequiredShadowSize - CurrentShadowSize,
|
||||||
TM.getSubtarget<X86Subtarget>().is64Bit(), STI);
|
TM.getSubtarget<X86Subtarget>().is64Bit(), STI);
|
||||||
Count = false;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void X86AsmPrinter::EmitAndCountInstruction(MCInst &Inst) {
|
void X86AsmPrinter::EmitAndCountInstruction(MCInst &Inst) {
|
||||||
|
Loading…
Reference in New Issue
Block a user