1 // Copyright Guillaume Piolat 2017 2 // Distributed under the Boost Software License, Version 1.0. 3 // (See accompanying file LICENSE_1_0.txt or copy at 4 // http://www.boost.org/LICENSE_1_0.txt) 5 6 module dplug.fft.dmd32_compat; 7 8 // OSX has 32-bit vector extensions 9 version(OSX){} 10 else 11 { 12 // Provide compatibility with x86 DMD, which doesn't define SIMD types. 13 version(DigitalMars): 14 version(X86) 15 { 16 struct double2 17 { 18 double x, y; 19 20 double2 opBinary(string op)(double2 a) if (op == "+") 21 { 22 return double2(x+a.x, y+a.y); 23 } 24 25 double2 opBinary(string op)(double2 a) if (op == "-") 26 { 27 return double2(x-a.x, y-a.y); 28 } 29 30 double2 opBinary(string op)(double2 a) if (op == "*") 31 { 32 return double2(x*a.x, y*a.y); 33 } 34 35 } 36 37 struct float4 38 { 39 float x, y, z, w; 40 41 float4 opBinary(string op)(float4 a) if (op == "+") 42 { 43 return float4(x+a.x, y+a.y, z+a.z, w+a.w); 44 } 45 46 float4 opBinary(string op)(float4 a) if (op == "-") 47 { 48 return float4(x-a.x, y-a.y, z-a.z, w-a.w); 49 } 50 51 float4 opBinary(string op)(float4 a) if (op == "*") 52 { 53 return float4(x*a.x, y*a.y, z*a.z, w*a.w); 54 } 55 } 56 57 struct double4 58 { 59 float x, y, z, w; 60 61 double4 opBinary(string op)(double4 a) if (op == "+") 62 { 63 return float4(x+a.x, y+a.y, z+a.z, w+a.w); 64 } 65 66 double4 opBinary(string op)(double4 a) if (op == "-") 67 { 68 return float4(x-a.x, y-a.y, z-a.z, w-a.w); 69 } 70 71 double4 opBinary(string op)(double4 a) if (op == "*") 72 { 73 return float4(x*a.x, y*a.y, z*a.z, w*a.w); 74 } 75 } 76 77 struct float8 78 { 79 float a, b, c, d, e, f, g, h; 80 81 float8 opBinary(string op)(float8 o) if (op == "+") 82 { 83 return float8(a+o.a, 84 b+o.b, 85 c+o.c, 86 d+o.d, 87 e+o.e, 88 f+o.f, 89 g+o.g, 90 h+o.h); 91 } 92 93 float8 opBinary(string op)(float8 o) if (op == "-") 94 { 95 return float8(a-o.a, 96 b-o.b, 97 c-o.c, 98 d-o.d, 99 e-o.e, 100 f-o.f, 101 g-o.g, 102 h-o.h); 103 } 104 105 float8 opBinary(string op)(float8 o) if (op == "*") 106 { 107 return float8(a*o.a, 108 b*o.b, 109 c*o.c, 110 d*o.d, 111 e*o.e, 112 f*o.f, 113 g*o.g, 114 h*o.h); 115 } 116 } 117 } 118 } 119