Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add uint support to Conv_R4 #165

Open
GoldenretriverYT opened this issue Aug 22, 2022 · 3 comments
Open

Add uint support to Conv_R4 #165

GoldenretriverYT opened this issue Aug 22, 2022 · 3 comments

Comments

@GoldenretriverYT
Copy link
Contributor

Area of Cosmos - What area of Cosmos are we dealing with?

IL2CPU

Expected Behaviour - What do you think that should happen?

Should compile fine

Actual Behaviour - What unexpectedly happens?

Compilation fails

2>Detecting fields for type 'IL2CPU.Debug.Symbols.Method'
2>IL2CPU : error : Exception: System.Exception: Error compiling method 'SystemInt32cs_ttfTTFstbtt__run_charstringcs_ttfstbtt_fontinfopointerSystemInt32cs_ttfTTFstbtt__csctxpointer': System.NotSupportedException: Specified method is not supported.
2>   at Cosmos.IL2CPU.X86.IL.Conv_R4.Execute(Il2cpuMethodInfo aMethod, ILOpCode aOpCode) in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\IL\Conv_R4.cs:line 37
2>   at Cosmos.IL2CPU.AppAssembler.EmitInstructions(Il2cpuMethodInfo aMethod, List`1 aCurrentGroup, Boolean& emitINT3) in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 632
2>   at Cosmos.IL2CPU.AppAssembler.ProcessMethod(Il2cpuMethodInfo aMethod, List`1 aOpCodes) in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 476
2> ---> System.NotSupportedException: Specified method is not supported.
2>   at Cosmos.IL2CPU.X86.IL.Conv_R4.Execute(Il2cpuMethodInfo aMethod, ILOpCode aOpCode) in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\IL\Conv_R4.cs:line 37
2>   at Cosmos.IL2CPU.AppAssembler.EmitInstructions(Il2cpuMethodInfo aMethod, List`1 aCurrentGroup, Boolean& emitINT3) in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 632
2>   at Cosmos.IL2CPU.AppAssembler.ProcessMethod(Il2cpuMethodInfo aMethod, List`1 aOpCodes) in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 476
2>   --- End of inner exception stack trace ---
2>   at Cosmos.IL2CPU.AppAssembler.ProcessMethod(Il2cpuMethodInfo aMethod, List`1 aOpCodes) in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\AppAssembler.cs:line 482
2>   at Cosmos.IL2CPU.ILScanner.Assemble() in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 1044
2>   at Cosmos.IL2CPU.ILScanner.Execute(MethodBase aStartMethod, IEnumerable`1 plugsAssemblies) in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\ILScanner.cs:line 278
2>   at Cosmos.IL2CPU.CompilerEngine.Execute() in C:\Users\FrancescoDettling\source\repos\Cosmos\IL2CPU\source\Cosmos.IL2CPU\CompilerEngine.cs:line 222

Reproduction - How did you get this error to appear?

Clone this repository: https://github.com/GoldenretriverYT/CosmosTTF/tree/implement-new-ttf
Then try to add it to your Cosmos OS. The method causing this error is stbtt__run_charstring in NewTTFLib.cs

Version - Were you using the User Kit or Dev Kit? And what User Kit version or Dev Kit commit (Cosmos, IL2CPU, X#)?

Latest DevKit

@GoldenretriverYT
Copy link
Contributor Author

After further inspection, this seems to be caused by this:
https://github.com/CosmosOS/IL2CPU/blob/12172758af82ba2c9673fcd1688c5a3d7aa8a97a/source/Cosmos.IL2CPU/IL/Conv_R4.cs

After checking the generated DLLs. I can confirm that conv.r4 is used in the DLL, with int32 and uint32.

@GoldenretriverYT
Copy link
Contributor Author

This can be fixed by doing

int temp = (int)stbtt__cff_int(&b);
f = temp;

instead of

f = (Int32)stbtt__cff_int(&b);

@GoldenretriverYT
Copy link
Contributor Author

Its probably cause Roslyn optimized out the cast, because it believes uint32 is directly castable to float (which is true in regular C#) so I believe support for that should be added.

@quajak quajak transferred this issue from CosmosOS/Cosmos Sep 3, 2022
@quajak quajak changed the title Specified method is not supported (AT COMPILATION) Add uint support to Conv_R4 Sep 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants