Example #1
0
        bool IsGRegisterFree(int Index, x86RegisterMask Mask, bool EnableParamLocs = false)
        {
            if (!GRegisters.IsFree(Index, Mask))
            {
                return(false);
            }
            if (!FSData.DisabledLocations.GRegisters.IsFree(Index, Mask))
            {
                return(false);
            }

            if (!EnableParamLocs)
            {
                var P = ContainerData.UsedByParams;
                if (P.GRegisters.Initialized && !P.GRegisters.IsFree(Index, Mask))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #2
0
        public x86DataLocation GetAllocated(x86DataLocationType Type, int Size, int Align = -1)
        {
            if ((Type & x86DataLocationType.General) != 0)
            {
                var Sequence = x86CallConv.AllocationSequence.GRegisters;
                var Mask     = new x86RegisterMask(Size);
                var HighMask = new x86RegisterMask(1, Size);

                if ((Type & x86DataLocationType.OneByte) == 0)
                {
                    for (var i = 0; i < Sequence.Length; i++)
                    {
                        var Reg = Sequence[i];
                        if (Arch.IsGRegisterExists(Reg, Mask) && !Arch.IsGRegisterExists(Reg, 0, 1) && !GRegisters.IsFree(Reg, Mask))
                        {
                            return(new x86GRegLocation(Arch, Reg, Mask));
                        }
                    }

                    for (var i = 0; i < Sequence.Length; i++)
                    {
                        var Reg = Sequence[i];
                        if (Arch.IsGRegisterExists(Reg, Mask) && !GRegisters.IsFree(Reg, Mask))
                        {
                            return(new x86GRegLocation(Arch, Reg, Mask));
                        }
                    }
                }
                else
                {
                    for (var i = 0; i < Sequence.Length; i++)
                    {
                        var Reg = Sequence[i];
                        if (Arch.IsGRegisterExists(Reg, Mask) && Arch.IsGRegisterExists(Reg, 0, 1) && !GRegisters.IsFree(Reg, Mask))
                        {
                            return(new x86GRegLocation(Arch, Reg, Mask));
                        }
                    }
                }
            }

            if ((Type & x86DataLocationType.SSEReg) != 0)
            {
                var Sequence = x86CallConv.AllocationSequence.SSERegisters;
                for (var i = 0; i < Sequence.Length; i++)
                {
                    var Reg = Sequence[i];
                    if (Reg < Arch.RegCount && !SSERegisters.IsFree(Reg))
                    {
                        return(new x86SSERegLocation(Arch, Reg, Size));
                    }
                }
            }

            if ((Type & x86DataLocationType.Memory) != 0)
            {
                StackOffset = DataStoring.AlignWithDecrease(StackOffset - Size, Align);
                return(new x86StackLocation(Arch, FuncScope, StackOffset, Size, false));
            }

            return(null);
        }