diff --git a/ARMeilleure/Instructions/InstEmitSimdMove.cs b/ARMeilleure/Instructions/InstEmitSimdMove.cs index b93936fbba..12fc71c990 100644 --- a/ARMeilleure/Instructions/InstEmitSimdMove.cs +++ b/ARMeilleure/Instructions/InstEmitSimdMove.cs @@ -284,13 +284,26 @@ namespace ARMeilleure.Instructions { OpCodeSimdFmov op = (OpCodeSimdFmov)context.CurrOp; - if (op.Size == 0) + if (Optimizations.UseSse2) { - context.Copy(GetVec(op.Rd), X86GetScalar(context, (int)op.Immediate)); + if (op.Size == 0) + { + context.Copy(GetVec(op.Rd), X86GetScalar(context, (int)op.Immediate)); + } + else + { + context.Copy(GetVec(op.Rd), X86GetScalar(context, op.Immediate)); + } } else { - context.Copy(GetVec(op.Rd), X86GetScalar(context, op.Immediate)); + Operand e = Const(op.Immediate); + + Operand res = context.VectorZero(); + + res = EmitVectorInsert(context, res, e, 0, op.Size + 2); + + context.Copy(GetVec(op.Rd), res); } } @@ -298,13 +311,31 @@ namespace ARMeilleure.Instructions { OpCodeSimdImm op = (OpCodeSimdImm)context.CurrOp; - if (op.RegisterSize == RegisterSize.Simd128) + if (Optimizations.UseSse2) { - context.Copy(GetVec(op.Rd), X86GetAllElements(context, op.Immediate)); + if (op.RegisterSize == RegisterSize.Simd128) + { + context.Copy(GetVec(op.Rd), X86GetAllElements(context, op.Immediate)); + } + else + { + context.Copy(GetVec(op.Rd), X86GetScalar(context, op.Immediate)); + } } else { - context.Copy(GetVec(op.Rd), X86GetScalar(context, op.Immediate)); + Operand e = Const(op.Immediate); + + Operand res = context.VectorZero(); + + int elems = op.RegisterSize == RegisterSize.Simd128 ? 2 : 1; + + for (int index = 0; index < elems; index++) + { + res = EmitVectorInsert(context, res, e, index, 3); + } + + context.Copy(GetVec(op.Rd), res); } } diff --git a/ARMeilleure/Translation/AOT/RelocEntry.cs b/ARMeilleure/Translation/AOT/RelocEntry.cs index 0e0f7069de..f83f6c8395 100644 --- a/ARMeilleure/Translation/AOT/RelocEntry.cs +++ b/ARMeilleure/Translation/AOT/RelocEntry.cs @@ -13,7 +13,7 @@ namespace ARMeilleure.Translation.AOT public override string ToString() { - return $"(Position = {Position}, Name = {Name})"; + return $"({nameof(Position)} = {Position}, {nameof(Name)} = {Name})"; } } } diff --git a/ARMeilleure/Translation/DelegateHelpers.cs b/ARMeilleure/Translation/DelegateHelpers.cs index 2d4292548a..7944d4140c 100644 --- a/ARMeilleure/Translation/DelegateHelpers.cs +++ b/ARMeilleure/Translation/DelegateHelpers.cs @@ -27,7 +27,7 @@ namespace ARMeilleure.Translation { if (info == null) { - throw new ArgumentNullException(); + throw new ArgumentNullException(nameof(info)); } Type[] parameters = info.GetParameters().Select(pI => pI.ParameterType).ToArray(); diff --git a/ARMeilleure/Translation/Delegates.cs b/ARMeilleure/Translation/Delegates.cs index 35f3ca223e..23957d65ba 100644 --- a/ARMeilleure/Translation/Delegates.cs +++ b/ARMeilleure/Translation/Delegates.cs @@ -11,7 +11,7 @@ namespace ARMeilleure.Translation { if (key == null) { - throw new ArgumentNullException(); + throw new ArgumentNullException(nameof(key)); } if (_delegates.TryGetValue(key, out DelegateInfo dlgInfo)) @@ -32,12 +32,12 @@ namespace ARMeilleure.Translation { if (key == null) { - throw new ArgumentNullException(); + throw new ArgumentNullException(nameof(key)); } if (!_delegates.TryGetValue(key, out DelegateInfo dlgInfo)) { - throw new Exception(); + throw new ArgumentException($"({nameof(key)} = {key})"); } return dlgInfo; @@ -51,7 +51,7 @@ namespace ARMeilleure.Translation if (!_delegates.TryAdd(key, new DelegateInfo(dlg))) { - throw new Exception(); + throw new ArgumentException($"({nameof(key)} = {key})"); } }