public static byte v2MoveToRegister(Vector v) { for (byte x = 0; x < 8; x++) { if (!Registers[x]) { string r = x.ToString(); switch (v.Direction) { case VectorDirection.Up: if (flipped) { AsmFile.WriteLine("movlps xmm" + r + ",[" + v.Register + ToHex(v.Offset - 4) + "]"); } else { AsmFile.WriteLine("movlps xmm" + r + ",[" + v.Register + ToHex(v.Offset) + "]"); } Registers[x] = new RegisterState(VectorDirection.Up, operation); break; case VectorDirection.Down: throw new OptimizationException("Code generator: Code using flipped v2's doesn't fit"); case VectorDirection.Static: AsmFile.WriteLine("movss xmm" + r + ",[" + v.Register + ToHex(v.Offset) + "]"); AsmFile.WriteLine("shufps xmm" + r + ",xmm" + r + ",0x00"); Registers[x] = new RegisterState(VectorDirection.Static, operation); break; } return(x); } } throw new OptimizationException("Code generater: Ran out of registers"); }
public static byte v3MoveToRegister(Vector v) { for (byte x = 0; x < 8; x++) { if (!Registers[x]) { string r = x.ToString(); switch (v.Direction) { case VectorDirection.Up: if (aligned) { if (flipped) { AsmFile.WriteLine("movaps xmm" + r + ",[" + v.Register + ToHex(v.Offset - 8) + "]"); } else { AsmFile.WriteLine("movaps xmm" + r + ",[" + v.Register + ToHex(v.Offset) + "]"); } } else { AsmFile.WriteLine("movss xmm" + r + ",[" + v.Register + ToHex(v.Offset) + "]"); if (flipped) { AsmFile.WriteLine("movhps xmm" + r + ",[" + v.Register + ToHex(v.Offset - 8) + "]"); } else { AsmFile.WriteLine("movhps xmm" + r + ",[" + v.Register + ToHex(v.Offset + 4) + "]"); } } Registers[x] = new RegisterState(VectorDirection.Up, operation); break; case VectorDirection.Down: throw new OptimizationException("Code generator: Haven't got reversed v3 input working yet"); case VectorDirection.Static: AsmFile.WriteLine("movss xmm" + r + ",[" + v.Register + ToHex(v.Offset) + "]"); AsmFile.WriteLine("shufps xmm" + r + ",xmm" + r + ",0x00"); Registers[x] = new RegisterState(VectorDirection.Static, operation); break; } return(x); } } throw new OptimizationException("Code generater: Ran out of registers"); }
public static byte v4MoveToRegister(Vector v) { for (byte x = 0; x < 8; x++) { if (!Registers[x]) { string r = x.ToString(); switch (v.Direction) { case VectorDirection.Up: if (aligned) { AsmFile.WriteLine("movaps xmm" + r + ",[" + v.Register + ToHex(v.Offset) + "]"); } else { AsmFile.WriteLine("movups xmm" + r + ",[" + v.Register + ToHex(v.Offset) + "]"); } Registers[x] = new RegisterState(VectorDirection.Up, operation); break; case VectorDirection.Down: AsmFile.WriteLine("movhps xmm" + r + ",[" + v.Register + ToHex(v.Offset - (v.Count - 2) * 4) + "]"); AsmFile.WriteLine("shufps xmm" + r + ",[" + v.Register + ToHex(v.Offset - v.Count * 4) + "],0x1B"); Registers[x] = new RegisterState(VectorDirection.Down, operation); break; case VectorDirection.Static: AsmFile.WriteLine("movss xmm" + r + ",[" + v.Register + ToHex(v.Offset) + "]"); AsmFile.WriteLine("shufps xmm" + r + ",xmm" + r + ",0x00"); Registers[x] = new RegisterState(VectorDirection.Static, operation); break; } return(x); } } throw new OptimizationException("Code generater: Ran out of registers"); }
public static byte v4MoveToRegister(Vector v) { for(byte x=0;x<8;x++) { if(!Registers[x]) { string r=x.ToString(); switch(v.Direction) { case VectorDirection.Up: if(aligned) { AsmFile.WriteLine("movaps xmm"+r+",["+v.Register+ToHex(v.Offset)+"]"); } else { AsmFile.WriteLine("movups xmm"+r+",["+v.Register+ToHex(v.Offset)+"]"); } Registers[x]=new RegisterState(VectorDirection.Up,operation); break; case VectorDirection.Down: AsmFile.WriteLine("movhps xmm"+r+",["+v.Register+ToHex(v.Offset-(v.Count-2)*4)+"]"); AsmFile.WriteLine("shufps xmm"+r+",["+v.Register+ToHex(v.Offset-v.Count*4)+"],0x1B"); Registers[x]=new RegisterState(VectorDirection.Down,operation); break; case VectorDirection.Static: AsmFile.WriteLine("movss xmm"+r+",["+v.Register+ToHex(v.Offset)+"]"); AsmFile.WriteLine("shufps xmm"+r+",xmm"+r+",0x00"); Registers[x]=new RegisterState(VectorDirection.Static,operation); break; } return x; } } throw new OptimizationException("Code generater: Ran out of registers"); }
public static byte v3MoveToRegister(Vector v) { for(byte x=0;x<8;x++) { if(!Registers[x]) { string r=x.ToString(); switch(v.Direction) { case VectorDirection.Up: if(aligned) { if(flipped) { AsmFile.WriteLine("movaps xmm"+r+",["+v.Register+ToHex(v.Offset-8)+"]"); } else { AsmFile.WriteLine("movaps xmm"+r+",["+v.Register+ToHex(v.Offset)+"]"); } } else { AsmFile.WriteLine("movss xmm"+r+",["+v.Register+ToHex(v.Offset)+"]"); if(flipped) { AsmFile.WriteLine("movhps xmm"+r+",["+v.Register+ToHex(v.Offset-8)+"]"); } else { AsmFile.WriteLine("movhps xmm"+r+",["+v.Register+ToHex(v.Offset+4)+"]"); } } Registers[x]=new RegisterState(VectorDirection.Up,operation); break; case VectorDirection.Down: throw new OptimizationException("Code generator: Haven't got reversed v3 input working yet"); case VectorDirection.Static: AsmFile.WriteLine("movss xmm"+r+",["+v.Register+ToHex(v.Offset)+"]"); AsmFile.WriteLine("shufps xmm"+r+",xmm"+r+",0x00"); Registers[x]=new RegisterState(VectorDirection.Static,operation); break; } return x; } } throw new OptimizationException("Code generater: Ran out of registers"); }
public static byte v2MoveToRegister(Vector v) { for(byte x=0;x<8;x++) { if(!Registers[x]) { string r=x.ToString(); switch(v.Direction) { case VectorDirection.Up: if(flipped) { AsmFile.WriteLine("movlps xmm"+r+",["+v.Register+ToHex(v.Offset-4)+"]"); } else { AsmFile.WriteLine("movlps xmm"+r+",["+v.Register+ToHex(v.Offset)+"]"); } Registers[x]=new RegisterState(VectorDirection.Up,operation); break; case VectorDirection.Down: throw new OptimizationException("Code generator: Code using flipped v2's doesn't fit"); case VectorDirection.Static: AsmFile.WriteLine("movss xmm"+r+",["+v.Register+ToHex(v.Offset)+"]"); AsmFile.WriteLine("shufps xmm"+r+",xmm"+r+",0x00"); Registers[x]=new RegisterState(VectorDirection.Static,operation); break; } return x; } } throw new OptimizationException("Code generater: Ran out of registers"); }