当前位置: 首页>>代码示例>>C#>>正文


C# InstructionNode.GetOperand方法代码示例

本文整理汇总了C#中Mosa.Compiler.Framework.InstructionNode.GetOperand方法的典型用法代码示例。如果您正苦于以下问题:C# InstructionNode.GetOperand方法的具体用法?C# InstructionNode.GetOperand怎么用?C# InstructionNode.GetOperand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mosa.Compiler.Framework.InstructionNode的用法示例。


在下文中一共展示了InstructionNode.GetOperand方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CmpXchg

        private static void CmpXchg(InstructionNode node, MachineCodeEmitter emitter)
        {
            Debug.Assert(node.Result.IsRegister);
            Debug.Assert(node.Operand1.IsRegister);
            Debug.Assert(node.Operand2.IsRegister);
            Debug.Assert(node.GetOperand(3).IsRegister);
            Debug.Assert(node.Result.Register == GeneralPurposeRegister.EAX);
            Debug.Assert(node.Operand1.Register == GeneralPurposeRegister.EAX);
            Debug.Assert(node.ResultCount == 1);

            var linkreference = node.Operand2.IsLabel || node.Operand2.IsField || node.Operand2.IsSymbol;

            // Compare EAX with r/m32. If equal, ZF is set and r32 is loaded into r/m32.
            // Else, clear ZF and load r/m32 into EAX.

            // memory, register 0000 1111 : 1011 000w : mod reg r/m
            var opcode = new OpcodeEncoder()
                .AppendConditionalPrefix(0x66, node.Size == InstructionSize.Size16)  // 8:prefix: 16bit
                .AppendNibble(Bits.b0000)                                       // 4:opcode
                .AppendNibble(Bits.b1111)                                       // 4:opcode
                .AppendNibble(Bits.b1011)                                       // 4:opcode
                .Append3Bits(Bits.b000)                                         // 3:opcode
                .AppendWidthBit(node.Size != InstructionSize.Size8)             // 1:width
                .ModRegRMSIBDisplacement(node.GetOperand(3), node.Operand2, node.Operand3) // Mod-Reg-RM-?SIB-?Displacement
                .AppendConditionalIntegerValue(0, linkreference);               // 32:memory

            if (linkreference)
                emitter.Emit(opcode, node.Operand1, (opcode.Size - 32) / 8);
            else
                emitter.Emit(opcode);
        }
开发者ID:Zahovay,项目名称:MOSA-Project,代码行数:31,代码来源:CmpXchgLoad.cs

示例2: EmitFloatingPointConstants

        /// <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);
            }
        }
开发者ID:tgiphil,项目名称:MOSA-Project,代码行数:38,代码来源:FloatingPointStage.cs

示例3: ToString

        /// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <param name="node">The context.</param>
        /// <returns>
        /// A <see cref="System.String" /> that represents this instance.
        /// </returns>
        public string ToString(InstructionNode node)
        {
            var sb = new StringBuilder();

            sb.AppendFormat("L_{0:X4}", node.Label);

            if (node.Marked)
                sb.Append('*');
            else
                sb.Append(' ');

            sb.Append(ToString());

            var size = GetSizeString(node.Size);

            if (size != string.Empty)
                sb.Append("/" + size);

            if (node.ConditionCode != ConditionCode.Undefined)
            {
                sb.Append(" [");
                sb.Append(GetConditionString(node.ConditionCode));
                sb.Append("]");
            }

            if (node.MosaType != null)
            {
                sb.Append(" [[");
                sb.Append(node.MosaType.FullName);
                sb.Append("]]");
            }

            if (node.MosaField != null)
            {
                sb.Append(" [[");
                sb.Append(node.MosaField.FullName);
                sb.Append("]]");
            }

            string mod = GetModifier(node);
            if (mod != null)
            {
                sb.Append(" [");
                sb.Append(mod);
                sb.Append("]");
            }

            for (int i = 0; i < node.ResultCount; i++)
            {
                var op = node.GetResult(i);
                sb.Append(" ");
                sb.Append(op == null ? "[NULL]" : op.ToString());
                sb.Append(",");
            }

            if (node.ResultCount > 0)
            {
                sb.Length = sb.Length - 1;
            }

            if (node.ResultCount > 0 && node.OperandCount > 0)
            {
                sb.Append(" <=");
            }

            for (int i = 0; i < node.OperandCount; i++)
            {
                var op = node.GetOperand(i);
                sb.Append(" ");
                sb.Append(op == null ? "[NULL]" : op.ToString());
                sb.Append(",");
            }

            if (node.OperandCount > 0)
            {
                sb.Length = sb.Length - 1;
            }

            if (node.BranchTargets != null)
            {
                sb.Append(' ');

                for (int i = 0; (i < 2) && (i < node.BranchTargetsCount); i++)
                {
                    if (i != 0)
                    {
                        sb.Append(", ");
                    }

                    sb.Append(node.BranchTargets[i].ToString());
                }

                if (node.BranchTargetsCount > 2)
//.........这里部分代码省略.........
开发者ID:yonglehou,项目名称:MOSA-Project,代码行数:101,代码来源:BaseInstruction.cs


注:本文中的Mosa.Compiler.Framework.InstructionNode.GetOperand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。