Target->Native renaming. More intuitive (at least to me)

This commit is contained in:
Henrik Rydgård committed 2024-07-22 01:24:34 +02:00
1 parent 898774a93d
commit 85e7ff7ac3
8 files changed
+31 -31

No files matched your search

+3 -3
View File
@@ -70,7 +70,7 @@ bool Arm64JitBackend::CompileBlock(IRBlockCache *irBlockCache, int block_num, bo
return false;
IRBlock *block = irBlockCache->GetBlock(block_num);
BeginWrite(std::min(GetSpaceLeft(), (size_t)block->GetNumInstructions() * 32));
BeginWrite(std::min(GetSpaceLeft(), (size_t)block->GetNumIRInstructions() * 32));
u32 startPC = block->GetOriginalStart();
bool wroteCheckedOffset = false;
@@ -96,9 +96,9 @@ bool Arm64JitBackend::CompileBlock(IRBlockCache *irBlockCache, int block_num, bo
regs_.Start(irBlockCache, block_num);
std::vector<const u8 *> addresses;
addresses.reserve(block->GetNumInstructions());
addresses.reserve(block->GetNumIRInstructions());
const IRInst *instructions = irBlockCache->GetBlockInstructionPtr(*block);
for (int i = 0; i < block->GetNumInstructions(); ++i) {
for (int i = 0; i < block->GetNumIRInstructions(); ++i) {
const IRInst &inst = instructions[i];
regs_.SetIRIndex(i);
addresses.push_back(GetCodePtr());
+9 -9
View File
@@ -121,7 +121,7 @@ void IRJit::Compile(u32 em_address) {
block->Finalize(cookie);
if (block->IsValid()) {
// Success, we're done.
FinalizeTargetBlock(&blocks_, block_num);
FinalizeNativeBlock(&blocks_, block_num);
return;
}
}
@@ -165,12 +165,12 @@ bool IRJit::CompileBlock(u32 em_address, std::vector<IRInst> &instructions, u32
// TODO: Should we always hash? Then we can reuse blocks.
b->UpdateHash();
}
if (!CompileTargetBlock(&blocks_, block_num, preload))
if (!CompileNativeBlock(&blocks_, block_num, preload))
return false;
// Overwrites the first instruction, and also updates stats.
blocks_.FinalizeBlock(block_num, preload);
if (!preload)
FinalizeTargetBlock(&blocks_, block_num);
FinalizeNativeBlock(&blocks_, block_num);
return true;
}
@@ -303,7 +303,7 @@ void IRJit::RunLoopUntil(u64 globalticks) {
}
bool IRJit::DescribeCodePtr(const u8 *ptr, std::string &name) {
// Used in target disassembly viewer.
// Used in native disassembly viewer.
return false;
}
@@ -445,7 +445,7 @@ void IRBlockCache::RemoveBlock(int blockIndex) {
// Additionally, we zap the block in the IR arena.
IRInst bad{ IROp::Bad };
for (int off = block.GetIRArenaOffset(); off < block.GetIRArenaOffset() + block.GetNumInstructions(); off++) {
for (int off = block.GetIRArenaOffset(); off < block.GetIRArenaOffset() + block.GetNumIRInstructions(); off++) {
arena_[off] = bad;
}
}
@@ -477,7 +477,7 @@ int IRBlockCache::FindByCookie(int cookie) {
if (blocks_.empty())
return -1;
// TODO: Maybe a flag to determine target offset mode?
// TODO: Maybe a flag to determine native offset mode?
if (!compileToNative_) {
return GetBlockNumFromIRArenaOffset(cookie);
}
@@ -539,9 +539,9 @@ JitBlockDebugInfo IRBlockCache::GetBlockDebugInfo(int blockNum) const {
debugInfo.origDisasm.push_back(mipsDis);
}
debugInfo.irDisasm.reserve(ir.GetNumInstructions());
debugInfo.irDisasm.reserve(ir.GetNumIRInstructions());
const IRInst *instructions = GetBlockInstructionPtr(ir);
for (int i = 0; i < ir.GetNumInstructions(); i++) {
for (int i = 0; i < ir.GetNumIRInstructions(); i++) {
IRInst inst = instructions[i];
char buffer[256];
DisassembleIR(buffer, sizeof(buffer), inst);
@@ -555,7 +555,7 @@ void IRBlockCache::ComputeStats(BlockCacheStats &bcStats) const {
double maxBloat = 0.0;
double minBloat = 1000000000.0;
for (const auto &b : blocks_) {
double codeSize = (double)b.GetNumInstructions() * 4; // We count bloat in instructions, not bytes. sizeof(IRInst);
double codeSize = (double)b.GetNumIRInstructions() * 4; // We count bloat in instructions, not bytes. sizeof(IRInst);
if (codeSize == 0)
continue;
u32 origAddr, mipsBytes;
+6 -6
View File
@@ -50,7 +50,7 @@ class IRBlock {
public:
IRBlock() {}
IRBlock(u32 emAddr, u32 origSize, int instOffset, u32 numInstructions)
: origAddr_(emAddr), origSize_(origSize), arenaOffset_(instOffset), numInstructions_(numInstructions) {}
: origAddr_(emAddr), origSize_(origSize), arenaOffset_(instOffset), numIRInstructions_(numInstructions) {}
IRBlock(IRBlock &&b) {
arenaOffset_ = b.arenaOffset_;
hash_ = b.hash_;
@@ -58,14 +58,14 @@ public:
origSize_ = b.origSize_;
origFirstOpcode_ = b.origFirstOpcode_;
nativeOffset_ = b.nativeOffset_;
numInstructions_ = b.numInstructions_;
numIRInstructions_ = b.numIRInstructions_;
b.arenaOffset_ = 0xFFFFFFFF;
}
~IRBlock() {}
u32 GetIRArenaOffset() const { return arenaOffset_; }
int GetNumInstructions() const { return numInstructions_; }
int GetNumIRInstructions() const { return numIRInstructions_; }
MIPSOpcode GetOriginalFirstOp() const { return origFirstOpcode_; }
bool HasOriginalFirstOp() const;
bool RestoreOriginalFirstOp(int number);
@@ -110,7 +110,7 @@ private:
u32 origAddr_ = 0;
u32 origSize_ = 0;
MIPSOpcode origFirstOpcode_ = MIPSOpcode(0x68FFFFFF);
u32 numInstructions_ = 0;
u32 numIRInstructions_ = 0;
};
class IRBlockCache : public JitBlockCacheDebugInterface {
@@ -236,8 +236,8 @@ public:
protected:
bool CompileBlock(u32 em_address, std::vector<IRInst> &instructions, u32 &mipsBytes, bool preload);
virtual bool CompileTargetBlock(IRBlockCache *irBlockCache, int block_num, bool preload) { return true; }
virtual void FinalizeTargetBlock(IRBlockCache *irBlockCache, int block_num) {}
virtual bool CompileNativeBlock(IRBlockCache *irBlockCache, int block_num, bool preload) { return true; }
virtual void FinalizeNativeBlock(IRBlockCache *irBlockCache, int block_num) {}
bool compileToNative_;
+2 -2
View File
@@ -507,11 +507,11 @@ void IRNativeJit::Init(IRNativeBackend &backend) {
}
}
bool IRNativeJit::CompileTargetBlock(IRBlockCache *irblockCache, int block_num, bool preload) {
bool IRNativeJit::CompileNativeBlock(IRBlockCache *irblockCache, int block_num, bool preload) {
return backend_->CompileBlock(irblockCache, block_num, preload);
}
void IRNativeJit::FinalizeTargetBlock(IRBlockCache *irblockCache, int block_num) {
void IRNativeJit::FinalizeNativeBlock(IRBlockCache *irblockCache, int block_num) {
backend_->FinalizeBlock(irblockCache, block_num, jo);
}
+2 -2
View File
@@ -198,8 +198,8 @@ public:
protected:
void Init(IRNativeBackend &backend);
bool CompileTargetBlock(IRBlockCache *irBlockCache, int block_num, bool preload) override;
void FinalizeTargetBlock(IRBlockCache *irBlockCache, int block_num) override;
bool CompileNativeBlock(IRBlockCache *irBlockCache, int block_num, bool preload) override;
void FinalizeNativeBlock(IRBlockCache *irBlockCache, int block_num) override;
IRNativeBackend *backend_ = nullptr;
IRNativeHooks hooks_;
+5 -5
View File
@@ -126,7 +126,7 @@ void IRNativeRegCacheBase::Start(MIPSComp::IRBlockCache *irBlockCache, int block
mr[statics[i].mr].nReg = statics[i].nr;
mr[statics[i].mr].isStatic = true;
// Lock it until the very end.
mr[statics[i].mr].spillLockIRIndex = irBlock_->GetNumInstructions();
mr[statics[i].mr].spillLockIRIndex = irBlock_->GetNumIRInstructions();
}
irBlockNum_ = blockNum;
@@ -434,7 +434,7 @@ bool IRNativeRegCacheBase::IsRegClobbered(MIPSLoc type, IRReg r) const {
// We look starting one ahead, unlike spilling. We want to know if it clobbers later.
info.currentIndex = irIndex_ + 1;
info.instructions = irBlockCache_->GetBlockInstructionPtr(irBlockNum_);
info.numInstructions = irBlock_->GetNumInstructions();
info.numInstructions = irBlock_->GetNumIRInstructions();
// Make sure we're on the first one if this is multi-lane.
IRReg first = r;
@@ -461,7 +461,7 @@ bool IRNativeRegCacheBase::IsRegRead(MIPSLoc type, IRReg first) const {
// We look starting one ahead, unlike spilling.
info.currentIndex = irIndex_ + 1;
info.instructions = irBlockCache_->GetBlockInstructionPtr(irBlockNum_);
info.numInstructions = irBlock_->GetNumInstructions();
info.numInstructions = irBlock_->GetNumIRInstructions();
// Note: this intentionally doesn't look at the full reg, only the lane.
IRUsage usage = GetNextRegUsage(info, type, first);
@@ -478,7 +478,7 @@ IRNativeReg IRNativeRegCacheBase::FindBestToSpill(MIPSLoc type, MIPSMap flags, b
info.lookaheadCount = UNUSED_LOOKAHEAD_OPS;
info.currentIndex = irIndex_;
info.instructions = irBlockCache_->GetBlockInstructionPtr(irBlockNum_);
info.numInstructions = irBlock_->GetNumInstructions();
info.numInstructions = irBlock_->GetNumIRInstructions();
*clobbered = false;
for (int i = 0; i < allocCount; i++) {
@@ -1031,7 +1031,7 @@ void IRNativeRegCacheBase::MapNativeReg(MIPSLoc type, IRNativeReg nreg, IRReg fi
info.lookaheadCount = 16;
info.currentIndex = irIndex_;
info.instructions = irBlockCache_->GetBlockInstructionPtr(irBlockNum_);
info.numInstructions = irBlock_->GetNumInstructions();
info.numInstructions = irBlock_->GetNumIRInstructions();
IRReg basefpr = first - oldlane - 32;
clobbered = true;
+2 -2
View File
@@ -61,7 +61,7 @@ bool RiscVJitBackend::CompileBlock(IRBlockCache *irBlockCache, int block_num, bo
return false;
IRBlock *block = irBlockCache->GetBlock(block_num);
BeginWrite(std::min(GetSpaceLeft(), (size_t)block->GetNumInstructions() * 32));
BeginWrite(std::min(GetSpaceLeft(), (size_t)block->GetNumIRInstructions() * 32));
u32 startPC = block->GetOriginalStart();
bool wroteCheckedOffset = false;
@@ -86,7 +86,7 @@ bool RiscVJitBackend::CompileBlock(IRBlockCache *irBlockCache, int block_num, bo
std::vector<const u8 *> addresses;
const IRInst *instructions = irBlockCache->GetBlockInstructionPtr(*block);
for (int i = 0; i < block->GetNumInstructions(); ++i) {
for (int i = 0; i < block->GetNumIRInstructions(); ++i) {
const IRInst &inst = instructions[i];
regs_.SetIRIndex(i);
addresses.push_back(GetCodePtr());
+2 -2
View File
@@ -89,9 +89,9 @@ bool X64JitBackend::CompileBlock(IRBlockCache *irBlockCache, int block_num, bool
regs_.Start(irBlockCache, block_num);
std::vector<const u8 *> addresses;
addresses.reserve(block->GetNumInstructions());
addresses.reserve(block->GetNumIRInstructions());
const IRInst *instructions = irBlockCache->GetBlockInstructionPtr(*block);
for (int i = 0; i < block->GetNumInstructions(); ++i) {
for (int i = 0; i < block->GetNumIRInstructions(); ++i) {
const IRInst &inst = instructions[i];
regs_.SetIRIndex(i);
addresses.push_back(GetCodePtr());