Mosa.Compiler.Framework.InstructionNode.SetOperand C# (CSharp) Method

SetOperand() public method

Sets the operand by index.
public SetOperand ( int index, Operand operand ) : void
index int The index.
operand Operand The operand.
return void
        public void SetOperand(int index, Operand operand)
        {
            switch (index)
            {
                case 0: Operand1 = operand; return;
                case 1: Operand2 = operand; return;
                case 2: Operand3 = operand; return;
                default:
                    {
                        Operand current = GetAdditionalOperand(index);
                        if (current == operand) return;
                        if (current != null)
                        {
                            current.Uses.Remove(this);
                        }

                        if (operand != null)
                        {
                            if (operand.IsVirtualRegister || operand.IsOnStack)
                            {
                                operand.Uses.Add(this);
                            }
                        }

                        SetAdditionalOperand(index, operand);
                        return;
                    }
            }
        }

Usage Example

Esempio n. 1
0
        /// <summary>
        /// Emits the constant operands.
        /// </summary>
        /// <param name="node">The node.</param>
        protected void EmitFloatingPointConstants(InstructionNode node)
        {
            for (int i = 0; i < node.OperandCount; i++)
            {
                var operand = node.GetOperand(i);

                if (operand == null || !operand.IsConstant || !operand.IsR)
                    continue;

                if (operand.IsUnresolvedConstant)
                    continue;

                var v1 = AllocateVirtualRegister(operand.Type);

                var symbol = (operand.IsR4) ?
                    MethodCompiler.Linker.GetConstantSymbol(operand.ConstantSingleFloatingPoint)
                    : MethodCompiler.Linker.GetConstantSymbol(operand.ConstantDoubleFloatingPoint);

                var s1 = Operand.CreateLabel(operand.Type, symbol.Name);

                var before = new Context(node).InsertBefore();

                if (operand.IsR4)
                {
                    before.SetInstruction(X86.MovssLoad, InstructionSize.Size32, v1, s1, ConstantZero);
                }
                else
                {
                    before.SetInstruction(X86.MovsdLoad, InstructionSize.Size64, v1, s1, ConstantZero);
                }

                node.SetOperand(i, v1);
            }
        }