2024-01-20 11:11:28 -03:00
|
|
|
using Ryujinx.Cpu.LightningJit.CodeGen;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Ryujinx.Cpu.LightningJit.Arm32
|
|
|
|
|
{
|
|
|
|
|
readonly struct ScopedRegister : IDisposable
|
|
|
|
|
{
|
|
|
|
|
private readonly RegisterAllocator _registerAllocator;
|
|
|
|
|
private readonly Operand _operand;
|
|
|
|
|
private readonly bool _isAllocated;
|
|
|
|
|
|
|
|
|
|
public readonly Operand Operand => _operand;
|
|
|
|
|
public readonly bool IsAllocated => _isAllocated;
|
|
|
|
|
|
|
|
|
|
public ScopedRegister(RegisterAllocator registerAllocator, Operand operand, bool isAllocated = true)
|
|
|
|
|
{
|
|
|
|
|
_registerAllocator = registerAllocator;
|
|
|
|
|
_operand = operand;
|
|
|
|
|
_isAllocated = isAllocated;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public readonly void Dispose()
|
|
|
|
|
{
|
|
|
|
|
if (!_isAllocated)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2025-11-11 12:55:36 -06:00
|
|
|
if (_operand.Type.IsInteger)
|
2024-01-20 11:11:28 -03:00
|
|
|
{
|
|
|
|
|
_registerAllocator.FreeTempGprRegister(_operand.AsInt32());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_registerAllocator.FreeTempFpSimdRegister(_operand.AsInt32());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|