Gas64 (no more use of gcc, only gas) WDS / LNX

User projects written in or related to FreeBASIC.
Post Reply
Provoni
Posts: 513
Joined: Jan 05, 2014 12:33
Location: Belgium

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by Provoni »

jj2007 wrote:
Provoni wrote:now it was done in about 20 seconds. Great work! Though my program runs 1.6x faster with GCC
Develop it with SARG's compiler, release it compiled with GCC. My 20,000 line programs "compile" in less than 2 seconds, but that is Assembler ;-)
Yep indeed, good idea, I have it set up.
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by coderJeff »

gas64 is now merged in to 1.07.2 (on freebasic/fbc/fbc-1.07 branch) and 1.08.0 (on freebasic/fbc/master branch).

- '-gen gas64' to use
- intrinsic '__FB_BACKEND__' set to "gas64" when used
- default backend is still -gen gas on 32-bit and -gen gcc on 64-bit

A while back discussed using -gen gas and __FB_BACKEND__ = "gas" for both 32-bit and 64-bit. Going to leave the behaviour as-is for now, but, If you did want to write conditional source code for either now or future:

Code: Select all

#if ( __FB_BACKEND__ = "gas") or (__FB_BACKEND__ = "gas64")
  #if defined( __FB_64BIT__ )
    '' asm for 64-bit
  #else
    '' asm for 32-bit
  #endif
#else
  '' generic code for any other backend
#endif
deltarho[1859]
Posts: 4292
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by deltarho[1859] »

Excuse my ignorance but where is 'freebasic/fbc/fbc-1.07 branch'?
Provoni
Posts: 513
Joined: Jan 05, 2014 12:33
Location: Belgium

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by Provoni »

deltarho[1859] wrote: Excuse my ignorance but where is 'freebasic/fbc/fbc-1.07 branch'?
I don't know either.
deltarho[1859]
Posts: 4292
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by deltarho[1859] »

Provoni wrote:I don't know either.
Oh, thank you - I can take my dunce cap off now. Yes, I have one. I would like to say it gathers dust most of the time but I can't. Image
coderJeff
Site Admin
Posts: 4313
Joined: Nov 04, 2005 14:23
Location: Ontario, Canada
Contact:

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by coderJeff »

deltarho[1859] wrote:Excuse my ignorance but where is 'freebasic/fbc/fbc-1.07 branch'?
Maybe easiest place to see would be:
https://github.com/freebasic/fbc/branches

The fbc-1.07 branch will be used for a 1,07.2 version release. It's diverged from the main development branch.
deltarho[1859]
Posts: 4292
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by deltarho[1859] »

Thanks coderJeff - I will wait for a .2 release. I went to the link and put my dunce cap back on. Image
jepalza
Posts: 149
Joined: Feb 24, 2010 10:08
Location: Spain (Bilbao)

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by jepalza »

Compiling my FB 80486 emulator ( viewtopic.php?f=8&t=27435&hilit=80486 ) , give me this error:

Code: Select all

FreeBASIC Compiler - Version 1.07-(08).1 (2020-08-16), built for win64 (64bit)
Copyright (C) 2004-2019 The FreeBASIC development team.
standalone
target:       win64, x86-64, 64bit
backend:      gas64
compiling:    _80486_emu.bas -o _80486_emu.a64 (main module)
assembling:   c:\aplis\FreeBasic\bin\win64\as.exe --64 "_80486_emu.a64" -o "_80486_emu.o"
_80486_emu.a64: Assembler messages:
_80486_emu.a64:57478: Error: no such instruction: `found AN ERROR:in check_optim mov unkonwn=mov'
_80486_emu.a64:57481: Error: expecting operand after ','; got nothing
_80486_emu.a64:57497: Error: no such instruction: `found AN ERROR:in check_optim mov unkonwn=mov'
_80486_emu.a64:57500: Error: expecting operand after ','; got nothing assembling failed: 'c:\FreeBasic\bin\win64\as.exe' terminated with exit code 1
Using this command line parameter:
-RR -R -gen gas64 -v -s console -g "_80486_emu.bas"

Is not important for me, only to testing, but, maybe for you is important, in order to locate possible fails.
Last edited by jepalza on Oct 23, 2020 5:12, edited 1 time in total.
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by SARG »

@jepalza
Thank you for testing.
I could not reproduce the errors, instead I got this strange message (see below).
I also tried with a regular version of FBC and getting the same message.
As the assembler was not launched I checked inside the a64 file. The errors you reported are caused intentionnaly when something goes wrong but I didn't find any.
The version of 80846_emu is that from april 2020.

Code: Select all

FreeBASIC Compiler - Version 1.07-(08).1 (2020-08-16), built for win64 (64bit)
Copyright (C) 2004-2019 The FreeBASIC development team.
standalone
target:       win64, x86-64, 64bit
backend:      gas64
compiling:    _80486_emu.bas -o _80486_emu.a64 (main module)
D:\telechargements\emu80846\mem.bas(232) warning 4(2): Suspicious pointer assignment
D:\telechargements\emu80846\x86.bas(306) warning 4(2): Suspicious pointer assignment
D:\telechargements\emu80846\x86.bas(309) warning 4(2): Suspicious pointer assignment
D:\telechargements\emu80846\x86.bas(349) warning 4(2): Suspicious pointer assignment
D:\telechargements\emu80846\x86.bas(352) warning 4(2): Suspicious pointer assignment
compiling:    .bas -o .a64
.bas() error 23: File not found, .bas
jepalza
Posts: 149
Joined: Feb 24, 2010 10:08
Location: Spain (Bilbao)

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by jepalza »

I'm using same code, date "april 20", freebasic 1.07.1 (x64) and lastest GAS64

This line is different between your output log and mine:
assembling: c:\aplis\FreeBasic\bin\win64\as.exe --64 "_80486_emu.a64" -o "_80486_emu.o"
In my case, GAS compiler is using "AS.EXE", is automatic? or optional?
or maybe parameter are different?

Compiling with GCC is correct (in rar file downloaded, ther is one BAT to compile with GCC fine)

Look output asm:

Code: Select all

   mov r11, QWORD PTR TOP$[rip+0]
   and r11, 7
   shl r11, 3
   lea r8, STD$[rip+0]  #NO_OPTIM
   cvtsd2ss xmm0, [r8+r11]
#O3movd r10d, xmm0
   #O3mov -116[rbp], r10d
#O3movss -116[rbp], xmm0 #Optim 3

   FOUND AN ERROR : in check_optim mov unkonwn=mov   (THIS LINE IS 57481 IN MY OUTPUT LOG)

   #O3mov ecx, -116[rbp]
   mov ecx,  #Optim 3
   call SETEAL$ #NO_ALL
   mov rax, -7
   add QWORD PTR CYCLES$[rip+0], rax
   jmp .Lt_2C41
   jmp .Lt_2C71
   .Lt_2C78:
   mov r11, QWORD PTR TOP$[rip+0]
   and r11, 7
   shl r11, 3
   lea r8, STD$[rip+0]  #NO_OPTIM
   cvtsd2ss xmm0, [r8+r11]
#O3movd r10d, xmm0
   #O3mov -116[rbp], r10d
#O3movss -116[rbp], xmm0 #Optim 3

   FOUND AN ERROR : in check_optim mov unkonwn=mov    (THIS LINE IS 57497 IN MY OUTPUT LOG)

   #O3mov ecx, -116[rbp]
   mov ecx,  #Optim 3
   call SETEAL$ #NO_ALL
   cmp QWORD PTR ABRT$[rip+0], 0
   je .Lt_2C7A
   jmp .Lt_2C41
   .Lt_2C7A:
 

Maybe, i go to try compile your gas source, for locate error by myself...


[edit]: i got compiled gas64 from your sources, and discover that (maybe) is missing another case in file "ir-gas64.bas", line 553, some like this:

Code: Select all

            ''xmm register ?
            elseif prevpart2[0]=asc("x") then
                asm_info("OPTIMIZATION 3")
                mid(ctx.proc_txt,prevwpos)="#O3"

                if prevmov="movq" then
                    if instr(part2,"[") then
                        mov="movsd"
                    else
                        mov="movq"
                    end if
                elseif prevmov="movd" then
                    if part1[0]=asc("r") or part1[0]=asc("e") then
                       mov="movd"
                    else
                       mov="movss"
                    end If
                elseif prevmov="movss" Then
                     mov="movd"
                Else
                    asm_error("in check_optim mov unkonwn="+mov)
                end if
In order to test it, did make this missing case and all works.
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by SARG »

Hi jepalza,

Yesterday I did a mistake. There is a typo in the error message ' in check_optim mov unkonwn=mov' and I searched with the correct word 'unknown' so nothing found.....

However I can't explain why the fbc compilation fails. Due to the compilation failure the assembly is not launched so the line with as.exe is missing.

Regarding the error you reported (and that I see now) an issue in the optimizer, it should not be hard to fix. ;-)
jepalza
Posts: 149
Joined: Feb 24, 2010 10:08
Location: Spain (Bilbao)

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by jepalza »

Ok, at same time you and me, we are writing in forum. i Did locate the fail, and solution can be easy, only add antoher case in "xmm register" of "ir-gas64.bas", line 553 aprox. , new case for "movss" instruction.
SARG wrote: Yesterday I did a mistake. There is a typo in the error message ' in check_optim mov unkonwn=mov' and I searched with the correct word 'unknown' so nothing found.....
Jaja, ok, did see it "unkonw".... , jaja, very difficult to locate it, if searching correct "unknown"
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by SARG »

It's not so simple. Adding elseif removes the error but a memory update stays wrongly commented so not good. Anyway thanks for the help.

Code: Select all

 cvtsd2ss xmm0, [r8+r11]
#O3movd r10d, xmm0
   #O3mov -116[rbp], r10d
#O3movss -116[rbp], xmm0 #Optim 3  <----  erroneus commented line
   movss ecx, xmm0
   call SETEAL #NO_ALL
In fact a test to skip this optimization (like that one just above for integer registers) is not complete. Add 'and instr(prevpart1,"[")=0' and all is good.

Code: Select all

 ''xmm register ?
elseif prevpart2[0]=asc("x") and instr(prevpart1,"[")=0 then

Btw in my optimization todo list this case will be handle to use the register not the memory.

Code: Select all

   movss -116[rbp], xmm0
   mov ecx, -116[rbp]

Code: Select all

   movss -116[rbp], xmm0 #Optim 99     <----  kept line
   #99mov ecx, -116[rbp]               <----  commented line
   
   movss ecx, xmm0					      <----  new line	
jepalza
Posts: 149
Joined: Feb 24, 2010 10:08
Location: Spain (Bilbao)

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by jepalza »

Ok, i don't know the code, is the first time that i see source code. But, with my "simple" solution, at least, it compile without errors. For testing is enought.
SARG
Posts: 1756
Joined: May 27, 2005 7:15
Location: FRANCE

Re: Gas64 (no more use of gcc, only gas) WDS / LNX

Post by SARG »

Hi all,

A new version with a lot of internal changes. Don't forget to set the option -gen gas64 when using fbc

The file contains the exes for WDS 1.07 / 1.08 and only the modifications for 1.07 not yet in github.
http://users.freebasic-portal.de/sarg/fbc64_gas64_W.zip

For 1.08 the sources (github fbc master + lastest modifications not yet included) can be found here --> https://github.com/SARG-FB/fbc/tree/gas64_rev
Post Reply