當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。