Esempio n. 1
0
        public x86DataLocation Deallocate(x86DataLocationType Type, int Size, int Align = -1)
        {
            var Ret = GetAllocated(Type, Size, Align);

            SetUnused(Ret);
            return(Ret);
        }
Esempio n. 2
0
        public x86DataLocation GetPosition(FunctionScope Scope, int Size, int Align = 1,
                                           x86DataLocationType PositionTypes        = x86DataLocationType.GRegMem)
        {
            if ((PositionTypes & x86DataLocationType.General) != 0)
            {
                if (CanAllocGReg(Size))
                {
                    return(GetGRegister(Size));
                }
            }

            if ((PositionTypes & x86DataLocationType.SSEReg) != 0)
            {
                if (CanAllocSSEReg() && Size <= Arch.SSERegSize)
                {
                    return(GetSSERegister(Arch.SSERegSize));
                }
            }

            if ((PositionTypes & x86DataLocationType.Memory) != 0)
            {
                return(GetStackPosition(Scope, Size, Align));
            }

            return(null);
        }
Esempio n. 3
0
        public x86DataLocation Allocate(Type T, x86DataLocationType DataCalcPos = x86DataLocationType.None, x86DataList CantBe = null)
        {
            if (DataCalcPos == x86DataLocationType.None)
            {
                DataCalcPos = x86Identifiers.GetPossibleLocations(T);
            }

            return(Allocate(T.Size, T.Align, DataCalcPos, CantBe));
        }
Esempio n. 4
0
        private x86DataLocation AllocMultiPos(int Size, int Align, x86DataLocationType DataCalcPos, x86DataList CantBe, int PartSize)
        {
            var Count     = Size / PartSize;
            var Positions = new x86DataLocation[Count];

            for (var i = 0; i < Count; i++)
            {
                Positions[i] = Allocate(Arch.RegSize, Align, DataCalcPos, CantBe);
                if (Positions[i] == null)
                {
                    return(null);
                }
            }

            return(new x86MultiLocation(Arch, Size, Positions));
        }
Esempio n. 5
0
        public void Reset()
        {
            FPUItemsOnStack      = 0;
            UsedFPUStack         = 0;
            SameAllocationAsType = x86SameAllocationAsType.None;
            Flags             &= x86NodeFlags.LeftByReset;
            DataCalcPos        = x86DataLocationType.None;
            PreferredOutput    = null;
            UsedData           = null;
            UsedDataBySelf     = null;
            TempCantBe         = null;
            PreAllocate        = null;
            Properties         = new x86DataProperties();
            NeededTempByPlugin = new x86NeededTempData();
            Output             = null;

            ParameterBytes    = 0;
            OriginalShiftSize = 0;
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        public x86DataLocation Allocate(int Size, int Align, x86DataLocationType DataCalcPos = x86DataLocationType.GRegMem,
                                        x86DataList CantBe = null)
        {
            if ((DataCalcPos & x86DataLocationType.SSEReg) != 0)
            {
                if (Size > Arch.SSERegSize)
                {
                    if (SSERegAvaiable())
                    {
                        var Ret = AllocMultiPos(Size, Align, DataCalcPos, CantBe, 16);
                        if (Ret != null)
                        {
                            return(Ret);
                        }
                    }
                }
                else
                {
                    var SSERegList = CantBe != null ? CantBe.SSERegisters : new x86RegisterList();
                    var Ret        = AllocSSERegister(16, SSERegList);
                    if (Ret != null)
                    {
                        return(Ret);
                    }
                }
            }

            if ((DataCalcPos & x86DataLocationType.General) != 0)
            {
                if (Size > Arch.RegSize)
                {
                    if (RegAvaiable())
                    {
                        var Ret = AllocMultiPos(Size, Align, DataCalcPos, CantBe, Arch.RegSize);
                        if (Ret != null)
                        {
                            return(Ret);
                        }
                    }
                }
                else
                {
                    var GRegList = CantBe != null ? CantBe.GRegisters : new x86GRegisterList();
                    var Ret      = AllocGRegister(Size, (DataCalcPos & x86DataLocationType.OneByte) != 0, GRegList);
                    if (Ret != null)
                    {
                        return(Ret);
                    }
                }
            }

            if ((DataCalcPos & x86DataLocationType.Memory) != 0)
            {
                var Ret = AllocMemory(Size, Align);
                if (Ret != null)
                {
                    return(Ret);
                }
            }

            return(null);
        }