Exemple #1
0
        private static void LoadLocals(BasicBlock block, long inputs, RegisterType baseType)
        {
            Operand arg0 = Local(OperandType.I64);

            for (int bit = 63; bit >= 0; bit--)
            {
                long mask = 1L << bit;

                if ((inputs & mask) == 0)
                {
                    continue;
                }

                Operand dest = GetRegFromBit(bit, baseType);

                long offset = NativeContext.GetRegisterOffset(dest.GetRegister());

                Operand addr = Local(OperandType.I64);

                Operation loadOp = new Operation(Instruction.Load, dest, addr);

                block.Operations.AddFirst(loadOp);

                Operation calcOffsOp = new Operation(Instruction.Add, addr, arg0, Const(offset));

                block.Operations.AddFirst(calcOffsOp);
            }

            Operation loadArg0 = new Operation(Instruction.LoadArgument, arg0, Const(0));

            block.Operations.AddFirst(loadArg0);
        }
Exemple #2
0
        private static void StoreLocals(BasicBlock block, long outputs, RegisterType baseType, ExecutionMode mode)
        {
            Operand arg0 = Local(OperandType.I64);

            Operation loadArg0 = Operation(Instruction.LoadArgument, arg0, Const(0));

            block.Append(loadArg0);

            for (int bit = 0; bit < 64; bit++)
            {
                long mask = 1L << bit;

                if ((outputs & mask) == 0)
                {
                    continue;
                }

                Operand source = GetRegFromBit(bit, baseType, mode);

                long offset = NativeContext.GetRegisterOffset(source.GetRegister());

                Operand addr = Local(OperandType.I64);

                Operation calcOffsOp = Operation(Instruction.Add, addr, arg0, Const(offset));

                block.Append(calcOffsOp);

                Operation storeOp = Operation(Instruction.Store, null, addr, source);

                block.Append(storeOp);
            }
        }
Exemple #3
0
        private static void StoreLocals(BasicBlock block, long outputs, RegisterType baseType, bool isCompleteFunction)
        {
            if (Optimizations.AssumeStrictAbiCompliance && isCompleteFunction)
            {
                if (baseType == RegisterType.Integer || baseType == RegisterType.Flag)
                {
                    outputs = ClearCallerSavedIntRegs(outputs);
                }
                else /* if (baseType == RegisterType.Vector) */
                {
                    outputs = ClearCallerSavedVecRegs(outputs);
                }
            }

            Operand arg0 = Local(OperandType.I64);

            Operation loadArg0 = new Operation(Instruction.LoadArgument, arg0, Const(0));

            block.Append(loadArg0);

            for (int bit = 0; bit < 64; bit++)
            {
                long mask = 1L << bit;

                if ((outputs & mask) == 0)
                {
                    continue;
                }

                Operand source = GetRegFromBit(bit, baseType);

                long offset = NativeContext.GetRegisterOffset(source.GetRegister());

                Operand addr = Local(OperandType.I64);

                Operation calcOffsOp = new Operation(Instruction.Add, addr, arg0, Const(offset));

                block.Append(calcOffsOp);

                Operation storeOp = new Operation(Instruction.Store, null, addr, source);

                block.Append(storeOp);
            }
        }