Browse Source

* fpu fixes (merged)

peter 24 years ago
parent
commit
05160462c9
5 changed files with 205 additions and 41 deletions
  1. 19 14
      compiler/Makefile
  2. 17 3
      compiler/i386/cpuasm.pas
  3. 137 7
      compiler/i386/ra386.pas
  4. 13 3
      compiler/i386/ra386int.pas
  5. 19 14
      compiler/new/Makefile

+ 19 - 14
compiler/Makefile

@@ -1,22 +1,29 @@
 #
 #
-# Don't edit, this file is generated by fpcmake v1.99.0 [2001/02/02]
+# Don't edit, this file is generated by fpcmake v1.99.0 [2001/02/20]
 #
 #
 default: all
 default: all
 override PATH:=$(subst \,/,$(PATH))
 override PATH:=$(subst \,/,$(PATH))
-PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH)))))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH=$(subst :, ,$(PATH))
+else
+SEARCHPATH=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
 ifeq ($(PWD),)
 ifeq ($(PWD),)
-PWD:=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH)))))
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
 ifeq ($(PWD),)
 ifeq ($(PWD),)
 nopwd:
 nopwd:
 	@echo You need the GNU utils package to use this Makefile!
 	@echo You need the GNU utils package to use this Makefile!
 	@echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip
 	@echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip
 	@exit
 	@exit
 else
 else
-inUnix=1
 PWD:=$(firstword $(PWD))
 PWD:=$(firstword $(PWD))
+SRCEXEEXT=
 endif
 endif
 else
 else
 PWD:=$(firstword $(PWD))
 PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
 endif
 endif
 ifndef inUnix
 ifndef inUnix
 ifeq ($(OS),Windows_NT)
 ifeq ($(OS),Windows_NT)
@@ -26,11 +33,10 @@ ifdef OS2_SHELL
 inOS2=1
 inOS2=1
 endif
 endif
 endif
 endif
-endif
-ifdef inUnix
-SRCEXEEXT=
 else
 else
-SRCEXEEXT=.exe
+ifneq ($(findstring cygwin,$(MACH_TYPE)),)
+inCygWin=1
+endif
 endif
 endif
 ifdef inUnix
 ifdef inUnix
 BATCHEXT=.sh
 BATCHEXT=.sh
@@ -46,11 +52,6 @@ PATHSEP=/
 else
 else
 PATHSEP=$(subst /,\,/)
 PATHSEP=$(subst /,\,/)
 endif
 endif
-ifdef inUnix
-SEARCHPATH=$(subst :, ,$(PATH))
-else
-SEARCHPATH=$(subst ;, ,$(PATH))
-endif
 ifdef PWD
 ifdef PWD
 BASEDIR:=$(shell $(PWD))
 BASEDIR:=$(shell $(PWD))
 else
 else
@@ -240,7 +241,7 @@ endif
 ifndef LD
 ifndef LD
 LD=ld
 LD=ld
 endif
 endif
-PPAS=$(BATCHEXT)
+PPAS=ppas$(BATCHEXT)
 ifdef inUnix
 ifdef inUnix
 LDCONFIG=ldconfig
 LDCONFIG=ldconfig
 else
 else
@@ -383,6 +384,7 @@ ifeq ($(OS_TARGET),os2)
 PPUEXT=.ppo
 PPUEXT=.ppo
 ASMEXT=.so2
 ASMEXT=.so2
 OEXT=.oo2
 OEXT=.oo2
+AOUTEXT=.out
 SMARTEXT=.so
 SMARTEXT=.so
 STATICLIBEXT=.ao2
 STATICLIBEXT=.ao2
 SHAREDLIBEXT=.dll
 SHAREDLIBEXT=.dll
@@ -818,6 +820,9 @@ endif
 	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
 	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
 	-$(DELTREE) *$(SMARTEXT)
 	-$(DELTREE) *$(SMARTEXT)
 	-$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE)
 	-$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
 .PHONY: fpc_info
 .PHONY: fpc_info
 fpc_info:
 fpc_info:
 	@$(ECHO)
 	@$(ECHO)

+ 17 - 3
compiler/i386/cpuasm.pas

@@ -725,9 +725,9 @@ begin
      { if the first is ST and the second is also a register
      { if the first is ST and the second is also a register
        it is necessarily ST1 .. ST7 }
        it is necessarily ST1 .. ST7 }
      (oper[0].reg=R_ST)) or
      (oper[0].reg=R_ST)) or
-     ((ops=1) and
+     { ((ops=1) and
       (oper[0].typ=top_reg) and
       (oper[0].typ=top_reg) and
-      (oper[0].reg in [R_ST1..R_ST7])) or
+      (oper[0].reg in [R_ST1..R_ST7]))  or}
      (ops=0) then
      (ops=0) then
       if opcode=A_FSUBR then
       if opcode=A_FSUBR then
         opcode:=A_FSUB
         opcode:=A_FSUB
@@ -745,6 +745,17 @@ begin
         opcode:=A_FDIVP
         opcode:=A_FDIVP
       else if opcode=A_FDIVP then
       else if opcode=A_FDIVP then
         opcode:=A_FDIVRP;
         opcode:=A_FDIVRP;
+   if  ((ops=1) and
+      (oper[0].typ=top_reg) and
+      (oper[0].reg in [R_ST1..R_ST7])) then
+      if opcode=A_FSUBRP then
+        opcode:=A_FSUBP
+      else if opcode=A_FSUBP then
+        opcode:=A_FSUBRP
+      else if opcode=A_FDIVRP then
+        opcode:=A_FDIVP
+      else if opcode=A_FDIVP then
+        opcode:=A_FDIVRP;
 end;
 end;
 
 
 
 
@@ -1738,7 +1749,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.10  2001-01-13 20:24:24  peter
+  Revision 1.11  2001-02-20 21:51:36  peter
+    * fpu fixes (merged)
+
+  Revision 1.10  2001/01/13 20:24:24  peter
     * fixed operand order that got mixed up for external writers after
     * fixed operand order that got mixed up for external writers after
       my previous assembler block valid instruction check
       my previous assembler block valid instruction check
 
 

+ 137 - 7
compiler/i386/ra386.pas

@@ -65,7 +65,22 @@ uses
 {$endif}
 {$endif}
   globtype,symconst,symdef,systems,types,globals,verbose,cpuasm;
   globtype,symconst,symdef,systems,types,globals,verbose,cpuasm;
 
 
+{$define ATTOP}
+{$define INTELOP}
+
+{$ifdef NORA386INT}
+  {$ifdef NOAG386NSM}
+    {$ifdef NOAG386INT}
+      {$undef INTELOP}
+    {$endif}
+  {$endif}
+{$endif}
 
 
+{$ifdef NORA386ATT}
+  {$ifdef NOAG386ATT}
+    {$undef ATTOP}
+  {$endif}
+{$endif}
 {*****************************************************************************
 {*****************************************************************************
                               Parser Helpers
                               Parser Helpers
 *****************************************************************************}
 *****************************************************************************}
@@ -417,9 +432,6 @@ begin
      { if the first is ST and the second is also a register
      { if the first is ST and the second is also a register
        it is necessarily ST1 .. ST7 }
        it is necessarily ST1 .. ST7 }
      (operands[1]^.opr.reg=R_ST)) or
      (operands[1]^.opr.reg=R_ST)) or
-     ((ops=1) and
-      (operands[1]^.opr.typ=OPR_REGISTER) and
-      (operands[1]^.opr.reg in [R_ST1..R_ST7])) or
       (ops=0)  then
       (ops=0)  then
       if opcode=A_FSUBR then
       if opcode=A_FSUBR then
         opcode:=A_FSUB
         opcode:=A_FSUB
@@ -437,6 +449,17 @@ begin
         opcode:=A_FDIVP
         opcode:=A_FDIVP
       else if opcode=A_FDIVP then
       else if opcode=A_FDIVP then
         opcode:=A_FDIVRP;
         opcode:=A_FDIVRP;
+  if  ((ops=1) and
+      (operands[1]^.opr.typ=OPR_REGISTER) and
+      (operands[1]^.opr.reg in [R_ST1..R_ST7])) then
+      if opcode=A_FSUBRP then
+        opcode:=A_FSUBP
+      else if opcode=A_FSUBP then
+        opcode:=A_FSUBRP
+      else if opcode=A_FDIVRP then
+        opcode:=A_FDIVP
+      else if opcode=A_FDIVP then
+        opcode:=A_FDIVRP;
 end;
 end;
 
 
 {*****************************************************************************
 {*****************************************************************************
@@ -464,10 +487,108 @@ begin
      as alias of FADDP
      as alias of FADDP
      and GNU AS interprets FADD without operand differently
      and GNU AS interprets FADD without operand differently
      for version 2.9.1 and 2.9.5 !! }
      for version 2.9.1 and 2.9.5 !! }
-   if (opcode=A_FADD) and (ops=0) then
+   if (ops=0) and
+      ((opcode=A_FADD) or
+       (opcode=A_FMUL) or
+       (opcode=A_FSUB) or
+       (opcode=A_FSUBR) or
+       (opcode=A_FDIV) or
+       (opcode=A_FDIVR)) then
+     begin
+       if opcode=A_FADD then
+         opcode:=A_FADDP
+       else if opcode=A_FMUL then
+         opcode:=A_FMULP
+       else if opcode=A_FSUB then
+         opcode:=A_FSUBP
+       else if opcode=A_FSUBR then
+         opcode:=A_FSUBRP
+       else if opcode=A_FDIV then
+         opcode:=A_FDIVP
+       else if opcode=A_FDIVR then
+         opcode:=A_FDIVRP;
+{$ifdef ATTOP}
+       message1(asmr_w_fadd_to_faddp,att_op2str[opcode]);
+{$else}
+  {$ifdef INTELOP}
+       message1(asmr_w_fadd_to_faddp,int_op2str[opcode]);
+  {$else}
+       message1(asmr_w_fadd_to_faddp,'fXX');
+  {$endif INTELOP}
+{$endif ATTOP}
+     end;
+
+   { GNU AS interprets FDIV without operand differently
+     for version 2.9.1 and 2.10
+     we add explicit args to it !! }
+  if (ops=0) and
+     ((opcode=A_FSUBP) or
+      (opcode=A_FSUBRP) or
+      (opcode=A_FDIVP) or
+      (opcode=A_FDIVRP) or
+      (opcode=A_FSUB) or
+      (opcode=A_FSUBR) or
+      (opcode=A_FDIV) or
+      (opcode=A_FDIVR)) then
+     begin
+{$ifdef ATTOP}
+       message1(asmr_w_adding_explicit_args_fXX,att_op2str[opcode]);
+{$else}
+  {$ifdef INTELOP}
+       message1(asmr_w_adding_explicit_args_fXX,int_op2str[opcode]);
+  {$else}
+       message1(asmr_w_adding_explicit_args_fXX,'fXX');
+  {$endif INTELOP}
+{$endif ATTOP}
+       ops:=2;
+       operands[1]^.opr.typ:=OPR_REGISTER;
+       operands[2]^.opr.typ:=OPR_REGISTER;
+       operands[1]^.opr.reg:=R_ST;
+       operands[2]^.opr.reg:=R_ST1;
+     end;
+  if (ops=1) and
+      ((operands[1]^.opr.typ=OPR_REGISTER) and
+      (operands[1]^.opr.reg in [R_ST1..R_ST7])) and
+     ((opcode=A_FSUBP) or
+      (opcode=A_FSUBRP) or
+      (opcode=A_FDIVP) or
+      (opcode=A_FDIVRP)) then
      begin
      begin
-       opcode:=A_FADDP;
-       message(asmr_w_fadd_to_faddp);
+{$ifdef ATTOP}
+       message1(asmr_w_adding_explicit_first_arg_fXX,att_op2str[opcode]);
+{$else}
+  {$ifdef INTELOP}
+       message1(asmr_w_adding_explicit_first_arg_fXX,int_op2str[opcode]);
+  {$else}
+       message1(asmr_w_adding_explicit_first_arg_fXX,'fXX');
+  {$endif INTELOP}
+{$endif ATTOP}
+       ops:=2;
+       operands[2]^.opr.typ:=OPR_REGISTER;
+       operands[2]^.opr.reg:=operands[1]^.opr.reg;
+       operands[1]^.opr.reg:=R_ST;
+     end;
+
+  if (ops=1) and
+      ((operands[1]^.opr.typ=OPR_REGISTER) and
+      (operands[1]^.opr.reg in [R_ST1..R_ST7])) and
+     ((opcode=A_FSUB) or
+      (opcode=A_FSUBR) or
+      (opcode=A_FDIV) or
+      (opcode=A_FDIVR)) then
+     begin
+{$ifdef ATTOP}
+       message1(asmr_w_adding_explicit_second_arg_fXX,att_op2str[opcode]);
+{$else}
+  {$ifdef INTELOP}
+       message1(asmr_w_adding_explicit_second_arg_fXX,int_op2str[opcode]);
+  {$else}
+       message1(asmr_w_adding_explicit_second_arg_fXX,'fXX');
+  {$endif INTELOP}
+{$endif ATTOP}
+       ops:=2;
+       operands[2]^.opr.typ:=OPR_REGISTER;
+       operands[2]^.opr.reg:=R_ST;
      end;
      end;
 
 
    { I tried to convince Linus Torwald to add
    { I tried to convince Linus Torwald to add
@@ -500,6 +621,12 @@ begin
      end;
      end;
    end;
    end;
 
 
+  if (opcode=A_CALL) and (opsize=S_FAR) then
+    opcode:=A_LCALL;
+  if (opcode=A_JMP) and (opsize=S_FAR) then
+    opcode:=A_LJMP;
+  if (opcode=A_LCALL) or (opcode=A_LJMP) then
+    opsize:=S_FAR;
  { Condition ? }
  { Condition ? }
   if condition<>C_None then
   if condition<>C_None then
    ai.SetCondition(condition);
    ai.SetCondition(condition);
@@ -518,7 +645,10 @@ end;
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.5  2001-01-12 19:18:42  peter
+  Revision 1.6  2001-02-20 21:51:36  peter
+    * fpu fixes (merged)
+
+  Revision 1.5  2001/01/12 19:18:42  peter
     * check for valid asm instructions
     * check for valid asm instructions
 
 
   Revision 1.4  2000/12/25 00:07:34  peter
   Revision 1.4  2000/12/25 00:07:34  peter

+ 13 - 3
compiler/i386/ra386int.pas

@@ -1605,6 +1605,7 @@ Procedure T386IntelInstruction.BuildOpCode;
 var
 var
   PrefixOp,OverrideOp: tasmop;
   PrefixOp,OverrideOp: tasmop;
   size : topsize;
   size : topsize;
+  lasttoken : tasmtoken;
   operandnum : longint;
   operandnum : longint;
 Begin
 Begin
   PrefixOp:=A_None;
   PrefixOp:=A_None;
@@ -1727,9 +1728,15 @@ Begin
       AS_FAR :
       AS_FAR :
         Begin
         Begin
           if actasmtoken = AS_NEAR then
           if actasmtoken = AS_NEAR then
-            Message(asmr_w_near_ignored)
+            begin
+              Message(asmr_w_near_ignored);
+              opsize:=S_NEAR;
+            end
           else
           else
-            Message(asmr_w_far_ignored);
+            begin
+              Message(asmr_w_far_ignored);
+              opsize:=S_FAR;
+            end;
           Consume(actasmtoken);
           Consume(actasmtoken);
           if actasmtoken=AS_PTR then
           if actasmtoken=AS_PTR then
            begin
            begin
@@ -1943,7 +1950,10 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.8  2001-02-09 23:42:49  peter
+  Revision 1.9  2001-02-20 21:51:36  peter
+    * fpu fixes (merged)
+
+  Revision 1.8  2001/02/09 23:42:49  peter
     * merged fix for bug 1327
     * merged fix for bug 1327
 
 
   Revision 1.7  2001/01/05 17:36:58  florian
   Revision 1.7  2001/01/05 17:36:58  florian

+ 19 - 14
compiler/new/Makefile

@@ -1,22 +1,29 @@
 #
 #
-# Don't edit, this file is generated by fpcmake v1.99.0 [2001/02/02]
+# Don't edit, this file is generated by fpcmake v1.99.0 [2001/02/20]
 #
 #
 default: all
 default: all
 override PATH:=$(subst \,/,$(PATH))
 override PATH:=$(subst \,/,$(PATH))
-PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(subst ;, ,$(PATH)))))
+ifeq ($(findstring ;,$(PATH)),)
+inUnix=1
+SEARCHPATH=$(subst :, ,$(PATH))
+else
+SEARCHPATH=$(subst ;, ,$(PATH))
+endif
+PWD:=$(strip $(wildcard $(addsuffix /pwd.exe,$(SEARCHPATH))))
 ifeq ($(PWD),)
 ifeq ($(PWD),)
-PWD:=$(strip $(wildcard $(addsuffix /pwd,$(subst :, ,$(PATH)))))
+PWD:=$(strip $(wildcard $(addsuffix /pwd,$(SEARCHPATH))))
 ifeq ($(PWD),)
 ifeq ($(PWD),)
 nopwd:
 nopwd:
 	@echo You need the GNU utils package to use this Makefile!
 	@echo You need the GNU utils package to use this Makefile!
 	@echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip
 	@echo Get ftp://ftp.freepascal.org/pub/fpc/dist/go32v2/utilgo32.zip
 	@exit
 	@exit
 else
 else
-inUnix=1
 PWD:=$(firstword $(PWD))
 PWD:=$(firstword $(PWD))
+SRCEXEEXT=
 endif
 endif
 else
 else
 PWD:=$(firstword $(PWD))
 PWD:=$(firstword $(PWD))
+SRCEXEEXT=.exe
 endif
 endif
 ifndef inUnix
 ifndef inUnix
 ifeq ($(OS),Windows_NT)
 ifeq ($(OS),Windows_NT)
@@ -26,11 +33,10 @@ ifdef OS2_SHELL
 inOS2=1
 inOS2=1
 endif
 endif
 endif
 endif
-endif
-ifdef inUnix
-SRCEXEEXT=
 else
 else
-SRCEXEEXT=.exe
+ifneq ($(findstring cygwin,$(MACH_TYPE)),)
+inCygWin=1
+endif
 endif
 endif
 ifdef inUnix
 ifdef inUnix
 BATCHEXT=.sh
 BATCHEXT=.sh
@@ -46,11 +52,6 @@ PATHSEP=/
 else
 else
 PATHSEP=$(subst /,\,/)
 PATHSEP=$(subst /,\,/)
 endif
 endif
-ifdef inUnix
-SEARCHPATH=$(subst :, ,$(PATH))
-else
-SEARCHPATH=$(subst ;, ,$(PATH))
-endif
 ifdef PWD
 ifdef PWD
 BASEDIR:=$(shell $(PWD))
 BASEDIR:=$(shell $(PWD))
 else
 else
@@ -233,7 +234,7 @@ endif
 ifndef LD
 ifndef LD
 LD=ld
 LD=ld
 endif
 endif
-PPAS=$(BATCHEXT)
+PPAS=ppas$(BATCHEXT)
 ifdef inUnix
 ifdef inUnix
 LDCONFIG=ldconfig
 LDCONFIG=ldconfig
 else
 else
@@ -376,6 +377,7 @@ ifeq ($(OS_TARGET),os2)
 PPUEXT=.ppo
 PPUEXT=.ppo
 ASMEXT=.so2
 ASMEXT=.so2
 OEXT=.oo2
 OEXT=.oo2
+AOUTEXT=.out
 SMARTEXT=.so
 SMARTEXT=.so
 STATICLIBEXT=.ao2
 STATICLIBEXT=.ao2
 SHAREDLIBEXT=.dll
 SHAREDLIBEXT=.dll
@@ -811,6 +813,9 @@ endif
 	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
 	-$(DEL) *$(OEXT) *$(PPUEXT) *$(RSTEXT) *$(ASMEXT) *$(STATICLIBEXT) *$(SHAREDLIBEXT) *$(PPLEXT)
 	-$(DELTREE) *$(SMARTEXT)
 	-$(DELTREE) *$(SMARTEXT)
 	-$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE)
 	-$(DEL) $(FPCMADE) $(PPAS) link.res $(FPCEXTFILE) $(REDIRFILE)
+ifdef AOUTEXT
+	-$(DEL) *$(AOUTEXT)
+endif
 .PHONY: fpc_info
 .PHONY: fpc_info
 fpc_info:
 fpc_info:
 	@$(ECHO)
 	@$(ECHO)