예제 #1
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="operandCount">The operand count.</param>
 /// <param name="resultCount">The result count.</param>
 public InstructionNode(BaseInstruction instruction, int operandCount, byte resultCount)
 {
     Instruction = instruction;
     OperandCount = operandCount;
     ResultCount = resultCount;
     Size = InstructionSize.None;
 }
예제 #2
0
        public void Save(BaseInstruction instruction)
        {
            var client = new RedisClient();
            var key = new InstructionKeys ().GetKey (instruction.Id);

            var json = instruction.ToJson ();
            client.Set(key, json);

            var idManager = new InstructionIdManager ();
            idManager.Add (instruction);
        }
        public void Add(BaseInstruction instruction)
        {
            var key = new InstructionKeys ().GetIdsKey (instruction.TargetType, instruction.TargetId);

            var client = new RedisClient ();

            var stringToAppend = instruction.Id.ToString();

            if (client.Exists (key))
                stringToAppend = "." + stringToAppend;

            client.Append (key, stringToAppend);
        }
        protected void TransformLoadInstruction(Context context, BaseInstruction loadUp, BaseInstruction loadUpImm, BaseInstruction loadDownImm, Operand result, Operand operand1, Operand operand2)
        {
            BaseInstruction instruction;

            operand1 = MoveConstantToRegister(context, operand1);

            if (operand2.IsResolvedConstant)
            {
                if (operand2.ConstantUnsignedLongInteger >= 0 && operand2.ConstantSignedInteger <= (1 << 13))
                {
                    instruction = loadUpImm;
                }
                else if (operand2.ConstantUnsignedLongInteger < 0 && -operand2.ConstantSignedInteger <= (1 << 13))
                {
                    instruction = loadDownImm;
                    operand2    = CreateConstant((uint)-operand2.ConstantSignedInteger);
                }
                else
                {
                    instruction = loadDownImm;
                    operand2    = MoveConstantToRegister(context, operand2);
                }
            }
            else if (operand2.IsUnresolvedConstant)
            {
                instruction = loadUp;
                operand2    = MoveConstantToRegister(context, operand2);
            }
            else
            {
                instruction = loadUpImm;
            }

            context.SetInstruction(instruction, ConditionCode.Always, result, operand1, operand2);
        }
예제 #5
0
 public Node(BaseInstruction instruction, ConditionCode condition)
 {
     NodeType      = NodeType.Instruction;
     Instruction   = instruction;
     ConditionCode = condition;
 }
예제 #6
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 public InstructionNode(BaseInstruction instruction)
     : this(instruction, instruction.DefaultOperandCount, instruction.DefaultResultCount)
 {
 }
예제 #7
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="condition">The condition.</param>
 /// <param name="block">The block.</param>
 public void SetInstruction(BaseInstruction instruction, ConditionCode condition, BasicBlock block)
 {
     SetInstruction(instruction);
     ConditionCode = condition;
     AddBranchTarget(block);
 }
예제 #8
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="condition">The condition.</param>
 /// <param name="block">The block.</param>
 public InstructionNode(BaseInstruction instruction, ConditionCode condition, BasicBlock block)
     : this(instruction, condition)
 {
     AddBranchTarget(block);
 }
예제 #9
0
 private bool IsCommutative(BaseInstruction instruction)
 {
     return(instruction == X86.Addsd || instruction == X86.Addss || instruction == X86.Mulsd || instruction == X86.Mulss);
 }
예제 #10
0
 public String DecompileInstruction_C(BaseInstruction BI)
 {
     return(DecompileInstruction(BI.GetCUsage(), BI.CStringify, BI.C));
 }
예제 #11
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="result">The result.</param>
 /// <param name="result2">The result2.</param>
 /// <param name="operand1">The operand1.</param>
 public void SetInstruction2(BaseInstruction instruction, Operand result, Operand result2, Operand operand1)
 {
     SetInstruction(instruction, 1, 2);
     Result = result;
     Result2 = result2;
     Operand1 = operand1;
 }
예제 #12
0
 public String DecompileInstruction_A(BaseInstruction BI)
 {
     return(DecompileInstruction(BI.GetAUsage(), BI.AStringify, BI.A));
 }
예제 #13
0
 public String DecompileInstruction_B(BaseInstruction BI)
 {
     return(DecompileInstruction(BI.GetBUsage(), BI.BStringify, BI.B));
 }
예제 #14
0
 public String StringifyInstruction_C(BaseInstruction BI)
 {
     return(StringifyInstruction(BI.GetCUsage(), BI.CStringify, BI.C));
 }
예제 #15
0
 public String StringifyInstruction_B(BaseInstruction BI)
 {
     return(StringifyInstruction(BI.GetBUsage(), BI.BStringify, BI.B));
 }
예제 #16
0
 public String StringifyInstruction_A(BaseInstruction BI)
 {
     return(StringifyInstruction(BI.GetAUsage(), BI.AStringify, BI.A));
 }
예제 #17
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="condition">The condition.</param>
 /// <param name="updateStatus">if set to <c>true</c> [update status].</param>
 /// <param name="result">The result.</param>
 /// <param name="operand1">The operand1.</param>
 /// <param name="operand2">The operand2.</param>
 public void SetInstruction(BaseInstruction instruction, ConditionCode condition, bool updateStatus, Operand result, Operand operand1, Operand operand2)
 {
     SetInstruction(instruction, 2, (byte)((result == null) ? 0 : 1));
     Result = result;
     Operand1 = operand1;
     Operand2 = operand2;
     ConditionCode = condition;
     UpdateStatus = updateStatus;
 }
예제 #18
0
 protected static InstructionNode GetPreviousNodeUntil(Context context, BaseInstruction untilInstruction, int window, Operand operand1 = null, Operand operand2 = null)
 {
     return(GetPreviousNodeUntil(context, untilInstruction, window, out _, operand1, operand2));
 }
예제 #19
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="size">The size.</param>
 /// <param name="result">The result.</param>
 /// <param name="operand1">The operand1.</param>
 /// <param name="operand2">The operand2.</param>
 /// <param name="operand3">The operand3.</param>
 public void SetInstruction(BaseInstruction instruction, InstructionSize size, Operand result, Operand operand1, Operand operand2, Operand operand3)
 {
     SetInstruction(instruction, result, operand1, operand2, operand3);
     Size = size;
 }
예제 #20
0
 protected static InstructionNode GetNextNodeUntil(Context context, BaseInstruction untilInstruction, int window, Operand operand = null)
 {
     return(GetNextNodeUntil(context, untilInstruction, window, out _, operand));
 }
예제 #21
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="result">The result.</param>
 /// <param name="result2">The result2.</param>
 /// <param name="operand1">The operand1.</param>
 /// <param name="operand2">The operand2.</param>
 /// <param name="operand3">The operand3.</param>
 public void SetInstruction2(BaseInstruction instruction, Operand result, Operand result2, Operand operand1, Operand operand2, Operand operand3)
 {
     SetInstruction(instruction, 3, 2);
     Result = result;
     Result2 = result2;
     Operand1 = operand1;
     Operand2 = operand2;
     Operand3 = operand3;
 }
예제 #22
0
        protected void TransformInstruction(Context context, BaseInstruction virtualInstruction, BaseInstruction immediateInstruction, Operand result, StatusRegister statusRegister, Operand operand1)
        {
            if (operand1.IsConstant)
            {
                operand1 = CreateRotatedImmediateOperand(context, operand1);
            }

            if (operand1.IsVirtualRegister || operand1.IsCPURegister)
            {
                context.SetInstruction(virtualInstruction, result, operand1);
            }
            else if (operand1.IsResolvedConstant)
            {
                context.SetInstruction(immediateInstruction, result, operand1);
            }
            else
            {
                throw new CompilerException("Error at {context} in {Method}");
            }
        }
예제 #23
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="updateStatus">if set to <c>true</c> [update status].</param>
 /// <param name="result">The result.</param>
 public InstructionNode(BaseInstruction instruction, bool updateStatus, Operand result)
     : this(instruction, result)
 {
     UpdateStatus = updateStatus;
 }
예제 #24
0
        protected void TransformInstruction(Context context, BaseInstruction virtualInstruction, BaseInstruction immediateInstruction, Operand result, StatusRegister statusRegister, Operand operand1, Operand operand2)
        {
            if (operand1.IsConstant)
            {
                if (virtualInstruction.IsCommutative && !operand2.IsConstant)
                {
                    var temp = operand1;
                    operand1 = operand2;
                    operand2 = temp;
                }
                else
                {
                    operand1 = MoveConstantToRegister(context, operand1);
                }
            }

            if (operand2.IsConstant)
            {
                operand2 = CreateRotatedImmediateOperand(context, operand2);
            }

            Debug.Assert(operand1.IsVirtualRegister || operand1.IsCPURegister);

            if (operand2.IsVirtualRegister || operand2.IsCPURegister)
            {
                context.SetInstruction(virtualInstruction, statusRegister, result, operand1, operand2);
            }
            else if (operand2.IsResolvedConstant)
            {
                context.SetInstruction(immediateInstruction, statusRegister, result, operand1, operand2);
            }
            else
            {
                throw new CompilerException("Error at {context} in {Method}");
            }
        }
예제 #25
0
        /// <summary>
        /// Sets the instruction.
        /// </summary>
        /// <param name="instruction">The instruction.</param>
        /// <param name="operandCount">The operand count.</param>
        /// <param name="resultCount">The result count.</param>
        public void SetInstruction(BaseInstruction instruction, int operandCount, byte resultCount)
        {
            Debug.Assert(!IsBlockStartInstruction);
            Debug.Assert(!IsBlockEndInstruction);

            int label = Label;
            var block = Block;

            Clear();

            Instruction = instruction;
            OperandCount = operandCount;
            ResultCount = resultCount;
            Label = label;
            Size = InstructionSize.None;
            Block = block;

            //Block.DebugCheck();
        }
예제 #26
0
        protected void TransformInstructionXXX(Context context, BaseInstruction virtualInstruction, BaseInstruction immediateInstruction, Operand result, StatusRegister statusRegister, Operand operand1, Operand operand2)
        {
            // TODO!!!!!

            // AddFloatR4 result, operand1, operand2

            // TODO: (across all float instructions)
            // if operand1 is constant
            // if resolved & specific constant, then AdfImm
            // else if resolved & non-specific constant, then LoadConstant, adf
            // else if unresolved, throw not implemented

            if (operand1.IsConstant)
            {
                if (virtualInstruction.IsCommutative && !operand2.IsConstant)
                {
                    var temp = operand1;
                    operand1 = operand2;
                    operand2 = temp;
                }
                else
                {
                    operand1 = MoveConstantToRegister(context, operand1);
                }
            }

            if (operand2.IsConstant)
            {
                operand2 = CreateRotatedImmediateOperand(context, operand2);
            }

            Debug.Assert(operand1.IsVirtualRegister || operand1.IsCPURegister);

            if (operand2.IsVirtualRegister || operand2.IsCPURegister)
            {
                context.SetInstruction(virtualInstruction, statusRegister, result, operand1, operand2);
            }
            else if (operand2.IsResolvedConstant)
            {
                context.SetInstruction(immediateInstruction, statusRegister, result, operand1, operand2);
            }
            else
            {
                throw new CompilerException("Error at {context} in {Method}");
            }
        }
예제 #27
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="block1">The block1.</param>
 /// <param name="block2">The block2.</param>
 public void SetInstruction(BaseInstruction instruction, BasicBlock block1, BasicBlock block2)
 {
     SetInstruction(instruction);
     AddBranchTarget(block1);
     AddBranchTarget(block2);
 }
예제 #28
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="target">The target.</param>
 public InstructionNode(BaseInstruction instruction, MosaMethod target)
     : this(instruction)
 {
     InvokeMethod = target;
 }
예제 #29
0
 private static void Replace(Context context, BaseInstruction floatingPointInstruction, BaseInstruction signedInstruction, BaseInstruction unsignedInstruction)
 {
     if (context.Result.IsR)
     {
         context.ReplaceInstructionOnly(floatingPointInstruction);
     }
     else if (context.Result.IsUnsigned)
     {
         context.ReplaceInstructionOnly(unsignedInstruction);
     }
     else
     {
         context.ReplaceInstructionOnly(signedInstruction);
     }
 }
예제 #30
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="condition">The condition.</param>
 /// <param name="result">The result.</param>
 public void SetInstruction(BaseInstruction instruction, ConditionCode condition, Operand result)
 {
     SetInstruction(instruction, 0, (byte)((result == null) ? 0 : 1));
     Result = result;
     ConditionCode = condition;
 }
예제 #31
0
        protected void TransformExtend(Context context, BaseInstruction instruction, Operand result, Operand operand1)
        {
            operand1 = MoveConstantToRegister(context, operand1);

            context.SetInstruction(instruction, ConditionCode.Always, result, operand1);
        }
예제 #32
0
 public Node(BaseInstruction instruction)
 {
     NodeType    = NodeType.Instruction;
     Instruction = instruction;
 }
예제 #33
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="result">The result.</param>
 /// <param name="operand1">The operand1.</param>
 public void SetInstruction(BaseInstruction instruction, bool updateStatus, Operand result, Operand operand1)
 {
     SetInstruction(instruction, 1, (byte)((result == null) ? 0 : 1));
     Result = result;
     Operand1 = operand1;
     UpdateStatus = updateStatus;
 }
예제 #34
0
        protected void TransformStoreInstruction(Context context, BaseInstruction storeUp, BaseInstruction storeUpImm, BaseInstruction loadDownImm, Operand operand1, Operand operand2, Operand operand3)
        {
            BaseInstruction instruction;

            operand1 = MoveConstantToRegister(context, operand1);

            if (operand2.IsResolvedConstant)
            {
                if (operand2.ConstantUnsigned64 >= 0 && operand2.ConstantSigned32 <= (1 << 13))
                {
                    instruction = storeUpImm;
                }
                else if (operand2.ConstantUnsigned64 < 0 && -operand2.ConstantSigned32 <= (1 << 13))
                {
                    instruction = loadDownImm;
                    operand2    = CreateConstant((uint)-operand2.ConstantSigned32);
                }
                else
                {
                    instruction = loadDownImm;
                    operand2    = MoveConstantToRegister(context, operand2);
                }
            }
            else if (operand2.IsUnresolvedConstant)
            {
                instruction = storeUp;
                operand2    = MoveConstantToRegister(context, operand2);
            }
            else
            {
                instruction = storeUpImm;
            }

            context.SetInstruction(instruction, ConditionCode.Always, null, operand1, operand2, operand3);
        }
예제 #35
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="condition">The condition.</param>
 /// <param name="result">The result.</param>
 /// <param name="operand1">The operand1.</param>
 /// <param name="operand2">The operand2.</param>
 /// <param name="block">The block.</param>
 public void SetInstruction(BaseInstruction instruction, ConditionCode condition, Operand result, Operand operand1, Operand operand2, BasicBlock block)
 {
     SetInstruction(instruction, 2, (byte)((result == null) ? 0 : 1));
     Result = result;
     Operand1 = operand1;
     Operand2 = operand2;
     ConditionCode = condition;
     AddBranchTarget(block);
 }
예제 #36
0
        protected void Inline(InstructionNode callSiteNode, BasicBlocks blocks)
        {
            var mapBlocks = new Dictionary <BasicBlock, BasicBlock>(blocks.Count);
            var map       = new Dictionary <Operand, Operand>();

            var nextBlock = Split(callSiteNode);

            // create basic blocks
            foreach (var block in blocks)
            {
                var newBlock = CreateNewBlock();
                mapBlocks.Add(block, newBlock);
            }

            // copy instructions
            foreach (var block in blocks)
            {
                var newBlock = mapBlocks[block];

                for (var node = block.AfterFirst; !node.IsBlockEndInstruction; node = node.Next)
                {
                    if (node.IsEmpty)
                    {
                        continue;
                    }

                    if (node.Instruction == IRInstruction.Prologue)
                    {
                        continue;
                    }

                    if (node.Instruction == IRInstruction.Epilogue)
                    {
                        newBlock.BeforeLast.Insert(new InstructionNode(IRInstruction.Jmp, nextBlock));
                        continue;
                    }

                    if (node.Instruction == IRInstruction.SetReturn32 ||
                        node.Instruction == IRInstruction.SetReturn64 ||
                        node.Instruction == IRInstruction.SetReturnR4 ||
                        node.Instruction == IRInstruction.SetReturnR8 ||
                        node.Instruction == IRInstruction.SetReturnCompound)
                    {
                        if (callSiteNode.Result != null)
                        {
                            var newOperand = Map(node.Operand1, map, callSiteNode);

                            BaseInstruction moveInstruction = null;

                            if (node.Instruction == IRInstruction.SetReturn32)
                            {
                                moveInstruction = IRInstruction.MoveInt32;
                            }
                            else if (node.Instruction == IRInstruction.SetReturn64)
                            {
                                moveInstruction = IRInstruction.MoveInt64;
                            }
                            else if (node.Instruction == IRInstruction.SetReturnR4)
                            {
                                moveInstruction = IRInstruction.MoveFloatR4;
                            }
                            else if (node.Instruction == IRInstruction.SetReturnR8)
                            {
                                moveInstruction = IRInstruction.MoveFloatR8;
                            }
                            else if (node.Instruction == IRInstruction.SetReturnCompound)
                            {
                                moveInstruction = IRInstruction.MoveCompound;
                            }

                            Debug.Assert(moveInstruction != null);

                            var moveNode = new InstructionNode(moveInstruction, callSiteNode.Result, newOperand);

                            newBlock.BeforeLast.Insert(moveNode);
                        }

                        continue;
                    }

                    var newNode = new InstructionNode(node.Instruction, node.OperandCount, node.ResultCount)
                    {
                        ConditionCode = node.ConditionCode,
                        Label         = callSiteNode.Label
                    };

                    if (node.BranchTargets != null)
                    {
                        // copy targets
                        foreach (var target in node.BranchTargets)
                        {
                            newNode.AddBranchTarget(mapBlocks[target]);
                        }
                    }

                    // copy results
                    for (int i = 0; i < node.ResultCount; i++)
                    {
                        var op = node.GetResult(i);

                        var newOp = Map(op, map, callSiteNode);

                        newNode.SetResult(i, newOp);
                    }

                    // copy operands
                    for (int i = 0; i < node.OperandCount; i++)
                    {
                        var op = node.GetOperand(i);

                        var newOp = Map(op, map, callSiteNode);

                        newNode.SetOperand(i, newOp);
                    }

                    // copy other
                    if (node.MosaType != null)
                    {
                        newNode.MosaType = node.MosaType;
                    }
                    if (node.MosaField != null)
                    {
                        newNode.MosaField = node.MosaField;
                    }

                    UpdateParameterInstructions(newNode);

                    newBlock.BeforeLast.Insert(newNode);
                }
            }

            var prologue = mapBlocks[blocks.PrologueBlock];

            var callSiteOperands = callSiteNode.GetOperands();

            if (callSiteOperands.Count > 1)
            {
                var context = new Context(prologue);

                for (int i = 1; i < callSiteOperands.Count; i++)
                {
                    var operand = callSiteOperands[i];

                    if (!operand.IsVirtualRegister || operand.Low == null)
                    {
                        continue;
                    }

                    context.AppendInstruction(IRInstruction.GetLow64, operand.Low, operand);
                    context.AppendInstruction(IRInstruction.GetHigh64, operand.High, operand);
                }
            }

            callSiteNode.SetInstruction(IRInstruction.Jmp, prologue);
        }
예제 #37
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="result">The result.</param>
 /// <param name="operand1">The operand1.</param>
 /// <param name="operand2">The operand2.</param>
 /// <param name="operand3">The operand3.</param>
 public void SetInstruction(BaseInstruction instruction, Operand result, Operand operand1, Operand operand2, Operand operand3)
 {
     SetInstruction(instruction, 3, (byte)((result == null) ? 0 : 1));
     Result = result;
     Operand1 = operand1;
     Operand2 = operand2;
     Operand3 = operand3;
 }
예제 #38
0
 protected override bool IsThreeTwoAddressRequired(BaseInstruction instruction)
 {
     return((instruction as X86Instruction)?.ThreeTwoAddressConversion == true);
 }
예제 #39
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="result">The result.</param>
 /// <param name="result2">The result2.</param>
 public void SetInstruction2(BaseInstruction instruction, Operand result, Operand result2)
 {
     SetInstruction(instruction, 1, 2);
     Result = result;
     Result2 = result2;
 }
 protected override bool IsMov(BaseInstruction instruction)
 {
     return(instruction == X64.Mov32 || instruction == X64.Mov64 || instruction == X64.Movsd || instruction == X64.Movss);
 }
예제 #41
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="block1">The block1.</param>
 /// <param name="block2">The block2.</param>
 public InstructionNode(BaseInstruction instruction, BasicBlock block1, BasicBlock block2)
     : this(instruction)
 {
     AddBranchTarget(block1);
     AddBranchTarget(block2);
 }
예제 #42
0
 public void Add(BaseInstruction instruction)
 {
     _expressions.Add(instruction);
 }
예제 #43
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="condition">The condition.</param>
 public InstructionNode(BaseInstruction instruction, ConditionCode condition)
     : this(instruction)
 {
     ConditionCode = condition;
 }
예제 #44
0
 /// <summary>
 /// Determines whether [is instruction move] [the specified instruction].
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <returns></returns>
 public override bool IsInstructionMove(BaseInstruction instruction)
 {
     return(instruction == X86.Mov32 || instruction == X86.Movsd || instruction == X86.Movss);
 }
예제 #45
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="result">The result.</param>
 public InstructionNode(BaseInstruction instruction, Operand result)
     : this(instruction, 0, 1)
 {
     Result = result;
 }
예제 #46
0
 /// <summary>
 /// Determines whether [is instruction move] [the specified instruction].
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <returns></returns>
 public override bool IsInstructionMove(BaseInstruction instruction)
 {
     // TODO
     return(false);
 }
예제 #47
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="result">The result.</param>
 /// <param name="operand1">The operand1.</param>
 public InstructionNode(BaseInstruction instruction, Operand result, Operand operand1)
     : this(instruction, 1, 1)
 {
     Result = result;
     Operand1 = operand1;
 }
예제 #48
0
 protected override void Setup()
 {
     loadInstruction = Select(IRInstruction.LoadInt32, IRInstruction.LoadInt64);
     moveInstruction = Select(IRInstruction.MoveInt32, IRInstruction.MoveInt64);
 }
예제 #49
0
 /// <summary>
 /// Replaces the instruction only.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 public void ReplaceInstructionOnly(BaseInstruction instruction)
 {
     Instruction = instruction;
 }
        private bool IntegerOperation(BaseInstruction instruction, ulong operand1, ulong operand2, ConditionCode conditionCode, out ulong result)
        {
            if (instruction == IRInstruction.AddSigned || instruction == IRInstruction.AddUnsigned)
            {
                result = operand1 + operand2;
                return(true);
            }
            else if (instruction == IRInstruction.SubSigned || instruction == IRInstruction.SubUnsigned)
            {
                result = operand1 - operand2;
                return(true);
            }
            else if (instruction == IRInstruction.MulUnsigned || instruction == IRInstruction.MulSigned)
            {
                result = operand1 * operand2;
                return(true);
            }
            else if (instruction == IRInstruction.DivUnsigned && operand2 != 0)
            {
                result = operand1 / operand2;
                return(true);
            }
            else if (instruction == IRInstruction.DivSigned && operand2 != 0)
            {
                result = (ulong)((long)operand1 / (long)operand2);
                return(true);
            }
            else if (instruction == IRInstruction.RemUnsigned && operand2 != 0)
            {
                result = operand1 % operand2;
                return(true);
            }
            else if (instruction == IRInstruction.RemSigned && operand2 != 0)
            {
                result = (ulong)((long)operand1 % (long)operand2);
                return(true);
            }
            else if (instruction == IRInstruction.ArithmeticShiftRight)
            {
                result = (ulong)(((long)operand1) >> (int)operand2);
                return(true);
            }
            else if (instruction == IRInstruction.ShiftRight)
            {
                result = operand1 >> (int)operand2;
                return(true);
            }
            else if (instruction == IRInstruction.ShiftLeft)
            {
                result = operand1 << (int)operand2;
                return(true);
            }
            else if (instruction == IRInstruction.CompareInteger)
            {
                bool?compare = Compare(operand1, operand2, conditionCode);

                if (compare.HasValue)
                {
                    result = compare.Value ? 1u : 0u;
                    return(true);
                }
            }

            result = 0;
            return(false);
        }
예제 #51
0
        /// <summary>
        /// Sets the instruction.
        /// </summary>
        /// <param name="instruction">The instruction.</param>
        public void SetInstruction(BaseInstruction instruction)
        {
            if (instruction != null)
                SetInstruction(instruction, instruction.DefaultOperandCount, instruction.DefaultResultCount);
            else
                SetInstruction(null, 0, 0);

            //Block.DebugCheck();
        }
예제 #52
0
 public BaseTransformation(BaseInstruction instruction)
     : this()
 {
     Instruction = instruction;
 }
예제 #53
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="target">The target.</param>
 public void SetInstruction(BaseInstruction instruction, MosaMethod target)
 {
     SetInstruction(instruction);
     InvokeMethod = target;
 }
예제 #54
0
 public BaseTransformation(BaseInstruction instruction, bool log = false)
     : this()
 {
     Instruction = instruction;
     Log         = log;
 }
예제 #55
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="condition">The condition.</param>
 public void SetInstruction(BaseInstruction instruction, ConditionCode condition)
 {
     SetInstruction(instruction);
     ConditionCode = condition;
 }
예제 #56
0
 /// <summary>
 /// Determines whether [is instruction move] [the specified instruction].
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <returns></returns>
 public override bool IsInstructionMove(BaseInstruction instruction)
 {
     return(instruction == ARMv6.Mov);
 }
예제 #57
0
 /// <summary>
 /// Sets the instruction.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <param name="result">The result.</param>
 public void SetInstruction(BaseInstruction instruction, Operand result)
 {
     SetInstruction(instruction, 0, 1);
     Result = result;
 }
 protected abstract bool IsNop(BaseInstruction instruction);
예제 #59
0
 /// <summary>
 /// Determines whether the specified instruction is commutative.
 /// </summary>
 /// <param name="instruction">The instruction.</param>
 /// <returns>
 /// 	<c>true</c> if the specified instruction is commutative; otherwise, <c>false</c>.
 /// </returns>
 private static bool IsCommutative(BaseInstruction instruction)
 {
     return (instruction is CIL.AddInstruction) ||
            (instruction is CIL.MulInstruction) ||
            (instruction is IR.LogicalAnd) ||
            (instruction is IR.LogicalOr) ||
            (instruction is IR.LogicalXor);
 }
 protected abstract bool IsMov(BaseInstruction instruction);