Ejemplo n.º 1
0
 public OpId(NumericSystem NumSystem, OpKind OpKind, NumericKind NumKind, Genericity Generic, OpFusion Fusion, string OpTitle)
 {
     this.NumSystem   = NumSystem;
     this.OpKind      = OpKind;
     this.NumKind     = NumKind;
     this.OperandType = PrimalKinds.kind <T>();
     this.Generic     = Generic;
     this.Fusion      = Fusion;
     this.OpTitle     = ifEmpty(OpTitle, OpId.DefineOpTitle(this));
     this.OpUri       = OpId.BuildOpUri(this);
 }
Ejemplo n.º 2
0
        protected void VerifyOp <K>(OpKind opKind, UnaryOp <K> subject, UnaryOp <K> baseline, bool nonzero = false, [CallerMemberName] string caller = null,
                                    [CallerFilePath] string file = null, [CallerLineNumber] int?line = null)
            where K : struct
        {
            var kind   = PrimalKinds.kind <K>();
            var opid   = opKind.PrimalGOpId <K>();
            var src    = RandArray <K>(nonzero);
            var timing = stopwatch();

            for (var i = 0; i < src.Length; i++)
            {
                Claim.eq(baseline(src[i]), subject(src[i]), caller, file, line);
            }
        }
Ejemplo n.º 3
0
        public static OpArity Arity(this OpKind op)
        {
            var attributions = (from a in typeof(OpKind).DeclaredFieldAttributions <ArityAttribute>()
                                select(a.Key.Name, a.Value.Arity)).ToDictionary();

            if (attributions.ContainsKey(op.ToString()))
            {
                return(attributions[op.ToString()]);
            }
            else
            {
                return(OpArity.None);
            }
        }
Ejemplo n.º 4
0
        protected void VerifyOp <K>(OpKind opKind, BinaryOp <K> baseline, BinaryOp <K> op, bool nonzero = false, [CallerMemberName] string caller = null,
                                    [CallerFilePath] string file = null, [CallerLineNumber] int?line = null)
            where K : struct
        {
            var kind   = PrimalKinds.kind <K>();
            var lhs    = RandArray <K>();
            var rhs    = RandArray <K>(nonzero);
            var len    = length(lhs, rhs);
            var timing = stopwatch();

            for (var i = 0; i < len; i++)
            {
                Claim.numeq(baseline(lhs[i], rhs[i]), op(lhs[i], rhs[i]), caller, file, line);
            }
        }
Ejemplo n.º 5
0
 // String returns a human readable representation of an OpKind. It is not
 // intended for machine processing.
 public static @string String(this OpKind k) => func((_, panic, __) =>
 {
     if (k == Delete)
     {
         return("delete");
     }
     else if (k == Insert)
     {
         return("insert");
     }
     else if (k == Equal)
     {
         return("equal");
     }
     else
     {
         panic("unknown operation kind");
     }
 });
Ejemplo n.º 6
0
        internal BaseOpSymb(
            OpKind opKind,
            int arity,
            Func <Node, List <Flag>, bool> validator,
            Func <TermIndex, Term[], Term[]> upApprox,
            Func <TermIndex, Term[], Term[]> downApprox,
            Func <Executer, Bindable[], Term> evaluator,
            Func <TermIndex, Term[], IEnumerable <Tuple <RelKind, Term, Term> > > appConstrainer = null)
        {
            Contract.Requires(validator != null && upApprox != null && downApprox != null);
            Contract.Requires(evaluator != null);

            OpKind         = opKind;
            Validator      = validator;
            UpwardApprox   = upApprox;
            DownwardApprox = downApprox;
            Evaluator      = evaluator;
            AppConstrainer = appConstrainer == null ? EmptyConstrainer : appConstrainer;
            this.arity     = arity;
        }
Ejemplo n.º 7
0
 public static MetricSpec <T> Define <T>(OpKind OpKind, NumericSystem NumSystem, NumericKind NumKind,
                                         OpVariance Variance, ByteSize OperandSize)
     where T : struct
 => new MetricSpec <T>(OpKind, NumSystem, NumKind, Variance, OperandSize);
Ejemplo n.º 8
0
 //------------------------------------------------------------
 // コンストラクタ。
 public PostfixExpression(OpKind opKind, IExpression expr)
 {
     mOpKind    = opKind;
     mFirstExpr = expr;
 }
Ejemplo n.º 9
0
 public static MetricSpec Define(OpKind OpKind, NumericSystem NumSystem, NumericKind NumKind,
                                 PrimalKind OperandType, OpVariance Variance, ByteSize OperandSize)
 => new MetricSpec(OpKind, NumSystem, NumKind, OperandType, Variance, OperandSize);
Ejemplo n.º 10
0
 public static MetricComparisonSpec DefineComparison <T>(this MetricKind Baseline, MetricKind Bench, OpKind Operator)
     where T : struct
 => MetricComparisonSpec.Define(Baseline, Bench, PrimalKinds.kind <T>(), Operator);
Ejemplo n.º 11
0
 //------------------------------------------------------------
 // コンストラクタ。
 public UnaryOpExpression(OpKind aOpKind, IExpression aExpr)
 {
     mOpKind = aOpKind;
     mExpr   = aExpr;
 }
Ejemplo n.º 12
0
Archivo: OpSig.cs Proyecto: 0xCM/arrows
 public static IOpSig Define(NumericKind numKind, OpKind op, ParamSig operand, ParamSig ret)
 => new UnaryOpSig(numKind, op, operand, ret);
Ejemplo n.º 13
0
 public static MetricComparisonSpec DefineComparison(this MetricKind Baseline, MetricKind Bench, PrimalKind Primitive, OpKind Operator)
 => MetricComparisonSpec.Define(Baseline, Bench, Primitive, Operator);
Ejemplo n.º 14
0
 //------------------------------------------------------------
 // コンストラクタ。
 public UnaryOpExpression(Token aOpToken, OpKind aOpKind, IExpression aExpr)
 {
     mOpToken = aOpToken;
     mOpKind  = aOpKind;
     mExpr    = aExpr;
 }
Ejemplo n.º 15
0
 public static bool IsImmediate(this OpKind opKind) => opKind >= OpKind.Immediate8 && opKind <= OpKind.Immediate32to64;
Ejemplo n.º 16
0
 public OpType(OpKind op)
 {
     Primitive = PrimalKinds.kind <T>();
     this.Op   = op;
 }
Ejemplo n.º 17
0
 public OpMetricAttribute(MetricKind Metric, OpKind Op)
 {
     this.Metric = Metric;
     this.Op     = Op;
 }
Ejemplo n.º 18
0
Archivo: OpSig.cs Proyecto: 0xCM/arrows
 public UnaryOpSig(NumericKind NumKind, OpKind Op, ParamSig Operand, ParamSig Return)
     : base(NumKind, Op, Return)
 {
     this.Operand = Operand;
 }
Ejemplo n.º 19
0
Archivo: OpSig.cs Proyecto: 0xCM/arrows
 public OpSig(NumericKind NumKind, OpKind Op, ParamSig Return)
 {
     this.NumKind = NumKind;
     this.Op      = Op;
     this.Return  = Return;
 }
Ejemplo n.º 20
0
Archivo: OpSig.cs Proyecto: 0xCM/arrows
 public static IOpSig Define(NumericKind numKind, OpKind op, ParamSig lhs, ParamSig rhs, ParamSig ret)
 => new BinaryOpSig(numKind, op, lhs, rhs, ret);
Ejemplo n.º 21
0
 //------------------------------------------------------------
 // コンストラクタ
 public BinaryOpExpression(OpKind aOpKind, IExpression aFirst, IExpression aSecond)
 {
     mOpKind = aOpKind;
     mFirst  = aFirst;
     mSecond = aSecond;
 }
Ejemplo n.º 22
0
 public MetricComparisonSpec(MetricKind Baseline, MetricKind Bench, PrimalKind Primitive, OpKind Operator)
 {
     this.BaseKind  = Baseline;
     this.BenchKind = Bench;
     this.Primitive = Primitive;
     this.Operator  = Operator;
 }
Ejemplo n.º 23
0
 //------------------------------------------------------------
 // コンストラクタ
 public AssignmentExpression(OpKind aOpKind, IExpression aLeftExpr, IExpression aRightExpr)
 {
     mOpKind    = aOpKind;
     mLeftExpr  = aLeftExpr;
     mRightExpr = aRightExpr;
 }
Ejemplo n.º 24
0
 public static MetricId Define(MetricKind Classifier, PrimalKind Primitive, OpKind Operator)
 => new MetricId(Classifier, Primitive, Operator);
Ejemplo n.º 25
0
 private static void Emit(OpKind kind, int immediate = 0, int len1 = 0, int len2 = 0)
 {
     prototypes.Add(new Opcode(kind, immediate, len1, len2));
 }
Ejemplo n.º 26
0
 public static MetricId Identify(this MetricKind metric, PrimalKind primitive, OpKind op)
 => MetricId.Define(metric, primitive, op);
Ejemplo n.º 27
0
        static void ReadOpKind(DecoderTestCase tc, int operand, string value, out OpKind opKind, ref Register opRegister)
        {
            var parts = value.Split(opKindSeps);

            switch (parts[0])
            {
            case OpKind_Register:
                if (parts.Length != 2)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 2 values, actual = {parts.Length}");
                }
                opRegister = ToRegister(parts[1]);
                opKind     = OpKind.Register;
                break;

            case OpKind_NearBranch16:
                if (parts.Length != 2)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 2 values, actual = {parts.Length}");
                }
                opKind        = OpKind.NearBranch16;
                tc.NearBranch = ToUInt16(parts[1]);
                break;

            case OpKind_NearBranch32:
                if (parts.Length != 2)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 2 values, actual = {parts.Length}");
                }
                opKind        = OpKind.NearBranch32;
                tc.NearBranch = ToUInt32(parts[1]);
                break;

            case OpKind_NearBranch64:
                if (parts.Length != 2)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 2 values, actual = {parts.Length}");
                }
                opKind        = OpKind.NearBranch64;
                tc.NearBranch = ToUInt64(parts[1]);
                break;

            case OpKind_FarBranch16:
                if (parts.Length != 3)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 3 values, actual = {parts.Length}");
                }
                opKind = OpKind.FarBranch16;
                tc.FarBranchSelector = ToUInt16(parts[1]);
                tc.FarBranch         = ToUInt16(parts[2]);
                break;

            case OpKind_FarBranch32:
                if (parts.Length != 3)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 3 values, actual = {parts.Length}");
                }
                opKind = OpKind.FarBranch32;
                tc.FarBranchSelector = ToUInt16(parts[1]);
                tc.FarBranch         = ToUInt32(parts[2]);
                break;

            case OpKind_Immediate8:
                if (parts.Length != 2)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 2 values, actual = {parts.Length}");
                }
                opKind       = OpKind.Immediate8;
                tc.Immediate = ToUInt8(parts[1]);
                break;

            case OpKind_Immediate16:
                if (parts.Length != 2)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 2 values, actual = {parts.Length}");
                }
                opKind       = OpKind.Immediate16;
                tc.Immediate = ToUInt16(parts[1]);
                break;

            case OpKind_Immediate32:
                if (parts.Length != 2)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 2 values, actual = {parts.Length}");
                }
                opKind       = OpKind.Immediate32;
                tc.Immediate = ToUInt32(parts[1]);
                break;

            case OpKind_Immediate64:
                if (parts.Length != 2)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 2 values, actual = {parts.Length}");
                }
                opKind       = OpKind.Immediate64;
                tc.Immediate = ToUInt64(parts[1]);
                break;

            case OpKind_Immediate8to16:
                if (parts.Length != 2)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 2 values, actual = {parts.Length}");
                }
                opKind       = OpKind.Immediate8to16;
                tc.Immediate = ToUInt16(parts[1]);
                break;

            case OpKind_Immediate8to32:
                if (parts.Length != 2)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 2 values, actual = {parts.Length}");
                }
                opKind       = OpKind.Immediate8to32;
                tc.Immediate = ToUInt32(parts[1]);
                break;

            case OpKind_Immediate8to64:
                if (parts.Length != 2)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 2 values, actual = {parts.Length}");
                }
                opKind       = OpKind.Immediate8to64;
                tc.Immediate = ToUInt64(parts[1]);
                break;

            case OpKind_Immediate32to64:
                if (parts.Length != 2)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 2 values, actual = {parts.Length}");
                }
                opKind       = OpKind.Immediate32to64;
                tc.Immediate = ToUInt64(parts[1]);
                break;

            case OpKind_Immediate8_2nd:
                if (parts.Length != 2)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 2 values, actual = {parts.Length}");
                }
                opKind           = OpKind.Immediate8_2nd;
                tc.Immediate_2nd = ToUInt8(parts[1]);
                break;

            case OpKind_MemorySegSI:
                if (parts.Length != 3)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 3 values, actual = {parts.Length}");
                }
                opKind           = OpKind.MemorySegSI;
                tc.MemorySegment = ToRegister(parts[1]);
                tc.MemorySize    = ToMemorySize(parts[2]);
                break;

            case OpKind_MemorySegESI:
                if (parts.Length != 3)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 3 values, actual = {parts.Length}");
                }
                opKind           = OpKind.MemorySegESI;
                tc.MemorySegment = ToRegister(parts[1]);
                tc.MemorySize    = ToMemorySize(parts[2]);
                break;

            case OpKind_MemorySegRSI:
                if (parts.Length != 3)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 3 values, actual = {parts.Length}");
                }
                opKind           = OpKind.MemorySegRSI;
                tc.MemorySegment = ToRegister(parts[1]);
                tc.MemorySize    = ToMemorySize(parts[2]);
                break;

            case OpKind_MemorySegDI:
                if (parts.Length != 3)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 3 values, actual = {parts.Length}");
                }
                opKind           = OpKind.MemorySegDI;
                tc.MemorySegment = ToRegister(parts[1]);
                tc.MemorySize    = ToMemorySize(parts[2]);
                break;

            case OpKind_MemorySegEDI:
                if (parts.Length != 3)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 3 values, actual = {parts.Length}");
                }
                opKind           = OpKind.MemorySegEDI;
                tc.MemorySegment = ToRegister(parts[1]);
                tc.MemorySize    = ToMemorySize(parts[2]);
                break;

            case OpKind_MemorySegRDI:
                if (parts.Length != 3)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 3 values, actual = {parts.Length}");
                }
                opKind           = OpKind.MemorySegRDI;
                tc.MemorySegment = ToRegister(parts[1]);
                tc.MemorySize    = ToMemorySize(parts[2]);
                break;

            case OpKind_MemoryESDI:
                if (parts.Length != 2)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 2 values, actual = {parts.Length}");
                }
                opKind        = OpKind.MemoryESDI;
                tc.MemorySize = ToMemorySize(parts[1]);
                break;

            case OpKind_MemoryESEDI:
                if (parts.Length != 2)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 2 values, actual = {parts.Length}");
                }
                opKind        = OpKind.MemoryESEDI;
                tc.MemorySize = ToMemorySize(parts[1]);
                break;

            case OpKind_MemoryESRDI:
                if (parts.Length != 2)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 2 values, actual = {parts.Length}");
                }
                opKind        = OpKind.MemoryESRDI;
                tc.MemorySize = ToMemorySize(parts[1]);
                break;

            case OpKind_Memory64:
                if (parts.Length != 4)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 4 values, actual = {parts.Length}");
                }
                opKind             = OpKind.Memory64;
                tc.MemorySegment   = ToRegister(parts[1]);
                tc.MemoryAddress64 = ToUInt64(parts[2]);
                tc.MemorySize      = ToMemorySize(parts[3]);
                break;

            case OpKind_Memory:
                if (parts.Length != 8)
                {
                    throw new InvalidOperationException($"Operand {operand}: expected 8 values, actual = {parts.Length}");
                }
                opKind                = OpKind.Memory;
                tc.MemorySegment      = ToRegister(parts[1]);
                tc.MemoryBase         = ToRegister(parts[2]);
                tc.MemoryIndex        = ToRegister(parts[3]);
                tc.MemoryIndexScale   = ToInt32(parts[4]);
                tc.MemoryDisplacement = ToUInt32(parts[5]);
                tc.MemoryDisplSize    = ToInt32(parts[6]);
                tc.MemorySize         = ToMemorySize(parts[7]);
                break;

            default:
                throw new InvalidOperationException($"Invalid opkind: '{parts[0]}'");
            }
        }
Ejemplo n.º 28
0
 public static MetricId Identify <T>(this MetricKind metric, OpKind op)
     where T : struct
 => MetricId.Define(metric, PrimalKinds.kind <T>(), op);
Ejemplo n.º 29
0
 public Line(OpKind Kind = default, @string Content = default)
 {
     this.Kind    = Kind;
     this.Content = Content;
 }
Ejemplo n.º 30
0
 public static void Deconstruct(this MetricId metric, out MetricKind Classifier, out PrimalKind Primitive, out OpKind Operator)
 {
     Classifier = metric.Classifier;
     Primitive  = metric.Primitive;
     Operator   = metric.Operator;
 }